Add BIND 9.2.4rc7.
[dragonfly.git] / contrib / bind-9.2.4rc7 / lib / dns / rdata / generic / null_10.c
blob44bccf24d949aa3c374dd8801b460a0bbecc6af6
1 /*
2 * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1998-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: null_10.c,v 1.35.2.2 2004/03/09 06:11:32 marka Exp $ */
20 /* Reviewed: Thu Mar 16 13:57:50 PST 2000 by explorer */
22 #ifndef RDATA_GENERIC_NULL_10_C
23 #define RDATA_GENERIC_NULL_10_C
25 #define RRTYPE_NULL_ATTRIBUTES (0)
27 static inline isc_result_t
28 fromtext_null(ARGS_FROMTEXT) {
29 REQUIRE(type == 10);
31 UNUSED(rdclass);
32 UNUSED(type);
33 UNUSED(lexer);
34 UNUSED(origin);
35 UNUSED(downcase);
36 UNUSED(target);
37 UNUSED(callbacks);
39 return (DNS_R_SYNTAX);
42 static inline isc_result_t
43 totext_null(ARGS_TOTEXT) {
44 REQUIRE(rdata->type == 10);
46 UNUSED(rdata);
47 UNUSED(tctx);
48 UNUSED(target);
50 return (DNS_R_SYNTAX);
53 static inline isc_result_t
54 fromwire_null(ARGS_FROMWIRE) {
55 isc_region_t sr;
57 REQUIRE(type == 10);
59 UNUSED(type);
60 UNUSED(rdclass);
61 UNUSED(dctx);
62 UNUSED(downcase);
64 isc_buffer_activeregion(source, &sr);
65 isc_buffer_forward(source, sr.length);
66 return (mem_tobuffer(target, sr.base, sr.length));
69 static inline isc_result_t
70 towire_null(ARGS_TOWIRE) {
71 REQUIRE(rdata->type == 10);
73 UNUSED(cctx);
75 return (mem_tobuffer(target, rdata->data, rdata->length));
78 static inline int
79 compare_null(ARGS_COMPARE) {
80 isc_region_t r1;
81 isc_region_t r2;
83 REQUIRE(rdata1->type == rdata2->type);
84 REQUIRE(rdata1->rdclass == rdata2->rdclass);
85 REQUIRE(rdata1->type == 10);
87 dns_rdata_toregion(rdata1, &r1);
88 dns_rdata_toregion(rdata2, &r2);
89 return (compare_region(&r1, &r2));
92 static inline isc_result_t
93 fromstruct_null(ARGS_FROMSTRUCT) {
94 dns_rdata_null_t *null = source;
96 REQUIRE(type == 10);
97 REQUIRE(source != NULL);
98 REQUIRE(null->common.rdtype == type);
99 REQUIRE(null->common.rdclass == rdclass);
100 REQUIRE(null->data != NULL || null->length == 0);
102 UNUSED(type);
103 UNUSED(rdclass);
105 return (mem_tobuffer(target, null->data, null->length));
108 static inline isc_result_t
109 tostruct_null(ARGS_TOSTRUCT) {
110 dns_rdata_null_t *null = target;
111 isc_region_t r;
113 REQUIRE(rdata->type == 10);
114 REQUIRE(target != NULL);
116 null->common.rdclass = rdata->rdclass;
117 null->common.rdtype = rdata->type;
118 ISC_LINK_INIT(&null->common, link);
120 dns_rdata_toregion(rdata, &r);
121 null->length = r.length;
122 null->data = mem_maybedup(mctx, r.base, r.length);
123 if (null->data == NULL)
124 return (ISC_R_NOMEMORY);
126 null->mctx = mctx;
127 return (ISC_R_SUCCESS);
130 static inline void
131 freestruct_null(ARGS_FREESTRUCT) {
132 dns_rdata_null_t *null = source;
134 REQUIRE(source != NULL);
135 REQUIRE(null->common.rdtype == 10);
137 if (null->mctx == NULL)
138 return;
140 if (null->data != NULL)
141 isc_mem_free(null->mctx, null->data);
142 null->mctx = NULL;
145 static inline isc_result_t
146 additionaldata_null(ARGS_ADDLDATA) {
147 UNUSED(rdata);
148 UNUSED(add);
149 UNUSED(arg);
151 REQUIRE(rdata->type == 10);
153 return (ISC_R_SUCCESS);
156 static inline isc_result_t
157 digest_null(ARGS_DIGEST) {
158 isc_region_t r;
160 REQUIRE(rdata->type == 10);
162 dns_rdata_toregion(rdata, &r);
164 return ((digest)(arg, &r));
167 #endif /* RDATA_GENERIC_NULL_10_C */