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