/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 | 5.82k | #define RRTYPE_TALINK_ATTRIBUTES 0 |
18 | | |
19 | | static isc_result_t |
20 | 2.37k | fromtext_talink(ARGS_FROMTEXT) { |
21 | 2.37k | isc_token_t token; |
22 | 2.37k | isc_buffer_t buffer; |
23 | 2.37k | int i; |
24 | | |
25 | 2.37k | REQUIRE(type == dns_rdatatype_talink); |
26 | | |
27 | 2.37k | UNUSED(type); |
28 | 2.37k | UNUSED(rdclass); |
29 | 2.37k | UNUSED(callbacks); |
30 | | |
31 | 2.37k | if (origin == NULL) { |
32 | 8 | origin = dns_rootname; |
33 | 8 | } |
34 | | |
35 | 7.09k | for (i = 0; i < 2; i++) { |
36 | 4.73k | RETERR(isc_lex_getmastertoken(lexer, &token, |
37 | 4.73k | isc_tokentype_string, false)); |
38 | | |
39 | 4.72k | buffer_fromregion(&buffer, &token.value.as_region); |
40 | 4.72k | RETTOK(dns_name_wirefromtext(&buffer, origin, options, target)); |
41 | 4.72k | } |
42 | | |
43 | 2.35k | return ISC_R_SUCCESS; |
44 | 2.37k | } |
45 | | |
46 | | static isc_result_t |
47 | 589 | totext_talink(ARGS_TOTEXT) { |
48 | 589 | isc_region_t dregion; |
49 | 589 | dns_name_t prev; |
50 | 589 | dns_name_t next; |
51 | 589 | dns_name_t prefix; |
52 | 589 | unsigned int opts; |
53 | | |
54 | 589 | REQUIRE(rdata->type == dns_rdatatype_talink); |
55 | 589 | REQUIRE(rdata->length != 0); |
56 | | |
57 | 589 | dns_name_init(&prev); |
58 | 589 | dns_name_init(&next); |
59 | 589 | dns_name_init(&prefix); |
60 | | |
61 | 589 | dns_rdata_toregion(rdata, &dregion); |
62 | | |
63 | 589 | dns_name_fromregion(&prev, &dregion); |
64 | 589 | isc_region_consume(&dregion, name_length(&prev)); |
65 | | |
66 | 589 | dns_name_fromregion(&next, &dregion); |
67 | 589 | isc_region_consume(&dregion, name_length(&next)); |
68 | | |
69 | 589 | opts = name_prefix(&prev, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT |
70 | 589 | : 0; |
71 | 589 | RETERR(dns_name_totext(&prefix, opts, target)); |
72 | | |
73 | 589 | RETERR(str_totext(" ", target)); |
74 | | |
75 | 589 | opts = name_prefix(&next, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT |
76 | 589 | : 0; |
77 | 589 | return dns_name_totext(&prefix, opts, target); |
78 | 589 | } |
79 | | |
80 | | static isc_result_t |
81 | 832 | fromwire_talink(ARGS_FROMWIRE) { |
82 | 832 | dns_name_t prev; |
83 | 832 | dns_name_t next; |
84 | | |
85 | 832 | REQUIRE(type == dns_rdatatype_talink); |
86 | | |
87 | 832 | UNUSED(type); |
88 | 832 | UNUSED(rdclass); |
89 | | |
90 | 832 | dns_name_init(&prev); |
91 | 832 | dns_name_init(&next); |
92 | | |
93 | 832 | RETERR(dns_name_fromwire(&prev, source, dctx, target)); |
94 | 817 | return dns_name_fromwire(&next, source, dctx, target); |
95 | 832 | } |
96 | | |
97 | | static int |
98 | 1.18M | compare_talink(ARGS_COMPARE) { |
99 | 1.18M | isc_region_t region1; |
100 | 1.18M | isc_region_t region2; |
101 | | |
102 | 1.18M | REQUIRE(rdata1->type == rdata2->type); |
103 | 1.18M | REQUIRE(rdata1->rdclass == rdata2->rdclass); |
104 | 1.18M | REQUIRE(rdata1->type == dns_rdatatype_talink); |
105 | 1.18M | REQUIRE(rdata1->length != 0); |
106 | 1.18M | REQUIRE(rdata2->length != 0); |
107 | | |
108 | 1.18M | dns_rdata_toregion(rdata1, ®ion1); |
109 | 1.18M | dns_rdata_toregion(rdata2, ®ion2); |
110 | 1.18M | return isc_region_compare(®ion1, ®ion2); |
111 | 1.18M | } |
112 | | |
113 | | static isc_result_t |
114 | 0 | fromstruct_talink(ARGS_FROMSTRUCT) { |
115 | 0 | dns_rdata_talink_t *talink = source; |
116 | 0 | isc_region_t region; |
117 | |
|
118 | 0 | REQUIRE(type == dns_rdatatype_talink); |
119 | 0 | REQUIRE(talink != NULL); |
120 | 0 | REQUIRE(talink->common.rdtype == type); |
121 | 0 | REQUIRE(talink->common.rdclass == rdclass); |
122 | |
|
123 | 0 | UNUSED(type); |
124 | 0 | UNUSED(rdclass); |
125 | |
|
126 | 0 | dns_name_toregion(&talink->prev, ®ion); |
127 | 0 | RETERR(isc_buffer_copyregion(target, ®ion)); |
128 | 0 | dns_name_toregion(&talink->next, ®ion); |
129 | 0 | return isc_buffer_copyregion(target, ®ion); |
130 | 0 | } |
131 | | |
132 | | static isc_result_t |
133 | 0 | tostruct_talink(ARGS_TOSTRUCT) { |
134 | 0 | isc_region_t region; |
135 | 0 | dns_rdata_talink_t *talink = target; |
136 | 0 | dns_name_t name; |
137 | |
|
138 | 0 | REQUIRE(rdata->type == dns_rdatatype_talink); |
139 | 0 | REQUIRE(talink != NULL); |
140 | 0 | REQUIRE(rdata->length != 0); |
141 | |
|
142 | 0 | DNS_RDATACOMMON_INIT(talink, rdata->type, rdata->rdclass); |
143 | |
|
144 | 0 | dns_rdata_toregion(rdata, ®ion); |
145 | |
|
146 | 0 | dns_name_init(&name); |
147 | 0 | dns_name_fromregion(&name, ®ion); |
148 | 0 | isc_region_consume(®ion, name_length(&name)); |
149 | 0 | dns_name_init(&talink->prev); |
150 | 0 | dns_name_clone(&name, &talink->prev); |
151 | |
|
152 | 0 | dns_name_fromregion(&name, ®ion); |
153 | 0 | isc_region_consume(®ion, name_length(&name)); |
154 | 0 | dns_name_init(&talink->next); |
155 | 0 | dns_name_clone(&name, &talink->next); |
156 | |
|
157 | 0 | return ISC_R_SUCCESS; |
158 | 0 | } |
159 | | |
160 | | static isc_result_t |
161 | 0 | additionaldata_talink(ARGS_ADDLDATA) { |
162 | 0 | REQUIRE(rdata->type == dns_rdatatype_talink); |
163 | |
|
164 | 0 | UNUSED(rdata); |
165 | 0 | UNUSED(owner); |
166 | 0 | UNUSED(add); |
167 | 0 | UNUSED(arg); |
168 | |
|
169 | 0 | return ISC_R_SUCCESS; |
170 | 0 | } |
171 | | |
172 | | static isc_result_t |
173 | 0 | digest_talink(ARGS_DIGEST) { |
174 | 0 | isc_region_t r; |
175 | |
|
176 | 0 | REQUIRE(rdata->type == dns_rdatatype_talink); |
177 | |
|
178 | 0 | dns_rdata_toregion(rdata, &r); |
179 | 0 | return (digest)(arg, &r); |
180 | 0 | } |
181 | | |
182 | | static bool |
183 | 0 | checkowner_talink(ARGS_CHECKOWNER) { |
184 | 0 | REQUIRE(type == dns_rdatatype_talink); |
185 | |
|
186 | 0 | UNUSED(name); |
187 | 0 | UNUSED(type); |
188 | 0 | UNUSED(rdclass); |
189 | 0 | UNUSED(wildcard); |
190 | |
|
191 | 0 | return true; |
192 | 0 | } |
193 | | |
194 | | static bool |
195 | 0 | checknames_talink(ARGS_CHECKNAMES) { |
196 | 0 | REQUIRE(rdata->type == dns_rdatatype_talink); |
197 | |
|
198 | 0 | UNUSED(bad); |
199 | 0 | UNUSED(owner); |
200 | |
|
201 | 0 | return true; |
202 | 0 | } |
203 | | |
204 | | static int |
205 | 0 | casecompare_talink(ARGS_COMPARE) { |
206 | 0 | return compare_talink(rdata1, rdata2); |
207 | 0 | } |
208 | | |
209 | | #endif /* RDATA_GENERIC_TALINK_58_C */ |