]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add support for parsing DSYNC scheme mnemonics
authorMark Andrews <marka@isc.org>
Sat, 26 Jul 2025 04:17:20 +0000 (06:17 +0200)
committerMark Andrews <marka@isc.org>
Tue, 5 Aug 2025 07:27:44 +0000 (17:27 +1000)
Adds dns_dsyncscheme_fromtext, dns_dsyncscheme_totext and
dns_dsyncscheme_format.  Adds type dns_dsyncscheme_t.

lib/dns/include/dns/dsync.h [new file with mode: 0644]
lib/dns/include/dns/types.h
lib/dns/rcode.c

diff --git a/lib/dns/include/dns/dsync.h b/lib/dns/include/dns/dsync.h
new file mode 100644 (file)
index 0000000..9533d4c
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * SPDX-License-Identifier: MPL-2.0
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, you can obtain one at https://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+#pragma once
+
+#define DNS_DSYNCSCHEME_NOTIFY (1)
+
+#define DNS_DSYNCSCHEMEFORMAT_SIZE (7)
+
+isc_result_t
+dns_dsyncscheme_fromtext(dns_dsyncscheme_t *schemep, isc_textregion_t *source);
+
+isc_result_t
+dns_dsyncscheme_totext(dns_dsyncscheme_t scheme, isc_buffer_t *target);
+
+void
+dns_dsyncscheme_format(dns_dsyncscheme_t scheme, char *cp, unsigned int size);
index 79854963512176eb16822eb58ad49f3001f123b0..73d8c40890137d2b59adbfe2f2509edc1d6c42a3 100644 (file)
@@ -81,6 +81,7 @@ typedef ISC_LIST(dns_dns64_t) dns_dns64list_t;
 typedef struct dns_dnsseckey dns_dnsseckey_t;
 typedef ISC_LIST(dns_dnsseckey_t) dns_dnsseckeylist_t;
 typedef uint8_t                           dns_dsdigest_t;
+typedef uint8_t                           dns_dsyncscheme_t;
 typedef struct dns_dtdata         dns_dtdata_t;
 typedef struct dns_dtenv          dns_dtenv_t;
 typedef struct dns_dtmsg          dns_dtmsg_t;
index 133f49a99e7ec39712d0f76a649f2a276bedee1d..c749959a4920c9b3f6a1ee59a4b5e0911d04e124 100644 (file)
@@ -29,6 +29,7 @@
 #include <dns/cert.h>
 #include <dns/ds.h>
 #include <dns/dsdigest.h>
+#include <dns/dsync.h>
 #include <dns/keyflags.h>
 #include <dns/keyvalues.h>
 #include <dns/rcode.h>
                { DNS_DSDIGEST_GOST2012, "GOST2012", 0 },                    \
                DSDIGESTPRIVATENAMES SENTINEL
 
+#define DSYNCSCHEMES { DNS_DSYNCSCHEME_NOTIFY, "NOTIFY", 0 }, SENTINEL
+
 struct tbl {
        unsigned int value;
        const char *name;
@@ -179,6 +182,7 @@ static struct tbl secalgs[] = { SECALGNAMES };
 static struct tbl secprotos[] = { SECPROTONAMES };
 static struct tbl hashalgs[] = { HASHALGNAMES };
 static struct tbl dsdigests[] = { DSDIGESTNAMES };
+static struct tbl dsyncschemes[] = { DSYNCSCHEMES };
 static struct tbl privatednss[] = { PRIVATEDNSS SENTINEL };
 static struct tbl privateoids[] = { PRIVATEOIDS SENTINEL };
 static struct tbl dstalgorithms[] = { PRIVATEDNSS PRIVATEOIDS SECALGNAMES };
@@ -547,6 +551,41 @@ dns_dsdigest_format(dns_dsdigest_t typ, char *cp, unsigned int size) {
        }
 }
 
+/*
+ * DSYNC Scheme
+ */
+
+isc_result_t
+dns_dsyncscheme_fromtext(dns_dsyncscheme_t *schemep, isc_textregion_t *source) {
+       unsigned int value;
+
+       REQUIRE(schemep != NULL);
+       RETERR(dns_mnemonic_fromtext(&value, source, dsyncschemes, 0xff));
+       *schemep = value;
+       return ISC_R_SUCCESS;
+}
+
+isc_result_t
+dns_dsyncscheme_totext(dns_dsyncscheme_t scheme, isc_buffer_t *target) {
+       return dns_mnemonic_totext(scheme, target, dsyncschemes);
+}
+
+void
+dns_dsyncscheme_format(dns_dsyncscheme_t scheme, char *cp, unsigned int size) {
+       isc_buffer_t b;
+       isc_region_t r;
+       isc_result_t result;
+
+       REQUIRE(cp != NULL && size > 0);
+       isc_buffer_init(&b, cp, size - 1);
+       result = dns_dsyncscheme_totext(scheme, &b);
+       isc_buffer_usedregion(&b, &r);
+       r.base[r.length] = 0;
+       if (result != ISC_R_SUCCESS) {
+               r.base[0] = 0;
+       }
+}
+
 /*
  * This uses lots of hard coded values, but how often do we actually
  * add classes?