1 /*	$NetBSD: proforma.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) 1998-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: proforma.c,v 1.38 2009/12/04 22:06:37 tbox Exp  */
21 
22 #ifndef RDATA_GENERIC_#_#_C
23 #define RDATA_GENERIC_#_#_C
24 
25 #define RRTYPE_#_ATTRIBUTES (0)
26 
27 static inline isc_result_t
28 fromtext_#(ARGS_FROMTEXT) {
29 	isc_token_t token;
30 
31 	REQUIRE(type == #);
32 	REQUIRE(rdclass == #);
33 
34 	RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string,
35 				      ISC_FALSE));
36 
37 	return (ISC_R_NOTIMPLEMENTED);
38 }
39 
40 static inline isc_result_t
41 totext_#(ARGS_TOTEXT) {
42 
43 	REQUIRE(rdata->type == #);
44 	REQUIRE(rdata->rdclass == #);
45 	REQUIRE(rdata->length != 0);	/* XXX */
46 
47 	return (ISC_R_NOTIMPLEMENTED);
48 }
49 
50 static inline isc_result_t
51 fromwire_#(ARGS_FROMWIRE) {
52 
53 	REQUIRE(type == #);
54 	REQUIRE(rdclass == #);
55 
56 	/* NONE or GLOBAL14 */
57 	dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE);
58 
59 	return (ISC_R_NOTIMPLEMENTED);
60 }
61 
62 static inline isc_result_t
63 towire_#(ARGS_TOWIRE) {
64 
65 	REQUIRE(rdata->type == #);
66 	REQUIRE(rdata->rdclass == #);
67 	REQUIRE(rdata->length != 0);	/* XXX */
68 
69 	/* NONE or GLOBAL14 */
70 	dns_compress_setmethods(cctx, DNS_COMPRESS_NONE);
71 
72 	return (ISC_R_NOTIMPLEMENTED);
73 }
74 
75 static inline int
76 compare_#(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 == #);
83 	REQUIRE(rdata1->rdclass == #);
84 	REQUIRE(rdata1->length != 0);	/* XXX */
85 	REQUIRE(rdata2->length != 0);	/* XXX */
86 
87 	dns_rdata_toregion(rdata1, &r1);
88 	dns_rdata_toregion(rdata2, &r2);
89 	return (isc_region_compare(&r1, &r2));
90 }
91 
92 static inline isc_result_t
93 fromstruct_#(ARGS_FROMSTRUCT) {
94 	dns_rdata_#_t *# = source;
95 
96 	REQUIRE(type == #);
97 	REQUIRE(rdclass == #);
98 	REQUIRE(source != NULL);
99 	REQUIRE(#->common.rdtype == type);
100 	REQUIRE(#->common.rdclass == rdclass);
101 
102 	return (ISC_R_NOTIMPLEMENTED);
103 }
104 
105 static inline isc_result_t
106 tostruct_#(ARGS_TOSTRUCT) {
107 
108 	REQUIRE(rdata->type == #);
109 	REQUIRE(rdata->rdclass == #);
110 	REQUIRE(rdata->length != 0);	/* XXX */
111 
112 	return (ISC_R_NOTIMPLEMENTED);
113 }
114 
115 static inline void
116 freestruct_#(ARGS_FREESTRUCT) {
117 	dns_rdata_#_t *# = source;
118 
119 	REQUIRE(source != NULL);
120 	REQUIRE(#->common.rdtype == #);
121 	REQUIRE(#->common.rdclass == #);
122 
123 }
124 
125 static inline isc_result_t
126 additionaldata_#(ARGS_ADDLDATA) {
127 	REQUIRE(rdata->type == #);
128 	REQUIRE(rdata->rdclass == #);
129 
130 	(void)add;
131 	(void)arg;
132 
133 	return (ISC_R_SUCCESS);
134 }
135 
136 static inline isc_result_t
137 digest_#(ARGS_DIGEST) {
138 	isc_region_t r;
139 
140 	REQUIRE(rdata->type == #);
141 	REQUIRE(rdata->rdclass == #);
142 
143 	dns_rdata_toregion(rdata, &r);
144 
145 	return ((digest)(arg, &r));
146 }
147 
148 static inline isc_boolean_t
149 checkowner_#(ARGS_CHECKOWNER) {
150 
151 	REQUIRE(type == #);
152 	REQUIRE(rdclass == #);
153 
154 	UNUSED(name);
155 	UNUSED(type);
156 	UNUSED(rdclass);
157 	UNUSED(wildcard);
158 
159 	return (ISC_TRUE);
160 }
161 
162 static inline isc_boolean_t
163 checknames_#(ARGS_CHECKNAMES) {
164 
165 	REQUIRE(rdata->type == #);
166 	REQUIRE(rdata->rdclass == #);
167 
168 	UNUSED(rdata);
169 	UNUSED(owner);
170 	UNUSED(bad);
171 
172 	return (ISC_TRUE);
173 }
174 
175 static inline int
176 casecompare_#(ARGS_COMPARE) {
177 	isc_region_t r1;
178 	isc_region_t r2;
179 
180 	REQUIRE(rdata1->type == rdata2->type);
181 	REQUIRE(rdata1->rdclass == rdata2->rdclass);
182 	REQUIRE(rdata1->type == #);
183 	REQUIRE(rdata1->rdclass == #);
184 	REQUIRE(rdata1->length != 0);	/* XXX */
185 	REQUIRE(rdata2->length != 0);	/* XXX */
186 
187 	dns_rdata_toregion(rdata1, &r1);
188 	dns_rdata_toregion(rdata2, &r2);
189 	return (isc_region_compare(&r1, &r2));
190 }
191 
192 #endif	/* RDATA_GENERIC_#_#_C */
193