xref: /netbsd-src/external/mpl/bind/dist/lib/dns/rdata/generic/ninfo_56.c (revision bcda20f65a8566e103791ec395f7f499ef322704)
1 /*	$NetBSD: ninfo_56.c,v 1.10 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_NINFO_56_C
17 #define RDATA_GENERIC_NINFO_56_C
18 
19 #define RRTYPE_NINFO_ATTRIBUTES (0)
20 
21 static isc_result_t
22 fromtext_ninfo(ARGS_FROMTEXT) {
23 	REQUIRE(type == dns_rdatatype_ninfo);
24 
25 	return generic_fromtext_txt(CALL_FROMTEXT);
26 }
27 
28 static isc_result_t
29 totext_ninfo(ARGS_TOTEXT) {
30 	REQUIRE(rdata != NULL);
31 	REQUIRE(rdata->type == dns_rdatatype_ninfo);
32 
33 	return generic_totext_txt(CALL_TOTEXT);
34 }
35 
36 static isc_result_t
37 fromwire_ninfo(ARGS_FROMWIRE) {
38 	REQUIRE(type == dns_rdatatype_ninfo);
39 
40 	return generic_fromwire_txt(CALL_FROMWIRE);
41 }
42 
43 static isc_result_t
44 towire_ninfo(ARGS_TOWIRE) {
45 	REQUIRE(rdata->type == dns_rdatatype_ninfo);
46 
47 	UNUSED(cctx);
48 
49 	return mem_tobuffer(target, rdata->data, rdata->length);
50 }
51 
52 static int
53 compare_ninfo(ARGS_COMPARE) {
54 	isc_region_t r1;
55 	isc_region_t r2;
56 
57 	REQUIRE(rdata1->type == rdata2->type);
58 	REQUIRE(rdata1->rdclass == rdata2->rdclass);
59 	REQUIRE(rdata1->type == dns_rdatatype_ninfo);
60 
61 	dns_rdata_toregion(rdata1, &r1);
62 	dns_rdata_toregion(rdata2, &r2);
63 	return isc_region_compare(&r1, &r2);
64 }
65 
66 static isc_result_t
67 fromstruct_ninfo(ARGS_FROMSTRUCT) {
68 	REQUIRE(type == dns_rdatatype_ninfo);
69 
70 	return generic_fromstruct_txt(CALL_FROMSTRUCT);
71 }
72 
73 static isc_result_t
74 tostruct_ninfo(ARGS_TOSTRUCT) {
75 	dns_rdata_ninfo_t *ninfo = target;
76 
77 	REQUIRE(rdata->type == dns_rdatatype_ninfo);
78 	REQUIRE(ninfo != NULL);
79 
80 	ninfo->common.rdclass = rdata->rdclass;
81 	ninfo->common.rdtype = rdata->type;
82 	ISC_LINK_INIT(&ninfo->common, link);
83 
84 	return generic_tostruct_txt(CALL_TOSTRUCT);
85 }
86 
87 static void
88 freestruct_ninfo(ARGS_FREESTRUCT) {
89 	dns_rdata_ninfo_t *ninfo = source;
90 
91 	REQUIRE(ninfo != NULL);
92 	REQUIRE(ninfo->common.rdtype == dns_rdatatype_ninfo);
93 
94 	generic_freestruct_txt(source);
95 }
96 
97 static isc_result_t
98 additionaldata_ninfo(ARGS_ADDLDATA) {
99 	REQUIRE(rdata->type == dns_rdatatype_ninfo);
100 
101 	UNUSED(rdata);
102 	UNUSED(owner);
103 	UNUSED(add);
104 	UNUSED(arg);
105 
106 	return ISC_R_SUCCESS;
107 }
108 
109 static isc_result_t
110 digest_ninfo(ARGS_DIGEST) {
111 	isc_region_t r;
112 
113 	REQUIRE(rdata->type == dns_rdatatype_ninfo);
114 
115 	dns_rdata_toregion(rdata, &r);
116 
117 	return (digest)(arg, &r);
118 }
119 
120 static bool
121 checkowner_ninfo(ARGS_CHECKOWNER) {
122 	REQUIRE(type == dns_rdatatype_ninfo);
123 
124 	UNUSED(name);
125 	UNUSED(type);
126 	UNUSED(rdclass);
127 	UNUSED(wildcard);
128 
129 	return true;
130 }
131 
132 static bool
133 checknames_ninfo(ARGS_CHECKNAMES) {
134 	REQUIRE(rdata->type == dns_rdatatype_ninfo);
135 
136 	UNUSED(rdata);
137 	UNUSED(owner);
138 	UNUSED(bad);
139 
140 	return true;
141 }
142 
143 static int
144 casecompare_ninfo(ARGS_COMPARE) {
145 	return compare_ninfo(rdata1, rdata2);
146 }
147 
148 isc_result_t
149 dns_rdata_ninfo_first(dns_rdata_ninfo_t *ninfo) {
150 	REQUIRE(ninfo != NULL);
151 	REQUIRE(ninfo->common.rdtype == dns_rdatatype_ninfo);
152 
153 	return generic_txt_first(ninfo);
154 }
155 
156 isc_result_t
157 dns_rdata_ninfo_next(dns_rdata_ninfo_t *ninfo) {
158 	REQUIRE(ninfo != NULL);
159 	REQUIRE(ninfo->common.rdtype == dns_rdatatype_ninfo);
160 
161 	return generic_txt_next(ninfo);
162 }
163 
164 isc_result_t
165 dns_rdata_ninfo_current(dns_rdata_ninfo_t *ninfo,
166 			dns_rdata_ninfo_string_t *string) {
167 	REQUIRE(ninfo != NULL);
168 	REQUIRE(ninfo->common.rdtype == dns_rdatatype_ninfo);
169 
170 	return generic_txt_current(ninfo, string);
171 }
172 #endif /* RDATA_GENERIC_NINFO_56_C */
173