diff --git a/main/dns.c b/main/dns.c
index 3b198a0f3263cd444dea46089ca71f468185dc66..76f8075e53a004e91f03a908de8017bbbac30e94 100644
--- a/main/dns.c
+++ b/main/dns.c
@@ -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;
 	}
 
diff --git a/main/dns_core.c b/main/dns_core.c
index e1cbc21916ae66e731f89e193b96bd958f511e99..a243b4bdd3fbd328c00d9641c6dc4e3d956b8566 100644
--- a/main/dns_core.c
+++ b/main/dns_core.c
@@ -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)
diff --git a/main/dns_naptr.c b/main/dns_naptr.c
index d24e1b5f4471147a25cf6c19092cd8c38bb1cce5..5490b556830122237f823dacf8b7b415d6fdbbf0 100644
--- a/main/dns_naptr.c
+++ b/main/dns_naptr.c
@@ -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;
 }
diff --git a/main/dns_srv.c b/main/dns_srv.c
index 9d36fb61f9dd43c90fd1180ce7350f609f319c80..b562e325753b2d669862461346df430133046552 100644
--- a/main/dns_srv.c
+++ b/main/dns_srv.c
@@ -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;
 }
diff --git a/res/res_pjsip/pjsip_resolver.c b/res/res_pjsip/pjsip_resolver.c
index 5a902466e3fd1e25bf39e9613353fe5b6a7a4eaa..d6646d50323474bf51bac137fe59535cfd96d42f 100644
--- a/res/res_pjsip/pjsip_resolver.c
+++ b/res/res_pjsip/pjsip_resolver.c
@@ -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) {