Remove building with NOCRYPTO option
[minix.git] / external / bsd / bind / dist / lib / dns / rdata / generic / hinfo_13.c
blobc40d2efb20e72293a722dbee25701244d1c7613d
1 /* $NetBSD: hinfo_13.c,v 1.4 2014/12/10 04:37:59 christos Exp $ */
3 /*
4 * Copyright (C) 2004, 2007, 2009, 2014 Internet Systems Consortium, Inc. ("ISC")
5 * Copyright (C) 1998-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: hinfo_13.c,v 1.46 2009/12/04 22:06:37 tbox Exp */
23 * Reviewed: Wed Mar 15 16:47:10 PST 2000 by halley.
26 #ifndef RDATA_GENERIC_HINFO_13_C
27 #define RDATA_GENERIC_HINFO_13_C
29 #define RRTYPE_HINFO_ATTRIBUTES (0)
31 static inline isc_result_t
32 fromtext_hinfo(ARGS_FROMTEXT) {
33 isc_token_t token;
34 int i;
36 UNUSED(type);
37 UNUSED(rdclass);
38 UNUSED(origin);
39 UNUSED(options);
40 UNUSED(callbacks);
42 REQUIRE(type == 13);
44 for (i = 0; i < 2; i++) {
45 RETERR(isc_lex_getmastertoken(lexer, &token,
46 isc_tokentype_qstring,
47 ISC_FALSE));
48 RETTOK(txt_fromtext(&token.value.as_textregion, target));
50 return (ISC_R_SUCCESS);
53 static inline isc_result_t
54 totext_hinfo(ARGS_TOTEXT) {
55 isc_region_t region;
57 UNUSED(tctx);
59 REQUIRE(rdata->type == 13);
60 REQUIRE(rdata->length != 0);
62 dns_rdata_toregion(rdata, &region);
63 RETERR(txt_totext(&region, ISC_TRUE, target));
64 RETERR(str_totext(" ", target));
65 return (txt_totext(&region, ISC_TRUE, target));
68 static inline isc_result_t
69 fromwire_hinfo(ARGS_FROMWIRE) {
71 REQUIRE(type == 13);
73 UNUSED(type);
74 UNUSED(dctx);
75 UNUSED(rdclass);
76 UNUSED(options);
78 RETERR(txt_fromwire(source, target));
79 return (txt_fromwire(source, target));
82 static inline isc_result_t
83 towire_hinfo(ARGS_TOWIRE) {
85 UNUSED(cctx);
87 REQUIRE(rdata->type == 13);
88 REQUIRE(rdata->length != 0);
90 return (mem_tobuffer(target, rdata->data, rdata->length));
93 static inline int
94 compare_hinfo(ARGS_COMPARE) {
95 isc_region_t r1;
96 isc_region_t r2;
98 REQUIRE(rdata1->type == rdata2->type);
99 REQUIRE(rdata1->rdclass == rdata2->rdclass);
100 REQUIRE(rdata1->type == 13);
101 REQUIRE(rdata1->length != 0);
102 REQUIRE(rdata2->length != 0);
104 dns_rdata_toregion(rdata1, &r1);
105 dns_rdata_toregion(rdata2, &r2);
106 return (isc_region_compare(&r1, &r2));
109 static inline isc_result_t
110 fromstruct_hinfo(ARGS_FROMSTRUCT) {
111 dns_rdata_hinfo_t *hinfo = source;
113 REQUIRE(type == 13);
114 REQUIRE(source != NULL);
115 REQUIRE(hinfo->common.rdtype == type);
116 REQUIRE(hinfo->common.rdclass == rdclass);
118 UNUSED(type);
119 UNUSED(rdclass);
121 RETERR(uint8_tobuffer(hinfo->cpu_len, target));
122 RETERR(mem_tobuffer(target, hinfo->cpu, hinfo->cpu_len));
123 RETERR(uint8_tobuffer(hinfo->os_len, target));
124 return (mem_tobuffer(target, hinfo->os, hinfo->os_len));
127 static inline isc_result_t
128 tostruct_hinfo(ARGS_TOSTRUCT) {
129 dns_rdata_hinfo_t *hinfo = target;
130 isc_region_t region;
132 REQUIRE(rdata->type == 13);
133 REQUIRE(target != NULL);
134 REQUIRE(rdata->length != 0);
136 hinfo->common.rdclass = rdata->rdclass;
137 hinfo->common.rdtype = rdata->type;
138 ISC_LINK_INIT(&hinfo->common, link);
140 dns_rdata_toregion(rdata, &region);
141 hinfo->cpu_len = uint8_fromregion(&region);
142 isc_region_consume(&region, 1);
143 hinfo->cpu = mem_maybedup(mctx, region.base, hinfo->cpu_len);
144 if (hinfo->cpu == NULL)
145 return (ISC_R_NOMEMORY);
146 isc_region_consume(&region, hinfo->cpu_len);
148 hinfo->os_len = uint8_fromregion(&region);
149 isc_region_consume(&region, 1);
150 hinfo->os = mem_maybedup(mctx, region.base, hinfo->os_len);
151 if (hinfo->os == NULL)
152 goto cleanup;
154 hinfo->mctx = mctx;
155 return (ISC_R_SUCCESS);
157 cleanup:
158 if (mctx != NULL && hinfo->cpu != NULL)
159 isc_mem_free(mctx, hinfo->cpu);
160 return (ISC_R_NOMEMORY);
163 static inline void
164 freestruct_hinfo(ARGS_FREESTRUCT) {
165 dns_rdata_hinfo_t *hinfo = source;
167 REQUIRE(source != NULL);
169 if (hinfo->mctx == NULL)
170 return;
172 if (hinfo->cpu != NULL)
173 isc_mem_free(hinfo->mctx, hinfo->cpu);
174 if (hinfo->os != NULL)
175 isc_mem_free(hinfo->mctx, hinfo->os);
176 hinfo->mctx = NULL;
179 static inline isc_result_t
180 additionaldata_hinfo(ARGS_ADDLDATA) {
181 REQUIRE(rdata->type == 13);
183 UNUSED(add);
184 UNUSED(arg);
185 UNUSED(rdata);
187 return (ISC_R_SUCCESS);
190 static inline isc_result_t
191 digest_hinfo(ARGS_DIGEST) {
192 isc_region_t r;
194 REQUIRE(rdata->type == 13);
196 dns_rdata_toregion(rdata, &r);
198 return ((digest)(arg, &r));
201 static inline isc_boolean_t
202 checkowner_hinfo(ARGS_CHECKOWNER) {
204 REQUIRE(type == 13);
206 UNUSED(name);
207 UNUSED(type);
208 UNUSED(rdclass);
209 UNUSED(wildcard);
211 return (ISC_TRUE);
214 static inline isc_boolean_t
215 checknames_hinfo(ARGS_CHECKNAMES) {
217 REQUIRE(rdata->type == 13);
219 UNUSED(rdata);
220 UNUSED(owner);
221 UNUSED(bad);
223 return (ISC_TRUE);
226 static inline int
227 casecompare_hinfo(ARGS_COMPARE) {
228 return (compare_hinfo(rdata1, rdata2));
230 #endif /* RDATA_GENERIC_HINFO_13_C */