1 /* $NetBSD: eid_31.c,v 1.11 2026/01/29 18:37:54 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://ana-3.lcs.mit.edu/~jnc/nimrod/dns.txt */ 17 18 #ifndef RDATA_IN_1_EID_31_C 19 #define RDATA_IN_1_EID_31_C 20 21 #define RRTYPE_EID_ATTRIBUTES (0) 22 23 static isc_result_t 24 fromtext_in_eid(ARGS_FROMTEXT) { 25 REQUIRE(type == dns_rdatatype_eid); 26 REQUIRE(rdclass == dns_rdataclass_in); 27 28 UNUSED(type); 29 UNUSED(origin); 30 UNUSED(options); 31 UNUSED(rdclass); 32 UNUSED(callbacks); 33 34 return isc_hex_tobuffer(lexer, target, -2); 35 } 36 37 static isc_result_t 38 totext_in_eid(ARGS_TOTEXT) { 39 isc_region_t region; 40 41 REQUIRE(rdata->type == dns_rdatatype_eid); 42 REQUIRE(rdata->rdclass == dns_rdataclass_in); 43 REQUIRE(rdata->length != 0); 44 45 dns_rdata_toregion(rdata, ®ion); 46 47 if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) { 48 RETERR(str_totext("( ", target)); 49 } 50 if (tctx->width == 0) { 51 RETERR(isc_hex_totext(®ion, 60, "", target)); 52 } else { 53 RETERR(isc_hex_totext(®ion, tctx->width - 2, tctx->linebreak, 54 target)); 55 } 56 if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) { 57 RETERR(str_totext(" )", target)); 58 } 59 return ISC_R_SUCCESS; 60 } 61 62 static isc_result_t 63 fromwire_in_eid(ARGS_FROMWIRE) { 64 isc_region_t region; 65 66 REQUIRE(type == dns_rdatatype_eid); 67 REQUIRE(rdclass == dns_rdataclass_in); 68 69 UNUSED(type); 70 UNUSED(dctx); 71 UNUSED(rdclass); 72 73 isc_buffer_activeregion(source, ®ion); 74 if (region.length < 1) { 75 return ISC_R_UNEXPECTEDEND; 76 } 77 78 RETERR(mem_tobuffer(target, region.base, region.length)); 79 isc_buffer_forward(source, region.length); 80 return ISC_R_SUCCESS; 81 } 82 83 static isc_result_t 84 towire_in_eid(ARGS_TOWIRE) { 85 REQUIRE(rdata->type == dns_rdatatype_eid); 86 REQUIRE(rdata->rdclass == dns_rdataclass_in); 87 REQUIRE(rdata->length != 0); 88 89 UNUSED(cctx); 90 91 return mem_tobuffer(target, rdata->data, rdata->length); 92 } 93 94 static int 95 compare_in_eid(ARGS_COMPARE) { 96 isc_region_t r1; 97 isc_region_t r2; 98 99 REQUIRE(rdata1->type == rdata2->type); 100 REQUIRE(rdata1->rdclass == rdata2->rdclass); 101 REQUIRE(rdata1->type == dns_rdatatype_eid); 102 REQUIRE(rdata1->rdclass == dns_rdataclass_in); 103 REQUIRE(rdata1->length != 0); 104 REQUIRE(rdata2->length != 0); 105 106 dns_rdata_toregion(rdata1, &r1); 107 dns_rdata_toregion(rdata2, &r2); 108 return isc_region_compare(&r1, &r2); 109 } 110 111 static isc_result_t 112 fromstruct_in_eid(ARGS_FROMSTRUCT) { 113 dns_rdata_in_eid_t *eid = source; 114 115 REQUIRE(type == dns_rdatatype_eid); 116 REQUIRE(rdclass == dns_rdataclass_in); 117 REQUIRE(eid != NULL); 118 REQUIRE(eid->common.rdtype == type); 119 REQUIRE(eid->common.rdclass == rdclass); 120 REQUIRE(eid->eid != NULL || eid->eid_len == 0); 121 122 UNUSED(type); 123 UNUSED(rdclass); 124 125 return mem_tobuffer(target, eid->eid, eid->eid_len); 126 } 127 128 static isc_result_t 129 tostruct_in_eid(ARGS_TOSTRUCT) { 130 dns_rdata_in_eid_t *eid = target; 131 isc_region_t r; 132 133 REQUIRE(rdata->type == dns_rdatatype_eid); 134 REQUIRE(rdata->rdclass == dns_rdataclass_in); 135 REQUIRE(eid != NULL); 136 REQUIRE(rdata->length != 0); 137 138 DNS_RDATACOMMON_INIT(eid, rdata->type, rdata->rdclass); 139 140 dns_rdata_toregion(rdata, &r); 141 eid->eid_len = r.length; 142 eid->eid = mem_maybedup(mctx, r.base, r.length); 143 eid->mctx = mctx; 144 return ISC_R_SUCCESS; 145 } 146 147 static void 148 freestruct_in_eid(ARGS_FREESTRUCT) { 149 dns_rdata_in_eid_t *eid = source; 150 151 REQUIRE(eid != NULL); 152 REQUIRE(eid->common.rdclass == dns_rdataclass_in); 153 REQUIRE(eid->common.rdtype == dns_rdatatype_eid); 154 155 if (eid->mctx == NULL) { 156 return; 157 } 158 159 if (eid->eid != NULL) { 160 isc_mem_free(eid->mctx, eid->eid); 161 } 162 eid->mctx = NULL; 163 } 164 165 static isc_result_t 166 additionaldata_in_eid(ARGS_ADDLDATA) { 167 REQUIRE(rdata->type == dns_rdatatype_eid); 168 REQUIRE(rdata->rdclass == dns_rdataclass_in); 169 170 UNUSED(rdata); 171 UNUSED(owner); 172 UNUSED(add); 173 UNUSED(arg); 174 175 return ISC_R_SUCCESS; 176 } 177 178 static isc_result_t 179 digest_in_eid(ARGS_DIGEST) { 180 isc_region_t r; 181 182 REQUIRE(rdata->type == dns_rdatatype_eid); 183 REQUIRE(rdata->rdclass == dns_rdataclass_in); 184 185 dns_rdata_toregion(rdata, &r); 186 187 return (digest)(arg, &r); 188 } 189 190 static bool 191 checkowner_in_eid(ARGS_CHECKOWNER) { 192 REQUIRE(type == dns_rdatatype_eid); 193 REQUIRE(rdclass == dns_rdataclass_in); 194 195 UNUSED(name); 196 UNUSED(type); 197 UNUSED(rdclass); 198 UNUSED(wildcard); 199 200 return true; 201 } 202 203 static bool 204 checknames_in_eid(ARGS_CHECKNAMES) { 205 REQUIRE(rdata->type == dns_rdatatype_eid); 206 REQUIRE(rdata->rdclass == dns_rdataclass_in); 207 208 UNUSED(rdata); 209 UNUSED(owner); 210 UNUSED(bad); 211 212 return true; 213 } 214 215 static int 216 casecompare_in_eid(ARGS_COMPARE) { 217 return compare_in_eid(rdata1, rdata2); 218 } 219 220 #endif /* RDATA_IN_1_EID_31_C */ 221