Remove building with NOCRYPTO option
[minix.git] / external / bsd / bind / dist / lib / dns / rdata / generic / mf_4.c
blob38c544de4f04e1f1481cbdbee4f04733d2d6afcb
1 /* $NetBSD: mf_4.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: mf_4.c,v 1.47 2009/12/04 22:06:37 tbox Exp */
22 /* reviewed: Wed Mar 15 17:47:33 PST 2000 by brister */
24 #ifndef RDATA_GENERIC_MF_4_C
25 #define RDATA_GENERIC_MF_4_C
27 #define RRTYPE_MF_ATTRIBUTES (0)
29 static inline isc_result_t
30 fromtext_mf(ARGS_FROMTEXT) {
31 isc_token_t token;
32 dns_name_t name;
33 isc_buffer_t buffer;
35 REQUIRE(type == 4);
37 UNUSED(type);
38 UNUSED(rdclass);
39 UNUSED(callbacks);
41 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
42 ISC_FALSE));
44 dns_name_init(&name, NULL);
45 buffer_fromregion(&buffer, &token.value.as_region);
46 origin = (origin != NULL) ? origin : dns_rootname;
47 RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target));
48 return (ISC_R_SUCCESS);
51 static inline isc_result_t
52 totext_mf(ARGS_TOTEXT) {
53 isc_region_t region;
54 dns_name_t name;
55 dns_name_t prefix;
56 isc_boolean_t sub;
58 REQUIRE(rdata->type == 4);
59 REQUIRE(rdata->length != 0);
61 dns_name_init(&name, NULL);
62 dns_name_init(&prefix, NULL);
64 dns_rdata_toregion(rdata, &region);
65 dns_name_fromregion(&name, &region);
67 sub = name_prefix(&name, tctx->origin, &prefix);
69 return (dns_name_totext(&prefix, sub, target));
72 static inline isc_result_t
73 fromwire_mf(ARGS_FROMWIRE) {
74 dns_name_t name;
76 REQUIRE(type == 4);
78 UNUSED(type);
79 UNUSED(rdclass);
81 dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14);
83 dns_name_init(&name, NULL);
84 return (dns_name_fromwire(&name, source, dctx, options, target));
87 static inline isc_result_t
88 towire_mf(ARGS_TOWIRE) {
89 dns_name_t name;
90 dns_offsets_t offsets;
91 isc_region_t region;
93 REQUIRE(rdata->type == 4);
94 REQUIRE(rdata->length != 0);
96 dns_compress_setmethods(cctx, DNS_COMPRESS_GLOBAL14);
98 dns_name_init(&name, offsets);
99 dns_rdata_toregion(rdata, &region);
100 dns_name_fromregion(&name, &region);
102 return (dns_name_towire(&name, cctx, target));
105 static inline int
106 compare_mf(ARGS_COMPARE) {
107 dns_name_t name1;
108 dns_name_t name2;
109 isc_region_t region1;
110 isc_region_t region2;
112 REQUIRE(rdata1->type == rdata2->type);
113 REQUIRE(rdata1->rdclass == rdata2->rdclass);
114 REQUIRE(rdata1->type == 4);
115 REQUIRE(rdata1->length != 0);
116 REQUIRE(rdata2->length != 0);
118 dns_name_init(&name1, NULL);
119 dns_name_init(&name2, NULL);
121 dns_rdata_toregion(rdata1, &region1);
122 dns_rdata_toregion(rdata2, &region2);
124 dns_name_fromregion(&name1, &region1);
125 dns_name_fromregion(&name2, &region2);
127 return (dns_name_rdatacompare(&name1, &name2));
130 static inline isc_result_t
131 fromstruct_mf(ARGS_FROMSTRUCT) {
132 dns_rdata_mf_t *mf = source;
133 isc_region_t region;
135 REQUIRE(type == 4);
136 REQUIRE(source != NULL);
137 REQUIRE(mf->common.rdtype == type);
138 REQUIRE(mf->common.rdclass == rdclass);
140 UNUSED(type);
141 UNUSED(rdclass);
143 dns_name_toregion(&mf->mf, &region);
144 return (isc_buffer_copyregion(target, &region));
147 static inline isc_result_t
148 tostruct_mf(ARGS_TOSTRUCT) {
149 dns_rdata_mf_t *mf = target;
150 isc_region_t r;
151 dns_name_t name;
153 REQUIRE(rdata->type == 4);
154 REQUIRE(target != NULL);
155 REQUIRE(rdata->length != 0);
157 mf->common.rdclass = rdata->rdclass;
158 mf->common.rdtype = rdata->type;
159 ISC_LINK_INIT(&mf->common, link);
161 dns_name_init(&name, NULL);
162 dns_rdata_toregion(rdata, &r);
163 dns_name_fromregion(&name, &r);
164 dns_name_init(&mf->mf, NULL);
165 RETERR(name_duporclone(&name, mctx, &mf->mf));
166 mf->mctx = mctx;
167 return (ISC_R_SUCCESS);
170 static inline void
171 freestruct_mf(ARGS_FREESTRUCT) {
172 dns_rdata_mf_t *mf = source;
174 REQUIRE(source != NULL);
175 REQUIRE(mf->common.rdtype == 4);
177 if (mf->mctx == NULL)
178 return;
179 dns_name_free(&mf->mf, mf->mctx);
180 mf->mctx = NULL;
183 static inline isc_result_t
184 additionaldata_mf(ARGS_ADDLDATA) {
185 dns_name_t name;
186 dns_offsets_t offsets;
187 isc_region_t region;
189 REQUIRE(rdata->type == 4);
191 dns_name_init(&name, offsets);
192 dns_rdata_toregion(rdata, &region);
193 dns_name_fromregion(&name, &region);
195 return ((add)(arg, &name, dns_rdatatype_a));
198 static inline isc_result_t
199 digest_mf(ARGS_DIGEST) {
200 isc_region_t r;
201 dns_name_t name;
203 REQUIRE(rdata->type == 4);
205 dns_rdata_toregion(rdata, &r);
206 dns_name_init(&name, NULL);
207 dns_name_fromregion(&name, &r);
209 return (dns_name_digest(&name, digest, arg));
212 static inline isc_boolean_t
213 checkowner_mf(ARGS_CHECKOWNER) {
215 REQUIRE(type == 4);
217 UNUSED(name);
218 UNUSED(type);
219 UNUSED(rdclass);
220 UNUSED(wildcard);
222 return (ISC_TRUE);
225 static inline isc_boolean_t
226 checknames_mf(ARGS_CHECKNAMES) {
228 REQUIRE(rdata->type == 4);
230 UNUSED(rdata);
231 UNUSED(owner);
232 UNUSED(bad);
234 return (ISC_TRUE);
237 static inline int
238 casecompare_mf(ARGS_COMPARE) {
239 return (compare_mf(rdata1, rdata2));
242 #endif /* RDATA_GENERIC_MF_4_C */