1 /* $NetBSD: rkey_57.c,v 1.9 2025/01/26 16:25:33 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 #ifndef RDATA_GENERIC_RKEY_57_C 17 #define RDATA_GENERIC_RKEY_57_C 18 19 #define RRTYPE_RKEY_ATTRIBUTES 0 20 21 static isc_result_t 22 fromtext_rkey(ARGS_FROMTEXT) { 23 REQUIRE(type == dns_rdatatype_rkey); 24 25 return generic_fromtext_key(CALL_FROMTEXT); 26 } 27 28 static isc_result_t 29 totext_rkey(ARGS_TOTEXT) { 30 REQUIRE(rdata != NULL); 31 REQUIRE(rdata->type == dns_rdatatype_rkey); 32 33 return generic_totext_key(CALL_TOTEXT); 34 } 35 36 static isc_result_t 37 fromwire_rkey(ARGS_FROMWIRE) { 38 REQUIRE(type == dns_rdatatype_rkey); 39 40 return generic_fromwire_key(CALL_FROMWIRE); 41 } 42 43 static isc_result_t 44 towire_rkey(ARGS_TOWIRE) { 45 isc_region_t sr; 46 47 REQUIRE(rdata != NULL); 48 REQUIRE(rdata->type == dns_rdatatype_rkey); 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_rkey(ARGS_COMPARE) { 59 isc_region_t r1; 60 isc_region_t r2; 61 62 REQUIRE(rdata1 != NULL); 63 REQUIRE(rdata2 != NULL); 64 REQUIRE(rdata1->type == rdata2->type); 65 REQUIRE(rdata1->rdclass == rdata2->rdclass); 66 REQUIRE(rdata1->type == dns_rdatatype_rkey); 67 REQUIRE(rdata1->length != 0); 68 REQUIRE(rdata2->length != 0); 69 70 dns_rdata_toregion(rdata1, &r1); 71 dns_rdata_toregion(rdata2, &r2); 72 return isc_region_compare(&r1, &r2); 73 } 74 75 static isc_result_t 76 fromstruct_rkey(ARGS_FROMSTRUCT) { 77 REQUIRE(type == dns_rdatatype_rkey); 78 79 return generic_fromstruct_key(CALL_FROMSTRUCT); 80 } 81 82 static isc_result_t 83 tostruct_rkey(ARGS_TOSTRUCT) { 84 dns_rdata_rkey_t *rkey = target; 85 86 REQUIRE(rkey != NULL); 87 REQUIRE(rdata != NULL); 88 REQUIRE(rdata->type == dns_rdatatype_rkey); 89 90 rkey->common.rdclass = rdata->rdclass; 91 rkey->common.rdtype = rdata->type; 92 ISC_LINK_INIT(&rkey->common, link); 93 94 return generic_tostruct_key(CALL_TOSTRUCT); 95 } 96 97 static void 98 freestruct_rkey(ARGS_FREESTRUCT) { 99 dns_rdata_rkey_t *rkey = (dns_rdata_rkey_t *)source; 100 101 REQUIRE(rkey != NULL); 102 REQUIRE(rkey->common.rdtype == dns_rdatatype_rkey); 103 104 generic_freestruct_key(source); 105 } 106 107 static isc_result_t 108 additionaldata_rkey(ARGS_ADDLDATA) { 109 REQUIRE(rdata->type == dns_rdatatype_rkey); 110 111 UNUSED(rdata); 112 UNUSED(owner); 113 UNUSED(add); 114 UNUSED(arg); 115 116 return ISC_R_SUCCESS; 117 } 118 119 static isc_result_t 120 digest_rkey(ARGS_DIGEST) { 121 isc_region_t r; 122 123 REQUIRE(rdata != NULL); 124 REQUIRE(rdata->type == dns_rdatatype_rkey); 125 126 dns_rdata_toregion(rdata, &r); 127 128 return (digest)(arg, &r); 129 } 130 131 static bool 132 checkowner_rkey(ARGS_CHECKOWNER) { 133 REQUIRE(type == dns_rdatatype_rkey); 134 135 UNUSED(name); 136 UNUSED(type); 137 UNUSED(rdclass); 138 UNUSED(wildcard); 139 140 return true; 141 } 142 143 static bool 144 checknames_rkey(ARGS_CHECKNAMES) { 145 REQUIRE(rdata != NULL); 146 REQUIRE(rdata->type == dns_rdatatype_rkey); 147 148 UNUSED(rdata); 149 UNUSED(owner); 150 UNUSED(bad); 151 152 return true; 153 } 154 155 static int 156 casecompare_rkey(ARGS_COMPARE) { 157 /* 158 * Treat ALG 253 (private DNS) subtype name case sensitively. 159 */ 160 return compare_rkey(rdata1, rdata2); 161 } 162 163 #endif /* RDATA_GENERIC_RKEY_57_C */ 164