Skip to content

Commit

Permalink
nathelper: use always contact to build ruri and received field if ava…
Browse files Browse the repository at this point in the history
…ilable to send the ping

Fixes #37
  • Loading branch information
linuxmaniac committed Feb 20, 2015
1 parent af59452 commit 486c069
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions modules/nathelper/nathelper.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand All @@ -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 */
Expand All @@ -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;
}
}
Expand Down

0 comments on commit 486c069

Please sign in to comment.