1 /* $NetBSD: null_10.c,v 1.4 2014/12/10 04:37:59 christos Exp $ */
2
3 /*
4 * Copyright (C) 2004, 2007, 2009, 2011, 2012 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 */
21
22 /* Reviewed: Thu Mar 16 13:57:50 PST 2000 by explorer */
23
24 #ifndef RDATA_GENERIC_NULL_10_C
25 #define RDATA_GENERIC_NULL_10_C
26
27 #define RRTYPE_NULL_ATTRIBUTES (0)
28
29 static inline isc_result_t
fromtext_null(ARGS_FROMTEXT)30 fromtext_null(ARGS_FROMTEXT) {
31 REQUIRE(type == 10);
32
33 UNUSED(rdclass);
34 UNUSED(type);
35 UNUSED(lexer);
36 UNUSED(origin);
37 UNUSED(options);
38 UNUSED(target);
39 UNUSED(callbacks);
40
41 return (DNS_R_SYNTAX);
42 }
43
44 static inline isc_result_t
totext_null(ARGS_TOTEXT)45 totext_null(ARGS_TOTEXT) {
46 REQUIRE(rdata->type == 10);
47
48 return (unknown_totext(rdata, tctx, target));
49 }
50
51 static inline isc_result_t
fromwire_null(ARGS_FROMWIRE)52 fromwire_null(ARGS_FROMWIRE) {
53 isc_region_t sr;
54
55 REQUIRE(type == 10);
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_null(ARGS_TOWIRE)68 towire_null(ARGS_TOWIRE) {
69 REQUIRE(rdata->type == 10);
70
71 UNUSED(cctx);
72
73 return (mem_tobuffer(target, rdata->data, rdata->length));
74 }
75
76 static inline int
compare_null(ARGS_COMPARE)77 compare_null(ARGS_COMPARE) {
78 isc_region_t r1;
79 isc_region_t r2;
80
81 REQUIRE(rdata1->type == rdata2->type);
82 REQUIRE(rdata1->rdclass == rdata2->rdclass);
83 REQUIRE(rdata1->type == 10);
84
85 dns_rdata_toregion(rdata1, &r1);
86 dns_rdata_toregion(rdata2, &r2);
87 return (isc_region_compare(&r1, &r2));
88 }
89
90 static inline isc_result_t
fromstruct_null(ARGS_FROMSTRUCT)91 fromstruct_null(ARGS_FROMSTRUCT) {
92 dns_rdata_null_t *null = source;
93
94 REQUIRE(type == 10);
95 REQUIRE(source != NULL);
96 REQUIRE(null->common.rdtype == type);
97 REQUIRE(null->common.rdclass == rdclass);
98 REQUIRE(null->data != NULL || null->length == 0);
99
100 UNUSED(type);
101 UNUSED(rdclass);
102
103 return (mem_tobuffer(target, null->data, null->length));
104 }
105
106 static inline isc_result_t
tostruct_null(ARGS_TOSTRUCT)107 tostruct_null(ARGS_TOSTRUCT) {
108 dns_rdata_null_t *null = target;
109 isc_region_t r;
110
111 REQUIRE(rdata->type == 10);
112 REQUIRE(target != NULL);
113
114 null->common.rdclass = rdata->rdclass;
115 null->common.rdtype = rdata->type;
116 ISC_LINK_INIT(&null->common, link);
117
118 dns_rdata_toregion(rdata, &r);
119 null->length = r.length;
120 null->data = mem_maybedup(mctx, r.base, r.length);
121 if (null->data == NULL)
122 return (ISC_R_NOMEMORY);
123
124 null->mctx = mctx;
125 return (ISC_R_SUCCESS);
126 }
127
128 static inline void
freestruct_null(ARGS_FREESTRUCT)129 freestruct_null(ARGS_FREESTRUCT) {
130 dns_rdata_null_t *null = source;
131
132 REQUIRE(source != NULL);
133 REQUIRE(null->common.rdtype == 10);
134
135 if (null->mctx == NULL)
136 return;
137
138 if (null->data != NULL)
139 isc_mem_free(null->mctx, null->data);
140 null->mctx = NULL;
141 }
142
143 static inline isc_result_t
additionaldata_null(ARGS_ADDLDATA)144 additionaldata_null(ARGS_ADDLDATA) {
145 UNUSED(rdata);
146 UNUSED(add);
147 UNUSED(arg);
148
149 REQUIRE(rdata->type == 10);
150
151 return (ISC_R_SUCCESS);
152 }
153
154 static inline isc_result_t
digest_null(ARGS_DIGEST)155 digest_null(ARGS_DIGEST) {
156 isc_region_t r;
157
158 REQUIRE(rdata->type == 10);
159
160 dns_rdata_toregion(rdata, &r);
161
162 return ((digest)(arg, &r));
163 }
164
165 static inline isc_boolean_t
checkowner_null(ARGS_CHECKOWNER)166 checkowner_null(ARGS_CHECKOWNER) {
167
168 REQUIRE(type == 10);
169
170 UNUSED(name);
171 UNUSED(type);
172 UNUSED(rdclass);
173 UNUSED(wildcard);
174
175 return (ISC_TRUE);
176 }
177
178 static inline isc_boolean_t
checknames_null(ARGS_CHECKNAMES)179 checknames_null(ARGS_CHECKNAMES) {
180
181 REQUIRE(rdata->type == 10);
182
183 UNUSED(rdata);
184 UNUSED(owner);
185 UNUSED(bad);
186
187 return (ISC_TRUE);
188 }
189
190 static inline int
casecompare_null(ARGS_COMPARE)191 casecompare_null(ARGS_COMPARE) {
192 return (compare_null(rdata1, rdata2));
193 }
194
195 #endif /* RDATA_GENERIC_NULL_10_C */
196