Browse Source

modules/nathelper: check also transport protocol when determining
if ;alias parameter needs to be added by add_contact_alias() call

(cherry picked from commit 93c81f5326acc2aefaca01c347f79c972727d0bf)

Juha Heinanen 7 năm trước cách đây
mục cha
commit
a7049edf43

+ 2 - 2
src/modules/nathelper/doc/nathelper_admin.xml

@@ -707,8 +707,8 @@ if(is_rfc1918("$rd")) {
 		the contact URI containing either received ip, port, and
 		the contact URI containing either received ip, port, and
 		transport protocol or those given as parameters.  If called
 		transport protocol or those given as parameters.  If called
 		without parameters, <quote>;alias</quote> parameter is
 		without parameters, <quote>;alias</quote> parameter is
-		only added if received ip and port differ from those in
-		contact URI.
+		only added if received ip, port, or transport protocol differs
+        from that in contact URI.
 		</para>
 		</para>
 		<para>
 		<para>
 		This function can be used from
 		This function can be used from

+ 7 - 7
src/modules/nathelper/nathelper.c

@@ -780,13 +780,13 @@ static int add_contact_alias_0(struct sip_msg *msg)
 			&& ((ip = str2ip6(&(uri.host))) == NULL)) {
 			&& ((ip = str2ip6(&(uri.host))) == NULL)) {
 		LM_DBG("contact uri host is not an ip address\n");
 		LM_DBG("contact uri host is not an ip address\n");
 	} else {
 	} else {
-		if(ip_addr_cmp(ip, &(msg->rcv.src_ip))
-				&& ((msg->rcv.src_port == uri.port_no)
-						   || ((uri.port.len == 0)
-									  && (msg->rcv.src_port == 5060)))) {
-			LM_DBG("no need to add alias param\n");
-			return 2;
-		}
+		if (ip_addr_cmp(ip, &(msg->rcv.src_ip)) &&
+                    ((msg->rcv.src_port == uri.port_no) ||
+                     ((uri.port.len == 0) && (msg->rcv.src_port == 5060))) &&
+                    (uri.proto == msg->rcv.proto)) {
+                        LM_DBG("no need to add alias param\n");
+                        return 2;
+                }
 	}
 	}
 
 
 	/* Check if function has been called already */
 	/* Check if function has been called already */