summaryrefslogtreecommitdiff
path: root/channels/chan_sip.c
diff options
context:
space:
mode:
authorThierry Magnien <thierry.magnien@gmail.com>2017-04-26 14:58:44 +0200
committerThierry Magnien <thierry.magnien@gmail.com>2017-05-02 05:58:33 -0500
commit5cee143d9cd36b51c09d0abff4c3ade5d6183241 (patch)
tree43554138856bfea6828f92e3c8aa998cab4912c9 /channels/chan_sip.c
parentd9549bc4750ab00f57b78beba79b5b79911d579a (diff)
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
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r--channels/chan_sip.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index c8e2fa756..2e386dd55 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -29275,6 +29275,17 @@ static int sip_prepare_socket(struct sip_pvt *p)
}
}
+ /* 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;