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