[sr-dev] git:3.1: topoh: add angle brackets around contact uri

Daniel-Constantin Mierla miconda at gmail.com
Tue Feb 8 12:52:42 CET 2011


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Fri Feb  4 19:27:10 2011 +0100

topoh: add angle brackets around contact uri

- if there are no angle brackets around initial contact uri, add for
  encoded uri to keep URI parameters properly
(cherry picked from commit 66f80a68a48835b1634da04ead4deadeb89ce7f7)

---

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

diff --git a/modules/topoh/th_msg.c b/modules/topoh/th_msg.c
index a721141..df29ea1 100644
--- a/modules/topoh/th_msg.c
+++ b/modules/topoh/th_msg.c
@@ -247,6 +247,7 @@ int th_mask_contact(sip_msg_t *msg)
 	struct lump* l;
 	str out;
 	str in;
+	char *p;
 	contact_t *c;
 
 	if(msg->contact==NULL) 
@@ -270,6 +271,24 @@ int th_mask_contact(sip_msg_t *msg)
 		LM_ERR("cannot encode contact uri\n");
 		return -1;
 	}
+	if(*(in.s-1)!='<')
+	{
+		/* add < > around contact uri if not there */
+		p = (char*)pkg_malloc(out.len+3);
+		if(p==NULL)
+		{
+			LM_ERR("failed to get more pkg\n");
+			pkg_free(out.s);
+			return -1;
+		}
+		*p = '<';
+		strncpy(p+1, out.s, out.len);
+		p[out.len+1] = '>';
+		p[out.len+2] = '\0';
+		pkg_free(out.s);
+		out.s = p;
+		out.len += 2;
+	}
 				
 	l=del_lump(msg, in.s-msg->buf, in.len, 0);
 	if (l==0)




More information about the sr-dev mailing list