[asterisk-commits] channels/chan sip.c: use binding IP address for outgoing TCP... (asterisk[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed May 3 11:05:36 CDT 2017


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/5529 )

Change subject: channels/chan_sip.c: use binding IP address for outgoing TCP SIP connections
......................................................................


channels/chan_sip.c: use binding IP address for outgoing TCP SIP connections

For outgoing TCP connections, Asterisk uses the first IP address of the
interface instead of the IP address we asked him to bind to.

ASTERISK-26922 #close
Reported-by: Ksenia

Change-Id: I43c71ca89211dbf1838e5bcdb9be8d06d98e54eb
---
M channels/chan_sip.c
1 file changed, 11 insertions(+), 0 deletions(-)

Approvals:
  George Joseph: Looks good to me, but someone else must approve
  Matthew Fredrickson: Looks good to me, approved
  Joshua Colp: Looks good to me, but someone else must approve; Approved for Submit



diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index affe937..d60927d 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -29275,6 +29275,17 @@
 		}
 	}
 
+	/* If a bind address has been specified, use it */
+	if ((s->type == AST_TRANSPORT_TLS) && !ast_sockaddr_isnull(&sip_tls_desc.local_address)) {
+		ca->local_address = sip_tls_desc.local_address;
+	}
+	else if ((s->type == AST_TRANSPORT_TCP) && !ast_sockaddr_isnull(&sip_tcp_desc.local_address)) {
+		ca->local_address = sip_tcp_desc.local_address;
+	}
+	/* Reset tcp source port to zero to let system pick a random one */
+	if (!ast_sockaddr_isnull(&ca->local_address)) {
+		ast_sockaddr_set_port(&ca->local_address, 0);
+	}
 	/* Create a client connection for address, this does not start the connection, just sets it up. */
 	if (!(s->tcptls_session = ast_tcptls_client_create(ca))) {
 		goto create_tcptls_session_fail;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I43c71ca89211dbf1838e5bcdb9be8d06d98e54eb
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Thierry Magnien <thierry.magnien at gmail.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matthew Fredrickson <creslin at digium.com>



More information about the asterisk-commits mailing list