| 317 | /************************** INTERFACE functions ****************************/ |
| 318 | |
| 319 | static int mod_init( void ) |
| 320 | { |
| 321 | LM_INFO("initializing...\n"); |
| 322 | |
| 323 | init_db_url(db_url, 1 /* can be null */); |
| 324 | |
| 325 | db_table_acc.len = strlen(db_table_acc.s); |
| 326 | db_table_mc.len = strlen(db_table_mc.s); |
| 327 | acc_method_col.len = strlen(acc_method_col.s); |
| 328 | acc_fromtag_col.len = strlen(acc_fromtag_col.s); |
| 329 | acc_totag_col.len = strlen(acc_totag_col.s); |
| 330 | acc_callid_col.len = strlen(acc_callid_col.s); |
| 331 | acc_sipcode_col.len = strlen(acc_sipcode_col.s); |
| 332 | acc_sipreason_col.len = strlen(acc_sipreason_col.s); |
| 333 | acc_time_col.len = strlen(acc_time_col.s); |
| 334 | |
| 335 | if (log_facility_str) { |
| 336 | int tmp = str2facility(log_facility_str); |
| 337 | if (tmp != -1) |
| 338 | acc_log_facility = tmp; |
| 339 | else { |
| 340 | LM_ERR("invalid log facility configured\n"); |
| 341 | return -1; |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | /* load the TM API */ |
| 346 | if (load_tm_api(&tmb)!=0) { |
| 347 | LM_ERR("can't load TM API\n"); |
| 348 | return -1; |
| 349 | } |
| 350 | |
| 351 | /* if detect_direction is enabled, load rr also */ |
| 352 | if (detect_direction) { |
| 353 | if (load_rr_api(&rrb)!=0) { |
| 354 | LM_ERR("can't load RR API\n"); |
| 355 | return -1; |
| 356 | } |
| 357 | /* we need the append_fromtag on in RR */ |
| 358 | if (!rrb.append_fromtag) { |
| 359 | LM_ERR("'append_fromtag' RR param is not enabled!" |
| 360 | " - required by 'detect_direction'\n"); |
| 361 | return -1; |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | /* ----------- SYSLOG INIT SECTION ----------- */ |
| 366 | acc_log_init(); |
| 367 | |
| 368 | /* ----------- DATABASE INIT SECTION ----------- */ |
| 369 | if (db_url.s) { |
| 370 | if (acc_db_init(&db_url)<0){ |
| 371 | LM_ERR("failed! bad db url / missing db module ?\n"); |
| 372 | return -1; |
| 373 | } |
| 374 | } else { |
| 375 | if (db_extra_tags || db_leg_tags) { |
| 376 | LM_ERR("DB leg and/or extra fields defined but no DB url!\n"); |
nothing calls this directly
no test coverage detected