<p>Kevin Harwell <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/14106">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve
Kevin Harwell: Looks good to me, approved; Approved for Submit
George Joseph: Looks good to me, but someone else must approve
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">chan_sip: TCP/TLS client without server.<br><br>It is possible to configure a TCP/TLS client without having a TCP/TLS<br>server. In that case, no error or warning was printed but the headers<br>Contact and Via in SIP REGISTER were "(null)".<br><br>ASTERISK-28798<br><br>Change-Id: I387ca5cb6a65f1eb675a29c5e41df8ec6c242ab2<br>---<br>M channels/chan_sip.c<br>1 file changed, 29 insertions(+), 18 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/channels/chan_sip.c b/channels/chan_sip.c</span><br><span>index 63a0129..e4e077b 100644</span><br><span>--- a/channels/chan_sip.c</span><br><span>+++ b/channels/chan_sip.c</span><br><span>@@ -3934,23 +3934,27 @@</span><br><span> /* no remapping, but we bind to a specific address, so use it. */</span><br><span> switch (p->socket.type) {</span><br><span> case AST_TRANSPORT_TCP:</span><br><span style="color: hsl(0, 100%, 40%);">- if (!ast_sockaddr_is_any(&sip_tcp_desc.local_address)) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_sockaddr_copy(us,</span><br><span style="color: hsl(0, 100%, 40%);">- &sip_tcp_desc.local_address);</span><br><span style="color: hsl(0, 100%, 40%);">- } else {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_sockaddr_set_port(us,</span><br><span style="color: hsl(0, 100%, 40%);">- ast_sockaddr_port(&sip_tcp_desc.local_address));</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- break;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_sockaddr_isnull(&sip_tcp_desc.local_address)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_sockaddr_is_any(&sip_tcp_desc.local_address)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sockaddr_copy(us,</span><br><span style="color: hsl(120, 100%, 40%);">+ &sip_tcp_desc.local_address);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sockaddr_set_port(us,</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sockaddr_port(&sip_tcp_desc.local_address));</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ break;</span><br><span style="color: hsl(120, 100%, 40%);">+ } /* fall through on purpose */</span><br><span> case AST_TRANSPORT_TLS:</span><br><span style="color: hsl(0, 100%, 40%);">- if (!ast_sockaddr_is_any(&sip_tls_desc.local_address)) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_sockaddr_copy(us,</span><br><span style="color: hsl(0, 100%, 40%);">- &sip_tls_desc.local_address);</span><br><span style="color: hsl(0, 100%, 40%);">- } else {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_sockaddr_set_port(us,</span><br><span style="color: hsl(0, 100%, 40%);">- ast_sockaddr_port(&sip_tls_desc.local_address));</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- break;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_sockaddr_isnull(&sip_tls_desc.local_address)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_sockaddr_is_any(&sip_tls_desc.local_address)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sockaddr_copy(us,</span><br><span style="color: hsl(120, 100%, 40%);">+ &sip_tls_desc.local_address);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sockaddr_set_port(us,</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_sockaddr_port(&sip_tls_desc.local_address));</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ break;</span><br><span style="color: hsl(120, 100%, 40%);">+ } /* fall through on purpose */</span><br><span> case AST_TRANSPORT_UDP:</span><br><span> /* fall through on purpose */</span><br><span> default:</span><br><span>@@ -16249,8 +16253,15 @@</span><br><span> /* Set transport and port so the correct contact is built */</span><br><span> set_socket_transport(&p->socket, r->transport);</span><br><span> if (r->transport == AST_TRANSPORT_TLS || r->transport == AST_TRANSPORT_TCP) {</span><br><span style="color: hsl(0, 100%, 40%);">- p->socket.port =</span><br><span style="color: hsl(0, 100%, 40%);">- htons(ast_sockaddr_port(&sip_tcp_desc.local_address));</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_sockaddr_isnull(&sip_tcp_desc.local_address)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_ERROR,</span><br><span style="color: hsl(120, 100%, 40%);">+ "TCP/TLS clients without server were not tested.\n");</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(LOG_ERROR,</span><br><span style="color: hsl(120, 100%, 40%);">+ "Please, follow-up and report at issue 28798.\n");</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ p->socket.port =</span><br><span style="color: hsl(120, 100%, 40%);">+ htons(ast_sockaddr_port(&sip_tcp_desc.local_address));</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> }</span><br><span> </span><br><span> /*</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/14106">change 14106</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/14106"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: I387ca5cb6a65f1eb675a29c5e41df8ec6c242ab2 </div>
<div style="display:none"> Gerrit-Change-Number: 14106 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: Alexander Traud <pabstraud@compuserve.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>