xref: /netbsd-src/external/mpl/bind/dist/lib/dns/rdata/generic/ta_32768.c (revision bcda20f65a8566e103791ec395f7f499ef322704)
1 /*	$NetBSD: ta_32768.c,v 1.10 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 /* http://www.watson.org/~weiler/INI1999-19.pdf */
17 
18 #ifndef RDATA_GENERIC_TA_32768_C
19 #define RDATA_GENERIC_TA_32768_C
20 
21 #define RRTYPE_TA_ATTRIBUTES 0
22 
23 static isc_result_t
24 fromtext_ta(ARGS_FROMTEXT) {
25 	REQUIRE(type == dns_rdatatype_ta);
26 
27 	return generic_fromtext_ds(CALL_FROMTEXT);
28 }
29 
30 static isc_result_t
31 totext_ta(ARGS_TOTEXT) {
32 	REQUIRE(rdata->type == dns_rdatatype_ta);
33 
34 	return generic_totext_ds(CALL_TOTEXT);
35 }
36 
37 static isc_result_t
38 fromwire_ta(ARGS_FROMWIRE) {
39 	REQUIRE(type == dns_rdatatype_ta);
40 
41 	return generic_fromwire_ds(CALL_FROMWIRE);
42 }
43 
44 static isc_result_t
45 towire_ta(ARGS_TOWIRE) {
46 	isc_region_t sr;
47 
48 	REQUIRE(rdata->type == dns_rdatatype_ta);
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_ta(ARGS_COMPARE) {
59 	isc_region_t r1;
60 	isc_region_t r2;
61 
62 	REQUIRE(rdata1->type == rdata2->type);
63 	REQUIRE(rdata1->rdclass == rdata2->rdclass);
64 	REQUIRE(rdata1->type == dns_rdatatype_ta);
65 	REQUIRE(rdata1->length != 0);
66 	REQUIRE(rdata2->length != 0);
67 
68 	dns_rdata_toregion(rdata1, &r1);
69 	dns_rdata_toregion(rdata2, &r2);
70 	return isc_region_compare(&r1, &r2);
71 }
72 
73 static isc_result_t
74 fromstruct_ta(ARGS_FROMSTRUCT) {
75 	REQUIRE(type == dns_rdatatype_ta);
76 
77 	return generic_fromstruct_ds(CALL_FROMSTRUCT);
78 }
79 
80 static isc_result_t
81 tostruct_ta(ARGS_TOSTRUCT) {
82 	dns_rdata_ds_t *ds = target;
83 
84 	REQUIRE(rdata->type == dns_rdatatype_ta);
85 	REQUIRE(ds != NULL);
86 
87 	/*
88 	 * Checked by generic_tostruct_ds().
89 	 */
90 	ds->common.rdclass = rdata->rdclass;
91 	ds->common.rdtype = rdata->type;
92 	ISC_LINK_INIT(&ds->common, link);
93 
94 	return generic_tostruct_ds(CALL_TOSTRUCT);
95 }
96 
97 static void
98 freestruct_ta(ARGS_FREESTRUCT) {
99 	dns_rdata_ta_t *ds = source;
100 
101 	REQUIRE(ds != NULL);
102 	REQUIRE(ds->common.rdtype == dns_rdatatype_ta);
103 
104 	if (ds->mctx == NULL) {
105 		return;
106 	}
107 
108 	if (ds->digest != NULL) {
109 		isc_mem_free(ds->mctx, ds->digest);
110 	}
111 	ds->mctx = NULL;
112 }
113 
114 static isc_result_t
115 additionaldata_ta(ARGS_ADDLDATA) {
116 	REQUIRE(rdata->type == dns_rdatatype_ta);
117 
118 	UNUSED(rdata);
119 	UNUSED(owner);
120 	UNUSED(add);
121 	UNUSED(arg);
122 
123 	return ISC_R_SUCCESS;
124 }
125 
126 static isc_result_t
127 digest_ta(ARGS_DIGEST) {
128 	isc_region_t r;
129 
130 	REQUIRE(rdata->type == dns_rdatatype_ta);
131 
132 	dns_rdata_toregion(rdata, &r);
133 
134 	return (digest)(arg, &r);
135 }
136 
137 static bool
138 checkowner_ta(ARGS_CHECKOWNER) {
139 	REQUIRE(type == dns_rdatatype_ta);
140 
141 	UNUSED(name);
142 	UNUSED(type);
143 	UNUSED(rdclass);
144 	UNUSED(wildcard);
145 
146 	return true;
147 }
148 
149 static bool
150 checknames_ta(ARGS_CHECKNAMES) {
151 	REQUIRE(rdata->type == dns_rdatatype_ta);
152 
153 	UNUSED(rdata);
154 	UNUSED(owner);
155 	UNUSED(bad);
156 
157 	return true;
158 }
159 
160 static int
161 casecompare_ta(ARGS_COMPARE) {
162 	return compare_ta(rdata1, rdata2);
163 }
164 
165 #endif /* RDATA_GENERIC_TA_32768_C */
166