/* * Initialize parent */ static int mod_init(void) { bind_usrloc_t bind_usrloc; DBG("registrar - initializing\n"); /* * We will need sl_send_reply from stateless * module for sending replies */ sl_reply = find_export("sl_send_reply", 2, 0); if (!sl_reply) { LOG(L_ERR, "registrar: This module requires sl module\n"); return -1; } realm_prefix.s = realm_pref; realm_prefix.len = strlen(realm_pref); bind_usrloc = (bind_usrloc_t)find_export("ul_bind_usrloc", 1, 0); if (!bind_usrloc) { LOG(L_ERR, "registrar: Can't bind usrloc\n"); return -1; } if (bind_usrloc(&ul) < 0) { return -1; } def_q = (float)default_q / (float)1000; return 0; }
/* If the usrloc module is loaded, this function will grab hooks into its * callback registration function, and add handleContactCallbacks() as the * callback for UL_CONTACT_INSERT and UL_CONTACT_EXPIRE. * * Returns 1 on success, and zero otherwise. */ int registerForUSRLOCCallbacks(void) { bind_usrloc_t bind_usrloc; usrloc_api_t ul; bind_usrloc = (bind_usrloc_t)find_export("ul_bind_usrloc", 1, 0); if (!bind_usrloc) { LM_INFO("Can't find ul_bind_usrloc\n"); goto error; } if (bind_usrloc(&ul) < 0 || ul.register_ulcb == NULL) { LM_INFO("Can't bind usrloc\n"); goto error; } ul.register_ulcb(UL_CONTACT_INSERT, handleContactCallbacks, NULL); ul.register_ulcb(UL_CONTACT_EXPIRE, handleContactCallbacks, NULL); ul.register_ulcb(UL_CONTACT_DELETE, handleContactCallbacks, NULL); return 1; error: LM_INFO("failed to register for callbacks with the USRLOC module.\n"); LM_INFO("openserSIPContactTable and openserSIPUserTable will be" " unavailable\n"); return 0; }
/* * Initialize parent */ static int mod_init(void) { bind_usrloc_t bind_usrloc; DBG("registrar - initializing\n"); /* * We will need sl_send_reply from stateless * module for sending replies */ sl_reply = find_export("sl_send_reply", 2, 0); if (!sl_reply) { LOG(L_ERR, "registrar: This module requires sl module\n"); return -1; } realm_prefix.s = realm_pref; realm_prefix.len = strlen(realm_pref); rcv_param.len = strlen(rcv_param.s); bind_usrloc = (bind_usrloc_t)find_export("ul_bind_usrloc", 1, 0); if (!bind_usrloc) { LOG(L_ERR, "registrar: Can't bind usrloc\n"); return -1; } /* Normalize default_q parameter */ if (default_q != Q_UNSPECIFIED) { if (default_q > MAX_Q) { DBG("registrar: default_q = %d, lowering to MAX_Q: %d\n", default_q, MAX_Q); default_q = MAX_Q; } else if (default_q < MIN_Q) { DBG("registrar: default_q = %d, raising to MIN_Q: %d\n", default_q, MIN_Q); default_q = MIN_Q; } } if (bind_usrloc(&ul) < 0) { return -1; } /* * Test if use_domain parameters of usrloc and registrar * module are equal */ if (ul.use_domain != use_domain) { LOG(L_ERR, "ERROR: 'use_domain' parameters of 'usrloc' and 'registrar' modules" " must have the same value !\n"); LOG(L_ERR, "(Hint: Did you forget to use modparam(\"registrar\", \"use_domain\", 1) in" " in your ser.cfg ?)\n"); return -1; } return 0; }
/** * init module function */ static int mod_init(void) { bind_usrloc_t bind_usrloc; /* fix the parameters */ if (!fix_parameters()) goto error; /* load the TM API */ if (load_tm_api(&isc_tmb) != 0) { LM_ERR("can't load TM API\n"); goto error; } 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(&isc_ulb) < 0) { return -1; } /* Init the isc_my_uri parameter */ if (!isc_my_uri_c) { LM_CRIT("mandatory parameter \"isc_my_uri\" found empty\n"); goto error; } isc_my_uri.s = isc_my_uri_c; isc_my_uri.len = strlen(isc_my_uri_c); isc_my_uri_sip.len = 4 + isc_my_uri.len; isc_my_uri_sip.s = shm_malloc(isc_my_uri_sip.len + 1); memcpy(isc_my_uri_sip.s, "sip:", 4); memcpy(isc_my_uri_sip.s + 4, isc_my_uri.s, isc_my_uri.len); isc_my_uri_sip.s[isc_my_uri_sip.len] = 0; LM_DBG("ISC module successfully initialised\n"); return 0; error: LM_ERR("Failed to initialise ISC module\n"); return -1; }
/* * Initialize parent */ static int mod_init(void) { bind_sl_t bind_sl; bind_usrloc_t bind_usrloc; DBG("registrar - initializing\n"); /* * We will need sl_send_reply from stateless * module for sending replies */ bind_sl = (bind_sl_t)find_export("bind_sl", 0, 0); if (!bind_sl) { ERR("This module requires sl module\n"); return -1; } if (bind_sl(&sl) < 0) return -1; bind_usrloc = (bind_usrloc_t)find_export("ul_bind_usrloc", 1, 0); if (!bind_usrloc) { ERR("Can't bind usrloc\n"); return -1; } /* Normalize default_q parameter */ if (default_q != Q_UNSPECIFIED) { if (default_q > MAX_Q) { DBG("registrar: default_q = %d, lowering to MAX_Q: %d\n", default_q, MAX_Q); default_q = MAX_Q; } else if (default_q < MIN_Q) { DBG("registrar: default_q = %d, raising to MIN_Q: %d\n", default_q, MIN_Q); default_q = MIN_Q; } } if (parse_attr_params() < 0) return -1; if (bind_usrloc(&ul) < 0) { return -1; } return 0; }
int natpinger_init(void) { bind_usrloc_t bind_usrloc; load_tm_f load_tm; char *p; if (natping_interval > 0) { bind_usrloc = (bind_usrloc_t)find_export("ul_bind_usrloc", 1, 0); if (!bind_usrloc) { LOG(L_ERR, "ERROR: nathelper: natpinger_init: Can't find usrloc module\n"); return -1; } if (bind_usrloc(&ul) < 0) { return -1; } if (natping_method != NULL) { for (p = natping_method; *p != '\0'; ++p) *p = toupper(*p); if (strcmp(natping_method, "NULL") == 0) natping_method = NULL; } if (natping_method != NULL) { /* import the TM auto-loading function */ if (!(load_tm = (load_tm_f)find_export("load_tm", NO_SCRIPT, 0))) { LOG(L_ERR, "ERROR: nathelper: natpinger_init: can't import load_tm\n"); return -1; } /* let the auto-loading function load all TM stuff */ if (load_tm(&tmb) == -1) return -1; } register_timer(natping, NULL, natping_interval); } return 0; }
static int mod_init(void) { pv_spec_t avp_spec; str s; bind_usrloc_t bind_usrloc; qvalue_t dq; callback_singleton = shm_malloc(sizeof (int)); *callback_singleton = 0; /*build the required strings */ scscf_serviceroute_uri_str.s = (char*) pkg_malloc(orig_prefix.len + scscf_name_str.len); if (!scscf_serviceroute_uri_str.s) { LM_ERR("Unable to allocate memory for service route uri\n"); return -1; } if (contact_expires_buffer_percentage < 0 || contact_expires_buffer_percentage > 90) { LM_ERR("contact expires percentage not valid, must be >0 and <=90"); return -1; } memcpy(scscf_serviceroute_uri_str.s, orig_prefix.s, orig_prefix.len); scscf_serviceroute_uri_str.len = orig_prefix.len; if (scscf_name_str.len > 4 && strncasecmp(scscf_name_str.s, "sip:", 4) == 0) { memcpy(scscf_serviceroute_uri_str.s + scscf_serviceroute_uri_str.len, scscf_name_str.s + 4, scscf_name_str.len - 4); scscf_serviceroute_uri_str.len += scscf_name_str.len - 4; } else { memcpy(scscf_serviceroute_uri_str.s + scscf_serviceroute_uri_str.len, scscf_name_str.s, scscf_name_str.len); scscf_serviceroute_uri_str.len += scscf_name_str.len; } pv_tmx_data_init(); /* </build required strings> */ #ifdef STATISTICS /* register statistics */ if (register_module_stats(exports.name, mod_stats) != 0) { LM_ERR("failed to register core statistics\n"); return -1; } if (!register_stats()) { LM_ERR("Unable to register statistics\n"); return -1; } #endif /*register space for notification processors*/ register_procs(notification_processes); cfg_register_child(notification_processes); /* bind the SL API */ if (sl_load_api(&slb) != 0) { LM_ERR("cannot bind to SL API\n"); return -1; } /* load the TM API */ if (load_tm_api(&tmb) != 0) { LM_ERR("can't load TM API\n"); return -1; } /* load the CDP API */ if (load_cdp_api(&cdpb) != 0) { LM_ERR("can't load CDP API\n"); return -1; } cdp_avp = load_cdp_avp(); if (!cdp_avp) { LM_ERR("can't load CDP_AVP API\n"); return -1; } if (cfg_declare("registrar", registrar_cfg_def, &default_registrar_cfg, cfg_sizeof(registrar), ®istrar_cfg)) { LM_ERR("Fail to declare the configuration\n"); return -1; } if (rcv_avp_param && *rcv_avp_param) { s.s = rcv_avp_param; 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", rcv_avp_param); return -1; } if (pv_get_avp_name(0, &avp_spec.pvp, &rcv_avp_name, &rcv_avp_type) != 0) { LM_ERR("[%s]- invalid AVP definition\n", rcv_avp_param); return -1; } } else { rcv_avp_name.n = 0; rcv_avp_type = 0; } if (aor_avp_param && *aor_avp_param) { s.s = aor_avp_param; 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", aor_avp_param); return -1; } if (pv_get_avp_name(0, &avp_spec.pvp, &aor_avp_name, &aor_avp_type) != 0) { LM_ERR("[%s]- invalid AVP definition\n", aor_avp_param); return -1; } } else { aor_avp_name.n = 0; aor_avp_type = 0; } if (reg_callid_avp_param && *reg_callid_avp_param) { s.s = reg_callid_avp_param; 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", reg_callid_avp_param); return -1; } if (pv_get_avp_name(0, &avp_spec.pvp, ®_callid_avp_name, ®_callid_avp_type) != 0) { LM_ERR("[%s]- invalid AVP definition\n", reg_callid_avp_param); return -1; } } else { reg_callid_avp_name.n = 0; reg_callid_avp_type = 0; } bind_usrloc = (bind_usrloc_t) find_export("ul_bind_usrloc", 1, 0); if (!bind_usrloc) { LM_ERR("can't bind usrloc\n"); return -1; } /* Normalize default_q parameter */ dq = cfg_get(registrar, registrar_cfg, default_q); if (dq != Q_UNSPECIFIED) { if (dq > MAX_Q) { LM_DBG("default_q = %d, lowering to MAX_Q: %d\n", dq, MAX_Q); dq = MAX_Q; } else if (dq < MIN_Q) { LM_DBG("default_q = %d, raising to MIN_Q: %d\n", dq, MIN_Q); dq = MIN_Q; } } cfg_get(registrar, registrar_cfg, default_q) = dq; 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; } if (ul.register_ulcb(0, 0, UL_IMPU_INSERT, ul_impu_inserted, 0) < 0) { LM_ERR("can not register callback for insert\n"); return -1; } if (sock_hdr_name.s) { if (sock_hdr_name.len == 0 || sock_flag == -1) { LM_WARN("empty sock_hdr_name or sock_flag no set -> reseting\n"); sock_hdr_name.len = 0; sock_flag = -1; } } else if (sock_flag != -1) { LM_WARN("sock_flag defined but no sock_hdr_name -> reseting flag\n"); sock_flag = -1; } /* fix the flags */ sock_flag = (sock_flag != -1) ? (1 << sock_flag) : 0; tcp_persistent_flag = (tcp_persistent_flag != -1) ? (1 << tcp_persistent_flag) : 0; /* init the registrar notifications */ if (!notify_init()) return -1; /* register the registrar notifications timer */ //Currently we do not use this - we send notifies immediately //if (register_timer(notification_timer, notification_list, 5) < 0) return -1; return 0; }
/*! \brief * Initialize parent */ static int mod_init(void) { pv_spec_t avp_spec; str s; bind_usrloc_t bind_usrloc; LM_INFO("initializing...\n"); /* load SIGNALING API */ if(load_sig_api(&sigb)< 0) { LM_ERR("can't load signaling functions\n"); return -1; } /* load TM API */ memset(&tmb, 0, sizeof(struct tm_binds)); load_tm_api(&tmb); realm_prefix.s = realm_pref; realm_prefix.len = strlen(realm_pref); rcv_param.len = strlen(rcv_param.s); if (rcv_avp_param && *rcv_avp_param) { s.s = rcv_avp_param; 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", rcv_avp_param); return -1; } if(pv_get_avp_name(0, &avp_spec.pvp, &rcv_avp_name, &rcv_avp_type)!=0) { LM_ERR("[%s]- invalid AVP definition\n", rcv_avp_param); return -1; } } else { rcv_avp_name = -1; rcv_avp_type = 0; } if (mct_avp_param && *mct_avp_param) { s.s = mct_avp_param; 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", mct_avp_param); return -1; } if(pv_get_avp_name(0, &avp_spec.pvp, &mct_avp_name, &mct_avp_type)!=0) { LM_ERR("[%s]- invalid AVP definition\n", mct_avp_param); return -1; } } else { mct_avp_name = -1; mct_avp_type = 0; } if (attr_avp_param && *attr_avp_param) { s.s = attr_avp_param; 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", attr_avp_param); return -1; } if(pv_get_avp_name(0, &avp_spec.pvp, &attr_avp_name, &attr_avp_type)!=0) { LM_ERR("[%s]- invalid AVP definition\n", attr_avp_param); return -1; } } else { attr_avp_name = -1; attr_avp_type = 0; } bind_usrloc = (bind_usrloc_t)find_export("ul_bind_usrloc", 1, 0); if (!bind_usrloc) { LM_ERR("can't bind usrloc\n"); return -1; } /* Normalize default_q parameter */ if (default_q != Q_UNSPECIFIED) { if (default_q > MAX_Q) { LM_DBG("default_q = %d, lowering to MAX_Q: %d\n", default_q, MAX_Q); default_q = MAX_Q; } else if (default_q < MIN_Q) { LM_DBG("default_q = %d, raising to MIN_Q: %d\n", default_q, MIN_Q); default_q = MIN_Q; } } if (bind_usrloc(&ul) < 0) { return -1; } /* * Import use_domain parameter from usrloc */ reg_use_domain = ul.use_domain; if (sock_hdr_name.s) sock_hdr_name.len = strlen(sock_hdr_name.s); if (gruu_secret.s) gruu_secret.len = strlen(gruu_secret.s); /* fix the flags */ fix_flag_name(tcp_persistent_flag_s, tcp_persistent_flag); tcp_persistent_flag = get_flag_id_by_name(FLAG_TYPE_MSG, tcp_persistent_flag_s); tcp_persistent_flag = (tcp_persistent_flag!=-1)?(1<<tcp_persistent_flag):0; return 0; }
/** * init module function */ static int mod_init(void) { bind_usrloc_t bind_usrloc; bind_pua_t bind_pua; LM_DBG("initializing module ...\n"); if(default_domain.s == NULL ) { LM_ERR("default domain parameter not set\n"); return -1; } default_domain.len= strlen(default_domain.s); if(pres_prefix.s == NULL ) { LM_DBG("No pres_prefix configured\n"); } else pres_prefix.len= strlen(pres_prefix.s); if(presence_server.s) { presence_server.len= strlen(presence_server.s); } 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) { LM_ERR("Can't bind usrloc\n"); return -1; } if(ul.register_ulcb == NULL) { LM_ERR("Could not import ul_register_ulcb\n"); return -1; } if(ul.register_ulcb(UL_CONTACT_INSERT, ul_publish, 0)< 0) { LM_ERR("can not register callback for" " insert\n"); return -1; } if(ul.register_ulcb(UL_CONTACT_EXPIRE, ul_publish, 0)< 0) { LM_ERR("can not register callback for" " expire\n"); return -1; } if(ul.register_ulcb(UL_CONTACT_UPDATE, ul_publish, 0)< 0) { LM_ERR("can not register callback for update\n"); return -1; } if(ul.register_ulcb(UL_CONTACT_DELETE, ul_publish, 0)< 0) { LM_ERR("can not register callback for delete\n"); return -1; } 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(pua.send_subscribe == NULL) { LM_ERR("Could not import send_subscribe\n"); return -1; } pua_send_subscribe= pua.send_subscribe; /* register post-script pua_unset_publish unset function */ if(register_script_cb(pua_unset_publish, POST_SCRIPT_CB|REQ_TYPE_CB, 0)<0) { LM_ERR("failed to register POST request callback\n"); return -1; } return 0; }
/*! \brief * Initialize parent */ static int mod_init(void) { pv_spec_t avp_spec; str s; bind_usrloc_t bind_usrloc; qvalue_t dq; if(sruid_init(&_reg_sruid, '-', "uloc", SRUID_INC)<0) return -1; #ifdef STATISTICS /* register statistics */ if (register_module_stats( exports.name, mod_stats)!=0 ) { LM_ERR("failed to register core statistics\n"); return -1; } #endif /* bind the SL API */ if (sl_load_api(&slb)!=0) { LM_ERR("cannot bind to SL API\n"); return -1; } if(cfg_declare("registrar", registrar_cfg_def, &default_registrar_cfg, cfg_sizeof(registrar), ®istrar_cfg)){ LM_ERR("Fail to declare the configuration\n"); return -1; } if (rcv_avp_param && *rcv_avp_param) { s.s = rcv_avp_param; 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", rcv_avp_param); return -1; } if(pv_get_avp_name(0, &avp_spec.pvp, &rcv_avp_name, &rcv_avp_type)!=0) { LM_ERR("[%s]- invalid AVP definition\n", rcv_avp_param); return -1; } } else { rcv_avp_name.n = 0; rcv_avp_type = 0; } if (reg_callid_avp_param && *reg_callid_avp_param) { s.s = reg_callid_avp_param; 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", reg_callid_avp_param); return -1; } if(pv_get_avp_name(0, &avp_spec.pvp, ®_callid_avp_name, ®_callid_avp_type)!=0) { LM_ERR("[%s]- invalid AVP definition\n", reg_callid_avp_param); return -1; } } else { reg_callid_avp_name.n = 0; reg_callid_avp_type = 0; } bind_usrloc = (bind_usrloc_t)find_export("ul_bind_usrloc", 1, 0); if (!bind_usrloc) { LM_ERR("can't bind usrloc\n"); return -1; } /* Normalize default_q parameter */ dq = cfg_get(registrar, registrar_cfg, default_q); if ( dq!= Q_UNSPECIFIED) { if (dq > MAX_Q) { LM_DBG("default_q = %d, lowering to MAX_Q: %d\n", dq, MAX_Q); dq = MAX_Q; } else if (dq < MIN_Q) { LM_DBG("default_q = %d, raising to MIN_Q: %d\n", dq, MIN_Q); dq = MIN_Q; } } cfg_get(registrar, registrar_cfg, default_q) = dq; if (bind_usrloc(&ul) < 0) { return -1; } if(ul.register_ulcb != NULL) { reg_expire_event_rt = route_lookup(&event_rt, "usrloc:contact-expired"); if (reg_expire_event_rt>=0 && event_rt.rlist[reg_expire_event_rt]==0) reg_expire_event_rt=-1; /* disable */ if (reg_expire_event_rt>=0) { set_child_rpc_sip_mode(); if(ul.register_ulcb(UL_CONTACT_EXPIRE, reg_ul_expired_contact, 0)< 0) { LM_ERR("can not register callback for expired contacts\n"); return -1; } } } /* * Import use_domain parameter from usrloc */ reg_use_domain = ul.use_domain; if (sock_hdr_name.s) { if (sock_hdr_name.len==0 || sock_flag==-1) { LM_WARN("empty sock_hdr_name or sock_flag no set -> reseting\n"); sock_hdr_name.len = 0; sock_flag = -1; } } else if (sock_flag!=-1) { LM_WARN("sock_flag defined but no sock_hdr_name -> reseting flag\n"); sock_flag = -1; } if (reg_outbound_mode < 0 || reg_outbound_mode > 2) { LM_ERR("outbound_mode modparam must be 0 (not supported), 1 (supported), or 2 (supported and required)\n"); return -1; } if (reg_regid_mode < 0 || reg_regid_mode > 1) { LM_ERR("regid_mode modparam must be 0 (use with outbound), 1 (use always)\n"); return -1; } if (reg_flow_timer < 0 || reg_flow_timer > REG_FLOW_TIMER_MAX || (reg_flow_timer > 0 && reg_outbound_mode == REG_OUTBOUND_NONE)) { LM_ERR("bad value for flow_timer\n"); return -1; } /* fix the flags */ sock_flag = (sock_flag!=-1)?(1<<sock_flag):0; tcp_persistent_flag = (tcp_persistent_flag!=-1)?(1<<tcp_persistent_flag):0; return 0; }
static int cpl_init(void) { bind_usrloc_t bind_usrloc; struct stat stat_t; char *ptr; int val; init_db_url( db_url , 0 /*cannot be null*/); db_table.len = strlen(db_table.s); LM_INFO("initializing...\n"); if (proxy_route && proxy_route[0]) { cpl_env.proxy_route = get_script_route_ID_by_name( proxy_route, rlist, RT_NO); if (cpl_env.proxy_route==-1) { LM_ERR("route <%s> does not exist\n",proxy_route); return -1; } } if (cpl_env.proxy_recurse>MAX_PROXY_RECURSE) { LM_CRIT("value of proxy_recurse param (%d) exceeds " "the maximum safety value (%d)\n", cpl_env.proxy_recurse,MAX_PROXY_RECURSE); goto error; } if (dtd_file==0) { LM_CRIT("mandatory parameter \"cpl_dtd_file\" found empty\n"); goto error; } else { /* check if the dtd file exists */ if (stat( dtd_file, &stat_t)==-1) { LM_ERR("checking file \"%s\" status failed; stat returned %s\n", dtd_file,strerror(errno)); goto error; } if ( !S_ISREG( stat_t.st_mode ) ) { LM_ERR("dir \"%s\" is not a regular file!\n", dtd_file); goto error; } if (access( dtd_file, R_OK )==-1) { LM_ERR("checking file \"%s\" for permissions " "failed; access returned %s\n",dtd_file,strerror(errno)); goto error; } } if (cpl_env.log_dir==0) { LM_INFO("log_dir param found empty -> logging disabled!\n"); } else { if ( strlen(cpl_env.log_dir)>MAX_LOG_DIR_SIZE ) { LM_ERR("dir \"%s\" has a too long name :-(!\n", cpl_env.log_dir); goto error; } /* check if the dir exists */ if (stat( cpl_env.log_dir, &stat_t)==-1) { LM_ERR("checking dir \"%s\" status failed;" " stat returned %s\n",cpl_env.log_dir,strerror(errno)); goto error; } if ( !S_ISDIR( stat_t.st_mode ) ) { LM_ERR("dir \"%s\" is not a directory!\n", cpl_env.log_dir); goto error; } if (access( cpl_env.log_dir, R_OK|W_OK )==-1) { LM_ERR("checking dir \"%s\" for permissions failed; access " "returned %s\n", cpl_env.log_dir, strerror(errno)); goto error; } } /* bind to the mysql module */ if (cpl_db_bind(&db_url, &db_table)<0) goto error; /* load TM API */ if (load_tm_api(&cpl_fct.tmb)!=0) { LM_ERR("can't load TM API\n"); goto error; } /* load SIGNALING API */ if(load_sig_api(&cpl_fct.sigb)< 0) { LM_ERR("can't load signaling functions\n"); return -1; } /* bind to usrloc module if requested */ if (lookup_domain) { /* import all usrloc functions */ bind_usrloc = (bind_usrloc_t)find_export("ul_bind_usrloc", 1, 0); if (!bind_usrloc) { LM_ERR("can't bind usrloc\n"); goto error; } if (bind_usrloc( &(cpl_fct.ulb) ) < 0) { LM_ERR("importing usrloc failed\n"); goto error; } /* convert lookup_domain from char* to udomain_t* pointer */ if (cpl_fct.ulb.register_udomain( lookup_domain, &cpl_env.lu_domain) < 0) { LM_ERR("failed to register domain <%s>\n",lookup_domain); goto error; } } else { LM_NOTICE("no lookup_domain given -> disable lookup node\n"); } /* build a pipe for sending commands to aux process */ if ( pipe( cpl_env.cmd_pipe )==-1 ) { LM_CRIT("cannot create command pipe: %s!\n", strerror(errno) ); goto error; } /* set the writing non blocking */ if ( (val=fcntl(cpl_env.cmd_pipe[1], F_GETFL, 0))<0 ) { LM_ERR("getting flags from pipe[1] failed: fcntl said %s!\n", strerror(errno)); goto error; } if ( fcntl(cpl_env.cmd_pipe[1], F_SETFL, val|O_NONBLOCK) ) { LM_ERR("setting flags to pipe[1] failed: fcntl said %s!\n", strerror(errno)); goto error; } /* init the CPL parser */ if (init_CPL_parser( dtd_file )!=1 ) { LM_ERR("init_CPL_parser failed!\n"); goto error; } /* make a copy of the original TZ env. variable */ ptr = getenv("TZ"); cpl_env.orig_tz.len = 3/*"TZ="*/ + (ptr?(strlen(ptr)+1):0); if ( (cpl_env.orig_tz.s=shm_malloc( cpl_env.orig_tz.len ))==0 ) { LM_ERR("no more shm mem. for saving TZ!\n"); goto error; } memcpy(cpl_env.orig_tz.s,"TZ=",3); if (ptr) strcpy(cpl_env.orig_tz.s+3,ptr); /* convert realm_prefix from string null terminated to str */ if (cpl_env.realm_prefix.s) { cpl_env.realm_prefix.len = strlen(cpl_env.realm_prefix.s); /* convert the realm_prefix to lower cases */ strlower( &cpl_env.realm_prefix ); } return 0; error: return -1; }
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; }
/** * init module function */ static int mod_init(void) { bind_pua_t bind_pua; bind_usrloc_t bind_usrloc; if (publish_reginfo == 1) { /* Verify the default domain: */ if(default_domain.s == NULL ) { LM_ERR("default domain parameter not set\n"); return -1; } default_domain.len= strlen(default_domain.s); } if(server_address.s== NULL) { LM_ERR("server_address parameter not set\n"); return -1; } server_address.len= strlen(server_address.s); if(outbound_proxy.s == NULL) LM_DBG("No outbound proxy set\n"); else outbound_proxy.len= strlen(outbound_proxy.s); /* Bind to PUA: */ 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; } /* Check for Publish/Subscribe methods */ if(pua.send_publish == NULL) { LM_ERR("Could not import send_publish\n"); return -1; } if(pua.send_subscribe == NULL) { LM_ERR("Could not import send_subscribe\n"); return -1; } /* Bind to URSLOC: */ 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) { LM_ERR("Can't bind usrloc\n"); return -1; } if (publish_reginfo == 1) { if(ul.register_ulcb == NULL) { LM_ERR("Could not import ul_register_ulcb\n"); return -1; } if(ul.register_ulcb(UL_CONTACT_INSERT, reginfo_usrloc_cb , 0)< 0) { LM_ERR("can not register callback for insert\n"); return -1; } if(ul.register_ulcb(UL_CONTACT_EXPIRE, reginfo_usrloc_cb, 0)< 0) { LM_ERR("can not register callback for expire\n"); return -1; } if(ul.register_ulcb(UL_CONTACT_UPDATE, reginfo_usrloc_cb, 0)< 0) { LM_ERR("can not register callback for update\n"); return -1; } if(ul.register_ulcb(UL_CONTACT_DELETE, reginfo_usrloc_cb, 0)< 0) { LM_ERR("can not register callback for delete\n"); return -1; } } if(sruid_init(&_reginfo_sruid, (char)'-', "regi", SRUID_INC)<0) return -1; return 0; }
static int cpl_init(void) { bind_usrloc_t bind_usrloc; struct stat stat_t; char *ptr; int val; pv_spec_t avp_spec; unsigned short avp_type; if(register_mi_mod(exports.name, mi_cmds)!=0) { LM_ERR("failed to register MI commands\n"); return -1; } db_url.len = strlen(db_url.s); db_table.len = strlen(db_table.s); if (timer_avp.s) timer_avp.len = strlen(timer_avp.s); if (cpl_env.proxy_recurse>MAX_PROXY_RECURSE) { LM_CRIT("value of proxy_recurse param (%d) exceeds " "the maximum safety value (%d)\n", cpl_env.proxy_recurse,MAX_PROXY_RECURSE); goto error; } /* fix the timer_avp name */ if (timer_avp.s && timer_avp.len > 0) { if (pv_parse_spec(&timer_avp, &avp_spec)==0 || avp_spec.type!=PVT_AVP) { LM_ERR("malformed or non AVP %.*s AVP definition\n", timer_avp.len, timer_avp.s); return -1; } if(pv_get_avp_name(0, &(avp_spec.pvp), &cpl_env.timer_avp, &avp_type)!=0) { LM_ERR("[%.*s]- invalid AVP definition\n", timer_avp.len, timer_avp.s); return -1; } cpl_env.timer_avp_type = avp_type; } if (dtd_file==0) { LM_CRIT("mandatory parameter \"cpl_dtd_file\" found empty\n"); goto error; } else { /* check if the dtd file exists */ if (stat( dtd_file, &stat_t)==-1) { LM_ERR("checking file \"%s\" status failed; stat returned %s\n", dtd_file,strerror(errno)); goto error; } if ( !S_ISREG( stat_t.st_mode ) ) { LM_ERR("dir \"%s\" is not a regular file!\n", dtd_file); goto error; } if (access( dtd_file, R_OK )==-1) { LM_ERR("checking file \"%s\" for permissions " "failed; access returned %s\n",dtd_file,strerror(errno)); goto error; } } if (cpl_env.log_dir==0) { LM_INFO("log_dir param found empty -> logging disabled!\n"); } else { if ( strlen(cpl_env.log_dir)>MAX_LOG_DIR_SIZE ) { LM_ERR("dir \"%s\" has a too long name :-(!\n", cpl_env.log_dir); goto error; } /* check if the dir exists */ if (stat( cpl_env.log_dir, &stat_t)==-1) { LM_ERR("checking dir \"%s\" status failed;" " stat returned %s\n",cpl_env.log_dir,strerror(errno)); goto error; } if ( !S_ISDIR( stat_t.st_mode ) ) { LM_ERR("dir \"%s\" is not a directory!\n", cpl_env.log_dir); goto error; } if (access( cpl_env.log_dir, R_OK|W_OK )==-1) { LM_ERR("checking dir \"%s\" for permissions failed; access " "returned %s\n", cpl_env.log_dir, strerror(errno)); goto error; } } /* bind to the mysql module */ if (cpl_db_bind(&db_url, &db_table)<0) goto error; /* load TM API */ if (load_tm_api(&cpl_fct.tmb)!=0) { LM_ERR("can't load TM API\n"); goto error; } /* bind the SL API */ if (sl_load_api(&cpl_fct.slb)!=0) { LM_ERR("cannot bind to SL API\n"); return -1; } /* bind to usrloc module if requested */ if (lookup_domain) { /* import all usrloc functions */ bind_usrloc = (bind_usrloc_t)find_export("ul_bind_usrloc", 1, 0); if (!bind_usrloc) { LM_ERR("can't bind usrloc\n"); goto error; } if (bind_usrloc( &(cpl_fct.ulb) ) < 0) { LM_ERR("importing usrloc failed\n"); goto error; } /* convert lookup_domain from char* to udomain_t* pointer */ if (cpl_fct.ulb.register_udomain( lookup_domain, &cpl_env.lu_domain) < 0) { LM_ERR("failed to register domain <%s>\n",lookup_domain); goto error; } } else { LM_NOTICE("no lookup_domain given -> disable lookup node\n"); } /* build a pipe for sending commands to aux process */ if ( pipe( cpl_env.cmd_pipe )==-1 ) { LM_CRIT("cannot create command pipe: %s!\n", strerror(errno) ); goto error; } /* set the writing non blocking */ if ( (val=fcntl(cpl_env.cmd_pipe[1], F_GETFL, 0))<0 ) { LM_ERR("getting flags from pipe[1] failed: fcntl said %s!\n", strerror(errno)); goto error; } if ( fcntl(cpl_env.cmd_pipe[1], F_SETFL, val|O_NONBLOCK) ) { LM_ERR("setting flags to pipe[1] failed: fcntl said %s!\n", strerror(errno)); goto error; } /* init the CPL parser */ if (init_CPL_parser( dtd_file )!=1 ) { LM_ERR("init_CPL_parser failed!\n"); goto error; } /* make a copy of the original TZ env. variable */ ptr = getenv("TZ"); cpl_env.orig_tz.len = 3/*"TZ="*/ + (ptr?(strlen(ptr)+1):0); if ( (cpl_env.orig_tz.s=shm_malloc( cpl_env.orig_tz.len ))==0 ) { LM_ERR("no more shm mem. for saving TZ!\n"); goto error; } memcpy(cpl_env.orig_tz.s,"TZ=",3); if (ptr) strcpy(cpl_env.orig_tz.s+3,ptr); /* convert realm_prefix from string null terminated to str */ if (cpl_env.realm_prefix.s) { cpl_env.realm_prefix.len = strlen(cpl_env.realm_prefix.s); /* convert the realm_prefix to lower cases */ strlower( &cpl_env.realm_prefix ); } return 0; error: return -1; }
/*! \brief * Initialize parent */ static int mod_init(void) { bind_usrloc_t bind_usrloc; bind_pua_t bind_pua; /*register space for event processor*/ register_procs(1); if (!fix_parameters()) goto error; /* bind the SL API */ if (sl_load_api(&slb) != 0) { LM_ERR("cannot bind to SL API\n"); return -1; } LM_DBG("Successfully bound to SL module\n"); /* load the TM API */ if (load_tm_api(&tmb) != 0) { LM_ERR("can't load TM API\n"); return -1; } LM_DBG("Successfully bound to TM module\n"); bind_usrloc = (bind_usrloc_t) find_export("ul_bind_ims_usrloc_pcscf", 1, 0); if (!bind_usrloc) { LM_ERR("can't bind ims_usrloc_pcscf\n"); return -1; } if (bind_usrloc(&ul) < 0) { return -1; } LM_DBG("Successfully bound to PCSCF Usrloc module\n"); if(subscribe_to_reginfo == 1){ /* Bind to PUA: */ 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; } /* Check for Publish/Subscribe methods */ if (pua.send_publish == NULL) { LM_ERR("Could not import send_publish\n"); return -1; } if (pua.send_subscribe == NULL) { LM_ERR("Could not import send_subscribe\n"); return -1; } if (pua.get_subs_list == NULL) { LM_ERR("Could not import get_subs_list\n"); return -1; } LM_DBG("Successfully bound to PUA module\n"); /*init cdb cb event list*/ if (!init_reginfo_event_list()) { LM_ERR("unable to initialise reginfo_event_list\n"); return -1; } LM_DBG("Successfully initialised reginfo_event_list\n"); } return 0; error: return -1; }
/*! \brief * init module function */ static int mod_init(void) { bind_usrloc_t bind_usrloc; bind_pua_t bind_pua; if(!default_domain.s || default_domain.len<=0) { LM_ERR("default domain parameter not set\n"); return -1; } if(!pres_prefix.s || pres_prefix.len<=0) LM_DBG("No pres_prefix configured\n"); 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) { LM_ERR("Can't bind usrloc\n"); return -1; } if(ul.register_ulcb == NULL) { LM_ERR("Could not import ul_register_ulcb\n"); return -1; } if(ul.register_ulcb(UL_CONTACT_INSERT, ul_publish, 0)< 0) { LM_ERR("can not register callback for" " insert\n"); return -1; } if(ul.register_ulcb(UL_CONTACT_EXPIRE, ul_publish, 0)< 0) { LM_ERR("can not register callback for" " expire\n"); return -1; } if(ul.register_ulcb(UL_CONTACT_UPDATE, ul_publish, 0)< 0) { LM_ERR("can not register callback for update\n"); return -1; } if(ul.register_ulcb(UL_CONTACT_DELETE, ul_publish, 0)< 0) { LM_ERR("can not register callback for delete\n"); return -1; } 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(&_pu_pua) < 0) { LM_ERR("Can't bind pua\n"); return -1; } if(_pu_pua.send_publish == NULL) { LM_ERR("Could not import send_publish\n"); return -1; } if(_pu_pua.send_subscribe == NULL) { LM_ERR("Could not import send_subscribe\n"); return -1; } /* register post-script pua_unset_publish unset function */ if(register_script_cb(pua_unset_publish, POST_SCRIPT_CB|REQUEST_CB, 0)<0) { LM_ERR("failed to register POST request callback\n"); return -1; } if(pua_ul_bflag!=-1) pua_ul_bmask = 1 << pua_ul_bflag; return 0; }
/** * init module function */ static int mod_init(void) { LM_DBG("initialize module...\n"); bind_pua_t bind_pua; bind_usrloc_t bind_usrloc; if(server_address.s== NULL) { LM_ERR("compulsory 'server_address' parameter not set!"); return -1; } server_address.len= strlen(server_address.s); if(presence_server.s) { presence_server.len= strlen(presence_server.s); } if(default_domain.s) { default_domain.len= strlen(default_domain.s); } if(header_name.s == NULL ) { LM_ERR("header_name parameter not set\n"); return -1; } header_name.len= strlen(header_name.s); if(bla_outbound_proxy.s == NULL ) { LM_DBG("No outbound proxy set\n"); } else bla_outbound_proxy.len= strlen(bla_outbound_proxy.s); 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(pua.send_subscribe == NULL) { LM_ERR("Could not import send_subscribe\n"); return -1; } pua_send_subscribe= pua.send_subscribe; if(pua.is_dialog == NULL) { LM_ERR("Could not import send_subscribe\n"); return -1; } pua_is_dialog= pua.is_dialog; if(pua.register_puacb== NULL) { LM_ERR("Could not import register callback\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) { LM_ERR("Can't bind usrloc\n"); return -1; } if(ul.register_ulcb == NULL) { LM_ERR("Could not import ul_register_ulcb\n"); return -1; } if(ul.register_ulcb(UL_CONTACT_INSERT, bla_cb , 0)< 0) { LM_ERR("can not register callback for" " insert\n"); return -1; } if(ul.register_ulcb(UL_CONTACT_EXPIRE, bla_cb, 0)< 0) { LM_ERR("can not register callback for" " insert\n"); return -1; } if(ul.register_ulcb(UL_CONTACT_UPDATE, bla_cb, 0)< 0) { LM_ERR("can not register callback for" " update\n"); return -1; } if(ul.register_ulcb(UL_CONTACT_DELETE, bla_cb, 0)< 0) { LM_ERR("can not register callback for" " delete\n"); return -1; } return 0; }
static int cpl_init(void) { bind_usrloc_t bind_usrloc; load_tm_f load_tm; struct stat stat_t; char *ptr; int val; str foo; LOG(L_INFO,"CPL - initializing\n"); /* check the module params */ if (DB_URL==0) { LOG(L_CRIT,"ERROR:cpl_init: mandatory parameter \"cpl_db\" " "found empty\n"); goto error; } if (DB_TABLE==0) { LOG(L_CRIT,"ERROR:cpl_init: mandatory parameter \"cpl_table\" " "found empty\n"); goto error; } if (cpl_env.proxy_recurse>MAX_PROXY_RECURSE) { LOG(L_CRIT,"ERROR:cpl_init: value of proxy_recurse param (%d) exceeds " "the maximum safety value (%d)\n", cpl_env.proxy_recurse,MAX_PROXY_RECURSE); goto error; } /* fix the timer_avp name */ if (timer_avp) { foo.s = timer_avp; foo.len = strlen(foo.s); if (parse_avp_spec(&foo,&cpl_env.timer_avp_type,&cpl_env.timer_avp,0)<0){ LOG(L_CRIT,"ERROR:cpl_init: invalid timer AVP specs \"%s\"\n", timer_avp); goto error; } if (cpl_env.timer_avp_type&AVP_NAME_STR && cpl_env.timer_avp.s.s==foo.s) { cpl_env.timer_avp.s = foo; } } if (dtd_file==0) { LOG(L_CRIT,"ERROR:cpl_init: mandatory parameter \"cpl_dtd_file\" " "found empty\n"); goto error; } else { /* check if the dtd file exists */ if (stat( dtd_file, &stat_t)==-1) { LOG(L_ERR,"ERROR:cpl_init: checking file \"%s\" status failed;" " stat returned %s\n",dtd_file,strerror(errno)); goto error; } if ( !S_ISREG( stat_t.st_mode ) ) { LOG(L_ERR,"ERROR:cpl_init: dir \"%s\" is not a regular file!\n", dtd_file); goto error; } if (access( dtd_file, R_OK )==-1) { LOG(L_ERR,"ERROR:cpl_init: checking file \"%s\" for permissions " "failed; access returned %s\n",dtd_file,strerror(errno)); goto error; } } if (cpl_env.log_dir==0) { LOG(L_INFO,"INFO:cpl_init: log_dir param found void -> logging " " disabled!\n"); } else { if ( strlen(cpl_env.log_dir)>MAX_LOG_DIR_SIZE ) { LOG(L_ERR,"ERROR:cpl_init: dir \"%s\" has a too long name :-(!\n", cpl_env.log_dir); goto error; } /* check if the dir exists */ if (stat( cpl_env.log_dir, &stat_t)==-1) { LOG(L_ERR,"ERROR:cpl_init: checking dir \"%s\" status failed;" " stat returned %s\n",cpl_env.log_dir,strerror(errno)); goto error; } if ( !S_ISDIR( stat_t.st_mode ) ) { LOG(L_ERR,"ERROR:cpl_init: dir \"%s\" is not a directory!\n", cpl_env.log_dir); goto error; } if (access( cpl_env.log_dir, R_OK|W_OK )==-1) { LOG(L_ERR,"ERROR:cpl_init: checking dir \"%s\" for permissions " "failed; access returned %s\n", cpl_env.log_dir, strerror(errno)); goto error; } } /* import the TM auto-loading function */ if ( !(load_tm=(load_tm_f)find_export("load_tm", NO_SCRIPT, 0))) { LOG(L_ERR, "ERROR:cpl_c:cpl_init: cannot import load_tm\n"); goto error; } /* let the auto-loading function load all TM stuff */ if (load_tm( &(cpl_fct.tmb) )==-1) goto error; /* bind the SL API */ if (sl_load_api(&cpl_fct.slb)!=0) { LM_ERR("cannot bind to SL API\n"); return -1; } /* bind to usrloc module if requested */ if (lookup_domain) { /* import all usrloc functions */ bind_usrloc = (bind_usrloc_t)find_export("ul_bind_usrloc", 1, 0); if (!bind_usrloc) { LOG(L_ERR, "ERROR:cpl_c:cpl_init: Can't bind usrloc\n"); goto error; } if (bind_usrloc( &(cpl_fct.ulb) ) < 0) { LOG(L_ERR, "ERROR:cpl_c:cpl_init: importing usrloc failed\n"); goto error; } /* convert lookup_domain from char* to udomain_t* pointer */ if (cpl_fct.ulb.register_udomain( lookup_domain, &cpl_env.lu_domain) < 0) { LOG(L_ERR, "ERROR:cpl_c:cpl_init: Error while registering domain " "<%s>\n",lookup_domain); goto error; } } else { LOG(L_NOTICE,"NOTICE:cpl_init: no lookup_domain given -> disable " " lookup node\n"); } /* build a pipe for sending commands to aux process */ if ( pipe( cpl_env.cmd_pipe )==-1 ) { LOG(L_CRIT,"ERROR:cpl_init: cannot create command pipe: %s!\n", strerror(errno) ); goto error; } /* set the writing non blocking */ if ( (val=fcntl(cpl_env.cmd_pipe[1], F_GETFL, 0))<0 ) { LOG(L_ERR,"ERROR:cpl_init: getting flags from pipe[1] failed: fcntl " "said %s!\n",strerror(errno)); goto error; } if ( fcntl(cpl_env.cmd_pipe[1], F_SETFL, val|O_NONBLOCK) ) { LOG(L_ERR,"ERROR:cpl_init: setting flags to pipe[1] failed: fcntl " "said %s!\n",strerror(errno)); goto error; } /* init the CPL parser */ if (init_CPL_parser( dtd_file )!=1 ) { LOG(L_ERR,"ERROR:cpl_init: init_CPL_parser failed!\n"); goto error; } /* make a copy of the original TZ env. variable */ ptr = getenv("TZ"); cpl_env.orig_tz.len = 3/*"TZ="*/ + (ptr?(strlen(ptr)+1):0); if ( (cpl_env.orig_tz.s=shm_malloc( cpl_env.orig_tz.len ))==0 ) { LOG(L_ERR,"ERROR:cpl_init: no more shm mem. for saving TZ!\n"); goto error; } memcpy(cpl_env.orig_tz.s,"TZ=",3); if (ptr) strcpy(cpl_env.orig_tz.s+3,ptr); /* convert realm_prefix from string null terminated to str */ if (cpl_env.realm_prefix.s) { /* convert the realm_prefix to lower cases */ strlower( &cpl_env.realm_prefix ); } /* Register a child process that will keep updating * its local configuration */ cfg_register_child(1); return 0; error: return -1; }