From b919b9b4f34d7960739e005f0af5285729ecf508 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Thu, 19 Sep 2024 08:45:50 +1000 Subject: [PATCH 1/2] Add the new record type WALLET (262) This provides a mapping from a domain name to a cryptographic currency wallet and is a clone of TXT. --- bin/tests/system/rrchecker/tests_rrchecker.py | 1 + lib/dns/rdata/generic/wallet_262.c | 170 ++++++++++++++++++ lib/dns/rdata/generic/wallet_262.h | 33 ++++ tests/dns/rdata_test.c | 13 ++ 4 files changed, 217 insertions(+) create mode 100644 lib/dns/rdata/generic/wallet_262.c create mode 100644 lib/dns/rdata/generic/wallet_262.h diff --git a/bin/tests/system/rrchecker/tests_rrchecker.py b/bin/tests/system/rrchecker/tests_rrchecker.py index f425b83b91..0bdde9ea4a 100644 --- a/bin/tests/system/rrchecker/tests_rrchecker.py +++ b/bin/tests/system/rrchecker/tests_rrchecker.py @@ -101,6 +101,7 @@ import pytest "UINFO", "UNSPEC", "URI", + "WALLET", "WKS", "X25", "ZONEMD", diff --git a/lib/dns/rdata/generic/wallet_262.c b/lib/dns/rdata/generic/wallet_262.c new file mode 100644 index 0000000000..bff33e423c --- /dev/null +++ b/lib/dns/rdata/generic/wallet_262.c @@ -0,0 +1,170 @@ +/* + * 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. + */ + +#ifndef RDATA_GENERIC_WALLET_262_C +#define RDATA_GENERIC_WALLET_262_C + +#define RRTYPE_WALLET_ATTRIBUTES (0) + +static isc_result_t +fromtext_wallet(ARGS_FROMTEXT) { + REQUIRE(type == dns_rdatatype_wallet); + + return (generic_fromtext_txt(CALL_FROMTEXT)); +} + +static isc_result_t +totext_wallet(ARGS_TOTEXT) { + REQUIRE(rdata != NULL); + REQUIRE(rdata->type == dns_rdatatype_wallet); + + return (generic_totext_txt(CALL_TOTEXT)); +} + +static isc_result_t +fromwire_wallet(ARGS_FROMWIRE) { + REQUIRE(type == dns_rdatatype_wallet); + + return (generic_fromwire_txt(CALL_FROMWIRE)); +} + +static isc_result_t +towire_wallet(ARGS_TOWIRE) { + REQUIRE(rdata->type == dns_rdatatype_wallet); + + UNUSED(cctx); + + return (mem_tobuffer(target, rdata->data, rdata->length)); +} + +static int +compare_wallet(ARGS_COMPARE) { + isc_region_t r1; + isc_region_t r2; + + REQUIRE(rdata1->type == rdata2->type); + REQUIRE(rdata1->rdclass == rdata2->rdclass); + REQUIRE(rdata1->type == dns_rdatatype_wallet); + + dns_rdata_toregion(rdata1, &r1); + dns_rdata_toregion(rdata2, &r2); + return (isc_region_compare(&r1, &r2)); +} + +static isc_result_t +fromstruct_wallet(ARGS_FROMSTRUCT) { + REQUIRE(type == dns_rdatatype_wallet); + + return (generic_fromstruct_txt(CALL_FROMSTRUCT)); +} + +static isc_result_t +tostruct_wallet(ARGS_TOSTRUCT) { + dns_rdata_wallet_t *wallet = target; + + REQUIRE(rdata->type == dns_rdatatype_wallet); + REQUIRE(wallet != NULL); + + wallet->common.rdclass = rdata->rdclass; + wallet->common.rdtype = rdata->type; + ISC_LINK_INIT(&wallet->common, link); + + return (generic_tostruct_txt(CALL_TOSTRUCT)); +} + +static void +freestruct_wallet(ARGS_FREESTRUCT) { + dns_rdata_wallet_t *wallet = source; + + REQUIRE(wallet != NULL); + REQUIRE(wallet->common.rdtype == dns_rdatatype_wallet); + + generic_freestruct_txt(source); +} + +static isc_result_t +additionaldata_wallet(ARGS_ADDLDATA) { + REQUIRE(rdata->type == dns_rdatatype_wallet); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(add); + UNUSED(arg); + + return (ISC_R_SUCCESS); +} + +static isc_result_t +digest_wallet(ARGS_DIGEST) { + isc_region_t r; + + REQUIRE(rdata->type == dns_rdatatype_wallet); + + dns_rdata_toregion(rdata, &r); + + return ((digest)(arg, &r)); +} + +static bool +checkowner_wallet(ARGS_CHECKOWNER) { + REQUIRE(type == dns_rdatatype_wallet); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (true); +} + +static bool +checknames_wallet(ARGS_CHECKNAMES) { + REQUIRE(rdata->type == dns_rdatatype_wallet); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (true); +} + +static int +casecompare_wallet(ARGS_COMPARE) { + return (compare_wallet(rdata1, rdata2)); +} + +isc_result_t +dns_rdata_wallet_first(dns_rdata_wallet_t *wallet) { + REQUIRE(wallet != NULL); + REQUIRE(wallet->common.rdtype == dns_rdatatype_wallet); + + return (generic_txt_first(wallet)); +} + +isc_result_t +dns_rdata_wallet_next(dns_rdata_wallet_t *wallet) { + REQUIRE(wallet != NULL); + REQUIRE(wallet->common.rdtype == dns_rdatatype_wallet); + + return (generic_txt_next(wallet)); +} + +isc_result_t +dns_rdata_wallet_current(dns_rdata_wallet_t *wallet, + dns_rdata_wallet_string_t *string) { + REQUIRE(wallet != NULL); + REQUIRE(wallet->common.rdtype == dns_rdatatype_wallet); + + return (generic_txt_current(wallet, string)); +} +#endif /* RDATA_GENERIC_WALLET_262_C */ diff --git a/lib/dns/rdata/generic/wallet_262.h b/lib/dns/rdata/generic/wallet_262.h new file mode 100644 index 0000000000..ca552ca427 --- /dev/null +++ b/lib/dns/rdata/generic/wallet_262.h @@ -0,0 +1,33 @@ +/* + * 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 + +typedef struct dns_rdata_txt_string dns_rdata_wallet_string_t; + +typedef struct dns_rdata_txt dns_rdata_wallet_t; + +/* + * ISC_LANG_BEGINDECLS and ISC_LANG_ENDDECLS are already done + * via rdatastructpre.h and rdatastructsuf.h. + */ + +isc_result_t +dns_rdata_wallet_first(dns_rdata_wallet_t *); + +isc_result_t +dns_rdata_wallet_next(dns_rdata_wallet_t *); + +isc_result_t +dns_rdata_wallet_current(dns_rdata_wallet_t *, dns_rdata_wallet_string_t *); diff --git a/tests/dns/rdata_test.c b/tests/dns/rdata_test.c index 0d7fe0304f..f61c7ea400 100644 --- a/tests/dns/rdata_test.c +++ b/tests/dns/rdata_test.c @@ -2449,6 +2449,18 @@ ISC_RUN_TEST_IMPL(sshfp) { dns_rdatatype_sshfp, sizeof(dns_rdata_sshfp_t)); } +ISC_RUN_TEST_IMPL(wallet) { + text_ok_t text_ok[] = { TEXT_VALID_CHANGED("cid-example wid-example", + "\"cid-example\" " + "\"wid-example\""), + /* + * Sentinel. + */ + TEXT_SENTINEL() }; + check_rdata(text_ok, NULL, NULL, false, dns_rdataclass_in, + dns_rdatatype_wallet, sizeof(dns_rdata_rkey_t)); +} + /* * WKS tests. * @@ -3153,6 +3165,7 @@ ISC_TEST_ENTRY(nxt) ISC_TEST_ENTRY(rkey) ISC_TEST_ENTRY(resinfo) ISC_TEST_ENTRY(sshfp) +ISC_TEST_ENTRY(wallet) ISC_TEST_ENTRY(wks) ISC_TEST_ENTRY(zonemd) From 9b358e6e8b7adc469aee0b7bd5ad2972925acc79 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Thu, 19 Sep 2024 08:45:50 +1000 Subject: [PATCH 2/2] Add examples of WALLET records --- bin/tests/system/doth/example.axfr.good | 4 ++++ bin/tests/system/doth/example8.axfr.good | 4 ++++ bin/tests/system/genzone.sh | 8 +++++++- bin/tests/system/xfer/dig1.good | 4 ++++ bin/tests/system/xfer/dig2.good | 4 ++++ 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/bin/tests/system/doth/example.axfr.good b/bin/tests/system/doth/example.axfr.good index 176c824f4a..a5ec1f2570 100644 --- a/bin/tests/system/doth/example.axfr.good +++ b/bin/tests/system/doth/example.axfr.good @@ -2665,6 +2665,10 @@ unspec01.example. 3600 IN UNSPEC \# 1 04 uri01.example. 3600 IN URI 10 20 "https://www.isc.org/" uri02.example. 3600 IN URI 30 40 "https://www.isc.org/HolyCowThisSureIsAVeryLongURIRecordIDontEvenKnowWhatSomeoneWouldEverWantWithSuchAThingButTheSpecificationRequiresThatWesupportItSoHereWeGoTestingItLaLaLaLaLaLaLaSeriouslyThoughWhyWouldYouEvenConsiderUsingAURIThisLongItSeemsLikeASillyIdeaButEnhWhatAreYouGonnaDo/" uri03.example. 3600 IN URI 30 40 "" +wallet.example. 3600 IN WALLET "currency-identifer" "wallet-identifier" +wallet-multiple.example. 3600 IN WALLET "currency-identifer1" "wallet-identifier1" +wallet-multiple.example. 3600 IN WALLET "currency-identifer1" "wallet-identifier2" +wallet-multiple.example. 3600 IN WALLET "currency-identifer2" "wallet-identifier3" wks01.example. 3600 IN WKS 10.0.0.1 6 0 1 2 21 23 wks02.example. 3600 IN WKS 10.0.0.1 17 0 1 2 53 wks03.example. 3600 IN WKS 10.0.0.2 6 65535 diff --git a/bin/tests/system/doth/example8.axfr.good b/bin/tests/system/doth/example8.axfr.good index 97b05323d7..39d70e2021 100644 --- a/bin/tests/system/doth/example8.axfr.good +++ b/bin/tests/system/doth/example8.axfr.good @@ -2665,6 +2665,10 @@ unspec01.example8. 3600 IN UNSPEC \# 1 04 uri01.example8. 3600 IN URI 10 20 "https://www.isc.org/" uri02.example8. 3600 IN URI 30 40 "https://www.isc.org/HolyCowThisSureIsAVeryLongURIRecordIDontEvenKnowWhatSomeoneWouldEverWantWithSuchAThingButTheSpecificationRequiresThatWesupportItSoHereWeGoTestingItLaLaLaLaLaLaLaSeriouslyThoughWhyWouldYouEvenConsiderUsingAURIThisLongItSeemsLikeASillyIdeaButEnhWhatAreYouGonnaDo/" uri03.example8. 3600 IN URI 30 40 "" +wallet.example8. 3600 IN WALLET "currency-identifer" "wallet-identifier" +wallet-multiple.example8. 3600 IN WALLET "currency-identifer1" "wallet-identifier1" +wallet-multiple.example8. 3600 IN WALLET "currency-identifer1" "wallet-identifier2" +wallet-multiple.example8. 3600 IN WALLET "currency-identifer2" "wallet-identifier3" wks01.example8. 3600 IN WKS 10.0.0.1 6 0 1 2 21 23 wks02.example8. 3600 IN WKS 10.0.0.1 17 0 1 2 53 wks03.example8. 3600 IN WKS 10.0.0.2 6 65535 diff --git a/bin/tests/system/genzone.sh b/bin/tests/system/genzone.sh index 40bf221a3b..36bc4ac69b 100644 --- a/bin/tests/system/genzone.sh +++ b/bin/tests/system/genzone.sh @@ -481,7 +481,13 @@ amtrelay06 AMTRELAY \# 2 0004 ; type 261 resinfo RESINFO qnamemin exterr=15,16,17 infourl=https://resolver.example.com/guide -; type 262 -- 32767 (unassigned) +; type 262 +wallet WALLET currency-identifer wallet-identifier +wallet-multiple WALLET currency-identifer1 wallet-identifier1 +wallet-multiple WALLET currency-identifer1 wallet-identifier2 +wallet-multiple WALLET currency-identifer2 wallet-identifier3 + +; type 265 -- 32767 (unassigned) ; type 32768 ta TA 30795 1 1 ( diff --git a/bin/tests/system/xfer/dig1.good b/bin/tests/system/xfer/dig1.good index 27285100d7..d44fcda9d2 100644 --- a/bin/tests/system/xfer/dig1.good +++ b/bin/tests/system/xfer/dig1.good @@ -167,6 +167,10 @@ unspec01.example. 3600 IN UNSPEC \# 1 04 uri01.example. 3600 IN URI 10 20 "https://www.isc.org/" uri02.example. 3600 IN URI 30 40 "https://www.isc.org/HolyCowThisSureIsAVeryLongURIRecordIDontEvenKnowWhatSomeoneWouldEverWantWithSuchAThingButTheSpecificationRequiresThatWesupportItSoHereWeGoTestingItLaLaLaLaLaLaLaSeriouslyThoughWhyWouldYouEvenConsiderUsingAURIThisLongItSeemsLikeASillyIdeaButEnhWhatAreYouGonnaDo/" uri03.example. 3600 IN URI 30 40 "" +wallet.example. 3600 IN WALLET "currency-identifer" "wallet-identifier" +wallet-multiple.example. 3600 IN WALLET "currency-identifer1" "wallet-identifier1" +wallet-multiple.example. 3600 IN WALLET "currency-identifer1" "wallet-identifier2" +wallet-multiple.example. 3600 IN WALLET "currency-identifer2" "wallet-identifier3" wks01.example. 3600 IN WKS 10.0.0.1 6 0 1 2 21 23 wks02.example. 3600 IN WKS 10.0.0.1 17 0 1 2 53 wks03.example. 3600 IN WKS 10.0.0.2 6 65535 diff --git a/bin/tests/system/xfer/dig2.good b/bin/tests/system/xfer/dig2.good index 5b1d93d09c..4b090f83fe 100644 --- a/bin/tests/system/xfer/dig2.good +++ b/bin/tests/system/xfer/dig2.good @@ -167,6 +167,10 @@ unspec01.example. 3600 IN UNSPEC \# 1 04 uri01.example. 3600 IN URI 10 20 "https://www.isc.org/" uri02.example. 3600 IN URI 30 40 "https://www.isc.org/HolyCowThisSureIsAVeryLongURIRecordIDontEvenKnowWhatSomeoneWouldEverWantWithSuchAThingButTheSpecificationRequiresThatWesupportItSoHereWeGoTestingItLaLaLaLaLaLaLaSeriouslyThoughWhyWouldYouEvenConsiderUsingAURIThisLongItSeemsLikeASillyIdeaButEnhWhatAreYouGonnaDo/" uri03.example. 3600 IN URI 30 40 "" +wallet.example. 3600 IN WALLET "currency-identifer" "wallet-identifier" +wallet-multiple.example. 3600 IN WALLET "currency-identifer1" "wallet-identifier1" +wallet-multiple.example. 3600 IN WALLET "currency-identifer1" "wallet-identifier2" +wallet-multiple.example. 3600 IN WALLET "currency-identifer2" "wallet-identifier3" wks01.example. 3600 IN WKS 10.0.0.1 6 0 1 2 21 23 wks02.example. 3600 IN WKS 10.0.0.1 17 0 1 2 53 wks03.example. 3600 IN WKS 10.0.0.2 6 65535