nat_traversal: correcting the ipv6 contact in fix_contact 1319/head
authorSurendra Tiwari <surendratiwari3@gmail.com>
Fri, 17 Nov 2017 11:39:55 +0000 (11:39 +0000)
committerSurendra Tiwari <surendratiwari3@gmail.com>
Fri, 17 Nov 2017 11:39:55 +0000 (11:39 +0000)
- fix_contact for ipv6 addres,add the [] to the host part of contact header

src/modules/nat_traversal/nat_traversal.c

index d3c6c95..ae38d76 100644 (file)
@@ -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);