/** * init module function */ static int mod_init(void) { if(_gzc_sanity_checks!=0) { if(sanity_load_api(&scb)<0) { LM_ERR("cannot bind to sanity module\n"); goto error; } } sr_event_register_cb(SREV_NET_DATA_IN, gzc_msg_received); sr_event_register_cb(SREV_NET_DATA_OUT, gzc_msg_sent); #ifdef USE_TCP tcp_set_clone_rcvbuf(1); #endif return 0; error: return -1; }
/** * init module function */ static int mod_init(void) { /* Find a database module */ if (db_bind_mod(&_tps_db_url, &_tpsdbf)) { LM_ERR("unable to bind database module\n"); return -1; } if (!DB_CAPABILITY(_tpsdbf, DB_CAP_ALL)) { LM_CRIT("database modules does not " "provide all functions needed\n"); return -1; } if(_tps_sanity_checks!=0) { if(sanity_load_api(&scb)<0) { LM_ERR("cannot bind to sanity module\n"); goto error; } } if(tps_storage_lock_set_init()<0) { LM_ERR("failed to initialize locks set\n"); return -1; } if(sruid_init(&_tps_sruid, '-', "tpsh", SRUID_INC)<0) return -1; sr_event_register_cb(SREV_NET_DATA_IN, tps_msg_received); sr_event_register_cb(SREV_NET_DATA_OUT, tps_msg_sent); #ifdef USE_TCP tcp_set_clone_rcvbuf(1); #endif if(sr_wtimer_add(tps_storage_clean, NULL, _tps_clean_interval)<0) return -1; return 0; error: return -1; }
/** * init module function */ static int mod_init(void) { sip_uri_t puri; char buri[MAX_URI_SIZE]; _th_eventrt_outgoing = route_lookup(&event_rt, _th_eventrt_name.s); if(_th_eventrt_outgoing<0 || event_rt.rlist[_th_eventrt_outgoing]==NULL) { _th_eventrt_outgoing = -1; } if(faked_msg_init()<0) { LM_ERR("failed to init fmsg\n"); return -1; } if(th_sanity_checks!=0) { if(sanity_load_api(&scb)<0) { LM_ERR("cannot bind to sanity module\n"); goto error; } } if(th_ip.len<=0) { LM_ERR("mask IP parameter is invalid\n"); goto error; } if(th_ip.len + 32 >= MAX_URI_SIZE) { LM_ERR("mask address is too long\n"); goto error; } memcpy(buri, "sip:", 4); memcpy(buri+4, th_ip.s, th_ip.len); buri[th_ip.len+8] = '\0'; if(parse_uri(buri, th_ip.len+4, &puri)<0) { LM_ERR("mask uri is invalid\n"); goto error; } if(check_self(&puri.host, puri.port_no, 0)==1) { th_mask_addr_myself = 1; LM_INFO("mask address matches myself [%.*s]\n", th_ip.len, th_ip.s); } /* 'SIP/2.0/UDP ' + ip + ';' + param + '=' + prefix (+ '\0') */ th_via_prefix.len = 12 + th_ip.len + 1 + th_vparam_name.len + 1 + th_vparam_prefix.len; th_via_prefix.s = (char*)pkg_malloc(th_via_prefix.len+1); if(th_via_prefix.s==NULL) { LM_ERR("via prefix parameter is invalid\n"); goto error; } /* 'sip:' + ip + ';' + param + '=' + prefix (+ '\0') */ th_uri_prefix.len = 4 + th_ip.len + 1 + th_uparam_name.len + 1 + th_uparam_prefix.len; th_uri_prefix.s = (char*)pkg_malloc(th_uri_prefix.len+1); if(th_uri_prefix.s==NULL) { LM_ERR("uri prefix parameter is invalid\n"); goto error; } /* build via prefix */ memcpy(th_via_prefix.s, "SIP/2.0/UDP ", 12); memcpy(th_via_prefix.s+12, th_ip.s, th_ip.len); th_via_prefix.s[12+th_ip.len] = ';'; memcpy(th_via_prefix.s+12+th_ip.len+1, th_vparam_name.s, th_vparam_name.len); th_via_prefix.s[12+th_ip.len+1+th_vparam_name.len] = '='; memcpy(th_via_prefix.s+12+th_ip.len+1+th_vparam_name.len+1, th_vparam_prefix.s, th_vparam_prefix.len); th_via_prefix.s[th_via_prefix.len] = '\0'; LM_DBG("VIA prefix: [%s]\n", th_via_prefix.s); /* build uri prefix */ memcpy(th_uri_prefix.s, "sip:", 4); memcpy(th_uri_prefix.s+4, th_ip.s, th_ip.len); th_uri_prefix.s[4+th_ip.len] = ';'; memcpy(th_uri_prefix.s+4+th_ip.len+1, th_uparam_name.s, th_uparam_name.len); th_uri_prefix.s[4+th_ip.len+1+th_uparam_name.len] = '='; memcpy(th_uri_prefix.s+4+th_ip.len+1+th_uparam_name.len+1, th_uparam_prefix.s, th_uparam_prefix.len); th_uri_prefix.s[th_uri_prefix.len] = '\0'; LM_DBG("URI prefix: [%s]\n", th_uri_prefix.s); th_mask_init(); sr_event_register_cb(SREV_NET_DATA_IN, th_msg_received); sr_event_register_cb(SREV_NET_DATA_OUT, th_msg_sent); #ifdef USE_TCP tcp_set_clone_rcvbuf(1); #endif return 0; error: return -1; }
/** * init module function */ static int mod_init(void) { if(th_sanity_checks!=0) { if(sanity_load_api(&scb)<0) { LM_ERR("cannot bind to sanity module\n"); goto error; } } th_cookie_name.len = strlen(th_cookie_name.s); th_ip.len = strlen(th_ip.s); if(th_ip.len<=0) { LM_ERR("mask IP parameter is invalid\n"); goto error; } if(check_self(&th_ip, 0, 0)==1) { LM_ERR("mask IP must be different than SIP server local IP\n"); goto error; } th_uparam_name.len = strlen(th_uparam_name.s); th_uparam_prefix.len = strlen(th_uparam_prefix.s); th_vparam_name.len = strlen(th_vparam_name.s); th_vparam_prefix.len = strlen(th_vparam_prefix.s); th_callid_prefix.len = strlen(th_callid_prefix.s); /* 'SIP/2.0/UDP ' + ip + ';' + param + '=' + prefix (+ '\0') */ th_via_prefix.len = 12 + th_ip.len + 1 + th_vparam_name.len + 1 + th_vparam_prefix.len; th_via_prefix.s = (char*)pkg_malloc(th_via_prefix.len+1); if(th_via_prefix.s==NULL) { LM_ERR("via prefix parameter is invalid\n"); goto error; } /* 'sip:' + ip + ';' + param + '=' + prefix (+ '\0') */ th_uri_prefix.len = 4 + th_ip.len + 1 + th_uparam_name.len + 1 + th_uparam_prefix.len; th_uri_prefix.s = (char*)pkg_malloc(th_uri_prefix.len+1); if(th_uri_prefix.s==NULL) { LM_ERR("uri prefix parameter is invalid\n"); goto error; } /* build via prefix */ memcpy(th_via_prefix.s, "SIP/2.0/UDP ", 12); memcpy(th_via_prefix.s+12, th_ip.s, th_ip.len); th_via_prefix.s[12+th_ip.len] = ';'; memcpy(th_via_prefix.s+12+th_ip.len+1, th_vparam_name.s, th_vparam_name.len); th_via_prefix.s[12+th_ip.len+1+th_vparam_name.len] = '='; memcpy(th_via_prefix.s+12+th_ip.len+1+th_vparam_name.len+1, th_vparam_prefix.s, th_vparam_prefix.len); th_via_prefix.s[th_via_prefix.len] = '\0'; LM_DBG("VIA prefix: [%s]\n", th_via_prefix.s); /* build uri prefix */ memcpy(th_uri_prefix.s, "sip:", 4); memcpy(th_uri_prefix.s+4, th_ip.s, th_ip.len); th_uri_prefix.s[4+th_ip.len] = ';'; memcpy(th_uri_prefix.s+4+th_ip.len+1, th_uparam_name.s, th_uparam_name.len); th_uri_prefix.s[4+th_ip.len+1+th_uparam_name.len] = '='; memcpy(th_uri_prefix.s+4+th_ip.len+1+th_uparam_name.len+1, th_uparam_prefix.s, th_uparam_prefix.len); th_uri_prefix.s[th_uri_prefix.len] = '\0'; LM_DBG("URI prefix: [%s]\n", th_uri_prefix.s); th_mask_init(); sr_event_register_cb(SREV_NET_DATA_IN, th_msg_received); sr_event_register_cb(SREV_NET_DATA_OUT, th_msg_sent); #ifdef USE_TCP tcp_set_clone_rcvbuf(1); #endif return 0; error: return -1; }