[Asterisk-code-review] res pjsip multihomed: Don't change Contact port on connectio... (asterisk[14])

Joshua Colp asteriskteam at digium.com
Wed Sep 14 09:05:56 CDT 2016


Joshua Colp has uploaded a new change for review.

  https://gerrit.asterisk.org/3900

Change subject: res_pjsip_multihomed: Don't change Contact port on connectionful.
......................................................................

res_pjsip_multihomed: Don't change Contact port on connectionful.

The res_pjsip_multihomed module determines what interface a request is
going out on and updates the SIP message accordingly with the address
information. This currently incorrectly updates the Contact header for
connectionful protocols to the ephemeral connection port, instead of
keeping it as the port which will actually accept the connection back.
If the remote side attempts to connect back on the ephemeral port it
will fail.

This change makes it so the port is only updated if the connection is
UDP based.

ASTERISK-26374 #close

Change-Id: I50f8dab65b9f75117d73ba5f6bbcf6c9871854ab
---
M res/res_pjsip_multihomed.c
1 file changed, 8 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/00/3900/1

diff --git a/res/res_pjsip_multihomed.c b/res/res_pjsip_multihomed.c
index f5deb77..b9c6229 100644
--- a/res/res_pjsip_multihomed.c
+++ b/res/res_pjsip_multihomed.c
@@ -146,9 +146,14 @@
 
 			/* prm.ret_addr is allocated from the tdata pool OR the transport so it is perfectly fine to just do an assignment like this */
 			pj_strassign(&uri->host, &prm.ret_addr);
-			uri->port = prm.ret_port;
-			ast_debug(4, "Re-wrote Contact URI host/port to %.*s:%d\n",
-				(int)pj_strlen(&uri->host), pj_strbuf(&uri->host), uri->port);
+			ast_debug(4, "Re-wrote Contact URI host to %.*s\n",
+				(int)pj_strlen(&uri->host), pj_strbuf(&uri->host));
+
+			if (tdata->tp_info.transport->key.type == PJSIP_TRANSPORT_UDP ||
+				tdata->tp_info.transport->key.type == PJSIP_TRANSPORT_UDP6) {
+				uri->port = prm.ret_port;
+				ast_debug(4, "Re-wrote Contact URI port to %d\n", uri->port);
+			}
 
 			pjsip_tx_data_invalidate_msg(tdata);
 		}

-- 
To view, visit https://gerrit.asterisk.org/3900
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I50f8dab65b9f75117d73ba5f6bbcf6c9871854ab
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-Owner: Joshua Colp <jcolp at digium.com>



More information about the asterisk-code-review mailing list