Add BIND 9.2.4rc7.
[dragonfly.git] / contrib / bind-9.2.4rc7 / lib / dns / rdata / generic / unspec_103.c
blob9bb00e6fa7f83d5a85d4fdcba3ba9e9ca7ed879f
1 /*
2 * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1999-2001 Internet Software Consortium.
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
18 /* $Id: unspec_103.c,v 1.28.2.2 2004/03/09 06:11:34 marka Exp $ */
20 #ifndef RDATA_GENERIC_UNSPEC_103_C
21 #define RDATA_GENERIC_UNSPEC_103_C
23 #define RRTYPE_UNSPEC_ATTRIBUTES (0)
25 static inline isc_result_t
26 fromtext_unspec(ARGS_FROMTEXT) {
28 REQUIRE(type == 103);
30 UNUSED(type);
31 UNUSED(rdclass);
32 UNUSED(origin);
33 UNUSED(downcase);
34 UNUSED(callbacks);
36 return (atob_tobuffer(lexer, target));
39 static inline isc_result_t
40 totext_unspec(ARGS_TOTEXT) {
42 REQUIRE(rdata->type == 103);
44 UNUSED(tctx);
46 return (btoa_totext(rdata->data, rdata->length, target));
49 static inline isc_result_t
50 fromwire_unspec(ARGS_FROMWIRE) {
51 isc_region_t sr;
53 REQUIRE(type == 103);
55 UNUSED(type);
56 UNUSED(rdclass);
57 UNUSED(dctx);
58 UNUSED(downcase);
60 isc_buffer_activeregion(source, &sr);
61 isc_buffer_forward(source, sr.length);
62 return (mem_tobuffer(target, sr.base, sr.length));
65 static inline isc_result_t
66 towire_unspec(ARGS_TOWIRE) {
68 REQUIRE(rdata->type == 103);
70 UNUSED(cctx);
72 return (mem_tobuffer(target, rdata->data, rdata->length));
75 static inline int
76 compare_unspec(ARGS_COMPARE) {
77 isc_region_t r1;
78 isc_region_t r2;
80 REQUIRE(rdata1->type == rdata2->type);
81 REQUIRE(rdata1->rdclass == rdata2->rdclass);
82 REQUIRE(rdata1->type == 103);
84 dns_rdata_toregion(rdata1, &r1);
85 dns_rdata_toregion(rdata2, &r2);
86 return (compare_region(&r1, &r2));
89 static inline isc_result_t
90 fromstruct_unspec(ARGS_FROMSTRUCT) {
91 dns_rdata_unspec_t *unspec = source;
93 REQUIRE(type == 103);
94 REQUIRE(source != NULL);
95 REQUIRE(unspec->common.rdtype == type);
96 REQUIRE(unspec->common.rdclass == rdclass);
97 REQUIRE(unspec->data != NULL || unspec->datalen == 0);
99 UNUSED(type);
100 UNUSED(rdclass);
102 return (mem_tobuffer(target, unspec->data, unspec->datalen));
105 static inline isc_result_t
106 tostruct_unspec(ARGS_TOSTRUCT) {
107 dns_rdata_unspec_t *unspec = target;
108 isc_region_t r;
110 REQUIRE(rdata->type == 103);
111 REQUIRE(target != NULL);
113 unspec->common.rdclass = rdata->rdclass;
114 unspec->common.rdtype = rdata->type;
115 ISC_LINK_INIT(&unspec->common, link);
117 dns_rdata_toregion(rdata, &r);
118 unspec->datalen = r.length;
119 unspec->data = mem_maybedup(mctx, r.base, r.length);
120 if (unspec->data == NULL)
121 return (ISC_R_NOMEMORY);
123 unspec->mctx = mctx;
124 return (ISC_R_SUCCESS);
127 static inline void
128 freestruct_unspec(ARGS_FREESTRUCT) {
129 dns_rdata_unspec_t *unspec = source;
131 REQUIRE(source != NULL);
132 REQUIRE(unspec->common.rdtype == 103);
134 if (unspec->mctx == NULL)
135 return;
137 if (unspec->data != NULL)
138 isc_mem_free(unspec->mctx, unspec->data);
139 unspec->mctx = NULL;
142 static inline isc_result_t
143 additionaldata_unspec(ARGS_ADDLDATA) {
144 REQUIRE(rdata->type == 103);
146 UNUSED(rdata);
147 UNUSED(add);
148 UNUSED(arg);
150 return (ISC_R_SUCCESS);
153 static inline isc_result_t
154 digest_unspec(ARGS_DIGEST) {
155 isc_region_t r;
157 REQUIRE(rdata->type == 103);
159 dns_rdata_toregion(rdata, &r);
161 return ((digest)(arg, &r));
164 #endif /* RDATA_GENERIC_UNSPEC_103_C */