Detect FPU by checking CPUID features.
[dragonfly.git] / contrib / bind-9.5.2 / lib / dns / rdata / in_1 / dhcid_49.c
blob27c4e4e23eb4520adbfa31e98d1b3bde8c17cbb6
1 /*
2 * Copyright (C) 2006, 2007 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.
17 /* $Id: dhcid_49.c,v 1.5 2007/06/19 23:47:17 tbox Exp $ */
19 /* RFC 4701 */
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) {
29 REQUIRE(type == 49);
30 REQUIRE(rdclass == 1);
32 UNUSED(type);
33 UNUSED(rdclass);
34 UNUSED(origin);
35 UNUSED(options);
36 UNUSED(callbacks);
38 return (isc_base64_tobuffer(lexer, target, -1));
41 static inline isc_result_t
42 totext_in_dhcid(ARGS_TOTEXT) {
43 isc_region_t sr;
44 char buf[sizeof(" ; 64000 255 64000")];
45 size_t n;
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 RETERR(isc_base64_totext(&sr, tctx->width - 2, tctx->linebreak,
56 target));
57 if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) {
58 RETERR(str_totext(/* ( */ " )", target));
59 if (rdata->length > 2) {
60 n = snprintf(buf, sizeof(buf), " ; %u %u %u",
61 sr.base[0] * 256 + sr.base[1],
62 sr.base[2], rdata->length - 3);
63 INSIST(n < sizeof(buf));
64 RETERR(str_totext(buf, target));
67 return (ISC_R_SUCCESS);
70 static inline isc_result_t
71 fromwire_in_dhcid(ARGS_FROMWIRE) {
72 isc_region_t sr;
74 REQUIRE(type == 49);
75 REQUIRE(rdclass == 1);
77 UNUSED(type);
78 UNUSED(rdclass);
79 UNUSED(dctx);
80 UNUSED(options);
82 isc_buffer_activeregion(source, &sr);
83 if (sr.length == 0)
84 return (ISC_R_UNEXPECTEDEND);
86 isc_buffer_forward(source, sr.length);
87 return (mem_tobuffer(target, sr.base, sr.length));
90 static inline isc_result_t
91 towire_in_dhcid(ARGS_TOWIRE) {
92 isc_region_t sr;
94 REQUIRE(rdata->type == 49);
95 REQUIRE(rdata->rdclass == 1);
96 REQUIRE(rdata->length != 0);
98 UNUSED(cctx);
100 dns_rdata_toregion(rdata, &sr);
101 return (mem_tobuffer(target, sr.base, sr.length));
104 static inline int
105 compare_in_dhcid(ARGS_COMPARE) {
106 isc_region_t r1;
107 isc_region_t r2;
109 REQUIRE(rdata1->type == rdata2->type);
110 REQUIRE(rdata1->rdclass == rdata2->rdclass);
111 REQUIRE(rdata1->type == 49);
112 REQUIRE(rdata1->rdclass == 1);
113 REQUIRE(rdata1->length != 0);
114 REQUIRE(rdata2->length != 0);
116 dns_rdata_toregion(rdata1, &r1);
117 dns_rdata_toregion(rdata2, &r2);
118 return (isc_region_compare(&r1, &r2));
121 static inline isc_result_t
122 fromstruct_in_dhcid(ARGS_FROMSTRUCT) {
123 dns_rdata_in_dhcid_t *dhcid = source;
125 REQUIRE(type == 49);
126 REQUIRE(rdclass == 1);
127 REQUIRE(source != NULL);
128 REQUIRE(dhcid->common.rdtype == type);
129 REQUIRE(dhcid->common.rdclass == rdclass);
130 REQUIRE(dhcid->length != 0);
132 UNUSED(type);
133 UNUSED(rdclass);
135 return (mem_tobuffer(target, dhcid->dhcid, dhcid->length));
138 static inline isc_result_t
139 tostruct_in_dhcid(ARGS_TOSTRUCT) {
140 dns_rdata_in_dhcid_t *dhcid = target;
141 isc_region_t region;
143 REQUIRE(rdata->type == 49);
144 REQUIRE(rdata->rdclass == 1);
145 REQUIRE(target != NULL);
146 REQUIRE(rdata->length != 0);
148 dhcid->common.rdclass = rdata->rdclass;
149 dhcid->common.rdtype = rdata->type;
150 ISC_LINK_INIT(&dhcid->common, link);
152 dns_rdata_toregion(rdata, &region);
154 dhcid->dhcid = mem_maybedup(mctx, region.base, region.length);
155 if (dhcid->dhcid == NULL)
156 return (ISC_R_NOMEMORY);
158 dhcid->mctx = mctx;
159 return (ISC_R_SUCCESS);
162 static inline void
163 freestruct_in_dhcid(ARGS_FREESTRUCT) {
164 dns_rdata_in_dhcid_t *dhcid = source;
166 REQUIRE(dhcid != NULL);
167 REQUIRE(dhcid->common.rdtype == 49);
168 REQUIRE(dhcid->common.rdclass == 1);
170 if (dhcid->mctx == NULL)
171 return;
173 if (dhcid->dhcid != NULL)
174 isc_mem_free(dhcid->mctx, dhcid->dhcid);
175 dhcid->mctx = NULL;
178 static inline isc_result_t
179 additionaldata_in_dhcid(ARGS_ADDLDATA) {
180 REQUIRE(rdata->type == 49);
181 REQUIRE(rdata->rdclass == 1);
183 UNUSED(rdata);
184 UNUSED(add);
185 UNUSED(arg);
187 return (ISC_R_SUCCESS);
190 static inline isc_result_t
191 digest_in_dhcid(ARGS_DIGEST) {
192 isc_region_t r;
194 REQUIRE(rdata->type == 49);
195 REQUIRE(rdata->rdclass == 1);
197 dns_rdata_toregion(rdata, &r);
199 return ((digest)(arg, &r));
202 static inline isc_boolean_t
203 checkowner_in_dhcid(ARGS_CHECKOWNER) {
205 REQUIRE(type == 49);
206 REQUIRE(rdclass == 1);
208 UNUSED(name);
209 UNUSED(type);
210 UNUSED(rdclass);
211 UNUSED(wildcard);
213 return (ISC_TRUE);
216 static inline isc_boolean_t
217 checknames_in_dhcid(ARGS_CHECKNAMES) {
219 REQUIRE(rdata->type == 49);
220 REQUIRE(rdata->rdclass == 1);
222 UNUSED(rdata);
223 UNUSED(owner);
224 UNUSED(bad);
226 return (ISC_TRUE);
229 #endif /* RDATA_IN_1_DHCID_49_C */