/** * The initialization function, called when the module is loaded by * the script. This function is called only once. * * Bind to the dialog module and setup the callbacks. Also initialize * the shared memory to store our interninal information in. */ static int mod_init(void) { if (qos_flag == -1) { LM_ERR("no qos flag set!!\n"); return -1; } else if (qos_flag > MAX_FLAG) { LM_ERR("invalid qos flag %d!!\n", qos_flag); return -1; } /* init callbacks */ if (init_qos_callbacks()!=0) { LM_ERR("cannot init callbacks\n"); return -1; } /* Register the main (static) dialog call back. */ if (load_dlg_api(&dialog_st) != 0) { LM_ERR("Can't load dialog hooks\n"); return(-1); } /* Load dialog hooks */ dialog_st.register_dlgcb(NULL, DLGCB_CREATED, qos_dialog_created_CB, NULL, NULL); /* * We are GOOD-TO-GO. */ return 0; }
/** * The initialization function, called when the module is loaded by * the script. This function is called only once. * * Bind to the dialog module and setup the callbacks. Also initialize * the shared memory to store our interninal information in. * * @return 0 to continue to load the OpenSIPS, -1 to stop the loading * and abort OpenSIPS. */ static int mod_init(void) { str s; LM_INFO("SIP Session Timer module - initializing\n"); /* * if statistics are disabled, prevent their registration to core. */ if (sst_enable_stats==0) { exports.stats = 0; } if (sst_flag == -1) { LM_ERR("no sst flag set!!\n"); return -1; } else if (sst_flag > MAX_FLAG) { LM_ERR("invalid sst flag %d!!\n", sst_flag); return -1; } if (timeout_spec != NULL) { LM_DBG("Dialog AVP is %s", timeout_spec); s.s = timeout_spec; s.len = strlen(s.s); if (pv_parse_spec(&s, &timeout_avp)==0 && (timeout_avp.type != PVT_AVP)){ LM_ERR("malformed or non AVP timeout AVP definition in '%s'\n", timeout_spec); return -1; } } /* load SIGNALING API */ if(load_sig_api(&sigb)< 0) { LM_ERR("can't load signaling functions\n"); return -1; } /* * Init the handlers */ sst_handler_init((timeout_spec?&timeout_avp:0), sst_minSE, sst_flag, sst_reject,sst_interval); /* * Register the main (static) dialog call back. */ if (load_dlg_api(&dialog_st) != 0) { LM_ERR("failed to load dialog hooks"); return(-1); } /* Load dialog hooks */ dialog_st.register_dlgcb(NULL, DLGCB_CREATED, sst_dialog_created_CB, NULL, NULL); /* * We are GOOD-TO-GO. */ return 0; }
int init_dialog_support(void) { if (load_dlg_api(&dlgf)!=0) { LM_ERR("failed to find dialog API - is dialog module loaded?\n"); return -1; } return 0; }
static int fixup_trace_dialog(void** param, int param_no) { /* register callback to dialog */ if (load_dlg_api(&dlgb)!=0) { LM_ERR("can't load dialog api\n"); return -1; } return 0; }
/* initialization of all necessary callbacks to track a dialog */ int init_cdr_generation( void) { if( load_dlg_api( &dlgb) != 0) { LM_ERR("can't load dialog API\n"); return -1; } if( dlgb.register_dlgcb( 0, DLGCB_CREATED, cdr_on_create, 0, 0) != 0) { LM_ERR("can't register create callback\n"); return -1; } return 0; }
static int mod_init(void) { LM_INFO("initializing...\n"); /* param handling */ topo_hiding_prefix.len = strlen(topo_hiding_prefix.s); topo_hiding_seed.len = strlen(topo_hiding_seed.s); th_contact_encode_param.len = strlen(th_contact_encode_param.s); if (topo_hiding_ct_params.s) { topo_hiding_ct_params.len = strlen(topo_hiding_ct_params.s); topo_parse_passed_ct_params(&topo_hiding_ct_params); } if (topo_hiding_ct_hdr_params.s) { topo_hiding_ct_hdr_params.len = strlen(topo_hiding_ct_hdr_params.s); topo_parse_passed_hdr_ct_params(&topo_hiding_ct_hdr_params); } /* loading dependencies */ if (load_tm_api(&tm_api)!=0) { LM_ERR("can't load TM API\n"); goto error; } if (load_dlg_api(&dlg_api)!=0) { if (force_dialog) { LM_ERR("cannot force dialog. dialog module not loaded\n"); goto error; } } if (register_pre_raw_processing_cb(topo_callid_pre_raw, PRE_RAW_PROCESSING, 0/*no free*/) < 0) { LM_ERR("failed to initialize pre raw support\n"); return -1; } if (register_post_raw_processing_cb(topo_callid_post_raw, POST_RAW_PROCESSING, 0/*no free*/) < 0) { LM_ERR("failed to initialize post raw support\n"); return -1; } return 0; error: return -1; }
/** * types: cdr, missed * case insesitive * */ static inline unsigned long long do_acc_flags_parser(str* token) { str_trim_spaces_lr(*token); if (token->len == do_acc_cdr_s.len && !strncasecmp(token->s, do_acc_cdr_s.s, token->len)) { if (!is_cdr_enabled) { if (parse_avp_spec( &acc_created_avp_name, &acc_created_avp_id) < 0) { LM_ERR("failed to register AVP name <%s>\n", acc_created_avp_name.s); return -1; } if (load_dlg_api(&dlg_api)!=0) LM_DBG("failed to find dialog API - is dialog module loaded?\n"); if (!dlg_api.get_dlg) { LM_WARN("error loading dialog module - cdrs cannot be generated\n"); return 0; } if (dlg_api.get_dlg && dlg_api.register_dlgcb(NULL, DLGCB_LOADED,acc_loaded_callback, NULL, NULL) < 0) LM_ERR("cannot register callback for dialog loaded - accounting " "for ongoing calls will be lost after restart\n"); is_cdr_enabled=1; } return DO_ACC_CDR; } else if (token->len == do_acc_missed_s.len && !strncasecmp(token->s, do_acc_missed_s.s, token->len)) { /* load dialog module if these are used */ return DO_ACC_MISSED; } else if (token->len == do_acc_failed_s.len && !strncasecmp(token->s, do_acc_failed_s.s, token->len)) { return DO_ACC_FAILED; } else { return -1; } }
/** * init module function */ static int mod_init(void) { LM_DBG("initializing siprec module ...\n"); if (srs_init() < 0) { LM_ERR("cannot initialize srs structures!\n"); return -1; } if (src_init() < 0) { LM_ERR("cannot initialize src structures!\n"); return -1; } if (load_dlg_api(&srec_dlg) != 0) { LM_ERR("dialog module not loaded! Cannot use siprec module\n"); return -1; } if (load_tm_api(&srec_tm) != 0) { LM_ERR("tm module not loaded! Cannot use siprec module\n"); return -1; } if (load_b2b_api(&srec_b2b) != 0) { LM_ERR("b2b_entities module not loaded! Cannot use siprec module\n"); return -1; } if (load_rtpproxy_api(&srec_rtp) != 0) { LM_ERR("rtpproxy module not loaded! Cannot use siprec module\n"); return -1; } if (srec_dlg.register_dlgcb(NULL, DLGCB_LOADED, srec_loaded_callback, NULL, NULL) < 0) LM_WARN("cannot register callback for loaded dialogs - will not be " "able to terminate siprec sessions after a restart!\n"); return 0; }
int mod_init(void) { LM_DBG("initializing module...\n"); if (seq_route) { seq_route_id = get_script_route_ID_by_name(seq_route, rlist, RT_NO); if (seq_route_id == -1) LM_ERR("route \"%s\" does not exist! ignoring\n", seq_route); } if (load_tm_api(&tm_api) != 0) { LM_ERR("failed to load tm API\n"); return -1; } if (use_dialog && load_dlg_api(&dlg_api) != 0) { LM_ERR("failed to load dialog API\n"); return -1; } if (load_rr_api(&rr_api) != 0) { LM_ERR("failed to load rr API\n"); return -1; } if (load_sl_api(&sl_api) != 0) { LM_ERR("failed to load sl API\n"); return -1; } if (__register_script_cb(run_helper_logic, PRE_SCRIPT_CB|REQ_TYPE_CB, NULL, -1) != 0) { LM_ERR("cannot register script callback"); return -1; } return 0; }
/** * init module function */ static int mod_init(void) { bind_pua_t bind_pua; str s; pv_spec_t avp_spec; bind_pua= (bind_pua_t)find_export("bind_pua", 1,0); if (!bind_pua) { LM_ERR("Can't bind pua\n"); return -1; } if (bind_pua(&pua) < 0) { LM_ERR("Can't bind pua\n"); return -1; } if(pua.send_publish == NULL) { LM_ERR("Could not import send_publish\n"); return -1; } pua_send_publish= pua.send_publish; /* bind to the dialog API */ if (load_dlg_api(&dlg_api)!=0) { LM_ERR("failed to find dialog API - is dialog module loaded?\n"); return -1; } /* register dialog creation callback */ if (dlg_api.register_dlgcb(NULL, DLGCB_CREATED, __dialog_created, NULL, NULL) != 0) { LM_ERR("cannot register callback for dialog creation\n"); return -1; } if(use_pubruri_avps) { if(!(pubruri_caller_avp && *pubruri_caller_avp) && (pubruri_callee_avp && *pubruri_callee_avp)) { LM_ERR("pubruri_caller_avp and pubruri_callee_avp must be set, if use_pubruri_avps is enabled\n"); return -1; } s.s = pubruri_caller_avp; s.len = strlen(s.s); if (pv_parse_spec(&s, &avp_spec)==0 || avp_spec.type!=PVT_AVP) { LM_ERR("malformed or non AVP %s AVP definition\n", pubruri_caller_avp); return -1; } if(pv_get_avp_name(0, &avp_spec.pvp, &pubruri_caller_avp_name, &pubruri_caller_avp_type)!=0) { LM_ERR("[%s]- invalid AVP definition\n", pubruri_caller_avp); return -1; } s.s = pubruri_callee_avp; s.len = strlen(s.s); if (pv_parse_spec(&s, &avp_spec)==0 || avp_spec.type!=PVT_AVP) { LM_ERR("malformed or non AVP %s AVP definition\n", pubruri_callee_avp); return -1; } if(pv_get_avp_name(0, &avp_spec.pvp, &pubruri_callee_avp_name, &pubruri_callee_avp_type)!=0) { LM_ERR("[%s]- invalid AVP definition\n", pubruri_callee_avp); return -1; } } return 0; }
static int mod_init(void) { LM_INFO("Load-Balancer module - initializing\n"); init_db_url( db_url , 0 /*cannot be null*/); /* Load dialog API */ if (load_dlg_api(&lb_dlg_binds) != 0) { LM_ERR("Can't load dialog hooks"); return -1; } /* data pointer in shm */ curr_data = (struct lb_data**)shm_malloc( sizeof(struct lb_data*) ); if (curr_data==0) { LM_CRIT("failed to get shm mem for data ptr\n"); return -1; } *curr_data = 0; /* create & init lock */ if ((ref_lock = lock_init_rw()) == NULL) { LM_CRIT("failed to init lock\n"); return -1; } if (init_lb_bls()) { LM_ERR("BL INIT failed\n"); return -1; } /* init and open DB connection */ if (init_lb_db(&db_url, table_name)!=0) { LM_ERR("failed to initialize the DB support\n"); return -1; } /* load data */ if ( lb_reload_data()!=0 ) { LM_CRIT("failed to load load-balancing data\n"); return -1; } /* close DB connection */ lb_close_db(); /* arm a function for probing */ if (lb_prob_interval) { /* load TM API */ if (load_tm_api(&lb_tmb)!=0) { LM_ERR("can't load TM API\n"); return -1; } /* probing method */ lb_probe_method.len = strlen(lb_probe_method.s); lb_probe_from.len = strlen(lb_probe_from.s); if (lb_probe_replies.s) lb_probe_replies.len = strlen(lb_probe_replies.s); /* register pinger function */ if (register_timer( "lb-pinger", lb_prob_handler , NULL, lb_prob_interval)<0) { LM_ERR("failed to register probing handler\n"); return -1; } if (lb_probe_replies.s) { lb_probe_replies.len = strlen(lb_probe_replies.s); if(parse_reply_codes( &lb_probe_replies, &probing_reply_codes, &probing_codes_no )< 0) { LM_ERR("Bad format for options_reply_code parameter" " - Need a code list separated by commas\n"); return -1; } } } /* parse avps */ if (parse_avp_spec(&grp_avp_name_s, &grp_avp_name)) { LM_ERR("cannot parse group avp\n"); return -1; } if (parse_avp_spec(&mask_avp_name_s, &mask_avp_name)) { LM_ERR("cannot parse mask avp\n"); return -1; } if (parse_avp_spec(&id_avp_name_s, &id_avp_name)) { LM_ERR("cannot parse id avp\n"); return -1; } return 0; }
static int mod_init(void) { LM_INFO("initializing...\n"); int rr_api_loaded=0; if ( is_script_func_used("uac_auth", -1) ) { /* load the UAC_AUTH API as uac_auth() is invoked from script */ if(load_uac_auth_api(&uac_auth_api)<0){ LM_ERR("can't load UAC_AUTH API, needed for uac_auth()\n"); goto error; } } /* load the TM API - FIXME it should be loaded only * if NO_RESTORE and AUTH */ if (load_tm_api(&uac_tmb)!=0) { LM_ERR("can't load TM API\n"); goto error; } if (restore_mode_str && *restore_mode_str) { if (strcasecmp(restore_mode_str,"none")==0) { restore_mode = UAC_NO_RESTORE; } else if (strcasecmp(restore_mode_str,"manual")==0) { restore_mode = UAC_MANUAL_RESTORE; } else if (strcasecmp(restore_mode_str,"auto")==0) { restore_mode = UAC_AUTO_RESTORE; } else { LM_ERR("unsupported value '%s' for restore_mode\n", restore_mode_str); goto error; } } if ( is_script_func_used("uac_replace_from", -1) || is_script_func_used("uac_replace_to", -1) ) { /* replace TO/FROM stuff is used, get prepared */ rr_from_param.len = strlen(rr_from_param.s); rr_to_param.len = strlen(rr_to_param.s); if ( (rr_from_param.len==0 || rr_to_param.len==0) && restore_mode!=UAC_NO_RESTORE) { LM_ERR("rr_store_param cannot be empty if FROM is restoreable\n"); goto error; } uac_passwd.len = strlen(uac_passwd.s); if (restore_mode!=UAC_NO_RESTORE) { /* load the RR API */ if (load_rr_api(&uac_rrb)!=0) { LM_ERR("can't load RR API\n"); goto error; } rr_api_loaded=1; if (restore_mode==UAC_AUTO_RESTORE) { /* we need the append_fromtag on in RR */ if (!force_dialog && !uac_rrb.append_fromtag) { LM_ERR("'append_fromtag' RR param is not enabled!" " - required by AUTO restore mode\n"); goto error; } /* trying to load dialog module */ memset(&dlg_api, 0, sizeof(struct dlg_binds)); if (load_dlg_api(&dlg_api)!=0) { if (force_dialog) { LM_ERR("cannot force dialog. dialog module not loaded\n"); goto error; } LM_DBG("failed to find dialog API - is dialog module loaded?\n"); } else { if ( (parse_store_bavp(&store_to_bavp, &to_bavp_spec) || parse_store_bavp(&store_from_bavp, &from_bavp_spec))) { LM_ERR("cannot set correct store parameters\n"); goto error; } /* install calback to catch all loaded dialogs */ if ( dlg_api.register_dlgcb( NULL, DLGCB_LOADED, dlg_restore_callback, NULL, NULL) != 0 ) { LM_ERR("failed to install dialog restore callback\n"); goto error; } } /* get all requests doing loose route */ if (uac_rrb.register_rrcb( rr_checker, 0, 2)!=0) { LM_ERR("failed to install RR callback\n"); goto error; } } } /* init from replacer */ init_from_replacer(); } if (is_script_func_used("uac_auth", -1)) { if (!rr_api_loaded) { if (load_rr_api(&uac_rrb)!=0) { LM_ERR("can't load RR API\n"); goto error; } } if (!uac_rrb.append_fromtag) { LM_ERR("'append_fromtag' RR param is not enabled!" " - required by uac_auth() restore mode\n"); goto error; } if (uac_rrb.register_rrcb( rr_uac_auth_checker, 0, 2)!=0) { LM_ERR("failed to install RR callback\n"); goto error; } } return 0; error: return -1; }
/** * The initialization function, called when the module is loaded by * the script. This function is called only once. * * Bind to the dialog module and setup the callbacks. Also initialize * the shared memory to store our interninal information in. * * @return 0 to continue to load the Kamailio, -1 to stop the loading * and abort Kamailio. */ static int mod_init(void) { str s; /* if statistics are disabled, prevent their registration to core. */ if (sst_enable_stats==0) { exports.stats = 0; } #ifdef STATISTICS /* register statistics */ if (sst_enable_stats!=0) { if (register_module_stats( exports.name, mod_stats)!=0 ) { LM_ERR("failed to register core statistics\n"); return -1; } } #endif if (sst_flag == -1) { LM_ERR("no sst flag set!!\n"); return -1; } else if (sst_flag > MAX_FLAG) { LM_ERR("invalid sst flag %d!!\n", sst_flag); return -1; } if (timeout_spec != NULL) { LM_DBG("Dialog AVP is %s", timeout_spec); s.s = timeout_spec; s.len = strlen(s.s); if (pv_parse_spec(&s, &timeout_avp)==0 && (timeout_avp.type != PVT_AVP)){ LM_ERR("malformed or non AVP timeout AVP definition in '%s'\n", timeout_spec); return -1; } } /* bind the SL API */ if (sl_load_api(&slb)!=0) { LM_ERR("cannot bind to SL API\n"); return -1; } /* Init the handlers */ sst_handler_init((timeout_spec?&timeout_avp:0), sst_minSE, sst_flag, sst_reject); /* Register the main (static) dialog call back. */ if (load_dlg_api(&dialog_st) != 0) { LM_ERR("failed to load dialog hooks"); return(-1); } /* Load dialog hooks */ dialog_st.register_dlgcb(NULL, DLGCB_CREATED, sst_dialog_created_CB, NULL, NULL); return 0; }
static int mod_init(void) { LM_INFO("Load-Balancer module - initializing\n"); init_db_url( db_url , 0 /*cannot be null*/); /* Load dialog API */ if (load_dlg_api(&lb_dlg_binds) != 0) { LM_ERR("Can't load dialog hooks\n"); return -1; } if (fetch_freeswitch_stats) { if (load_fs_api(&fs_api) == -1) { LM_ERR("failed to load the FS API!\n"); return -1; } } /* data pointer in shm */ curr_data = (struct lb_data**)shm_malloc( sizeof(struct lb_data*) ); if (curr_data==0) { LM_CRIT("failed to get shm mem for data ptr\n"); return -1; } *curr_data = 0; /* create & init lock */ if ((ref_lock = lock_init_rw()) == NULL) { LM_CRIT("failed to init lock\n"); return -1; } if (init_lb_bls()) { LM_ERR("BL INIT failed\n"); return -1; } /* init and open DB connection */ if (init_lb_db(&db_url, table_name)!=0) { LM_ERR("failed to initialize the DB support\n"); return -1; } /* load data */ if ( lb_reload_data()!=0 ) { LM_CRIT("failed to load load-balancing data\n"); return -1; } /* close DB connection */ lb_close_db(); /* arm a function for probing */ if (lb_prob_interval) { /* load TM API */ if (load_tm_api(&lb_tmb)!=0) { LM_ERR("can't load TM API\n"); return -1; } /* probing method */ lb_probe_method.len = strlen(lb_probe_method.s); lb_probe_from.len = strlen(lb_probe_from.s); if (lb_probe_replies.s) lb_probe_replies.len = strlen(lb_probe_replies.s); /* register pinger function */ if (register_timer( "lb-pinger", lb_prob_handler , NULL, lb_prob_interval, TIMER_FLAG_DELAY_ON_DELAY)<0) { LM_ERR("failed to register probing handler\n"); return -1; } /* Register the max load recalculation timer */ if (fetch_freeswitch_stats && register_timer("lb-update-max-load", lb_update_max_loads, NULL, fs_api.stats_update_interval, TIMER_FLAG_SKIP_ON_DELAY)<0) { LM_ERR("failed to register timer for max load recalc!\n"); return -1; } if (lb_probe_replies.s) { lb_probe_replies.len = strlen(lb_probe_replies.s); if(parse_reply_codes( &lb_probe_replies, &probing_reply_codes, &probing_codes_no )< 0) { LM_ERR("Bad format for options_reply_code parameter" " - Need a code list separated by commas\n"); return -1; } } } /* parse avps */ if (parse_avp_spec(&group_avp_name_s, &group_avp_name)) { LM_ERR("cannot parse group avp\n"); return -1; } if (parse_avp_spec(&flags_avp_name_s, &flags_avp_name)) { LM_ERR("cannot parse flags avp\n"); return -1; } if (parse_avp_spec(&mask_avp_name_s, &mask_avp_name)) { LM_ERR("cannot parse mask avp\n"); return -1; } if (parse_avp_spec(&id_avp_name_s, &id_avp_name)) { LM_ERR("cannot parse id avp\n"); return -1; } if (parse_avp_spec(&res_avp_name_s, &res_avp_name)) { LM_ERR("cannot parse resources avp\n"); return -1; } if (lb_init_event() < 0) { LM_ERR("cannot init event\n"); return -1; } if (lb_repl_cluster < 0) { LM_ERR("Invalid replication_cluster, must be 0 or " "a positive cluster id\n"); return -1; } if (lb_repl_cluster && load_clusterer_api(&clusterer_api)!=0) { LM_DBG("failed to find clusterer API - is clusterer module loaded?\n"); return -1; } /* register handler for processing load_balancer replication packets to the clusterer module */ if (lb_repl_cluster > 0 && clusterer_api.register_capability(&status_repl_cap, receive_lb_binary_packet, NULL, lb_repl_cluster, 0, NODE_CMP_ANY) < 0) { LM_ERR("cannot register binary packet callback to clusterer module!\n"); return -1; } return 0; }
static int mod_init(void) { pv_spec_t avp_spec; int *param; modparam_t type; // initialize the canonical_uri_avp structure if (canonical_uri_avp.spec.s==NULL || canonical_uri_avp.spec.len<=0) { LOG(L_ERR, "missing/empty canonical_uri_avp parameter. using default.\n"); canonical_uri_avp.spec.s = CANONICAL_URI_AVP_SPEC; } if (pv_parse_spec(&(canonical_uri_avp.spec), &avp_spec)==0 || avp_spec.type!=PVT_AVP) { LOG(L_CRIT, "invalid AVP specification for canonical_uri_avp: `%s'\n", canonical_uri_avp.spec.s); return -1; } if (pv_get_avp_name(0, &(avp_spec.pvp), &(canonical_uri_avp.name), &(canonical_uri_avp.type))!=0) { LOG(L_CRIT, "invalid AVP specification for canonical_uri_avp: `%s'\n", canonical_uri_avp.spec.s); return -1; } // initialize the signaling_ip_avp structure if (signaling_ip_avp.spec.s==NULL || signaling_ip_avp.spec.len<=0) { LOG(L_ERR, "missing/empty signaling_ip_avp parameter. using default.\n"); signaling_ip_avp.spec.s = SIGNALING_IP_AVP_SPEC; } if (pv_parse_spec(&(signaling_ip_avp.spec), &avp_spec)==0 || avp_spec.type!=PVT_AVP) { LOG(L_CRIT, "invalid AVP specification for signaling_ip_avp: `%s'\n", signaling_ip_avp.spec.s); return -1; } if (pv_get_avp_name(0, &(avp_spec.pvp), &(signaling_ip_avp.name), &(signaling_ip_avp.type))!=0) { LOG(L_CRIT, "invalid AVP specification for signaling_ip_avp: `%s'\n", signaling_ip_avp.spec.s); return -1; } // initialize the sip_application_avp structure if (sip_application_avp.spec.s==NULL || sip_application_avp.spec.len<=0) { LOG(L_ERR, "missing/empty sip_application_avp parameter. using default.\n"); sip_application_avp.spec.s = SIP_APPLICATION_AVP_SPEC; } if (pv_parse_spec(&(sip_application_avp.spec), &avp_spec)==0 || avp_spec.type!=PVT_AVP) { LOG(L_CRIT, "invalid AVP specification for sip_application_avp: `%s'\n", sip_application_avp.spec.s); return -1; } if (pv_get_avp_name(0, &(avp_spec.pvp), &(sip_application_avp.name), &(sip_application_avp.type))!=0) { LOG(L_CRIT, "invalid AVP specification for sip_application_avp: `%s'\n", sip_application_avp.spec.s); return -1; } // bind to the dialog API if (load_dlg_api(&dlg_api)!=0) { LOG(L_CRIT, "cannot load the dialog module API\n"); return -1; } // load dlg_flag and default_timeout parameters from the dialog module param = find_param_export(find_module_by_name("dialog"), "dlg_flag", INT_PARAM, &type); if (!param) { LOG(L_CRIT, "cannot find dlg_flag parameter in the dialog module\n"); return -1; } if (type != INT_PARAM) { LOG(L_CRIT, "dlg_flag parameter found but with wrong type: %d\n", type); return -1; } dialog_flag = *param; // register dialog creation callback if (dlg_api.register_dlgcb(NULL, DLGCB_CREATED, __dialog_created, NULL, NULL) != 0) { LOG(L_CRIT, "cannot register callback for dialog creation\n"); return -1; } // register dialog loading callback if (dlg_api.register_dlgcb(NULL, DLGCB_LOADED, __dialog_loaded, NULL, NULL) != 0) { LOG(L_ERR, "cannot register callback for dialogs loaded from the database\n"); } // register a pre-script callback to automatically enable dialog tracing if (register_script_cb(postprocess_request, POST_SCRIPT_CB|REQUEST_CB, 0) != 0) { LOG(L_CRIT, "ERROR:call_control:mod_init: could not register request postprocessing callback\n"); return -1; } return 0; }
static int mod_init(void) { int n; load_dlg_f load_dlg; load_tm_f load_tm; bind_usrloc_t bind_usrloc; if (!fix_parameters()) { LM_ERR("unable to set Ro configuration parameters correctly\n"); goto error; } /* bind to the tm module */ if (!(load_tm = (load_tm_f) find_export("load_tm", NO_SCRIPT, 0))) { LM_ERR("Can not import load_tm. This module requires tm module\n"); goto error; } if (load_tm(&tmb) == -1) goto error; if (!(load_dlg = (load_dlg_f) find_export("load_dlg", 0, 0))) { /* bind to dialog module */ LM_ERR("can not import load_dlg. This module requires Kamailio dialog module.\n"); } if (load_dlg(&dlgb) == -1) { goto error; } if (load_cdp_api(&cdpb) != 0) { /* load the CDP API */ LM_ERR("can't load CDP API\n"); goto error; } if (load_dlg_api(&dlgb) != 0) { /* load the dialog API */ LM_ERR("can't load Dialog API\n"); goto error; } cdp_avp = load_cdp_avp(); /* load CDP_AVP API */ if (!cdp_avp) { LM_ERR("can't load CDP_AVP API\n"); goto error; } /* init timer lists*/ if (init_ro_timer(ro_session_ontimeout) != 0) { LM_ERR("cannot init timer list\n"); return -1; } /* initialized the hash table */ for (n = 0; n < (8 * sizeof(n)); n++) { if (ro_session_hash_size == (1 << n)) break; if (ro_session_hash_size < (1 << n)) { LM_WARN("hash_size is not a power of 2 as it should be -> rounding from %d to %d\n", ro_session_hash_size, 1 << (n - 1)); ro_session_hash_size = 1 << (n - 1); } } if (init_ro_session_table(ro_session_hash_size) < 0) { LM_ERR("failed to create ro session hash table\n"); return -1; } /* register global timer */ if (register_timer(ro_timer_routine, 0/*(void*)ro_session_list*/, 1) < 0) { LM_ERR("failed to register timer \n"); return -1; } bind_usrloc = (bind_usrloc_t) find_export("ul_bind_usrloc", 1, 0); if (!bind_usrloc) { LM_ERR("can't bind usrloc\n"); return -1; } if (bind_usrloc(&ul) < 0) { return -1; } /*Register for callback of URECORD being deleted - so we can send a SAR*/ if (ul.register_ulcb == NULL) { LM_ERR("Could not import ul_register_ulcb\n"); return -1; } /* register statistics */ if (register_module_stats(exports.name, charging_stats) != 0) { LM_ERR("failed to register core statistics\n"); return -1; } /*if (register_stat(MOD_NAME, "ccr_responses_time", &ccr_responses_time, 0)) { LM_ERR("failed to register core statistics\n"); return -1; }*/ /* if a database should be used to store the dialogs' information */ ro_db_mode = ro_db_mode_param; if (ro_db_mode == DB_MODE_NONE) { db_url.s = 0; db_url.len = 0; } else { if (ro_db_mode != DB_MODE_REALTIME && ro_db_mode != DB_MODE_SHUTDOWN) { LM_ERR("unsupported db_mode %d\n", ro_db_mode); return -1; } if (!db_url.s || db_url.len == 0) { LM_ERR("db_url not configured for db_mode %d\n", ro_db_mode); return -1; } if (init_ro_db(&db_url, ro_session_hash_size, db_update_period, db_fetch_rows) != 0) { LM_ERR("failed to initialize the DB support\n"); return -1; } // run_load_callbacks(); } return 0; error: LM_ERR("Failed to initialise ims_qos module\n"); return RO_RETURN_FALSE; }
static int mod_init(void) { pv_spec_t avp_spec; // initialize the canonical_uri_avp structure if (canonical_uri_avp.spec.s==NULL || *(canonical_uri_avp.spec.s)==0) { LM_ERR("missing/empty canonical_uri_avp parameter. using default.\n"); canonical_uri_avp.spec.s = CANONICAL_URI_AVP_SPEC; } canonical_uri_avp.spec.len = strlen(canonical_uri_avp.spec.s); if (pv_parse_spec(&(canonical_uri_avp.spec), &avp_spec)==0 || avp_spec.type!=PVT_AVP) { LM_CRIT("invalid AVP specification for canonical_uri_avp: `%s'\n", canonical_uri_avp.spec.s); return -1; } if (pv_get_avp_name(0, &(avp_spec.pvp), &(canonical_uri_avp.name), &(canonical_uri_avp.type))!=0) { LM_CRIT("invalid AVP specification for canonical_uri_avp: `%s'\n", canonical_uri_avp.spec.s); return -1; } // initialize the signaling_ip_avp structure if (signaling_ip_avp.spec.s==NULL || *(signaling_ip_avp.spec.s)==0) { LM_ERR("missing/empty signaling_ip_avp parameter. using default.\n"); signaling_ip_avp.spec.s = SIGNALING_IP_AVP_SPEC; } signaling_ip_avp.spec.len = strlen(signaling_ip_avp.spec.s); if (pv_parse_spec(&(signaling_ip_avp.spec), &avp_spec)==0 || avp_spec.type!=PVT_AVP) { LM_CRIT("invalid AVP specification for signaling_ip_avp: `%s'\n", signaling_ip_avp.spec.s); return -1; } if (pv_get_avp_name(0, &(avp_spec.pvp), &(signaling_ip_avp.name), &(signaling_ip_avp.type))!=0) { LM_CRIT("invalid AVP specification for signaling_ip_avp: `%s'\n", signaling_ip_avp.spec.s); return -1; } // initialize the call_limit_avp structure if (call_limit_avp.spec.s==NULL || *(call_limit_avp.spec.s)==0) { LM_ERR("missing/empty call_limit_avp parameter. using default.\n"); call_limit_avp.spec.s = CALL_LIMIT_AVP_SPEC; } call_limit_avp.spec.len = strlen(call_limit_avp.spec.s); if (pv_parse_spec(&(call_limit_avp.spec), &avp_spec)==0 || avp_spec.type!=PVT_AVP) { LM_CRIT("invalid AVP specification for call_limit_avp: `%s'\n", call_limit_avp.spec.s); return -1; } if (pv_get_avp_name(0, &(avp_spec.pvp), &(call_limit_avp.name), &(call_limit_avp.type))!=0) { LM_CRIT("invalid AVP specification for call_limit_avp: `%s'\n", call_limit_avp.spec.s); return -1; } // initialize the call_token_avp structure if (call_token_avp.spec.s==NULL || *(call_token_avp.spec.s)==0) { LM_ERR("missing/empty call_token_avp parameter. using default.\n"); call_token_avp.spec.s = CALL_TOKEN_AVP_SPEC; } call_token_avp.spec.len = strlen(call_token_avp.spec.s); if (pv_parse_spec(&(call_token_avp.spec), &avp_spec)==0 || avp_spec.type!=PVT_AVP) { LM_CRIT("invalid AVP specification for call_token_avp: `%s'\n", call_token_avp.spec.s); return -1; } if (pv_get_avp_name(0, &(avp_spec.pvp), &(call_token_avp.name), &(call_token_avp.type))!=0) { LM_CRIT("invalid AVP specification for call_token_avp: `%s'\n", call_token_avp.spec.s); return -1; } // initialize the diverter_avp structure if (diverter_avp.spec.s==NULL || *(diverter_avp.spec.s)==0) { LM_ERR("missing/empty diverter_avp parameter. using default.\n"); diverter_avp.spec.s = DIVERTER_AVP_SPEC; } diverter_avp.spec.len = strlen(diverter_avp.spec.s); if (pv_parse_spec(&(diverter_avp.spec), &avp_spec)==0 || avp_spec.type!=PVT_AVP) { LM_CRIT("invalid AVP specification for diverter_avp: `%s'\n", diverter_avp.spec.s); return -1; } if (pv_get_avp_name(0, &(avp_spec.pvp), &(diverter_avp.name), &(diverter_avp.type))!=0) { LM_CRIT("invalid AVP specification for diverter_avp: `%s'\n", diverter_avp.spec.s); return -1; } // bind to the dialog API if (load_dlg_api(&dlg_api)!=0) { LM_CRIT("cannot load the dialog module API\n"); return -1; } // register dialog loading callback if (dlg_api.register_dlgcb(NULL, DLGCB_LOADED, __dialog_loaded, NULL, NULL) != 0) { LM_CRIT("cannot register callback for dialogs loaded from the database\n"); } fix_flag_name(prepaid_account_str, prepaid_account_flag); prepaid_account_flag = get_flag_id_by_name(FLAG_TYPE_MSG, prepaid_account_str); return 0; }
/** * init module function */ static int mod_init(void) { /* fix the parameters */ if (!fix_parameters()) goto error; #ifdef STATISTICS /* register statistics */ if (register_module_stats(exports.name, mod_stats) != 0) { LM_ERR("failed to register core statistics\n"); goto error; } if (!register_stats()) { LM_ERR("Unable to register statistics\n"); goto error; } #endif callback_singleton = shm_malloc(sizeof (int)); *callback_singleton = 0; /*register space for event processor*/ register_procs(1); cdp_avp = 0; /* load the TM API */ if (load_tm_api(&tmb) != 0) { LM_ERR("can't load TM API\n"); goto error; } /* load the CDP API */ if (load_cdp_api(&cdpb) != 0) { LM_ERR("can't load CDP API\n"); goto error; } /* load the dialog API */ if (load_dlg_api(&dlgb) != 0) { LM_ERR("can't load Dialog API\n"); goto error; } cdp_avp = load_cdp_avp(); if (!cdp_avp) { LM_ERR("can't load CDP_AVP API\n"); goto error; } /* load the usrloc API */ bind_usrloc = (bind_usrloc_t) find_export("ul_bind_ims_usrloc_pcscf", 1, 0); if (!bind_usrloc) { LM_ERR("can't bind usrloc_pcscf\n"); return CSCF_RETURN_FALSE; } if (bind_usrloc(&ul) < 0) { LM_ERR("can't bind to usrloc pcscf\n"); return CSCF_RETURN_FALSE; } LM_DBG("Successfully bound to PCSCF Usrloc module\n"); LM_DBG("Diameter RX interface successfully bound to TM, Dialog, Usrloc and CDP modules\n"); /*init cdb cb event list*/ if (!init_cdp_cb_event_list()) { LM_ERR("unable to initialise cdp callback event list\n"); return -1; } return 0; error: LM_ERR("Failed to initialise ims_qos module\n"); return CSCF_RETURN_FALSE; }
static int mod_init(void) { pv_spec_t avp_spec; if (restore_mode_str && *restore_mode_str) { if (strcasecmp(restore_mode_str,"none")==0) { restore_mode = UAC_NO_RESTORE; } else if (strcasecmp(restore_mode_str,"manual")==0) { restore_mode = UAC_MANUAL_RESTORE; } else if (strcasecmp(restore_mode_str,"auto")==0) { restore_mode = UAC_AUTO_RESTORE; } else { LM_ERR("unsupported value '%s' for restore_mode\n", restore_mode_str); goto error; } } if ( (rr_from_param.len==0 || rr_to_param.len==0) && restore_mode!=UAC_NO_RESTORE) { LM_ERR("rr_store_param cannot be empty if FROM is restoreable\n"); goto error; } /* parse the auth AVP spesc, if any */ if ( auth_username_avp || auth_password_avp || auth_realm_avp) { if (!auth_username_avp || !auth_password_avp || !auth_realm_avp) { LM_ERR("partial definition of auth AVP!"); goto error; } if ( parse_auth_avp(auth_realm_avp, &auth_realm_spec, "realm")<0 || parse_auth_avp(auth_username_avp, &auth_username_spec, "username")<0 || parse_auth_avp(auth_password_avp, &auth_password_spec, "password")<0 ) { goto error; } } else { memset( &auth_realm_spec, 0, sizeof(pv_spec_t)); memset( &auth_password_spec, 0, sizeof(pv_spec_t)); memset( &auth_username_spec, 0, sizeof(pv_spec_t)); } /* load the TM API - FIXME it should be loaded only * if NO_RESTORE and AUTH */ if (load_tm_api(&uac_tmb)!=0) { LM_ERR("can't load TM API\n"); goto error; } if (restore_mode!=UAC_NO_RESTORE) { /* load the RR API */ if (load_rr_api(&uac_rrb)!=0) { LM_ERR("can't load RR API\n"); goto error; } if(restore_from_avp.s) { if (pv_parse_spec(&restore_from_avp, &avp_spec)==0 || avp_spec.type!=PVT_AVP) { LM_ERR("malformed or non AVP %.*s AVP definition\n", restore_from_avp.len, restore_from_avp.s); return -1; } if(pv_get_avp_name(0, &avp_spec.pvp, &restore_from_avp_name, &restore_from_avp_type)!=0) { LM_ERR("[%.*s]- invalid AVP definition\n", restore_from_avp.len, restore_from_avp.s); return -1; } restore_from_avp_type |= AVP_VAL_STR; } if(restore_to_avp.s) { if (pv_parse_spec(&restore_to_avp, &avp_spec)==0 || avp_spec.type!=PVT_AVP) { LM_ERR("malformed or non AVP %.*s AVP definition\n", restore_to_avp.len, restore_to_avp.s); return -1; } if(pv_get_avp_name(0, &avp_spec.pvp, &restore_to_avp_name, &restore_to_avp_type)!=0) { LM_ERR("[%.*s]- invalid AVP definition\n", restore_to_avp.len, restore_to_avp.s); return -1; } restore_to_avp_type |= AVP_VAL_STR; } if (restore_mode==UAC_AUTO_RESTORE) { /* we need the append_fromtag on in RR */ memset(&dlg_api, 0, sizeof(struct dlg_binds)); if (uac_restore_dlg==0 || load_dlg_api(&dlg_api)!=0) { if (!uac_rrb.append_fromtag) { LM_ERR("'append_fromtag' RR param is not enabled!" " - required by AUTO restore mode\n"); goto error; } if (uac_restore_dlg!=0) LM_DBG("failed to find dialog API - is dialog module loaded?\n"); } /* get all requests doing loose route */ if (uac_rrb.register_rrcb( rr_checker, 0)!=0) { LM_ERR("failed to install RR callback\n"); goto error; } } } if(reg_db_url.s && reg_db_url.len>=0) { if(!reg_contact_addr.s || reg_contact_addr.len<=0) { LM_ERR("contact address parameter not set\n"); goto error; } if(reg_htable_size>14) reg_htable_size = 14; if(reg_htable_size<2) reg_htable_size = 2; reg_htable_size = 1<<reg_htable_size; if(uac_reg_init_rpc()!=0) { LM_ERR("failed to register RPC commands\n"); goto error; } if(uac_reg_init_ht(reg_htable_size)<0) { LM_ERR("failed to init reg htable\n"); goto error; } register_procs(1); /* add child to update local config framework structures */ cfg_register_child(1); } init_from_replacer(); uac_req_init(); return 0; error: return -1; }
/** * init module function */ static int mod_init(void) { bind_pua_t bind_pua; evs_process_body_t* evp=0; bind_pua= (bind_pua_t)find_export("bind_pua", 1,0); if (!bind_pua) { LM_ERR("Can't bind pua\n"); return -1; } if (bind_pua(&pua) < 0) { LM_ERR("Can't bind pua\n"); return -1; } if(pua.send_publish == NULL) { LM_ERR("Could not import send_publish\n"); return -1; } pua_send_publish= pua.send_publish; if(!osips_ps) evp = dialoginfo_process_body; /* add event in pua module */ if(pua.add_event(DIALOG_EVENT, "dialog", "application/dialog-info+xml", evp) < 0) { LM_ERR("failed to add 'dialog' event to pua module\n"); return -1; } /* bind to the dialog API */ if (load_dlg_api(&dlg_api)!=0) { LM_ERR("failed to find dialog API - is dialog module loaded?\n"); return -1; } if(presence_server.s) presence_server.len = strlen(presence_server.s); if(caller_spec_param.s) { caller_spec_param.len = strlen(caller_spec_param.s); if(pv_parse_spec(&caller_spec_param, &caller_spec)==NULL) { LM_ERR("failed to parse caller spec\n"); return -2; } switch(caller_spec.type) { case PVT_NONE: case PVT_EMPTY: case PVT_NULL: case PVT_MARKER: case PVT_COLOR: LM_ERR("invalid caller spec\n"); return -3; default: ; } } if(callee_spec_param.s) { callee_spec_param.len = strlen(callee_spec_param.s); if(pv_parse_spec(&callee_spec_param, &callee_spec)==NULL) { LM_ERR("failed to parse callee spec\n"); return -2; } switch(callee_spec.type) { case PVT_NONE: case PVT_EMPTY: case PVT_NULL: case PVT_MARKER: case PVT_COLOR: LM_ERR("invalid callee spec\n"); return -3; default: ; } } return 0; }
static int mod_init( void ) { pv_spec_t avp_spec; LM_INFO("initializing...\n"); if (db_url.s) db_url.len = strlen(db_url.s); db_table_acc.len = strlen(db_table_acc.s); db_table_mc.len = strlen(db_table_mc.s); acc_method_col.len = strlen(acc_method_col.s); acc_fromtag_col.len = strlen(acc_fromtag_col.s); acc_totag_col.len = strlen(acc_totag_col.s); acc_callid_col.len = strlen(acc_callid_col.s); acc_sipcode_col.len = strlen(acc_sipcode_col.s); acc_sipreason_col.len = strlen(acc_sipreason_col.s); acc_time_col.len = strlen(acc_time_col.s); if (log_facility_str) { int tmp = str2facility(log_facility_str); if (tmp != -1) acc_log_facility = tmp; else { LM_ERR("invalid log facility configured"); return -1; } } /* ----------- GENERIC INIT SECTION ----------- */ fix_flag_name(failed_transaction_string, failed_transaction_flag); failed_transaction_flag = get_flag_id_by_name(FLAG_TYPE_MSG, failed_transaction_string); if (flag_idx2mask(&failed_transaction_flag)<0) return -1; fix_flag_name(cdr_string, cdr_flag); cdr_flag = get_flag_id_by_name(FLAG_TYPE_MSG, cdr_string); if (flag_idx2mask(&cdr_flag)<0) return -1; /* load the TM API */ if (load_tm_api(&tmb)!=0) { LM_ERR("can't load TM API\n"); return -1; } if (load_dlg_api(&dlg_api)!=0) LM_DBG("failed to find dialog API - is dialog module loaded?\n"); if (cdr_flag && !dlg_api.get_dlg) { LM_WARN("error loading dialog module - cdrs cannot be generated\n"); cdr_flag = 0; } /* if detect_direction is enabled, load rr also */ if (detect_direction) { if (load_rr_api(&rrb)!=0) { LM_ERR("can't load RR API\n"); return -1; } /* we need the append_fromtag on in RR */ if (!rrb.append_fromtag) { LM_ERR("'append_fromtag' RR param is not enabled!" " - required by 'detect_direction'\n"); return -1; } } /* listen for all incoming requests */ if ( tmb.register_tmcb( 0, 0, TMCB_REQUEST_IN, acc_onreq, 0, 0 ) <=0 ) { LM_ERR("cannot register TMCB_REQUEST_IN callback\n"); return -1; } /* init the extra engine */ init_acc_extra(); /* configure multi-leg accounting */ if (leg_info_str && (leg_info=parse_acc_leg(leg_info_str))==0 ) { LM_ERR("failed to parse multi_leg_info param\n"); return -1; } if (leg_bye_info_str && (leg_bye_info=parse_acc_leg(leg_bye_info_str))==0 ) { LM_ERR("failed to parse multi_leg_bye_info param\n"); return -1; } /* ----------- SYSLOG INIT SECTION ----------- */ /* parse the extra string, if any */ if (log_extra_str && (log_extra=parse_acc_extra(log_extra_str, 1))==0 ) { LM_ERR("failed to parse log_extra param\n"); return -1; } if (log_extra_bye_str && (log_extra_bye=parse_acc_extra(log_extra_bye_str, 0))==0 ) { LM_ERR("failed to parse log_extra_bye param\n"); return -1; } fix_flag_name(log_string, log_flag); log_flag = get_flag_id_by_name(FLAG_TYPE_MSG, log_string); if (flag_idx2mask(&log_flag)<0) return -1; fix_flag_name(log_missed_string, log_missed_flag); log_missed_flag = get_flag_id_by_name(FLAG_TYPE_MSG, log_missed_string); if (flag_idx2mask(&log_missed_flag)<0) return -1; acc_log_init(); /* ------------ SQL INIT SECTION ----------- */ if (db_url.s && db_url.len > 0) { /* parse the extra string, if any */ if (db_extra_str && (db_extra=parse_acc_extra(db_extra_str, 1))==0 ) { LM_ERR("failed to parse db_extra param\n"); return -1; } if (db_extra_bye_str && (db_extra_bye=parse_acc_extra(db_extra_bye_str, 0))==0 ) { LM_ERR("failed to parse db_extra_bye param\n"); return -1; } if (acc_db_init(&db_url)<0){ LM_ERR("failed...did you load a database module?\n"); return -1; } /* fix the flags */ fix_flag_name(db_string, db_flag); db_flag = get_flag_id_by_name(FLAG_TYPE_MSG, db_string); if (flag_idx2mask(&db_flag)<0) return -1; fix_flag_name(db_missed_string, db_missed_flag); db_missed_flag = get_flag_id_by_name(FLAG_TYPE_MSG, db_missed_string); if (flag_idx2mask(&db_missed_flag)<0) return -1; if (db_table_avp.s) { db_table_avp.len = strlen(db_table_avp.s); if (pv_parse_spec(&db_table_avp, &avp_spec) == 0 || avp_spec.type != PVT_AVP) { LM_ERR("malformed or non AVP %s\n", db_table_avp.s); return -1; } if (pv_get_avp_name(0, &avp_spec.pvp, &db_table_name, &db_table_name_type)) { LM_ERR("invalid definition of AVP %s\n", db_table_avp.s); return -1; } } } else { db_flag = 0; db_missed_flag = 0; } /* ------------ AAA PROTOCOL INIT SECTION ----------- */ if (aaa_proto_url && aaa_proto_url[0]) { /* parse the extra string, if any */ if (aaa_extra_str && (aaa_extra = parse_acc_extra(aaa_extra_str, 1))==0) { LM_ERR("failed to parse aaa_extra param\n"); return -1; } if (aaa_extra_bye_str && (aaa_extra_bye = parse_acc_extra(aaa_extra_bye_str, 0))==0) { LM_ERR("failed to parse aaa_extra_bye param\n"); return -1; } /* fix the flags */ fix_flag_name(aaa_string, aaa_flag); aaa_flag = get_flag_id_by_name(FLAG_TYPE_MSG, aaa_string); if (flag_idx2mask(&aaa_flag)<0) return -1; fix_flag_name(aaa_missed_string, aaa_missed_flag); aaa_missed_flag = get_flag_id_by_name(FLAG_TYPE_MSG, aaa_missed_string); if (flag_idx2mask(&aaa_missed_flag)<0) return -1; if (init_acc_aaa(aaa_proto_url, service_type)!=0 ) { LM_ERR("failed to init radius\n"); return -1; } } else { aaa_proto_url = NULL; aaa_flag = 0; aaa_missed_flag = 0; } /* ------------ DIAMETER INIT SECTION ----------- */ #ifdef DIAM_ACC /* fix the flags */ fix_flag_name(diameter_string, diameter_flag); diameter_flag = get_flag_id_by_name(FLAG_TYPE_MSG, diameter_string); if (flag_idx2mask(&diameter_flag)<0) return -1; fix_flag_name(diameter_missed_string, diameter_missed_flag); diameter_missed_flag=get_flag_id_by_name(FLAG_TYPE_MSG, diameter_missed_string); if (flag_idx2mask(&diameter_missed_flag)<0) return -1; /* parse the extra string, if any */ if (dia_extra_str && (dia_extra=parse_acc_extra(dia_extra_str))==0 ) { LM_ERR("failed to parse dia_extra param\n"); return -1; } if (acc_diam_init()!=0) { LM_ERR("failed to init diameter engine\n"); return -1; } #endif /* ------------ EVENTS INIT SECTION ----------- */ if (evi_extra_str && (evi_extra = parse_acc_extra(evi_extra_str, 1))==0) { LM_ERR("failed to parse evi_extra param\n"); return -1; } if (evi_extra_bye_str && (evi_extra_bye = parse_acc_extra(evi_extra_bye_str, 0))==0) { LM_ERR("failed to parse evi_extra_bye param\n"); return -1; } /* fix the flags */ fix_flag_name(evi_string, evi_flag); evi_flag = get_flag_id_by_name(FLAG_TYPE_MSG, evi_string); if (flag_idx2mask(&evi_flag)<0) return -1; fix_flag_name(evi_missed_string, evi_missed_flag); evi_missed_flag = get_flag_id_by_name(FLAG_TYPE_MSG, evi_missed_string); if (flag_idx2mask(&evi_missed_flag)<0) return -1; if (init_acc_evi() < 0) { LM_ERR("cannot init acc events\n"); return -1; } /* load callbacks */ if (cdr_flag && dlg_api.get_dlg && dlg_api.register_dlgcb(NULL, DLGCB_LOADED,acc_loaded_callback, NULL, NULL) < 0) LM_ERR("cannot register callback for dialog loaded - accounting " "for ongoing calls will be lost after restart\n"); return 0; }
/** * init module function */ static int mod_init(void) { bind_pua_t bind_pua; evs_process_body_t* evp=0; bind_pua= (bind_pua_t)find_export("bind_pua", 1,0); if (!bind_pua) { LM_ERR("Can't bind pua\n"); return -1; } if (bind_pua(&pua) < 0) { LM_ERR("Can't bind pua\n"); return -1; } if(pua.send_publish == NULL) { LM_ERR("Could not import send_publish\n"); return -1; } pua_send_publish= pua.send_publish; if (nopublish_flag!= -1 && nopublish_flag > MAX_FLAG) { LM_ERR("invalid nopublish flag %d!!\n", nopublish_flag); return -1; } nopublish_flag = (nopublish_flag!=-1)?(1<<nopublish_flag):0; if(!osips_ps) evp = dialoginfo_process_body; /* add event in pua module */ if(pua.add_event(DIALOG_EVENT, "dialog", "application/dialog-info+xml", evp) < 0) { LM_ERR("failed to add 'dialog' event to pua module\n"); return -1; } /* bind to the dialog API */ if (load_dlg_api(&dlg_api)!=0) { LM_ERR("failed to find dialog API - is dialog module loaded?\n"); return -1; } /* register dialog loading callback */ if (dlg_api.register_dlgcb(NULL, DLGCB_LOADED, __dialog_loaded, NULL, NULL) != 0) { LM_CRIT("cannot register callback for dialogs loaded from the database\n"); } if(presence_server.s) presence_server.len = strlen(presence_server.s); if(caller_spec_param.s) { caller_spec_param.len = strlen(caller_spec_param.s); if(pv_parse_spec(&caller_spec_param, &caller_spec)==NULL) { LM_ERR("failed to parse caller spec\n"); return -2; } switch(caller_spec.type) { case PVT_NONE: case PVT_EMPTY: case PVT_NULL: case PVT_MARKER: case PVT_COLOR: LM_ERR("invalid caller spec\n"); return -3; default: ; } } if(callee_spec_param.s) { callee_spec_param.len = strlen(callee_spec_param.s); if(pv_parse_spec(&callee_spec_param, &callee_spec)==NULL) { LM_ERR("failed to parse callee spec\n"); return -2; } switch(callee_spec.type) { case PVT_NONE: case PVT_EMPTY: case PVT_NULL: case PVT_MARKER: case PVT_COLOR: LM_ERR("invalid callee spec\n"); return -3; default: ; } } return 0; }
/*! \brief * Module initialization function */ static int mod_init(void) { int i; load_dlg_f load_dlg; if (usrloc_debug){ LM_INFO("Logging usrloc records to %.*s\n", usrloc_debug_file.len, usrloc_debug_file.s); debug_file = fopen(usrloc_debug_file.s, "a"); fprintf(debug_file, "starting\n"); fflush(debug_file); } if (rpc_register_array(ul_rpc) != 0) { LM_ERR("failed to register RPC commands\n"); return -1; } if (ul_hash_size <= 1) ul_hash_size = 512; else ul_hash_size = 1 << ul_hash_size; ul_locks_no = ul_hash_size; if (subs_hash_size <= 1) subs_hash_size = 512; else subs_hash_size = 1 << subs_hash_size; subs_locks_no = subs_hash_size; if (contacts_hash_size <= 1) contacts_hash_size = 512; else contacts_hash_size = 1 << contacts_hash_size; contacts_locks_no = contacts_hash_size; /* check matching mode */ switch (matching_mode) { case CONTACT_ONLY: case CONTACT_CALLID: case CONTACT_PATH: case CONTACT_PORT_IP_ONLY: break; default: LM_ERR("invalid matching mode %d\n", matching_mode); } if (ul_init_locks() != 0) { LM_ERR("locks array initialization failed\n"); return -1; } /* create hash table for storing registered contacts */ if (init_contacts_locks() !=0) { LM_ERR("failed to initialise locks array for contacts\n"); return -1; } contact_list = (struct contact_list*)shm_malloc(sizeof(struct contact_list)); if (!contact_list) { LM_ERR("no more memory to create contact list structure\n"); return -1; } contact_list->slot = (struct contact_hslot*) shm_malloc(sizeof(struct contact_hslot) * contacts_hash_size); if (!contact_list->slot) { LM_ERR("no more memory to create contact list structure\n"); return -1; } for (i=0; i<contacts_hash_size;i++) { init_contact_slot(&contact_list->slot[i], i); } contact_list->size = contacts_hash_size; if (subs_init_locks() != 0) { LM_ERR("IMS Subscription locks array initialization failed\n"); return -1; } ims_subscription_list = (struct ims_subscription_list*) shm_malloc(sizeof(struct ims_subscription_list)); if (!ims_subscription_list) { LM_ERR("no more shm memory to create ims subscription list\n"); return -1; } ims_subscription_list->slot = (struct hslot_sp*) shm_malloc(sizeof(struct hslot_sp) * subs_hash_size); if (!ims_subscription_list->slot) { LM_ERR("no more memory to create subscription list structure\n"); return -1; } for (i=0; i<subs_hash_size;i++) { subs_init_slot(&ims_subscription_list->slot[i], i); } ims_subscription_list->size = subs_hash_size; /* presence binding for subscribe processing*/ presence_api_t pres; bind_presence_t bind_presence; bind_presence= (bind_presence_t)find_export("bind_presence", 1,0); if (!bind_presence) { LM_ERR("can't bind presence\n"); return -1; } if (bind_presence(&pres) < 0) { LM_ERR("can't bind pua\n"); return -1; } pres_extract_sdialog_info= pres.extract_sdialog_info; pres_new_shtable = pres.new_shtable; pres_destroy_shtable = pres.destroy_shtable; pres_insert_shtable = pres.insert_shtable; pres_delete_shtable = pres.delete_shtable; pres_update_shtable = pres.update_shtable; pres_search_shtable = pres.search_shtable; if(!pres_new_shtable || !pres_destroy_shtable || !pres_insert_shtable || !pres_delete_shtable || !pres_update_shtable || !pres_search_shtable || !pres_extract_sdialog_info) { LM_ERR("could not import add_event\n"); return -1; } /* subscriber dialog hash table */ if(sub_dialog_hash_size<=1) { sub_dialog_hash_size= 512; } else { sub_dialog_hash_size = 1<<sub_dialog_hash_size; } sub_dialog_table= pres_new_shtable(sub_dialog_hash_size); if(sub_dialog_table== NULL) { LM_ERR("while creating new hash table\n"); return -1; } /* Shall we use database ? */ if (db_mode != NO_DB) { /* Yes */ if (db_bind_mod(&db_url, &ul_dbf) < 0) { /* Find database module */ LM_ERR("failed to bind database module\n"); return -1; } if (!DB_CAPABILITY(ul_dbf, DB_CAP_ALL)) { LM_ERR("database module does not implement all functions" " needed by the module\n"); return -1; } if (ul_fetch_rows <= 0) { LM_ERR("invalid fetch_rows number '%d'\n", ul_fetch_rows); return -1; } } if (!(load_dlg = (load_dlg_f) find_export("load_dlg", 0, 0))) { /* bind to dialog module */ LM_ERR("can not import load_dlg. This module requires Kamailio dialog module.\n"); } if (load_dlg(&dlgb) == -1) { return -1; } if (load_dlg_api(&dlgb) != 0) { /* load the dialog API */ LM_ERR("can't load Dialog API\n"); return -1; } /* Register counters */ if (ul_scscf_init_counters() != 0) { LM_ERR("Failed to register counters\n"); return -1; } /* Register cache timer */ register_timer(timer, 0, timer_interval); /* init the callbacks list */ if (init_ulcb_list() < 0) { LM_ERR("usrloc/callbacks initialization failed\n"); return -1; } if (nat_bflag == (unsigned int) -1) { nat_bflag = 0; } else if (nat_bflag >= 8 * sizeof(nat_bflag)) { LM_ERR("bflag index (%d) too big!\n", nat_bflag); return -1; } else { nat_bflag = 1 << nat_bflag; } init_flag = 1; /* From contact_dlg_handlers.c * * V1.1*/ if (dlgb.register_dlgcb(0x00, DLGCB_CREATED, contact_dlg_create_handler, 0x00, 0x00) ) { LM_ERR("Unable to setup DLGCB_CREATED"); return -1; } else { LM_DBG(" DLGCB_CREATED created successfully"); } return 0; }
static int mod_init(void) { int i, udp_receiver_no; LM_INFO("initializing module\n"); memset(&dlg_binds, 0, sizeof(dlg_binds)); if (load_dlg_api(&dlg_binds) != 0) { LM_ERR("failed to load dlg api\n"); return -1; } sdp_buffer.s = pkg_malloc(SDP_BUFFER_SIZE); if (!sdp_buffer.s) { LM_ERR("insufficient pkg memory\n"); return -1; } udp_receiver_no = count_init_children(0); if (!dont_fork) { #ifdef USE_TCP udp_receiver_no -= !tcp_disable ? tcp_children_no : 0; #endif udp_receiver_no--; /* MAIN */ } udp_receiver_no -= 2; /* TIMER, SANGOMA WORKER */ LM_DBG("Children: %d\n", udp_receiver_no); udp_receiver_pipes = pkg_malloc(2 * udp_receiver_no * sizeof(*udp_receiver_pipes)); if (!udp_receiver_pipes) { LM_ERR("Not enough pkg mem\n"); return -1; } index_lock = shm_malloc(sizeof(*index_lock)); if (!index_lock) { LM_ERR("No more shm mem\n"); return -1; } if (!lock_init(index_lock)) { LM_ERR("Failed to init lock\n"); return -1; } proc_counter = shm_malloc(sizeof(*proc_counter)); if (!proc_counter) { LM_ERR("Not enough shm mem\n"); return -1; } *proc_counter = 0; if (pipe(sangoma_pipe) != 0) { LM_ERR("Failed to create sangoma worker pipe\n"); return -1; } LM_DBG("Sangoma pipe: [%d %d]\n", sangoma_pipe[0], sangoma_pipe[1]); for (i = 0; i < udp_receiver_no; i++) { if (pipe(udp_receiver_pipes + 2 * i) != 0) { LM_ERR("Failed to create pipe for UDP receiver %d\n", i); return -1; } LM_DBG("SIP pipe: [%d %d]\n", udp_receiver_pipes[2 * i], udp_receiver_pipes[2 * i + 1]); } sngtc_init_cfg.operation_mode = SNGTC_MODE_SOAP_CLIENT; sngtc_init_cfg.log = sng_logger; sngtc_init_cfg.create_rtp = sng_create_rtp; sngtc_init_cfg.create_rtp_port = sng_create_rtp_port; sngtc_init_cfg.destroy_rtp = sng_destroy_rtp; sngtc_init_cfg.release_rtp_port = sng_release_rtp_port; if (sngtc_detect_init_modules(&sngtc_init_cfg, &i) != 0) { LM_ERR("failed to detect vocallo modules\n"); return -1; } LM_DBG("Detected %d vocallo modules\n", i); if (sngtc_activate_modules(&sngtc_init_cfg, &i) != 0) { LM_ERR("failed to activate vocallo modules\n"); return -1; } LM_DBG("Activated %d vocallo modules\n", i); return 0; }