]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use named Service Parameter Keys (SvcParamKeys) by default
authorAram Sargsyan <aram@isc.org>
Mon, 10 Feb 2025 13:11:18 +0000 (13:11 +0000)
committerArаm Sаrgsyаn <aram@isc.org>
Mon, 17 Feb 2025 17:33:43 +0000 (17:33 +0000)
When converting SVCB records to text representation use named
SvcParamKeys values unless backward-compatible mode is activated,
in which case the values which were not defined initially in
RFC9460 and were added later (see [1]) are converted to opaque
"keyN" syntax, like, for example, "key7" instead of "dohpath".

[1] https://www.iana.org/assignments/dns-svcb/dns-svcb.xhtml

Co-authored-by: sdomi <ja@sdomi.pl>
lib/dns/include/dns/rdata.h
lib/dns/rdata/in_1/svcb_64.c

index 2123bbc927a16f39211d5de08674917121849065..ac255b2028b65af57565af07811d449ed107d94a 100644 (file)
@@ -173,6 +173,9 @@ struct dns_rdata {
 /*% Print AAAA record fully expanded */
 #define DNS_STYLEFLAG_EXPANDAAAA 0x00000020ULL
 
+/*% Print non-initial Service Parameter Keys in backward-compatible format */
+#define DNS_STYLEFLAG_SVCPARAMKEYCOMPAT 0x00000040ULL
+
 #define DNS_RDATA_DOWNCASE      DNS_NAME_DOWNCASE
 #define DNS_RDATA_CHECKNAMES    DNS_NAME_CHECKNAMES
 #define DNS_RDATA_CHECKNAMESFAIL DNS_NAME_CHECKNAMESFAIL
index 8764617688fcf943bd0218e8f5c1aa7f33fead29..b5c431c70bc330c8b482f478cf2ff7763f2d98ec 100644 (file)
@@ -377,12 +377,12 @@ svc_fromtext(isc_textregion_t *region, isc_buffer_t *target) {
 
 static const char *
 svcparamkey(unsigned short value, enum encoding *encoding, char *buf,
-           size_t len) {
+           size_t len, bool compat) {
        size_t i;
        int n;
 
        for (i = 0; i < ARRAY_SIZE(sbpr); i++) {
-               if (sbpr[i].value == value && sbpr[i].initial) {
+               if (sbpr[i].value == value && (sbpr[i].initial || !compat)) {
                        *encoding = sbpr[i].encoding;
                        return sbpr[i].name;
                }
@@ -639,6 +639,7 @@ generic_totext_in_svcb(ARGS_TOTEXT) {
        char buf[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255")];
        unsigned short num;
        int n;
+       bool compat = (tctx->flags & DNS_STYLEFLAG_SVCPARAMKEYCOMPAT) != 0;
 
        REQUIRE(rdata->length != 0);
 
@@ -674,8 +675,9 @@ generic_totext_in_svcb(ARGS_TOTEXT) {
                INSIST(region.length >= 2);
                num = uint16_fromregion(&region);
                isc_region_consume(&region, 2);
-               RETERR(str_totext(svcparamkey(num, &encoding, buf, sizeof(buf)),
-                                 target));
+               RETERR(str_totext(
+                       svcparamkey(num, &encoding, buf, sizeof(buf), compat),
+                       target));
 
                INSIST(region.length >= 2);
                num = uint16_fromregion(&region);
@@ -747,7 +749,8 @@ generic_totext_in_svcb(ARGS_TOTEXT) {
                                num = uint16_fromregion(&r);
                                isc_region_consume(&r, 2);
                                RETERR(str_totext(svcparamkey(num, &encoding,
-                                                             buf, sizeof(buf)),
+                                                             buf, sizeof(buf),
+                                                             compat),
                                                  target));
                                if (r.length != 0) {
                                        RETERR(str_totext(",", target));