From: Colin Vidal Date: Wed, 14 May 2025 11:56:48 +0000 (+0200) Subject: Share reverse (ARPA) domain names X-Git-Tag: v9.21.14~13^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=72541880f276dc087dac6148794d3f9a83e824ff;p=thirdparty%2Fbind9.git Share reverse (ARPA) domain names Names for reverse resolution are now shared and accessible from dns/name.h header as those are used by ptr_12.c and byaddr.c files. (Also, for consistency, move deprecated ip6.int. name in name.h, even though it is used only by ptr_12.c). --- diff --git a/lib/dns/byaddr.c b/lib/dns/byaddr.c index 2836434b2b0..b22a9221df7 100644 --- a/lib/dns/byaddr.c +++ b/lib/dns/byaddr.c @@ -88,11 +88,8 @@ dns_byaddr_createptrname(const isc_netaddr_t *address, dns_name_t *name) { static isc_result_t parseptrnamev4(const dns_name_t *name, isc_netaddr_t *addr) { isc_buffer_t b; - static unsigned char inaddrarpa_data[] = "\007IN-ADDR\004ARPA"; - static dns_name_t const inaddrarpa = - DNS_NAME_INITABSOLUTE(inaddrarpa_data); - if (!dns_name_issubdomain(name, &inaddrarpa)) { + if (!dns_name_issubdomain(name, dns_inaddrarpa)) { return ISC_R_FAILURE; } @@ -134,10 +131,8 @@ static isc_result_t parseptrnamev6(const dns_name_t *name, isc_netaddr_t *addr) { isc_buffer_t b; isc_hex_decodectx_t ctx; - static unsigned char ip6arpa_data[] = "\003IP6\004ARPA"; - static dns_name_t const ip6arpa = DNS_NAME_INITABSOLUTE(ip6arpa_data); - if (!dns_name_issubdomain(name, &ip6arpa)) { + if (!dns_name_issubdomain(name, dns_ip6arpa)) { return ISC_R_FAILURE; } diff --git a/lib/dns/include/dns/name.h b/lib/dns/include/dns/name.h index 07265f5ae5b..d0c336fe0b5 100644 --- a/lib/dns/include/dns/name.h +++ b/lib/dns/include/dns/name.h @@ -140,6 +140,9 @@ struct dns_name { extern const dns_name_t *dns_rootname; extern const dns_name_t *dns_wildcardname; +extern const dns_name_t *dns_ip6arpa; +extern const dns_name_t *dns_ip6int; +extern const dns_name_t *dns_inaddrarpa; /*%< * DNS_NAME_INITNONABSOLUTE and DNS_NAME_INITABSOLUTE are macros for diff --git a/lib/dns/name.c b/lib/dns/name.c index ba6e5693e60..9613d7e3b42 100644 --- a/lib/dns/name.c +++ b/lib/dns/name.c @@ -52,14 +52,25 @@ typedef enum { * the const attribute of a string. */ static unsigned char root_ndata[] = { "" }; -static dns_name_t root = DNS_NAME_INITABSOLUTE(root_ndata); +static dns_name_t const root = DNS_NAME_INITABSOLUTE(root_ndata); const dns_name_t *dns_rootname = &root; static unsigned char wild_ndata[] = { "\001*" }; - static dns_name_t const wild = DNS_NAME_INITNONABSOLUTE(wild_ndata); const dns_name_t *dns_wildcardname = &wild; +static unsigned char ip6arpa_data[] = "\003IP6\004ARPA"; +static dns_name_t const ip6arpa = DNS_NAME_INITABSOLUTE(ip6arpa_data); +const dns_name_t *dns_ip6arpa = &ip6arpa; + +static unsigned char ip6int_data[] = "\003IP6\003INT"; +static dns_name_t const ip6int = DNS_NAME_INITABSOLUTE(ip6int_data); +const dns_name_t *dns_ip6int = &ip6int; + +static unsigned char inaddrarpa_data[] = "\007IN-ADDR\004ARPA"; +static dns_name_t const inaddrarpa = DNS_NAME_INITABSOLUTE(inaddrarpa_data); +const dns_name_t *dns_inaddrarpa = &inaddrarpa; + /* * dns_name_t to text post-conversion procedure. */ diff --git a/lib/dns/rdata/generic/ptr_12.c b/lib/dns/rdata/generic/ptr_12.c index bed80171e83..d319d38371f 100644 --- a/lib/dns/rdata/generic/ptr_12.c +++ b/lib/dns/rdata/generic/ptr_12.c @@ -225,15 +225,6 @@ checkowner_ptr(ARGS_CHECKOWNER) { return true; } -static unsigned char ip6_arpa_data[] = "\003IP6\004ARPA"; -static const dns_name_t ip6_arpa = DNS_NAME_INITABSOLUTE(ip6_arpa_data); - -static unsigned char ip6_int_data[] = "\003IP6\003INT"; -static const dns_name_t ip6_int = DNS_NAME_INITABSOLUTE(ip6_int_data); - -static unsigned char in_addr_arpa_data[] = "\007IN-ADDR\004ARPA"; -static const dns_name_t in_addr_arpa = DNS_NAME_INITABSOLUTE(in_addr_arpa_data); - static bool checknames_ptr(ARGS_CHECKNAMES) { isc_region_t region; @@ -249,9 +240,9 @@ checknames_ptr(ARGS_CHECKNAMES) { return true; } - if (dns_name_issubdomain(owner, &in_addr_arpa) || - dns_name_issubdomain(owner, &ip6_arpa) || - dns_name_issubdomain(owner, &ip6_int)) + if (dns_name_issubdomain(owner, dns_inaddrarpa) || + dns_name_issubdomain(owner, dns_ip6arpa) || + dns_name_issubdomain(owner, dns_ip6int)) { dns_rdata_toregion(rdata, ®ion); dns_name_init(&name);