4 * Copyright (C) 2004, 2007, 2009 Internet Systems Consortium, Inc. ("ISC")
5 * Copyright (C) 1998-2002 Internet Software Consortium.
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.
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.
20 /* Id: null_10.c,v 1.44 2009/12/04 22:06:37 tbox Exp */
22 /* Reviewed: Thu Mar 16 13:57:50 PST 2000 by explorer */
24 #ifndef RDATA_GENERIC_NULL_10_C
25 #define RDATA_GENERIC_NULL_10_C
27 #define RRTYPE_NULL_ATTRIBUTES (0)
29 static inline isc_result_t
30 fromtext_null(ARGS_FROMTEXT
) {
41 return (DNS_R_SYNTAX
);
44 static inline isc_result_t
45 totext_null(ARGS_TOTEXT
) {
46 REQUIRE(rdata
->type
== 10);
52 return (DNS_R_SYNTAX
);
55 static inline isc_result_t
56 fromwire_null(ARGS_FROMWIRE
) {
66 isc_buffer_activeregion(source
, &sr
);
67 isc_buffer_forward(source
, sr
.length
);
68 return (mem_tobuffer(target
, sr
.base
, sr
.length
));
71 static inline isc_result_t
72 towire_null(ARGS_TOWIRE
) {
73 REQUIRE(rdata
->type
== 10);
77 return (mem_tobuffer(target
, rdata
->data
, rdata
->length
));
81 compare_null(ARGS_COMPARE
) {
85 REQUIRE(rdata1
->type
== rdata2
->type
);
86 REQUIRE(rdata1
->rdclass
== rdata2
->rdclass
);
87 REQUIRE(rdata1
->type
== 10);
89 dns_rdata_toregion(rdata1
, &r1
);
90 dns_rdata_toregion(rdata2
, &r2
);
91 return (isc_region_compare(&r1
, &r2
));
94 static inline isc_result_t
95 fromstruct_null(ARGS_FROMSTRUCT
) {
96 dns_rdata_null_t
*null
= source
;
99 REQUIRE(source
!= NULL
);
100 REQUIRE(null
->common
.rdtype
== type
);
101 REQUIRE(null
->common
.rdclass
== rdclass
);
102 REQUIRE(null
->data
!= NULL
|| null
->length
== 0);
107 return (mem_tobuffer(target
, null
->data
, null
->length
));
110 static inline isc_result_t
111 tostruct_null(ARGS_TOSTRUCT
) {
112 dns_rdata_null_t
*null
= target
;
115 REQUIRE(rdata
->type
== 10);
116 REQUIRE(target
!= NULL
);
118 null
->common
.rdclass
= rdata
->rdclass
;
119 null
->common
.rdtype
= rdata
->type
;
120 ISC_LINK_INIT(&null
->common
, link
);
122 dns_rdata_toregion(rdata
, &r
);
123 null
->length
= r
.length
;
124 null
->data
= mem_maybedup(mctx
, r
.base
, r
.length
);
125 if (null
->data
== NULL
)
126 return (ISC_R_NOMEMORY
);
129 return (ISC_R_SUCCESS
);
133 freestruct_null(ARGS_FREESTRUCT
) {
134 dns_rdata_null_t
*null
= source
;
136 REQUIRE(source
!= NULL
);
137 REQUIRE(null
->common
.rdtype
== 10);
139 if (null
->mctx
== NULL
)
142 if (null
->data
!= NULL
)
143 isc_mem_free(null
->mctx
, null
->data
);
147 static inline isc_result_t
148 additionaldata_null(ARGS_ADDLDATA
) {
153 REQUIRE(rdata
->type
== 10);
155 return (ISC_R_SUCCESS
);
158 static inline isc_result_t
159 digest_null(ARGS_DIGEST
) {
162 REQUIRE(rdata
->type
== 10);
164 dns_rdata_toregion(rdata
, &r
);
166 return ((digest
)(arg
, &r
));
169 static inline isc_boolean_t
170 checkowner_null(ARGS_CHECKOWNER
) {
182 static inline isc_boolean_t
183 checknames_null(ARGS_CHECKNAMES
) {
185 REQUIRE(rdata
->type
== 10);
195 casecompare_null(ARGS_COMPARE
) {
196 return (compare_null(rdata1
, rdata2
));
199 #endif /* RDATA_GENERIC_NULL_10_C */