/* Module initialization function */ static int mod_init(void) { if (init_shmlock() != 0) { LM_CRIT("cannot initialize shmlock.\n"); return -1; } if (conf_init(mp_max_id) < 0) { LM_CRIT("cannot initialize configuration.\n"); return -1; } /* read module parameters and update configuration structure */ if (conf_parse_proxy(mp_proxy) < 0) { LM_CRIT("cannot parse proxy module parameter.\n"); return -1; } if (conf_parse_filter(mp_filter) < 0) { LM_CRIT("cannot parse filter module parameter.\n"); return -1; } if (conf_parse_switch(mp_switch) < 0) { LM_CRIT("cannot parse switch module parameter.\n"); return -1; } if (forward_active == 1) { /* register callback for id 0 */ if (register_script_cb(pre_script_filter, PRE_SCRIPT_CB|ONREPLY_CB, 0) < 0) { LM_CRIT("cannot register script callback for requests.\n"); return -1; } if (register_script_cb(pre_script_filter, PRE_SCRIPT_CB|ONREPLY_CB, 0) < 0) { LM_CRIT("cannot register script callback for replies.\n"); return -1; } } else { LM_INFO("forward functionality disabled"); } /* presence database */ LM_DBG("pres_db_url=%s/%d/%p\n", ZSW(pres_db_url.s), pres_db_url.len, pres_db_url.s); if(pres_db_init() < 0) { return -1; } return 0; }
/*! * \brief fifo command for configuring switch * \return pointer to the mi_root on success, 0 otherwise */ static struct mi_root* forward_fifo_switch(struct mi_root* cmd_tree, void* param) { struct mi_node *node = NULL; int result; node = cmd_tree->node.kids; if (node==NULL || node->next!=NULL || node->value.s==NULL) return init_mi_tree(400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN); // critical section start: // avoids dirty reads when updating configuration. lock_get(conf_lock); result = conf_parse_switch(node->value.s); // critical section end lock_release(conf_lock); if (result < 0) { LM_ERR("cannot parse parameter\n"); return init_mi_tree( 400, MI_BAD_PARM_S, MI_BAD_PARM_LEN); } return init_mi_tree(200, MI_OK_S, MI_OK_LEN); }
/* Module initialization function */ static int mod_init(void) { if(register_mi_mod(exports.name, mi_cmds)!=0) { LM_ERR("failed to register MI commands\n"); return -1; } /* Initialize curl */ if (curl_global_init(CURL_GLOBAL_ALL)) { LM_ERR("curl_global_init failed\n"); return -1; } if (init_shmlock() != 0) { LM_CRIT("cannot initialize shmlock.\n"); return -1; } if (conf_init(mp_max_id) < 0) { LM_CRIT("cannot initialize configuration.\n"); return -1; } /* read module parameters and update configuration structure */ if (conf_parse_proxy(mp_proxy) < 0) { LM_CRIT("cannot parse proxy module parameter.\n"); return -1; } if (conf_parse_filter(mp_filter) < 0) { LM_CRIT("cannot parse filter module parameter.\n"); return -1; } if (conf_parse_switch(mp_switch) < 0) { LM_CRIT("cannot parse switch module parameter.\n"); return -1; } if (forward_active == 1) { /* register callback for id 0 */ if (register_script_cb(pre_script_filter, PRE_SCRIPT_CB|ONREPLY_CB, 0) < 0) { LM_CRIT("cannot register script callback for requests.\n"); return -1; } if (register_script_cb(pre_script_filter, PRE_SCRIPT_CB|ONREPLY_CB, 0) < 0) { LM_CRIT("cannot register script callback for replies.\n"); return -1; } } else { LM_INFO("forward functionality disabled"); } /* presence database */ pres_db_url.len = pres_db_url.s ? strlen(pres_db_url.s) : 0; LM_DBG("pres_db_url=%s/%d/%p\n", ZSW(pres_db_url.s), pres_db_url.len, pres_db_url.s); xcap_table.len = xcap_table.s ? strlen(xcap_table.s) : 0; if(pres_db_init() < 0) { return -1; } return 0; }