1 /* $NetBSD: cds_59.c,v 1.10 2025/01/26 16:25:30 christos Exp $ */ 2 3 /* 4 * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 5 * 6 * SPDX-License-Identifier: MPL-2.0 7 * 8 * This Source Code Form is subject to the terms of the Mozilla Public 9 * License, v. 2.0. If a copy of the MPL was not distributed with this 10 * file, you can obtain one at https://mozilla.org/MPL/2.0/. 11 * 12 * See the COPYRIGHT file distributed with this work for additional 13 * information regarding copyright ownership. 14 */ 15 16 /* draft-ietf-dnsop-delegation-trust-maintainance-14 */ 17 18 #ifndef RDATA_GENERIC_CDS_59_C 19 #define RDATA_GENERIC_CDS_59_C 20 21 #define RRTYPE_CDS_ATTRIBUTES 0 22 23 #include <dns/ds.h> 24 25 static isc_result_t 26 fromtext_cds(ARGS_FROMTEXT) { 27 REQUIRE(type == dns_rdatatype_cds); 28 29 return generic_fromtext_ds(CALL_FROMTEXT); 30 } 31 32 static isc_result_t 33 totext_cds(ARGS_TOTEXT) { 34 REQUIRE(rdata != NULL); 35 REQUIRE(rdata->type == dns_rdatatype_cds); 36 37 return generic_totext_ds(CALL_TOTEXT); 38 } 39 40 static isc_result_t 41 fromwire_cds(ARGS_FROMWIRE) { 42 REQUIRE(type == dns_rdatatype_cds); 43 44 return generic_fromwire_ds(CALL_FROMWIRE); 45 } 46 47 static isc_result_t 48 towire_cds(ARGS_TOWIRE) { 49 isc_region_t sr; 50 51 REQUIRE(rdata->type == dns_rdatatype_cds); 52 REQUIRE(rdata->length != 0); 53 54 UNUSED(cctx); 55 56 dns_rdata_toregion(rdata, &sr); 57 return mem_tobuffer(target, sr.base, sr.length); 58 } 59 60 static int 61 compare_cds(ARGS_COMPARE) { 62 isc_region_t r1; 63 isc_region_t r2; 64 65 REQUIRE(rdata1->type == rdata2->type); 66 REQUIRE(rdata1->rdclass == rdata2->rdclass); 67 REQUIRE(rdata1->type == dns_rdatatype_cds); 68 REQUIRE(rdata1->length != 0); 69 REQUIRE(rdata2->length != 0); 70 71 dns_rdata_toregion(rdata1, &r1); 72 dns_rdata_toregion(rdata2, &r2); 73 return isc_region_compare(&r1, &r2); 74 } 75 76 static isc_result_t 77 fromstruct_cds(ARGS_FROMSTRUCT) { 78 REQUIRE(type == dns_rdatatype_cds); 79 80 return generic_fromstruct_ds(CALL_FROMSTRUCT); 81 } 82 83 static isc_result_t 84 tostruct_cds(ARGS_TOSTRUCT) { 85 dns_rdata_cds_t *cds = target; 86 87 REQUIRE(rdata->type == dns_rdatatype_cds); 88 REQUIRE(cds != NULL); 89 REQUIRE(rdata->length != 0); 90 91 /* 92 * Checked by generic_tostruct_ds(). 93 */ 94 cds->common.rdclass = rdata->rdclass; 95 cds->common.rdtype = rdata->type; 96 ISC_LINK_INIT(&cds->common, link); 97 98 return generic_tostruct_ds(CALL_TOSTRUCT); 99 } 100 101 static void 102 freestruct_cds(ARGS_FREESTRUCT) { 103 dns_rdata_cds_t *cds = source; 104 105 REQUIRE(cds != NULL); 106 REQUIRE(cds->common.rdtype == dns_rdatatype_cds); 107 108 if (cds->mctx == NULL) { 109 return; 110 } 111 112 if (cds->digest != NULL) { 113 isc_mem_free(cds->mctx, cds->digest); 114 } 115 cds->mctx = NULL; 116 } 117 118 static isc_result_t 119 additionaldata_cds(ARGS_ADDLDATA) { 120 REQUIRE(rdata->type == dns_rdatatype_cds); 121 122 UNUSED(rdata); 123 UNUSED(owner); 124 UNUSED(add); 125 UNUSED(arg); 126 127 return ISC_R_SUCCESS; 128 } 129 130 static isc_result_t 131 digest_cds(ARGS_DIGEST) { 132 isc_region_t r; 133 134 REQUIRE(rdata->type == dns_rdatatype_cds); 135 136 dns_rdata_toregion(rdata, &r); 137 138 return (digest)(arg, &r); 139 } 140 141 static bool 142 checkowner_cds(ARGS_CHECKOWNER) { 143 REQUIRE(type == dns_rdatatype_cds); 144 145 UNUSED(name); 146 UNUSED(type); 147 UNUSED(rdclass); 148 UNUSED(wildcard); 149 150 return true; 151 } 152 153 static bool 154 checknames_cds(ARGS_CHECKNAMES) { 155 REQUIRE(rdata->type == dns_rdatatype_cds); 156 157 UNUSED(rdata); 158 UNUSED(owner); 159 UNUSED(bad); 160 161 return true; 162 } 163 164 static int 165 casecompare_cds(ARGS_COMPARE) { 166 return compare_cds(rdata1, rdata2); 167 } 168 169 #endif /* RDATA_GENERIC_CDS_59_C */ 170