[Asterisk-code-review] pjsip_resolver.c: Ensure AAAA dns requests are made. (asterisk[16])
Joshua Colp
asteriskteam at digium.com
Wed May 13 06:43:08 CDT 2020
Joshua Colp has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/14421 )
Change subject: pjsip_resolver.c: Ensure AAAA dns requests are made.
......................................................................
pjsip_resolver.c: Ensure AAAA dns requests are made.
1. Modify sip_resolve and sip_resolve_callback to request AAAA lookups
when an IPV6 transport type has been requested.
2. Rename all occurrences of pjsip_transport_get_type_name to
pjsip_transport_get_type_desc. This ensures that the log/debug info
shows whether the transport is IPv6 or IPv4.
3. Do not add the constant PJSIP_TRANSPORT_IPV6 to existing transport
types. This results in invalid values. Use a bitwise or instead.
ASTERISK-26780
Patches:
pjsip_resolver.c uploaded by Peter Sokolov (License #7070)
Change-Id: I8b1e298f8efa682d0a7644113258fe76d9889c58
---
M res/res_pjsip/pjsip_resolver.c
1 file changed, 15 insertions(+), 11 deletions(-)
Approvals:
Kevin Harwell: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved; Approved for Submit
diff --git a/res/res_pjsip/pjsip_resolver.c b/res/res_pjsip/pjsip_resolver.c
index a7bd3ea..3d03269 100644
--- a/res/res_pjsip/pjsip_resolver.c
+++ b/res/res_pjsip/pjsip_resolver.c
@@ -174,7 +174,7 @@
}
ast_debug(2, "[%p] Added target '%s' with record type '%d', transport '%s', and port '%d'\n",
- resolve, name, rr_type, pjsip_transport_get_type_name(transport), target.port);
+ resolve, name, rr_type, pjsip_transport_get_type_desc(transport), target.port);
return ast_dns_query_set_add(resolve->queries, name, rr_type, rr_class);
}
@@ -200,7 +200,7 @@
pj_sockaddr_print(&resolve->addresses.entry[idx].addr, addr, sizeof(addr), 3);
ast_log(LOG_DEBUG, "[%p] Address '%d' is %s with transport '%s'\n",
resolve, idx, addr,
- pjsip_transport_get_type_name(resolve->addresses.entry[idx].type));
+ pjsip_transport_get_type_desc(resolve->addresses.entry[idx].type));
}
}
@@ -237,7 +237,7 @@
* want only IPv4.
*/
if (!sip_transport_is_available(transport) &&
- (!(transport & PJSIP_TRANSPORT_IPV6) && !sip_transport_is_available(transport + PJSIP_TRANSPORT_IPV6))) {
+ (!(transport & PJSIP_TRANSPORT_IPV6) && !sip_transport_is_available(transport | PJSIP_TRANSPORT_IPV6))) {
ast_debug(2, "[%p] NAPTR service %s skipped as transport is unavailable\n",
resolve, service);
return -1;
@@ -349,12 +349,14 @@
ast_debug(2, "[%p] SRV record received on target '%s'\n", resolve, ast_dns_query_get_name(query));
/* If an explicit IPv6 target transport has been requested look for only AAAA records */
- if (target->transport & PJSIP_TRANSPORT_IPV6) {
+ if ((target->transport & PJSIP_TRANSPORT_IPV6) &&
+ sip_transport_is_available(target->transport)) {
sip_resolve_add(resolve, ast_dns_srv_get_host(record), T_AAAA, C_IN, target->transport,
ast_dns_srv_get_port(record));
have_srv = 1;
- } else if (sip_transport_is_available(target->transport + PJSIP_TRANSPORT_IPV6)) {
- sip_resolve_add(resolve, ast_dns_srv_get_host(record), T_AAAA, C_IN, target->transport + PJSIP_TRANSPORT_IPV6,
+ } else if (!(target->transport & PJSIP_TRANSPORT_IPV6) &&
+ sip_transport_is_available(target->transport | PJSIP_TRANSPORT_IPV6)) {
+ sip_resolve_add(resolve, ast_dns_srv_get_host(record), T_AAAA, C_IN, target->transport | PJSIP_TRANSPORT_IPV6,
ast_dns_srv_get_port(record));
have_srv = 1;
}
@@ -497,11 +499,11 @@
}
if (ip_addr_ver == 6) {
- type = (pjsip_transport_type_e)((int) type + PJSIP_TRANSPORT_IPV6);
+ type = (pjsip_transport_type_e)((int) type | PJSIP_TRANSPORT_IPV6);
}
}
- ast_debug(2, "Transport type for target '%s' is '%s'\n", host, pjsip_transport_get_type_name(type));
+ ast_debug(2, "Transport type for target '%s' is '%s'\n", host, pjsip_transport_get_type_desc(type));
/* If it's already an address call the callback immediately */
if (ip_addr_ver) {
@@ -590,12 +592,14 @@
}
if ((type == PJSIP_TRANSPORT_UNSPECIFIED && sip_transport_is_available(PJSIP_TRANSPORT_UDP6)) ||
- sip_transport_is_available(type + PJSIP_TRANSPORT_IPV6)) {
- res |= sip_resolve_add(resolve, host, T_AAAA, C_IN, (type == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_UDP6 : type + PJSIP_TRANSPORT_IPV6), target->addr.port);
+ ((type & PJSIP_TRANSPORT_IPV6) && sip_transport_is_available(type))) {
+ res |= sip_resolve_add(resolve, host, T_AAAA, C_IN, (type == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_UDP6 : type), target->addr.port);
+ } else if (!(type & PJSIP_TRANSPORT_IPV6) && sip_transport_is_available(type | PJSIP_TRANSPORT_IPV6)) {
+ res |= sip_resolve_add(resolve, host, T_AAAA, C_IN, type | PJSIP_TRANSPORT_IPV6, target->addr.port);
}
if ((type == PJSIP_TRANSPORT_UNSPECIFIED && sip_transport_is_available(PJSIP_TRANSPORT_UDP)) ||
- sip_transport_is_available(type)) {
+ (!(type & PJSIP_TRANSPORT_IPV6) && sip_transport_is_available(type))) {
res |= sip_resolve_add(resolve, host, T_A, C_IN, (type == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_UDP : type), target->addr.port);
}
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/14421
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I8b1e298f8efa682d0a7644113258fe76d9889c58
Gerrit-Change-Number: 14421
Gerrit-PatchSet: 1
Gerrit-Owner: Roger James <roger at beardandsandals.co.uk>
Gerrit-Reviewer: Friendly Automation
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/20200513/559cfb1c/attachment-0001.html>
More information about the asterisk-code-review
mailing list