Created
March 25, 2015 14:20
-
-
Save ionutrazvanionita/51dbc261250bb8b30b54 to your computer and use it in GitHub Desktop.
emergency.patch: new list logic, removed trailing whitespaces, removed unused vars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/modules/emergency/emergency_methods.c b/modules/emergency/emergency_methods.c | |
index 68c7c22..9fe5f98 100644 | |
--- a/modules/emergency/emergency_methods.c | |
+++ b/modules/emergency/emergency_methods.c | |
@@ -23,7 +23,7 @@ | |
* -------- | |
* 2014-10-14 initial version (Villaron/Tesini) | |
* 2013-03-21 implementing subscriber function (Villaron/Tesini) | |
- * | |
+ * | |
*/ | |
@@ -68,7 +68,7 @@ static param_export_t params[] = { | |
{ "timer_interval", INT_PARAM, &timer_interval}, | |
{ "db_url", STR_PARAM, &db_url.s}, | |
{ "db_table_routing", STR_PARAM, &table_name}, | |
- { "db_table_report", STR_PARAM, &table_report}, | |
+ { "db_table_report", STR_PARAM, &table_report}, | |
{ "url_vpc", STR_PARAM, &url_vpc}, | |
{ "vpc_organization_name", STR_PARAM, &vpc_organization_name}, | |
{ "vpc_hostname", STR_PARAM, &vpc_hostname}, | |
@@ -89,7 +89,7 @@ static param_export_t params[] = { | |
{ "contingency_hostname", STR_PARAM, &contingency_hostname}, | |
{ "emergency_call_server", STR_PARAM, &call_server_hostname}, | |
{ "proxy_hole", INT_PARAM, &proxy_hole}, | |
- { "callorigin", STR_PARAM, &call_origin}, | |
+ { "callorigin", STR_PARAM, &call_origin}, | |
{ 0, 0, 0} | |
}; | |
@@ -177,7 +177,7 @@ static int set_codes(unsigned int type, void *val) { | |
return 0; | |
} | |
-/* | |
+/* | |
* This function is responsible for : | |
* - load api from modules dialog and rr | |
* - open database connection and test the version of the tables in the database | |
@@ -204,7 +204,7 @@ static int mod_init(void) { | |
LM_DBG(" ---fill parameters not config with blank_space \n"); | |
if (fill_blank_space() == -1) | |
return -1; | |
- | |
+ | |
if ( load_dlg_api( &dlgb ) != 0 ) { | |
LM_ERR("failed to load DLG api\n"); | |
return -1; | |
@@ -222,7 +222,7 @@ static int mod_init(void) { | |
empty = shm_malloc(sizeof (char)); | |
- memset(empty, '\0', 1); | |
+ memset(empty, '\0', 1); | |
if (db_url.s) { | |
db_url.len = strlen(db_url.s); | |
@@ -307,7 +307,7 @@ static int mod_init(void) { | |
/* this function is responsible for: | |
-* - open database connection | |
+* - open database connection | |
* - initialize polling routing timer | |
*/ | |
static int child_init(int rank) { | |
@@ -327,8 +327,8 @@ static int child_init(int rank) { | |
/* | |
-* | |
-* - close database connection | |
+* | |
+* - close database connection | |
* - terminate lock (ref_lock) | |
*/ | |
static void mod_destroy(void) { | |
@@ -343,7 +343,7 @@ static void mod_destroy(void) { | |
} | |
-/* | |
+/* | |
* - treats the request within the dialog forwarding to the INVITE that first created the dialog | |
* - if the request is a BYE treats the call ending functions | |
*/ | |
@@ -355,15 +355,15 @@ void indialog_ua(struct dlg_cell* dlg, int type, struct dlg_cb_params * params){ | |
LM_INFO(" New sequential request received:%d !! \n",dir); | |
LM_INFO(" New sequential request method:%.*s \n",msg->first_line.u.request.method.len,msg->first_line.u.request.method.s); | |
- if (memcmp(msg->first_line.u.request.method.s,"BYE", msg->first_line.u.request.method.len) == 0) { | |
- LM_INFO(" --- TREAT BYE ----- \n \n"); | |
+ if (memcmp(msg->first_line.u.request.method.s,"BYE", msg->first_line.u.request.method.len) == 0) { | |
+ LM_INFO(" --- TREAT BYE ----- \n \n"); | |
resp = bye(msg,dir); | |
- LM_INFO(" ---TREATMENT DIALOG BYE:%d", resp); | |
+ LM_INFO(" ---TREATMENT DIALOG BYE:%d", resp); | |
//return resp; | |
}else{ | |
if (dir == 1){ | |
- LM_INFO(" --- TREAT DOWNSTREAM ----- \n \n"); | |
+ LM_INFO(" --- TREAT DOWNSTREAM ----- \n \n"); | |
resp = routing_ack(msg); | |
LM_INFO(" ---TREATMENT DIALOG ACK:%d", resp); | |
//return resp; | |
@@ -373,7 +373,7 @@ void indialog_ua(struct dlg_cell* dlg, int type, struct dlg_cb_params * params){ | |
} | |
-void reply_in_redirect( struct cell* t, int type, struct tmcb_params *params){ | |
+void reply_in_redirect( struct cell* t, int type, struct tmcb_params *params){ | |
char *contact_esgwri = NULL; | |
char *contact_lro = NULL; | |
@@ -388,20 +388,20 @@ void reply_in_redirect( struct cell* t, int type, struct tmcb_params *params){ | |
if (get_callid_header(msg_retran, &callidHeader) == -1){; | |
pkg_free(contact_esgwri); | |
- pkg_free(contact_lro); | |
+ pkg_free(contact_lro); | |
return; | |
} | |
call_cell = shm_malloc(sizeof (ESCT)); | |
if (call_cell == NULL) { | |
- LM_ERR("--------------------------------------------------no more shm memory\n"); | |
+ LM_ERR("--------------------------------------------------no more shm memory\n"); | |
return; | |
} | |
int len_callid = strlen(callidHeader); | |
call_cell->callid = shm_malloc(sizeof (char)* len_callid + 1); | |
if (call_cell->callid == NULL) { | |
- LM_ERR("--------------------------------------------------no more shm memory\n"); | |
+ LM_ERR("--------------------------------------------------no more shm memory\n"); | |
return; | |
} | |
memcpy(call_cell->callid, callidHeader, len_callid); | |
@@ -410,9 +410,9 @@ void reply_in_redirect( struct cell* t, int type, struct tmcb_params *params){ | |
call_cell->esqk = empty; | |
call_cell->lro = empty; | |
call_cell->ert_srid = empty; | |
- call_cell->esgwri = empty; | |
+ call_cell->esgwri = empty; | |
call_cell->result = empty; | |
- call_cell->datetimestamp = empty; | |
+ call_cell->datetimestamp = empty; | |
call_cell->ert_npa = 0; | |
call_cell->ert_resn = 0; | |
@@ -437,15 +437,15 @@ void reply_in_redirect( struct cell* t, int type, struct tmcb_params *params){ | |
} | |
if (get_esgwri_ert_in_contact(contact_esgwri, call_cell) == -1){ | |
- return; | |
+ return; | |
} | |
} | |
insert_call_cell_in_list(call_cell); | |
- return; | |
+ return; | |
} | |
-/* | |
+/* | |
* - verifying the expiration for packet loss ( timing values are diferent for ACK and BYE) | |
* - if there is an expiration the module sends a POST informing the VPC to exclude the number | |
* the key ESQK is retreived from the list calls_eme | |
@@ -470,19 +470,19 @@ static void libera_esqk(void) { | |
NODE* next = current->next; | |
LM_INFO("TIMEOUT:%d\n", current->esct->timeout); | |
if (current->esct->timeout <= 0 ){ | |
- LM_INFO("time fires\n"); | |
+ LM_INFO("time fires\n"); | |
free_cell = current; | |
if (previous == NULL){ | |
- if (next == NULL){ | |
- *calls_eme = NULL; | |
+ if (next == NULL){ | |
+ *calls_eme = NULL; | |
}else{ | |
*calls_eme = next; | |
} | |
}else{ | |
current = next; | |
previous->next = current; | |
- } | |
+ } | |
if ((proxy_hole == 0) || (proxy_hole == 2)){ | |
@@ -493,7 +493,7 @@ static void libera_esqk(void) { | |
//send esctRequest to the VPC | |
if(free_cell->esct->datetimestamp){ | |
shm_free (free_cell->esct->datetimestamp); | |
- LM_DBG(" --- FREE_CELL->TIME"); | |
+ LM_DBG(" --- FREE_CELL->TIME"); | |
} | |
time(&rawtime); | |
timeinfo = localtime(&rawtime); | |
@@ -508,10 +508,10 @@ static void libera_esqk(void) { | |
esct_callid = parse_xml_esct(response); | |
if (esct_callid== NULL) { | |
- LM_ERR(" --- esctAck invalid format or without mandatory field \n \n"); | |
+ LM_ERR(" --- esctAck invalid format or without mandatory field \n \n"); | |
} else { | |
- if (strcmp(esct_callid, free_cell->esct->callid)){ | |
- LM_ERR(" --- callid in esctAck different from asctRequest \n \n"); | |
+ if (strcmp(esct_callid, free_cell->esct->callid)){ | |
+ LM_ERR(" --- callid in esctAck different from asctRequest \n \n"); | |
} | |
if(esct_callid) | |
pkg_free(esct_callid); | |
@@ -522,10 +522,10 @@ static void libera_esqk(void) { | |
} | |
free_call_cell(free_cell); | |
- | |
+ | |
}else{ | |
- previous = current; | |
- } | |
+ previous = current; | |
+ } | |
current = current->next; | |
} | |
} | |
@@ -547,31 +547,28 @@ static void free_subs(void) { | |
while (current) { | |
next = current->next; | |
- LM_INFO("timeout %d\n", current->timeout); | |
+ LM_INFO("timeout %d\n", current->timeout); | |
if (current->timeout <= time_C ){ | |
- LM_INFO("time fires %d\n", current->timeout); | |
+ LM_INFO("time fires %d\n", current->timeout); | |
free_cell = current; | |
if (previous == NULL){ | |
- if (next == NULL){ | |
- *subs_pt = NULL; | |
- }else{ | |
- *subs_pt = next; | |
- } | |
+ *subs_pt = current = next; | |
}else{ | |
current = next; | |
previous->next = current; | |
- } | |
- | |
+ } | |
+ | |
+ pkg_free(free_cell); | |
}else{ | |
- previous = current; | |
- } | |
- current = current->next; | |
+ previous = current; | |
+ current = current->next; | |
+ } | |
} | |
} | |
-/* | |
+/* | |
* - copying data from the routing table to the list db_esrn_domain (performance improvement) | |
*/ | |
void routing_timer(unsigned int ticks, void *attr) { | |
@@ -591,7 +588,7 @@ void routing_timer(unsigned int ticks, void *attr) { | |
*/ | |
-/* | |
+/* | |
* - verify if the request is an emergency call | |
* - is it is an emergency forward the INVITE to the destiny determined by the VPC | |
*/ | |
@@ -601,15 +598,15 @@ int emergency_call(struct sip_msg *msg) { | |
// verify if mandatory parameters were configurated in script | |
if (mandatory_parm) | |
- return -1; | |
+ return -1; | |
- // the emergency call treatment start with INVITE | |
+ // the emergency call treatment start with INVITE | |
if (memcmp(msg->first_line.u.request.method.s,"INVITE", msg->first_line.u.request.method.len) == 0) { | |
if (is_emergency_call(msg)) { | |
- LM_INFO(" --- IT IS AN EMERGECY ----- \n \n"); | |
- // It is, forward the INVITE | |
+ LM_INFO(" --- IT IS AN EMERGECY ----- \n \n"); | |
+ // It is, forward the INVITE | |
if(send_request_vpc(msg) == 1){ | |
- LM_INFO(" --- CRIA DIALOGO ----- \n \n"); | |
+ LM_INFO(" --- CRIA DIALOGO ----- \n \n"); | |
if (dlgb.create_dlg(msg,0)<1) { | |
LM_ERR("failed to create dialog\n"); | |
return -1; | |
@@ -628,18 +625,18 @@ int emergency_call(struct sip_msg *msg) { | |
} | |
} else { | |
- LM_INFO(" --- IT IS NOT AN EMERGENCY ----- \n \n"); | |
+ LM_INFO(" --- IT IS NOT AN EMERGENCY ----- \n \n"); | |
} | |
}else{ | |
if (memcmp(msg->first_line.u.request.method.s,"NOTIFY", msg->first_line.u.request.method.len) == 0){ | |
- LM_INFO(" --- TREAT NOTIFY ----- \n \n"); | |
+ LM_INFO(" --- TREAT NOTIFY ----- \n \n"); | |
if ( !treat_notify(msg)){ | |
LM_ERR ("***** ERROR IN NOTIFY TREATMENT \n"); | |
- return -1; | |
+ return -1; | |
} | |
- return 1; | |
+ return 1; | |
} | |
} | |
@@ -648,7 +645,7 @@ int emergency_call(struct sip_msg *msg) { | |
/* treat the command FAILURE | |
-* - treat contingency forwarding in the case of failure of the original | |
+* - treat contingency forwarding in the case of failure of the original | |
* - Forward the INVITE to a gateway with the contingency number lro from the field R-URI | |
*/ | |
static int failure(struct sip_msg *msg) { | |
@@ -693,14 +690,14 @@ static int failure(struct sip_msg *msg) { | |
return -1 ; | |
} | |
memset(cbn_aux, 0, MAX_URI_SIZE); | |
- found_CBN(msg, &cbn_aux); | |
+ found_CBN(msg, &cbn_aux); | |
cbn.s = cbn_aux; | |
cbn.len = strlen(cbn.s); | |
- LM_INFO(" --- FOUND CBN%.*s \n \n", cbn.len, cbn.s); | |
+ LM_INFO(" --- FOUND CBN%.*s \n \n", cbn.len, cbn.s); | |
if(strlen(info_call->esgwri) > 1){ | |
LM_INFO ("CONTEUDO FAILURE REPLY ESGWRI II %s \n",info_call->esgwri); | |
- if(new_uri_proxy(msg, info_call->esgwri) == -1){ | |
+ if(new_uri_proxy(msg, info_call->esgwri) == -1){ | |
LM_ERR(" ---ERRO EM NEW_URI_PROXY"); | |
return -1; | |
} | |
@@ -709,7 +706,7 @@ static int failure(struct sip_msg *msg) { | |
if ((strlen(info_call->ert_srid) > 1)&&(info_call->ert_resn != 0)&&(info_call->ert_npa != 0)){ | |
LM_INFO ("CONTEUDO FAILURE REPLY SRID %s \n",info_call->ert_srid); | |
LM_INFO ("CONTEUDO FAILURE REPLY RESN %d \n",info_call->ert_resn); | |
- LM_INFO ("CONTEUDO FAILURE REPLY NPA %d \n",info_call->ert_npa); | |
+ LM_INFO ("CONTEUDO FAILURE REPLY NPA %d \n",info_call->ert_npa); | |
if(routing_by_ert( msg, info_call) == -1){ | |
return -1; | |
} | |
@@ -728,7 +725,7 @@ static int failure(struct sip_msg *msg) { | |
return 1; | |
} | |
- } | |
+ } | |
LM_INFO("treat lro \n"); | |
// verfifica se o parametro contingency_hostname foi definido no script, caso contrario failure não sera tratado | |
@@ -756,7 +753,7 @@ static int failure(struct sip_msg *msg) { | |
if(new_uri_proxy(msg, new_to) == -1){ | |
LM_ERR(" ---ERRO EM NEW_URI_PROXY"); | |
goto error; | |
- } | |
+ } | |
if(info_call->esgwri && strlen(info_call->esgwri)>0) | |
shm_free(info_call->esgwri); | |
@@ -768,12 +765,12 @@ static int failure(struct sip_msg *msg) { | |
if(callidHeader) | |
pkg_free(callidHeader); | |
- | |
+ | |
return 1; | |
} | |
- | |
- error : | |
- LM_INFO(" ---FAILURE JA TRANSMITIU LRO"); | |
+ | |
+ error : | |
+ LM_INFO(" ---FAILURE JA TRANSMITIU LRO"); | |
if(callidHeader) | |
pkg_free(callidHeader); | |
return -1; | |
@@ -784,10 +781,10 @@ static int failure(struct sip_msg *msg) { | |
* Internal functions | |
*/ | |
-/* verify if the call is an emergency call | |
+/* verify if the call is an emergency call | |
* - verify if the field uri has a urn standard for emergency call defined by RFC 5031 | |
* - if it does not, then verify if se user field is one of the emengency_code in the database | |
-* - if it is a code, the module checks if the host is from the opensips | |
+* - if it is a code, the module checks if the host is from the opensips | |
or if there is a field Geolocation_routing = 'yes" | |
*/ | |
int is_emergency_call(struct sip_msg *msg) { | |
@@ -816,14 +813,14 @@ int is_emergency_call(struct sip_msg *msg) { | |
if (codigo->code.len == msg->parsed_uri.user.len){ | |
if (strncmp(codigo->code.s, msg->parsed_uri.user.s , codigo->code.len) == 0) { | |
- | |
+ | |
LM_DBG(" ---> CODIGO -- OK %.*s\n\n", codigo->code.len, codigo->code.s); | |
- | |
- if (check_myself(msg)) { | |
+ | |
+ if (check_myself(msg)) { | |
return 1; | |
} else { | |
// Host isn't same of opensips, Geolocation_Routing determine if routing the INVITE (RFC 6442) | |
- int ret = check_geolocation_header(msg); | |
+ int ret = check_geolocation_header(msg); | |
return ret; | |
} | |
} | |
@@ -858,10 +855,10 @@ int is_emergency_call(struct sip_msg *msg) { | |
* - datetimestamp | |
* - lro | |
* - disposition | |
-* - result | |
+* - result | |
* - timeout | |
-* - extracts CBN from INVITE | |
-* - | |
+* - extracts CBN from INVITE | |
+* - | |
*/ | |
int send_request_vpc(struct sip_msg *msg) { | |
char* xml; | |
@@ -882,7 +879,7 @@ int send_request_vpc(struct sip_msg *msg) { | |
} | |
memset(cbn_aux, 0, MAX_URI_SIZE); | |
- found_CBN(msg, &cbn_aux); | |
+ found_CBN(msg, &cbn_aux); | |
cbn.s = cbn_aux; | |
cbn.len = strlen(cbn.s); | |
LM_INFO(" --- FOUND CBN%.*s \n \n", cbn.len, cbn.s); | |
@@ -899,8 +896,8 @@ int send_request_vpc(struct sip_msg *msg) { | |
return 1; | |
} | |
- if (proxy_hole == 3) { | |
- // Call Server SCENARIO III | |
+ if (proxy_hole == 3) { | |
+ // Call Server SCENARIO III | |
LM_INFO(" ---Hole: proxy redirect \n"); | |
//if (add_hdr_PAI(msg) == -1) { | |
//LM_ERR("FAILURE IN ADD PAI"); | |
@@ -926,27 +923,27 @@ int send_request_vpc(struct sip_msg *msg) { | |
LM_DBG(" --- INIT get_callid_header\n \n"); | |
if ( get_callid_header(msg, &callidHeader) == -1){ | |
LM_ERR("Failed to get callid header\n"); | |
- return -1; | |
+ return -1; | |
} | |
- if(pidf_body && strlen(pidf_body)>1) { | |
- if(locationHeader && strlen(locationHeader)>1){ | |
+ if(pidf_body && strlen(pidf_body)>1) { | |
+ if(locationHeader && strlen(locationHeader)>1){ | |
int size_lie = strlen(pidf_body) + strlen(locationHeader) + 2; | |
lie = pkg_malloc(sizeof (char)* size_lie); | |
memset(lie, 0, size_lie); | |
sprintf(lie, "%s %s", locationHeader, pidf_body); | |
- pkg_free(pidf_body); | |
+ pkg_free(pidf_body); | |
pkg_free(locationHeader); | |
}else{ | |
- lie = pidf_body; | |
+ lie = pidf_body; | |
} | |
} else{ | |
- if(locationHeader && strlen(locationHeader)>1){ | |
+ if(locationHeader && strlen(locationHeader)>1){ | |
lie = locationHeader; | |
}else{ | |
LM_ERR("INVITE whithout location information\n"); | |
- return -1; | |
- } | |
- } | |
+ return -1; | |
+ } | |
+ } | |
LM_INFO(" --- CALLID-HEADER = %s \n \n", callidHeader); | |
@@ -960,14 +957,14 @@ int send_request_vpc(struct sip_msg *msg) { | |
goto error; | |
} | |
LM_INFO(" --- CALLID-HEADER II = %s \n \n", callidHeader); | |
- | |
+ | |
parsed = parse_xml(response); | |
if (parsed != NULL) { | |
- LM_INFO(" --- CALLID-HEADER III = %s \n \n", callidHeader); | |
+ LM_INFO(" --- CALLID-HEADER III = %s \n \n", callidHeader); | |
if(create_call_cell(parsed, msg, callidHeader, cbn) == -1){ | |
pkg_free(response); | |
goto error; | |
- } | |
+ } | |
//free_parsed(parsed); | |
} else { | |
LM_ERR("PARSER ERROR\n"); | |
@@ -977,26 +974,26 @@ int send_request_vpc(struct sip_msg *msg) { | |
LM_INFO("END EMERGENCY"); | |
pkg_free(response); | |
- | |
+ | |
if(callidHeader) | |
pkg_free(callidHeader); | |
- | |
+ | |
if(lie) | |
- pkg_free(lie); | |
+ pkg_free(lie); | |
+ | |
+ free_parsed(parsed); | |
- free_parsed(parsed); | |
- | |
return 1; | |
- | |
-error : | |
+ | |
+error : | |
if(callidHeader) | |
pkg_free(callidHeader); | |
if(lie) | |
- pkg_free(lie); | |
- | |
+ pkg_free(lie); | |
+ | |
free_parsed(parsed); | |
- return -1; | |
+ return -1; | |
} | |
@@ -1031,12 +1028,12 @@ int create_call_cell(PARSED *parsed,struct sip_msg* msg, char* callidHeader, str | |
LM_ERR("--------------------------------------------------no more shm memory\n"); | |
return -1; | |
} | |
- | |
+ | |
// obtem campos do esrResponse e guarda na celula na lista ligada calls_eme | |
if(treat_parse_esrResponse(msg, call_cell , call_cell_source , call_cell_vpc , parsed, proxy_hole) == -1){ | |
return -1; | |
} | |
- | |
+ | |
if (treat_routing(msg, call_cell, callidHeader, cbn) == -1){ | |
return -1; | |
} | |
@@ -1062,18 +1059,18 @@ int treat_routing(struct sip_msg* msg, struct esct *call_cell, char* callidHeade | |
int result = atoi(call_cell->result); | |
int faixa = faixa_result(result); | |
LM_INFO(" --- faixa %d", faixa); | |
- | |
+ | |
if (faixa == 1) { | |
// result NOK sem envio de numero de contigencia | |
LM_ERR("RESULT INVALIDO -- SAINDO DO EMERGENCY %d \n", result); | |
goto error; | |
} | |
- | |
- if (proxy_hole == 0){ | |
+ | |
+ if (proxy_hole == 0){ | |
if (faixa == 2) { | |
// result NOK mas o VPC mandou o numero de contingencia para escoar a chamada | |
- LM_ERR("RESULT INVALIDO --CONTINGENCY \n"); | |
+ LM_ERR("RESULT INVALIDO --CONTINGENCY \n"); | |
contingency(msg, call_cell); | |
@@ -1083,7 +1080,7 @@ int treat_routing(struct sip_msg* msg, struct esct *call_cell, char* callidHeade | |
pkg_free(cbn.s); | |
return 1; | |
- } | |
+ } | |
// result OK | |
call_cell->disposition = "esgwri"; | |
@@ -1093,31 +1090,31 @@ int treat_routing(struct sip_msg* msg, struct esct *call_cell, char* callidHeade | |
// VPC enviou o campo esgwri para encaminhar o INVITE | |
if (call_cell->esqk == NULL){ | |
LM_ERR(" ---Result 200 but without esqk \n"); | |
- goto error; | |
+ goto error; | |
} | |
LM_INFO(" ---CALL CELL -----------------------------------------------------ENTROU N IF ESQWRI = %s", call_cell->esgwri); | |
- | |
+ | |
if(new_uri_proxy(msg,call_cell->esgwri) == -1){ | |
LM_ERR(" ---ERRO EM NEW_URI_PROXY"); | |
goto error; | |
- } | |
+ } | |
} else { | |
LM_INFO("ert_srid %s \n", call_cell->ert_srid); | |
- LM_INFO("ert_resn %d \n", call_cell->ert_resn); | |
- | |
- if ((call_cell->ert_srid != NULL) && (call_cell->ert_resn != 0) && (call_cell->ert_npa != 0)) { | |
+ LM_INFO("ert_resn %d \n", call_cell->ert_resn); | |
+ | |
+ if ((call_cell->ert_srid != NULL) && (call_cell->ert_resn != 0) && (call_cell->ert_npa != 0)) { | |
if (call_cell->esqk == NULL){ | |
LM_ERR(" ---Result 200 but without esqk \n"); | |
- goto error; | |
- } | |
+ goto error; | |
+ } | |
if(routing_by_ert( msg, call_cell) == -1){ | |
goto error; | |
} | |
}else{ | |
- // VPC não enviou nenhum dado para fazer o encaminhamento | |
+ // VPC não enviou nenhum dado para fazer o encaminhamento | |
LM_ERR(" ---Result 200 but without ert or esgwri \n"); | |
- goto error; | |
+ goto error; | |
} | |
} | |
@@ -1127,28 +1124,28 @@ int treat_routing(struct sip_msg* msg, struct esct *call_cell, char* callidHeade | |
}else{ | |
if (proxy_hole == 2){ | |
- LM_INFO(" ---TRATA REDIRECT\n \n"); | |
+ LM_INFO(" ---TRATA REDIRECT\n \n"); | |
if(add_hdr_rpl(call_cell, msg)==-1){ | |
return -1; | |
} | |
if(!eme_tm.t_reply(msg,300,&msg300)){ | |
LM_DBG("t_reply (100)\n"); | |
- return -1; | |
- } | |
+ return -1; | |
+ } | |
call_cell->disposition = "redirect"; | |
- call_cell->timeout = BYE_TIME; | |
- pkg_free(cbn.s); | |
+ call_cell->timeout = BYE_TIME; | |
+ pkg_free(cbn.s); | |
int expires = 300; | |
- if( !send_subscriber(msg, callidHeader, expires)) | |
+ if( !send_subscriber(msg, callidHeader, expires)) | |
return -1; | |
}else{ | |
LM_ERR("proxy_hole invalid\n"); | |
goto error; | |
- } | |
- } | |
+ } | |
+ } | |
return 1; | |
error: | |
@@ -1167,13 +1164,13 @@ error: | |
* - forward the invite | |
*/ | |
int routing_by_ert( struct sip_msg *msg, ESCT *call_cell) { | |
- char *esgwri_db; | |
+ char *esgwri_db; | |
if (emergency_routing(call_cell->ert_srid, call_cell->ert_resn, call_cell->ert_npa, &esgwri_db, ref_lock) != -1) { | |
int esgwri_db_len = strlen(esgwri_db); | |
- LM_INFO("DB_ESGWRI %s \n", esgwri_db); | |
+ LM_INFO("DB_ESGWRI %s \n", esgwri_db); | |
call_cell->esgwri = shm_malloc(sizeof (char)* esgwri_db_len + 1); | |
if (call_cell->esgwri == NULL) { | |
LM_ERR("--------------------------------------------------no more shm memory\n"); | |
@@ -1185,11 +1182,11 @@ int routing_by_ert( struct sip_msg *msg, ESCT *call_cell) { | |
if(new_uri_proxy(msg, esgwri_db) == -1){ | |
if (esgwri_db) | |
- pkg_free(esgwri_db); | |
+ pkg_free(esgwri_db); | |
LM_ERR(" ---ERROR IN NEW_URI_PROXY"); | |
return -1; | |
} | |
- | |
+ | |
pkg_free(esgwri_db); | |
} else { | |
@@ -1200,16 +1197,16 @@ int routing_by_ert( struct sip_msg *msg, ESCT *call_cell) { | |
} | |
-/* | |
+/* | |
* this function treats the forwarding of the message in the case when the VPC returns esrResponse "NOT OK" but with the field LRO not blanck | |
* -Forward the INVITE in a contingency gateway with the altenative numbe lro in the user field of the R-URI | |
*/ | |
int contingency(struct sip_msg *msg, ESCT *call_cell){ | |
- | |
+ | |
char *new_to; | |
char *lro; | |
- | |
- //Treat LRO | |
+ | |
+ //Treat LRO | |
//checks if the LRO field was forwarded by VPC, otherwise the called will have NOK treatment | |
lro = call_cell-> lro; | |
if (lro == NULL) { | |
@@ -1230,7 +1227,7 @@ int contingency(struct sip_msg *msg, ESCT *call_cell){ | |
new_to = pkg_malloc(sizeof (char)* tamanho_new_to); | |
sprintf(new_to, "sip:%s@%s;user=phone", lro, contingency_hostname); | |
- | |
+ | |
call_cell->esgwri = shm_malloc(sizeof (char)* tamanho_new_to + 1); | |
if (call_cell->esgwri == NULL) { | |
LM_ERR("--------------------------------------------------no more shm memory\n"); | |
@@ -1243,9 +1240,9 @@ int contingency(struct sip_msg *msg, ESCT *call_cell){ | |
LM_ERR(" ---ERRO EM NEW_URI_PROXY"); | |
return -1; | |
} | |
- | |
- pkg_free(new_to); | |
- | |
+ | |
+ pkg_free(new_to); | |
+ | |
call_cell->disposition = "lro"; | |
call_cell->esgw = ""; | |
call_cell->timeout = ACK_TIME; | |
@@ -1266,7 +1263,7 @@ int routing_ack(struct sip_msg *msg) { | |
LM_DBG(" --- START TREATMENT ACK \n \n"); | |
if (proxy_hole == 1) { | |
- // Call Server scenario II | |
+ // Call Server scenario II | |
if (proxy_request(msg,call_server_hostname) == -1) { | |
LM_DBG("ERROR IN ROUTING EMERGENCY REQUEST \n"); | |
resp = -1; | |
@@ -1276,7 +1273,7 @@ int routing_ack(struct sip_msg *msg) { | |
} | |
if (proxy_hole == 2) { | |
- // Redirect Proxy scenario III | |
+ // Redirect Proxy scenario III | |
LM_INFO(" ---Hole: proxy redirect \n"); | |
return -1; | |
} | |
@@ -1284,7 +1281,7 @@ int routing_ack(struct sip_msg *msg) { | |
if (get_callid_header(msg, &callidHeader) == -1) | |
return -1; | |
- LM_DBG(" ---TREATMENT ACK callid=%s \n", callidHeader); | |
+ LM_DBG(" ---TREATMENT ACK callid=%s \n", callidHeader); | |
info_call = find_esct(callidHeader); | |
if (info_call == NULL) { | |
LM_DBG(" ---TREATMENT ACK - NOT FIND CALLID \n"); | |
@@ -1293,7 +1290,7 @@ int routing_ack(struct sip_msg *msg) { | |
} | |
if (strlen(info_call->esgwri) > 0) { | |
- LM_DBG(" ---Routing ACK %s \n\n", info_call->esgwri); | |
+ LM_DBG(" ---Routing ACK %s \n\n", info_call->esgwri); | |
if(new_uri_proxy(msg, info_call->esgwri) == -1){ | |
LM_ERR(" ---ERROR IN NEW_URI_PROXY"); | |
resp = -1; | |
@@ -1304,7 +1301,7 @@ int routing_ack(struct sip_msg *msg) { | |
info_call->timeout = BYE_TIME; | |
resp = 1; | |
-end : | |
+end : | |
if(callidHeader) | |
pkg_free(callidHeader); | |
return resp; | |
@@ -1329,12 +1326,12 @@ int bye(struct sip_msg *msg, int dir) { | |
struct tm * timeinfo; | |
char formated_time[80]; | |
NODE* info_call; | |
- char* xml; | |
+ char* xml=NULL; | |
LM_DBG(" --- BYE \n \n"); | |
if (proxy_hole == 1) { | |
- // Call Server scenario II | |
+ // Call Server scenario II | |
LM_DBG(" ---Hole: proxy routing \n"); | |
if (proxy_request(msg,call_server_hostname) == -1) { | |
LM_ERR("ERROR IN ROUTING EMERGENCY REQUEST"); | |
@@ -1344,7 +1341,7 @@ int bye(struct sip_msg *msg, int dir) { | |
} | |
if (proxy_hole == 2) { | |
- // Redirect Proxy scenario III | |
+ // Redirect Proxy scenario III | |
LM_DBG(" ---Hole: proxy redirect \n"); | |
return -1; | |
} | |
@@ -1352,7 +1349,7 @@ int bye(struct sip_msg *msg, int dir) { | |
/* | |
if (proxy_hole == 3) { | |
// Redirect proxy scenario III | |
- // NOT YET IMPLEMENTED | |
+ // NOT YET IMPLEMENTED | |
LM_DBG(" ---Hole: proxy redirect \n"); | |
return -1; | |
} | |
@@ -1371,7 +1368,7 @@ int bye(struct sip_msg *msg, int dir) { | |
if (dir == 1) { | |
if (strlen(info_call->esct->esgwri) > 0) { | |
- LM_DBG(" ---Routing BYE %s \n\n", info_call->esct->esgwri); | |
+ LM_DBG(" ---Routing BYE %s \n\n", info_call->esct->esgwri); | |
if(new_uri_proxy(msg, info_call->esct->esgwri) == -1){ | |
LM_ERR(" ---ERROR IN NEW_URI_PROXY"); | |
free_call_cell(info_call); | |
@@ -1390,32 +1387,33 @@ int bye(struct sip_msg *msg, int dir) { | |
if(info_call->esct->datetimestamp){ | |
shm_free (info_call->esct->datetimestamp); | |
- LM_DBG(" --- FREE INFO_CALL->TIME"); | |
+ LM_DBG(" --- FREE INFO_CALL->TIME"); | |
} | |
time(&rawtime); | |
timeinfo = localtime(&rawtime); | |
- strftime(formated_time, 80, "%Y-%m-%dT%H:%M:%S%Z", timeinfo); | |
+ strftime(formated_time, 80, "%Y-%m-%dT%H:%M:%S%Z", timeinfo); | |
info_call->esct->datetimestamp = formated_time; | |
- LM_INFO(" --- TREAT BYE - XML ESCT %s \n \n", xml); | |
- xml = buildXmlFromModel(info_call->esct); | |
+ xml = buildXmlFromModel(info_call->esct); | |
+ | |
+ LM_INFO(" --- TREAT BYE - XML ESCT %s \n \n", xml); | |
// sends HTTP POST esctRequest to VPC | |
resp = post(url_vpc, xml, &response); | |
if (resp == -1) { | |
LM_ERR(" --- PROBLEM IN POST DO BYE\n \n"); | |
- free_call_cell(info_call); | |
- pkg_free(xml); | |
- resp = -1; | |
+ free_call_cell(info_call); | |
+ pkg_free(xml); | |
+ resp = -1; | |
goto end; | |
} | |
esct_callid = parse_xml_esct(response); | |
if (esct_callid== NULL) { | |
- LM_ERR(" --- esctAck invalid format or without mandatory field \n \n"); | |
+ LM_ERR(" --- esctAck invalid format or without mandatory field \n \n"); | |
} else { | |
if (strcmp(esct_callid, callidHeader)){ | |
- LM_ERR(" --- callid in esctAck different from asctRequest \n \n"); | |
+ LM_ERR(" --- callid in esctAck different from asctRequest \n \n"); | |
} | |
if(esct_callid) | |
pkg_free(esct_callid); | |
@@ -1428,7 +1426,7 @@ int bye(struct sip_msg *msg, int dir) { | |
free_call_cell(info_call); | |
resp = 1; | |
-end : | |
+end : | |
if(callidHeader) | |
pkg_free(callidHeader); | |
return resp; | |
@@ -1500,7 +1498,7 @@ unsigned long get_xml_size(char* lie, char* formated_time, char* callidHeader, c | |
resp += strlen(MODEL); | |
resp += strlen(lie); | |
resp += strlen(callidHeader); | |
- resp += strlen(cbn); | |
+ resp += strlen(cbn); | |
resp += strlen(formated_time); | |
resp += strlen(vpc_organization_name); | |
resp += strlen(vpc_hostname) + strlen(vpc_nena_id); | |
@@ -1529,7 +1527,7 @@ char* formatted_xml(char* lie, char* callidHeader, char* cbn) { | |
LM_DBG(" --- FORMATANDO XML \n \n"); | |
int size_xml = get_xml_size(lie, formated_time, callidHeader, cbn) + 1; | |
- LM_DBG(" --- TAMANHO XML %d \n \n", size_xml); | |
+ LM_DBG(" --- TAMANHO XML %d \n \n", size_xml); | |
xml = pkg_malloc(sizeof (char) * size_xml); | |
memset(xml, 0, size_xml); | |
sprintf(xml, MODEL,\ | |
@@ -1540,4 +1538,4 @@ char* formatted_xml(char* lie, char* callidHeader, char* cbn) { | |
call_origin, formated_time); | |
LM_DBG(" --- INIT xml %s\n \n", xml); | |
return xml; | |
-} | |
\ No newline at end of file | |
+} | |
diff --git a/modules/emergency/model.h b/modules/emergency/model.h | |
index 3ec8687..aa7773a 100644 | |
--- a/modules/emergency/model.h | |
+++ b/modules/emergency/model.h | |
@@ -57,4 +57,4 @@ xsi:schemaLocation=\"urn:nena:xml:ns:es:v2 v2.xsd\"> \n \ | |
<callOrigin>%s</callOrigin> \n \ | |
<datetimestamp>%s</datetimestamp> \n \ | |
<customer>0</customer> \n \ | |
-</esrRequest>"; | |
\ No newline at end of file | |
+</esrRequest>"; | |
diff --git a/modules/emergency/report_emergency.c b/modules/emergency/report_emergency.c | |
index 93eb53c..b1fa791 100644 | |
--- a/modules/emergency/report_emergency.c | |
+++ b/modules/emergency/report_emergency.c | |
@@ -26,7 +26,7 @@ | |
#include <stdio.h> | |
#include <stdlib.h> | |
-#include "report_emergency.h" | |
+#include "report_emergency.h" | |
#define NR_KEYS 12 | |
@@ -158,7 +158,7 @@ int report(struct emergency_report *report, str db_url, str table_report) { | |
LM_INFO("DISPOSITION_REPORT_LEN %d \n", report->disposition.len); | |
- // no field can be null | |
+ // no field can be null | |
int i = 0; | |
for (i = 0; i < NR_KEYS; i++) | |
@@ -177,7 +177,7 @@ int report(struct emergency_report *report, str db_url, str table_report) { | |
db_funcs.close(db_con); | |
db_con = 0; | |
- | |
+ | |
return 1; | |
} | |
@@ -186,20 +186,20 @@ int report(struct emergency_report *report, str db_url, str table_report) { | |
* - CALLID | |
* - ESGWRI | |
* - ERT-RESN | |
-* - ERT-NPA | |
-* - ERT-SRID | |
-* - LRO | |
-* - VPC - NAME | |
-* - VPC - HOST | |
-* - TIMESTAMP | |
-* - RESULT | |
-* - DISPOSITION | |
+* - ERT-NPA | |
+* - ERT-SRID | |
+* - LRO | |
+* - VPC - NAME | |
+* - VPC - HOST | |
+* - TIMESTAMP | |
+* - RESULT | |
+* - DISPOSITION | |
*/ | |
int collect_data(struct node *current, str db_url, str table_report) { | |
int callid_len, esgwri_len, srid_len, lro_len, vpc_name_len, vpc_host_len, time_len, result_len, disposition_len; | |
int size_report; | |
- struct emergency_report *report_eme; | |
+ struct emergency_report *report_eme; | |
callid_len = strlen(current->esct->callid); | |
esgwri_len = strlen(current->esct->esgwri); | |
srid_len = strlen(current->esct->ert_srid); | |
@@ -209,14 +209,14 @@ int collect_data(struct node *current, str db_url, str table_report) { | |
disposition_len = strlen(current->esct->disposition); | |
vpc_name_len = strlen(current->esct->vpc->organizationname); | |
vpc_host_len = strlen(current->esct->vpc->hostname); | |
- | |
+ | |
size_report = sizeof (struct emergency_report) +callid_len + esgwri_len + srid_len + lro_len + vpc_name_len + vpc_host_len + time_len + result_len + disposition_len; | |
report_eme = pkg_malloc(size_report); | |
if (report_eme == NULL) { | |
LM_ERR("no more pkg memory\n"); | |
return -1; | |
} | |
- | |
+ | |
memset(report_eme, 0, size_report); | |
report_eme->callid.len = callid_len; | |
@@ -234,7 +234,7 @@ int collect_data(struct node *current, str db_url, str table_report) { | |
report_eme->ert_resn = current->esct->ert_resn; | |
report_eme->ert_npa = current->esct->ert_npa; | |
- | |
+ | |
report_eme->esgwri.len = esgwri_len; | |
if (esgwri_len == 0) { | |
report_eme->esgwri.s = " "; | |
@@ -272,8 +272,8 @@ int collect_data(struct node *current, str db_url, str table_report) { | |
} | |
report_eme->result.len = result_len; | |
report_eme->result.s = (char *) (report_eme + 1) + callid_len + srid_len + esgwri_len + lro_len + vpc_name_len + vpc_host_len + time_len; | |
- memcpy(report_eme->result.s, current->esct->result, result_len); | |
- | |
+ memcpy(report_eme->result.s, current->esct->result, result_len); | |
+ | |
report_eme->timestamp.len = time_len; | |
if (time_len == 0) { | |
report_eme->timestamp.s = " "; | |
@@ -281,7 +281,7 @@ int collect_data(struct node *current, str db_url, str table_report) { | |
} else { | |
report_eme->timestamp.s = (char *) (report_eme + 1) + callid_len + srid_len + esgwri_len + lro_len + vpc_name_len + vpc_host_len; | |
memcpy(report_eme->timestamp.s, current->esct->datetimestamp, time_len); | |
- } | |
+ } | |
report_eme->disposition.len = disposition_len; | |
report_eme->disposition.s = (char *) (report_eme + 1) + callid_len + srid_len + esgwri_len + lro_len + vpc_name_len + vpc_host_len + time_len + result_len; | |
memcpy(report_eme->disposition.s, current->esct->disposition, disposition_len); | |
@@ -298,7 +298,7 @@ int collect_data(struct node *current, str db_url, str table_report) { | |
LM_INFO(" --- REPORT - RESULT %.*s \n\n", report_eme->result.len, report_eme->result.s); | |
LM_INFO(" --- REPORT - DISPOSITION %.*s \n\n", report_eme->disposition.len, report_eme->disposition.s); | |
- LM_INFO(" --- TABLE_REPORT %.*s \n\n", table_report.len, table_report.s); | |
+ LM_INFO(" --- TABLE_REPORT %.*s \n\n", table_report.len, table_report.s); | |
/* | |
if (report(report_eme, db_url, table_report) != 1) { | |
@@ -307,7 +307,7 @@ int collect_data(struct node *current, str db_url, str table_report) { | |
return -1; | |
} | |
*/ | |
- | |
+ | |
LM_INFO("****** INSERT OK\n"); | |
pkg_free(report_eme); | |
return 1; | |
@@ -315,7 +315,7 @@ int collect_data(struct node *current, str db_url, str table_report) { | |
/* retreives esgwrifrom the list db_esrn_esgwri | |
-* using srid(selectiveRoutingID), resn(routingESN) and npa. | |
+* using srid(selectiveRoutingID), resn(routingESN) and npa. | |
*/ | |
int emergency_routing(char *srid, int resn, int npa, char** esgwri, rw_lock_t *ref_lock ) { | |
@@ -326,7 +326,7 @@ int emergency_routing(char *srid, int resn, int npa, char** esgwri, rw_lock_t *r | |
while (esrn_domain != NULL) { | |
LM_DBG("CMP SRID= %.*s \n", esrn_domain->srid.len, esrn_domain->srid.s); | |
LM_DBG("CMP RESN= %d \n", esrn_domain->resn); | |
- LM_DBG("CMP NPA = %d \n", esrn_domain->npa); | |
+ LM_DBG("CMP NPA = %d \n", esrn_domain->npa); | |
if (strncmp(esrn_domain->srid.s, srid, esrn_domain->srid.len) == 0) { | |
if ((esrn_domain->resn == resn)&&(esrn_domain->npa == npa)) { | |
char* temp = pkg_malloc(sizeof (char) * esrn_domain->esgwri.len + 1); | |
@@ -361,7 +361,7 @@ int get_db_routing(str table_name, rw_lock_t *ref_lock ){ | |
str SRID; | |
int RESN; | |
int NPA; | |
- int nr_rows, i, size, id; | |
+ int nr_rows, i, size; | |
struct esrn_routing *esrn_cell, *old_list, *it, *aux, *new_list; | |
struct esrn_routing *init_esrn = NULL; | |
@@ -393,8 +393,6 @@ int get_db_routing(str table_name, rw_lock_t *ref_lock ){ | |
goto end; | |
} | |
- id = VAL_INT(values); | |
- | |
if (VAL_NULL(values + 1) || | |
(VAL_TYPE(values + 1) != DB_STR && VAL_TYPE(values + 1) != DB_STRING)) { | |
LM_ERR("Invalid translated returned 2\n"); | |
@@ -488,4 +486,4 @@ end: | |
return 1; | |
-} | |
\ No newline at end of file | |
+} | |
diff --git a/modules/emergency/subscriber_emergency.c b/modules/emergency/subscriber_emergency.c | |
index 54ee642..10ab6b0 100755 | |
--- a/modules/emergency/subscriber_emergency.c | |
+++ b/modules/emergency/subscriber_emergency.c | |
@@ -26,15 +26,15 @@ | |
#include <stdio.h> | |
#include <stdlib.h> | |
-#include "subscriber_emergency.h" | |
- | |
+#include "subscriber_emergency.h" | |
+ | |
#define INIT 0 | |
#define NOTIFY_WAIT 1 | |
-#define PENDING 2 | |
-#define ACTIVE 3 | |
-#define TERMINATED 4 | |
+#define PENDING 2 | |
+#define ACTIVE 3 | |
+#define TERMINATED 4 | |
-/*Create cell to control Subscriber Dialog States | |
+/*Create cell to control Subscriber Dialog States | |
This cell save this information: | |
- Dialog Id: | |
.Callid | |
@@ -43,11 +43,11 @@ | |
- expires | |
- Local_uri | |
- Remote_uri | |
- - Notifier_uri | |
+ - Notifier_uri | |
- INVITE's Callid | |
- Event body | |
- State | |
-*/ | |
+*/ | |
int create_subscriber_cell(struct sip_msg* reply, struct parms_cb* params_cb){ | |
str* callid = NULL; | |
@@ -56,7 +56,7 @@ int create_subscriber_cell(struct sip_msg* reply, struct parms_cb* params_cb){ | |
int size_subs_cell; | |
struct sm_subscriber *new_cell = NULL; | |
int vsp_addr_len; | |
- char *vsp_addr = "@vsp.com"; | |
+ char *vsp_addr = "@vsp.com"; | |
time_t rawtime; | |
int time_now; | |
struct sm_subscriber *subs_cell = NULL; | |
@@ -65,16 +65,16 @@ int create_subscriber_cell(struct sip_msg* reply, struct parms_cb* params_cb){ | |
if (callid == NULL) { | |
LM_ERR("--------------------------------------------------no more pkg memory\n"); | |
return 0; | |
- } | |
- /*Verify repĺy is OK and get callid and expires from response*/ | |
+ } | |
+ /*Verify repĺy is OK and get callid and expires from response*/ | |
if ( !extract_reply_headers(reply, callid, expires)){ | |
- LM_ERR("fail in extract headers\n"); | |
- return 0; | |
+ LM_ERR("fail in extract headers\n"); | |
+ return 0; | |
} | |
/*get From header fields */ | |
pfrom = get_from(reply); | |
- LM_INFO("PFROM: %.*s \n ", pfrom->uri.len, pfrom->uri.s ); | |
+ LM_INFO("PFROM: %.*s \n ", pfrom->uri.len, pfrom->uri.s ); | |
if( pfrom->tag_value.s ==NULL || pfrom->tag_value.len == 0){ | |
LM_ERR("reply without tag value \n"); | |
return 0; | |
@@ -82,7 +82,7 @@ int create_subscriber_cell(struct sip_msg* reply, struct parms_cb* params_cb){ | |
/*get To header fields */ | |
pto = get_to(reply); | |
- LM_INFO("PTO: %.*s \n ", pto->uri.len, pto->uri.s ); | |
+ LM_INFO("PTO: %.*s \n ", pto->uri.len, pto->uri.s ); | |
if (pto == NULL || pto->error != PARSE_OK) { | |
LM_ERR("failed to parse TO header\n"); | |
return 0; | |
@@ -90,7 +90,7 @@ int create_subscriber_cell(struct sip_msg* reply, struct parms_cb* params_cb){ | |
// get source ip address that send INVITE | |
vsp_addr = ip_addr2a(&reply->rcv.src_ip); | |
- vsp_addr_len = strlen(vsp_addr); | |
+ vsp_addr_len = strlen(vsp_addr); | |
time(&rawtime); | |
time_now = (int)rawtime; | |
@@ -106,21 +106,21 @@ int create_subscriber_cell(struct sip_msg* reply, struct parms_cb* params_cb){ | |
memset(subs_cell, 0, size_subs_cell + 1); | |
subs_cell->expires = expires; | |
- subs_cell->timeout = TIMER_B + time_now; | |
- LM_INFO("SUBS_TIMEOUT: %d \n ", subs_cell->timeout ); | |
+ subs_cell->timeout = TIMER_B + time_now; | |
+ LM_INFO("SUBS_TIMEOUT: %d \n ", subs_cell->timeout ); | |
subs_cell->dlg_id.callid.len = callid->len; | |
- subs_cell->dlg_id.callid.s = (char *) (subs_cell + 1); | |
+ subs_cell->dlg_id.callid.s = (char *) (subs_cell + 1); | |
memcpy(subs_cell->dlg_id.callid.s, callid->s, callid->len); | |
- LM_INFO("SUBS_CALLID: %.*s \n ", subs_cell->dlg_id.callid.len, subs_cell->dlg_id.callid.s ); | |
+ LM_INFO("SUBS_CALLID: %.*s \n ", subs_cell->dlg_id.callid.len, subs_cell->dlg_id.callid.s ); | |
subs_cell->dlg_id.from_tag.len = pfrom->tag_value.len; | |
- subs_cell->dlg_id.from_tag.s = (char *) (subs_cell + 1) + callid->len; | |
+ subs_cell->dlg_id.from_tag.s = (char *) (subs_cell + 1) + callid->len; | |
memcpy(subs_cell->dlg_id.from_tag.s, pfrom->tag_value.s, pfrom->tag_value.len); | |
- LM_INFO("SUBS_FROM_TAG: %.*s \n ", subs_cell->dlg_id.from_tag.len, subs_cell->dlg_id.from_tag.s ); | |
+ LM_INFO("SUBS_FROM_TAG: %.*s \n ", subs_cell->dlg_id.from_tag.len, subs_cell->dlg_id.from_tag.s ); | |
subs_cell->dlg_id.to_tag.len = pto->tag_value.len; | |
- subs_cell->dlg_id.to_tag.s = (char *) (subs_cell + 1) + callid->len + pfrom->tag_value.len; | |
+ subs_cell->dlg_id.to_tag.s = (char *) (subs_cell + 1) + callid->len + pfrom->tag_value.len; | |
memcpy(subs_cell->dlg_id.to_tag.s, pto->tag_value.s, pto->tag_value.len); | |
LM_INFO("SUBS_TO_TAG: %.*s \n ", subs_cell->dlg_id.to_tag.len, subs_cell->dlg_id.to_tag.s ); | |
@@ -131,23 +131,23 @@ int create_subscriber_cell(struct sip_msg* reply, struct parms_cb* params_cb){ | |
subs_cell->rem_uri.len= pto->uri.len; | |
subs_cell->rem_uri.s = (char *) (subs_cell + 1) + callid->len + pfrom->tag_value.len + pfrom->uri.len + pto->tag_value.len; | |
- memcpy(subs_cell->rem_uri.s, pto->uri.s, pto->uri.len); | |
- LM_INFO("SUBS_REM_URI: %.*s \n ", subs_cell->rem_uri.len, subs_cell->rem_uri.s ); | |
+ memcpy(subs_cell->rem_uri.s, pto->uri.s, pto->uri.len); | |
+ LM_INFO("SUBS_REM_URI: %.*s \n ", subs_cell->rem_uri.len, subs_cell->rem_uri.s ); | |
subs_cell->callid_ori.len= params_cb->callid_ori.len; | |
subs_cell->callid_ori.s = (char *) (subs_cell + 1) + callid->len + pfrom->tag_value.len + pfrom->uri.len + pto->tag_value.len + pto->uri.len; | |
- memcpy(subs_cell->callid_ori.s, params_cb->callid_ori.s, params_cb->callid_ori.len); | |
- LM_INFO("SUBS_CALLID_ORI: %.*s \n ", subs_cell->callid_ori.len, subs_cell->callid_ori.s ); | |
+ memcpy(subs_cell->callid_ori.s, params_cb->callid_ori.s, params_cb->callid_ori.len); | |
+ LM_INFO("SUBS_CALLID_ORI: %.*s \n ", subs_cell->callid_ori.len, subs_cell->callid_ori.s ); | |
subs_cell->event.len= params_cb->event.len; | |
subs_cell->event.s = (char *) (subs_cell + 1) + callid->len + pfrom->tag_value.len + pfrom->uri.len + pto->tag_value.len + pto->uri.len + params_cb->callid_ori.len; | |
- memcpy(subs_cell->event.s, params_cb->event.s, params_cb->event.len); | |
- LM_INFO("SUBS_EVENT: %.*s \n ", subs_cell->event.len, subs_cell->event.s ); | |
+ memcpy(subs_cell->event.s, params_cb->event.s, params_cb->event.len); | |
+ LM_INFO("SUBS_EVENT: %.*s \n ", subs_cell->event.len, subs_cell->event.s ); | |
subs_cell->contact.len = vsp_addr_len + 10; | |
subs_cell->contact.s = (char *) (subs_cell + 1) + callid->len + pfrom->tag_value.len + pfrom->uri.len + pto->tag_value.len + pto->uri.len + params_cb->callid_ori.len + params_cb->event.len; | |
- memcpy(subs_cell->contact.s, "sip:teste@", 10); | |
- memcpy(subs_cell->contact.s + 10, vsp_addr, vsp_addr_len); | |
+ memcpy(subs_cell->contact.s, "sip:teste@", 10); | |
+ memcpy(subs_cell->contact.s + 10, vsp_addr, vsp_addr_len); | |
LM_INFO("SUBS_CONTACT: %.*s \n ", subs_cell->contact.len, subs_cell->contact.s ); | |
subs_cell -> status = NOTIFY_WAIT; | |
@@ -183,7 +183,7 @@ int extract_reply_headers(struct sip_msg* reply, str* callid, int expires){ | |
if( reply->callid==NULL || reply->callid->body.s==NULL){ | |
LM_ERR("reply without callid header\n"); | |
return 0; | |
- } | |
+ } | |
*callid = reply->callid->body; | |
if (reply->from->parsed == NULL){ | |
@@ -200,7 +200,7 @@ int extract_reply_headers(struct sip_msg* reply, str* callid, int expires){ | |
if(reply->expires == NULL){ | |
LM_ERR("reply without Expires header\n"); | |
- return 0; | |
+ return 0; | |
} | |
/* extract the other necesary information for inserting a new record */ | |
if(reply->expires && reply->expires->body.len > 0){ | |
@@ -219,15 +219,15 @@ int extract_reply_headers(struct sip_msg* reply, str* callid, int expires){ | |
/* Treat Subscribe reply callbackfrom Notifier */ | |
void subs_cback_func(struct cell *t, int cb_type, struct tmcb_params *params){ | |
- int code = params->code; | |
- struct sip_msg *reply = params->rpl; | |
+ int code = params->code; | |
+ struct sip_msg *reply = params->rpl; | |
struct parms_cb* params_cb = (struct parms_cb*)(*params->param); | |
- LM_INFO("TREAT SUBSCRIBE RERPLY \n"); | |
+ LM_INFO("TREAT SUBSCRIBE RERPLY \n"); | |
LM_DBG("REPLY: %.*s \n ", reply->first_line.u.reply.version.len, reply->first_line.u.reply.version.s ); | |
- LM_DBG("CODE: %d \n ", code); | |
- LM_INFO("CALLID_INVITE: %.*s \n ",params_cb->callid_ori.len,params_cb->callid_ori.s); | |
+ LM_DBG("CODE: %d \n ", code); | |
+ LM_INFO("CALLID_INVITE: %.*s \n ",params_cb->callid_ori.len,params_cb->callid_ori.s); | |
/* verify if response is OK*/ | |
if (code < 300){ | |
@@ -241,12 +241,12 @@ void subs_cback_func(struct cell *t, int cb_type, struct tmcb_params *params){ | |
/* Response NOK send esct to clear esqk in VPC*/ | |
LM_ERR("reply to SUBSCRIBER NOK\n"); | |
if(send_esct(params_cb->callid_ori) == 0){ | |
- LM_ERR("error in send to esct\n"); | |
- } | |
+ LM_ERR("error in send to esct\n"); | |
+ } | |
} | |
shm_free(params_cb->callid_ori.s); | |
- shm_free(params_cb->event.s); | |
+ shm_free(params_cb->event.s); | |
shm_free(params_cb); | |
return; | |
} | |
@@ -274,7 +274,7 @@ str* add_hdr_subscriber(int expires, str event){ | |
if(str_expires == NULL || size_expires == 0){ | |
LM_ERR("while converting int to str\n"); | |
return NULL; | |
- } | |
+ } | |
LM_INFO("EVENT STR %.*s \n", event.len, event.s); | |
size_event = event.len; | |
@@ -296,10 +296,10 @@ str* add_hdr_subscriber(int expires, str event){ | |
memcpy(aux_hdr, CRLF, CRLF_LEN); | |
aux_hdr += CRLF_LEN; | |
- memcpy(aux_hdr, "Expires: ", 9); | |
+ memcpy(aux_hdr, "Expires: ", 9); | |
aux_hdr += 9; | |
memcpy(aux_hdr, str_expires, size_expires); | |
- aux_hdr += size_expires; | |
+ aux_hdr += size_expires; | |
memcpy(aux_hdr, CRLF, CRLF_LEN); | |
aux_hdr += CRLF_LEN; | |
aux_hdr = '\0'; | |
@@ -314,15 +314,15 @@ int build_params_cb(struct sip_msg* msg, char* callidHeader, struct parms_cb* p | |
char *dialog_aux; | |
str from_tag; | |
int size_callid; | |
- int size_dialog; | |
- char *dialog; | |
+ int size_dialog; | |
+ char *dialog; | |
if (parse_from_header(msg) != 0) { | |
- LM_ERR(" REQUEST WITHOUT FROM HEADER\n"); | |
+ LM_ERR(" REQUEST WITHOUT FROM HEADER\n"); | |
} | |
- from_tag = get_from(msg)->tag_value; | |
- LM_INFO("****** FROM_TAG: %.*s\n", from_tag.len, from_tag.s); | |
+ from_tag = get_from(msg)->tag_value; | |
+ LM_INFO("****** FROM_TAG: %.*s\n", from_tag.len, from_tag.s); | |
LM_INFO("************ CALLID = %s \n", callidHeader); | |
size_callid = strlen(callidHeader); | |
@@ -333,14 +333,14 @@ int build_params_cb(struct sip_msg* msg, char* callidHeader, struct parms_cb* p | |
LM_ERR("--------------------------------------------------no more pkg memory\n"); | |
return 0; | |
} | |
- memset(dialog_aux, 0, size_dialog + 1); | |
+ memset(dialog_aux, 0, size_dialog + 1); | |
dialog = dialog_aux; | |
memcpy(dialog_aux, "dialog; call-id=", 16); | |
dialog_aux += 16; | |
memcpy(dialog_aux, callidHeader, size_callid); | |
dialog_aux += size_callid; | |
memcpy(dialog_aux, ";from-tag=", 10); | |
- dialog_aux += 10; | |
+ dialog_aux += 10; | |
memcpy(dialog_aux, from_tag.s, from_tag.len); | |
LM_INFO("****** dialog: %s\n", dialog); | |
@@ -352,14 +352,14 @@ int build_params_cb(struct sip_msg* msg, char* callidHeader, struct parms_cb* p | |
} | |
call_aux[size_callid] = 0; | |
- memcpy(call_aux, callidHeader, size_callid); | |
+ memcpy(call_aux, callidHeader, size_callid); | |
params_cb->callid_ori.s = call_aux; | |
- params_cb->callid_ori.len = size_callid; | |
+ params_cb->callid_ori.len = size_callid; | |
params_cb->event.s = dialog; | |
- params_cb->event.len = size_dialog; | |
+ params_cb->event.len = size_dialog; | |
- return 1; | |
+ return 1; | |
} | |
@@ -370,19 +370,19 @@ int get_uris_to_subscribe(struct sip_msg* msg, str* contact, str* notifier, str* | |
struct sip_uri *furi; | |
int size_contact; | |
int size_notifier; | |
- int size_subscriber; | |
+ int size_subscriber; | |
char *contact_aux; | |
char *notifier_aux; | |
- char *subscriber_aux; | |
+ char *subscriber_aux; | |
int vsp_addr_len; | |
- char *vsp_addr = "@vsp.com"; | |
+ char *vsp_addr = "@vsp.com"; | |
int rp_addr_len; | |
- char *rp_addr = "@rp.com"; | |
+ char *rp_addr = "@rp.com"; | |
/* build contact uri to use in To header */ | |
if ((furi = parse_from_uri(msg)) == NULL) { | |
- LM_ERR("****** ERROR PARSE FROM \n"); | |
- return 0; | |
+ LM_ERR("****** ERROR PARSE FROM \n"); | |
+ return 0; | |
} | |
size_contact= furi->user.len + furi->host.len + furi->port.len + 6; | |
@@ -400,13 +400,13 @@ int get_uris_to_subscribe(struct sip_msg* msg, str* contact, str* notifier, str* | |
memcpy(contact_aux, furi->user.s, furi->user.len); | |
contact_aux += furi->user.len; | |
*contact_aux = '@'; | |
- contact_aux++; | |
+ contact_aux++; | |
memcpy(contact_aux, furi->host.s, furi->host.len); | |
contact_aux += furi->host.len; | |
- *contact_aux = ':'; | |
+ *contact_aux = ':'; | |
contact_aux++; | |
memcpy(contact_aux, furi->port.s, furi->port.len); | |
- LM_INFO("****** contact: %.*s\n", contact->len, contact->s); | |
+ LM_INFO("****** contact: %.*s\n", contact->len, contact->s); | |
/* build notifier uri to use in R-URI */ | |
if ((parse_sip_msg_uri(msg) < 0) || | |
@@ -417,7 +417,7 @@ int get_uris_to_subscribe(struct sip_msg* msg, str* contact, str* notifier, str* | |
} | |
// get source ip address that send INVITE | |
vsp_addr = ip_addr2a(&msg->rcv.src_ip); | |
- vsp_addr_len = strlen(vsp_addr); | |
+ vsp_addr_len = strlen(vsp_addr); | |
size_notifier = vsp_addr_len + msg->parsed_uri.user.len + 5; | |
notifier_aux = pkg_malloc(size_notifier + 1); | |
@@ -456,7 +456,7 @@ int get_uris_to_subscribe(struct sip_msg* msg, str* contact, str* notifier, str* | |
memcpy(subscriber_aux, "sip:opensips_redirect", 21); | |
subscriber_aux += 21; | |
memcpy(subscriber_aux, rp_addr, rp_addr_len); | |
- LM_INFO("****** subscriber: %.*s\n", subscriber->len, subscriber->s); | |
+ LM_INFO("****** subscriber: %.*s\n", subscriber->len, subscriber->s); | |
return 1; | |
@@ -467,12 +467,11 @@ int get_uris_to_subscribe(struct sip_msg* msg, str* contact, str* notifier, str* | |
void subs_cback_func_II(struct cell *t, int cb_type, struct tmcb_params *params){ | |
int code = params->code; | |
- str callid; | |
- struct sip_msg *reply = params->rpl; | |
+ struct sip_msg *reply = params->rpl; | |
- LM_INFO("TREAT SUBSCRIBE TERMINATED REPLY \n"); | |
+ LM_INFO("TREAT SUBSCRIBE TERMINATED REPLY \n"); | |
LM_DBG("REPLY: %.*s \n ", reply->first_line.u.reply.version.len, reply->first_line.u.reply.version.s ); | |
- LM_DBG("CODE: %d \n ", code); | |
+ LM_DBG("CODE: %d \n ", code); | |
if (code < 300){ | |
@@ -490,7 +489,6 @@ void subs_cback_func_II(struct cell *t, int cb_type, struct tmcb_params *params) | |
LM_ERR("reply without callid header\n"); | |
return; | |
} | |
- callid = reply->callid->body; | |
}else{ | |
LM_ERR("reply to subscribe terminated NOK\n "); | |
} | |
@@ -543,7 +541,7 @@ dlg_t* build_dlg(struct sm_subscriber* subscriber){ | |
dialog->rem_uri.len = subscriber->rem_uri.len; | |
size+= dialog->rem_uri.len; | |
- | |
+ | |
dialog->rem_target.s = (char*)dialog+ size; | |
memcpy(dialog->rem_target.s, subscriber->contact.s, subscriber->contact.len); | |
dialog->rem_target.len = subscriber->contact.len; | |
@@ -572,7 +570,7 @@ int send_subscriber(struct sip_msg* msg, char* callidHeader, int expires){ | |
if (contact_pt == NULL) { | |
LM_ERR("--------------------------------------------------no more pkg memory\n"); | |
return 0; | |
- } | |
+ } | |
notifier_pt = (str*) pkg_malloc (sizeof (str)); | |
if (notifier_pt == NULL) { | |
LM_ERR("--------------------------------------------------no more pkg memory\n"); | |
@@ -586,20 +584,20 @@ int send_subscriber(struct sip_msg* msg, char* callidHeader, int expires){ | |
if( !get_uris_to_subscribe(msg, contact_pt, notifier_pt, subscriber_pt)){ | |
LM_ERR("**** fail in build parameters to cb \n"); | |
return 0; | |
- } | |
+ } | |
/*buid struct (INVITE Callid, Event body) for parameter callback */ | |
params_cb = (struct parms_cb*) shm_malloc (sizeof (struct parms_cb)); | |
if (params_cb == NULL) { | |
LM_ERR("--------------------------------------------------no more shm memory\n"); | |
return 0; | |
- } | |
+ } | |
if( !build_params_cb(msg, callidHeader, params_cb )){ | |
LM_ERR("**** fail in build parameters to cb \n"); | |
return 0; | |
- } | |
+ } | |
- /* add new header (Event, Expires) in SUBSCRIBE request */ | |
+ /* add new header (Event, Expires) in SUBSCRIBE request */ | |
pt_hdr = add_hdr_subscriber( expires, params_cb->event); | |
/* send SUBSCRIBER */ | |
@@ -619,9 +617,9 @@ int send_subscriber(struct sip_msg* msg, char* callidHeader, int expires){ | |
if(sending< 0){ | |
LM_ERR("while sending request with t_request\n"); | |
shm_free(params_cb->callid_ori.s); | |
- shm_free(params_cb->event.s); | |
+ shm_free(params_cb->event.s); | |
shm_free(params_cb); | |
- } | |
+ } | |
pkg_free(notifier_pt->s); | |
pkg_free(contact_pt->s); | |
@@ -629,8 +627,8 @@ int send_subscriber(struct sip_msg* msg, char* callidHeader, int expires){ | |
pkg_free(notifier_pt); | |
pkg_free(contact_pt); | |
pkg_free(subscriber_pt); | |
- pkg_free(pt_hdr->s); | |
- pkg_free(pt_hdr); | |
+ pkg_free(pt_hdr->s); | |
+ pkg_free(pt_hdr); | |
return 1; | |
@@ -648,13 +646,13 @@ int send_subscriber_within(struct sip_msg* msg, struct sm_subscriber* subs, int | |
dialog = build_dlg(subs); | |
if(dialog== NULL){ | |
- LM_INFO(" --- ERROR IN BUILD DIALOG \n"); | |
- return -1; | |
+ LM_INFO(" --- ERROR IN BUILD DIALOG \n"); | |
+ return -1; | |
} | |
- LM_INFO(" --- FINAL \n"); | |
+ LM_INFO(" --- FINAL \n"); | |
LM_INFO(" --- DIALOG CALLID%.*s \n", dialog->id.call_id.len, dialog->id.call_id.s); | |
LM_INFO(" --- DIALOG REMTAG%.*s \n", dialog->id.rem_tag.len, dialog->id.rem_tag.s); | |
- LM_INFO(" --- DIALOG LOCTAG%.*s \n", dialog->id.loc_tag.len, dialog->id.loc_tag.s); | |
+ LM_INFO(" --- DIALOG LOCTAG%.*s \n", dialog->id.loc_tag.len, dialog->id.loc_tag.s); | |
LM_INFO(" --- DIALOG REMURI%.*s \n", dialog->rem_uri.len, dialog->rem_uri.s); | |
LM_INFO(" --- DIALOG LOCURI%.*s \n", dialog->loc_uri.len, dialog->loc_uri.s); | |
LM_INFO(" --- DIALOG CONTACT%.*s \n", dialog->rem_target.len, dialog->rem_target.s); | |
@@ -663,8 +661,8 @@ int send_subscriber_within(struct sip_msg* msg, struct sm_subscriber* subs, int | |
event[subs->event.len] = 0; | |
memcpy(event, subs->event.s, subs->event.len); | |
- LM_INFO(" --- EXPIRES = %d \n", expires); | |
- LM_INFO(" --- EVENT = %.*s \n", subs->event.len, subs->event.s); | |
+ LM_INFO(" --- EXPIRES = %d \n", expires); | |
+ LM_INFO(" --- EVENT = %.*s \n", subs->event.len, subs->event.s); | |
pt_hdr = add_hdr_subscriber(expires, subs->event); | |
@@ -683,7 +681,7 @@ int send_subscriber_within(struct sip_msg* msg, struct sm_subscriber* subs, int | |
LM_INFO(" --- AQUI WITHIN II \n"); | |
if(sending< 0) | |
LM_ERR("while sending request with t_request_within\n"); | |
- | |
+ | |
return 1; | |
} | |
@@ -708,7 +706,7 @@ struct sm_subscriber* get_subs_cell(struct sip_msg *msg) { | |
return NULL; | |
} | |
callid = msg->callid->body; | |
- LM_DBG("CALLID: %.*s \n ", callid.len, callid.s ); | |
+ LM_DBG("CALLID: %.*s \n ", callid.len, callid.s ); | |
if (msg->from->parsed == NULL){ | |
if ( parse_from_header( msg )<0 ){ | |
@@ -719,7 +717,7 @@ struct sm_subscriber* get_subs_cell(struct sip_msg *msg) { | |
//get From header from Notify | |
pfrom = get_from(msg); | |
- LM_DBG("PFROM: %.*s \n ", pfrom->uri.len, pfrom->uri.s ); | |
+ LM_DBG("PFROM: %.*s \n ", pfrom->uri.len, pfrom->uri.s ); | |
if( pfrom->tag_value.s ==NULL || pfrom->tag_value.len == 0){ | |
LM_ERR("reply without tag value \n"); | |
@@ -735,13 +733,13 @@ struct sm_subscriber* get_subs_cell(struct sip_msg *msg) { | |
if (pto == NULL || pto->error != PARSE_OK) { | |
LM_ERR("failed to parse TO header\n"); | |
return NULL; | |
- } | |
+ } | |
if( pto->tag_value.s ==NULL || pto->tag_value.len == 0){ | |
LM_ERR("reply without tag value \n"); | |
//return 0; | |
- } | |
- LM_DBG("PTO: %.*s \n ", pto->uri.len, pto->uri.s ); | |
- LM_DBG("PTO_TAG: %.*s \n ", pto->tag_value.len, pto->tag_value.s ); | |
+ } | |
+ LM_DBG("PTO: %.*s \n ", pto->uri.len, pto->uri.s ); | |
+ LM_DBG("PTO_TAG: %.*s \n ", pto->tag_value.len, pto->tag_value.s ); | |
return find_subscriber_cell(&callid, &pto->tag_value); | |
} | |
@@ -766,13 +764,13 @@ int treat_notify(struct sip_msg *msg) { | |
/* look for cell in list linked subs_pt with same dialog Id*/ | |
cell_subs = get_subs_cell(msg); | |
- LM_INFO("STATUS: %d \n ", cell_subs->status); | |
+ LM_INFO("STATUS: %d \n ", cell_subs->status); | |
LM_INFO("TIMEOUT: %d \n ", cell_subs->timeout); | |
/* get in Subscription_state header: state and expire */ | |
if(get_subscription_state_header(msg, &subs_state, &subs_expires) == 1){ | |
- LM_INFO("STATE: %s\n ", subs_state); | |
- LM_INFO("SUBS_EXPIRES: %s\n ", subs_expires); | |
+ LM_INFO("STATE: %s\n ", subs_state); | |
+ LM_INFO("SUBS_EXPIRES: %s\n ", subs_expires); | |
} | |
@@ -783,35 +781,35 @@ int treat_notify(struct sip_msg *msg) { | |
/* analise state value*/ | |
if (strcmp(subs_state, "active") == 0){ | |
cell_subs->status = ACTIVE; | |
- cell_subs->expires = atoi(subs_expires); | |
- cell_subs->timeout = cell_subs->expires + time_now; | |
- LM_INFO("TIMEOUT: %d \n ", cell_subs->timeout); | |
+ cell_subs->expires = atoi(subs_expires); | |
+ cell_subs->timeout = cell_subs->expires + time_now; | |
+ LM_INFO("TIMEOUT: %d \n ", cell_subs->timeout); | |
}else{ | |
- if (strcmp(subs_state, "pending") == 0){ | |
+ if (strcmp(subs_state, "pending") == 0){ | |
cell_subs->status = PENDING ; | |
- cell_subs->expires = atoi(subs_expires); | |
- cell_subs->timeout = TIMER_B + time_now; | |
+ cell_subs->expires = atoi(subs_expires); | |
+ cell_subs->timeout = TIMER_B + time_now; | |
}else{ | |
- if(strcmp(subs_state, "terminated") == 0){ | |
+ if(strcmp(subs_state, "terminated") == 0){ | |
- /* state is terminated indicate that subcriber dialog finish | |
+ /* state is terminated indicate that subcriber dialog finish | |
then pull cell of the list linked and send esct to VPC*/ | |
- LM_INFO(" --- CLEAR CELL \n"); | |
+ LM_INFO(" --- CLEAR CELL \n"); | |
callid_orig = cell_subs->callid_ori; | |
if(send_esct(callid_orig) == 0){ | |
- LM_ERR("error in send to esct\n"); | |
+ LM_ERR("error in send to esct\n"); | |
} | |
- next = cell_subs->next; | |
- previous = cell_subs->prev; | |
+ next = cell_subs->next; | |
+ previous = cell_subs->prev; | |
if (previous == NULL){ | |
- if (next == NULL){; | |
+ if (next == NULL){; | |
*subs_pt = NULL; | |
- }else{ | |
+ }else{ | |
*subs_pt = next; | |
} | |
- }else{ | |
+ }else{ | |
previous->next = next; | |
} | |
@@ -819,21 +817,21 @@ int treat_notify(struct sip_msg *msg) { | |
if(!eme_tm.t_reply(msg,200,&msg200)){ | |
LM_ERR("t_reply (200)\n"); | |
resp = 0; | |
- goto end; | |
- } | |
+ goto end; | |
+ } | |
resp = 1; | |
goto end; | |
}else{ | |
- LM_ERR("INCOMPATIBLE RECEIVED STATUS\n"); | |
+ LM_ERR("INCOMPATIBLE RECEIVED STATUS\n"); | |
resp = 0; | |
- goto end; | |
- } | |
- } | |
+ goto end; | |
+ } | |
+ } | |
} | |
- LM_DBG("STATUS: %d \n ", cell_subs->status); | |
- LM_DBG(" --- NOTIFY BODY %s", msg->eoh); | |
+ LM_DBG("STATUS: %d \n ", cell_subs->status); | |
+ LM_DBG(" --- NOTIFY BODY %s", msg->eoh); | |
notify_body = parse_notify(msg->eoh); | |
LM_INFO(" --- STATE %s", notify_body->state); | |
@@ -842,33 +840,33 @@ int treat_notify(struct sip_msg *msg) { | |
if(!eme_tm.t_reply(msg,200,&msg200)){ | |
LM_DBG("t_reply (200)\n"); | |
resp = 0; | |
- goto end; | |
- } | |
+ goto end; | |
+ } | |
- /* if Notify body state has terminated value, which indicates that emergency call finish, | |
+ /* if Notify body state has terminated value, which indicates that emergency call finish, | |
then send subscribe with expire=0 to terminate the subscriber dialog*/ | |
if(strcmp(notify_body->state, "terminated") == 0){ | |
expires = 0; | |
- LM_INFO(" --- STATE %s", notify_body->state); | |
+ LM_INFO(" --- STATE %s", notify_body->state); | |
if(send_subscriber_within(msg, cell_subs, expires) == -1){ | |
- LM_ERR(" --- Error in send subscriber terminated \n"); | |
+ LM_ERR(" --- Error in send subscriber terminated \n"); | |
} | |
} | |
resp = 1; | |
end: | |
pkg_free(subs_state); | |
- pkg_free(subs_expires); | |
- return resp; | |
+ pkg_free(subs_expires); | |
+ return resp; | |
} | |
/* check Notify's callid/to_tag with data cell*/ | |
int same_dialog_id(struct sm_subscriber* subscriber_cell, str* callId, str* to_tag) { | |
- if (callId->len == 0||to_tag->len == 0||subscriber_cell->dlg_id.callid.len == 0 ||subscriber_cell->dlg_id.to_tag.len == 0 ) | |
+ if (callId->len == 0||to_tag->len == 0||subscriber_cell->dlg_id.callid.len == 0 ||subscriber_cell->dlg_id.to_tag.len == 0 ) | |
return 0; | |
- | |
+ | |
LM_DBG(" --- Match Callid %.*s ", callId->len, callId->s); | |
LM_DBG(" --- Match subscriber_cell->callid %.*s ", subscriber_cell->dlg_id.callid.len, subscriber_cell->dlg_id.callid.s); | |
if (subscriber_cell->dlg_id.callid.len != callId->len) | |
@@ -876,7 +874,7 @@ int same_dialog_id(struct sm_subscriber* subscriber_cell, str* callId, str* to_t | |
if (strncmp(subscriber_cell->dlg_id.callid.s, callId->s, subscriber_cell->dlg_id.callid.len) == 0){ | |
if (subscriber_cell->dlg_id.from_tag.len != to_tag->len) | |
return 0; | |
- if (strncmp(subscriber_cell->dlg_id.from_tag.s, to_tag->s, subscriber_cell->dlg_id.from_tag.len ) == 0){ | |
+ if (strncmp(subscriber_cell->dlg_id.from_tag.s, to_tag->s, subscriber_cell->dlg_id.from_tag.len ) == 0){ | |
return 1; | |
} | |
} | |
@@ -885,7 +883,7 @@ int same_dialog_id(struct sm_subscriber* subscriber_cell, str* callId, str* to_t | |
-/* Search the cell with callid and to_tag keys in list linked subs_pt, | |
+/* Search the cell with callid and to_tag keys in list linked subs_pt, | |
* if found returns the pointer of this cell | |
*/ | |
struct sm_subscriber* find_subscriber_cell(str* callId, str* to_tag) { | |
@@ -902,8 +900,8 @@ struct sm_subscriber* find_subscriber_cell(str* callId, str* to_tag) { | |
return current; | |
} | |
previous = current; | |
- current = current->next; | |
+ current = current->next; | |
} | |
LM_DBG("Did not find\n"); | |
return NULL; | |
-} | |
\ No newline at end of file | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment