[Asterisk-code-review] res pjsip multihomed: Change Contact port to listening port. (asterisk[master])

Anonymous Coward asteriskteam at digium.com
Tue Sep 20 12:45:16 CDT 2016


Anonymous Coward #1000019 has submitted this change and it was merged.

Change subject: res_pjsip_multihomed: Change Contact port to listening port.
......................................................................


res_pjsip_multihomed: Change Contact port to listening port.

The res_pjsip_multihomed module determines what interface and transport
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 the bound address for the listening socket which can actually
accept the connection back. If the remote side attempts to connect back on
the epehemeral port it will fail.

This change makes it so the port is updated to the bound port on
connectionful protocols and is maintained on UDP (as there can be
multiple of those).

ASTERISK-26374 #close

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

Approvals:
  George Joseph: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved



diff --git a/res/res_pjsip_multihomed.c b/res/res_pjsip_multihomed.c
index f5deb77..5deeb92 100644
--- a/res/res_pjsip_multihomed.c
+++ b/res/res_pjsip_multihomed.c
@@ -109,8 +109,11 @@
 		return PJ_SUCCESS;
 	}
 
-	/* The port in the message should always be that of the original transport */
-	prm.ret_port = tdata->tp_info.transport->local_name.port;
+	/* For UDP we can have multiple transports so the port needs to be maintained */
+	if (tdata->tp_info.transport->key.type == PJSIP_TRANSPORT_UDP ||
+		tdata->tp_info.transport->key.type == PJSIP_TRANSPORT_UDP6) {
+		prm.ret_port = tdata->tp_info.transport->local_name.port;
+	}
 
 	/* If the IP source differs from the existing transport see if we need to update it */
 	if (pj_strcmp(&prm.ret_addr, &tdata->tp_info.transport->local_name.host)) {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I50f8dab65b9f75117d73ba5f6bbcf6c9871854ab
Gerrit-PatchSet: 3
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>



More information about the asterisk-code-review mailing list