]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Add support for older name resolving version libraries like openBSD 80/4480/1
authorsnuffy <snuffy22@gmail.com>
Sat, 19 Nov 2016 22:19:18 +0000 (09:19 +1100)
committersnuffy <snuffy22@gmail.com>
Sat, 19 Nov 2016 22:32:15 +0000 (17:32 -0500)
Fix support of OS's like openBSD that use an older nameser.h,
this change reverts the defines to the older style which on other
systems is found in nameser_compat.h

Tested on openBSD 6.0, Debian 8

ASTERISK-26608 #close

Change-Id: Iffb36caab8c5aa9dece0ce2d009041f7b56cc86a

main/dns.c
main/dns_core.c
main/dns_naptr.c
main/dns_srv.c
res/res_pjsip/pjsip_resolver.c

index fa94089e7929c1ce2087c7889656a418cb01b6e3..1a95afd93a99045e9ff132739f9d574c36af3216 100644 (file)
@@ -557,7 +557,7 @@ enum ast_dns_search_result ast_search_dns_ex(void *context, const char *dname, i
 
        if (dns_response_len < 0) {
                ast_debug(1, "DNS search failed for %s\n", dname);
-               response_handler(context, (unsigned char *)"", 0, ns_r_nxdomain);
+               response_handler(context, (unsigned char *)"", 0, NXDOMAIN);
                return AST_DNS_SEARCH_FAILURE;
        }
 
index cfce8efb084724f12cafe8139912445eae8ff86a..762b3cc349687fc2dbd854a9309738e9c622be66 100644 (file)
@@ -114,7 +114,7 @@ int ast_dns_result_get_lowest_ttl(const struct ast_dns_result *result)
        int ttl = 0;
        const struct ast_dns_record *record;
 
-       if (ast_dns_result_get_rcode(result) == ns_r_nxdomain) {
+       if (ast_dns_result_get_rcode(result) == NXDOMAIN) {
                return 0;
        }
 
@@ -197,7 +197,7 @@ struct ast_dns_query *dns_query_alloc(const char *name, int rr_type, int rr_clas
        if (ast_strlen_zero(name)) {
                ast_log(LOG_WARNING, "Could not perform asynchronous resolution, no name provided\n");
                return NULL;
-       } else if (rr_type > ns_t_max) {
+       } else if (rr_type > 65536) {
                ast_log(LOG_WARNING, "Could not perform asynchronous resolution of '%s', resource record type '%d' exceeds maximum\n",
                        name, rr_type);
                return NULL;
@@ -205,7 +205,7 @@ struct ast_dns_query *dns_query_alloc(const char *name, int rr_type, int rr_clas
                ast_log(LOG_WARNING, "Could not perform asynchronous resolution of '%s', invalid resource record type '%d'\n",
                        name, rr_type);
                return NULL;
-       } else if (rr_class > ns_c_max) {
+       } else if (rr_class > 65536) {
                ast_log(LOG_WARNING, "Could not perform asynchronous resolution of '%s', resource record class '%d' exceeds maximum\n",
                        name, rr_class);
                return NULL;
@@ -319,7 +319,7 @@ int ast_dns_resolve(const char *name, int rr_type, int rr_class, struct ast_dns_
        if (ast_strlen_zero(name)) {
                ast_log(LOG_WARNING, "Could not perform synchronous resolution, no name provided\n");
                return -1;
-       } else if (rr_type > ns_t_max) {
+       } else if (rr_type > 65536) {
                ast_log(LOG_WARNING, "Could not perform synchronous resolution of '%s', resource record type '%d' exceeds maximum\n",
                        name, rr_type);
                return -1;
@@ -327,7 +327,7 @@ int ast_dns_resolve(const char *name, int rr_type, int rr_class, struct ast_dns_
                ast_log(LOG_WARNING, "Could not perform synchronous resolution of '%s', invalid resource record type '%d'\n",
                        name, rr_type);
                return -1;
-       } else if (rr_class > ns_c_max) {
+       } else if (rr_class > 65536) {
                ast_log(LOG_WARNING, "Could not perform synchronous resolution of '%s', resource record class '%d' exceeds maximum\n",
                        name, rr_class);
                return -1;
@@ -445,8 +445,8 @@ static struct ast_dns_record *generic_record_alloc(struct ast_dns_query *query,
 typedef struct ast_dns_record *(*dns_alloc_fn)(struct ast_dns_query *query, const char *data, const size_t size);
 
 static dns_alloc_fn dns_alloc_table [] = {
-       [ns_t_naptr] = dns_naptr_alloc,
-       [ns_t_srv] = dns_srv_alloc,
+       [T_NAPTR] = dns_naptr_alloc,
+       [T_SRV] = dns_srv_alloc,
 };
 
 static struct ast_dns_record *allocate_dns_record(int rr_type, struct ast_dns_query *query, const char *data, const size_t size)
@@ -464,7 +464,7 @@ int ast_dns_resolver_add_record(struct ast_dns_query *query, int rr_type, int rr
                ast_debug(2, "Query '%p': Could not add record, invalid resource record type '%d'\n",
                        query, rr_type);
                return -1;
-       } else if (rr_type > ns_t_max) {
+       } else if (rr_type > 65536) {
                ast_debug(2, "Query '%p': Could not add record, resource record type '%d' exceeds maximum\n",
                        query, rr_type);
                return -1;
@@ -472,7 +472,7 @@ int ast_dns_resolver_add_record(struct ast_dns_query *query, int rr_type, int rr
                ast_debug(2, "Query '%p': Could not add record, invalid resource record class '%d'\n",
                        query, rr_class);
                return -1;
-       } else if (rr_class > ns_c_max) {
+       } else if (rr_class > 65536) {
                ast_debug(2, "Query '%p': Could not add record, resource record class '%d' exceeds maximum\n",
                        query, rr_class);
                return -1;
@@ -509,8 +509,8 @@ int ast_dns_resolver_add_record(struct ast_dns_query *query, int rr_type, int rr
 typedef void (*dns_sort_fn)(struct ast_dns_result *result);
 
 static dns_sort_fn dns_sort_table [] = {
-       [ns_t_naptr] = dns_naptr_sort,
-       [ns_t_srv] = dns_srv_sort,
+       [T_NAPTR] = dns_naptr_sort,
+       [T_SRV] = dns_srv_sort,
 };
 
 static void sort_result(int rr_type, struct ast_dns_result *result)
index 4d5a5f99aed8ff4295648352d67f3ba60628625a..4b1bd753738064e67a1f87f90cdf24467f325cb4 100644 (file)
@@ -32,6 +32,7 @@
 ASTERISK_REGISTER_FILE()
 
 #include <arpa/nameser.h>
+#include <netinet/in.h>
 #include <resolv.h>
 #include <regex.h>
 
@@ -592,7 +593,7 @@ const char *ast_dns_naptr_get_flags(const struct ast_dns_record *record)
 {
        struct ast_dns_naptr_record *naptr = (struct ast_dns_naptr_record *) record;
 
-       ast_assert(ast_dns_record_get_rr_type(record) == ns_t_naptr);
+       ast_assert(ast_dns_record_get_rr_type(record) == T_NAPTR);
        return naptr->flags;
 }
 
@@ -600,7 +601,7 @@ const char *ast_dns_naptr_get_service(const struct ast_dns_record *record)
 {
        struct ast_dns_naptr_record *naptr = (struct ast_dns_naptr_record *) record;
 
-       ast_assert(ast_dns_record_get_rr_type(record) == ns_t_naptr);
+       ast_assert(ast_dns_record_get_rr_type(record) == T_NAPTR);
        return naptr->service;
 }
 
@@ -608,7 +609,7 @@ const char *ast_dns_naptr_get_regexp(const struct ast_dns_record *record)
 {
        struct ast_dns_naptr_record *naptr = (struct ast_dns_naptr_record *) record;
 
-       ast_assert(ast_dns_record_get_rr_type(record) == ns_t_naptr);
+       ast_assert(ast_dns_record_get_rr_type(record) == T_NAPTR);
        return naptr->regexp;
 }
 
@@ -616,7 +617,7 @@ const char *ast_dns_naptr_get_replacement(const struct ast_dns_record *record)
 {
        struct ast_dns_naptr_record *naptr = (struct ast_dns_naptr_record *) record;
 
-       ast_assert(ast_dns_record_get_rr_type(record) == ns_t_naptr);
+       ast_assert(ast_dns_record_get_rr_type(record) == T_NAPTR);
        return naptr->replacement;
 }
 
@@ -624,7 +625,7 @@ unsigned short ast_dns_naptr_get_order(const struct ast_dns_record *record)
 {
        struct ast_dns_naptr_record *naptr = (struct ast_dns_naptr_record *) record;
 
-       ast_assert(ast_dns_record_get_rr_type(record) == ns_t_naptr);
+       ast_assert(ast_dns_record_get_rr_type(record) == T_NAPTR);
        return naptr->order;
 }
 
@@ -632,6 +633,6 @@ unsigned short ast_dns_naptr_get_preference(const struct ast_dns_record *record)
 {
        struct ast_dns_naptr_record *naptr = (struct ast_dns_naptr_record *) record;
 
-       ast_assert(ast_dns_record_get_rr_type(record) == ns_t_naptr);
+       ast_assert(ast_dns_record_get_rr_type(record) == T_NAPTR);
        return naptr->preference;
 }
index e4a3d8bbdb7090af878f167e970573ea7d5a6747..0a4c8781089a6d2f81ab20c5f06a4b08a98f5bde 100644 (file)
@@ -185,7 +185,7 @@ const char *ast_dns_srv_get_host(const struct ast_dns_record *record)
 {
        struct ast_dns_srv_record *srv = (struct ast_dns_srv_record *) record;
 
-       ast_assert(ast_dns_record_get_rr_type(record) == ns_t_srv);
+       ast_assert(ast_dns_record_get_rr_type(record) == T_SRV);
        return srv->host;
 }
 
@@ -193,7 +193,7 @@ unsigned short ast_dns_srv_get_priority(const struct ast_dns_record *record)
 {
        struct ast_dns_srv_record *srv = (struct ast_dns_srv_record *) record;
 
-       ast_assert(ast_dns_record_get_rr_type(record) == ns_t_srv);
+       ast_assert(ast_dns_record_get_rr_type(record) == T_SRV);
        return srv->priority;
 }
 
@@ -201,7 +201,7 @@ unsigned short ast_dns_srv_get_weight(const struct ast_dns_record *record)
 {
        struct ast_dns_srv_record *srv = (struct ast_dns_srv_record *) record;
 
-       ast_assert(ast_dns_record_get_rr_type(record) == ns_t_srv);
+       ast_assert(ast_dns_record_get_rr_type(record) == T_SRV);
        return srv->weight;
 }
 
@@ -209,6 +209,6 @@ unsigned short ast_dns_srv_get_port(const struct ast_dns_record *record)
 {
        struct ast_dns_srv_record *srv = (struct ast_dns_srv_record *) record;
 
-       ast_assert(ast_dns_record_get_rr_type(record) == ns_t_srv);
+       ast_assert(ast_dns_record_get_rr_type(record) == T_SRV);
        return srv->port;
 }
index 5a902466e3fd1e25bf39e9613353fe5b6a7a4eaa..d6646d50323474bf51bac137fe59535cfd96d42f 100644 (file)
@@ -253,7 +253,7 @@ static int sip_resolve_handle_naptr(struct sip_resolve *resolve, const struct as
                return -1;
        }
 
-       return sip_resolve_add(resolve, ast_dns_naptr_get_replacement(record), ns_t_srv, ns_c_in,
+       return sip_resolve_add(resolve, ast_dns_naptr_get_replacement(record), T_SRV, C_IN,
                transport, 0);
 }
 
@@ -304,12 +304,12 @@ static void sip_resolve_callback(const struct ast_dns_query_set *query_set)
                target = AST_VECTOR_GET_ADDR(&resolving, idx);
                for (record = ast_dns_result_get_records(result); record; record = ast_dns_record_get_next(record)) {
 
-                       if (ast_dns_record_get_rr_type(record) == ns_t_a ||
-                               ast_dns_record_get_rr_type(record) == ns_t_aaaa) {
+                       if (ast_dns_record_get_rr_type(record) == T_A ||
+                               ast_dns_record_get_rr_type(record) == T_AAAA) {
                                /* If NAPTR or SRV records exist the subsequent results from them take preference */
                                if (have_naptr || have_srv) {
                                        ast_debug(2, "[%p] %s record being skipped on target '%s' because NAPTR or SRV record exists\n",
-                                               resolve, ast_dns_record_get_rr_type(record) == ns_t_a ? "A" : "AAAA",
+                                               resolve, ast_dns_record_get_rr_type(record) == T_A ? "A" : "AAAA",
                                                ast_dns_query_get_name(query));
                                        continue;
                                }
@@ -322,7 +322,7 @@ static void sip_resolve_callback(const struct ast_dns_query_set *query_set)
                                resolve->addresses.entry[address_count].type = target->transport;
 
                                /* Populate address information for the new address entry */
-                               if (ast_dns_record_get_rr_type(record) == ns_t_a) {
+                               if (ast_dns_record_get_rr_type(record) == T_A) {
                                        ast_debug(2, "[%p] A record received on target '%s'\n", resolve, ast_dns_query_get_name(query));
                                        resolve->addresses.entry[address_count].addr_len = sizeof(pj_sockaddr_in);
                                        pj_sockaddr_init(pj_AF_INET(), &resolve->addresses.entry[address_count].addr, NULL,
@@ -338,7 +338,7 @@ static void sip_resolve_callback(const struct ast_dns_query_set *query_set)
                                }
 
                                address_count++;
-                       } else if (ast_dns_record_get_rr_type(record) == ns_t_srv) {
+                       } else if (ast_dns_record_get_rr_type(record) == T_SRV) {
                                if (have_naptr) {
                                        ast_debug(2, "[%p] SRV record being skipped on target '%s' because NAPTR record exists\n",
                                                resolve, ast_dns_query_get_name(query));
@@ -350,22 +350,22 @@ static void sip_resolve_callback(const struct ast_dns_query_set *query_set)
 
                                /* If an explicit IPv6 target transport has been requested look for only AAAA records */
                                if (target->transport & PJSIP_TRANSPORT_IPV6) {
-                                       sip_resolve_add(resolve, ast_dns_srv_get_host(record), ns_t_aaaa, ns_c_in, 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), ns_t_aaaa, ns_c_in, 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;
                                }
 
                                if (!(target->transport & PJSIP_TRANSPORT_IPV6) &&
                                        sip_transport_is_available(target->transport)) {
-                                       sip_resolve_add(resolve, ast_dns_srv_get_host(record), ns_t_a, ns_c_in, target->transport,
+                                       sip_resolve_add(resolve, ast_dns_srv_get_host(record), T_A, C_IN, target->transport,
                                                ast_dns_srv_get_port(record));
                                        have_srv = 1;
                                }
-                       } else if (ast_dns_record_get_rr_type(record) == ns_t_naptr) {
+                       } else if (ast_dns_record_get_rr_type(record) == T_NAPTR) {
                                int added = -1;
 
                                ast_debug(2, "[%p] NAPTR record received on target '%s'\n", resolve, ast_dns_query_get_name(query));
@@ -561,39 +561,39 @@ static void sip_resolve(pjsip_resolver_t *resolver, pj_pool_t *pool, const pjsip
                 * explicitly and only looks for IPv6 records.
                 */
 
-               res |= sip_resolve_add(resolve, host, ns_t_naptr, ns_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))) {
                        snprintf(srv, sizeof(srv), "_sips._tcp.%s", host);
-                       res |= sip_resolve_add(resolve, srv, ns_t_srv, ns_c_in,
+                       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))) {
                        snprintf(srv, sizeof(srv), "_sip._tcp.%s", host);
-                       res |= sip_resolve_add(resolve, srv, ns_t_srv, ns_c_in,
+                       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))) {
                        snprintf(srv, sizeof(srv), "_sip._udp.%s", host);
-                       res |= sip_resolve_add(resolve, srv, ns_t_srv, ns_c_in,
+                       res |= sip_resolve_add(resolve, srv, T_SRV, C_IN,
                                type == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_UDP : type, 0);
                }
        }
 
        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, ns_t_aaaa, ns_c_in, (type == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_UDP6 : type + PJSIP_TRANSPORT_IPV6), target->addr.port);
+               res |= sip_resolve_add(resolve, host, T_AAAA, C_IN, (type == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_UDP6 : type + PJSIP_TRANSPORT_IPV6), target->addr.port);
        }
 
        if ((type == PJSIP_TRANSPORT_UNSPECIFIED && sip_transport_is_available(PJSIP_TRANSPORT_UDP)) ||
                sip_transport_is_available(type)) {
-               res |= sip_resolve_add(resolve, host, ns_t_a, ns_c_in, (type == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_UDP : type), target->addr.port);
+               res |= sip_resolve_add(resolve, host, T_A, C_IN, (type == PJSIP_TRANSPORT_UNSPECIFIED ? PJSIP_TRANSPORT_UDP : type), target->addr.port);
        }
 
        if (res) {