Remove building with NOCRYPTO option
[minix.git] / external / bsd / bind / dist / lib / dns / rdata / in_1 / nsap-ptr_23.c
blob4c4b843d1671cc0b6cd42e7c7cc54d06fe4da870
1 /* $NetBSD: nsap-ptr_23.c,v 1.4 2014/12/10 04:37:59 christos Exp $ */
3 /*
4 * Copyright (C) 2004, 2005, 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: nsap-ptr_23.c,v 1.40 2009/12/04 22:06:37 tbox Exp */
22 /* Reviewed: Fri Mar 17 10:16:02 PST 2000 by gson */
24 /* RFC1348. Obsoleted in RFC 1706 - use PTR instead. */
26 #ifndef RDATA_IN_1_NSAP_PTR_23_C
27 #define RDATA_IN_1_NSAP_PTR_23_C
29 #define RRTYPE_NSAP_PTR_ATTRIBUTES (0)
31 static inline isc_result_t
32 fromtext_in_nsap_ptr(ARGS_FROMTEXT) {
33 isc_token_t token;
34 dns_name_t name;
35 isc_buffer_t buffer;
37 REQUIRE(type == 23);
38 REQUIRE(rdclass == 1);
40 UNUSED(type);
41 UNUSED(rdclass);
42 UNUSED(callbacks);
44 RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
45 ISC_FALSE));
47 dns_name_init(&name, NULL);
48 buffer_fromregion(&buffer, &token.value.as_region);
49 origin = (origin != NULL) ? origin : dns_rootname;
50 RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target));
51 return (ISC_R_SUCCESS);
54 static inline isc_result_t
55 totext_in_nsap_ptr(ARGS_TOTEXT) {
56 isc_region_t region;
57 dns_name_t name;
58 dns_name_t prefix;
59 isc_boolean_t sub;
61 REQUIRE(rdata->type == 23);
62 REQUIRE(rdata->rdclass == 1);
63 REQUIRE(rdata->length != 0);
65 dns_name_init(&name, NULL);
66 dns_name_init(&prefix, NULL);
68 dns_rdata_toregion(rdata, &region);
69 dns_name_fromregion(&name, &region);
71 sub = name_prefix(&name, tctx->origin, &prefix);
73 return (dns_name_totext(&prefix, sub, target));
76 static inline isc_result_t
77 fromwire_in_nsap_ptr(ARGS_FROMWIRE) {
78 dns_name_t name;
80 REQUIRE(type == 23);
81 REQUIRE(rdclass == 1);
83 UNUSED(type);
84 UNUSED(rdclass);
86 dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
88 dns_name_init(&name, NULL);
89 return (dns_name_fromwire(&name, source, dctx, options, target));
92 static inline isc_result_t
93 towire_in_nsap_ptr(ARGS_TOWIRE) {
94 dns_name_t name;
95 dns_offsets_t offsets;
96 isc_region_t region;
98 REQUIRE(rdata->type == 23);
99 REQUIRE(rdata->rdclass == 1);
100 REQUIRE(rdata->length != 0);
102 dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
103 dns_name_init(&name, offsets);
104 dns_rdata_toregion(rdata, &region);
105 dns_name_fromregion(&name, &region);
107 return (dns_name_towire(&name, cctx, target));
110 static inline int
111 compare_in_nsap_ptr(ARGS_COMPARE) {
112 dns_name_t name1;
113 dns_name_t name2;
114 isc_region_t region1;
115 isc_region_t region2;
117 REQUIRE(rdata1->type == rdata2->type);
118 REQUIRE(rdata1->rdclass == rdata2->rdclass);
119 REQUIRE(rdata1->type == 23);
120 REQUIRE(rdata1->rdclass == 1);
121 REQUIRE(rdata1->length != 0);
122 REQUIRE(rdata2->length != 0);
124 dns_name_init(&name1, NULL);
125 dns_name_init(&name2, NULL);
127 dns_rdata_toregion(rdata1, &region1);
128 dns_rdata_toregion(rdata2, &region2);
130 dns_name_fromregion(&name1, &region1);
131 dns_name_fromregion(&name2, &region2);
133 return (dns_name_rdatacompare(&name1, &name2));
136 static inline isc_result_t
137 fromstruct_in_nsap_ptr(ARGS_FROMSTRUCT) {
138 dns_rdata_in_nsap_ptr_t *nsap_ptr = source;
139 isc_region_t region;
141 REQUIRE(type == 23);
142 REQUIRE(rdclass == 1);
143 REQUIRE(source != NULL);
144 REQUIRE(nsap_ptr->common.rdtype == type);
145 REQUIRE(nsap_ptr->common.rdclass == rdclass);
147 UNUSED(type);
148 UNUSED(rdclass);
150 dns_name_toregion(&nsap_ptr->owner, &region);
151 return (isc_buffer_copyregion(target, &region));
154 static inline isc_result_t
155 tostruct_in_nsap_ptr(ARGS_TOSTRUCT) {
156 isc_region_t region;
157 dns_rdata_in_nsap_ptr_t *nsap_ptr = target;
158 dns_name_t name;
160 REQUIRE(rdata->type == 23);
161 REQUIRE(rdata->rdclass == 1);
162 REQUIRE(target != NULL);
163 REQUIRE(rdata->length != 0);
165 nsap_ptr->common.rdclass = rdata->rdclass;
166 nsap_ptr->common.rdtype = rdata->type;
167 ISC_LINK_INIT(&nsap_ptr->common, link);
169 dns_name_init(&name, NULL);
170 dns_rdata_toregion(rdata, &region);
171 dns_name_fromregion(&name, &region);
172 dns_name_init(&nsap_ptr->owner, NULL);
173 RETERR(name_duporclone(&name, mctx, &nsap_ptr->owner));
174 nsap_ptr->mctx = mctx;
175 return (ISC_R_SUCCESS);
178 static inline void
179 freestruct_in_nsap_ptr(ARGS_FREESTRUCT) {
180 dns_rdata_in_nsap_ptr_t *nsap_ptr = source;
182 REQUIRE(source != NULL);
183 REQUIRE(nsap_ptr->common.rdclass == 1);
184 REQUIRE(nsap_ptr->common.rdtype == 23);
186 if (nsap_ptr->mctx == NULL)
187 return;
189 dns_name_free(&nsap_ptr->owner, nsap_ptr->mctx);
190 nsap_ptr->mctx = NULL;
193 static inline isc_result_t
194 additionaldata_in_nsap_ptr(ARGS_ADDLDATA) {
195 REQUIRE(rdata->type == 23);
196 REQUIRE(rdata->rdclass == 1);
198 UNUSED(rdata);
199 UNUSED(add);
200 UNUSED(arg);
202 return (ISC_R_SUCCESS);
205 static inline isc_result_t
206 digest_in_nsap_ptr(ARGS_DIGEST) {
207 isc_region_t r;
208 dns_name_t name;
210 REQUIRE(rdata->type == 23);
211 REQUIRE(rdata->rdclass == 1);
213 dns_rdata_toregion(rdata, &r);
214 dns_name_init(&name, NULL);
215 dns_name_fromregion(&name, &r);
217 return (dns_name_digest(&name, digest, arg));
220 static inline isc_boolean_t
221 checkowner_in_nsap_ptr(ARGS_CHECKOWNER) {
223 REQUIRE(type == 23);
224 REQUIRE(rdclass == 1);
226 UNUSED(name);
227 UNUSED(type);
228 UNUSED(rdclass);
229 UNUSED(wildcard);
231 return (ISC_TRUE);
234 static inline isc_boolean_t
235 checknames_in_nsap_ptr(ARGS_CHECKNAMES) {
237 REQUIRE(rdata->type == 23);
238 REQUIRE(rdata->rdclass == 1);
240 UNUSED(rdata);
241 UNUSED(owner);
242 UNUSED(bad);
244 return (ISC_TRUE);
247 static inline int
248 casecompare_in_nsap_ptr(ARGS_COMPARE) {
249 return (compare_in_nsap_ptr(rdata1, rdata2));
252 #endif /* RDATA_IN_1_NSAP_PTR_23_C */