Explorar o código

Merge pull request #1319 from surendratiwari3/nat_traversal_ipv6_contact

nat_traversal: fixing ipv6 contact for fix_contact function in cfg.
Daniel-Constantin Mierla %!s(int64=7) %!d(string=hai) anos
pai
achega
6fc84ad9ef
Modificáronse 1 ficheiros con 10 adicións e 2 borrados
  1. 10 2
      src/modules/nat_traversal/nat_traversal.c

+ 10 - 2
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);