From 486c069222462e4bc05da36b098062be941d672d Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Tue, 17 Feb 2015 15:40:41 +0100 Subject: [PATCH] nathelper: use always contact to build ruri and received field if available to send the ping Fixes #37 --- modules/nathelper/nathelper.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/nathelper/nathelper.c b/modules/nathelper/nathelper.c index 0c9e4fb855d..81d2cacae8b 100644 --- a/modules/nathelper/nathelper.c +++ b/modules/nathelper/nathelper.c @@ -2051,6 +2051,8 @@ nh_timer(unsigned int ticks, void *timer_idx) int rval; void *buf, *cp; str c; + str recv; + str *dst_uri; str opt; str path; str ruid; @@ -2111,6 +2113,9 @@ nh_timer(unsigned int ticks, void *timer_idx) break; c.s = (char*)cp + sizeof(c.len); cp = (char*)cp + sizeof(c.len) + c.len; + memcpy(&(recv.len), cp, sizeof(recv.len)); + recv.s = (char*)cp + sizeof(recv.len); + cp = (char*)cp + sizeof(recv.len) + recv.len; memcpy( &send_sock, cp, sizeof(send_sock)); cp = (char*)cp + sizeof(send_sock); memcpy( &flags, cp, sizeof(flags)); @@ -2127,6 +2132,9 @@ nh_timer(unsigned int ticks, void *timer_idx) if ((flags & natping_disable_flag)) /* always 0 if natping_disable_flag not set */ continue; + if(recv.len>0) dst_uri = &recv; + else dst_uri = &c; + /* determin the destination */ if ( path.len && (flags&sipping_flag)!=0 ) { /* send to first URI in path */ @@ -2149,14 +2157,14 @@ nh_timer(unsigned int ticks, void *timer_idx) LM_ERR("could not parse path host for udpping_from_path\n"); continue; } - if (parse_uri(c.s, c.len, &curi) < 0) { - LM_ERR("can't parse contact uri\n"); + if (parse_uri(dst_uri->s, dst_uri->len, &curi) < 0) { + LM_ERR("can't parse contact/received uri\n"); continue; } } else { /* send to the contact/received */ - if (parse_uri(c.s, c.len, &curi) < 0) { - LM_ERR("can't parse contact uri\n"); + if (parse_uri(dst_uri->s, dst_uri->len, &curi) < 0) { + LM_ERR("can't parse contact/received uri\n"); continue; } }