2 * Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1998-2002 Internet Software Consortium.
5 * Permission to use, copy, modify, and/or 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: hinfo_13.c,v 1.44 2007/06/19 23:47:17 tbox Exp $ */
21 * Reviewed: Wed Mar 15 16:47:10 PST 2000 by halley.
24 #ifndef RDATA_GENERIC_HINFO_13_C
25 #define RDATA_GENERIC_HINFO_13_C
27 #define RRTYPE_HINFO_ATTRIBUTES (0)
29 static inline isc_result_t
30 fromtext_hinfo(ARGS_FROMTEXT
) {
42 for (i
= 0; i
< 2; i
++) {
43 RETERR(isc_lex_getmastertoken(lexer
, &token
,
44 isc_tokentype_qstring
,
46 RETTOK(txt_fromtext(&token
.value
.as_textregion
, target
));
48 return (ISC_R_SUCCESS
);
51 static inline isc_result_t
52 totext_hinfo(ARGS_TOTEXT
) {
57 REQUIRE(rdata
->type
== 13);
58 REQUIRE(rdata
->length
!= 0);
60 dns_rdata_toregion(rdata
, ®ion
);
61 RETERR(txt_totext(®ion
, target
));
62 RETERR(str_totext(" ", target
));
63 return (txt_totext(®ion
, target
));
66 static inline isc_result_t
67 fromwire_hinfo(ARGS_FROMWIRE
) {
76 RETERR(txt_fromwire(source
, target
));
77 return (txt_fromwire(source
, target
));
80 static inline isc_result_t
81 towire_hinfo(ARGS_TOWIRE
) {
85 REQUIRE(rdata
->type
== 13);
86 REQUIRE(rdata
->length
!= 0);
88 return (mem_tobuffer(target
, rdata
->data
, rdata
->length
));
92 compare_hinfo(ARGS_COMPARE
) {
96 REQUIRE(rdata1
->type
== rdata2
->type
);
97 REQUIRE(rdata1
->rdclass
== rdata2
->rdclass
);
98 REQUIRE(rdata1
->type
== 13);
99 REQUIRE(rdata1
->length
!= 0);
100 REQUIRE(rdata2
->length
!= 0);
102 dns_rdata_toregion(rdata1
, &r1
);
103 dns_rdata_toregion(rdata2
, &r2
);
104 return (isc_region_compare(&r1
, &r2
));
107 static inline isc_result_t
108 fromstruct_hinfo(ARGS_FROMSTRUCT
) {
109 dns_rdata_hinfo_t
*hinfo
= source
;
112 REQUIRE(source
!= NULL
);
113 REQUIRE(hinfo
->common
.rdtype
== type
);
114 REQUIRE(hinfo
->common
.rdclass
== rdclass
);
119 RETERR(uint8_tobuffer(hinfo
->cpu_len
, target
));
120 RETERR(mem_tobuffer(target
, hinfo
->cpu
, hinfo
->cpu_len
));
121 RETERR(uint8_tobuffer(hinfo
->os_len
, target
));
122 return (mem_tobuffer(target
, hinfo
->os
, hinfo
->os_len
));
125 static inline isc_result_t
126 tostruct_hinfo(ARGS_TOSTRUCT
) {
127 dns_rdata_hinfo_t
*hinfo
= target
;
130 REQUIRE(rdata
->type
== 13);
131 REQUIRE(target
!= NULL
);
132 REQUIRE(rdata
->length
!= 0);
134 hinfo
->common
.rdclass
= rdata
->rdclass
;
135 hinfo
->common
.rdtype
= rdata
->type
;
136 ISC_LINK_INIT(&hinfo
->common
, link
);
138 dns_rdata_toregion(rdata
, ®ion
);
139 hinfo
->cpu_len
= uint8_fromregion(®ion
);
140 isc_region_consume(®ion
, 1);
141 hinfo
->cpu
= mem_maybedup(mctx
, region
.base
, hinfo
->cpu_len
);
142 if (hinfo
->cpu
== NULL
)
143 return (ISC_R_NOMEMORY
);
144 isc_region_consume(®ion
, hinfo
->cpu_len
);
146 hinfo
->os_len
= uint8_fromregion(®ion
);
147 isc_region_consume(®ion
, 1);
148 hinfo
->os
= mem_maybedup(mctx
, region
.base
, hinfo
->os_len
);
149 if (hinfo
->os
== NULL
)
153 return (ISC_R_SUCCESS
);
156 if (mctx
!= NULL
&& hinfo
->cpu
!= NULL
)
157 isc_mem_free(mctx
, hinfo
->cpu
);
158 return (ISC_R_NOMEMORY
);
162 freestruct_hinfo(ARGS_FREESTRUCT
) {
163 dns_rdata_hinfo_t
*hinfo
= source
;
165 REQUIRE(source
!= NULL
);
167 if (hinfo
->mctx
== NULL
)
170 if (hinfo
->cpu
!= NULL
)
171 isc_mem_free(hinfo
->mctx
, hinfo
->cpu
);
172 if (hinfo
->os
!= NULL
)
173 isc_mem_free(hinfo
->mctx
, hinfo
->os
);
177 static inline isc_result_t
178 additionaldata_hinfo(ARGS_ADDLDATA
) {
179 REQUIRE(rdata
->type
== 13);
185 return (ISC_R_SUCCESS
);
188 static inline isc_result_t
189 digest_hinfo(ARGS_DIGEST
) {
192 REQUIRE(rdata
->type
== 13);
194 dns_rdata_toregion(rdata
, &r
);
196 return ((digest
)(arg
, &r
));
199 static inline isc_boolean_t
200 checkowner_hinfo(ARGS_CHECKOWNER
) {
212 static inline isc_boolean_t
213 checknames_hinfo(ARGS_CHECKNAMES
) {
215 REQUIRE(rdata
->type
== 13);
224 #endif /* RDATA_GENERIC_HINFO_13_C */