Robin Vleij writes:
> The core dump showed some stuff which I then connected to the
> following theads on the opensips list:
>
> http://lists.opensips.org/pipermail/devel/2008-December/001566.html
> Question is, was this fixed in Kamailio 1.4.4 as well? I can't find
> anything about it and since the projects are not the same anymore I'm
> not sure that we take each others fixes.
robin,
looks like this is the fix:
http://opensips.svn.sourceforge.net/viewvc/opensips/trunk/modules/tm/t_hook…
and it has not been applied to kamailio. perhaps daniel can check it.
i'll cc to sip-router folks so that they can make sure that the crash
does not occur there.
-- juha
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];
Module: sip-router
Branch: master
Commit: 8f2817965f28c05947484023c324866288d7abb1
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=8f28179…
Author: Henning Westerholt <henning.westerholt(a)1und1.de>
Committer: Henning Westerholt <henning.westerholt(a)1und1.de>
Date: Tue May 19 18:20:59 2009 +0200
core: PV printing, revert 103ffecf7, add the proper fix from kamailio
revert not needed commit 103ffecf7, add the proper fix from kamailio for this
problem. Now its possible to print and use more then one pseudo-variable at a time.
The old implementation used only one static buffer, so in subsequent calls to the
function the previous printed variable was overwritten.
---
sr_module.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/sr_module.c b/sr_module.c
index 1ab8868..8dfcfad 100644
--- a/sr_module.c
+++ b/sr_module.c
@@ -1349,6 +1349,9 @@ int fixup_str_2(void** param, int param_no)
}
+
+#define PV_PRINT_BUF_SIZE 1024
+#define PV_PRINT_BUF_NO 3
/** Get the function parameter value as string.
* @return 0 - Success
* -1 - Cannot get value
@@ -1359,8 +1362,8 @@ int get_str_fparam(str* dst, struct sip_msg* msg, fparam_t* param)
int ret;
avp_t* avp;
pv_value_t pv_val;
- static char pve_buf[256]; /* ugly hack needed for PVE */
- memset(pve_buf, 0, sizeof(pve_buf));
+ static int buf_itr = 0; /* ugly hack needed for PVE */
+ static char pve_buf[PV_PRINT_BUF_NO][PV_PRINT_BUF_SIZE];
switch(param->type) {
case FPARAM_REGEX:
@@ -1405,13 +1408,14 @@ int get_str_fparam(str* dst, struct sip_msg* msg, fparam_t* param)
}
break;
case FPARAM_PVE:
- dst->len=sizeof(pve_buf);
- if (unlikely(pv_printf(msg, param->v.pve, pve_buf, &dst->len)!=0)){
+ dst->s=pve_buf[buf_itr];
+ dst->len=PV_PRINT_BUF_SIZE;
+ buf_itr = (buf_itr+1)%PV_PRINT_BUF_NO;
+ if (unlikely(pv_printf(msg, param->v.pve, dst->s, &dst->len)!=0)){
ERR("Could not convert the PV-formated string to str\n");
dst->len=0;
return -1;
};
- dst->s=pve_buf;
break;
}
return 0;