Remove building with NOCRYPTO option
[minix.git] / external / bsd / bind / dist / lib / dns / rdata / generic / eui64_109.c
blob9a5cb72f90eab540b322cee80b3c6b7eae7c08e4
1 /* $NetBSD: eui64_109.c,v 1.1.1.4 2014/12/10 03:34:42 christos Exp $ */
3 /*
4 * Copyright (C) 2013, 2014 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 #ifndef RDATA_GENERIC_EUI64_109_C
20 #define RDATA_GENERIC_EUI64_109_C
22 #include <string.h>
24 #define RRTYPE_EUI64_ATTRIBUTES (0)
26 static inline isc_result_t
27 fromtext_eui64(ARGS_FROMTEXT) {
28 isc_token_t token;
29 unsigned char eui64[8];
30 unsigned int l0, l1, l2, l3, l4, l5, l6, l7;
31 int n;
33 REQUIRE(type == 109);
35 UNUSED(type);
36 UNUSED(rdclass);
37 UNUSED(origin);
38 UNUSED(options);
39 UNUSED(callbacks);
41 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
42 ISC_FALSE));
43 n = sscanf(DNS_AS_STR(token), "%2x-%2x-%2x-%2x-%2x-%2x-%2x-%2x",
44 &l0, &l1, &l2, &l3, &l4, &l5, &l6, &l7);
45 if (n != 8 || l0 > 255U || l1 > 255U || l2 > 255U || l3 > 255U ||
46 l4 > 255U || l5 > 255U || l6 > 255U || l7 > 255U)
47 return (DNS_R_BADEUI);
49 eui64[0] = l0;
50 eui64[1] = l1;
51 eui64[2] = l2;
52 eui64[3] = l3;
53 eui64[4] = l4;
54 eui64[5] = l5;
55 eui64[6] = l6;
56 eui64[7] = l7;
57 return (mem_tobuffer(target, eui64, sizeof(eui64)));
60 static inline isc_result_t
61 totext_eui64(ARGS_TOTEXT) {
62 char buf[sizeof("xx-xx-xx-xx-xx-xx-xx-xx")];
64 REQUIRE(rdata->type == 109);
65 REQUIRE(rdata->length == 8);
67 UNUSED(tctx);
69 (void)snprintf(buf, sizeof(buf),
70 "%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x",
71 rdata->data[0], rdata->data[1],
72 rdata->data[2], rdata->data[3],
73 rdata->data[4], rdata->data[5],
74 rdata->data[6], rdata->data[7]);
75 return (str_totext(buf, target));
78 static inline isc_result_t
79 fromwire_eui64(ARGS_FROMWIRE) {
80 isc_region_t sregion;
82 REQUIRE(type == 109);
84 UNUSED(type);
85 UNUSED(options);
86 UNUSED(rdclass);
87 UNUSED(dctx);
89 isc_buffer_activeregion(source, &sregion);
90 if (sregion.length != 8)
91 return (DNS_R_FORMERR);
92 isc_buffer_forward(source, sregion.length);
93 return (mem_tobuffer(target, sregion.base, sregion.length));
96 static inline isc_result_t
97 towire_eui64(ARGS_TOWIRE) {
99 REQUIRE(rdata->type == 109);
100 REQUIRE(rdata->length == 8);
102 UNUSED(cctx);
104 return (mem_tobuffer(target, rdata->data, rdata->length));
107 static inline int
108 compare_eui64(ARGS_COMPARE) {
109 isc_region_t region1;
110 isc_region_t region2;
112 REQUIRE(rdata1->type == rdata2->type);
113 REQUIRE(rdata1->rdclass == rdata2->rdclass);
114 REQUIRE(rdata1->type == 109);
115 REQUIRE(rdata1->length == 8);
116 REQUIRE(rdata2->length == 8);
118 dns_rdata_toregion(rdata1, &region1);
119 dns_rdata_toregion(rdata2, &region2);
120 return (isc_region_compare(&region1, &region2));
123 static inline isc_result_t
124 fromstruct_eui64(ARGS_FROMSTRUCT) {
125 dns_rdata_eui64_t *eui64 = source;
127 REQUIRE(type == 109);
128 REQUIRE(source != NULL);
129 REQUIRE(eui64->common.rdtype == type);
130 REQUIRE(eui64->common.rdclass == rdclass);
132 UNUSED(type);
133 UNUSED(rdclass);
135 return (mem_tobuffer(target, eui64->eui64, sizeof(eui64->eui64)));
138 static inline isc_result_t
139 tostruct_eui64(ARGS_TOSTRUCT) {
140 dns_rdata_eui64_t *eui64 = target;
142 REQUIRE(rdata->type == 109);
143 REQUIRE(target != NULL);
144 REQUIRE(rdata->length == 8);
146 UNUSED(mctx);
148 eui64->common.rdclass = rdata->rdclass;
149 eui64->common.rdtype = rdata->type;
150 ISC_LINK_INIT(&eui64->common, link);
152 memmove(eui64->eui64, rdata->data, rdata->length);
153 return (ISC_R_SUCCESS);
156 static inline void
157 freestruct_eui64(ARGS_FREESTRUCT) {
158 dns_rdata_eui64_t *eui64 = source;
160 REQUIRE(source != NULL);
161 REQUIRE(eui64->common.rdtype == 109);
163 return;
166 static inline isc_result_t
167 additionaldata_eui64(ARGS_ADDLDATA) {
169 REQUIRE(rdata->type == 109);
170 REQUIRE(rdata->length == 8);
172 UNUSED(rdata);
173 UNUSED(add);
174 UNUSED(arg);
176 return (ISC_R_SUCCESS);
179 static inline isc_result_t
180 digest_eui64(ARGS_DIGEST) {
181 isc_region_t r;
183 REQUIRE(rdata->type == 109);
184 REQUIRE(rdata->length == 8);
186 dns_rdata_toregion(rdata, &r);
188 return ((digest)(arg, &r));
191 static inline isc_boolean_t
192 checkowner_eui64(ARGS_CHECKOWNER) {
194 REQUIRE(type == 109);
196 UNUSED(name);
197 UNUSED(type);
198 UNUSED(rdclass);
199 UNUSED(wildcard);
201 return (ISC_TRUE);
204 static inline isc_boolean_t
205 checknames_eui64(ARGS_CHECKNAMES) {
207 REQUIRE(rdata->type == 109);
208 REQUIRE(rdata->length == 8);
210 UNUSED(rdata);
211 UNUSED(owner);
212 UNUSED(bad);
214 return (ISC_TRUE);
217 static inline int
218 casecompare_eui64(ARGS_COMPARE) {
219 return (compare_eui64(rdata1, rdata2));
222 #endif /* RDATA_GENERIC_EUI64_109_C */