1 /* $NetBSD: null_10.c,v 1.4 2014/12/10 04:37:59 christos Exp $ */
4 * Copyright (C) 2004, 2007, 2009, 2011, 2012 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.
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);
48 return (unknown_totext(rdata
, tctx
, target
));
51 static inline isc_result_t
52 fromwire_null(ARGS_FROMWIRE
) {
62 isc_buffer_activeregion(source
, &sr
);
63 isc_buffer_forward(source
, sr
.length
);
64 return (mem_tobuffer(target
, sr
.base
, sr
.length
));
67 static inline isc_result_t
68 towire_null(ARGS_TOWIRE
) {
69 REQUIRE(rdata
->type
== 10);
73 return (mem_tobuffer(target
, rdata
->data
, rdata
->length
));
77 compare_null(ARGS_COMPARE
) {
81 REQUIRE(rdata1
->type
== rdata2
->type
);
82 REQUIRE(rdata1
->rdclass
== rdata2
->rdclass
);
83 REQUIRE(rdata1
->type
== 10);
85 dns_rdata_toregion(rdata1
, &r1
);
86 dns_rdata_toregion(rdata2
, &r2
);
87 return (isc_region_compare(&r1
, &r2
));
90 static inline isc_result_t
91 fromstruct_null(ARGS_FROMSTRUCT
) {
92 dns_rdata_null_t
*null
= source
;
95 REQUIRE(source
!= NULL
);
96 REQUIRE(null
->common
.rdtype
== type
);
97 REQUIRE(null
->common
.rdclass
== rdclass
);
98 REQUIRE(null
->data
!= NULL
|| null
->length
== 0);
103 return (mem_tobuffer(target
, null
->data
, null
->length
));
106 static inline isc_result_t
107 tostruct_null(ARGS_TOSTRUCT
) {
108 dns_rdata_null_t
*null
= target
;
111 REQUIRE(rdata
->type
== 10);
112 REQUIRE(target
!= NULL
);
114 null
->common
.rdclass
= rdata
->rdclass
;
115 null
->common
.rdtype
= rdata
->type
;
116 ISC_LINK_INIT(&null
->common
, link
);
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
);
125 return (ISC_R_SUCCESS
);
129 freestruct_null(ARGS_FREESTRUCT
) {
130 dns_rdata_null_t
*null
= source
;
132 REQUIRE(source
!= NULL
);
133 REQUIRE(null
->common
.rdtype
== 10);
135 if (null
->mctx
== NULL
)
138 if (null
->data
!= NULL
)
139 isc_mem_free(null
->mctx
, null
->data
);
143 static inline isc_result_t
144 additionaldata_null(ARGS_ADDLDATA
) {
149 REQUIRE(rdata
->type
== 10);
151 return (ISC_R_SUCCESS
);
154 static inline isc_result_t
155 digest_null(ARGS_DIGEST
) {
158 REQUIRE(rdata
->type
== 10);
160 dns_rdata_toregion(rdata
, &r
);
162 return ((digest
)(arg
, &r
));
165 static inline isc_boolean_t
166 checkowner_null(ARGS_CHECKOWNER
) {
178 static inline isc_boolean_t
179 checknames_null(ARGS_CHECKNAMES
) {
181 REQUIRE(rdata
->type
== 10);
191 casecompare_null(ARGS_COMPARE
) {
192 return (compare_null(rdata1
, rdata2
));
195 #endif /* RDATA_GENERIC_NULL_10_C */