Sync usage with man page.
[netbsd-mini2440.git] / external / bsd / bind / dist / lib / dns / rdata / in_1 / dhcid_49.c
blobb5aeab65dce1f1a685afb2af07871fa3a5142636
1 /* $NetBSD$ */
3 /*
4 * Copyright (C) 2006, 2007, 2009 Internet Systems Consortium, Inc. ("ISC")
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
11 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
13 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
15 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
19 /* Id: dhcid_49.c,v 1.7 2009/12/04 22:06:37 tbox Exp */
21 /* RFC 4701 */
23 #ifndef RDATA_IN_1_DHCID_49_C
24 #define RDATA_IN_1_DHCID_49_C 1
26 #define RRTYPE_DHCID_ATTRIBUTES 0
28 static inline isc_result_t
29 fromtext_in_dhcid(ARGS_FROMTEXT) {
31 REQUIRE(type == 49);
32 REQUIRE(rdclass == 1);
34 UNUSED(type);
35 UNUSED(rdclass);
36 UNUSED(origin);
37 UNUSED(options);
38 UNUSED(callbacks);
40 return (isc_base64_tobuffer(lexer, target, -1));
43 static inline isc_result_t
44 totext_in_dhcid(ARGS_TOTEXT) {
45 isc_region_t sr;
46 char buf[sizeof(" ; 64000 255 64000")];
47 size_t n;
49 REQUIRE(rdata->type == 49);
50 REQUIRE(rdata->rdclass == 1);
51 REQUIRE(rdata->length != 0);
53 dns_rdata_toregion(rdata, &sr);
55 if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
56 RETERR(str_totext("( " /*)*/, target));
57 RETERR(isc_base64_totext(&sr, tctx->width - 2, tctx->linebreak,
58 target));
59 if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) {
60 RETERR(str_totext(/* ( */ " )", target));
61 if (rdata->length > 2) {
62 n = snprintf(buf, sizeof(buf), " ; %u %u %u",
63 sr.base[0] * 256 + sr.base[1],
64 sr.base[2], rdata->length - 3);
65 INSIST(n < sizeof(buf));
66 RETERR(str_totext(buf, target));
69 return (ISC_R_SUCCESS);
72 static inline isc_result_t
73 fromwire_in_dhcid(ARGS_FROMWIRE) {
74 isc_region_t sr;
76 REQUIRE(type == 49);
77 REQUIRE(rdclass == 1);
79 UNUSED(type);
80 UNUSED(rdclass);
81 UNUSED(dctx);
82 UNUSED(options);
84 isc_buffer_activeregion(source, &sr);
85 if (sr.length == 0)
86 return (ISC_R_UNEXPECTEDEND);
88 isc_buffer_forward(source, sr.length);
89 return (mem_tobuffer(target, sr.base, sr.length));
92 static inline isc_result_t
93 towire_in_dhcid(ARGS_TOWIRE) {
94 isc_region_t sr;
96 REQUIRE(rdata->type == 49);
97 REQUIRE(rdata->rdclass == 1);
98 REQUIRE(rdata->length != 0);
100 UNUSED(cctx);
102 dns_rdata_toregion(rdata, &sr);
103 return (mem_tobuffer(target, sr.base, sr.length));
106 static inline int
107 compare_in_dhcid(ARGS_COMPARE) {
108 isc_region_t r1;
109 isc_region_t r2;
111 REQUIRE(rdata1->type == rdata2->type);
112 REQUIRE(rdata1->rdclass == rdata2->rdclass);
113 REQUIRE(rdata1->type == 49);
114 REQUIRE(rdata1->rdclass == 1);
115 REQUIRE(rdata1->length != 0);
116 REQUIRE(rdata2->length != 0);
118 dns_rdata_toregion(rdata1, &r1);
119 dns_rdata_toregion(rdata2, &r2);
120 return (isc_region_compare(&r1, &r2));
123 static inline isc_result_t
124 fromstruct_in_dhcid(ARGS_FROMSTRUCT) {
125 dns_rdata_in_dhcid_t *dhcid = source;
127 REQUIRE(type == 49);
128 REQUIRE(rdclass == 1);
129 REQUIRE(source != NULL);
130 REQUIRE(dhcid->common.rdtype == type);
131 REQUIRE(dhcid->common.rdclass == rdclass);
132 REQUIRE(dhcid->length != 0);
134 UNUSED(type);
135 UNUSED(rdclass);
137 return (mem_tobuffer(target, dhcid->dhcid, dhcid->length));
140 static inline isc_result_t
141 tostruct_in_dhcid(ARGS_TOSTRUCT) {
142 dns_rdata_in_dhcid_t *dhcid = target;
143 isc_region_t region;
145 REQUIRE(rdata->type == 49);
146 REQUIRE(rdata->rdclass == 1);
147 REQUIRE(target != NULL);
148 REQUIRE(rdata->length != 0);
150 dhcid->common.rdclass = rdata->rdclass;
151 dhcid->common.rdtype = rdata->type;
152 ISC_LINK_INIT(&dhcid->common, link);
154 dns_rdata_toregion(rdata, &region);
156 dhcid->dhcid = mem_maybedup(mctx, region.base, region.length);
157 if (dhcid->dhcid == NULL)
158 return (ISC_R_NOMEMORY);
160 dhcid->mctx = mctx;
161 return (ISC_R_SUCCESS);
164 static inline void
165 freestruct_in_dhcid(ARGS_FREESTRUCT) {
166 dns_rdata_in_dhcid_t *dhcid = source;
168 REQUIRE(dhcid != NULL);
169 REQUIRE(dhcid->common.rdtype == 49);
170 REQUIRE(dhcid->common.rdclass == 1);
172 if (dhcid->mctx == NULL)
173 return;
175 if (dhcid->dhcid != NULL)
176 isc_mem_free(dhcid->mctx, dhcid->dhcid);
177 dhcid->mctx = NULL;
180 static inline isc_result_t
181 additionaldata_in_dhcid(ARGS_ADDLDATA) {
182 REQUIRE(rdata->type == 49);
183 REQUIRE(rdata->rdclass == 1);
185 UNUSED(rdata);
186 UNUSED(add);
187 UNUSED(arg);
189 return (ISC_R_SUCCESS);
192 static inline isc_result_t
193 digest_in_dhcid(ARGS_DIGEST) {
194 isc_region_t r;
196 REQUIRE(rdata->type == 49);
197 REQUIRE(rdata->rdclass == 1);
199 dns_rdata_toregion(rdata, &r);
201 return ((digest)(arg, &r));
204 static inline isc_boolean_t
205 checkowner_in_dhcid(ARGS_CHECKOWNER) {
207 REQUIRE(type == 49);
208 REQUIRE(rdclass == 1);
210 UNUSED(name);
211 UNUSED(type);
212 UNUSED(rdclass);
213 UNUSED(wildcard);
215 return (ISC_TRUE);
218 static inline isc_boolean_t
219 checknames_in_dhcid(ARGS_CHECKNAMES) {
221 REQUIRE(rdata->type == 49);
222 REQUIRE(rdata->rdclass == 1);
224 UNUSED(rdata);
225 UNUSED(owner);
226 UNUSED(bad);
228 return (ISC_TRUE);
231 static inline int
232 casecompare_in_dhcid(ARGS_COMPARE) {
233 return (compare_in_dhcid(rdata1, rdata2));
236 #endif /* RDATA_IN_1_DHCID_49_C */