]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Share reverse (ARPA) domain names
authorColin Vidal <colin@isc.org>
Wed, 14 May 2025 11:56:48 +0000 (13:56 +0200)
committerColin Vidal <colin@isc.org>
Wed, 1 Oct 2025 10:16:05 +0000 (12:16 +0200)
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).

lib/dns/byaddr.c
lib/dns/include/dns/name.h
lib/dns/name.c
lib/dns/rdata/generic/ptr_12.c

index 2836434b2b0539abbaa902850a41f33635d11d02..b22a9221df7e0dd2c409b90f39a247162d33c15b 100644 (file)
@@ -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;
        }
 
index 07265f5ae5b57d4df79f6cf3ce35775bc18f3404..d0c336fe0b52616d8e1117f9ef47646503de91ca 100644 (file)
@@ -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
index ba6e5693e60e9a0f146f5131d5bd4d347c2d1be1..9613d7e3b4286a63117fc243727e4616772539fe 100644 (file)
@@ -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.
  */
index bed80171e83521511f23010209385673846a2521..d319d38371f7c033ed44abec2ee317d44175c0e7 100644 (file)
@@ -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, &region);
                dns_name_init(&name);