1 /* $NetBSD: null_10.c,v 1.8 2024/02/21 22:52:13 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_NULL_10_C 17 #define RDATA_GENERIC_NULL_10_C 18 19 #define RRTYPE_NULL_ATTRIBUTES (0) 20 21 static isc_result_t 22 fromtext_null(ARGS_FROMTEXT) { 23 REQUIRE(type == dns_rdatatype_null); 24 25 UNUSED(rdclass); 26 UNUSED(type); 27 UNUSED(lexer); 28 UNUSED(origin); 29 UNUSED(options); 30 UNUSED(target); 31 UNUSED(callbacks); 32 33 return (DNS_R_SYNTAX); 34 } 35 36 static isc_result_t 37 totext_null(ARGS_TOTEXT) { 38 REQUIRE(rdata->type == dns_rdatatype_null); 39 40 return (unknown_totext(rdata, tctx, target)); 41 } 42 43 static isc_result_t 44 fromwire_null(ARGS_FROMWIRE) { 45 isc_region_t sr; 46 47 REQUIRE(type == dns_rdatatype_null); 48 49 UNUSED(type); 50 UNUSED(rdclass); 51 UNUSED(dctx); 52 UNUSED(options); 53 54 isc_buffer_activeregion(source, &sr); 55 isc_buffer_forward(source, sr.length); 56 return (mem_tobuffer(target, sr.base, sr.length)); 57 } 58 59 static isc_result_t 60 towire_null(ARGS_TOWIRE) { 61 REQUIRE(rdata->type == dns_rdatatype_null); 62 63 UNUSED(cctx); 64 65 return (mem_tobuffer(target, rdata->data, rdata->length)); 66 } 67 68 static int 69 compare_null(ARGS_COMPARE) { 70 isc_region_t r1; 71 isc_region_t r2; 72 73 REQUIRE(rdata1->type == rdata2->type); 74 REQUIRE(rdata1->rdclass == rdata2->rdclass); 75 REQUIRE(rdata1->type == dns_rdatatype_null); 76 77 dns_rdata_toregion(rdata1, &r1); 78 dns_rdata_toregion(rdata2, &r2); 79 return (isc_region_compare(&r1, &r2)); 80 } 81 82 static isc_result_t 83 fromstruct_null(ARGS_FROMSTRUCT) { 84 dns_rdata_null_t *null = source; 85 86 REQUIRE(type == dns_rdatatype_null); 87 REQUIRE(null != NULL); 88 REQUIRE(null->common.rdtype == type); 89 REQUIRE(null->common.rdclass == rdclass); 90 REQUIRE(null->data != NULL || null->length == 0); 91 92 UNUSED(type); 93 UNUSED(rdclass); 94 95 return (mem_tobuffer(target, null->data, null->length)); 96 } 97 98 static isc_result_t 99 tostruct_null(ARGS_TOSTRUCT) { 100 dns_rdata_null_t *null = target; 101 isc_region_t r; 102 103 REQUIRE(rdata->type == dns_rdatatype_null); 104 REQUIRE(null != NULL); 105 106 null->common.rdclass = rdata->rdclass; 107 null->common.rdtype = rdata->type; 108 ISC_LINK_INIT(&null->common, link); 109 110 dns_rdata_toregion(rdata, &r); 111 null->length = r.length; 112 null->data = mem_maybedup(mctx, r.base, r.length); 113 if (null->data == NULL) { 114 return (ISC_R_NOMEMORY); 115 } 116 117 null->mctx = mctx; 118 return (ISC_R_SUCCESS); 119 } 120 121 static void 122 freestruct_null(ARGS_FREESTRUCT) { 123 dns_rdata_null_t *null = source; 124 125 REQUIRE(null != NULL); 126 REQUIRE(null->common.rdtype == dns_rdatatype_null); 127 128 if (null->mctx == NULL) { 129 return; 130 } 131 132 if (null->data != NULL) { 133 isc_mem_free(null->mctx, null->data); 134 } 135 null->mctx = NULL; 136 } 137 138 static isc_result_t 139 additionaldata_null(ARGS_ADDLDATA) { 140 REQUIRE(rdata->type == dns_rdatatype_null); 141 142 UNUSED(rdata); 143 UNUSED(owner); 144 UNUSED(add); 145 UNUSED(arg); 146 147 return (ISC_R_SUCCESS); 148 } 149 150 static isc_result_t 151 digest_null(ARGS_DIGEST) { 152 isc_region_t r; 153 154 REQUIRE(rdata->type == dns_rdatatype_null); 155 156 dns_rdata_toregion(rdata, &r); 157 158 return ((digest)(arg, &r)); 159 } 160 161 static bool 162 checkowner_null(ARGS_CHECKOWNER) { 163 REQUIRE(type == dns_rdatatype_null); 164 165 UNUSED(name); 166 UNUSED(type); 167 UNUSED(rdclass); 168 UNUSED(wildcard); 169 170 return (true); 171 } 172 173 static bool 174 checknames_null(ARGS_CHECKNAMES) { 175 REQUIRE(rdata->type == dns_rdatatype_null); 176 177 UNUSED(rdata); 178 UNUSED(owner); 179 UNUSED(bad); 180 181 return (true); 182 } 183 184 static int 185 casecompare_null(ARGS_COMPARE) { 186 return (compare_null(rdata1, rdata2)); 187 } 188 189 #endif /* RDATA_GENERIC_NULL_10_C */ 190