Remove building with NOCRYPTO option
[minix.git] / external / bsd / bind / dist / lib / dns / rdata / generic / x25_19.c
blobe1df5058a192e96dd0186664e529dfc5036edd35
1 /* $NetBSD: x25_19.c,v 1.4 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: x25_19.c,v 1.41 2009/12/04 22:06:37 tbox Exp */
22 /* Reviewed: Thu Mar 16 16:15:57 PST 2000 by bwelling */
24 /* RFC1183 */
26 #ifndef RDATA_GENERIC_X25_19_C
27 #define RDATA_GENERIC_X25_19_C
29 #define RRTYPE_X25_ATTRIBUTES (0)
31 static inline isc_result_t
32 fromtext_x25(ARGS_FROMTEXT) {
33 isc_token_t token;
34 unsigned int i;
36 REQUIRE(type == 19);
38 UNUSED(type);
39 UNUSED(rdclass);
40 UNUSED(origin);
41 UNUSED(options);
42 UNUSED(callbacks);
44 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring,
45 ISC_FALSE));
46 if (token.value.as_textregion.length < 4)
47 RETTOK(DNS_R_SYNTAX);
48 for (i = 0; i < token.value.as_textregion.length; i++)
49 if (!isdigit(token.value.as_textregion.base[i] & 0xff))
50 RETTOK(ISC_R_RANGE);
51 RETTOK(txt_fromtext(&token.value.as_textregion, target));
52 return (ISC_R_SUCCESS);
55 static inline isc_result_t
56 totext_x25(ARGS_TOTEXT) {
57 isc_region_t region;
59 UNUSED(tctx);
61 REQUIRE(rdata->type == 19);
62 REQUIRE(rdata->length != 0);
64 dns_rdata_toregion(rdata, &region);
65 return (txt_totext(&region, ISC_TRUE, target));
68 static inline isc_result_t
69 fromwire_x25(ARGS_FROMWIRE) {
70 isc_region_t sr;
72 REQUIRE(type == 19);
74 UNUSED(type);
75 UNUSED(dctx);
76 UNUSED(rdclass);
77 UNUSED(options);
79 isc_buffer_activeregion(source, &sr);
80 if (sr.length < 5)
81 return (DNS_R_FORMERR);
82 return (txt_fromwire(source, target));
85 static inline isc_result_t
86 towire_x25(ARGS_TOWIRE) {
87 UNUSED(cctx);
89 REQUIRE(rdata->type == 19);
90 REQUIRE(rdata->length != 0);
92 return (mem_tobuffer(target, rdata->data, rdata->length));
95 static inline int
96 compare_x25(ARGS_COMPARE) {
97 isc_region_t r1;
98 isc_region_t r2;
100 REQUIRE(rdata1->type == rdata2->type);
101 REQUIRE(rdata1->rdclass == rdata2->rdclass);
102 REQUIRE(rdata1->type == 19);
103 REQUIRE(rdata1->length != 0);
104 REQUIRE(rdata2->length != 0);
106 dns_rdata_toregion(rdata1, &r1);
107 dns_rdata_toregion(rdata2, &r2);
108 return (isc_region_compare(&r1, &r2));
111 static inline isc_result_t
112 fromstruct_x25(ARGS_FROMSTRUCT) {
113 dns_rdata_x25_t *x25 = source;
114 isc_uint8_t i;
116 REQUIRE(type == 19);
117 REQUIRE(source != NULL);
118 REQUIRE(x25->common.rdtype == type);
119 REQUIRE(x25->common.rdclass == rdclass);
120 REQUIRE(x25->x25 != NULL && x25->x25_len != 0);
122 UNUSED(type);
123 UNUSED(rdclass);
125 if (x25->x25_len < 4)
126 return (ISC_R_RANGE);
128 for (i = 0; i < x25->x25_len; i++)
129 if (!isdigit(x25->x25[i] & 0xff))
130 return (ISC_R_RANGE);
132 RETERR(uint8_tobuffer(x25->x25_len, target));
133 return (mem_tobuffer(target, x25->x25, x25->x25_len));
136 static inline isc_result_t
137 tostruct_x25(ARGS_TOSTRUCT) {
138 dns_rdata_x25_t *x25 = target;
139 isc_region_t r;
141 REQUIRE(rdata->type == 19);
142 REQUIRE(target != NULL);
143 REQUIRE(rdata->length != 0);
145 x25->common.rdclass = rdata->rdclass;
146 x25->common.rdtype = rdata->type;
147 ISC_LINK_INIT(&x25->common, link);
149 dns_rdata_toregion(rdata, &r);
150 x25->x25_len = uint8_fromregion(&r);
151 isc_region_consume(&r, 1);
152 x25->x25 = mem_maybedup(mctx, r.base, x25->x25_len);
153 if (x25->x25 == NULL)
154 return (ISC_R_NOMEMORY);
156 x25->mctx = mctx;
157 return (ISC_R_SUCCESS);
160 static inline void
161 freestruct_x25(ARGS_FREESTRUCT) {
162 dns_rdata_x25_t *x25 = source;
163 REQUIRE(source != NULL);
164 REQUIRE(x25->common.rdtype == 19);
166 if (x25->mctx == NULL)
167 return;
169 if (x25->x25 != NULL)
170 isc_mem_free(x25->mctx, x25->x25);
171 x25->mctx = NULL;
174 static inline isc_result_t
175 additionaldata_x25(ARGS_ADDLDATA) {
176 REQUIRE(rdata->type == 19);
178 UNUSED(rdata);
179 UNUSED(add);
180 UNUSED(arg);
182 return (ISC_R_SUCCESS);
185 static inline isc_result_t
186 digest_x25(ARGS_DIGEST) {
187 isc_region_t r;
189 REQUIRE(rdata->type == 19);
191 dns_rdata_toregion(rdata, &r);
193 return ((digest)(arg, &r));
196 static inline isc_boolean_t
197 checkowner_x25(ARGS_CHECKOWNER) {
199 REQUIRE(type == 19);
201 UNUSED(name);
202 UNUSED(type);
203 UNUSED(rdclass);
204 UNUSED(wildcard);
206 return (ISC_TRUE);
209 static inline isc_boolean_t
210 checknames_x25(ARGS_CHECKNAMES) {
212 REQUIRE(rdata->type == 19);
214 UNUSED(rdata);
215 UNUSED(owner);
216 UNUSED(bad);
218 return (ISC_TRUE);
221 static inline int
222 casecompare_x25(ARGS_COMPARE) {
223 return (compare_x25(rdata1, rdata2));
226 #endif /* RDATA_GENERIC_X25_19_C */