Browse code

- carrierroute use autogenerated DB infrastructure - adapt configuration, move some descriptions to DB scheme

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@4872 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt authored on 09/09/2008 15:39:38
Showing 10 changed files
... ...
@@ -30,43 +30,15 @@ Henning Westerholt
30 30
 
31 31
         1.3. Exported Parameters
32 32
 
33
-              1.3.1. db_url (string)
34
-              1.3.2. db_table (string)
35
-              1.3.3. id_column (string)
36
-              1.3.4. carrier_column (string)
37
-              1.3.5. scan_prefix_column (string)
38
-              1.3.6. domain_column (string)
39
-              1.3.7. flags_column (string)
40
-              1.3.8. mask_column (string)
41
-              1.3.9. prob_column (string)
42
-              1.3.10. rewrite_host_column (string)
43
-              1.3.11. strip_column (string)
44
-              1.3.12. comment_column (string)
45
-              1.3.13. carrier_table (string)
46
-              1.3.14. rewrite_prefix_column (string)
47
-              1.3.15. rewrite_suffix_column (string)
48
-              1.3.16. carrier_id_col (string)
49
-              1.3.17. carrier_name_col (string)
50
-              1.3.18. subscriber_table (string)
51
-              1.3.19. subscriber_user_col (string)
52
-              1.3.20. subscriber_domain_col (string)
53
-              1.3.21. subscriber_carrier_col (string)
54
-              1.3.22. config_source (string)
55
-              1.3.23. config_file (string)
56
-              1.3.24. default_tree (string)
57
-              1.3.25. use_domain (int)
58
-              1.3.26. fallback_default (int)
59
-              1.3.27. db_failure_table (string)
60
-              1.3.28. failure_id_column (string)
61
-              1.3.29. failure_carrier_column (string)
62
-              1.3.30. failure_scan_prefix_column (string)
63
-              1.3.31. failure_domain_column (string)
64
-              1.3.32. failure_host_name_column (string)
65
-              1.3.33. failure_reply_code_column (string)
66
-              1.3.34. failure_flags_column (string)
67
-              1.3.35. failure_mask_column (string)
68
-              1.3.36. failure_next_domain_column (string)
69
-              1.3.37. failure_comment_column (string)
33
+              1.3.1. subscriber_table (string)
34
+              1.3.2. subscriber_user_col (string)
35
+              1.3.3. subscriber_domain_col (string)
36
+              1.3.4. subscriber_carrier_col (string)
37
+              1.3.5. config_source (string)
38
+              1.3.6. config_file (string)
39
+              1.3.7. default_tree (string)
40
+              1.3.8. use_domain (int)
41
+              1.3.9. fallback_default (int)
70 42
 
71 43
         1.4. Exported Functions
72 44
 
... ...
@@ -96,62 +68,93 @@ Henning Westerholt
96 68
 
97 69
               1.7.1. Database setup
98 70
 
71
+   2. Module parameter for database access.
72
+
73
+        2.1. db_url (String)
74
+        2.2. carrierroute_table (String)
75
+        2.3. carrierroute_id_col (string)
76
+        2.4. carrierroute_carrier_col (string)
77
+        2.5. carrierroute_domain_col (string)
78
+        2.6. carrierroute_scan_prefix_col (string)
79
+        2.7. carrierroute_flags_col (string)
80
+        2.8. carrierroute_mask_col (string)
81
+        2.9. carrierroute_prob_col (string)
82
+        2.10. carrierroute_strip_col (string)
83
+        2.11. carrierroute_rewrite_host_col (string)
84
+        2.12. carrierroute_rewrite_prefix_col (string)
85
+        2.13. carrierroute_rewrite_suffix_col (string)
86
+        2.14. carrierroute_description_col (string)
87
+        2.15. carrierfailureroute_table (String)
88
+        2.16. carrierfailureroute_id_col (string)
89
+        2.17. carrierfailureroute_carrier_col (string)
90
+        2.18. carrierfailureroute_domain_col (string)
91
+        2.19. carrierfailureroute_scan_prefix_col (string)
92
+        2.20. carrierfailureroute_host_name_col (string)
93
+        2.21. carrierfailureroute_reply_code_col (string)
94
+        2.22. carrierfailureroute_flags_col (string)
95
+        2.23. carrierfailureroute_mask_col (string)
96
+        2.24. carrierfailureroute_next_domain_col (string)
97
+        2.25. carrierfailureroute_description_col (string)
98
+        2.26. route_tree_table (String)
99
+        2.27. route_tree_id_col (string)
100
+        2.28. route_tree_carrier_col (string)
101
+
99 102
    List of Examples
100 103
 
101
-   1.1. Set db_url parameter
102
-   1.2. Set db_table parameter
103
-   1.3. Set id_column parameter
104
-   1.4. Set carrier_column parameter
105
-   1.5. Set scan_prefix_column parameter
106
-   1.6. Set domain_column parameter
107
-   1.7. Set flags_column parameter
108
-   1.8. Set mask_column parameter
109
-   1.9. Set prob_column parameter
110
-   1.10. Set rewrite_host_column parameter
111
-   1.11. Set strip_column parameter
112
-   1.12. Set comment_column parameter
113
-   1.13. Set carrier_table parameter
114
-   1.14. Set rewrite_prefix_column parameter
115
-   1.15. Set rewrite_suffix_column parameter
116
-   1.16. Set id_col parameter
117
-   1.17. Set carrier_name_col parameter
118
-   1.18. Set subscriber_table parameter
119
-   1.19. Set subscriber_user_col parameter
120
-   1.20. Set subscriber_domain_col parameter
121
-   1.21. Set subscriber_carrier_col parameter
122
-   1.22. Set config_source parameter
123
-   1.23. Set config_file parameter
124
-   1.24. Set default_tree parameter
125
-   1.25. Set use_domain parameter
126
-   1.26. Set fallback_default parameter
127
-   1.27. Set db_failuretable parameter
128
-   1.28. Set failure_id_column parameter
129
-   1.29. Set failure_carrier_column parameter
130
-   1.30. Set failure_scan_prefix_column parameter
131
-   1.31. Set failure_domain_column parameter
132
-   1.32. Set failure_host_name_column parameter
133
-   1.33. Set failure_reply_code_column parameter
134
-   1.34. Set failure_flags_column parameter
135
-   1.35. Set failure_mask_column parameter
136
-   1.36. Set failure_next_domain_column parameter
137
-   1.37. Set failure_comment_column parameter
138
-   1.38. cr_replace_host usage
139
-   1.39. cr_deactivate_host usage
140
-   1.40. cr_activate_host usage
141
-   1.41. cr_add_host usage
142
-   1.42. cr_delete_host usage
143
-   1.43. Configuration example - Routing to default tree
144
-   1.44. Configuration example - Routing to user tree
145
-   1.45. Configuration example - module configuration
146
-   1.46. Example database content - carrierroute table
147
-   1.47. Example database content - simple carrierfailureroute
104
+   1.1. Set subscriber_table parameter
105
+   1.2. Set subscriber_user_col parameter
106
+   1.3. Set subscriber_domain_col parameter
107
+   1.4. Set subscriber_carrier_col parameter
108
+   1.5. Set config_source parameter
109
+   1.6. Set config_file parameter
110
+   1.7. Set default_tree parameter
111
+   1.8. Set use_domain parameter
112
+   1.9. Set fallback_default parameter
113
+   1.10. cr_replace_host usage
114
+   1.11. cr_deactivate_host usage
115
+   1.12. cr_activate_host usage
116
+   1.13. cr_add_host usage
117
+   1.14. cr_delete_host usage
118
+   1.15. Configuration example - Routing to default tree
119
+   1.16. Configuration example - Routing to user tree
120
+   1.17. Configuration example - module configuration
121
+   1.18. Example database content - carrierroute table
122
+   1.19. Example database content - simple carrierfailureroute
148 123
           table
149 124
 
150
-   1.48. Example database content - more complex
125
+   1.20. Example database content - more complex
151 126
           carrierfailureroute table
152 127
 
153
-   1.49. Example database content - route_tree table
154
-   1.50. Necessary extensions for the user table
128
+   1.21. Example database content - route_tree table
129
+   1.22. Necessary extensions for the user table
130
+   2.1. Set db_url parameter
131
+   2.2. Set carrierroute_table parameter
132
+   2.3. Set carrierroute_id_col parameter
133
+   2.4. Set carrierroute_carrier_col parameter
134
+   2.5. Set carrierroute_domain_col parameter
135
+   2.6. Set carrierroute_scan_prefix_col parameter
136
+   2.7. Set carrierroute_flags_col parameter
137
+   2.8. Set carrierroute_mask_col parameter
138
+   2.9. Set carrierroute_prob_col parameter
139
+   2.10. Set carrierroute_strip_col parameter
140
+   2.11. Set carrierroute_rewrite_host_col parameter
141
+   2.12. Set carrierroute_rewrite_prefix_col parameter
142
+   2.13. Set carrierroute_rewrite_suffix_col parameter
143
+   2.14. Set carrierroute_description_col parameter
144
+   2.15. Set carrierfailureroute_table parameter
145
+   2.16. Set carrierfailureroute_id_col parameter
146
+   2.17. Set carrierfailureroute_carrier_col parameter
147
+   2.18. Set carrierfailureroute_domain_col parameter
148
+   2.19. Set carrierfailureroute_scan_prefix_col parameter
149
+   2.20. Set carrierfailureroute_host_name_col parameter
150
+   2.21. Set carrierfailureroute_reply_code_col parameter
151
+   2.22. Set carrierfailureroute_flags_col parameter
152
+   2.23. Set carrierfailureroute_mask_col parameter
153
+   2.24. Set carrierfailureroute_next_domain_col parameter
154
+   2.25. Set carrierfailureroute_description_col parameter
155
+   2.26. Set route_tree_table parameter
156
+   2.27. Set route_tree_id_col parameter
157
+   2.28. Set route_tree_carrier_col parameter
155 158
 
156 159
 Chapter 1. Admin Guide
157 160
 
... ...
@@ -235,323 +238,103 @@ Chapter 1. Admin Guide
235 238
 
236 239
 1.3. Exported Parameters
237 240
 
238
-1.3.1. db_url (string)
239
-
240
-   Url to the database containing the routing data.
241
-
242
-   Default value is
243
-   "mysql://openserro:openserro@localhost/openser".
244
-
245
-   Example 1.1. Set db_url parameter
246
-...
247
-modparam("carrierroute", "db_url", "dbdriver://username:password@dbhost/
248
-dbname")
249
-...
250
-
251
-1.3.2. db_table (string)
252
-
253
-   Name of the table where the routing data is stored.
254
-
255
-   Default value is "carrierroute".
256
-
257
-   Example 1.2. Set db_table parameter
258
-...
259
-modparam("carrierroute", "db_table", "carrierroute")
260
-...
261
-
262
-1.3.3. id_column (string)
263
-
264
-   Name of the column containing the id identifier.
265
-
266
-   Default value is "id".
267
-
268
-   Example 1.3. Set id_column parameter
269
-...
270
-modparam("carrierroute", "id_column", "id")
271
-...
272
-
273
-1.3.4. carrier_column (string)
274
-
275
-   Name of the column containing the carrier id.
276
-
277
-   Default value is "carrier".
278
-
279
-   Example 1.4. Set carrier_column parameter
280
-...
281
-modparam("carrierroute", "carrier_column", "carrier")
282
-...
283
-
284
-1.3.5. scan_prefix_column (string)
285
-
286
-   Name of column containing the scan prefixes. Scan prefixes
287
-   define the matching portion of a phone number, e.g. when we
288
-   have the scan prefixes 49721 and 49, the called number is
289
-   49721913740, it matches 49721, because the longest match is
290
-   taken. If no prefix matches, the number is not routed. To
291
-   prevent this, an empty prefix value of "" could be added.
292
-
293
-   Default value is "scan_prefix".
294
-
295
-   Example 1.5. Set scan_prefix_column parameter
296
-...
297
-modparam("carrierroute", "scan_prefix_column", "scan_prefix")
298
-...
299
-
300
-1.3.6. domain_column (string)
301
-
302
-   Name of column containing the rule domain. You can define
303
-   several routing domains to have different routing rules. Maybe
304
-   you use domain 0 for normal routing and domain 1 if domain 0
305
-   failed.
306
-
307
-   Default value is "domain".
308
-
309
-   Example 1.6. Set domain_column parameter
310
-...
311
-modparam("carrierroute", "domain_column", "domain")
312
-...
313
-
314
-1.3.7. flags_column (string)
315
-
316
-   Name of the column containing the flags.
317
-
318
-   Default value is "flags".
319
-
320
-   Example 1.7. Set flags_column parameter
321
-...
322
-modparam("carrierroute", "flags_column", "flags")
323
-...
324
-
325
-1.3.8. mask_column (string)
326
-
327
-   Name of the column containing the flags mask.
328
-
329
-   Default value is "mask".
330
-
331
-   Example 1.8. Set mask_column parameter
332
-...
333
-modparam("carrierroute", "mask_column", "mask")
334
-...
335
-
336
-1.3.9. prob_column (string)
337
-
338
-   Name of column containing probability. The probability value is
339
-   used to distribute the traffic between several gateways. Let's
340
-   say 70 % of the traffic shall be routed to gateway A, the other
341
-   30 % shall be routed to gateway B, we define a rule for gateway
342
-   A with a prob value of 0.7 and a rule for gateway B with a prob
343
-   value of 0.3.
344
-
345
-   If all probabilities for a given prefix, tree and domain don't
346
-   add to 100%, the prefix values will be adjusted according the
347
-   given prob values. E.g. if three hosts with prob values of 0.5,
348
-   0.5 and 0.4 are defined, the resulting probabilities are
349
-   35.714, 35.714 and 28.571%. But its better to choose meaningful
350
-   values in the first place because of clarity.
351
-
352
-   Default value is "prob".
353
-
354
-   Example 1.9. Set prob_column parameter
355
-...
356
-modparam("carrierroute", "prob_column", "prob")
357
-...
358
-
359
-1.3.10. rewrite_host_column (string)
360
-
361
-   Name of column containing rewrite host value. An empty field
362
-   represents a blacklist entry, anything else is put as domain
363
-   part into the Request URI of the SIP message.
364
-
365
-   Default value is "rewrite_host".
366
-
367
-   Example 1.10. Set rewrite_host_column parameter
368
-...
369
-modparam("carrierroute", "rewrite_host_column", "rewrite_host")
370
-...
371
-
372
-1.3.11. strip_column (string)
373
-
374
-   Name of the column containing the number of digits to be
375
-   stripped of the userpart of an URI before prepending
376
-   rewrite_prefix.
377
-
378
-   Default value is "strip".
379
-
380
-   Example 1.11. Set strip_column parameter
381
-...
382
-modparam("carrierroute", "strip_column", "strip")
383
-...
384
-
385
-1.3.12. comment_column (string)
386
-
387
-   Name of the column containing an optional comment (useful in
388
-   large routing tables) The comment is also displayed by the fifo
389
-   cmd "cr_dump_routes".
390
-
391
-   Default value is "description".
392
-
393
-   Example 1.12. Set comment_column parameter
394
-...
395
-modparam("carrierroute", "comment_column", "description")
396
-...
397
-
398
-1.3.13. carrier_table (string)
399
-
400
-   The name of the table containing the existing carriers,
401
-   consisting of the ids and corresponding names.
402
-
403
-   Default value is "route_tree".
404
-
405
-   Example 1.13. Set carrier_table parameter
406
-...
407
-modparam("carrierroute", "carrier_table", "route_tree")
408
-...
409
-
410
-1.3.14. rewrite_prefix_column (string)
411
-
412
-   Name of column containing rewrite prefixes. Here you can define
413
-   a rewrite prefix for the localpart of the SIP URI.
414
-
415
-   Default value is "rewrite_prefix".
416
-
417
-   Example 1.14. Set rewrite_prefix_column parameter
418
-...
419
-modparam("carrierroute", "rewrite_prefix_column", "rewrite_prefix")
420
-...
421
-
422
-1.3.15. rewrite_suffix_column (string)
423
-
424
-   Name of column containing rewrite suffixes. Here you can define
425
-   a rewrite suffix for the localpart of the SIP URI.
426
-
427
-   Default value is "rewrite_suffix".
428
-
429
-   Example 1.15. Set rewrite_suffix_column parameter
430
-                            ...
431
-modparam("carrierroute", "rewrite_suffix_column", "rewrite_suffix")
432
-                            ...
433
-
434
-1.3.16. carrier_id_col (string)
435
-
436
-   The name of the column in the carrier table containing the
437
-   carrier id.
438
-
439
-   Default value is "id".
440
-
441
-   Example 1.16. Set id_col parameter
442
-...
443
-modparam("carrierroute", "carrier_id_col", "id")
444
-...
445
-
446
-1.3.17. carrier_name_col (string)
447
-
448
-   The name of the column in the carrier table containing the
449
-   carrier name.
450
-
451
-   Default value is "carrier".
452
-
453
-   Example 1.17. Set carrier_name_col parameter
454
-...
455
-modparam("carrierroute", "carrier_name_col", "carrier")
456
-...
457
-
458
-1.3.18. subscriber_table (string)
241
+1.3.1. subscriber_table (string)
459 242
 
460 243
    The name of the table containing the subscribers
461 244
 
462 245
    Default value is "subscriber".
463 246
 
464
-   Example 1.18. Set subscriber_table parameter
247
+   Example 1.1. Set subscriber_table parameter
465 248
 ...
466 249
 modparam("carrierroute", "subscriber_table", "subscriber")
467 250
 ...
468 251
 
469
-1.3.19. subscriber_user_col (string)
252
+1.3.2. subscriber_user_col (string)
470 253
 
471 254
    The name of the column in the subscriber table containing the
472 255
    usernames.
473 256
 
474 257
    Default value is "username".
475 258
 
476
-   Example 1.19. Set subscriber_user_col parameter
259
+   Example 1.2. Set subscriber_user_col parameter
477 260
 ...
478 261
 modparam("carrierroute", "subscriber_user_col", "username")
479 262
 ...
480 263
 
481
-1.3.20. subscriber_domain_col (string)
264
+1.3.3. subscriber_domain_col (string)
482 265
 
483 266
    The name of the column in the subscriber table containing the
484 267
    domain of the subscriber.
485 268
 
486 269
    Default value is "domain".
487 270
 
488
-   Example 1.20. Set subscriber_domain_col parameter
271
+   Example 1.3. Set subscriber_domain_col parameter
489 272
 ...
490 273
 modparam("carrierroute", "subscriber_domain_col", "domain")
491 274
 ...
492 275
 
493
-1.3.21. subscriber_carrier_col (string)
276
+1.3.4. subscriber_carrier_col (string)
494 277
 
495 278
    The name of the column in the subscriber table containing the
496 279
    carrier id of the subscriber.
497 280
 
498 281
    Default value is "cr_preferred_carrier".
499 282
 
500
-   Example 1.21. Set subscriber_carrier_col parameter
283
+   Example 1.4. Set subscriber_carrier_col parameter
501 284
 ...
502 285
 modparam("carrierroute", "subscriber_carrier_col", "cr_preferred_carrier
503 286
 ")
504 287
 ...
505 288
 
506
-1.3.22. config_source (string)
289
+1.3.5. config_source (string)
507 290
 
508 291
    Specifies whether the module loads its config data from a file
509 292
    or from a database. Possible values are file or db.
510 293
 
511 294
    Default value is "file".
512 295
 
513
-   Example 1.22. Set config_source parameter
296
+   Example 1.5. Set config_source parameter
514 297
 ...
515 298
 modparam("carrierroute", "config_source", "file")
516 299
 ...
517 300
 
518
-1.3.23. config_file (string)
301
+1.3.6. config_file (string)
519 302
 
520 303
    Specifies the path to the config file.
521 304
 
522 305
    Default value is "/etc/kamailio/carrierroute.conf".
523 306
 
524
-   Example 1.23. Set config_file parameter
307
+   Example 1.6. Set config_file parameter
525 308
 ...
526 309
 modparam("carrierroute", "config_file", "/etc/kamailio/carrierroute.conf
527 310
 ")
528 311
 ...
529 312
 
530
-1.3.24. default_tree (string)
313
+1.3.7. default_tree (string)
531 314
 
532 315
    The name of the carrier tree used per default (if the current
533 316
    subscriber has no preferred tree)
534 317
 
535 318
    Default value is "default".
536 319
 
537
-   Example 1.24. Set default_tree parameter
320
+   Example 1.7. Set default_tree parameter
538 321
 ...
539 322
 modparam("carrierroute", "default_tree", "default")
540 323
 ...
541 324
 
542
-1.3.25. use_domain (int)
325
+1.3.8. use_domain (int)
543 326
 
544 327
    When using tree lookup per user, this parameter specifies
545 328
    whether to use the domain part for user matching or not.
546 329
 
547 330
    Default value is "0".
548 331
 
549
-   Example 1.25. Set use_domain parameter
332
+   Example 1.8. Set use_domain parameter
550 333
 ...
551 334
 modparam("carrierroute", "use_domain", 0)
552 335
 ...
553 336
 
554
-1.3.26. fallback_default (int)
337
+1.3.9. fallback_default (int)
555 338
 
556 339
    This parameter defines the behaviour when using user-based tree
557 340
    lookup. If the user has a non-existing tree set and
... ...
@@ -560,141 +343,11 @@ modparam("carrierroute", "use_domain", 0)
560 343
 
561 344
    Default value is "1".
562 345
 
563
-   Example 1.26. Set fallback_default parameter
346
+   Example 1.9. Set fallback_default parameter
564 347
 ...
565 348
 modparam("carrierroute", "fallback_default", 1)
566 349
 ...
567 350
 
568
-1.3.27. db_failure_table (string)
569
-
570
-   Name of the table where the failure routing data is stored.
571
-
572
-   Default value is "carrierfailureroute".
573
-
574
-   Example 1.27. Set db_failuretable parameter
575
-...
576
-modparam("carrierroute", "db_failuretable", "carrierfailureroute")
577
-...
578
-
579
-1.3.28. failure_id_column (string)
580
-
581
-   Name of the column containing the id identifier.
582
-
583
-   Default value is "id".
584
-
585
-   Example 1.28. Set failure_id_column parameter
586
-...
587
-modparam("carrierroute", "failure_id_column", "id")
588
-...
589
-
590
-1.3.29. failure_carrier_column (string)
591
-
592
-   Name of the column containing the carrier id.
593
-
594
-   Default value is "carrier".
595
-
596
-   Example 1.29. Set failure_carrier_column parameter
597
-...
598
-modparam("carrierroute", "failure_carrier_column", "carrier")
599
-...
600
-
601
-1.3.30. failure_scan_prefix_column (string)
602
-
603
-   Name of column containing the scan prefixes. Scan prexies
604
-   define the matching portion of a phone number, e.g. we have the
605
-   scan prefixes 49721 and 49, the called number is 49721913740,
606
-   it matches 49721, because the longest match is taken. If no
607
-   prefix matches, the number is not failure routed. To prevent
608
-   this, an empty prefix value of "" could be added.
609
-
610
-   Default value is "scan_prefix".
611
-
612
-   Example 1.30. Set failure_scan_prefix_column parameter
613
-...
614
-modparam("carrierroute", "failure_scan_prefix_column", "scan_prefix")
615
-...
616
-
617
-1.3.31. failure_domain_column (string)
618
-
619
-   Name of column containing the rule domain. You can define
620
-   several routing domains to have different routing rules. Maybe
621
-   you use domain 0 for normal routing and domain 1 if domain 0
622
-   failed.
623
-
624
-   Default value is "domain".
625
-
626
-   Example 1.31. Set failure_domain_column parameter
627
-...
628
-modparam("carrierroute", "failure_domain_column", "domain")
629
-...
630
-
631
-1.3.32. failure_host_name_column (string)
632
-
633
-   Name of the column containing the host name of the last routing
634
-   destination.
635
-
636
-   Default value is "host_name".
637
-
638
-   Example 1.32. Set failure_host_name_column parameter
639
-...
640
-modparam("carrierroute", "failure_host_name_column", "host_name")
641
-...
642
-
643
-1.3.33. failure_reply_code_column (string)
644
-
645
-   Name of the column containing the reply code.
646
-
647
-   Default value is "reply_code".
648
-
649
-   Example 1.33. Set failure_reply_code_column parameter
650
-...
651
-modparam("carrierroute", "failure_reply_code_column", "reply_code")
652
-...
653
-
654
-1.3.34. failure_flags_column (string)
655
-
656
-   Name of the column containing the flags.
657
-
658
-   Default value is "flags".
659
-
660
-   Example 1.34. Set failure_flags_column parameter
661
-...
662
-modparam("carrierroute", "failure_flags_column", "flags")
663
-...
664
-
665
-1.3.35. failure_mask_column (string)
666
-
667
-   Name of the column containing the flags mask.
668
-
669
-   Default value is "mask".
670
-
671
-   Example 1.35. Set failure_mask_column parameter
672
-...
673
-modparam("carrierroute", "failure_mask_column", "mask")
674
-...
675
-
676
-1.3.36. failure_next_domain_column (string)
677
-
678
-   Name of the column containing the next routing domain.
679
-
680
-   Default value is "next_domain".
681
-
682
-   Example 1.36. Set failure_next_domain_column parameter
683
-...
684
-modparam("carrierroute", "failure_next_domain_column", "next_domain")
685
-...
686
-
687
-1.3.37. failure_comment_column (string)
688
-
689
-   Name of the column containing an optional comment.
690
-
691
-   Default value is "description".
692
-
693
-   Example 1.37. Set failure_comment_column parameter
694
-...
695
-modparam("carrierroute", "failure_comment_column", "description")
696
-...
697
-
698 351
 1.4. Exported Functions
699 352
 
700 353
    Previous versions of carriertree had some more function. All
... ...
@@ -879,7 +532,7 @@ reply_code, dstavp)
879 532
 
880 533
    Use the "null" prefix to specify an empty prefix.
881 534
 
882
-   Example 1.38. cr_replace_host usage
535
+   Example 1.10. cr_replace_host usage
883 536
 ...
884 537
 kamctl fifo cr_replace_host "-d proxy -p 49 -h proxy1 -t proxy2"
885 538
 ...
... ...
@@ -901,7 +554,7 @@ kamctl fifo cr_replace_host "-d proxy -p 49 -h proxy1 -t proxy2"
901 554
 
902 555
    Use the "null" prefix to specify an empty prefix.
903 556
 
904
-   Example 1.39. cr_deactivate_host usage
557
+   Example 1.11. cr_deactivate_host usage
905 558
 ...
906 559
 kamctl fifo cr_deactivate_host "-d proxy -p 49 -h proxy1"
907 560
 ...
... ...
@@ -917,7 +570,7 @@ kamctl fifo cr_deactivate_host "-d proxy -p 49 -h proxy1"
917 570
 
918 571
    Use the "null" prefix to specify an empty prefix.
919 572
 
920
-   Example 1.40. cr_activate_host usage
573
+   Example 1.12. cr_activate_host usage
921 574
 ...
922 575
 kamctl fifo cr_activate_host "-d proxy -p 49 -h proxy1"
923 576
 ...
... ...
@@ -937,7 +590,7 @@ kamctl fifo cr_activate_host "-d proxy -p 49 -h proxy1"
937 590
 
938 591
    Use the "null" prefix to specify an empty prefix.
939 592
 
940
-   Example 1.41. cr_add_host usage
593
+   Example 1.13. cr_add_host usage
941 594
 ...
942 595
 kamctl fifo cr_add_host "-d proxy -p 49 -h proxy1 -w 0.25"
943 596
 ...
... ...
@@ -958,14 +611,14 @@ kamctl fifo cr_add_host "-d proxy -p 49 -h proxy1 -w 0.25"
958 611
 
959 612
    Use the "null" prefix to specify an empty prefix.
960 613
 
961
-   Example 1.42. cr_delete_host usage
614
+   Example 1.14. cr_delete_host usage
962 615
 ...
963 616
 kamctl fifo cr_delete_host "-d proxy -p 49 -h proxy1 -w 0.25"
964 617
 ...
965 618
 
966 619
 1.6. Examples
967 620
 
968
-   Example 1.43. Configuration example - Routing to default tree
621
+   Example 1.15. Configuration example - Routing to default tree
969 622
 ...
970 623
 route {
971 624
         # route calls based on hash over callid
... ...
@@ -999,7 +652,7 @@ failure_route[2] {
999 652
 }
1000 653
 
1001 654
 
1002
-   Example 1.44. Configuration example - Routing to user tree
655
+   Example 1.16. Configuration example - Routing to user tree
1003 656
 ...
1004 657
 route[1] {
1005 658
         cr_user_carrier("$fU", "$fd", "$avp(s:carrier)");
... ...
@@ -1039,7 +692,7 @@ failure_route[1] {
1039 692
 }
1040 693
 ...
1041 694
 
1042
-   Example 1.45. Configuration example - module configuration
695
+   Example 1.17. Configuration example - module configuration
1043 696
 
1044 697
    The following config file specifies within the default carrier
1045 698
    two domains, each with an prefix that contains two hosts. It is
... ...
@@ -1119,7 +772,7 @@ domain register {
1119 772
    For a minimal configuration either use the config file given
1120 773
    above, or insert some data into the tables of the module.
1121 774
 
1122
-   Example 1.46. Example database content - carrierroute table
775
+   Example 1.18. Example database content - carrierroute table
1123 776
 ...
1124 777
 +----+---------+--------+-------------+-------+------+---------------+
1125 778
 | id | carrier | domain | scan_prefix | flags | prob | rewrite_host  |
... ...
@@ -1158,7 +811,7 @@ domain register {
1158 811
    this flags are not set, the other two rules are used. The
1159 812
    "strip", "mask" and "comment" colums are omitted for brevity.
1160 813
 
1161
-   Example 1.47. Example database content - simple
814
+   Example 1.19. Example database content - simple
1162 815
    carrierfailureroute table
1163 816
 ...
1164 817
 +----+---------+--------+---------------+------------+-------------+
... ...
@@ -1180,7 +833,7 @@ domain register {
1180 833
    corresponding entry in the carrierroute table, otherwise the
1181 834
    module will not load the routing data.
1182 835
 
1183
-   Example 1.48. Example database content - more complex
836
+   Example 1.20. Example database content - more complex
1184 837
    carrierfailureroute table
1185 838
 ...
1186 839
 +----+---------+-----------+------------+--------+-----+-------------+
... ...
@@ -1207,7 +860,7 @@ domain register {
1207 860
    holds domain entries for this routing rules. Not all table
1208 861
    colums are show here for brevity.
1209 862
 
1210
-   Example 1.49. Example database content - route_tree table
863
+   Example 1.21. Example database content - route_tree table
1211 864
 ...
1212 865
 +----+----------+
1213 866
 | id | carrier  |
... ...
@@ -1226,9 +879,298 @@ domain register {
1226 879
    that you specified as modul parameter) to choose the actual
1227 880
    carrier for the users.
1228 881
 
1229
-   Example 1.50. Necessary extensions for the user table
882
+   Example 1.22. Necessary extensions for the user table
1230 883
 
1231 884
    Suggested changes:
1232 885
 ...
1233 886
 ALTER TABLE subscriber ADD cr_preferred_carrier int(10) default NULL;
1234 887
 ...
888
+
889
+Chapter 2. Module parameter for database access.
890
+
891
+2.1. db_url (String)
892
+
893
+   URL to the database containing the data.
894
+
895
+   Default value is
896
+   "mysql://openserro:openserro@localhost/openser".
897
+
898
+   Example 2.1. Set db_url parameter
899
+...
900
+modparam("carrierroute", "db_url", "dbdriver://username:password@dbhost/
901
+dbname")
902
+...
903
+
904
+2.2. carrierroute_table (String)
905
+
906
+   Name of the carrierroute table for the carrierroute module.
907
+
908
+   Default value is "carrierroute".
909
+
910
+   Example 2.2. Set carrierroute_table parameter
911
+...
912
+modparam("carrierroute", "carrierroute_table", "carrierroute")
913
+...
914
+
915
+2.3. carrierroute_id_col (string)
916
+
917
+   unique ID
918
+
919
+   Example 2.3. Set carrierroute_id_col parameter
920
+...
921
+modparam("carrierroute", "carrierroute_id_col", "id")
922
+...
923
+
924
+2.4. carrierroute_carrier_col (string)
925
+
926
+   This column contains the carrier id.
927
+
928
+   Example 2.4. Set carrierroute_carrier_col parameter
929
+...
930
+modparam("carrierroute", "carrierroute_carrier_col", "carrier")
931
+...
932
+
933
+2.5. carrierroute_domain_col (string)
934
+
935
+   This column contains the route domain. Additional domains could
936
+   be used for example as fallback.
937
+
938
+   Example 2.5. Set carrierroute_domain_col parameter
939
+...
940
+modparam("carrierroute", "carrierroute_domain_col", "domain")
941
+...
942
+
943
+2.6. carrierroute_scan_prefix_col (string)
944
+
945
+   This column contains the scan prefix, which define the matching
946
+   portion of a phone number.
947
+
948
+   Example 2.6. Set carrierroute_scan_prefix_col parameter
949
+...
950
+modparam("carrierroute", "carrierroute_scan_prefix_col", "scan_prefix")
951
+...
952
+
953
+2.7. carrierroute_flags_col (string)
954
+
955
+   This column contains the flags used for rule matching.
956
+
957
+   Example 2.7. Set carrierroute_flags_col parameter
958
+...
959
+modparam("carrierroute", "carrierroute_flags_col", "flags")
960
+...
961
+
962
+2.8. carrierroute_mask_col (string)
963
+
964
+   This column contains the mask that is applied to the message
965
+   flags before rule matching.
966
+
967
+   Example 2.8. Set carrierroute_mask_col parameter
968
+...
969
+modparam("carrierroute", "carrierroute_mask_col", "mask")
970
+...
971
+
972
+2.9. carrierroute_prob_col (string)
973
+
974
+   Name of column containing the probability. The probability
975
+   value is used to distribute the traffic between several
976
+   gateways.
977
+
978
+   Example 2.9. Set carrierroute_prob_col parameter
979
+...
980
+modparam("carrierroute", "carrierroute_prob_col", "prob")
981
+...
982
+
983
+2.10. carrierroute_strip_col (string)
984
+
985
+   Name of the column containing the number of digits to be
986
+   stripped of the userpart of an URI before prepending
987
+   rewrite_prefix.
988
+
989
+   Example 2.10. Set carrierroute_strip_col parameter
990
+...
991
+modparam("carrierroute", "carrierroute_strip_col", "strip")
992
+...
993
+
994
+2.11. carrierroute_rewrite_host_col (string)
995
+
996
+   Name of column containing rewrite prefixes. Here you can define
997
+   a rewrite prefix for the localpart of the SIP URI.
998
+
999
+   Example 2.11. Set carrierroute_rewrite_host_col parameter
1000
+...
1001
+modparam("carrierroute", "carrierroute_rewrite_host_col", "rewrite_host"
1002
+)
1003
+...
1004
+
1005
+2.12. carrierroute_rewrite_prefix_col (string)
1006
+
1007
+   Rewrite prefix for the localpart of the SIP URI.
1008
+
1009
+   Example 2.12. Set carrierroute_rewrite_prefix_col parameter
1010
+...
1011
+modparam("carrierroute", "carrierroute_rewrite_prefix_col", "rewrite_pre
1012
+fix")
1013
+...
1014
+
1015
+2.13. carrierroute_rewrite_suffix_col (string)
1016
+
1017
+   Rewrite suffix for the localpart of the SIP URI.
1018
+
1019
+   Example 2.13. Set carrierroute_rewrite_suffix_col parameter
1020
+...
1021
+modparam("carrierroute", "carrierroute_rewrite_suffix_col", "rewrite_suf
1022
+fix")
1023
+...
1024
+
1025
+2.14. carrierroute_description_col (string)
1026
+
1027
+   A comment for the route entry, useful for larger routing
1028
+   tables.
1029
+
1030
+   Example 2.14. Set carrierroute_description_col parameter
1031
+...
1032
+modparam("carrierroute", "carrierroute_description_col", "description")
1033
+...
1034
+
1035
+2.15. carrierfailureroute_table (String)
1036
+
1037
+   Name of the carrierfailureroute table for the carrierroute
1038
+   module.
1039
+
1040
+   Default value is "carrierfailureroute".
1041
+
1042
+   Example 2.15. Set carrierfailureroute_table parameter
1043
+...
1044
+modparam("carrierroute", "carrierfailureroute_table", "carrierfailurerou
1045
+te")
1046
+...
1047
+
1048
+2.16. carrierfailureroute_id_col (string)
1049
+
1050
+   unique ID
1051
+
1052
+   Example 2.16. Set carrierfailureroute_id_col parameter
1053
+...
1054
+modparam("carrierroute", "carrierfailureroute_id_col", "id")
1055
+...
1056
+
1057
+2.17. carrierfailureroute_carrier_col (string)
1058
+
1059
+   This column contains the carrier id.
1060
+
1061
+   Example 2.17. Set carrierfailureroute_carrier_col parameter
1062
+...
1063
+modparam("carrierroute", "carrierfailureroute_carrier_col", "carrier")
1064
+...
1065
+
1066
+2.18. carrierfailureroute_domain_col (string)
1067
+
1068
+   This column contains the route domain. Additional domains could
1069
+   be used for example as fallback.
1070
+
1071
+   Example 2.18. Set carrierfailureroute_domain_col parameter
1072
+...
1073
+modparam("carrierroute", "carrierfailureroute_domain_col", "domain")
1074
+...
1075
+
1076
+2.19. carrierfailureroute_scan_prefix_col (string)
1077
+
1078
+   This column contains the scan prefix, which define the matching
1079
+   portion of a phone number.
1080
+
1081
+   Example 2.19. Set carrierfailureroute_scan_prefix_col parameter
1082
+...
1083
+modparam("carrierroute", "carrierfailureroute_scan_prefix_col", "scan_pr
1084
+efix")
1085
+...
1086
+
1087
+2.20. carrierfailureroute_host_name_col (string)
1088
+
1089
+   This column contains the routing destination used for rule
1090
+   matching.
1091
+
1092
+   Example 2.20. Set carrierfailureroute_host_name_col parameter
1093
+...
1094
+modparam("carrierroute", "carrierfailureroute_host_name_col", "host_name
1095
+")
1096
+...
1097
+
1098
+2.21. carrierfailureroute_reply_code_col (string)
1099
+
1100
+   This column contains the reply code used for rule matching.
1101
+
1102
+   Example 2.21. Set carrierfailureroute_reply_code_col parameter
1103
+...
1104
+modparam("carrierroute", "carrierfailureroute_reply_code_col", "reply_co
1105
+de")
1106
+...
1107
+
1108
+2.22. carrierfailureroute_flags_col (string)
1109
+
1110
+   This column contains the flags used for rule matching.
1111
+
1112
+   Example 2.22. Set carrierfailureroute_flags_col parameter
1113
+...
1114
+modparam("carrierroute", "carrierfailureroute_flags_col", "flags")
1115
+...
1116
+
1117
+2.23. carrierfailureroute_mask_col (string)
1118
+
1119
+   This column contains the mask that is applied to the message
1120
+   flags before rule matching.
1121
+
1122
+   Example 2.23. Set carrierfailureroute_mask_col parameter
1123
+...
1124
+modparam("carrierroute", "carrierfailureroute_mask_col", "mask")
1125
+...
1126
+
1127
+2.24. carrierfailureroute_next_domain_col (string)
1128
+
1129
+   This column contains the route domain that should be used for
1130
+   the next routing attempt.
1131
+
1132
+   Example 2.24. Set carrierfailureroute_next_domain_col parameter
1133
+...
1134
+modparam("carrierroute", "carrierfailureroute_next_domain_col", "next_do
1135
+main")
1136
+...
1137
+
1138
+2.25. carrierfailureroute_description_col (string)
1139
+
1140
+   A comment for the route entry, useful for larger routing
1141
+   tables.
1142
+
1143
+   Example 2.25. Set carrierfailureroute_description_col parameter
1144
+...
1145
+modparam("carrierroute", "carrierfailureroute_description_col", "descrip
1146
+tion")
1147
+...
1148
+
1149
+2.26. route_tree_table (String)
1150
+
1151
+   Name of the route_tree table for the carrierroute module.
1152
+
1153
+   Default value is "route_tree".
1154
+
1155
+   Example 2.26. Set route_tree_table parameter
1156
+...
1157
+modparam("carrierroute", "route_tree_table", "route_tree")
1158
+...
1159
+
1160
+2.27. route_tree_id_col (string)
1161
+
1162
+   unique ID
1163
+
1164
+   Example 2.27. Set route_tree_id_col parameter
1165
+...
1166
+modparam("carrierroute", "route_tree_id_col", "id")
1167
+...
1168
+
1169
+2.28. route_tree_carrier_col (string)
1170
+
1171
+   This column contains the carrier name.
1172
+
1173
+   Example 2.28. Set route_tree_carrier_col parameter
1174
+...
1175
+modparam("carrierroute", "route_tree_carrier_col", "carrier")
1176
+...
... ...
@@ -51,81 +51,21 @@
51 51
 #include "route_fifo.h"
52 52
 #include "carrier_tree.h"
53 53
 #include "route_func.h"
54
+#include "db_carrierroute.h"
54 55
 
55 56
 MODULE_VERSION
56 57
 
57
-str db_url = str_init(DEFAULT_RODB_URL);
58
-str db_table = str_init("carrierroute");
59
-str db_failure_table = str_init("carrierfailureroute");
58
+str carrierroute_db_url = str_init(DEFAULT_RODB_URL);
60 59
 str subscriber_table = str_init("subscriber");
61
-str carrier_table = str_init("route_tree");
62
-
63
-static str id_col = str_init("id");
64
-static str carrier_col = str_init("carrier");
65
-static str domain_col = str_init("domain");
66
-static str scan_prefix_col = str_init("scan_prefix");
67
-static str flags_col = str_init("flags");
68
-static str mask_col = str_init("mask");
69
-static str prob_col = str_init("prob");
70
-static str rewrite_host_col = str_init("rewrite_host");
71
-static str strip_col = str_init("strip");
72
-static str rewrite_prefix_col = str_init("rewrite_prefix");
73
-static str rewrite_suffix_col = str_init("rewrite_suffix");
74
-static str comment_col = str_init("description");
75
-static str username_col = str_init("username");
76
-static str cr_preferred_carrier_col = str_init("cr_preferred_carrier");
60
+
61
+static str subscriber_username_col = str_init("username");
77 62
 static str subscriber_domain_col = str_init("domain");
78
-static str carrier_id_col = str_init("id");
79
-static str carrier_name_col = str_init("carrier");
80
-static str failure_id_col = str_init("id");
81
-static str failure_carrier_col = str_init("carrier");
82
-static str failure_domain_col = str_init("domain");
83
-static str failure_scan_prefix_col = str_init("scan_prefix");
84
-static str failure_host_name_col = str_init("host_name");
85
-static str failure_reply_code_col = str_init("reply_code");
86
-static str failure_flags_col = str_init("flags");
87
-static str failure_mask_col = str_init("mask");
88
-static str failure_next_domain_col = str_init("next_domain");
89
-static str failure_comment_col = str_init("description");
90
-
91
-
92
-str * columns[COLUMN_NUM] = {
93
-	&id_col,
94
-	&carrier_col,
95
-	&domain_col,
96
-	&scan_prefix_col,
97
-	&flags_col,
98
-	&mask_col,
99
-	&prob_col,
100
-	&rewrite_host_col,
101
-	&strip_col,
102
-	&rewrite_prefix_col,
103
-	&rewrite_suffix_col,
104
-	&comment_col,
105
-};
63
+static str cr_preferred_carrier_col = str_init("cr_preferred_carrier");
106 64
 
107 65
 str * subscriber_columns[SUBSCRIBER_COLUMN_NUM] = {
108
-	&username_col,
109
-	&domain_col,
110
-	&cr_preferred_carrier_col,
111
-};
112
-
113
-str * carrier_columns[CARRIER_COLUMN_NUM] = {
114
-	&id_col,
115
-	&carrier_col,
116
-};
117
-
118
-str * failure_columns[FAILURE_COLUMN_NUM] = {
119
-	&failure_id_col,
120
-	&failure_carrier_col,
121
-	&failure_domain_col,
122
-	&failure_scan_prefix_col,
123
-	&failure_host_name_col,
124
-	&failure_reply_code_col,
125
-	&failure_flags_col,
126
-	&failure_mask_col,
127
-	&failure_next_domain_col,
128
-	&failure_comment_col
66
+	&subscriber_username_col,
67
+	&subscriber_domain_col,
68
+	&cr_preferred_carrier_col
129 69
 };
130 70
 
131 71
 char * config_source = "file";
... ...
@@ -166,38 +106,17 @@ static cmd_export_t cmds[]={
166 106
 };
167 107
 
168 108
 static param_export_t params[]= {
169
-	{"db_url",                     STR_PARAM, &db_url.s },
170
-	{"db_table",                   STR_PARAM, &db_table.s },
171
-	{"db_failure_table",           STR_PARAM, &db_failure_table.s },
172
-	{"carrier_table",              STR_PARAM, &carrier_table.s },
109
+	carrierroute_DB_URL
110
+	carrierroute_DB_TABLE
111
+	carrierfailureroute_DB_TABLE
112
+	route_tree_DB_TABLE
113
+	carrierroute_DB_COLS
114
+	carrierfailureroute_DB_COLS
115
+	route_tree_DB_COLS
173 116
 	{"subscriber_table",           STR_PARAM, &subscriber_table.s },
174
-	{"id_column",                  STR_PARAM, &id_col.s },
175
-	{"carrier_column",             STR_PARAM, &carrier_col.s },
176
-	{"domain_column",              STR_PARAM, &domain_col.s },
177
-	{"scan_prefix_column",         STR_PARAM, &scan_prefix_col.s },
178
-	{"flags_column",               STR_PARAM, &flags_col.s },
179
-	{"mask_column",                STR_PARAM, &mask_col.s },
180
-	{"prob_column",                STR_PARAM, &prob_col.s },
181
-	{"rewrite_host_column",        STR_PARAM, &rewrite_host_col.s },
182
-	{"strip_column",               STR_PARAM, &strip_col.s },
183
-	{"rewrite_prefix_column",      STR_PARAM, &rewrite_prefix_col.s },
184
-	{"rewrite_suffix_column",      STR_PARAM, &rewrite_suffix_col.s },
185
-	{"comment_column",             STR_PARAM, &comment_col.s },
186
-	{"failure_id_column",          STR_PARAM, &failure_id_col.s },
187
-	{"failure_carrier_column",     STR_PARAM, &failure_carrier_col.s },
188
-	{"failure_domain_column",      STR_PARAM, &failure_domain_col.s },
189
-	{"failure_scan_prefix_column", STR_PARAM, &failure_scan_prefix_col.s },
190
-	{"failure_host_name_column",   STR_PARAM, &failure_host_name_col.s },
191
-	{"failure_reply_code_column",  STR_PARAM, &failure_reply_code_col.s },
192
-	{"failure_flags_column",       STR_PARAM, &failure_flags_col.s },
193
-	{"failure_mask_column",        STR_PARAM, &failure_mask_col.s },
194
-	{"failure_next_domain_column", STR_PARAM, &failure_next_domain_col.s },
195
-	{"failure_comment_column",     STR_PARAM, &failure_comment_col.s },
196
-	{"subscriber_user_col",        STR_PARAM, &username_col.s },
117
+	{"subscriber_user_col",        STR_PARAM, &subscriber_username_col.s },
197 118
 	{"subscriber_domain_col",      STR_PARAM, &subscriber_domain_col.s },
198 119
 	{"subscriber_carrier_col",     STR_PARAM, &cr_preferred_carrier_col.s },
199
-	{"carrier_id_col",             STR_PARAM, &carrier_id_col.s },
200
-	{"carrier_name_col",           STR_PARAM, &carrier_name_col.s },
201 120
 	{"config_source",              STR_PARAM, &config_source },
202 121
 	{"default_tree",               STR_PARAM, &default_tree },
203 122
 	{"config_file",                STR_PARAM, &config_file },
... ...
@@ -269,39 +188,14 @@ static enum hash_source hash_fixup(const char * my_hash_source) {
269 188
  */
270 189
 static int mod_init(void) {
271 190
 
272
-	db_url.len = strlen(db_url.s);
273
-	db_table.len = strlen(db_table.s);
274
-	carrier_table.len = strlen(carrier_table.s);
275 191
 	subscriber_table.len = strlen(subscriber_table.s);
276
-	id_col.len = strlen(id_col.s);
277
-	carrier_col.len = strlen(carrier_col.s);
278
-	domain_col.len = strlen(domain_col.s);
279
-	scan_prefix_col.len = strlen(scan_prefix_col.s);
280
-	flags_col.len = strlen(flags_col.s);
281
-	mask_col.len = strlen(mask_col.s);
282
-	prob_col.len = strlen(prob_col.s);
283
-	rewrite_host_col.len = strlen(rewrite_host_col.s);
284
-	strip_col.len = strlen(strip_col.s);
285
-	rewrite_prefix_col.len = strlen(rewrite_prefix_col.s);
286
-	rewrite_suffix_col.len = strlen(rewrite_suffix_col.s);
287
-	comment_col.len = strlen(comment_col.s);
288
-	username_col.len = strlen(username_col.s);
192
+	subscriber_username_col.len = strlen(subscriber_username_col.s);
289 193
 	subscriber_domain_col.len = strlen(subscriber_domain_col.s);
290 194
 	cr_preferred_carrier_col.len = strlen(cr_preferred_carrier_col.s);
291
-	carrier_id_col.len = strlen(carrier_id_col.s);
292
-	carrier_name_col.len = strlen(carrier_name_col.s);
293
-	failure_id_col.len = strlen(failure_id_col.s);
294
-	failure_carrier_col.len = strlen(failure_carrier_col.s);
295
-	failure_domain_col.len = strlen(failure_domain_col.s);
296
-	failure_scan_prefix_col.len = strlen(failure_scan_prefix_col.s);
297
-	failure_host_name_col.len = strlen(failure_host_name_col.s);
298
-	failure_reply_code_col.len = strlen(failure_reply_code_col.s);
299
-	failure_flags_col.len = strlen(failure_flags_col.s);
300
-	failure_mask_col.len = strlen(failure_mask_col.s);
301
-	failure_next_domain_col.len = strlen(failure_next_domain_col.s);
302
-	failure_comment_col.len = strlen(failure_comment_col.s);
303 195
 	default_tree.len = strlen(default_tree.s);
304 196
 
197
+	carrierroute_db_vars();
198
+
305 199
 	if (init_route_data(config_source) < 0) {
306 200
 		LM_ERR("could not init route data\n");
307 201
 		return -1;
... ...
@@ -43,57 +43,16 @@
43 43
 
44 44
 #define DICE_MAX 1000
45 45
 
46
-#define COLUMN_NUM 12
47
-#define COL_ID             0
48
-#define COL_CARRIER        1
49
-#define COL_DOMAIN         2
50
-#define COL_SCAN_PREFIX    3
51
-#define COL_FLAGS          4
52
-#define COL_MASK           5
53
-#define COL_PROB           6
54
-#define COL_REWRITE_HOST   7
55
-#define COL_STRIP          8
56
-#define COL_REWRITE_PREFIX 9
57
-#define COL_REWRITE_SUFFIX 10
58
-#define COL_COMMENT        11
59
-
60
-#define FAILURE_COLUMN_NUM 10
61
-#define FCOL_ID             0
62
-#define FCOL_CARRIER        1
63
-#define FCOL_DOMAIN         2
64
-#define FCOL_SCAN_PREFIX    3
65
-#define FCOL_HOST_NAME      4
66
-#define FCOL_REPLY_CODE     5
67
-#define FCOL_FLAGS          6
68
-#define FCOL_MASK           7
69
-#define FCOL_NEXT_DOMAIN    8
70
-#define FCOL_COMMENT        9
71
-
72 46
 #define SUBSCRIBER_COLUMN_NUM 3
73 47
 #define SUBSCRIBER_USERNAME_COL 0
74 48
 #define SUBSCRIBER_DOMAIN_COL   1
75 49
 #define SUBSCRIBER_CARRIER_COL  2
76 50
 
77
-#define CARRIER_COLUMN_NUM 2
78
-#define CARRIER_ID_COL 0
79
-#define CARRIER_NAME_COL 1
80
-
81 51
 #define SP_ROUTE_MODE_DB 1
82 52
 #define SP_ROUTE_MODE_FILE 2
83 53
 
84
-#define ROUTE_TABLE_VER 2
85
-#define CARRIER_TABLE_VER 1
86
-#define FAILURE_TABLE_VER 1
87
-
88
-extern str db_url;
89
-extern str db_table;
90
-extern str db_failure_table;
91
-extern str carrier_table;
92 54
 extern str subscriber_table;
93 55
 extern str * subscriber_columns[];
94
-extern str * carrier_columns[];
95
-extern str * columns[];
96
-extern str * failure_columns[];
97 56
 extern char * config_source;
98 57
 extern char * config_file;
99 58
 extern str default_tree;
100 59
new file mode 100644
... ...
@@ -0,0 +1,172 @@
1
+
2
+/*!
3
+ * \file
4
+ * \ingroup db
5
+ * \brief Database support for modules.
6
+ *
7
+ * Database support functions for modules.
8
+ *
9
+ * @cond
10
+ * WARNING:
11
+ * This file was autogenerated from the XML source file
12
+ * ../../modules/carrierroute/kamailio-carrierroute.xml.
13
+ * It can be regenerated by running 'make modules' in the db/schema
14
+ * directory of the source code. You need to have xsltproc and
15
+ * docbook-xsl stylesheets installed.
16
+ * ALL CHANGES DONE HERE WILL BE LOST IF THE FILE IS REGENERATED
17
+ * @endcond
18
+ */
19
+
20
+#include "db_carrierroute.h"
21
+
22
+/* database variables */
23
+/* TODO assign read-write or read-only URI, introduce a parameter in XML */
24
+
25
+//extern str carrierroute_db_url;
26
+db_con_t * carrierroute_dbh = NULL;
27
+db_func_t carrierroute_dbf;
28
+
29
+str carrierroute_table = str_init("carrierroute");
30
+
31
+/* column names */
32
+str carrierroute_id_col = str_init("id");
33
+str carrierroute_carrier_col = str_init("carrier");
34
+str carrierroute_domain_col = str_init("domain");
35
+str carrierroute_scan_prefix_col = str_init("scan_prefix");
36
+str carrierroute_flags_col = str_init("flags");
37
+str carrierroute_mask_col = str_init("mask");
38
+str carrierroute_prob_col = str_init("prob");
39
+str carrierroute_strip_col = str_init("strip");
40
+str carrierroute_rewrite_host_col = str_init("rewrite_host");
41
+str carrierroute_rewrite_prefix_col = str_init("rewrite_prefix");
42
+str carrierroute_rewrite_suffix_col = str_init("rewrite_suffix");
43
+str carrierroute_description_col = str_init("description");
44
+
45
+/* table version */
46
+const unsigned int carrierroute_version = 2;
47
+
48
+str carrierfailureroute_table = str_init("carrierfailureroute");
49
+
50
+/* column names */
51
+str carrierfailureroute_id_col = str_init("id");
52
+str carrierfailureroute_carrier_col = str_init("carrier");
53
+str carrierfailureroute_domain_col = str_init("domain");
54
+str carrierfailureroute_scan_prefix_col = str_init("scan_prefix");
55
+str carrierfailureroute_host_name_col = str_init("host_name");
56
+str carrierfailureroute_reply_code_col = str_init("reply_code");
57
+str carrierfailureroute_flags_col = str_init("flags");
58
+str carrierfailureroute_mask_col = str_init("mask");
59
+str carrierfailureroute_next_domain_col = str_init("next_domain");
60
+str carrierfailureroute_description_col = str_init("description");
61
+
62
+/* table version */
63
+const unsigned int carrierfailureroute_version = 1;
64
+
65
+str route_tree_table = str_init("route_tree");
66
+
67
+/* column names */
68
+str route_tree_id_col = str_init("id");
69
+str route_tree_carrier_col = str_init("carrier");
70
+
71
+/* table version */
72
+const unsigned int route_tree_version = 1;
73
+
74
+
75
+/*
76
+ * Closes the DB connection.
77
+ */
78
+void carrierroute_db_close(void) {
79
+	if (carrierroute_dbh) {
80
+		carrierroute_dbf.close(carrierroute_dbh);
81
+		carrierroute_dbh = NULL;
82
+	}
83
+}
84
+
85