[sr-dev] git:master:4838bca7: nat_traversal: correcting the ipv6 contact in fix_contact

Surendra Tiwari surendratiwari3 at gmail.com
Fri Nov 17 13:08:00 CET 2017


Module: kamailio
Branch: master
Commit: 4838bca79d5eb82d133b295d6e601c1924d7ac11
URL: https://github.com/kamailio/kamailio/commit/4838bca79d5eb82d133b295d6e601c1924d7ac11

Author: Surendra Tiwari <surendratiwari3 at gmail.com>
Committer: Surendra Tiwari <surendratiwari3 at gmail.com>
Date: 2017-11-17T11:39:55Z

nat_traversal: correcting the ipv6 contact in fix_contact

- fix_contact for ipv6 addres,add the [] to the host part of contact header

---

Modified: src/modules/nat_traversal/nat_traversal.c

---

Diff:  https://github.com/kamailio/kamailio/commit/4838bca79d5eb82d133b295d6e601c1924d7ac11.diff
Patch: https://github.com/kamailio/kamailio/commit/4838bca79d5eb82d133b295d6e601c1924d7ac11.patch

---

diff --git a/src/modules/nat_traversal/nat_traversal.c b/src/modules/nat_traversal/nat_traversal.c
index d3c6c95057..ae38d7653b 100644
--- a/src/modules/nat_traversal/nat_traversal.c
+++ b/src/modules/nat_traversal/nat_traversal.c
@@ -1478,8 +1478,16 @@ FixContact(struct sip_msg *msg)
         return -1;
     }
 
-    len = sprintf(buf, "%.*s%s:%d%.*s", before_host.len, before_host.s,
-                  newip.s, newport, after.len, after.s);
+    if (msg->rcv.src_ip.af==AF_INET6)
+    {
+    	len = sprintf(buf, "%.*s[%s]:%d%.*s", before_host.len, before_host.s,
+                  	newip.s, newport, after.len, after.s);
+    }
+    else
+    {
+	 len = sprintf(buf, "%.*s%s:%d%.*s", before_host.len, before_host.s,
+                        newip.s, newport, after.len, after.s);
+    } 
 
     if (insert_new_lump_after(anchor, buf, len, (enum _hdr_types_t)HDR_CONTACT_F) == 0) {
         pkg_free(buf);




More information about the sr-dev mailing list