From b7375dded805157bed596529dd1a0015a9ceb5b3 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Tue, 20 Nov 2007 09:47:32 +0000 Subject: Ticket #419: initial support for DNS AAAA resolution git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1587 74dad513-b988-da41-8d7b-12977e46ad98 --- pjlib-util/include/pjlib-util/dns.h | 12 +++++-- pjlib-util/include/pjlib-util/srv_resolver.h | 47 +++++++++++++++++++++++++--- 2 files changed, 53 insertions(+), 6 deletions(-) (limited to 'pjlib-util/include') diff --git a/pjlib-util/include/pjlib-util/dns.h b/pjlib-util/include/pjlib-util/dns.h index 4505eb3d..10ba1166 100644 --- a/pjlib-util/include/pjlib-util/dns.h +++ b/pjlib-util/include/pjlib-util/dns.h @@ -41,7 +41,10 @@ PJ_BEGIN_DECL * * This module provides low-level services to parse and packetize DNS queries * and responses. The functions support building a DNS query packet and parse - * the data in the DNS response. + * the data in the DNS response. This implementation conforms to the + * following specifications: + * - RFC 1035: DOMAIN NAMES - IMPLEMENTATION AND SPECIFICATION + * - RFC 1886: DNS Extensions to support IP version 6 * * To create a DNS query packet, application should call #pj_dns_make_query() * function, specifying the desired DNS query type, the name to be resolved, @@ -258,9 +261,14 @@ typedef struct pj_dns_parsed_rr /** A Resource Data (PJ_DNS_TYPE_A, 1) */ struct a { - pj_in_addr ip_addr;/**< IP host address string. */ + pj_in_addr ip_addr;/**< IPv4 address in network byte order. */ } a; + /** AAAA Resource Data (PJ_DNS_TYPE_AAAA, 28) */ + struct aaaa { + pj_in6_addr ip_addr;/**< IPv6 address in network byte order. */ + } aaaa; + } rdata; } pj_dns_parsed_rr; diff --git a/pjlib-util/include/pjlib-util/srv_resolver.h b/pjlib-util/include/pjlib-util/srv_resolver.h index 7673bfbe..27f3e28a 100644 --- a/pjlib-util/include/pjlib-util/srv_resolver.h +++ b/pjlib-util/include/pjlib-util/srv_resolver.h @@ -74,6 +74,40 @@ PJ_BEGIN_DECL * A DNS RR for specifying the location of services (DNS SRV) */ +/** + * Flags to be specified when starting the DNS SRV query. + */ +enum pj_dns_srv_option +{ + /** + * Specify if the resolver should fallback with DNS A + * resolution when the SRV resolution fails. This option may + * be specified together with PJ_DNS_SRV_FALLBACK_AAAA to + * make the resolver fallback to AAAA if SRV resolution fails, + * and then to DNS A resolution if the AAAA resolution fails. + */ + PJ_DNS_SRV_FALLBACK_A = 1, + + /** + * Specify if the resolver should fallback with DNS AAAA + * resolution when the SRV resolution fails. This option may + * be specified together with PJ_DNS_SRV_FALLBACK_A to + * make the resolver fallback to AAAA if SRV resolution fails, + * and then to DNS A resolution if the AAAA resolution fails. + */ + PJ_DNS_SRV_FALLBACK_AAAA = 2, + + /** + * Specify if the resolver should try to resolve with DNS AAAA + * resolution first of each targets in the DNS SRV record. If + * this option is not specified, the SRV resolver will query + * the DNS A record for the target instead. + */ + PJ_DNS_SRV_RESOLVE_AAAA = 4 + +} pj_dns_srv_option; + + /** * This structure represents DNS SRV records as the result of DNS SRV * resolution using #pj_dns_srv_resolve(). @@ -85,7 +119,7 @@ typedef struct pj_dns_srv_record /** Address records. */ struct -v { + { /** Server priority (the lower the higher the priority). */ unsigned priority; @@ -125,8 +159,13 @@ typedef void pj_dns_srv_resolver_cb(void *user_data, * resolved with DNS A resolution. * @param pool Memory pool used to allocate memory for the query. * @param resolver The resolver instance. - * @param fallback_a Specify if the resolver should fallback with DNS A - * resolution when the SRV resolution fails. + * @param option Option flags, which can be constructed from + * #pj_dns_srv_option bitmask. Note that this argument + * was called "fallback_a" in pjsip version 0.8.0 and + * older, but the new option should be backward + * compatible with existing applications. If application + * specifies PJ_TRUE as "fallback_a" value, it will + * correspond to PJ_DNS_SRV_FALLBACK_A option. * @param token Arbitrary data to be associated with this query when * the calback is called. * @param cb Pointer to callback function to receive the @@ -142,7 +181,7 @@ PJ_DECL(pj_status_t) pj_dns_srv_resolve(const pj_str_t *domain_name, unsigned def_port, pj_pool_t *pool, pj_dns_resolver *resolver, - pj_bool_t fallback_a, + unsigned option, void *token, pj_dns_srv_resolver_cb *cb, pj_dns_async_query **p_query); -- cgit v1.2.3