[sr-dev] git:master:486c0692: nathelper: use always contact to build ruri and received field if available to send the ping

Victor Seva linuxmaniac at torreviejawireless.org
Fri Feb 20 08:20:47 CET 2015


Module: kamailio
Branch: master
Commit: 486c069222462e4bc05da36b098062be941d672d
URL: https://github.com/kamailio/kamailio/commit/486c069222462e4bc05da36b098062be941d672d

Author: Victor Seva <linuxmaniac at torreviejawireless.org>
Committer: Victor Seva <linuxmaniac at torreviejawireless.org>
Date: 2015-02-20T08:19:17+01:00

nathelper: use always contact to build ruri and received field if available to send the ping

Fixes #37

---

Modified: modules/nathelper/nathelper.c

---

Diff:  https://github.com/kamailio/kamailio/commit/486c069222462e4bc05da36b098062be941d672d.diff
Patch: https://github.com/kamailio/kamailio/commit/486c069222462e4bc05da36b098062be941d672d.patch

---

diff --git a/modules/nathelper/nathelper.c b/modules/nathelper/nathelper.c
index 0c9e4fb..81d2cac 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;
 			}
 		}




More information about the sr-dev mailing list