Remove building with NOCRYPTO option
[minix.git] / external / bsd / bind / dist / lib / dns / rdata / generic / nid_104.c
blobc37add0a101ac431c13304d6e23c871fe85c785d
1 /* $NetBSD: nid_104.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_NID_104_C
20 #define RDATA_GENERIC_NID_104_C
22 #include <string.h>
24 #include <isc/net.h>
26 #define RRTYPE_NID_ATTRIBUTES (0)
28 static inline isc_result_t
29 fromtext_nid(ARGS_FROMTEXT) {
30 isc_token_t token;
31 unsigned char locator[NS_LOCATORSZ];
33 REQUIRE(type == 104);
35 UNUSED(type);
36 UNUSED(rdclass);
37 UNUSED(origin);
38 UNUSED(options);
39 UNUSED(callbacks);
41 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number,
42 ISC_FALSE));
43 if (token.value.as_ulong > 0xffffU)
44 RETTOK(ISC_R_RANGE);
45 RETERR(uint16_tobuffer(token.value.as_ulong, target));
47 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
48 ISC_FALSE));
50 if (locator_pton(DNS_AS_STR(token), locator) != 1)
51 RETTOK(DNS_R_SYNTAX);
52 return (mem_tobuffer(target, locator, NS_LOCATORSZ));
55 static inline isc_result_t
56 totext_nid(ARGS_TOTEXT) {
57 isc_region_t region;
58 char buf[sizeof("xxxx:xxxx:xxxx:xxxx")];
59 unsigned short num;
61 REQUIRE(rdata->type == 104);
62 REQUIRE(rdata->length != 0);
64 UNUSED(tctx);
66 dns_rdata_toregion(rdata, &region);
67 num = uint16_fromregion(&region);
68 isc_region_consume(&region, 2);
69 sprintf(buf, "%u", num);
70 RETERR(str_totext(buf, target));
72 RETERR(str_totext(" ", target));
74 sprintf(buf, "%x:%x:%x:%x",
75 region.base[0]<<8 | region.base[1],
76 region.base[2]<<8 | region.base[3],
77 region.base[4]<<8 | region.base[5],
78 region.base[6]<<8 | region.base[7]);
79 return (str_totext(buf, target));
82 static inline isc_result_t
83 fromwire_nid(ARGS_FROMWIRE) {
84 isc_region_t sregion;
86 REQUIRE(type == 104);
88 UNUSED(type);
89 UNUSED(options);
90 UNUSED(rdclass);
91 UNUSED(dctx);
93 isc_buffer_activeregion(source, &sregion);
94 if (sregion.length != 10)
95 return (DNS_R_FORMERR);
96 isc_buffer_forward(source, sregion.length);
97 return (mem_tobuffer(target, sregion.base, sregion.length));
100 static inline isc_result_t
101 towire_nid(ARGS_TOWIRE) {
103 REQUIRE(rdata->type == 104);
104 REQUIRE(rdata->length == 10);
106 UNUSED(cctx);
108 return (mem_tobuffer(target, rdata->data, rdata->length));
111 static inline int
112 compare_nid(ARGS_COMPARE) {
113 isc_region_t region1;
114 isc_region_t region2;
116 REQUIRE(rdata1->type == rdata2->type);
117 REQUIRE(rdata1->rdclass == rdata2->rdclass);
118 REQUIRE(rdata1->type == 104);
119 REQUIRE(rdata1->length == 10);
120 REQUIRE(rdata2->length == 10);
122 dns_rdata_toregion(rdata1, &region1);
123 dns_rdata_toregion(rdata2, &region2);
124 return (isc_region_compare(&region1, &region2));
127 static inline isc_result_t
128 fromstruct_nid(ARGS_FROMSTRUCT) {
129 dns_rdata_nid_t *nid = source;
131 REQUIRE(type == 104);
132 REQUIRE(source != NULL);
133 REQUIRE(nid->common.rdtype == type);
134 REQUIRE(nid->common.rdclass == rdclass);
136 UNUSED(type);
137 UNUSED(rdclass);
139 RETERR(uint16_tobuffer(nid->pref, target));
140 return (mem_tobuffer(target, nid->nid, sizeof(nid->nid)));
143 static inline isc_result_t
144 tostruct_nid(ARGS_TOSTRUCT) {
145 isc_region_t region;
146 dns_rdata_nid_t *nid = target;
148 REQUIRE(rdata->type == 104);
149 REQUIRE(target != NULL);
150 REQUIRE(rdata->length == 10);
152 UNUSED(mctx);
154 nid->common.rdclass = rdata->rdclass;
155 nid->common.rdtype = rdata->type;
156 ISC_LINK_INIT(&nid->common, link);
158 dns_rdata_toregion(rdata, &region);
159 nid->pref = uint16_fromregion(&region);
160 memmove(nid->nid, region.base, region.length);
161 return (ISC_R_SUCCESS);
164 static inline void
165 freestruct_nid(ARGS_FREESTRUCT) {
166 dns_rdata_nid_t *nid = source;
168 REQUIRE(source != NULL);
169 REQUIRE(nid->common.rdtype == 104);
171 return;
174 static inline isc_result_t
175 additionaldata_nid(ARGS_ADDLDATA) {
177 REQUIRE(rdata->type == 104);
178 REQUIRE(rdata->length == 10);
180 UNUSED(rdata);
181 UNUSED(add);
182 UNUSED(arg);
184 return (ISC_R_SUCCESS);
187 static inline isc_result_t
188 digest_nid(ARGS_DIGEST) {
189 isc_region_t r;
191 REQUIRE(rdata->type == 104);
192 REQUIRE(rdata->length == 10);
194 dns_rdata_toregion(rdata, &r);
196 return ((digest)(arg, &r));
199 static inline isc_boolean_t
200 checkowner_nid(ARGS_CHECKOWNER) {
202 REQUIRE(type == 104);
204 UNUSED(name);
205 UNUSED(type);
206 UNUSED(rdclass);
207 UNUSED(wildcard);
209 return (ISC_TRUE);
212 static inline isc_boolean_t
213 checknames_nid(ARGS_CHECKNAMES) {
215 REQUIRE(rdata->type == 104);
216 REQUIRE(rdata->length == 10);
218 UNUSED(rdata);
219 UNUSED(owner);
220 UNUSED(bad);
222 return (ISC_TRUE);
225 static inline int
226 casecompare_nid(ARGS_COMPARE) {
227 return (compare_nid(rdata1, rdata2));
230 #endif /* RDATA_GENERIC_NID_104_C */