[sr-dev] git:master: topoh: don't encode/decode content for local generated messages

Daniel-Constantin Mierla miconda at gmail.com
Fri Feb 21 18:10:10 CET 2014


Module: sip-router
Branch: master
Commit: 41f12e01b20a6b32d26297fbdf6ce17d40823ef2
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=41f12e01b20a6b32d26297fbdf6ce17d40823ef2

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Fri Feb 21 17:58:19 2014 +0100

topoh: don't encode/decode content for local generated messages

- requests generated by kamailio don't have headers that should be
  hidden
- replies to them don't have anything hidden
- update as part of report from FS#390

---

 modules/topoh/topoh_mod.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/modules/topoh/topoh_mod.c b/modules/topoh/topoh_mod.c
index 28a53bb..698f853 100644
--- a/modules/topoh/topoh_mod.c
+++ b/modules/topoh/topoh_mod.c
@@ -222,6 +222,13 @@ int th_prepare_msg(sip_msg_t *msg)
 		return 2;
 	}
 
+	/* force 2nd via parsing here - it helps checking it later */
+	if (parse_headers(msg, HDR_VIA2_F, 0)==-1
+		|| (msg->via2==0) || (msg->via2->error!=PARSE_OK))
+	{
+		LM_DBG("no second via in this message \n");
+	}
+
 	if(parse_from_header(msg)<0)
 	{
 		LM_ERR("cannot parse FROM header\n");
@@ -308,6 +315,13 @@ int th_msg_received(void *data)
 		}
 	} else {
 		/* reply */
+		if(msg.via2==0)
+		{
+			/* one Via in received reply -- it is for local generated request
+			 * - nothing to unhide */
+			goto done;
+		}
+
 		th_unmask_via(&msg, &th_cookie_value);
 		th_flip_record_route(&msg, 0);
 		if(th_cookie_value.s[0]=='u')
@@ -371,6 +385,12 @@ int th_msg_sent(void *data)
 		th_del_cookie(&msg);
 	if(msg.first_line.type==SIP_REQUEST)
 	{
+		if(msg.via2==0)
+		{
+			/* one Via in request sent out -- it is local generated
+			 * - nothing to hide */
+			goto done;
+		}
 		direction = (th_cookie_value.s[0]=='u')?1:0; /* upstream/downstram */
 		dialog = (get_to(&msg)->tag_value.len>0)?1:0;
 		local = (th_cookie_value.s[0]!='d'&&th_cookie_value.s[0]!='u')?1:0;




More information about the sr-dev mailing list