xref: /netbsd-src/external/mpl/bind/dist/lib/dns/rdata/generic/null_10.c (revision bcda20f65a8566e103791ec395f7f499ef322704)
1 /*	$NetBSD: null_10.c,v 1.9 2025/01/26 16:25:32 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 
53 	isc_buffer_activeregion(source, &sr);
54 	isc_buffer_forward(source, sr.length);
55 	return mem_tobuffer(target, sr.base, sr.length);
56 }
57 
58 static isc_result_t
59 towire_null(ARGS_TOWIRE) {
60 	REQUIRE(rdata->type == dns_rdatatype_null);
61 
62 	UNUSED(cctx);
63 
64 	return mem_tobuffer(target, rdata->data, rdata->length);
65 }
66 
67 static int
68 compare_null(ARGS_COMPARE) {
69 	isc_region_t r1;
70 	isc_region_t r2;
71 
72 	REQUIRE(rdata1->type == rdata2->type);
73 	REQUIRE(rdata1->rdclass == rdata2->rdclass);
74 	REQUIRE(rdata1->type == dns_rdatatype_null);
75 
76 	dns_rdata_toregion(rdata1, &r1);
77 	dns_rdata_toregion(rdata2, &r2);
78 	return isc_region_compare(&r1, &r2);
79 }
80 
81 static isc_result_t
82 fromstruct_null(ARGS_FROMSTRUCT) {
83 	dns_rdata_null_t *null = source;
84 
85 	REQUIRE(type == dns_rdatatype_null);
86 	REQUIRE(null != NULL);
87 	REQUIRE(null->common.rdtype == type);
88 	REQUIRE(null->common.rdclass == rdclass);
89 	REQUIRE(null->data != NULL || null->length == 0);
90 
91 	UNUSED(type);
92 	UNUSED(rdclass);
93 
94 	return mem_tobuffer(target, null->data, null->length);
95 }
96 
97 static isc_result_t
98 tostruct_null(ARGS_TOSTRUCT) {
99 	dns_rdata_null_t *null = target;
100 	isc_region_t r;
101 
102 	REQUIRE(rdata->type == dns_rdatatype_null);
103 	REQUIRE(null != NULL);
104 
105 	null->common.rdclass = rdata->rdclass;
106 	null->common.rdtype = rdata->type;
107 	ISC_LINK_INIT(&null->common, link);
108 
109 	dns_rdata_toregion(rdata, &r);
110 	null->length = r.length;
111 	null->data = mem_maybedup(mctx, r.base, r.length);
112 	null->mctx = mctx;
113 	return ISC_R_SUCCESS;
114 }
115 
116 static void
117 freestruct_null(ARGS_FREESTRUCT) {
118 	dns_rdata_null_t *null = source;
119 
120 	REQUIRE(null != NULL);
121 	REQUIRE(null->common.rdtype == dns_rdatatype_null);
122 
123 	if (null->mctx == NULL) {
124 		return;
125 	}
126 
127 	if (null->data != NULL) {
128 		isc_mem_free(null->mctx, null->data);
129 	}
130 	null->mctx = NULL;
131 }
132 
133 static isc_result_t
134 additionaldata_null(ARGS_ADDLDATA) {
135 	REQUIRE(rdata->type == dns_rdatatype_null);
136 
137 	UNUSED(rdata);
138 	UNUSED(owner);
139 	UNUSED(add);
140 	UNUSED(arg);
141 
142 	return ISC_R_SUCCESS;
143 }
144 
145 static isc_result_t
146 digest_null(ARGS_DIGEST) {
147 	isc_region_t r;
148 
149 	REQUIRE(rdata->type == dns_rdatatype_null);
150 
151 	dns_rdata_toregion(rdata, &r);
152 
153 	return (digest)(arg, &r);
154 }
155 
156 static bool
157 checkowner_null(ARGS_CHECKOWNER) {
158 	REQUIRE(type == dns_rdatatype_null);
159 
160 	UNUSED(name);
161 	UNUSED(type);
162 	UNUSED(rdclass);
163 	UNUSED(wildcard);
164 
165 	return true;
166 }
167 
168 static bool
169 checknames_null(ARGS_CHECKNAMES) {
170 	REQUIRE(rdata->type == dns_rdatatype_null);
171 
172 	UNUSED(rdata);
173 	UNUSED(owner);
174 	UNUSED(bad);
175 
176 	return true;
177 }
178 
179 static int
180 casecompare_null(ARGS_COMPARE) {
181 	return compare_null(rdata1, rdata2);
182 }
183 
184 #endif /* RDATA_GENERIC_NULL_10_C */
185