2 * Copyright (C) 2006, 2007, 2009, 2011, 2012 Internet Systems Consortium, Inc. ("ISC")
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
13 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 * PERFORMANCE OF THIS SOFTWARE.
21 #ifndef RDATA_IN_1_DHCID_49_C
22 #define RDATA_IN_1_DHCID_49_C 1
24 #define RRTYPE_DHCID_ATTRIBUTES 0
26 static inline isc_result_t
27 fromtext_in_dhcid(ARGS_FROMTEXT) {
30 REQUIRE(rdclass == 1);
38 return (isc_base64_tobuffer(lexer, target, -1));
41 static inline isc_result_t
42 totext_in_dhcid(ARGS_TOTEXT) {
44 char buf[sizeof(" ; 64000 255 64000")];
47 REQUIRE(rdata->type == 49);
48 REQUIRE(rdata->rdclass == 1);
49 REQUIRE(rdata->length != 0);
51 dns_rdata_toregion(rdata, &sr);
53 if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
54 RETERR(str_totext("( " /*)*/, target));
55 if (tctx->width == 0) /* No splitting */
56 RETERR(isc_base64_totext(&sr, 60, "", target));
58 RETERR(isc_base64_totext(&sr, tctx->width - 2,
59 tctx->linebreak, target));
60 if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) {
61 RETERR(str_totext(/* ( */ " )", target));
62 if (rdata->length > 2) {
63 n = snprintf(buf, sizeof(buf), " ; %u %u %u",
64 sr.base[0] * 256 + sr.base[1],
65 sr.base[2], rdata->length - 3);
66 INSIST(n < sizeof(buf));
67 RETERR(str_totext(buf, target));
70 return (ISC_R_SUCCESS);
73 static inline isc_result_t
74 fromwire_in_dhcid(ARGS_FROMWIRE) {
78 REQUIRE(rdclass == 1);
85 isc_buffer_activeregion(source, &sr);
87 return (ISC_R_UNEXPECTEDEND);
89 isc_buffer_forward(source, sr.length);
90 return (mem_tobuffer(target, sr.base, sr.length));
93 static inline isc_result_t
94 towire_in_dhcid(ARGS_TOWIRE) {
97 REQUIRE(rdata->type == 49);
98 REQUIRE(rdata->rdclass == 1);
99 REQUIRE(rdata->length != 0);
103 dns_rdata_toregion(rdata, &sr);
104 return (mem_tobuffer(target, sr.base, sr.length));
108 compare_in_dhcid(ARGS_COMPARE) {
112 REQUIRE(rdata1->type == rdata2->type);
113 REQUIRE(rdata1->rdclass == rdata2->rdclass);
114 REQUIRE(rdata1->type == 49);
115 REQUIRE(rdata1->rdclass == 1);
116 REQUIRE(rdata1->length != 0);
117 REQUIRE(rdata2->length != 0);
119 dns_rdata_toregion(rdata1, &r1);
120 dns_rdata_toregion(rdata2, &r2);
121 return (isc_region_compare(&r1, &r2));
124 static inline isc_result_t
125 fromstruct_in_dhcid(ARGS_FROMSTRUCT) {
126 dns_rdata_in_dhcid_t *dhcid = source;
129 REQUIRE(rdclass == 1);
130 REQUIRE(source != NULL);
131 REQUIRE(dhcid->common.rdtype == type);
132 REQUIRE(dhcid->common.rdclass == rdclass);
133 REQUIRE(dhcid->length != 0);
138 return (mem_tobuffer(target, dhcid->dhcid, dhcid->length));
141 static inline isc_result_t
142 tostruct_in_dhcid(ARGS_TOSTRUCT) {
143 dns_rdata_in_dhcid_t *dhcid = target;
146 REQUIRE(rdata->type == 49);
147 REQUIRE(rdata->rdclass == 1);
148 REQUIRE(target != NULL);
149 REQUIRE(rdata->length != 0);
151 dhcid->common.rdclass = rdata->rdclass;
152 dhcid->common.rdtype = rdata->type;
153 ISC_LINK_INIT(&dhcid->common, link);
155 dns_rdata_toregion(rdata, ®ion);
157 dhcid->dhcid = mem_maybedup(mctx, region.base, region.length);
158 if (dhcid->dhcid == NULL)
159 return (ISC_R_NOMEMORY);
162 return (ISC_R_SUCCESS);
166 freestruct_in_dhcid(ARGS_FREESTRUCT) {
167 dns_rdata_in_dhcid_t *dhcid = source;
169 REQUIRE(dhcid != NULL);
170 REQUIRE(dhcid->common.rdtype == 49);
171 REQUIRE(dhcid->common.rdclass == 1);
173 if (dhcid->mctx == NULL)
176 if (dhcid->dhcid != NULL)
177 isc_mem_free(dhcid->mctx, dhcid->dhcid);
181 static inline isc_result_t
182 additionaldata_in_dhcid(ARGS_ADDLDATA) {
183 REQUIRE(rdata->type == 49);
184 REQUIRE(rdata->rdclass == 1);
190 return (ISC_R_SUCCESS);
193 static inline isc_result_t
194 digest_in_dhcid(ARGS_DIGEST) {
197 REQUIRE(rdata->type == 49);
198 REQUIRE(rdata->rdclass == 1);
200 dns_rdata_toregion(rdata, &r);
202 return ((digest)(arg, &r));
205 static inline isc_boolean_t
206 checkowner_in_dhcid(ARGS_CHECKOWNER) {
209 REQUIRE(rdclass == 1);
219 static inline isc_boolean_t
220 checknames_in_dhcid(ARGS_CHECKNAMES) {
222 REQUIRE(rdata->type == 49);
223 REQUIRE(rdata->rdclass == 1);
233 casecompare_in_dhcid(ARGS_COMPARE) {
234 return (compare_in_dhcid(rdata1, rdata2));
237 #endif /* RDATA_IN_1_DHCID_49_C */