/src/bind9/lib/dns/rdata/generic/talink_58.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright (C) Internet Systems Consortium, Inc. ("ISC") |
3 | | * |
4 | | * SPDX-License-Identifier: MPL-2.0 |
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 | | #ifndef RDATA_GENERIC_TALINK_58_C |
15 | | #define RDATA_GENERIC_TALINK_58_C |
16 | | |
17 | 14.9k | #define RRTYPE_TALINK_ATTRIBUTES 0 |
18 | | |
19 | | static isc_result_t |
20 | 2.41k | fromtext_talink(ARGS_FROMTEXT) { |
21 | 2.41k | isc_token_t token; |
22 | 2.41k | isc_buffer_t buffer; |
23 | 2.41k | int i; |
24 | | |
25 | 2.41k | REQUIRE(type == dns_rdatatype_talink); |
26 | | |
27 | 2.41k | UNUSED(type); |
28 | 2.41k | UNUSED(rdclass); |
29 | 2.41k | UNUSED(callbacks); |
30 | | |
31 | 2.41k | if (origin == NULL) { |
32 | 9 | origin = dns_rootname; |
33 | 9 | } |
34 | | |
35 | 7.21k | for (i = 0; i < 2; i++) { |
36 | 4.81k | RETERR(isc_lex_getmastertoken(lexer, &token, |
37 | 4.81k | isc_tokentype_string, false)); |
38 | | |
39 | 4.80k | buffer_fromregion(&buffer, &token.value.as_region); |
40 | 4.80k | RETTOK(dns_name_wirefromtext(&buffer, origin, options, target)); |
41 | 4.80k | } |
42 | | |
43 | 2.40k | return ISC_R_SUCCESS; |
44 | 2.41k | } |
45 | | |
46 | | static isc_result_t |
47 | 2.53k | totext_talink(ARGS_TOTEXT) { |
48 | 2.53k | isc_region_t dregion; |
49 | 2.53k | dns_name_t prev; |
50 | 2.53k | dns_name_t next; |
51 | 2.53k | dns_name_t prefix; |
52 | 2.53k | unsigned int opts; |
53 | | |
54 | 2.53k | REQUIRE(rdata->type == dns_rdatatype_talink); |
55 | 2.53k | REQUIRE(rdata->length != 0); |
56 | | |
57 | 2.53k | dns_name_init(&prev); |
58 | 2.53k | dns_name_init(&next); |
59 | 2.53k | dns_name_init(&prefix); |
60 | | |
61 | 2.53k | dns_rdata_toregion(rdata, &dregion); |
62 | | |
63 | 2.53k | dns_name_fromregion(&prev, &dregion); |
64 | 2.53k | isc_region_consume(&dregion, name_length(&prev)); |
65 | | |
66 | 2.53k | dns_name_fromregion(&next, &dregion); |
67 | 2.53k | isc_region_consume(&dregion, name_length(&next)); |
68 | | |
69 | 2.53k | opts = name_prefix(&prev, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT |
70 | 2.53k | : 0; |
71 | 2.53k | RETERR(dns_name_totext(&prefix, opts, target)); |
72 | | |
73 | 2.53k | RETERR(str_totext(" ", target)); |
74 | | |
75 | 2.53k | opts = name_prefix(&next, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT |
76 | 2.53k | : 0; |
77 | 2.53k | return dns_name_totext(&prefix, opts, target); |
78 | 2.53k | } |
79 | | |
80 | | static isc_result_t |
81 | 3.26k | fromwire_talink(ARGS_FROMWIRE) { |
82 | 3.26k | dns_name_t prev; |
83 | 3.26k | dns_name_t next; |
84 | | |
85 | 3.26k | REQUIRE(type == dns_rdatatype_talink); |
86 | | |
87 | 3.26k | UNUSED(type); |
88 | 3.26k | UNUSED(rdclass); |
89 | | |
90 | 3.26k | dctx = dns_decompress_setpermitted(dctx, false); |
91 | | |
92 | 3.26k | dns_name_init(&prev); |
93 | 3.26k | dns_name_init(&next); |
94 | | |
95 | 3.26k | RETERR(dns_name_fromwire(&prev, source, dctx, target)); |
96 | 3.02k | return dns_name_fromwire(&next, source, dctx, target); |
97 | 3.26k | } |
98 | | |
99 | | static isc_result_t |
100 | 1.27k | towire_talink(ARGS_TOWIRE) { |
101 | 1.27k | isc_region_t sregion; |
102 | 1.27k | dns_name_t prev; |
103 | 1.27k | dns_name_t next; |
104 | | |
105 | 1.27k | REQUIRE(rdata->type == dns_rdatatype_talink); |
106 | 1.27k | REQUIRE(rdata->length != 0); |
107 | | |
108 | 1.27k | dns_compress_setpermitted(cctx, false); |
109 | | |
110 | 1.27k | dns_name_init(&prev); |
111 | 1.27k | dns_name_init(&next); |
112 | | |
113 | 1.27k | dns_rdata_toregion(rdata, &sregion); |
114 | | |
115 | 1.27k | dns_name_fromregion(&prev, &sregion); |
116 | 1.27k | isc_region_consume(&sregion, name_length(&prev)); |
117 | 1.27k | RETERR(dns_name_towire(&prev, cctx, target)); |
118 | | |
119 | 1.26k | dns_name_fromregion(&next, &sregion); |
120 | 1.26k | isc_region_consume(&sregion, name_length(&next)); |
121 | 1.26k | return dns_name_towire(&next, cctx, target); |
122 | 1.27k | } |
123 | | |
124 | | static int |
125 | 1.22M | compare_talink(ARGS_COMPARE) { |
126 | 1.22M | isc_region_t region1; |
127 | 1.22M | isc_region_t region2; |
128 | | |
129 | 1.22M | REQUIRE(rdata1->type == rdata2->type); |
130 | 1.22M | REQUIRE(rdata1->rdclass == rdata2->rdclass); |
131 | 1.22M | REQUIRE(rdata1->type == dns_rdatatype_talink); |
132 | 1.22M | REQUIRE(rdata1->length != 0); |
133 | 1.22M | REQUIRE(rdata2->length != 0); |
134 | | |
135 | 1.22M | dns_rdata_toregion(rdata1, ®ion1); |
136 | 1.22M | dns_rdata_toregion(rdata2, ®ion2); |
137 | 1.22M | return isc_region_compare(®ion1, ®ion2); |
138 | 1.22M | } |
139 | | |
140 | | static isc_result_t |
141 | 0 | fromstruct_talink(ARGS_FROMSTRUCT) { |
142 | 0 | dns_rdata_talink_t *talink = source; |
143 | 0 | isc_region_t region; |
144 | |
|
145 | 0 | REQUIRE(type == dns_rdatatype_talink); |
146 | 0 | REQUIRE(talink != NULL); |
147 | 0 | REQUIRE(talink->common.rdtype == type); |
148 | 0 | REQUIRE(talink->common.rdclass == rdclass); |
149 | |
|
150 | 0 | UNUSED(type); |
151 | 0 | UNUSED(rdclass); |
152 | |
|
153 | 0 | dns_name_toregion(&talink->prev, ®ion); |
154 | 0 | RETERR(isc_buffer_copyregion(target, ®ion)); |
155 | 0 | dns_name_toregion(&talink->next, ®ion); |
156 | 0 | return isc_buffer_copyregion(target, ®ion); |
157 | 0 | } |
158 | | |
159 | | static isc_result_t |
160 | 0 | tostruct_talink(ARGS_TOSTRUCT) { |
161 | 0 | isc_region_t region; |
162 | 0 | dns_rdata_talink_t *talink = target; |
163 | 0 | dns_name_t name; |
164 | |
|
165 | 0 | REQUIRE(rdata->type == dns_rdatatype_talink); |
166 | 0 | REQUIRE(talink != NULL); |
167 | 0 | REQUIRE(rdata->length != 0); |
168 | |
|
169 | 0 | DNS_RDATACOMMON_INIT(talink, rdata->type, rdata->rdclass); |
170 | |
|
171 | 0 | dns_rdata_toregion(rdata, ®ion); |
172 | |
|
173 | 0 | dns_name_init(&name); |
174 | 0 | dns_name_fromregion(&name, ®ion); |
175 | 0 | isc_region_consume(®ion, name_length(&name)); |
176 | 0 | dns_name_init(&talink->prev); |
177 | 0 | name_duporclone(&name, mctx, &talink->prev); |
178 | |
|
179 | 0 | dns_name_fromregion(&name, ®ion); |
180 | 0 | isc_region_consume(®ion, name_length(&name)); |
181 | 0 | dns_name_init(&talink->next); |
182 | 0 | name_duporclone(&name, mctx, &talink->next); |
183 | |
|
184 | 0 | talink->mctx = mctx; |
185 | 0 | return ISC_R_SUCCESS; |
186 | 0 | } |
187 | | |
188 | | static void |
189 | 0 | freestruct_talink(ARGS_FREESTRUCT) { |
190 | 0 | dns_rdata_talink_t *talink = source; |
191 | |
|
192 | 0 | REQUIRE(talink != NULL); |
193 | 0 | REQUIRE(talink->common.rdtype == dns_rdatatype_talink); |
194 | |
|
195 | 0 | if (talink->mctx == NULL) { |
196 | 0 | return; |
197 | 0 | } |
198 | | |
199 | 0 | dns_name_free(&talink->prev, talink->mctx); |
200 | 0 | dns_name_free(&talink->next, talink->mctx); |
201 | 0 | talink->mctx = NULL; |
202 | 0 | } |
203 | | |
204 | | static isc_result_t |
205 | 0 | additionaldata_talink(ARGS_ADDLDATA) { |
206 | 0 | REQUIRE(rdata->type == dns_rdatatype_talink); |
207 | |
|
208 | 0 | UNUSED(rdata); |
209 | 0 | UNUSED(owner); |
210 | 0 | UNUSED(add); |
211 | 0 | UNUSED(arg); |
212 | |
|
213 | 0 | return ISC_R_SUCCESS; |
214 | 0 | } |
215 | | |
216 | | static isc_result_t |
217 | 0 | digest_talink(ARGS_DIGEST) { |
218 | 0 | isc_region_t r; |
219 | |
|
220 | 0 | REQUIRE(rdata->type == dns_rdatatype_talink); |
221 | |
|
222 | 0 | dns_rdata_toregion(rdata, &r); |
223 | 0 | return (digest)(arg, &r); |
224 | 0 | } |
225 | | |
226 | | static bool |
227 | 0 | checkowner_talink(ARGS_CHECKOWNER) { |
228 | 0 | REQUIRE(type == dns_rdatatype_talink); |
229 | |
|
230 | 0 | UNUSED(name); |
231 | 0 | UNUSED(type); |
232 | 0 | UNUSED(rdclass); |
233 | 0 | UNUSED(wildcard); |
234 | |
|
235 | 0 | return true; |
236 | 0 | } |
237 | | |
238 | | static bool |
239 | 0 | checknames_talink(ARGS_CHECKNAMES) { |
240 | 0 | REQUIRE(rdata->type == dns_rdatatype_talink); |
241 | |
|
242 | 0 | UNUSED(bad); |
243 | 0 | UNUSED(owner); |
244 | |
|
245 | 0 | return true; |
246 | 0 | } |
247 | | |
248 | | static int |
249 | 0 | casecompare_talink(ARGS_COMPARE) { |
250 | 0 | return compare_talink(rdata1, rdata2); |
251 | 0 | } |
252 | | |
253 | | #endif /* RDATA_GENERIC_TALINK_58_C */ |