static int mod_init(void) { int i; struct in_addr addr; str socket_str; if (force_socket_str != NULL) { socket_str.s = force_socket_str; socket_str.len = strlen(socket_str.s); force_socket = grep_sock_info(&socket_str, 0, 0); } if (natpinger_init() < 0) { LOG(L_ERR, "nathelper: natpinger_init() failed\n"); return -1; } /* Prepare 1918 networks list */ for (i = 0; nets_1918[i].cnetaddr != NULL; i++) { if (inet_aton(nets_1918[i].cnetaddr, &addr) != 1) abort(); nets_1918[i].netaddr = ntohl(addr.s_addr) & nets_1918[i].mask; } register_select_table(sel_declaration); return 0; }
/** * init module function */ static int mod_init(void) { #ifdef USE_TCP tcp_set_clone_rcvbuf(1); #endif register_select_table(sel_declaration); return 0; }
static int mod_init(void) { struct dbops_action* p; xlbuf = pkg_malloc((xlbuf_size+1)*sizeof(char)); if (!xlbuf) { ERR(MODULE_NAME": out of memory, cannot create xlbuf\n"); return E_OUT_OF_MEM; } for (p=dbops_actions; p; p=p->next) { int res; res = init_action(p); if (res < 0) { pkg_free(xlbuf); xlbuf = NULL; return res; } } if(register_script_cb(dbops_pre_script_cb, REQUEST_CB | ONREPLY_CB | PRE_SCRIPT_CB, 0)<0) { LM_ERR("failed to register pre script callback\n"); pkg_free(xlbuf); xlbuf = NULL; return -1; } if(register_script_cb(dbops_post_script_cb, REQUEST_CB | ONREPLY_CB | POST_SCRIPT_CB, 0)<0) { LM_ERR("failed to register post script callback\n"); pkg_free(xlbuf); xlbuf = NULL; return -1; } register_select_table(sel_declaration); return 0; }
static int mod_init() { struct timer_action *a, **pa; DEBUG(MODULE_NAME": init: initializing, pid=%d\n", getpid()); /* copy from pkg to shm memory */ for (pa=&timer_actions; pkg_timer_actions; pa=&(*pa)->next) { a = pkg_timer_actions; *pa = shm_malloc(sizeof(**pa)); if (!*pa) { ERR(MODULE_NAME": cannot allocate timer data\n"); return E_OUT_OF_MEM; } memcpy(*pa, a, sizeof(**pa)); (*pa)->next = 0; pkg_timer_actions = a->next; pkg_free(a); } for (a=timer_actions; a; a=a->next) { a->link = timer_alloc(); if (!a->link) { ERR(MODULE_NAME": init: cannot allocate timer\n"); return E_OUT_OF_MEM; } timer_init(a->link, timer_handler, a, a->flags); if (!a->link) { ERR(MODULE_NAME": init: cannot initialize timer\n"); return E_CFG; } } memset(&rcv_info, 0, sizeof(rcv_info)); register_select_table(sel_declaration); return 0; }
static int mod_init(void) { int method; if (tls_disable){ LOG(L_WARN, "tls support is disabled " "(set enable_tls=1 in the config to enable it)\n"); return 0; } if (fix_tls_cfg(&default_tls_cfg) < 0 ) { ERR("initial tls configuration fixup failed\n"); return -1; } /* declare configuration */ if (cfg_declare("tls", tls_cfg_def, &default_tls_cfg, cfg_sizeof(tls), (void **)&tls_cfg)) { ERR("failed to register the configuration\n"); return -1; } /* Convert tls_method parameter to integer */ method = tls_parse_method(&cfg_get(tls, tls_cfg, method)); if (method < 0) { ERR("Invalid tls_method parameter value\n"); return -1; } /* fill mod_params */ mod_params.method = method; mod_params.verify_cert = cfg_get(tls, tls_cfg, verify_cert); mod_params.verify_depth = cfg_get(tls, tls_cfg, verify_depth); mod_params.require_cert = cfg_get(tls, tls_cfg, require_cert); mod_params.pkey_file = cfg_get(tls, tls_cfg, private_key); mod_params.ca_file = cfg_get(tls, tls_cfg, ca_list); mod_params.crl_file = cfg_get(tls, tls_cfg, crl); mod_params.cert_file = cfg_get(tls, tls_cfg, certificate); mod_params.cipher_list = cfg_get(tls, tls_cfg, cipher_list); mod_params.server_name = cfg_get(tls, tls_cfg, server_name); tls_domains_cfg = (tls_domains_cfg_t**)shm_malloc(sizeof(tls_domains_cfg_t*)); if (!tls_domains_cfg) { ERR("Not enough shared memory left\n"); goto error; } *tls_domains_cfg = NULL; register_select_table(tls_sel); /* register the rpc interface */ if (rpc_register_array(tls_rpc)!=0) { LOG(L_ERR, "failed to register RPC commands\n"); goto error; } /* if (init_tls() < 0) return -1; */ tls_domains_cfg_lock = lock_alloc(); if (tls_domains_cfg_lock == 0) { ERR("Unable to create TLS configuration lock\n"); goto error; } if (lock_init(tls_domains_cfg_lock) == 0) { lock_dealloc(tls_domains_cfg_lock); ERR("Unable to initialize TLS configuration lock\n"); goto error; } if (tls_ct_wq_init() < 0) { ERR("Unable to initialize TLS buffering\n"); goto error; } if (cfg_get(tls, tls_cfg, config_file).s) { *tls_domains_cfg = tls_load_config(&cfg_get(tls, tls_cfg, config_file)); if (!(*tls_domains_cfg)) goto error; } else { *tls_domains_cfg = tls_new_cfg(); if (!(*tls_domains_cfg)) goto error; } if (tls_check_sockets(*tls_domains_cfg) < 0) goto error; #ifndef OPENSSL_NO_ECDH LM_INFO("With ECDH-Support!\n"); #endif #ifndef OPENSSL_NO_DH LM_INFO("With Diffie Hellman\n"); #endif tls_lookup_event_routes(); return 0; error: destroy_tls_h(); return -1; }
static int mod_init(void) { int method; if (tls_disable){ LOG(L_WARN, "WARNING: tls: mod_init: tls support is disabled " "(set enable_tls=1 in the config to enable it)\n"); return 0; } if (cfg_get(tcp, tcp_cfg, async) && !tls_force_run){ ERR("tls does not support tcp in async mode, please use" " tcp_async=no in the config file\n"); return -1; } /* Convert tls_method parameter to integer */ method = tls_parse_method(&tls_method); if (method < 0) { ERR("Invalid tls_method parameter value\n"); return -1; } mod_params.method = method; /* Update relative paths of files configured through modparams, relative * pathnames will be converted to absolute and the directory of the main * SER configuration file will be used as reference. */ if (fix_rel_pathnames() < 0) return -1; tls_cfg = (tls_cfg_t**)shm_malloc(sizeof(tls_cfg_t*)); if (!tls_cfg) { ERR("Not enough shared memory left\n"); return -1; } *tls_cfg = NULL; register_tls_hooks(&tls_h); register_select_table(tls_sel); /* if (init_tls() < 0) return -1; */ tls_cfg_lock = lock_alloc(); if (tls_cfg_lock == 0) { ERR("Unable to create TLS configuration lock\n"); return -1; } if (lock_init(tls_cfg_lock) == 0) { lock_dealloc(tls_cfg_lock); ERR("Unable to initialize TLS configuration lock\n"); return -1; } if (tls_cfg_file.s) { *tls_cfg = tls_load_config(&tls_cfg_file); if (!(*tls_cfg)) return -1; } else { *tls_cfg = tls_new_cfg(); if (!(*tls_cfg)) return -1; } if (tls_check_sockets(*tls_cfg) < 0) return -1; /* fix the timeouts from s to ticks */ if (tls_con_lifetime<0){ /* set to max value (~ 1/2 MAX_INT) */ tls_con_lifetime=MAX_TLS_CON_LIFETIME; }else{ if ((unsigned)tls_con_lifetime > (unsigned)TICKS_TO_S(MAX_TLS_CON_LIFETIME)){ LOG(L_WARN, "tls: mod_init: tls_con_lifetime too big (%u s), " " the maximum value is %u\n", tls_con_lifetime, TICKS_TO_S(MAX_TLS_CON_LIFETIME)); tls_con_lifetime=MAX_TLS_CON_LIFETIME; }else{ tls_con_lifetime=S_TO_TICKS(tls_con_lifetime); } } return 0; }
int tm_init_selects() { register_select_table(select_declaration); return 0; }
static int mod_init() { DBG("%s - initializing\n", exports.name); return register_select_table(sel_declaration); }