xref: /netbsd-src/external/mpl/bind/dist/lib/dns/rdata/generic/ta_32768.c (revision e670fd5c413e99c2f6a37901bb21c537fcd322d2)
1 /*	$NetBSD: ta_32768.c,v 1.6 2021/02/19 16:42:17 christos Exp $	*/
2 
3 /*
4  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
5  *
6  * This Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0. If a copy of the MPL was not distributed with this
8  * file, you can obtain one at https://mozilla.org/MPL/2.0/.
9  *
10  * See the COPYRIGHT file distributed with this work for additional
11  * information regarding copyright ownership.
12  */
13 
14 /* http://www.watson.org/~weiler/INI1999-19.pdf */
15 
16 #ifndef RDATA_GENERIC_TA_32768_C
17 #define RDATA_GENERIC_TA_32768_C
18 
19 #define RRTYPE_TA_ATTRIBUTES 0
20 
21 static inline isc_result_t
22 fromtext_ta(ARGS_FROMTEXT) {
23 	REQUIRE(type == dns_rdatatype_ta);
24 
25 	return (generic_fromtext_ds(rdclass, type, lexer, origin, options,
26 				    target, callbacks));
27 }
28 
29 static inline isc_result_t
30 totext_ta(ARGS_TOTEXT) {
31 	REQUIRE(rdata->type == dns_rdatatype_ta);
32 
33 	return (generic_totext_ds(rdata, tctx, target));
34 }
35 
36 static inline isc_result_t
37 fromwire_ta(ARGS_FROMWIRE) {
38 	REQUIRE(type == dns_rdatatype_ta);
39 
40 	return (generic_fromwire_ds(rdclass, type, source, dctx, options,
41 				    target));
42 }
43 
44 static inline 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 inline 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 inline isc_result_t
74 fromstruct_ta(ARGS_FROMSTRUCT) {
75 	REQUIRE(type == dns_rdatatype_ta);
76 
77 	return (generic_fromstruct_ds(rdclass, type, source, target));
78 }
79 
80 static inline 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(rdata, target, mctx));
95 }
96 
97 static inline 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 inline isc_result_t
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 inline isc_result_t
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 inline bool
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 inline bool
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 inline int
160 casecompare_ta(ARGS_COMPARE) {
161 	return (compare_ta(rdata1, rdata2));
162 }
163 
164 #endif /* RDATA_GENERIC_TA_32768_C */
165