1/**
2 * str2host.h - conversion from str to the host fmt
3 *
4 * a Net::DNS like library for C
5 *
6 * (c) NLnet Labs, 2005-2006
7 *
8 * See the file LICENSE for the license
9 */
10
11#ifndef LDNS_2HOST_H
12#define LDNS_2HOST_H
13
14#include <ldns/common.h>
15#include <ldns/error.h>
16#include <ldns/rr.h>
17#include <ldns/rdata.h>
18#include <ldns/packet.h>
19#include <ldns/buffer.h>
20#include <ctype.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26/**
27 * \file
28 *
29 * Defines functions to convert dns data in presentation format or text files
30 * to internal structures.
31 */
32
33/**
34 * convert a byte into wireformat
35 * \param[in] rd the rdf where to put the data
36 * \param[in] bytestr the string to be converted
37 * \return ldns_status
38 */
39ldns_status ldns_str2rdf_int8(ldns_rdf **rd, const char *bytestr);
40
41/**
42 * convert a string to a int16 in wireformat
43 * \param[in] rd the rdf where to put the data
44 * \param[in] shortstr the string to be converted
45 * \return ldns_status
46 */
47ldns_status ldns_str2rdf_int16(ldns_rdf **rd, const char *shortstr);
48
49/**
50 * convert a strings into a 4 byte int in wireformat
51 * \param[in] rd the rdf where to put the data
52 * \param[in] longstr the string to be converted
53 * \return ldns_status
54 */
55ldns_status ldns_str2rdf_int32(ldns_rdf **rd, const char *longstr);
56
57/**
58 * convert a time string to a time value in wireformat
59 * \param[in] rd the rdf where to put the data
60 * \param[in] time the string to be converted
61 * \return ldns_status
62 */
63ldns_status ldns_str2rdf_time(ldns_rdf **rd, const char *time);
64
65/* convert string with NSEC3 salt to wireformat)
66 * \param[in] rd the rdf where to put the data
67 * \param[in] str the string to be converted
68 * return ldns_status
69 */
70ldns_status ldns_str2rdf_nsec3_salt(ldns_rdf **rd, const char *nsec3_salt);
71
72/* convert a time period (think TTL's) to wireformat)
73 * \param[in] rd the rdf where to put the data
74 * \param[in] str the string to be converted
75 * return ldns_status
76 */
77ldns_status ldns_str2rdf_period(ldns_rdf **rd, const char *str);
78
79/**
80 * convert str with an A record into wireformat
81 * \param[in] rd the rdf where to put the data
82 * \param[in] str the string to be converted
83 * \return ldns_status
84 */
85ldns_status ldns_str2rdf_a(ldns_rdf **rd, const char *str);
86
87/**
88 * convert the str with an AAAA record into wireformat
89 * \param[in] rd the rdf where to put the data
90 * \param[in] str the string to be converted
91 * \return ldns_status
92 */
93ldns_status ldns_str2rdf_aaaa(ldns_rdf **rd, const char *str);
94
95/**
96 * convert a string into wireformat (think txt record)
97 * \param[in] rd the rdf where to put the data
98 * \param[in] str the string to be converted (NULL terminated)
99 * \return ldns_status
100 */
101ldns_status ldns_str2rdf_str(ldns_rdf **rd, const char *str);
102
103/**
104 * convert str with the apl record into wireformat
105 * \param[in] rd the rdf where to put the data
106 * \param[in] str the string to be converted
107 * \return ldns_status
108 */
109ldns_status ldns_str2rdf_apl(ldns_rdf **rd, const char *str);
110
111/**
112 * convert the string with the b64 data into wireformat
113 * \param[in] rd the rdf where to put the data
114 * \param[in] str the string to be converted
115 * \return ldns_status
116 */
117ldns_status ldns_str2rdf_b64(ldns_rdf **rd, const char *str);
118
119/**
120 * convert the string with the b32 ext hex data into wireformat
121 * \param[in] rd the rdf where to put the data
122 * \param[in] str the string to be converted
123 * \return ldns_status
124 */
125ldns_status ldns_str2rdf_b32_ext(ldns_rdf **rd, const char *str);
126
127/**
128 * convert a hex value into wireformat
129 * \param[in] rd the rdf where to put the data
130 * \param[in] str the string to be converted
131 * \return ldns_status
132 */
133ldns_status ldns_str2rdf_hex(ldns_rdf **rd, const char *str);
134
135/**
136 * convert string with nsec into wireformat
137 * \param[in] rd the rdf where to put the data
138 * \param[in] str the string to be converted
139 * \return ldns_status
140 */
141ldns_status ldns_str2rdf_nsec(ldns_rdf **rd, const char *str);
142
143/**
144 * convert a rrtype into wireformat
145 * \param[in] rd the rdf where to put the data
146 * \param[in] str the string to be converted
147 * \return ldns_status
148 */
149ldns_status ldns_str2rdf_type(ldns_rdf **rd, const char *str);
150
151/**
152 * convert string with a classname into wireformat
153 * \param[in] rd the rdf where to put the data
154 * \param[in] str the string to be converted
155 * \return ldns_status
156 */
157ldns_status ldns_str2rdf_class(ldns_rdf **rd, const char *str);
158
159/**
160 * convert an certificate algorithm value into wireformat
161 * \param[in] rd the rdf where to put the data
162 * \param[in] str the string to be converted
163 * \return ldns_status
164 */
165ldns_status ldns_str2rdf_cert_alg(ldns_rdf **rd, const char *str);
166
167/**
168 * convert and algorithm value into wireformat
169 * \param[in] rd the rdf where to put the data
170 * \param[in] str the string to be converted
171 * \return ldns_status
172 */
173ldns_status ldns_str2rdf_alg(ldns_rdf **rd, const char *str);
174
175/**
176 * convert a string with a unknown RR into wireformat
177 * \param[in] rd the rdf where to put the data
178 * \param[in] str the string to be converted
179 * \return ldns_status
180 */
181ldns_status ldns_str2rdf_unknown(ldns_rdf **rd, const char *str);
182
183/**
184 * convert string with a protocol service into wireformat
185 * \param[in] rd the rdf where to put the data
186 * \param[in] str the string to be converted
187 * \return ldns_status
188 */
189ldns_status ldns_str2rdf_service(ldns_rdf **rd, const char *str);
190
191/**
192 * convert a string with a LOC RR into wireformat
193 * \param[in] rd the rdf where to put the data
194 * \param[in] str the string to be converted
195 * \return ldns_status
196 */
197ldns_status ldns_str2rdf_loc(ldns_rdf **rd, const char *str);
198
199/**
200 * convert string with a WKS RR into wireformat
201 * \param[in] rd the rdf where to put the data
202 * \param[in] str the string to be converted
203 * \return ldns_status
204 */
205ldns_status ldns_str2rdf_wks(ldns_rdf **rd, const char *str);
206
207/**
208 * convert a str with a NSAP RR into wireformat
209 * \param[in] rd the rdf where to put the data
210 * \param[in] str the string to be converted
211 * \return ldns_status
212 */
213ldns_status ldns_str2rdf_nsap(ldns_rdf **rd, const char *str);
214
215/**
216 * convert a str with a ATMA RR into wireformat
217 * \param[in] rd the rdf where to put the data
218 * \param[in] str the string to be converted
219 * \return ldns_status
220 */
221ldns_status ldns_str2rdf_atma(ldns_rdf **rd, const char *str);
222
223/**
224 * convert a str with a IPSECKEY RR into wireformat
225 * \param[in] rd the rdf where to put the data
226 * \param[in] str the string to be converted
227 * \return ldns_status
228 */
229ldns_status ldns_str2rdf_ipseckey(ldns_rdf **rd, const char *str);
230
231/**
232 * convert a dname string into wireformat
233 * \param[in] rd the rdf where to put the data
234 * \param[in] str the string to be converted
235 * \return ldns_status
236 */
237ldns_status ldns_str2rdf_dname(ldns_rdf **rd, const char *str);
238
239/**
240 * convert 4 * 16bit hex separated by colons into wireformat
241 * \param[in] rd the rdf where to put the data
242 * \param[in] str the string to be converted
243 * \return ldns_status
244 */
245ldns_status ldns_str2rdf_ilnp64(ldns_rdf **rd, const char *str);
246
247/**
248 * convert 6 hex bytes separated by dashes into wireformat
249 * \param[in] rd the rdf where to put the data
250 * \param[in] str the string to be converted
251 * \return ldns_status
252 */
253ldns_status ldns_str2rdf_eui48(ldns_rdf **rd, const char *str);
254
255/**
256 * convert 8 hex bytes separated by dashes into wireformat
257 * \param[in] rd the rdf where to put the data
258 * \param[in] str the string to be converted
259 * \return ldns_status
260 */
261ldns_status ldns_str2rdf_eui64(ldns_rdf **rd, const char *str);
262
263/**
264 * Convert a non-zero sequence of US-ASCII letters and numbers into wireformat
265 * \param[in] rd the rdf where to put the data
266 * \param[in] str the string to be converted
267 * \return ldns_status
268 */
269ldns_status ldns_str2rdf_tag(ldns_rdf **rd, const char *str);
270
271/**
272 * Convert a <character-string> encoding of the value field as specified
273 * [RFC1035], Section 5.1., encoded as one bug chunk of data.
274 * \param[in] rd the rdf where to put the data
275 * \param[in] str the string to be converted
276 * \return ldns_status
277 */
278ldns_status ldns_str2rdf_long_str(ldns_rdf **rd, const char *str);
279
280/**
281 * Convert a "<algorithm> <hit> <pk>" encoding of the value field as specified
282 * in Section 6. of [RFC5205], encoded as wireformat as specified in Section 5.
283 * of [RFC5205].
284 * \param[in] rd the rdf where to put the data
285 * \param[in] str the string to be converted
286 * \return ldns_status
287 */
288ldns_status ldns_str2rdf_hip(ldns_rdf **rd, const char *str);
289
290
291#ifdef __cplusplus
292}
293#endif
294
295#endif /* LDNS_2HOST_H */
296