[Asterisk-code-review] chan_sip: TCP/TLS client without server. (asterisk[13])

Friendly Automation asteriskteam at digium.com
Mon Apr 13 16:32:27 CDT 2020


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/14107 )

Change subject: chan_sip: TCP/TLS client without server.
......................................................................

chan_sip: TCP/TLS client without server.

It is possible to configure a TCP/TLS client without having a TCP/TLS
server. In that case, no error or warning was printed but the headers
Contact and Via in SIP REGISTER were "(null)".

ASTERISK-28798

Change-Id: I387ca5cb6a65f1eb675a29c5e41df8ec6c242ab2
---
M channels/chan_sip.c
1 file changed, 29 insertions(+), 18 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, approved
  George Joseph: Looks good to me, but someone else must approve
  Friendly Automation: Approved for Submit



diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index d25b139..6808ec9 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -3884,23 +3884,27 @@
 		/* no remapping, but we bind to a specific address, so use it. */
 		switch (p->socket.type) {
 		case AST_TRANSPORT_TCP:
-			if (!ast_sockaddr_is_any(&sip_tcp_desc.local_address)) {
-				ast_sockaddr_copy(us,
-						  &sip_tcp_desc.local_address);
-			} else {
-				ast_sockaddr_set_port(us,
-						      ast_sockaddr_port(&sip_tcp_desc.local_address));
-			}
-			break;
+			if (!ast_sockaddr_isnull(&sip_tcp_desc.local_address)) {
+				if (!ast_sockaddr_is_any(&sip_tcp_desc.local_address)) {
+					ast_sockaddr_copy(us,
+							  &sip_tcp_desc.local_address);
+				} else {
+					ast_sockaddr_set_port(us,
+					  ast_sockaddr_port(&sip_tcp_desc.local_address));
+				}
+				break;
+			} /* fall through on purpose */
 		case AST_TRANSPORT_TLS:
-			if (!ast_sockaddr_is_any(&sip_tls_desc.local_address)) {
-				ast_sockaddr_copy(us,
-						  &sip_tls_desc.local_address);
-			} else {
-				ast_sockaddr_set_port(us,
-						      ast_sockaddr_port(&sip_tls_desc.local_address));
-			}
-			break;
+			if (!ast_sockaddr_isnull(&sip_tls_desc.local_address)) {
+				if (!ast_sockaddr_is_any(&sip_tls_desc.local_address)) {
+					ast_sockaddr_copy(us,
+							  &sip_tls_desc.local_address);
+				} else {
+					ast_sockaddr_set_port(us,
+					  ast_sockaddr_port(&sip_tls_desc.local_address));
+				}
+				break;
+			} /* fall through on purpose */
 		case AST_TRANSPORT_UDP:
 			/* fall through on purpose */
 		default:
@@ -16182,8 +16186,15 @@
 		/* Set transport and port so the correct contact is built */
 		set_socket_transport(&p->socket, r->transport);
 		if (r->transport == AST_TRANSPORT_TLS || r->transport == AST_TRANSPORT_TCP) {
-			p->socket.port =
-			    htons(ast_sockaddr_port(&sip_tcp_desc.local_address));
+			if (ast_sockaddr_isnull(&sip_tcp_desc.local_address)) {
+				ast_log(LOG_ERROR,
+				    "TCP/TLS clients without server were not tested.\n");
+				ast_log(LOG_ERROR,
+				    "Please, follow-up and report at issue 28798.\n");
+			} else {
+				p->socket.port =
+				    htons(ast_sockaddr_port(&sip_tcp_desc.local_address));
+			}
 		}
 
 		/*

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/14107
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Change-Id: I387ca5cb6a65f1eb675a29c5e41df8ec6c242ab2
Gerrit-Change-Number: 14107
Gerrit-PatchSet: 3
Gerrit-Owner: Alexander Traud <pabstraud at compuserve.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200413/815fc928/attachment.html>


More information about the asterisk-code-review mailing list