From 1c51d44d82e9ddd1aa6effcba6b39ee97e3ca044 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Tue, 4 Mar 2025 15:51:49 -0800 Subject: [PATCH] add new functions to classify rdata types - dns_rdatatype_ismulti() returns true if a given type can have multiple answers: ANY, RRSIG, or SIG. - dns_rdatatype_issig() returns true for a signature: RRSIG or SIG. - dns_rdatatype_isaddr() returns true for an address: A or AAAA. - dns_rdatatype_isalias() returns true for an alias: CNAME or DNAME. --- lib/dns/include/dns/rdata.h | 25 +++++++++++++++++++++++++ lib/dns/rdata.c | 21 +++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/lib/dns/include/dns/rdata.h b/lib/dns/include/dns/rdata.h index ac255b2028..5fd4c85ba9 100644 --- a/lib/dns/include/dns/rdata.h +++ b/lib/dns/include/dns/rdata.h @@ -594,6 +594,31 @@ dns_rdatatype_isknown(dns_rdatatype_t type); * */ +bool +dns_rdatatype_ismulti(dns_rdatatype_t type); +/*%< + * Return true iff a query for the rdata type can have multiple + * unrelated answers in a response: ANY, RRSIG, or SIG. + */ + +bool +dns_rdatatype_issig(dns_rdatatype_t type); +/*%< + * Return true iff the rdata type is a signature: either RRSIG or SIG. + */ + +bool +dns_rdatatype_isaddr(dns_rdatatype_t type); +/*%< + * Return true iff the rdata type is an address: either A or AAAA. + */ + +bool +dns_rdatatype_isalias(dns_rdatatype_t type); +/*%< + * Return true iff the rdata type is an alias: either CNAME or DNAME. + */ + isc_result_t dns_rdata_additionaldata(dns_rdata_t *rdata, const dns_name_t *owner, dns_additionaldatafunc_t add, void *arg); diff --git a/lib/dns/rdata.c b/lib/dns/rdata.c index d4cfc6c4e7..8d33324b34 100644 --- a/lib/dns/rdata.c +++ b/lib/dns/rdata.c @@ -2461,6 +2461,27 @@ dns_rdatatype_isknown(dns_rdatatype_t type) { return false; } +bool +dns_rdatatype_ismulti(dns_rdatatype_t type) { + return type == dns_rdatatype_any || type == dns_rdatatype_rrsig || + type == dns_rdatatype_sig; +} + +bool +dns_rdatatype_issig(dns_rdatatype_t type) { + return type == dns_rdatatype_rrsig || type == dns_rdatatype_sig; +} + +bool +dns_rdatatype_isaddr(dns_rdatatype_t type) { + return type == dns_rdatatype_a || type == dns_rdatatype_aaaa; +} + +bool +dns_rdatatype_isalias(dns_rdatatype_t type) { + return type == dns_rdatatype_cname || type == dns_rdatatype_dname; +} + void dns_rdata_exists(dns_rdata_t *rdata, dns_rdatatype_t type) { REQUIRE(rdata != NULL);