1 /* $NetBSD: ta_32768.c,v 1.11 2026/01/29 18:37:53 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 /* http://www.watson.org/~weiler/INI1999-19.pdf */ 17 18 #ifndef RDATA_GENERIC_TA_32768_C 19 #define RDATA_GENERIC_TA_32768_C 20 21 #define RRTYPE_TA_ATTRIBUTES 0 22 23 static isc_result_t 24 fromtext_ta(ARGS_FROMTEXT) { 25 REQUIRE(type == dns_rdatatype_ta); 26 27 return generic_fromtext_ds(CALL_FROMTEXT); 28 } 29 30 static isc_result_t 31 totext_ta(ARGS_TOTEXT) { 32 REQUIRE(rdata->type == dns_rdatatype_ta); 33 34 return generic_totext_ds(CALL_TOTEXT); 35 } 36 37 static isc_result_t 38 fromwire_ta(ARGS_FROMWIRE) { 39 REQUIRE(type == dns_rdatatype_ta); 40 41 return generic_fromwire_ds(CALL_FROMWIRE); 42 } 43 44 static isc_result_t 45 towire_ta(ARGS_TOWIRE) { 46 isc_region_t sr; 47 48 REQUIRE(rdata->type == dns_rdatatype_ta); 49 REQUIRE(rdata->length != 0); 50 51 UNUSED(cctx); 52 53 dns_rdata_toregion(rdata, &sr); 54 return mem_tobuffer(target, sr.base, sr.length); 55 } 56 57 static int 58 compare_ta(ARGS_COMPARE) { 59 isc_region_t r1; 60 isc_region_t r2; 61 62 REQUIRE(rdata1->type == rdata2->type); 63 REQUIRE(rdata1->rdclass == rdata2->rdclass); 64 REQUIRE(rdata1->type == dns_rdatatype_ta); 65 REQUIRE(rdata1->length != 0); 66 REQUIRE(rdata2->length != 0); 67 68 dns_rdata_toregion(rdata1, &r1); 69 dns_rdata_toregion(rdata2, &r2); 70 return isc_region_compare(&r1, &r2); 71 } 72 73 static isc_result_t 74 fromstruct_ta(ARGS_FROMSTRUCT) { 75 REQUIRE(type == dns_rdatatype_ta); 76 77 return generic_fromstruct_ds(CALL_FROMSTRUCT); 78 } 79 80 static isc_result_t 81 tostruct_ta(ARGS_TOSTRUCT) { 82 dns_rdata_ds_t *ds = target; 83 84 REQUIRE(rdata->type == dns_rdatatype_ta); 85 REQUIRE(ds != NULL); 86 87 /* 88 * Checked by generic_tostruct_ds(). 89 */ 90 DNS_RDATACOMMON_INIT(ds, rdata->type, rdata->rdclass); 91 92 return generic_tostruct_ds(CALL_TOSTRUCT); 93 } 94 95 static void 96 freestruct_ta(ARGS_FREESTRUCT) { 97 dns_rdata_ta_t *ds = source; 98 99 REQUIRE(ds != NULL); 100 REQUIRE(ds->common.rdtype == dns_rdatatype_ta); 101 102 if (ds->mctx == NULL) { 103 return; 104 } 105 106 if (ds->digest != NULL) { 107 isc_mem_free(ds->mctx, ds->digest); 108 } 109 ds->mctx = NULL; 110 } 111 112 static isc_result_t 113 additionaldata_ta(ARGS_ADDLDATA) { 114 REQUIRE(rdata->type == dns_rdatatype_ta); 115 116 UNUSED(rdata); 117 UNUSED(owner); 118 UNUSED(add); 119 UNUSED(arg); 120 121 return ISC_R_SUCCESS; 122 } 123 124 static isc_result_t 125 digest_ta(ARGS_DIGEST) { 126 isc_region_t r; 127 128 REQUIRE(rdata->type == dns_rdatatype_ta); 129 130 dns_rdata_toregion(rdata, &r); 131 132 return (digest)(arg, &r); 133 } 134 135 static bool 136 checkowner_ta(ARGS_CHECKOWNER) { 137 REQUIRE(type == dns_rdatatype_ta); 138 139 UNUSED(name); 140 UNUSED(type); 141 UNUSED(rdclass); 142 UNUSED(wildcard); 143 144 return true; 145 } 146 147 static bool 148 checknames_ta(ARGS_CHECKNAMES) { 149 REQUIRE(rdata->type == dns_rdatatype_ta); 150 151 UNUSED(rdata); 152 UNUSED(owner); 153 UNUSED(bad); 154 155 return true; 156 } 157 158 static int 159 casecompare_ta(ARGS_COMPARE) { 160 return compare_ta(rdata1, rdata2); 161 } 162 163 #endif /* RDATA_GENERIC_TA_32768_C */ 164