/src/bind9/lib/dns/rdata/generic/brid_68.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_BRID_68_C |
15 | | #define RDATA_GENERIC_BRID_68_C |
16 | | |
17 | | #include <dst/dst.h> |
18 | | |
19 | 11.5k | #define RRTYPE_BRID_ATTRIBUTES (0) |
20 | | |
21 | | static isc_result_t |
22 | 1.23k | fromtext_brid(ARGS_FROMTEXT) { |
23 | 1.23k | REQUIRE(type == dns_rdatatype_brid); |
24 | | |
25 | 1.23k | UNUSED(type); |
26 | 1.23k | UNUSED(rdclass); |
27 | 1.23k | UNUSED(origin); |
28 | 1.23k | UNUSED(options); |
29 | 1.23k | UNUSED(callbacks); |
30 | | |
31 | 1.23k | return isc_base64_tobuffer(lexer, target, isc_one_or_more); |
32 | 1.23k | } |
33 | | |
34 | | static isc_result_t |
35 | 763 | totext_brid(ARGS_TOTEXT) { |
36 | 763 | isc_region_t sr; |
37 | | |
38 | 763 | REQUIRE(rdata->type == dns_rdatatype_brid); |
39 | 763 | REQUIRE(rdata->length > 0); |
40 | | |
41 | 763 | dns_rdata_toregion(rdata, &sr); |
42 | | |
43 | | /* data */ |
44 | 763 | if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) { |
45 | 22 | RETERR(str_totext(" (", target)); |
46 | 22 | } |
47 | | |
48 | 763 | if (tctx->width == 0) { /* No splitting */ |
49 | 0 | RETERR(isc_base64_totext(&sr, 60, "", target)); |
50 | 763 | } else { |
51 | 763 | RETERR(isc_base64_totext(&sr, tctx->width - 2, tctx->linebreak, |
52 | 763 | target)); |
53 | 763 | } |
54 | | |
55 | 763 | if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) { |
56 | 22 | RETERR(str_totext(" )", target)); |
57 | 22 | } |
58 | | |
59 | 763 | return ISC_R_SUCCESS; |
60 | 763 | } |
61 | | |
62 | | static isc_result_t |
63 | 2.32k | fromwire_brid(ARGS_FROMWIRE) { |
64 | 2.32k | isc_region_t sr; |
65 | | |
66 | 2.32k | REQUIRE(type == dns_rdatatype_brid); |
67 | | |
68 | 2.32k | UNUSED(type); |
69 | 2.32k | UNUSED(rdclass); |
70 | 2.32k | UNUSED(dctx); |
71 | | |
72 | 2.32k | isc_buffer_activeregion(source, &sr); |
73 | 2.32k | if (sr.length == 0) { |
74 | 5 | return ISC_R_UNEXPECTEDEND; |
75 | 5 | } |
76 | | |
77 | 2.32k | RETERR(mem_tobuffer(target, sr.base, sr.length)); |
78 | 2.09k | isc_buffer_forward(source, sr.length); |
79 | 2.09k | return ISC_R_SUCCESS; |
80 | 2.32k | } |
81 | | |
82 | | static isc_result_t |
83 | 386 | towire_brid(ARGS_TOWIRE) { |
84 | 386 | REQUIRE(rdata->type == dns_rdatatype_brid); |
85 | 386 | REQUIRE(rdata->length > 0); |
86 | | |
87 | 386 | UNUSED(cctx); |
88 | | |
89 | 386 | return mem_tobuffer(target, rdata->data, rdata->length); |
90 | 386 | } |
91 | | |
92 | | static int |
93 | 35.0k | compare_brid(ARGS_COMPARE) { |
94 | 35.0k | isc_region_t r1; |
95 | 35.0k | isc_region_t r2; |
96 | | |
97 | 35.0k | REQUIRE(rdata1->type == rdata2->type); |
98 | 35.0k | REQUIRE(rdata1->rdclass == rdata2->rdclass); |
99 | 35.0k | REQUIRE(rdata1->type == dns_rdatatype_brid); |
100 | 35.0k | REQUIRE(rdata1->length > 0); |
101 | 35.0k | REQUIRE(rdata2->length > 0); |
102 | | |
103 | 35.0k | dns_rdata_toregion(rdata1, &r1); |
104 | 35.0k | dns_rdata_toregion(rdata2, &r2); |
105 | 35.0k | return isc_region_compare(&r1, &r2); |
106 | 35.0k | } |
107 | | |
108 | | static isc_result_t |
109 | 0 | fromstruct_brid(ARGS_FROMSTRUCT) { |
110 | 0 | dns_rdata_brid_t *brid = source; |
111 | |
|
112 | 0 | REQUIRE(type == dns_rdatatype_brid); |
113 | 0 | REQUIRE(brid != NULL); |
114 | 0 | REQUIRE(brid->common.rdtype == type); |
115 | 0 | REQUIRE(brid->common.rdclass == rdclass); |
116 | |
|
117 | 0 | UNUSED(type); |
118 | 0 | UNUSED(rdclass); |
119 | | |
120 | | /* Data */ |
121 | 0 | return mem_tobuffer(target, brid->data, brid->datalen); |
122 | 0 | } |
123 | | |
124 | | static isc_result_t |
125 | 0 | tostruct_brid(ARGS_TOSTRUCT) { |
126 | 0 | dns_rdata_brid_t *brid = target; |
127 | 0 | isc_region_t sr; |
128 | |
|
129 | 0 | REQUIRE(rdata->type == dns_rdatatype_brid); |
130 | 0 | REQUIRE(brid != NULL); |
131 | 0 | REQUIRE(rdata->length > 0); |
132 | |
|
133 | 0 | DNS_RDATACOMMON_INIT(brid, rdata->type, rdata->rdclass); |
134 | |
|
135 | 0 | dns_rdata_toregion(rdata, &sr); |
136 | | |
137 | | /* Data */ |
138 | 0 | brid->datalen = sr.length; |
139 | 0 | brid->data = mem_maybedup(mctx, sr.base, brid->datalen); |
140 | 0 | brid->mctx = mctx; |
141 | 0 | return ISC_R_SUCCESS; |
142 | 0 | } |
143 | | |
144 | | static void |
145 | 0 | freestruct_brid(ARGS_FREESTRUCT) { |
146 | 0 | dns_rdata_brid_t *brid = (dns_rdata_brid_t *)source; |
147 | |
|
148 | 0 | REQUIRE(brid != NULL); |
149 | 0 | REQUIRE(brid->common.rdtype == dns_rdatatype_brid); |
150 | |
|
151 | 0 | if (brid->mctx == NULL) { |
152 | 0 | return; |
153 | 0 | } |
154 | | |
155 | 0 | if (brid->data != NULL) { |
156 | 0 | isc_mem_free(brid->mctx, brid->data); |
157 | 0 | } |
158 | 0 | brid->mctx = NULL; |
159 | 0 | } |
160 | | |
161 | | static isc_result_t |
162 | 0 | additionaldata_brid(ARGS_ADDLDATA) { |
163 | 0 | REQUIRE(rdata->type == dns_rdatatype_brid); |
164 | |
|
165 | 0 | UNUSED(rdata); |
166 | 0 | UNUSED(owner); |
167 | 0 | UNUSED(add); |
168 | 0 | UNUSED(arg); |
169 | |
|
170 | 0 | return ISC_R_SUCCESS; |
171 | 0 | } |
172 | | |
173 | | static isc_result_t |
174 | 0 | digest_brid(ARGS_DIGEST) { |
175 | 0 | isc_region_t r; |
176 | |
|
177 | 0 | REQUIRE(rdata->type == dns_rdatatype_brid); |
178 | |
|
179 | 0 | dns_rdata_toregion(rdata, &r); |
180 | |
|
181 | 0 | return (digest)(arg, &r); |
182 | 0 | } |
183 | | |
184 | | static bool |
185 | 0 | checkowner_brid(ARGS_CHECKOWNER) { |
186 | 0 | REQUIRE(type == dns_rdatatype_brid); |
187 | |
|
188 | 0 | UNUSED(name); |
189 | 0 | UNUSED(type); |
190 | 0 | UNUSED(rdclass); |
191 | 0 | UNUSED(wildcard); |
192 | |
|
193 | 0 | return true; |
194 | 0 | } |
195 | | |
196 | | static bool |
197 | 0 | checknames_brid(ARGS_CHECKNAMES) { |
198 | 0 | REQUIRE(rdata->type == dns_rdatatype_brid); |
199 | |
|
200 | 0 | UNUSED(rdata); |
201 | 0 | UNUSED(owner); |
202 | 0 | UNUSED(bad); |
203 | |
|
204 | 0 | return true; |
205 | 0 | } |
206 | | |
207 | | static int |
208 | 0 | casecompare_brid(ARGS_COMPARE) { |
209 | 0 | return compare_brid(rdata1, rdata2); |
210 | 0 | } |
211 | | #endif /* RDATA_GENERIC_BRID_68_C */ |