1 /* $NetBSD: cds_59.c,v 1.8 2022/09/23 12:15:31 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(add); 124 UNUSED(arg); 125 126 return (ISC_R_SUCCESS); 127 } 128 129 static isc_result_t 130 digest_cds(ARGS_DIGEST) { 131 isc_region_t r; 132 133 REQUIRE(rdata->type == dns_rdatatype_cds); 134 135 dns_rdata_toregion(rdata, &r); 136 137 return ((digest)(arg, &r)); 138 } 139 140 static bool 141 checkowner_cds(ARGS_CHECKOWNER) { 142 REQUIRE(type == dns_rdatatype_cds); 143 144 UNUSED(name); 145 UNUSED(type); 146 UNUSED(rdclass); 147 UNUSED(wildcard); 148 149 return (true); 150 } 151 152 static bool 153 checknames_cds(ARGS_CHECKNAMES) { 154 REQUIRE(rdata->type == dns_rdatatype_cds); 155 156 UNUSED(rdata); 157 UNUSED(owner); 158 UNUSED(bad); 159 160 return (true); 161 } 162 163 static int 164 casecompare_cds(ARGS_COMPARE) { 165 return (compare_cds(rdata1, rdata2)); 166 } 167 168 #endif /* RDATA_GENERIC_CDS_59_C */ 169