<p>Roger James has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/14404">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pjsip_resolver.c: Ensure AAAA dns requests are made.<br><br> Patch from JIRA issue 26780.<br> 1. Modify sip_resolve and sip_resolve_callback to request AAAA<br> lookups when an IPV6 transport type has been requested.<br> 2. Rename all occurences of pjsip_transport_get_type_name to<br> pjsip_transport_get_type_desc. This ensures that the log/debug<br> info shows whether the transport is IPv6 or IPv4.<br> 3. Do not add the constant PJSIP_TRANSPORT_IPV6 to existing<br> transport types. This results in invalid values. Use a bitwise<br> or instead.<br><br> ASTERISK-26780<br><br>Change-Id: I8b1e298f8efa682d0a7644113258fe76d9889c58<br>---<br>M res/res_pjsip/pjsip_resolver.c<br>1 file changed, 15 insertions(+), 11 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/04/14404/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_pjsip/pjsip_resolver.c b/res/res_pjsip/pjsip_resolver.c</span><br><span>index a7bd3ea..737121b 100644</span><br><span>--- a/res/res_pjsip/pjsip_resolver.c</span><br><span>+++ b/res/res_pjsip/pjsip_resolver.c</span><br><span>@@ -174,7 +174,7 @@</span><br><span> }</span><br><span> </span><br><span> ast_debug(2, "[%p] Added target '%s' with record type '%d', transport '%s', and port '%d'\n",</span><br><span style="color: hsl(0, 100%, 40%);">- resolve, name, rr_type, pjsip_transport_get_type_name(transport), target.port);</span><br><span style="color: hsl(120, 100%, 40%);">+ resolve, name, rr_type, pjsip_transport_get_type_desc(transport), target.port);</span><br><span> </span><br><span> return ast_dns_query_set_add(resolve->queries, name, rr_type, rr_class);</span><br><span> }</span><br><span>@@ -200,7 +200,7 @@</span><br><span> pj_sockaddr_print(&resolve->addresses.entry[idx].addr, addr, sizeof(addr), 3);</span><br><span> ast_log(LOG_DEBUG, "[%p] Address '%d' is %s with transport '%s'\n",</span><br><span> resolve, idx, addr,</span><br><span style="color: hsl(0, 100%, 40%);">- pjsip_transport_get_type_name(resolve->addresses.entry[idx].type));</span><br><span style="color: hsl(120, 100%, 40%);">+ pjsip_transport_get_type_desc(resolve->addresses.entry[idx].type));</span><br><span> }</span><br><span> }</span><br><span> </span><br><span>@@ -237,7 +237,7 @@</span><br><span> * want only IPv4.</span><br><span> */</span><br><span> if (!sip_transport_is_available(transport) &&</span><br><span style="color: hsl(0, 100%, 40%);">- (!(transport & PJSIP_TRANSPORT_IPV6) && !sip_transport_is_available(transport + PJSIP_TRANSPORT_IPV6))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ (!(transport & PJSIP_TRANSPORT_IPV6) && !sip_transport_is_available(transport | PJSIP_TRANSPORT_IPV6))) {</span><br><span> ast_debug(2, "[%p] NAPTR service %s skipped as transport is unavailable\n",</span><br><span> resolve, service);</span><br><span> return -1;</span><br><span>@@ -349,12 +349,14 @@</span><br><span> ast_debug(2, "[%p] SRV record received on target '%s'\n", resolve, ast_dns_query_get_name(query));</span><br><span> </span><br><span> /* If an explicit IPv6 target transport has been requested look for only AAAA records */</span><br><span style="color: hsl(0, 100%, 40%);">- if (target->transport & PJSIP_TRANSPORT_IPV6) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if ((target->transport & PJSIP_TRANSPORT_IPV6) &&</span><br><span style="color: hsl(120, 100%, 40%);">+ sip_transport_is_available(target->transport)) {</span><br><span> sip_resolve_add(resolve, ast_dns_srv_get_host(record), T_AAAA, C_IN, target->transport,</span><br><span> ast_dns_srv_get_port(record));</span><br><span> have_srv = 1;</span><br><span style="color: hsl(0, 100%, 40%);">- } else if (sip_transport_is_available(target->transport + PJSIP_TRANSPORT_IPV6)) {</span><br><span style="color: hsl(0, 100%, 40%);">- sip_resolve_add(resolve, ast_dns_srv_get_host(record), T_AAAA, C_IN, target->transport + PJSIP_TRANSPORT_IPV6,</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (!(target->transport & PJSIP_TRANSPORT_IPV6) &&</span><br><span style="color: hsl(120, 100%, 40%);">+ sip_transport_is_available(target->transport | PJSIP_TRANSPORT_IPV6)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ sip_resolve_add(resolve, ast_dns_srv_get_host(record), T_AAAA, C_IN, target->transport | PJSIP_TRANSPORT_IPV6,</span><br><span> ast_dns_srv_get_port(record));</span><br><span> have_srv = 1;</span><br><span> }</span><br><span>@@ -497,11 +499,11 @@</span><br><span> }</span><br><span> </span><br><span> if (ip_addr_ver == 6) {</span><br><span style="color: hsl(0, 100%, 40%);">- type = (pjsip_transport_type_e)((int) type + PJSIP_TRANSPORT_IPV6);</span><br><span style="color: hsl(120, 100%, 40%);">+ type = (pjsip_transport_type_e)((int) type | PJSIP_TRANSPORT_IPV6);</span><br><span> }</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- ast_debug(2, "Transport type for target '%s' is '%s'\n", host, pjsip_transport_get_type_name(type));</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(2, "Transport type for target '%s' is '%s'\n", host, pjsip_transport_get_type_desc(type));</span><br><span> </span><br><span> /* If it's already an address call the callback immediately */</span><br><span> if (ip_addr_ver) {</span><br><span>@@ -590,12 +592,14 @@</span><br><span> }</span><br><span> </span><br><span> if ((type == PJSIP_TRANSPORT_UNSPECIFIED && sip_transport_is_available(PJSIP_TRANSPORT_UDP6)) ||</span><br><span style="color: hsl(0, 100%, 40%);">- sip_transport_is_available(type + PJSIP_TRANSPORT_IPV6)) {</span><br><span style="color: hsl(0, 100%, 40%);">- res |= sip_resolve_add(resolve, host, T_AAAA, C_IN, (type == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_UDP6 : type + PJSIP_TRANSPORT_IPV6), target->addr.port);</span><br><span style="color: hsl(120, 100%, 40%);">+ ((type & PJSIP_TRANSPORT_IPV6) && sip_transport_is_available(type))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ res |= sip_resolve_add(resolve, host, T_AAAA, C_IN, (type == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_UDP6 : type), target->addr.port);</span><br><span style="color: hsl(120, 100%, 40%);">+ } else if (!(type & PJSIP_TRANSPORT_IPV6) && sip_transport_is_available(type | PJSIP_TRANSPORT_IPV6)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ res |= sip_resolve_add(resolve, host, T_AAAA, C_IN, type | PJSIP_TRANSPORT_IPV6, target->addr.port);</span><br><span> }</span><br><span> </span><br><span> if ((type == PJSIP_TRANSPORT_UNSPECIFIED && sip_transport_is_available(PJSIP_TRANSPORT_UDP)) ||</span><br><span style="color: hsl(0, 100%, 40%);">- sip_transport_is_available(type)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ (!(type & PJSIP_TRANSPORT_IPV6) && sip_transport_is_available(type))) {</span><br><span> res |= sip_resolve_add(resolve, host, T_A, C_IN, (type == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_UDP : type), target->addr.port);</span><br><span> }</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/14404">change 14404</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/+/14404"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I8b1e298f8efa682d0a7644113258fe76d9889c58 </div>
<div style="display:none"> Gerrit-Change-Number: 14404 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Roger James <roger@beardandsandals.co.uk> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>