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