Add support for older name resolving version libraries like openBSD

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
This commit is contained in:
snuffy
2016-11-20 09:19:18 +11:00
parent 7a8d6bc81b
commit b546497fe0
5 changed files with 39 additions and 38 deletions

View File

@@ -555,7 +555,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;
}

View File

@@ -112,7 +112,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;
}
@@ -195,7 +195,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;
@@ -203,7 +203,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;
@@ -317,7 +317,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;
@@ -325,7 +325,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;
@@ -443,8 +443,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)
@@ -462,7 +462,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;
@@ -470,7 +470,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;
@@ -507,8 +507,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)

View File

@@ -30,6 +30,7 @@
#include "asterisk.h"
#include <arpa/nameser.h>
#include <netinet/in.h>
#include <resolv.h>
#include <regex.h>
@@ -590,7 +591,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;
}
@@ -598,7 +599,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;
}
@@ -606,7 +607,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;
}
@@ -614,7 +615,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;
}
@@ -622,7 +623,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;
}
@@ -630,6 +631,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;
}

View File

@@ -183,7 +183,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;
}
@@ -191,7 +191,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;
}
@@ -199,7 +199,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;
}
@@ -207,6 +207,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;
}