[sr-dev] git:master: nathelper(k): remove maddr param in fix_nated_contact()

Daniel-Constantin Mierla miconda at gmail.com
Fri Jun 1 11:35:45 CEST 2012


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Fri Jun  1 11:34:20 2012 +0200

nathelper(k): remove maddr param in fix_nated_contact()

- if maddr exists, it makes no sense anymore if the contact uri is
  changed by the proxy
- reported by Morten Isaksen

---

 modules_k/nathelper/nathelper.c |   23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/modules_k/nathelper/nathelper.c b/modules_k/nathelper/nathelper.c
index 6c84962..bec490c 100644
--- a/modules_k/nathelper/nathelper.c
+++ b/modules_k/nathelper/nathelper.c
@@ -728,6 +728,8 @@ fix_nated_contact_f(struct sip_msg* msg, char* str1, char* str2)
 	struct lump *anchor;
 	struct sip_uri uri;
 	str hostport;
+	str params1 = {0};
+	str params2 = {0};
 
 	if (get_contact_uri(msg, &uri, &c) == -1)
 		return -1;
@@ -756,8 +758,25 @@ fix_nated_contact_f(struct sip_msg* msg, char* str1, char* str2)
 	temp[0] = hostport.s[0];
 	temp[1] = c->uri.s[c->uri.len];
 	c->uri.s[c->uri.len] = hostport.s[0] = '\0';
-	len1 = snprintf(buf, len, "%s%s:%d%s", c->uri.s, cp, msg->rcv.src_port,
-	    hostport.s + hostport.len);
+	if(uri.maddr.len<=0) {
+		len1 = snprintf(buf, len, "%s%s:%d%s", c->uri.s, cp, msg->rcv.src_port,
+		    hostport.s + hostport.len);
+	} else {
+		/* skip maddr parameter - makes no sense anymore */
+		LM_DBG("removing maddr parameter from contact uri: [%.*s]\n",
+				uri.maddr.len, uri.maddr.s);
+		params1.s = hostport.s + hostport.len;
+		params1.len = uri.maddr.s - params1.s;
+		while(params1.len>0
+				&& (params1.s[params1.len-1]==' '
+					|| params1.s[params1.len-1]=='\t'
+					|| params1.s[params1.len-1]==';'))
+			params1.len--;
+		params2.s = uri.maddr.s + uri.maddr.len;
+		params2.len = c->uri.s + c->uri.len - params2.s;
+		len1 = snprintf(buf, len, "%s%s:%d%.*s%.*s", c->uri.s, cp, msg->rcv.src_port,
+		    params1.len, params1.s, params2.len, params2.s);
+	}
 	if (len1 < len)
 		len = len1;
 	hostport.s[0] = temp[0];




More information about the sr-dev mailing list