xref: /netbsd-src/external/mpl/dhcp/bind/dist/lib/dns/rdata/generic/ta_32768.c (revision 4afad4b7fa6d4a0d3dedf41d1587a7250710ae54)
1 /*	$NetBSD: ta_32768.c,v 1.1 2024/02/18 20:57:45 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
fromtext_ta(ARGS_FROMTEXT)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
totext_ta(ARGS_TOTEXT)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
fromwire_ta(ARGS_FROMWIRE)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
towire_ta(ARGS_TOWIRE)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
compare_ta(ARGS_COMPARE)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
fromstruct_ta(ARGS_FROMSTRUCT)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
tostruct_ta(ARGS_TOSTRUCT)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
freestruct_ta(ARGS_FREESTRUCT)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
additionaldata_ta(ARGS_ADDLDATA)115 additionaldata_ta(ARGS_ADDLDATA) {
116 	REQUIRE(rdata->type == dns_rdatatype_ta);
117 
118 	UNUSED(rdata);
119 	UNUSED(add);
120 	UNUSED(arg);
121 
122 	return (ISC_R_SUCCESS);
123 }
124 
125 static isc_result_t
digest_ta(ARGS_DIGEST)126 digest_ta(ARGS_DIGEST) {
127 	isc_region_t r;
128 
129 	REQUIRE(rdata->type == dns_rdatatype_ta);
130 
131 	dns_rdata_toregion(rdata, &r);
132 
133 	return ((digest)(arg, &r));
134 }
135 
136 static bool
checkowner_ta(ARGS_CHECKOWNER)137 checkowner_ta(ARGS_CHECKOWNER) {
138 	REQUIRE(type == dns_rdatatype_ta);
139 
140 	UNUSED(name);
141 	UNUSED(type);
142 	UNUSED(rdclass);
143 	UNUSED(wildcard);
144 
145 	return (true);
146 }
147 
148 static bool
checknames_ta(ARGS_CHECKNAMES)149 checknames_ta(ARGS_CHECKNAMES) {
150 	REQUIRE(rdata->type == dns_rdatatype_ta);
151 
152 	UNUSED(rdata);
153 	UNUSED(owner);
154 	UNUSED(bad);
155 
156 	return (true);
157 }
158 
159 static int
casecompare_ta(ARGS_COMPARE)160 casecompare_ta(ARGS_COMPARE) {
161 	return (compare_ta(rdata1, rdata2));
162 }
163 
164 #endif /* RDATA_GENERIC_TA_32768_C */
165