1 /* $NetBSD: unspec_103.c,v 1.4 2014/12/10 04:37:59 christos Exp $ */
4 * Copyright (C) 2004, 2007, 2009 Internet Systems Consortium, Inc. ("ISC")
5 * Copyright (C) 1999-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: unspec_103.c,v 1.37 2009/12/04 22:06:37 tbox Exp */
22 #ifndef RDATA_GENERIC_UNSPEC_103_C
23 #define RDATA_GENERIC_UNSPEC_103_C
25 #define RRTYPE_UNSPEC_ATTRIBUTES (0)
27 static inline isc_result_t
28 fromtext_unspec(ARGS_FROMTEXT
) {
38 return (atob_tobuffer(lexer
, target
));
41 static inline isc_result_t
42 totext_unspec(ARGS_TOTEXT
) {
44 REQUIRE(rdata
->type
== 103);
48 return (btoa_totext(rdata
->data
, rdata
->length
, target
));
51 static inline isc_result_t
52 fromwire_unspec(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_unspec(ARGS_TOWIRE
) {
70 REQUIRE(rdata
->type
== 103);
74 return (mem_tobuffer(target
, rdata
->data
, rdata
->length
));
78 compare_unspec(ARGS_COMPARE
) {
82 REQUIRE(rdata1
->type
== rdata2
->type
);
83 REQUIRE(rdata1
->rdclass
== rdata2
->rdclass
);
84 REQUIRE(rdata1
->type
== 103);
86 dns_rdata_toregion(rdata1
, &r1
);
87 dns_rdata_toregion(rdata2
, &r2
);
88 return (isc_region_compare(&r1
, &r2
));
91 static inline isc_result_t
92 fromstruct_unspec(ARGS_FROMSTRUCT
) {
93 dns_rdata_unspec_t
*unspec
= source
;
96 REQUIRE(source
!= NULL
);
97 REQUIRE(unspec
->common
.rdtype
== type
);
98 REQUIRE(unspec
->common
.rdclass
== rdclass
);
99 REQUIRE(unspec
->data
!= NULL
|| unspec
->datalen
== 0);
104 return (mem_tobuffer(target
, unspec
->data
, unspec
->datalen
));
107 static inline isc_result_t
108 tostruct_unspec(ARGS_TOSTRUCT
) {
109 dns_rdata_unspec_t
*unspec
= target
;
112 REQUIRE(rdata
->type
== 103);
113 REQUIRE(target
!= NULL
);
115 unspec
->common
.rdclass
= rdata
->rdclass
;
116 unspec
->common
.rdtype
= rdata
->type
;
117 ISC_LINK_INIT(&unspec
->common
, link
);
119 dns_rdata_toregion(rdata
, &r
);
120 unspec
->datalen
= r
.length
;
121 unspec
->data
= mem_maybedup(mctx
, r
.base
, r
.length
);
122 if (unspec
->data
== NULL
)
123 return (ISC_R_NOMEMORY
);
126 return (ISC_R_SUCCESS
);
130 freestruct_unspec(ARGS_FREESTRUCT
) {
131 dns_rdata_unspec_t
*unspec
= source
;
133 REQUIRE(source
!= NULL
);
134 REQUIRE(unspec
->common
.rdtype
== 103);
136 if (unspec
->mctx
== NULL
)
139 if (unspec
->data
!= NULL
)
140 isc_mem_free(unspec
->mctx
, unspec
->data
);
144 static inline isc_result_t
145 additionaldata_unspec(ARGS_ADDLDATA
) {
146 REQUIRE(rdata
->type
== 103);
152 return (ISC_R_SUCCESS
);
155 static inline isc_result_t
156 digest_unspec(ARGS_DIGEST
) {
159 REQUIRE(rdata
->type
== 103);
161 dns_rdata_toregion(rdata
, &r
);
163 return ((digest
)(arg
, &r
));
166 static inline isc_boolean_t
167 checkowner_unspec(ARGS_CHECKOWNER
) {
169 REQUIRE(type
== 103);
179 static inline isc_boolean_t
180 checknames_unspec(ARGS_CHECKNAMES
) {
182 REQUIRE(rdata
->type
== 103);
192 casecompare_unspec(ARGS_COMPARE
) {
193 return (compare_unspec(rdata1
, rdata2
));
196 #endif /* RDATA_GENERIC_UNSPEC_103_C */