1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef RDATA_GENERIC_DOA_259_C
#define RDATA_GENERIC_DOA_259_C
static inline isc_result_t
totext_doa(ARGS_TOTEXT) {
char buf[sizeof("4294967295 ")];
isc_region_t region;
uint32_t n;
REQUIRE(rdata != NULL);
REQUIRE(rdata->type == dns_rdatatype_doa);
REQUIRE(rdata->length != 0);
UNUSED(tctx);
dns_rdata_toregion(rdata, ®ion);
/*
* DOA-ENTERPRISE
*/
n = uint32_fromregion(®ion);
isc_region_consume(®ion, 4);
snprintf(buf, sizeof(buf), "%u ", n);
RETERR(isc_str_tobuffer(buf, target));
/*
* DOA-TYPE
*/
n = uint32_fromregion(®ion);
isc_region_consume(®ion, 4);
snprintf(buf, sizeof(buf), "%u ", n);
RETERR(isc_str_tobuffer(buf, target));
/*
* DOA-LOCATION
*/
n = uint8_fromregion(®ion);
isc_region_consume(®ion, 1);
snprintf(buf, sizeof(buf), "%u ", n);
RETERR(isc_str_tobuffer(buf, target));
/*
* DOA-MEDIA-TYPE
*/
RETERR(txt_totext(®ion, ISC_TRUE, target));
RETERR(isc_str_tobuffer(" ", target));
/*
* DOA-DATA
*/
if (region.length == 0) {
return (isc_str_tobuffer("-", target));
} else {
return (isc_base64_totext(®ion, 60, "", target));
}
}
static inline isc_result_t
fromwire_doa(ARGS_FROMWIRE) {
isc_region_t region;
UNUSED(rdclass);
UNUSED(dctx);
UNUSED(options);
REQUIRE(type == dns_rdatatype_doa);
isc_buffer_activeregion(source, ®ion);
/*
* DOA-MEDIA-TYPE may be an empty <character-string> (i.e.,
* comprising of just the length octet) and DOA-DATA can have
* zero length.
*/
if (region.length < 4 + 4 + 1 + 1) {
return (ISC_R_UNEXPECTEDEND);
}
/*
* Check whether DOA-MEDIA-TYPE length is not malformed.
*/
if (region.base[9] > region.length - 10) {
return (ISC_R_UNEXPECTEDEND);
}
isc_buffer_forward(source, region.length);
return (isc_mem_tobuffer(target, region.base, region.length));
}
static inline isc_result_t
towire_doa(ARGS_TOWIRE) {
isc_region_t region;
UNUSED(cctx);
REQUIRE(rdata != NULL);
REQUIRE(rdata->type == dns_rdatatype_doa);
REQUIRE(rdata->length != 0);
dns_rdata_toregion(rdata, ®ion);
return (isc_mem_tobuffer(target, region.base, region.length));
}
#endif /* RDATA_GENERIC_DOA_259_C */
|