Remove building with NOCRYPTO option
[minix.git] / external / bsd / bind / dist / lib / dns / rdata / generic / dname_39.c
blobce81e9de871cdc107cc8c707b03a35c4d8bb42b0
1 /* $NetBSD: dname_39.c,v 1.4 2014/12/10 04:37:59 christos Exp $ */
3 /*
4 * Copyright (C) 2004, 2007, 2009 Internet Systems Consortium, Inc. ("ISC")
5 * Copyright (C) 1999-2001 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: dname_39.c,v 1.40 2009/12/04 22:06:37 tbox Exp */
22 /* Reviewed: Wed Mar 15 16:52:38 PST 2000 by explorer */
24 /* RFC2672 */
26 #ifndef RDATA_GENERIC_DNAME_39_C
27 #define RDATA_GENERIC_DNAME_39_C
29 #define RRTYPE_DNAME_ATTRIBUTES (DNS_RDATATYPEATTR_SINGLETON)
31 static inline isc_result_t
32 fromtext_dname(ARGS_FROMTEXT) {
33 isc_token_t token;
34 dns_name_t name;
35 isc_buffer_t buffer;
37 REQUIRE(type == 39);
39 UNUSED(type);
40 UNUSED(rdclass);
41 UNUSED(callbacks);
43 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
44 ISC_FALSE));
46 dns_name_init(&name, NULL);
47 buffer_fromregion(&buffer, &token.value.as_region);
48 origin = (origin != NULL) ? origin : dns_rootname;
49 RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target));
50 return (ISC_R_SUCCESS);
53 static inline isc_result_t
54 totext_dname(ARGS_TOTEXT) {
55 isc_region_t region;
56 dns_name_t name;
57 dns_name_t prefix;
58 isc_boolean_t sub;
60 REQUIRE(rdata->type == 39);
61 REQUIRE(rdata->length != 0);
63 dns_name_init(&name, NULL);
64 dns_name_init(&prefix, NULL);
66 dns_rdata_toregion(rdata, &region);
67 dns_name_fromregion(&name, &region);
69 sub = name_prefix(&name, tctx->origin, &prefix);
71 return (dns_name_totext(&prefix, sub, target));
74 static inline isc_result_t
75 fromwire_dname(ARGS_FROMWIRE) {
76 dns_name_t name;
78 REQUIRE(type == 39);
80 UNUSED(type);
81 UNUSED(rdclass);
83 dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
85 dns_name_init(&name, NULL);
86 return(dns_name_fromwire(&name, source, dctx, options, target));
89 static inline isc_result_t
90 towire_dname(ARGS_TOWIRE) {
91 dns_name_t name;
92 dns_offsets_t offsets;
93 isc_region_t region;
95 REQUIRE(rdata->type == 39);
96 REQUIRE(rdata->length != 0);
98 dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
99 dns_name_init(&name, offsets);
100 dns_rdata_toregion(rdata, &region);
101 dns_name_fromregion(&name, &region);
103 return (dns_name_towire(&name, cctx, target));
106 static inline int
107 compare_dname(ARGS_COMPARE) {
108 dns_name_t name1;
109 dns_name_t name2;
110 isc_region_t region1;
111 isc_region_t region2;
113 REQUIRE(rdata1->type == rdata2->type);
114 REQUIRE(rdata1->rdclass == rdata2->rdclass);
115 REQUIRE(rdata1->type == 39);
116 REQUIRE(rdata1->length != 0);
117 REQUIRE(rdata2->length != 0);
119 dns_name_init(&name1, NULL);
120 dns_name_init(&name2, NULL);
122 dns_rdata_toregion(rdata1, &region1);
123 dns_rdata_toregion(rdata2, &region2);
125 dns_name_fromregion(&name1, &region1);
126 dns_name_fromregion(&name2, &region2);
128 return (dns_name_rdatacompare(&name1, &name2));
131 static inline isc_result_t
132 fromstruct_dname(ARGS_FROMSTRUCT) {
133 dns_rdata_dname_t *dname = source;
134 isc_region_t region;
136 REQUIRE(type == 39);
137 REQUIRE(source != NULL);
138 REQUIRE(dname->common.rdtype == type);
139 REQUIRE(dname->common.rdclass == rdclass);
141 UNUSED(type);
142 UNUSED(rdclass);
144 dns_name_toregion(&dname->dname, &region);
145 return (isc_buffer_copyregion(target, &region));
148 static inline isc_result_t
149 tostruct_dname(ARGS_TOSTRUCT) {
150 isc_region_t region;
151 dns_rdata_dname_t *dname = target;
152 dns_name_t name;
154 REQUIRE(rdata->type == 39);
155 REQUIRE(target != NULL);
156 REQUIRE(rdata->length != 0);
158 dname->common.rdclass = rdata->rdclass;
159 dname->common.rdtype = rdata->type;
160 ISC_LINK_INIT(&dname->common, link);
162 dns_name_init(&name, NULL);
163 dns_rdata_toregion(rdata, &region);
164 dns_name_fromregion(&name, &region);
165 dns_name_init(&dname->dname, NULL);
166 RETERR(name_duporclone(&name, mctx, &dname->dname));
167 dname->mctx = mctx;
168 return (ISC_R_SUCCESS);
171 static inline void
172 freestruct_dname(ARGS_FREESTRUCT) {
173 dns_rdata_dname_t *dname = source;
175 REQUIRE(source != NULL);
176 REQUIRE(dname->common.rdtype == 39);
178 if (dname->mctx == NULL)
179 return;
181 dns_name_free(&dname->dname, dname->mctx);
182 dname->mctx = NULL;
185 static inline isc_result_t
186 additionaldata_dname(ARGS_ADDLDATA) {
187 UNUSED(rdata);
188 UNUSED(add);
189 UNUSED(arg);
191 REQUIRE(rdata->type == 39);
193 return (ISC_R_SUCCESS);
196 static inline isc_result_t
197 digest_dname(ARGS_DIGEST) {
198 isc_region_t r;
199 dns_name_t name;
201 REQUIRE(rdata->type == 39);
203 dns_rdata_toregion(rdata, &r);
204 dns_name_init(&name, NULL);
205 dns_name_fromregion(&name, &r);
207 return (dns_name_digest(&name, digest, arg));
210 static inline isc_boolean_t
211 checkowner_dname(ARGS_CHECKOWNER) {
213 REQUIRE(type == 39);
215 UNUSED(name);
216 UNUSED(type);
217 UNUSED(rdclass);
218 UNUSED(wildcard);
220 return (ISC_TRUE);
223 static inline isc_boolean_t
224 checknames_dname(ARGS_CHECKNAMES) {
226 REQUIRE(rdata->type == 39);
228 UNUSED(rdata);
229 UNUSED(owner);
230 UNUSED(bad);
232 return (ISC_TRUE);
235 static inline int
236 casecompare_dname(ARGS_COMPARE) {
237 return (compare_dname(rdata1, rdata2));
239 #endif /* RDATA_GENERIC_DNAME_39_C */