Remove building with NOCRYPTO option
[minix.git] / external / bsd / bind / dist / lib / dns / rdata / in_1 / aaaa_28.c
blobd19d4ed52abed9f0c369e19b88888eadbc1d267b
1 /* $NetBSD: aaaa_28.c,v 1.5 2014/12/10 04:37:59 christos Exp $ */
3 /*
4 * Copyright (C) 2004, 2005, 2007, 2009, 2014 Internet Systems Consortium, Inc. ("ISC")
5 * Copyright (C) 1999-2002 Internet Software Consortium.
7 * Permission to use, copy, modify, and/or distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
16 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
20 /* Id: aaaa_28.c,v 1.47 2009/12/04 22:06:37 tbox Exp */
22 /* Reviewed: Thu Mar 16 16:52:50 PST 2000 by bwelling */
24 /* RFC1886 */
26 #ifndef RDATA_IN_1_AAAA_28_C
27 #define RDATA_IN_1_AAAA_28_C
29 #include <isc/net.h>
31 #define RRTYPE_AAAA_ATTRIBUTES (0)
33 static inline isc_result_t
34 fromtext_in_aaaa(ARGS_FROMTEXT) {
35 isc_token_t token;
36 unsigned char addr[16];
37 isc_region_t region;
39 REQUIRE(type == 28);
40 REQUIRE(rdclass == 1);
42 UNUSED(type);
43 UNUSED(origin);
44 UNUSED(options);
45 UNUSED(rdclass);
46 UNUSED(callbacks);
48 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
49 ISC_FALSE));
51 if (inet_pton(AF_INET6, DNS_AS_STR(token), addr) != 1)
52 RETTOK(DNS_R_BADAAAA);
53 isc_buffer_availableregion(target, &region);
54 if (region.length < 16)
55 return (ISC_R_NOSPACE);
56 memmove(region.base, addr, 16);
57 isc_buffer_add(target, 16);
58 return (ISC_R_SUCCESS);
61 static inline isc_result_t
62 totext_in_aaaa(ARGS_TOTEXT) {
63 isc_region_t region;
65 UNUSED(tctx);
67 REQUIRE(rdata->type == 28);
68 REQUIRE(rdata->rdclass == 1);
69 REQUIRE(rdata->length == 16);
71 dns_rdata_toregion(rdata, &region);
72 return (inet_totext(AF_INET6, &region, target));
75 static inline isc_result_t
76 fromwire_in_aaaa(ARGS_FROMWIRE) {
77 isc_region_t sregion;
78 isc_region_t tregion;
80 REQUIRE(type == 28);
81 REQUIRE(rdclass == 1);
83 UNUSED(type);
84 UNUSED(dctx);
85 UNUSED(options);
86 UNUSED(rdclass);
88 isc_buffer_activeregion(source, &sregion);
89 isc_buffer_availableregion(target, &tregion);
90 if (sregion.length < 16)
91 return (ISC_R_UNEXPECTEDEND);
92 if (tregion.length < 16)
93 return (ISC_R_NOSPACE);
95 memmove(tregion.base, sregion.base, 16);
96 isc_buffer_forward(source, 16);
97 isc_buffer_add(target, 16);
98 return (ISC_R_SUCCESS);
101 static inline isc_result_t
102 towire_in_aaaa(ARGS_TOWIRE) {
103 isc_region_t region;
105 UNUSED(cctx);
107 REQUIRE(rdata->type == 28);
108 REQUIRE(rdata->rdclass == 1);
109 REQUIRE(rdata->length == 16);
111 isc_buffer_availableregion(target, &region);
112 if (region.length < rdata->length)
113 return (ISC_R_NOSPACE);
114 memmove(region.base, rdata->data, rdata->length);
115 isc_buffer_add(target, 16);
116 return (ISC_R_SUCCESS);
119 static inline int
120 compare_in_aaaa(ARGS_COMPARE) {
121 isc_region_t r1;
122 isc_region_t r2;
124 REQUIRE(rdata1->type == rdata2->type);
125 REQUIRE(rdata1->rdclass == rdata2->rdclass);
126 REQUIRE(rdata1->type == 28);
127 REQUIRE(rdata1->rdclass == 1);
128 REQUIRE(rdata1->length == 16);
129 REQUIRE(rdata2->length == 16);
131 dns_rdata_toregion(rdata1, &r1);
132 dns_rdata_toregion(rdata2, &r2);
133 return (isc_region_compare(&r1, &r2));
136 static inline isc_result_t
137 fromstruct_in_aaaa(ARGS_FROMSTRUCT) {
138 dns_rdata_in_aaaa_t *aaaa = source;
140 REQUIRE(type == 28);
141 REQUIRE(rdclass == 1);
142 REQUIRE(source != NULL);
143 REQUIRE(aaaa->common.rdtype == type);
144 REQUIRE(aaaa->common.rdclass == rdclass);
146 UNUSED(type);
147 UNUSED(rdclass);
149 return (mem_tobuffer(target, aaaa->in6_addr.s6_addr, 16));
152 static inline isc_result_t
153 tostruct_in_aaaa(ARGS_TOSTRUCT) {
154 dns_rdata_in_aaaa_t *aaaa = target;
155 isc_region_t r;
157 REQUIRE(rdata->type == 28);
158 REQUIRE(rdata->rdclass == 1);
159 REQUIRE(target != NULL);
160 REQUIRE(rdata->length == 16);
162 UNUSED(mctx);
164 aaaa->common.rdclass = rdata->rdclass;
165 aaaa->common.rdtype = rdata->type;
166 ISC_LINK_INIT(&aaaa->common, link);
168 dns_rdata_toregion(rdata, &r);
169 INSIST(r.length == 16);
170 memmove(aaaa->in6_addr.s6_addr, r.base, 16);
172 return (ISC_R_SUCCESS);
175 static inline void
176 freestruct_in_aaaa(ARGS_FREESTRUCT) {
177 dns_rdata_in_aaaa_t *aaaa = source;
179 REQUIRE(source != NULL);
180 REQUIRE(aaaa->common.rdclass == 1);
181 REQUIRE(aaaa->common.rdtype == 28);
183 UNUSED(aaaa);
186 static inline isc_result_t
187 additionaldata_in_aaaa(ARGS_ADDLDATA) {
188 REQUIRE(rdata->type == 28);
189 REQUIRE(rdata->rdclass == 1);
191 UNUSED(rdata);
192 UNUSED(add);
193 UNUSED(arg);
195 return (ISC_R_SUCCESS);
198 static inline isc_result_t
199 digest_in_aaaa(ARGS_DIGEST) {
200 isc_region_t r;
202 REQUIRE(rdata->type == 28);
203 REQUIRE(rdata->rdclass == 1);
205 dns_rdata_toregion(rdata, &r);
207 return ((digest)(arg, &r));
210 static inline isc_boolean_t
211 checkowner_in_aaaa(ARGS_CHECKOWNER) {
213 REQUIRE(type == 28);
214 REQUIRE(rdclass == 1);
216 UNUSED(type);
217 UNUSED(rdclass);
219 return (dns_name_ishostname(name, wildcard));
222 static inline isc_boolean_t
223 checknames_in_aaaa(ARGS_CHECKNAMES) {
225 REQUIRE(rdata->type == 28);
226 REQUIRE(rdata->rdclass == 1);
228 UNUSED(rdata);
229 UNUSED(owner);
230 UNUSED(bad);
232 return (ISC_TRUE);
235 static inline int
236 casecompare_in_aaaa(ARGS_COMPARE) {
237 return (compare_in_aaaa(rdata1, rdata2));
239 #endif /* RDATA_IN_1_AAAA_28_C */