Skip to content
Snippets Groups Projects
Commit 42abcfd3 authored by Wenpeng Song's avatar Wenpeng Song Committed by Yalu Zhang
Browse files

Enable NAPTR/SRV types of DNS lookup

parent c2c8e829
No related branches found
No related tags found
1 merge request!84Enable DNS NAPTR+SRV+A
......@@ -544,49 +544,47 @@ static void sip_resolve(pjsip_resolver_t *resolver, pj_pool_t *pool, const pjsip
ast_debug(2, "[%p] Created resolution tracking for target '%s'\n", resolve, host);
/* If no port has been specified we can do NAPTR + SRV */
if (!target->addr.port) {
char srv[NI_MAXHOST];
/* When resolving addresses PJSIP can request an explicit transport type. It will explicitly
* request an IPv6 transport if a message has been tagged to use an explicitly IPv6 transport.
* For other cases it can be left unspecified OR an explicit non-IPv6 transport can be requested.
* In the case where a non-IPv6 transport is requested there is no way to differentiate between
* a transport being requested as part of a SIP URI (sip:test.com;transport=tcp) and a message
* being tagged with a specific IPv4 transport. In this case we look for both IPv4 and IPv6 addresses.
* If a message has been tagged with a specific IPv4 transport the IPv6 addresses will simply
* be discarded. The code below and elsewhere handles the case where we know they requested IPv6
* explicitly and only looks for IPv6 records.
*/
/* NAPTR + SRV */
char srv[NI_MAXHOST];
/* When resolving addresses PJSIP can request an explicit transport type. It will explicitly
* request an IPv6 transport if a message has been tagged to use an explicitly IPv6 transport.
* For other cases it can be left unspecified OR an explicit non-IPv6 transport can be requested.
* In the case where a non-IPv6 transport is requested there is no way to differentiate between
* a transport being requested as part of a SIP URI (sip:test.com;transport=tcp) and a message
* being tagged with a specific IPv4 transport. In this case we look for both IPv4 and IPv6 addresses.
* If a message has been tagged with a specific IPv4 transport the IPv6 addresses will simply
* be discarded. The code below and elsewhere handles the case where we know they requested IPv6
* explicitly and only looks for IPv6 records.
*/
res |= sip_resolve_add(resolve, host, T_NAPTR, C_IN, type, 0);
res |= sip_resolve_add(resolve, host, T_NAPTR, C_IN, type, 0);
if (type == PJSIP_TRANSPORT_UNSPECIFIED ||
(type == PJSIP_TRANSPORT_TLS && sip_transport_is_available(PJSIP_TRANSPORT_TLS)) ||
(type == PJSIP_TRANSPORT_TLS6 && sip_transport_is_available(PJSIP_TRANSPORT_TLS6))) {
if (snprintf(srv, sizeof(srv), "_sips._tcp.%s", host) < NI_MAXHOST) {
res |= sip_resolve_add(resolve, srv, T_SRV, C_IN,
type == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_TLS : type, 0);
}
if (type == PJSIP_TRANSPORT_UNSPECIFIED ||
(type == PJSIP_TRANSPORT_TLS && sip_transport_is_available(PJSIP_TRANSPORT_TLS)) ||
(type == PJSIP_TRANSPORT_TLS6 && sip_transport_is_available(PJSIP_TRANSPORT_TLS6))) {
if (snprintf(srv, sizeof(srv), "_sips._tcp.%s", host) < NI_MAXHOST) {
res |= sip_resolve_add(resolve, srv, T_SRV, C_IN,
type == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_TLS : type, 0);
}
if (type == PJSIP_TRANSPORT_UNSPECIFIED ||
(type == PJSIP_TRANSPORT_TCP && sip_transport_is_available(PJSIP_TRANSPORT_TCP)) ||
(type == PJSIP_TRANSPORT_TCP6 && sip_transport_is_available(PJSIP_TRANSPORT_TCP6))) {
if (snprintf(srv, sizeof(srv), "_sip._tcp.%s", host) < NI_MAXHOST) {
res |= sip_resolve_add(resolve, srv, T_SRV, C_IN,
type == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_TCP : type, 0);
}
}
if (type == PJSIP_TRANSPORT_UNSPECIFIED ||
(type == PJSIP_TRANSPORT_TCP && sip_transport_is_available(PJSIP_TRANSPORT_TCP)) ||
(type == PJSIP_TRANSPORT_TCP6 && sip_transport_is_available(PJSIP_TRANSPORT_TCP6))) {
if (snprintf(srv, sizeof(srv), "_sip._tcp.%s", host) < NI_MAXHOST) {
res |= sip_resolve_add(resolve, srv, T_SRV, C_IN,
type == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_TCP : type, 0);
}
if (type == PJSIP_TRANSPORT_UNSPECIFIED ||
(type == PJSIP_TRANSPORT_UDP && sip_transport_is_available(PJSIP_TRANSPORT_UDP)) ||
(type == PJSIP_TRANSPORT_UDP6 && sip_transport_is_available(PJSIP_TRANSPORT_UDP6))) {
if (snprintf(srv, sizeof(srv), "_sip._udp.%s", host) < NI_MAXHOST) {
res |= sip_resolve_add(resolve, srv, T_SRV, C_IN,
type == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_UDP : type, 0);
}
}
if (type == PJSIP_TRANSPORT_UNSPECIFIED ||
(type == PJSIP_TRANSPORT_UDP && sip_transport_is_available(PJSIP_TRANSPORT_UDP)) ||
(type == PJSIP_TRANSPORT_UDP6 && sip_transport_is_available(PJSIP_TRANSPORT_UDP6))) {
if (snprintf(srv, sizeof(srv), "_sip._udp.%s", host) < NI_MAXHOST) {
res |= sip_resolve_add(resolve, srv, T_SRV, C_IN,
type == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_UDP : type, 0);
}
}
/* AAAA + A */
if ((type == PJSIP_TRANSPORT_UNSPECIFIED && sip_transport_is_available(PJSIP_TRANSPORT_UDP6)) ||
((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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment