Skip to content

Commit

Permalink
topos: formatting and debug cleanup after last commit with callid mas…
Browse files Browse the repository at this point in the history
…king

(cherry picked from commit f4dc688)
  • Loading branch information
miconda committed May 16, 2023
1 parent 7e1f330 commit 7e53506
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 43 deletions.
42 changes: 18 additions & 24 deletions src/modules/topos/topos_mod.c
Expand Up @@ -760,33 +760,30 @@ int tps_mask_callid(sip_msg_t *msg)
str out;
str in;

if(_tps_param_mask_callid==0)
if(_tps_param_mask_callid==0) {
return 0;
}

if(msg->callid==NULL)
{
if(msg->callid==NULL) {
LM_ERR("cannot get Call-Id header\n");
return -1;
}
LM_DBG("CALL-ID : [%.*s]\n", msg->callid->body.len, msg->callid->body.s);
LM_DBG("incoming call-id: [%.*s]\n", msg->callid->body.len, msg->callid->body.s);
in=msg->callid->body;

if(thb.mask_callid(&in, &out) != 0) {
LM_ERR("cannot encode callid\n");
return -1;
LM_ERR("cannot encode callid\n");
return -1;
}


LM_DBG("Updated CALL-ID : [%.*s]\n",out.len, out.s);
if(out.s==NULL)
{

LM_DBG("updated (masked) call-id: [%.*s]\n",out.len, out.s);
if(out.s==NULL) {
LM_ERR("cannot encode callid\n");
return -1;
}

l=del_lump(msg, msg->callid->body.s-msg->buf, msg->callid->body.len, 0);
if (l==0)
{
if (l==0) {
LM_ERR("failed deleting callid\n");
pkg_free(out.s);
return -1;
Expand All @@ -809,30 +806,27 @@ int tps_unmask_callid(sip_msg_t *msg)
str out;
str in;
int umask_ret;


if(_tps_param_mask_callid==0)
if(_tps_param_mask_callid==0) {
return 0;
}

if(msg->callid==NULL)
{
if(msg->callid==NULL) {
LM_ERR("cannot get Call-Id header\n");
return -1;
}



LM_DBG("CALL-ID : [%.*s]\n", msg->callid->body.len, msg->callid->body.s);
LM_DBG("incoming call-id: [%.*s]\n", msg->callid->body.len, msg->callid->body.s);
in=msg->callid->body;
umask_ret=thb.unmask_callid(&in, &out);
if(umask_ret == 1) {
LM_DBG("Unmask not required\n");
return 0;
}else if(umask_ret != 0) {
LM_ERR("cannot decode callid\n");
return -1;
LM_ERR("cannot decode callid\n");
return -1;
}
LM_DBG("Updated (unmasked) CALL-ID : [%.*s]\n",out.len, out.s);
LM_DBG("updated (unmasked) call-id: [%.*s]\n", out.len, out.s);
if(out.s==NULL)
{
LM_ERR("cannot decode callid\n");
Expand Down
30 changes: 11 additions & 19 deletions src/modules/topos/tps_msg.c
Expand Up @@ -880,14 +880,13 @@ int tps_request_received(sip_msg_t *msg, int dialog)
memset(&mtsd, 0, sizeof(tps_data_t));
memset(&stsd, 0, sizeof(tps_data_t));

tps_unmask_callid(msg);

if(tps_pack_message(msg, &mtsd)<0) {
LM_ERR("failed to extract and pack the headers\n");
return -1;
}

tps_unmask_callid(msg);
LM_DBG("Request message after CALLID Unmask-> [%.*s] \n",msg->len,msg->buf);


ret = tps_dlg_message_update(msg, &mtsd, _tps_contact_mode);
if(ret<0) {
LM_ERR("failed to update on dlg message\n");
Expand Down Expand Up @@ -1022,16 +1021,15 @@ int tps_response_received(sip_msg_t *msg)
memset(&mtsd, 0, sizeof(tps_data_t));
memset(&stsd, 0, sizeof(tps_data_t));
memset(&btsd, 0, sizeof(tps_data_t));


tps_unmask_callid(msg);

if(tps_pack_message(msg, &mtsd)<0) {
LM_ERR("failed to extract and pack the headers\n");
return -1;
}
tps_unmask_callid(msg);
LM_DBG("Response message after CALLID Unmask-> [%.*s] \n",msg->len,msg->buf);

lkey = msg->callid->body;

tps_storage_lock_get(&lkey);
if(tps_storage_load_branch(msg, &mtsd, &btsd, 0)<0) {
goto error;
Expand Down Expand Up @@ -1097,8 +1095,8 @@ int tps_request_sent(sip_msg_t *msg, int dialog, int local)

if(dialog!=0) {
if(tps_get_xuuid(msg, &xuuid)<0) {
LM_DBG("no x-uuid header -Local message only Call-ID Mask if downstream \n");
/* ACK and CANCEL go downstream so Call-ID mask required*/
LM_DBG("no x-uuid header - local message only - Call-ID mask if downstream \n");
/* ACK and CANCEL go downstream so Call-ID mask required */
if(get_cseq(msg)->method_id==METHOD_ACK
|| get_cseq(msg)->method_id==METHOD_CANCEL) {
tps_mask_callid(msg);
Expand Down Expand Up @@ -1170,13 +1168,10 @@ int tps_request_sent(sip_msg_t *msg, int dialog, int local)

done:
tps_storage_lock_release(&lkey);
/*DownStream Request sent MASK CALLID */
if(direction == TPS_DIR_DOWNSTREAM) {
/* mask CallID */
tps_mask_callid(msg);
LM_DBG("SENT message after CALLID CHG->[%.*s] \n",msg->len,msg->buf);
}

return 0;

error:
Expand Down Expand Up @@ -1273,12 +1268,9 @@ int tps_response_sent(sip_msg_t *msg)
if(tps_storage_update_dialog(msg, &mtsd, &stsd, TPS_DBU_CONTACT)<0) {
goto error1;
}

/*DownStream Response sent MASK CALLID */

if(direction == TPS_DIR_UPSTREAM) {
/* mask CallID */
tps_mask_callid(msg);
LM_DBG("SENT Response message after CALLID CHG->[%.*s] \n",msg->len,msg->buf);
}
return 0;

Expand Down

0 comments on commit 7e53506

Please sign in to comment.