소스 검색

topos: formatting and debug cleanup after last commit with callid masking

(cherry picked from commit f4dc688548aa7753af93ce6e9089b53e9fc4c7ec)
Daniel-Constantin Mierla 2 년 전
부모
커밋
7e53506f27
2개의 변경된 파일29개의 추가작업 그리고 43개의 파일을 삭제
  1. 18 24
      src/modules/topos/topos_mod.c
  2. 11 19
      src/modules/topos/tps_msg.c

+ 18 - 24
src/modules/topos/topos_mod.c

@@ -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;
@@ -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");

+ 11 - 19
src/modules/topos/tps_msg.c

@@ -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");
@@ -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;
@@ -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);
@@ -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:
@@ -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;