/src/bind9/lib/dns/rdata/generic/mb_7.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_MB_7_C |
15 | | #define RDATA_GENERIC_MB_7_C |
16 | | |
17 | 11.6k | #define RRTYPE_MB_ATTRIBUTES (0) |
18 | | |
19 | | static isc_result_t |
20 | 132k | fromtext_mb(ARGS_FROMTEXT) { |
21 | 132k | isc_token_t token; |
22 | 132k | isc_buffer_t buffer; |
23 | | |
24 | 132k | REQUIRE(type == dns_rdatatype_mb); |
25 | | |
26 | 132k | UNUSED(type); |
27 | 132k | UNUSED(rdclass); |
28 | 132k | UNUSED(callbacks); |
29 | | |
30 | 132k | RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, |
31 | 132k | false)); |
32 | | |
33 | 132k | buffer_fromregion(&buffer, &token.value.as_region); |
34 | 132k | if (origin == NULL) { |
35 | 12 | origin = dns_rootname; |
36 | 12 | } |
37 | 132k | RETTOK(dns_name_wirefromtext(&buffer, origin, options, target)); |
38 | 132k | return ISC_R_SUCCESS; |
39 | 132k | } |
40 | | |
41 | | static isc_result_t |
42 | 1.11k | totext_mb(ARGS_TOTEXT) { |
43 | 1.11k | isc_region_t region; |
44 | 1.11k | dns_name_t name; |
45 | 1.11k | dns_name_t prefix; |
46 | 1.11k | unsigned int opts; |
47 | | |
48 | 1.11k | REQUIRE(rdata->type == dns_rdatatype_mb); |
49 | 1.11k | REQUIRE(rdata->length != 0); |
50 | | |
51 | 1.11k | dns_name_init(&name); |
52 | 1.11k | dns_name_init(&prefix); |
53 | | |
54 | 1.11k | dns_rdata_toregion(rdata, ®ion); |
55 | 1.11k | dns_name_fromregion(&name, ®ion); |
56 | | |
57 | 1.11k | opts = name_prefix(&name, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT |
58 | 1.11k | : 0; |
59 | 1.11k | return dns_name_totext(&prefix, opts, target); |
60 | 1.11k | } |
61 | | |
62 | | static isc_result_t |
63 | 1.33k | fromwire_mb(ARGS_FROMWIRE) { |
64 | 1.33k | dns_name_t name; |
65 | | |
66 | 1.33k | REQUIRE(type == dns_rdatatype_mb); |
67 | | |
68 | 1.33k | UNUSED(type); |
69 | 1.33k | UNUSED(rdclass); |
70 | | |
71 | 1.33k | dctx = dns_decompress_setpermitted(dctx, true); |
72 | | |
73 | 1.33k | dns_name_init(&name); |
74 | 1.33k | return dns_name_fromwire(&name, source, dctx, target); |
75 | 1.33k | } |
76 | | |
77 | | static isc_result_t |
78 | 561 | towire_mb(ARGS_TOWIRE) { |
79 | 561 | dns_name_t name; |
80 | 561 | isc_region_t region; |
81 | | |
82 | 561 | REQUIRE(rdata->type == dns_rdatatype_mb); |
83 | 561 | REQUIRE(rdata->length != 0); |
84 | | |
85 | 561 | dns_compress_setpermitted(cctx, true); |
86 | | |
87 | 561 | dns_name_init(&name); |
88 | 561 | dns_rdata_toregion(rdata, ®ion); |
89 | 561 | dns_name_fromregion(&name, ®ion); |
90 | | |
91 | 561 | return dns_name_towire(&name, cctx, target); |
92 | 561 | } |
93 | | |
94 | | static int |
95 | 73.0k | compare_mb(ARGS_COMPARE) { |
96 | 73.0k | dns_name_t name1; |
97 | 73.0k | dns_name_t name2; |
98 | 73.0k | isc_region_t region1; |
99 | 73.0k | isc_region_t region2; |
100 | | |
101 | 73.0k | REQUIRE(rdata1->type == rdata2->type); |
102 | 73.0k | REQUIRE(rdata1->rdclass == rdata2->rdclass); |
103 | 73.0k | REQUIRE(rdata1->type == dns_rdatatype_mb); |
104 | 73.0k | REQUIRE(rdata1->length != 0); |
105 | 73.0k | REQUIRE(rdata2->length != 0); |
106 | | |
107 | 73.0k | dns_name_init(&name1); |
108 | 73.0k | dns_name_init(&name2); |
109 | | |
110 | 73.0k | dns_rdata_toregion(rdata1, ®ion1); |
111 | 73.0k | dns_rdata_toregion(rdata2, ®ion2); |
112 | | |
113 | 73.0k | dns_name_fromregion(&name1, ®ion1); |
114 | 73.0k | dns_name_fromregion(&name2, ®ion2); |
115 | | |
116 | 73.0k | return dns_name_rdatacompare(&name1, &name2); |
117 | 73.0k | } |
118 | | |
119 | | static isc_result_t |
120 | 0 | fromstruct_mb(ARGS_FROMSTRUCT) { |
121 | 0 | dns_rdata_mb_t *mb = source; |
122 | 0 | isc_region_t region; |
123 | |
|
124 | 0 | REQUIRE(type == dns_rdatatype_mb); |
125 | 0 | REQUIRE(mb != NULL); |
126 | 0 | REQUIRE(mb->common.rdtype == type); |
127 | 0 | REQUIRE(mb->common.rdclass == rdclass); |
128 | |
|
129 | 0 | UNUSED(type); |
130 | 0 | UNUSED(rdclass); |
131 | |
|
132 | 0 | dns_name_toregion(&mb->mb, ®ion); |
133 | 0 | return isc_buffer_copyregion(target, ®ion); |
134 | 0 | } |
135 | | |
136 | | static isc_result_t |
137 | 0 | tostruct_mb(ARGS_TOSTRUCT) { |
138 | 0 | isc_region_t region; |
139 | 0 | dns_rdata_mb_t *mb = target; |
140 | 0 | dns_name_t name; |
141 | |
|
142 | 0 | REQUIRE(rdata->type == dns_rdatatype_mb); |
143 | 0 | REQUIRE(mb != NULL); |
144 | 0 | REQUIRE(rdata->length != 0); |
145 | |
|
146 | 0 | DNS_RDATACOMMON_INIT(mb, rdata->type, rdata->rdclass); |
147 | |
|
148 | 0 | dns_name_init(&name); |
149 | 0 | dns_rdata_toregion(rdata, ®ion); |
150 | 0 | dns_name_fromregion(&name, ®ion); |
151 | 0 | dns_name_init(&mb->mb); |
152 | 0 | name_duporclone(&name, mctx, &mb->mb); |
153 | 0 | mb->mctx = mctx; |
154 | 0 | return ISC_R_SUCCESS; |
155 | 0 | } |
156 | | |
157 | | static void |
158 | 0 | freestruct_mb(ARGS_FREESTRUCT) { |
159 | 0 | dns_rdata_mb_t *mb = source; |
160 | |
|
161 | 0 | REQUIRE(mb != NULL); |
162 | |
|
163 | 0 | if (mb->mctx == NULL) { |
164 | 0 | return; |
165 | 0 | } |
166 | | |
167 | 0 | dns_name_free(&mb->mb, mb->mctx); |
168 | 0 | mb->mctx = NULL; |
169 | 0 | } |
170 | | |
171 | | static isc_result_t |
172 | 0 | additionaldata_mb(ARGS_ADDLDATA) { |
173 | 0 | dns_name_t name; |
174 | 0 | isc_region_t region; |
175 | |
|
176 | 0 | REQUIRE(rdata->type == dns_rdatatype_mb); |
177 | |
|
178 | 0 | UNUSED(owner); |
179 | |
|
180 | 0 | dns_name_init(&name); |
181 | 0 | dns_rdata_toregion(rdata, ®ion); |
182 | 0 | dns_name_fromregion(&name, ®ion); |
183 | |
|
184 | 0 | return (add)(arg, &name, dns_rdatatype_a, NULL DNS__DB_FILELINE); |
185 | 0 | } |
186 | | |
187 | | static isc_result_t |
188 | 0 | digest_mb(ARGS_DIGEST) { |
189 | 0 | isc_region_t r; |
190 | 0 | dns_name_t name; |
191 | |
|
192 | 0 | REQUIRE(rdata->type == dns_rdatatype_mb); |
193 | |
|
194 | 0 | dns_rdata_toregion(rdata, &r); |
195 | 0 | dns_name_init(&name); |
196 | 0 | dns_name_fromregion(&name, &r); |
197 | |
|
198 | 0 | return dns_name_digest(&name, digest, arg); |
199 | 0 | } |
200 | | |
201 | | static bool |
202 | 0 | checkowner_mb(ARGS_CHECKOWNER) { |
203 | 0 | REQUIRE(type == dns_rdatatype_mb); |
204 | |
|
205 | 0 | UNUSED(type); |
206 | 0 | UNUSED(rdclass); |
207 | 0 | UNUSED(wildcard); |
208 | |
|
209 | 0 | return dns_name_ismailbox(name); |
210 | 0 | } |
211 | | |
212 | | static bool |
213 | 0 | checknames_mb(ARGS_CHECKNAMES) { |
214 | 0 | REQUIRE(rdata->type == dns_rdatatype_mb); |
215 | |
|
216 | 0 | UNUSED(rdata); |
217 | 0 | UNUSED(owner); |
218 | 0 | UNUSED(bad); |
219 | |
|
220 | 0 | return true; |
221 | 0 | } |
222 | | |
223 | | static int |
224 | 0 | casecompare_mb(ARGS_COMPARE) { |
225 | 0 | return compare_mb(rdata1, rdata2); |
226 | 0 | } |
227 | | |
228 | | #endif /* RDATA_GENERIC_MB_7_C */ |