1/*
2 * Copyright (C) 2004, 2007, 2009  Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1999-2002  Internet Software Consortium.
4 *
5 * Permission to use, copy, modify, and/or 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.
8 *
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.
16 */
17
18/* $Id: unspec_103.c,v 1.37 2009/12/04 22:06:37 tbox Exp $ */
19
20#ifndef RDATA_GENERIC_UNSPEC_103_C
21#define RDATA_GENERIC_UNSPEC_103_C
22
23#define RRTYPE_UNSPEC_ATTRIBUTES (0)
24
25static inline isc_result_t
26fromtext_unspec(ARGS_FROMTEXT) {
27
28	REQUIRE(type == 103);
29
30	UNUSED(type);
31	UNUSED(rdclass);
32	UNUSED(origin);
33	UNUSED(options);
34	UNUSED(callbacks);
35
36	return (atob_tobuffer(lexer, target));
37}
38
39static inline isc_result_t
40totext_unspec(ARGS_TOTEXT) {
41
42	REQUIRE(rdata->type == 103);
43
44	UNUSED(tctx);
45
46	return (btoa_totext(rdata->data, rdata->length, target));
47}
48
49static inline isc_result_t
50fromwire_unspec(ARGS_FROMWIRE) {
51	isc_region_t sr;
52
53	REQUIRE(type == 103);
54
55	UNUSED(type);
56	UNUSED(rdclass);
57	UNUSED(dctx);
58	UNUSED(options);
59
60	isc_buffer_activeregion(source, &sr);
61	isc_buffer_forward(source, sr.length);
62	return (mem_tobuffer(target, sr.base, sr.length));
63}
64
65static inline isc_result_t
66towire_unspec(ARGS_TOWIRE) {
67
68	REQUIRE(rdata->type == 103);
69
70	UNUSED(cctx);
71
72	return (mem_tobuffer(target, rdata->data, rdata->length));
73}
74
75static inline int
76compare_unspec(ARGS_COMPARE) {
77	isc_region_t r1;
78	isc_region_t r2;
79
80	REQUIRE(rdata1->type == rdata2->type);
81	REQUIRE(rdata1->rdclass == rdata2->rdclass);
82	REQUIRE(rdata1->type == 103);
83
84	dns_rdata_toregion(rdata1, &r1);
85	dns_rdata_toregion(rdata2, &r2);
86	return (isc_region_compare(&r1, &r2));
87}
88
89static inline isc_result_t
90fromstruct_unspec(ARGS_FROMSTRUCT) {
91	dns_rdata_unspec_t *unspec = source;
92
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);
98
99	UNUSED(type);
100	UNUSED(rdclass);
101
102	return (mem_tobuffer(target, unspec->data, unspec->datalen));
103}
104
105static inline isc_result_t
106tostruct_unspec(ARGS_TOSTRUCT) {
107	dns_rdata_unspec_t *unspec = target;
108	isc_region_t r;
109
110	REQUIRE(rdata->type == 103);
111	REQUIRE(target != NULL);
112
113	unspec->common.rdclass = rdata->rdclass;
114	unspec->common.rdtype = rdata->type;
115	ISC_LINK_INIT(&unspec->common, link);
116
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);
122
123	unspec->mctx = mctx;
124	return (ISC_R_SUCCESS);
125}
126
127static inline void
128freestruct_unspec(ARGS_FREESTRUCT) {
129	dns_rdata_unspec_t *unspec = source;
130
131	REQUIRE(source != NULL);
132	REQUIRE(unspec->common.rdtype == 103);
133
134	if (unspec->mctx == NULL)
135		return;
136
137	if (unspec->data != NULL)
138		isc_mem_free(unspec->mctx, unspec->data);
139	unspec->mctx = NULL;
140}
141
142static inline isc_result_t
143additionaldata_unspec(ARGS_ADDLDATA) {
144	REQUIRE(rdata->type == 103);
145
146	UNUSED(rdata);
147	UNUSED(add);
148	UNUSED(arg);
149
150	return (ISC_R_SUCCESS);
151}
152
153static inline isc_result_t
154digest_unspec(ARGS_DIGEST) {
155	isc_region_t r;
156
157	REQUIRE(rdata->type == 103);
158
159	dns_rdata_toregion(rdata, &r);
160
161	return ((digest)(arg, &r));
162}
163
164static inline isc_boolean_t
165checkowner_unspec(ARGS_CHECKOWNER) {
166
167	REQUIRE(type == 103);
168
169	UNUSED(name);
170	UNUSED(type);
171	UNUSED(rdclass);
172	UNUSED(wildcard);
173
174	return (ISC_TRUE);
175}
176
177static inline isc_boolean_t
178checknames_unspec(ARGS_CHECKNAMES) {
179
180	REQUIRE(rdata->type == 103);
181
182	UNUSED(rdata);
183	UNUSED(owner);
184	UNUSED(bad);
185
186	return (ISC_TRUE);
187}
188
189static inline int
190casecompare_unspec(ARGS_COMPARE) {
191	return (compare_unspec(rdata1, rdata2));
192}
193
194#endif	/* RDATA_GENERIC_UNSPEC_103_C */
195