Hello,
please find attached a patch for the nathelper module from the modules_s directory. It aims to fix the issue that if you call fix_nated_contact() on IPv6 addresses the fixed URI does not contain the required [] around the IPv6 IP address of the URI.
Andrei: are the helper functions in ip_addr.h do not add the [] on purpose? I fixed this in the module directly because I assumed it could break other things if I would fix it directly in ip_addr.h.
Who ever feels himself responsible for the nathelper module could please review the patch and let me know if I should commit the patch.
Thanks Nils
Index: nathelper.c =================================================================== RCS file: /cvsroot/ser/sip_router/modules/nathelper/nathelper.c,v retrieving revision 1.135 diff -a -u -r1.135 nathelper.c --- nathelper.c 8 Dec 2008 11:26:49 -0000 1.135 +++ nathelper.c 20 May 2009 02:33:37 -0000 @@ -628,6 +628,9 @@
cp = ip_addr2a(&msg->rcv.src_ip); len = c->uri.len + strlen(cp) + 6 /* :port */ - hostport.len + 1; + if (msg->rcv.src_ip.af == AF_INET6) { + len += 2; /* [...] */ + } buf = pkg_malloc(len); if (buf == NULL) { LOG(L_ERR, "ERROR: fix_nated_contact: out of memory\n"); @@ -636,8 +639,14 @@ 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 (msg->rcv.src_ip.af == AF_INET6) { + len1 = snprintf(buf, len, "%s[%s]:%d%s", c->uri.s, cp, msg->rcv.src_port, + hostport.s + hostport.len); + } + else { + len1 = snprintf(buf, len, "%s%s:%d%s", c->uri.s, cp, msg->rcv.src_port, + hostport.s + hostport.len); + } if (len1 < len) len = len1; hostport.s[0] = temp[0];