<div dir="ltr">Hi all,<br><br>I need a help to solve some problems in the clearance of a function to perform a query Mysql....I created a function based on documentation of asipto / kamailio devel which is very good... But as I did not want to create a new module I'm trying to use the module domain... whose goal a proxy SIP receive msg that will should validate the realm comparing with a table set up in MySQL(trusdomain)... it should be used into config file to to declare of the table created in the Mysql: modparam ( "domain", "trusdomain_table," trusdomain)<br>
the version table of the openser has updated with the creation of this new table (trusdomain) and created a function into file: domain.c / h and a part was need be exported to config file in domain_mod.c / h....but on the tests a call..this proxy kills the pid openser ...<br>
<br>Sep 5 06:32:21 notehome openser[7962]: INFO:core:handle_sigs: child process 7964 exited by a signal 11 <br>Sep 5 06:32:21 notehome openser[7962]: INFO:core:handle_sigs: core was generated <br>Sep 5 06:32:21 notehome openser[7962]: INFO:core:handle_sigs: terminating due to SIGCHLD <br>
Sep 5 06:32:21 notehome openser[7967]: INFO:core:sig_usr: signal 15 received <br>Sep 5 06:32:21 notehome openser[7963]: INFO:core:sig_usr: signal 15 received <br>Sep 5 06:32:21 notehome openser[7968]: INFO:core:sig_usr: signal 15 received <br>
Sep 5 06:32:21 notehome openser[7966]: INFO:core:sig_usr: signal 15 received <br>Sep 5 06:32:21 notehome openser[7965]: INFO:core:sig_usr: signal 15 received<br><br>The function created in domain.c:<br>int is_from_trusted(struct sip_msg* _msg, char* _s1, char* _s2)<br>
{<br> struct sip_uri *puri;<br>/* struct str* _host; */<br>/* str table_trus;<br> str col_id;<br> str col_dom;<br> str col_lastmod; */<br><br>str* _host = (str*)(&(puri->host));<br> char* db_url = DEFAULT_RODB_URL;<br>
<br> db_key_t keys[1]; /* Tipo da coluna .. Nome das colunas */<br> db_val_t vals[1];<br> db_key_t cols[1];<br> db_res_t* res = NULL;<br> <br> if ((puri=parse_from_uri(_msg))==NULL){<br> LM_ERR("Error while parsing From header\n"); return -2;<br>
}<br><br> /* Bind the database module */<br> if (bind_dbmod(db_url, &domain_dbf )) {<br> LM_ERR("Cannot bind to database module!\n");<br> return -1;<br> }<br><br> /* Check for SELECT capability */<br>
if (!DB_CAPABILITY(domain_dbf, DB_CAP_QUERY)){<br> LM_ERR("Database modules does not provide all functions needed\n");<br> return -1;<br> }<br><br>/* Connect to DB */<br> db_handle = domain_dbf.init(db_url);<br>
if (!db_handle){<br> LM_ERR("failed to connect database\n");<br> return -1;<br> }<br><br> <br> keys[0]=trusdomain_col.s;<br> cols[0]=trusdomain_col.s; <br><br><br> LM_INFO(">>domain.c>>-2-IF RES_ROW_N(res)=>%d\n",RES_ROW_N(res));<br>
/* Estrutura dos vls das colunas - arq. db/db_val.h */<br> VAL_TYPE(vals) = DB_STR;<br> VAL_NULL(vals) = 0;<br> <br> VAL_STR(vals).s = _host->s;<br> VAL_STR(vals).len = _host->len;<br><br>/* LM_INFO(">>domain.c>>-1-connector=%d and tab=%s\n",db_handle,trusdomain_table.s); */<br>
if (domain_dbf.use_table(db_handle, trusdomain_table.s) < 0) {<br> LM_ERR("Error while trying to use trusdomain table\n");<br> return -1;<br> }<br><br> if (domain_dbf.query(db_handle, keys, NULL, vals, cols, 1, 1, 0, &res) < 0) {<br>
LM_ERR("Error while querying database\n");<br> domain_dbf.close(db_handle);<br> return -1;<br> }<br> <br> /* RES_ROW_N(res) Num. de linhas no fetch */<br> if (RES_ROW_N(res) <= 0 || RES_ROWS(res)[0].values[0].nul != 0){<br>
LM_DBG("no value found\n");<br> if (res != NULL && domain_dbf.free_result(db_handle, res) < 0)<br> LM_DBG("failed to free the result\n");<br> domain_dbf.close(db_handle);<br>
} else if (RES_ROW_N(res) >= 1) {<br> /* Teste do que estah na tab. trusdomain com o que vem na URI */<br> LM_DBG("Realm '%.*s' is trusted\n",_host->len, ZSW(_host->s));<br> }<br>
<br> /* Free the result */<br> domain_dbf.free_result(db_handle, res);<br> domain_dbf.close(db_handle);<br><br> return 0;<br>}<br><br>And declaration in domain_mod.c :<br>...<br>/* by mrg */<br>#define TRUSDOMAIN_TABLE "trusdomain"<br>
#define TRUSDOMAIN_TABLE_LEN (sizeof(TRUSDOMAIN_TABLE) - 1)<br>#define TRUSDOMAIN_COL "trusdomain"<br>#define TRUSDOMAIN_COL_LEN (sizeof(TRUSDOMAIN_COL) - 1)<br>...<br>...<br>str trusdomain_table = {TRUSDOMAIN_TABLE, TRUSDOMAIN_TABLE_LEN}; /* Name of trusted table */<br>
str trusdomain_col = {TRUSDOMAIN_COL, TRUSDOMAIN_COL_LEN}; /* Name of trusted column */<br>...<br>...<br>/*<br> * Exported functions<br> */<br>static cmd_export_t cmds[] = {<br> .............<br> {"is_domain_local", w_is_domain_local, 1, parameter_fixup, 0,<br>
REQUEST_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE},<br> {"is_from_trusted", is_from_trusted, 0, 0, 0,<br> REQUEST_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE},<br> {0, 0, 0, 0, 0, 0}<br>
};<br>.../*<br> * Exported parameters<br> */<br>static param_export_t params[] = {<br> ............<br> {"domain_table", STR_PARAM, &domain_table.s},<br> {"domain_col", STR_PARAM, &domain_col.s },<br>
{"trusdomain_table", STR_PARAM, &trusdomain_table.s},<br> {"trusdomain_col", STR_PARAM, &trusdomain_col.s},<br> {0, 0, 0}<br>};<br>...<br>...<br>static int mod_init(void)<br>{<br>
int vertr....;<br>.....<br> trusdomain_table.len = strlen(trusdomain_table.s);<br> trusdomain_col.len = strlen(trusdomain_col.s);<br>.....<br> if (db_mode != 0) {<br> if (domain_db_init(db_url.s)<0) return -1;<br>
<br> /* Check table version */<br> ver = domain_db_ver(&domain_table);<br> vertr = domain_db_ver(&trusdomain_table);<br> <br> if ((ver < 0) && (vertr < 0)) {<br> LM_ERR("Error while querying table version\n");<br>
goto error;<br> } else if ((ver < TABLE_VERSION) && (vertr < TABLE_VERSION)) {<br> LM_ERR("Invalid table version <%d> trustable version <%d> (should be %d)\n",<br>
ver, vertr, TABLE_VERSION);<br> goto error;<br> }<br>.......<br>.......<br> /* Initializing hash tables and hash table variable */<br>........<br> domain_db_close();<br> }<br><br>
return 0;<br>error:<br> domain_db_close();<br> return -1;<br>}<br><br>So I think that I must be something doing wrong ..... as would be the right and as I could learn fast to resolve error debugging of pID of Openser that has been deads...???<br>
<br>thx<br>Marcio<br></div>