/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 | 34.4k | #define RRTYPE_TALINK_ATTRIBUTES 0 |
18 | | |
19 | | static isc_result_t |
20 | 9.44k | fromtext_talink(ARGS_FROMTEXT) { |
21 | 9.44k | isc_token_t token; |
22 | 9.44k | isc_buffer_t buffer; |
23 | 9.44k | int i; |
24 | | |
25 | 9.44k | REQUIRE(type == dns_rdatatype_talink); |
26 | | |
27 | 9.44k | UNUSED(type); |
28 | 9.44k | UNUSED(rdclass); |
29 | 9.44k | UNUSED(callbacks); |
30 | | |
31 | 9.44k | if (origin == NULL) { |
32 | 10 | origin = dns_rootname; |
33 | 10 | } |
34 | | |
35 | 28.3k | for (i = 0; i < 2; i++) { |
36 | 18.8k | RETERR(isc_lex_getmastertoken(lexer, &token, |
37 | 18.8k | isc_tokentype_string, false)); |
38 | | |
39 | 18.8k | buffer_fromregion(&buffer, &token.value.as_region); |
40 | 18.8k | RETTOK(dns_name_wirefromtext(&buffer, origin, options, target)); |
41 | 18.8k | } |
42 | | |
43 | 9.42k | return ISC_R_SUCCESS; |
44 | 9.44k | } |
45 | | |
46 | | static isc_result_t |
47 | 4.72k | totext_talink(ARGS_TOTEXT) { |
48 | 4.72k | isc_region_t dregion; |
49 | 4.72k | dns_name_t prev; |
50 | 4.72k | dns_name_t next; |
51 | 4.72k | dns_name_t prefix; |
52 | 4.72k | unsigned int opts; |
53 | | |
54 | 4.72k | REQUIRE(rdata->type == dns_rdatatype_talink); |
55 | 4.72k | REQUIRE(rdata->length != 0); |
56 | | |
57 | 4.72k | dns_name_init(&prev); |
58 | 4.72k | dns_name_init(&next); |
59 | 4.72k | dns_name_init(&prefix); |
60 | | |
61 | 4.72k | dns_rdata_toregion(rdata, &dregion); |
62 | | |
63 | 4.72k | dns_name_fromregion(&prev, &dregion); |
64 | 4.72k | isc_region_consume(&dregion, name_length(&prev)); |
65 | | |
66 | 4.72k | dns_name_fromregion(&next, &dregion); |
67 | 4.72k | isc_region_consume(&dregion, name_length(&next)); |
68 | | |
69 | 4.72k | opts = name_prefix(&prev, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT |
70 | 4.72k | : 0; |
71 | 4.72k | RETERR(dns_name_totext(&prefix, opts, target)); |
72 | | |
73 | 4.72k | RETERR(str_totext(" ", target)); |
74 | | |
75 | 4.72k | opts = name_prefix(&next, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT |
76 | 4.72k | : 0; |
77 | 4.72k | return dns_name_totext(&prefix, opts, target); |
78 | 4.72k | } |
79 | | |
80 | | static isc_result_t |
81 | 5.60k | fromwire_talink(ARGS_FROMWIRE) { |
82 | 5.60k | dns_name_t prev; |
83 | 5.60k | dns_name_t next; |
84 | | |
85 | 5.60k | REQUIRE(type == dns_rdatatype_talink); |
86 | | |
87 | 5.60k | UNUSED(type); |
88 | 5.60k | UNUSED(rdclass); |
89 | | |
90 | 5.60k | dctx = dns_decompress_setpermitted(dctx, false); |
91 | | |
92 | 5.60k | dns_name_init(&prev); |
93 | 5.60k | dns_name_init(&next); |
94 | | |
95 | 5.60k | RETERR(dns_name_fromwire(&prev, source, dctx, target)); |
96 | 5.30k | return dns_name_fromwire(&next, source, dctx, target); |
97 | 5.60k | } |
98 | | |
99 | | static isc_result_t |
100 | 2.54k | towire_talink(ARGS_TOWIRE) { |
101 | 2.54k | isc_region_t sregion; |
102 | 2.54k | dns_name_t prev; |
103 | 2.54k | dns_name_t next; |
104 | | |
105 | 2.54k | REQUIRE(rdata->type == dns_rdatatype_talink); |
106 | 2.54k | REQUIRE(rdata->length != 0); |
107 | | |
108 | 2.54k | dns_compress_setpermitted(cctx, false); |
109 | | |
110 | 2.54k | dns_name_init(&prev); |
111 | 2.54k | dns_name_init(&next); |
112 | | |
113 | 2.54k | dns_rdata_toregion(rdata, &sregion); |
114 | | |
115 | 2.54k | dns_name_fromregion(&prev, &sregion); |
116 | 2.54k | isc_region_consume(&sregion, name_length(&prev)); |
117 | 2.54k | RETERR(dns_name_towire(&prev, cctx, target)); |
118 | | |
119 | 2.53k | dns_name_fromregion(&next, &sregion); |
120 | 2.53k | isc_region_consume(&sregion, name_length(&next)); |
121 | 2.53k | return dns_name_towire(&next, cctx, target); |
122 | 2.54k | } |
123 | | |
124 | | static int |
125 | 12.8k | compare_talink(ARGS_COMPARE) { |
126 | 12.8k | isc_region_t region1; |
127 | 12.8k | isc_region_t region2; |
128 | | |
129 | 12.8k | REQUIRE(rdata1->type == rdata2->type); |
130 | 12.8k | REQUIRE(rdata1->rdclass == rdata2->rdclass); |
131 | 12.8k | REQUIRE(rdata1->type == dns_rdatatype_talink); |
132 | 12.8k | REQUIRE(rdata1->length != 0); |
133 | 12.8k | REQUIRE(rdata2->length != 0); |
134 | | |
135 | 12.8k | dns_rdata_toregion(rdata1, ®ion1); |
136 | 12.8k | dns_rdata_toregion(rdata2, ®ion2); |
137 | 12.8k | return isc_region_compare(®ion1, ®ion2); |
138 | 12.8k | } |
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 | talink->common.rdclass = rdata->rdclass; |
170 | 0 | talink->common.rdtype = rdata->type; |
171 | |
|
172 | 0 | dns_rdata_toregion(rdata, ®ion); |
173 | |
|
174 | 0 | dns_name_init(&name); |
175 | 0 | dns_name_fromregion(&name, ®ion); |
176 | 0 | isc_region_consume(®ion, name_length(&name)); |
177 | 0 | dns_name_init(&talink->prev); |
178 | 0 | name_duporclone(&name, mctx, &talink->prev); |
179 | |
|
180 | 0 | dns_name_fromregion(&name, ®ion); |
181 | 0 | isc_region_consume(®ion, name_length(&name)); |
182 | 0 | dns_name_init(&talink->next); |
183 | 0 | name_duporclone(&name, mctx, &talink->next); |
184 | |
|
185 | 0 | talink->mctx = mctx; |
186 | 0 | return ISC_R_SUCCESS; |
187 | 0 | } |
188 | | |
189 | | static void |
190 | 0 | freestruct_talink(ARGS_FREESTRUCT) { |
191 | 0 | dns_rdata_talink_t *talink = source; |
192 | |
|
193 | 0 | REQUIRE(talink != NULL); |
194 | 0 | REQUIRE(talink->common.rdtype == dns_rdatatype_talink); |
195 | |
|
196 | 0 | if (talink->mctx == NULL) { |
197 | 0 | return; |
198 | 0 | } |
199 | | |
200 | 0 | dns_name_free(&talink->prev, talink->mctx); |
201 | 0 | dns_name_free(&talink->next, talink->mctx); |
202 | 0 | talink->mctx = NULL; |
203 | 0 | } |
204 | | |
205 | | static isc_result_t |
206 | 0 | additionaldata_talink(ARGS_ADDLDATA) { |
207 | 0 | REQUIRE(rdata->type == dns_rdatatype_talink); |
208 | |
|
209 | 0 | UNUSED(rdata); |
210 | 0 | UNUSED(owner); |
211 | 0 | UNUSED(add); |
212 | 0 | UNUSED(arg); |
213 | |
|
214 | 0 | return ISC_R_SUCCESS; |
215 | 0 | } |
216 | | |
217 | | static isc_result_t |
218 | 0 | digest_talink(ARGS_DIGEST) { |
219 | 0 | isc_region_t r; |
220 | |
|
221 | 0 | REQUIRE(rdata->type == dns_rdatatype_talink); |
222 | |
|
223 | 0 | dns_rdata_toregion(rdata, &r); |
224 | 0 | return (digest)(arg, &r); |
225 | 0 | } |
226 | | |
227 | | static bool |
228 | 0 | checkowner_talink(ARGS_CHECKOWNER) { |
229 | 0 | REQUIRE(type == dns_rdatatype_talink); |
230 | |
|
231 | 0 | UNUSED(name); |
232 | 0 | UNUSED(type); |
233 | 0 | UNUSED(rdclass); |
234 | 0 | UNUSED(wildcard); |
235 | |
|
236 | 0 | return true; |
237 | 0 | } |
238 | | |
239 | | static bool |
240 | 0 | checknames_talink(ARGS_CHECKNAMES) { |
241 | 0 | REQUIRE(rdata->type == dns_rdatatype_talink); |
242 | |
|
243 | 0 | UNUSED(bad); |
244 | 0 | UNUSED(owner); |
245 | |
|
246 | 0 | return true; |
247 | 0 | } |
248 | | |
249 | | static int |
250 | 0 | casecompare_talink(ARGS_COMPARE) { |
251 | 0 | return compare_talink(rdata1, rdata2); |
252 | 0 | } |
253 | | |
254 | | #endif /* RDATA_GENERIC_TALINK_58_C */ |