Remove building with NOCRYPTO option
[minix.git] / external / bsd / bind / dist / lib / dns / rdata / in_1 / dhcid_49.c
blob0d3403dcd8c0e6133534a5c73ed6ae845d0a422b
1 /* $NetBSD: dhcid_49.c,v 1.5 2014/12/10 04:37:59 christos Exp $ */
3 /*
4 * Copyright (C) 2006, 2007, 2009, 2011, 2012 Internet Systems Consortium, Inc. ("ISC")
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
11 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
13 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
15 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
19 /* Id */
21 /* RFC 4701 */
23 #ifndef RDATA_IN_1_DHCID_49_C
24 #define RDATA_IN_1_DHCID_49_C 1
26 #define RRTYPE_DHCID_ATTRIBUTES 0
28 static inline isc_result_t
29 fromtext_in_dhcid(ARGS_FROMTEXT) {
31 REQUIRE(type == 49);
32 REQUIRE(rdclass == 1);
34 UNUSED(type);
35 UNUSED(rdclass);
36 UNUSED(origin);
37 UNUSED(options);
38 UNUSED(callbacks);
40 return (isc_base64_tobuffer(lexer, target, -1));
43 static inline isc_result_t
44 totext_in_dhcid(ARGS_TOTEXT) {
45 isc_region_t sr;
46 char buf[sizeof(" ; 64000 255 64000")];
47 size_t n;
49 REQUIRE(rdata->type == 49);
50 REQUIRE(rdata->rdclass == 1);
51 REQUIRE(rdata->length != 0);
53 dns_rdata_toregion(rdata, &sr);
55 if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
56 RETERR(str_totext("( " /*)*/, target));
57 if (tctx->width == 0) /* No splitting */
58 RETERR(isc_base64_totext(&sr, 60, "", target));
59 else
60 RETERR(isc_base64_totext(&sr, tctx->width - 2,
61 tctx->linebreak, target));
62 if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) {
63 RETERR(str_totext(/* ( */ " )", target));
64 if (rdata->length > 2) {
65 n = snprintf(buf, sizeof(buf), " ; %u %u %u",
66 sr.base[0] * 256 + sr.base[1],
67 sr.base[2], rdata->length - 3);
68 INSIST(n < sizeof(buf));
69 RETERR(str_totext(buf, target));
72 return (ISC_R_SUCCESS);
75 static inline isc_result_t
76 fromwire_in_dhcid(ARGS_FROMWIRE) {
77 isc_region_t sr;
79 REQUIRE(type == 49);
80 REQUIRE(rdclass == 1);
82 UNUSED(type);
83 UNUSED(rdclass);
84 UNUSED(dctx);
85 UNUSED(options);
87 isc_buffer_activeregion(source, &sr);
88 if (sr.length == 0)
89 return (ISC_R_UNEXPECTEDEND);
91 isc_buffer_forward(source, sr.length);
92 return (mem_tobuffer(target, sr.base, sr.length));
95 static inline isc_result_t
96 towire_in_dhcid(ARGS_TOWIRE) {
97 isc_region_t sr;
99 REQUIRE(rdata->type == 49);
100 REQUIRE(rdata->rdclass == 1);
101 REQUIRE(rdata->length != 0);
103 UNUSED(cctx);
105 dns_rdata_toregion(rdata, &sr);
106 return (mem_tobuffer(target, sr.base, sr.length));
109 static inline int
110 compare_in_dhcid(ARGS_COMPARE) {
111 isc_region_t r1;
112 isc_region_t r2;
114 REQUIRE(rdata1->type == rdata2->type);
115 REQUIRE(rdata1->rdclass == rdata2->rdclass);
116 REQUIRE(rdata1->type == 49);
117 REQUIRE(rdata1->rdclass == 1);
118 REQUIRE(rdata1->length != 0);
119 REQUIRE(rdata2->length != 0);
121 dns_rdata_toregion(rdata1, &r1);
122 dns_rdata_toregion(rdata2, &r2);
123 return (isc_region_compare(&r1, &r2));
126 static inline isc_result_t
127 fromstruct_in_dhcid(ARGS_FROMSTRUCT) {
128 dns_rdata_in_dhcid_t *dhcid = source;
130 REQUIRE(type == 49);
131 REQUIRE(rdclass == 1);
132 REQUIRE(source != NULL);
133 REQUIRE(dhcid->common.rdtype == type);
134 REQUIRE(dhcid->common.rdclass == rdclass);
135 REQUIRE(dhcid->length != 0);
137 UNUSED(type);
138 UNUSED(rdclass);
140 return (mem_tobuffer(target, dhcid->dhcid, dhcid->length));
143 static inline isc_result_t
144 tostruct_in_dhcid(ARGS_TOSTRUCT) {
145 dns_rdata_in_dhcid_t *dhcid = target;
146 isc_region_t region;
148 REQUIRE(rdata->type == 49);
149 REQUIRE(rdata->rdclass == 1);
150 REQUIRE(target != NULL);
151 REQUIRE(rdata->length != 0);
153 dhcid->common.rdclass = rdata->rdclass;
154 dhcid->common.rdtype = rdata->type;
155 ISC_LINK_INIT(&dhcid->common, link);
157 dns_rdata_toregion(rdata, &region);
159 dhcid->dhcid = mem_maybedup(mctx, region.base, region.length);
160 if (dhcid->dhcid == NULL)
161 return (ISC_R_NOMEMORY);
163 dhcid->mctx = mctx;
164 return (ISC_R_SUCCESS);
167 static inline void
168 freestruct_in_dhcid(ARGS_FREESTRUCT) {
169 dns_rdata_in_dhcid_t *dhcid = source;
171 REQUIRE(dhcid != NULL);
172 REQUIRE(dhcid->common.rdtype == 49);
173 REQUIRE(dhcid->common.rdclass == 1);
175 if (dhcid->mctx == NULL)
176 return;
178 if (dhcid->dhcid != NULL)
179 isc_mem_free(dhcid->mctx, dhcid->dhcid);
180 dhcid->mctx = NULL;
183 static inline isc_result_t
184 additionaldata_in_dhcid(ARGS_ADDLDATA) {
185 REQUIRE(rdata->type == 49);
186 REQUIRE(rdata->rdclass == 1);
188 UNUSED(rdata);
189 UNUSED(add);
190 UNUSED(arg);
192 return (ISC_R_SUCCESS);
195 static inline isc_result_t
196 digest_in_dhcid(ARGS_DIGEST) {
197 isc_region_t r;
199 REQUIRE(rdata->type == 49);
200 REQUIRE(rdata->rdclass == 1);
202 dns_rdata_toregion(rdata, &r);
204 return ((digest)(arg, &r));
207 static inline isc_boolean_t
208 checkowner_in_dhcid(ARGS_CHECKOWNER) {
210 REQUIRE(type == 49);
211 REQUIRE(rdclass == 1);
213 UNUSED(name);
214 UNUSED(type);
215 UNUSED(rdclass);
216 UNUSED(wildcard);
218 return (ISC_TRUE);
221 static inline isc_boolean_t
222 checknames_in_dhcid(ARGS_CHECKNAMES) {
224 REQUIRE(rdata->type == 49);
225 REQUIRE(rdata->rdclass == 1);
227 UNUSED(rdata);
228 UNUSED(owner);
229 UNUSED(bad);
231 return (ISC_TRUE);
234 static inline int
235 casecompare_in_dhcid(ARGS_COMPARE) {
236 return (compare_in_dhcid(rdata1, rdata2));
239 #endif /* RDATA_IN_1_DHCID_49_C */