Remove building with NOCRYPTO option
[minix.git] / external / bsd / bind / dist / lib / dns / rdata / generic / cname_5.c
blobc4b07f7107d7836be61ded1ef67c2f0edf5e6cd3
1 /* $NetBSD: cname_5.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) 1998-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: cname_5.c,v 1.49 2009/12/04 22:06:37 tbox Exp */
22 /* reviewed: Wed Mar 15 16:48:45 PST 2000 by brister */
24 #ifndef RDATA_GENERIC_CNAME_5_C
25 #define RDATA_GENERIC_CNAME_5_C
27 #define RRTYPE_CNAME_ATTRIBUTES \
28 (DNS_RDATATYPEATTR_EXCLUSIVE | DNS_RDATATYPEATTR_SINGLETON)
30 static inline isc_result_t
31 fromtext_cname(ARGS_FROMTEXT) {
32 isc_token_t token;
33 dns_name_t name;
34 isc_buffer_t buffer;
36 REQUIRE(type == 5);
38 UNUSED(type);
39 UNUSED(rdclass);
40 UNUSED(callbacks);
42 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
43 ISC_FALSE));
45 dns_name_init(&name, NULL);
46 buffer_fromregion(&buffer, &token.value.as_region);
47 origin = (origin != NULL) ? origin : dns_rootname;
48 RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target));
49 return (ISC_R_SUCCESS);
52 static inline isc_result_t
53 totext_cname(ARGS_TOTEXT) {
54 isc_region_t region;
55 dns_name_t name;
56 dns_name_t prefix;
57 isc_boolean_t sub;
59 REQUIRE(rdata->type == 5);
60 REQUIRE(rdata->length != 0);
62 dns_name_init(&name, NULL);
63 dns_name_init(&prefix, NULL);
65 dns_rdata_toregion(rdata, &region);
66 dns_name_fromregion(&name, &region);
68 sub = name_prefix(&name, tctx->origin, &prefix);
70 return (dns_name_totext(&prefix, sub, target));
73 static inline isc_result_t
74 fromwire_cname(ARGS_FROMWIRE) {
75 dns_name_t name;
77 REQUIRE(type == 5);
79 UNUSED(type);
80 UNUSED(rdclass);
82 dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14);
84 dns_name_init(&name, NULL);
85 return (dns_name_fromwire(&name, source, dctx, options, target));
88 static inline isc_result_t
89 towire_cname(ARGS_TOWIRE) {
90 dns_name_t name;
91 dns_offsets_t offsets;
92 isc_region_t region;
94 REQUIRE(rdata->type == 5);
95 REQUIRE(rdata->length != 0);
97 dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
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_cname(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 == 5);
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_cname(ARGS_FROMSTRUCT) {
133 dns_rdata_cname_t *cname = source;
134 isc_region_t region;
136 REQUIRE(type == 5);
137 REQUIRE(source != NULL);
138 REQUIRE(cname->common.rdtype == type);
139 REQUIRE(cname->common.rdclass == rdclass);
141 UNUSED(type);
142 UNUSED(rdclass);
144 dns_name_toregion(&cname->cname, &region);
145 return (isc_buffer_copyregion(target, &region));
148 static inline isc_result_t
149 tostruct_cname(ARGS_TOSTRUCT) {
150 isc_region_t region;
151 dns_rdata_cname_t *cname = target;
152 dns_name_t name;
154 REQUIRE(rdata->type == 5);
155 REQUIRE(target != NULL);
156 REQUIRE(rdata->length != 0);
158 cname->common.rdclass = rdata->rdclass;
159 cname->common.rdtype = rdata->type;
160 ISC_LINK_INIT(&cname->common, link);
162 dns_name_init(&name, NULL);
163 dns_rdata_toregion(rdata, &region);
164 dns_name_fromregion(&name, &region);
165 dns_name_init(&cname->cname, NULL);
166 RETERR(name_duporclone(&name, mctx, &cname->cname));
167 cname->mctx = mctx;
168 return (ISC_R_SUCCESS);
171 static inline void
172 freestruct_cname(ARGS_FREESTRUCT) {
173 dns_rdata_cname_t *cname = source;
175 REQUIRE(source != NULL);
177 if (cname->mctx == NULL)
178 return;
180 dns_name_free(&cname->cname, cname->mctx);
181 cname->mctx = NULL;
184 static inline isc_result_t
185 additionaldata_cname(ARGS_ADDLDATA) {
186 UNUSED(rdata);
187 UNUSED(add);
188 UNUSED(arg);
190 REQUIRE(rdata->type == 5);
192 return (ISC_R_SUCCESS);
195 static inline isc_result_t
196 digest_cname(ARGS_DIGEST) {
197 isc_region_t r;
198 dns_name_t name;
200 REQUIRE(rdata->type == 5);
202 dns_rdata_toregion(rdata, &r);
203 dns_name_init(&name, NULL);
204 dns_name_fromregion(&name, &r);
206 return (dns_name_digest(&name, digest, arg));
209 static inline isc_boolean_t
210 checkowner_cname(ARGS_CHECKOWNER) {
212 REQUIRE(type == 5);
214 UNUSED(name);
215 UNUSED(type);
216 UNUSED(rdclass);
217 UNUSED(wildcard);
219 return (ISC_TRUE);
222 static inline isc_boolean_t
223 checknames_cname(ARGS_CHECKNAMES) {
225 REQUIRE(rdata->type == 5);
227 UNUSED(rdata);
228 UNUSED(owner);
229 UNUSED(bad);
231 return (ISC_TRUE);
234 static inline int
235 casecompare_cname(ARGS_COMPARE) {
236 return (compare_cname(rdata1, rdata2));
239 #endif /* RDATA_GENERIC_CNAME_5_C */