xref: /freebsd/contrib/unbound/sldns/str2wire.h (revision 8f76bb7dad48538c6832c2fb466a433d2a3f8cd5)
1 /**
2  * str2wire.h -  read txt presentation of RRs
3  *
4  * (c) NLnet Labs, 2005-2006
5  *
6  * See the file LICENSE for the license
7  */
8 
9 /**
10  * \file
11  *
12  * Parses text to wireformat.
13  */
14 
15 #ifndef LDNS_STR2WIRE_H
16 #define LDNS_STR2WIRE_H
17 
18 /* include rrdef for MAX_DOMAINLEN constant */
19 #include <sldns/rrdef.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 struct sldns_struct_lookup_table;
25 
26 #define LDNS_IP4ADDRLEN      (32/8)
27 #define LDNS_IP6ADDRLEN      (128/8)
28 
29 /** buffer to read an RR, cannot be larger than 64K because of packet size */
30 #define LDNS_RR_BUF_SIZE 65535 /* bytes */
31 #define LDNS_DEFAULT_TTL	3600
32 
33 /* SVCB keys currently defined in draft-ietf-dnsop-svcb-https */
34 #define SVCB_KEY_MANDATORY		0
35 #define SVCB_KEY_ALPN			1
36 #define SVCB_KEY_NO_DEFAULT_ALPN	2
37 #define SVCB_KEY_PORT			3
38 #define SVCB_KEY_IPV4HINT		4
39 #define SVCB_KEY_ECH			5
40 #define SVCB_KEY_IPV6HINT		6
41 #define SVCB_KEY_DOHPATH		7
42 #define SVCPARAMKEY_COUNT		8
43 
44 #define MAX_NUMBER_OF_SVCPARAMS	64
45 
46 #define SVCB_MAX_COMMA_SEPARATED_VALUES	1000
47 
48 /*
49  * To convert class and type to string see
50  * sldns_get_rr_class_by_name(str)
51  * sldns_get_rr_type_by_name(str)
52  * from rrdef.h
53  */
54 
55 /**
56  * Convert text string into dname wireformat, mallocless, with user buffer.
57  * @param str: the text string with the domain name.
58  * @param buf: the result buffer, suggested size LDNS_MAX_DOMAINLEN+1
59  * @param len: length of the buffer on input, length of the result on output.
60  * @return 0 on success, otherwise an error.
61  */
62 int sldns_str2wire_dname_buf(const char* str, uint8_t* buf, size_t* len);
63 
64 /**
65  * Same as sldns_str2wire_dname_buf, but concatenates origin if the domain
66  * name is relative (does not end in '.').
67  * @param str: the text string with the domain name.
68  * @param buf: the result buffer, suggested size LDNS_MAX_DOMAINLEN+1
69  * @param len: length of the buffer on input, length of the result on output.
70  * @param origin: the origin to append or NULL (nothing is appended).
71  * @param origin_len: length of origin.
72  * @return 0 on success, otherwise an error.
73  */
74 int sldns_str2wire_dname_buf_origin(const char* str, uint8_t* buf, size_t* len,
75 	uint8_t* origin, size_t origin_len);
76 
77 /**
78  * Convert text string into dname wireformat
79  * @param str: the text string with the domain name.
80  * @param len: returned length of wireformat.
81  * @return wireformat dname (malloced) or NULL on failure.
82  */
83 uint8_t* sldns_str2wire_dname(const char* str, size_t* len);
84 
85 /**
86  * Convert text RR to wireformat, with user buffer.
87  * @param str: the RR data in text presentation format.
88  * @param rr: the buffer where the result is stored into.  This buffer has
89  * 	the wire-dname(uncompressed), type, class, ttl, rdatalen, rdata.
90  * 	These values are probably not aligned, and in network format.
91  * 	Use the sldns_wirerr_get_xxx functions to access them safely.
92  * 	buffer size LDNS_RR_BUF_SIZE is suggested.
93  * @param len: on input the length of the buffer, on output the amount of
94  * 	the buffer used for the rr.
95  * @param dname_len: if non-NULL, filled with the dname length as result.
96  * 	Because after the dname you find the type, class, ttl, rdatalen, rdata.
97  * @param default_ttl: TTL used if no TTL available.
98  * @param origin: used for origin dname (if not NULL)
99  * @param origin_len: length of origin.
100  * @param prev: used for prev_rr dname (if not NULL)
101  * @param prev_len: length of prev.
102  * @return 0 on success, an error on failure.
103  */
104 int sldns_str2wire_rr_buf(const char* str, uint8_t* rr, size_t* len,
105 	size_t* dname_len, uint32_t default_ttl, uint8_t* origin,
106 	size_t origin_len, uint8_t* prev, size_t prev_len);
107 
108 /**
109  * Same as sldns_str2wire_rr_buf, but there is no rdata, it returns an RR
110  * with zero rdata and no ttl.  It has name, type, class.
111  * You can access those with the sldns_wirerr_get_type and class functions.
112  * @param str: the RR data in text presentation format.
113  * @param rr: the buffer where the result is stored into.
114  * @param len: on input the length of the buffer, on output the amount of
115  * 	the buffer used for the rr.
116  * @param dname_len: if non-NULL, filled with the dname length as result.
117  * 	Because after the dname you find the type, class, ttl, rdatalen, rdata.
118  * @param origin: used for origin dname (if not NULL)
119  * @param origin_len: length of origin.
120  * @param prev: used for prev_rr dname (if not NULL)
121  * @param prev_len: length of prev.
122  * @return 0 on success, an error on failure.
123  */
124 int sldns_str2wire_rr_question_buf(const char* str, uint8_t* rr, size_t* len,
125 	size_t* dname_len, uint8_t* origin, size_t origin_len, uint8_t* prev,
126 	size_t prev_len);
127 
128 /**
129  * Get the type of the RR.
130  * @param rr: the RR in wire format.
131  * @param len: rr length.
132  * @param dname_len: dname length to skip.
133  * @return type in host byteorder
134  */
135 uint16_t sldns_wirerr_get_type(uint8_t* rr, size_t len, size_t dname_len);
136 
137 /**
138  * Get the class of the RR.
139  * @param rr: the RR in wire format.
140  * @param len: rr length.
141  * @param dname_len: dname length to skip.
142  * @return class in host byteorder
143  */
144 uint16_t sldns_wirerr_get_class(uint8_t* rr, size_t len, size_t dname_len);
145 
146 /**
147  * Get the ttl of the RR.
148  * @param rr: the RR in wire format.
149  * @param len: rr length.
150  * @param dname_len: dname length to skip.
151  * @return ttl in host byteorder
152  */
153 uint32_t sldns_wirerr_get_ttl(uint8_t* rr, size_t len, size_t dname_len);
154 
155 /**
156  * Get the rdata length of the RR.
157  * @param rr: the RR in wire format.
158  * @param len: rr length.
159  * @param dname_len: dname length to skip.
160  * @return rdata length in host byteorder
161  * 	If the rdata length is larger than the rr-len allows, it is truncated.
162  * 	So, that it is safe to read the data length returned
163  * 	from this function from the rdata pointer of sldns_wirerr_get_rdata.
164  */
165 uint16_t sldns_wirerr_get_rdatalen(uint8_t* rr, size_t len, size_t dname_len);
166 
167 /**
168  * Get the rdata pointer of the RR.
169  * @param rr: the RR in wire format.
170  * @param len: rr length.
171  * @param dname_len: dname length to skip.
172  * @return rdata pointer
173  */
174 uint8_t* sldns_wirerr_get_rdata(uint8_t* rr, size_t len, size_t dname_len);
175 
176 /**
177  * Get the rdata pointer of the RR. prefixed with rdata length.
178  * @param rr: the RR in wire format.
179  * @param len: rr length.
180  * @param dname_len: dname length to skip.
181  * @return pointer to rdatalength, followed by the rdata.
182  */
183 uint8_t* sldns_wirerr_get_rdatawl(uint8_t* rr, size_t len, size_t dname_len);
184 
185 /**
186  * Parse result codes
187  */
188 #define LDNS_WIREPARSE_MASK 0x0fff
189 #define LDNS_WIREPARSE_SHIFT 12
190 #define LDNS_WIREPARSE_ERROR(e) ((e)&LDNS_WIREPARSE_MASK)
191 #define LDNS_WIREPARSE_OFFSET(e) ((((unsigned)(e))&~LDNS_WIREPARSE_MASK)>>LDNS_WIREPARSE_SHIFT)
192 /* use lookuptable to get error string, sldns_wireparse_errors */
193 #define LDNS_WIREPARSE_ERR_OK 0
194 #define LDNS_WIREPARSE_ERR_GENERAL 342
195 #define LDNS_WIREPARSE_ERR_DOMAINNAME_OVERFLOW 343
196 #define LDNS_WIREPARSE_ERR_DOMAINNAME_UNDERFLOW 344
197 #define LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL 345
198 #define LDNS_WIREPARSE_ERR_LABEL_OVERFLOW 346
199 #define LDNS_WIREPARSE_ERR_EMPTY_LABEL 347
200 #define LDNS_WIREPARSE_ERR_SYNTAX_BAD_ESCAPE 348
201 #define LDNS_WIREPARSE_ERR_SYNTAX 349
202 #define LDNS_WIREPARSE_ERR_SYNTAX_TTL 350
203 #define LDNS_WIREPARSE_ERR_SYNTAX_TYPE 351
204 #define LDNS_WIREPARSE_ERR_SYNTAX_CLASS 352
205 #define LDNS_WIREPARSE_ERR_SYNTAX_RDATA 353
206 #define LDNS_WIREPARSE_ERR_SYNTAX_MISSING_VALUE 354
207 #define LDNS_WIREPARSE_ERR_INVALID_STR 355
208 #define LDNS_WIREPARSE_ERR_SYNTAX_B64 356
209 #define LDNS_WIREPARSE_ERR_SYNTAX_B32_EXT 357
210 #define LDNS_WIREPARSE_ERR_SYNTAX_HEX 358
211 #define LDNS_WIREPARSE_ERR_CERT_BAD_ALGORITHM 359
212 #define LDNS_WIREPARSE_ERR_SYNTAX_TIME 360
213 #define LDNS_WIREPARSE_ERR_SYNTAX_PERIOD 361
214 #define LDNS_WIREPARSE_ERR_SYNTAX_ILNP64 362
215 #define LDNS_WIREPARSE_ERR_SYNTAX_EUI48 363
216 #define LDNS_WIREPARSE_ERR_SYNTAX_EUI64 364
217 #define LDNS_WIREPARSE_ERR_SYNTAX_TAG 365
218 #define LDNS_WIREPARSE_ERR_NOT_IMPL 366
219 #define LDNS_WIREPARSE_ERR_SYNTAX_INT 367
220 #define LDNS_WIREPARSE_ERR_SYNTAX_IP4 368
221 #define LDNS_WIREPARSE_ERR_SYNTAX_IP6 369
222 #define LDNS_WIREPARSE_ERR_SYNTAX_INTEGER_OVERFLOW 370
223 #define LDNS_WIREPARSE_ERR_INCLUDE 371
224 #define LDNS_WIREPARSE_ERR_PARENTHESIS 372
225 #define LDNS_WIREPARSE_ERR_SVCB_UNKNOWN_KEY 373
226 #define LDNS_WIREPARSE_ERR_SVCB_MISSING_PARAM 374
227 #define LDNS_WIREPARSE_ERR_SVCB_TOO_MANY_PARAMS 375
228 #define LDNS_WIREPARSE_ERR_SVCB_DUPLICATE_KEYS 376
229 #define LDNS_WIREPARSE_ERR_SVCB_MANDATORY_TOO_MANY_KEYS 377
230 #define LDNS_WIREPARSE_ERR_SVCB_MANDATORY_MISSING_PARAM 378
231 #define LDNS_WIREPARSE_ERR_SVCB_MANDATORY_DUPLICATE_KEY 379
232 #define LDNS_WIREPARSE_ERR_SVCB_MANDATORY_IN_MANDATORY 380
233 #define LDNS_WIREPARSE_ERR_SVCB_PORT_VALUE_SYNTAX 381
234 #define LDNS_WIREPARSE_ERR_SVCB_IPV4_TOO_MANY_ADDRESSES 382
235 #define LDNS_WIREPARSE_ERR_SVCB_IPV6_TOO_MANY_ADDRESSES 383
236 #define LDNS_WIREPARSE_ERR_SVCB_ALPN_KEY_TOO_LARGE 384
237 #define LDNS_WIREPARSE_ERR_SVCB_NO_DEFAULT_ALPN_VALUE 385
238 #define LDNS_WIREPARSE_ERR_SVCPARAM_BROKEN_RDATA 386
239 
240 
241 /**
242  * Get reference to a constant string for the (parse) error.
243  * @param e: error return value
244  * @return string.
245  */
246 const char* sldns_get_errorstr_parse(int e);
247 
248 /**
249  * wire parse state for parsing files
250  */
251 struct sldns_file_parse_state {
252 	/** the origin domain name, if len!=0. uncompressed wireformat */
253 	uint8_t origin[LDNS_MAX_DOMAINLEN+1];
254 	/** length of origin domain name, in bytes. 0 if not set. */
255 	size_t origin_len;
256 	/** the previous domain name, if len!=0. uncompressed wireformat*/
257 	uint8_t prev_rr[LDNS_MAX_DOMAINLEN+1];
258 	/** length of the previous domain name, in bytes. 0 if not set. */
259 	size_t prev_rr_len;
260 	/** default TTL, this is used if the text does not specify a TTL,
261 	 * host byteorder */
262 	uint32_t default_ttl;
263 	/** line number information */
264 	int lineno;
265 };
266 
267 /**
268  * Read one RR from zonefile with buffer for the data.
269  * @param in: file that is read from (one RR, multiple lines if it spans them).
270  * @param rr: this is malloced by the user and the result is stored here,
271  * 	if an RR is read.  If no RR is read this is signalled with the
272  * 	return len set to 0 (for ORIGIN, TTL directives).
273  * 	The read line is available in the rr_buf (zero terminated), for
274  * 	$DIRECTIVE style elements.
275  * @param len: on input, the length of the rr buffer.  on output the rr len.
276  * 	Buffer size of 64k should be enough.
277  * @param dname_len: returns the length of the dname initial part of the rr.
278  * @param parse_state: pass a pointer to user-allocated struct.
279  * 	Contents are maintained by this function.
280  * 	If you pass NULL then ORIGIN and TTL directives are not honored.
281  * 	You can start out with a particular origin by pre-filling it.
282  * 	otherwise, zero the structure before passing it.
283  * 	lineno is incremented when a newline is passed by the parser,
284  * 	you should initialize it at 1 at the start of the file.
285  * @return 0 on success, error on failure.
286  */
287 int sldns_fp2wire_rr_buf(FILE* in, uint8_t* rr, size_t* len, size_t* dname_len,
288 	struct sldns_file_parse_state* parse_state);
289 
290 /**
291  * Convert one rdf in rdata to wireformat and parse from string.
292  * @param str: the text to convert for this rdata element.
293  * @param rd: rdata buffer for the wireformat.
294  * @param len: length of rd buffer on input, used length on output.
295  * @param rdftype: the type of the rdf.
296  * @return 0 on success, error on failure.
297  */
298 int sldns_str2wire_rdf_buf(const char* str, uint8_t* rd, size_t* len,
299 	sldns_rdf_type rdftype);
300 
301 /**
302  * Convert rdf of type LDNS_RDF_TYPE_INT8 from string to wireformat.
303  * @param str: the text to convert for this rdata element.
304  * @param rd: rdata buffer for the wireformat.
305  * @param len: length of rd buffer on input, used length on output.
306  * @return 0 on success, error on failure.
307  */
308 int sldns_str2wire_int8_buf(const char* str, uint8_t* rd, size_t* len);
309 
310 /**
311  * Convert rdf of type LDNS_RDF_TYPE_INT16 from string to wireformat.
312  * @param str: the text to convert for this rdata element.
313  * @param rd: rdata buffer for the wireformat.
314  * @param len: length of rd buffer on input, used length on output.
315  * @return 0 on success, error on failure.
316  */
317 int sldns_str2wire_int16_buf(const char* str, uint8_t* rd, size_t* len);
318 
319 /**
320  * Convert rdf of type LDNS_RDF_TYPE_INT32 from string to wireformat.
321  * @param str: the text to convert for this rdata element.
322  * @param rd: rdata buffer for the wireformat.
323  * @param len: length of rd buffer on input, used length on output.
324  * @return 0 on success, error on failure.
325  */
326 int sldns_str2wire_int32_buf(const char* str, uint8_t* rd, size_t* len);
327 
328 /**
329  * Convert rdf of type LDNS_RDF_TYPE_A from string to wireformat.
330  * @param str: the text to convert for this rdata element.
331  * @param rd: rdata buffer for the wireformat.
332  * @param len: length of rd buffer on input, used length on output.
333  * @return 0 on success, error on failure.
334  */
335 int sldns_str2wire_a_buf(const char* str, uint8_t* rd, size_t* len);
336 
337 /**
338  * Convert rdf of type LDNS_RDF_TYPE_AAAA from string to wireformat.
339  * @param str: the text to convert for this rdata element.
340  * @param rd: rdata buffer for the wireformat.
341  * @param len: length of rd buffer on input, used length on output.
342  * @return 0 on success, error on failure.
343  */
344 int sldns_str2wire_aaaa_buf(const char* str, uint8_t* rd, size_t* len);
345 
346 /**
347  * Convert rdf of type LDNS_RDF_TYPE_STR from string to wireformat.
348  * @param str: the text to convert for this rdata element.
349  * @param rd: rdata buffer for the wireformat.
350  * @param len: length of rd buffer on input, used length on output.
351  * @return 0 on success, error on failure.
352  */
353 int sldns_str2wire_str_buf(const char* str, uint8_t* rd, size_t* len);
354 
355 /**
356  * Convert rdf of type LDNS_RDF_TYPE_APL from string to wireformat.
357  * @param str: the text to convert for this rdata element.
358  * @param rd: rdata buffer for the wireformat.
359  * @param len: length of rd buffer on input, used length on output.
360  * @return 0 on success, error on failure.
361  */
362 int sldns_str2wire_apl_buf(const char* str, uint8_t* rd, size_t* len);
363 
364 /**
365  * Convert rdf of type LDNS_RDF_TYPE_B64 from string to wireformat.
366  * @param str: the text to convert for this rdata element.
367  * @param rd: rdata buffer for the wireformat.
368  * @param len: length of rd buffer on input, used length on output.
369  * @return 0 on success, error on failure.
370  */
371 int sldns_str2wire_b64_buf(const char* str, uint8_t* rd, size_t* len);
372 
373 /**
374  * Convert rdf of type LDNS_RDF_TYPE_B32_EXT from string to wireformat.
375  * And also LDNS_RDF_TYPE_NSEC3_NEXT_OWNER.
376  * @param str: the text to convert for this rdata element.
377  * @param rd: rdata buffer for the wireformat.
378  * @param len: length of rd buffer on input, used length on output.
379  * @return 0 on success, error on failure.
380  */
381 int sldns_str2wire_b32_ext_buf(const char* str, uint8_t* rd, size_t* len);
382 
383 /**
384  * Convert rdf of type LDNS_RDF_TYPE_HEX from string to wireformat.
385  * @param str: the text to convert for this rdata element.
386  * @param rd: rdata buffer for the wireformat.
387  * @param len: length of rd buffer on input, used length on output.
388  * @return 0 on success, error on failure.
389  */
390 int sldns_str2wire_hex_buf(const char* str, uint8_t* rd, size_t* len);
391 
392 /**
393  * Convert rdf of type LDNS_RDF_TYPE_NSEC from string to wireformat.
394  * @param str: the text to convert for this rdata element.
395  * @param rd: rdata buffer for the wireformat.
396  * @param len: length of rd buffer on input, used length on output.
397  * @return 0 on success, error on failure.
398  */
399 int sldns_str2wire_nsec_buf(const char* str, uint8_t* rd, size_t* len);
400 
401 /**
402  * Convert rdf of type LDNS_RDF_TYPE_TYPE from string to wireformat.
403  * @param str: the text to convert for this rdata element.
404  * @param rd: rdata buffer for the wireformat.
405  * @param len: length of rd buffer on input, used length on output.
406  * @return 0 on success, error on failure.
407  */
408 int sldns_str2wire_type_buf(const char* str, uint8_t* rd, size_t* len);
409 
410 /**
411  * Convert rdf of type LDNS_RDF_TYPE_CLASS from string to wireformat.
412  * @param str: the text to convert for this rdata element.
413  * @param rd: rdata buffer for the wireformat.
414  * @param len: length of rd buffer on input, used length on output.
415  * @return 0 on success, error on failure.
416  */
417 int sldns_str2wire_class_buf(const char* str, uint8_t* rd, size_t* len);
418 
419 /**
420  * Convert rdf of type LDNS_RDF_TYPE_CERT_ALG from string to wireformat.
421  * @param str: the text to convert for this rdata element.
422  * @param rd: rdata buffer for the wireformat.
423  * @param len: length of rd buffer on input, used length on output.
424  * @return 0 on success, error on failure.
425  */
426 int sldns_str2wire_cert_alg_buf(const char* str, uint8_t* rd, size_t* len);
427 
428 /**
429  * Convert rdf of type LDNS_RDF_TYPE_ALG from string to wireformat.
430  * @param str: the text to convert for this rdata element.
431  * @param rd: rdata buffer for the wireformat.
432  * @param len: length of rd buffer on input, used length on output.
433  * @return 0 on success, error on failure.
434  */
435 int sldns_str2wire_alg_buf(const char* str, uint8_t* rd, size_t* len);
436 
437 /**
438  * Convert rdf of type LDNS_RDF_TYPE_TIME from string to wireformat.
439  * @param str: the text to convert for this rdata element.
440  * @param rd: rdata buffer for the wireformat.
441  * @param len: length of rd buffer on input, used length on output.
442  * @return 0 on success, error on failure.
443  */
444 int sldns_str2wire_time_buf(const char* str, uint8_t* rd, size_t* len);
445 
446 /**
447  * Convert rdf of type LDNS_RDF_TYPE_PERIOD from string to wireformat.
448  * @param str: the text to convert for this rdata element.
449  * @param rd: rdata buffer for the wireformat.
450  * @param len: length of rd buffer on input, used length on output.
451  * @return 0 on success, error on failure.
452  */
453 int sldns_str2wire_period_buf(const char* str, uint8_t* rd, size_t* len);
454 
455 /**
456  * Convert rdf of type LDNS_RDF_TYPE_TSIGTIME from string to wireformat.
457  * @param str: the text to convert for this rdata element.
458  * @param rd: rdata buffer for the wireformat.
459  * @param len: length of rd buffer on input, used length on output.
460  * @return 0 on success, error on failure.
461  */
462 int sldns_str2wire_tsigtime_buf(const char* str, uint8_t* rd, size_t* len);
463 
464 /**
465  * Convert rdf of type LDNS_RDF_TYPE_TSIGERROR from string to wireformat.
466  * @param str: the text to convert for this rdata element.
467  * @param rd: rdata buffer for the wireformat.
468  * @param len: length of rd buffer on input, used length on output.
469  * @return 0 on success, error on failure.
470  */
471 int sldns_str2wire_tsigerror_buf(const char* str, uint8_t* rd, size_t* len);
472 
473 /**
474  * Convert rdf of type LDNS_RDF_TYPE_LOC from string to wireformat.
475  * @param str: the text to convert for this rdata element.
476  * @param rd: rdata buffer for the wireformat.
477  * @param len: length of rd buffer on input, used length on output.
478  * @return 0 on success, error on failure.
479  */
480 int sldns_str2wire_loc_buf(const char* str, uint8_t* rd, size_t* len);
481 
482 /**
483  * Convert rdf of type LDNS_RDF_TYPE_WKS from string to wireformat.
484  * @param str: the text to convert for this rdata element.
485  * @param rd: rdata buffer for the wireformat.
486  * @param len: length of rd buffer on input, used length on output.
487  * @return 0 on success, error on failure.
488  */
489 int sldns_str2wire_wks_buf(const char* str, uint8_t* rd, size_t* len);
490 
491 /**
492  * Convert rdf of type LDNS_RDF_TYPE_NSAP from string to wireformat.
493  * @param str: the text to convert for this rdata element.
494  * @param rd: rdata buffer for the wireformat.
495  * @param len: length of rd buffer on input, used length on output.
496  * @return 0 on success, error on failure.
497  */
498 int sldns_str2wire_nsap_buf(const char* str, uint8_t* rd, size_t* len);
499 
500 /**
501  * Convert rdf of type LDNS_RDF_TYPE_ATMA from string to wireformat.
502  * @param str: the text to convert for this rdata element.
503  * @param rd: rdata buffer for the wireformat.
504  * @param len: length of rd buffer on input, used length on output.
505  * @return 0 on success, error on failure.
506  */
507 int sldns_str2wire_atma_buf(const char* str, uint8_t* rd, size_t* len);
508 
509 /**
510  * Convert rdf of type LDNS_RDF_TYPE_IPSECKEY from string to wireformat.
511  * @param str: the text to convert for this rdata element.
512  * @param rd: rdata buffer for the wireformat.
513  * @param len: length of rd buffer on input, used length on output.
514  * @return 0 on success, error on failure.
515  */
516 int sldns_str2wire_ipseckey_buf(const char* str, uint8_t* rd, size_t* len);
517 
518 /**
519  * Convert rdf of type LDNS_RDF_TYPE_NSEC3_SALT from string to wireformat.
520  * @param str: the text to convert for this rdata element.
521  * @param rd: rdata buffer for the wireformat.
522  * @param len: length of rd buffer on input, used length on output.
523  * @return 0 on success, error on failure.
524  */
525 int sldns_str2wire_nsec3_salt_buf(const char* str, uint8_t* rd, size_t* len);
526 
527 /**
528  * Convert rdf of type LDNS_RDF_TYPE_ILNP64 from string to wireformat.
529  * @param str: the text to convert for this rdata element.
530  * @param rd: rdata buffer for the wireformat.
531  * @param len: length of rd buffer on input, used length on output.
532  * @return 0 on success, error on failure.
533  */
534 int sldns_str2wire_ilnp64_buf(const char* str, uint8_t* rd, size_t* len);
535 
536 /**
537  * Convert rdf of type LDNS_RDF_TYPE_EUI48 from string to wireformat.
538  * @param str: the text to convert for this rdata element.
539  * @param rd: rdata buffer for the wireformat.
540  * @param len: length of rd buffer on input, used length on output.
541  * @return 0 on success, error on failure.
542  */
543 int sldns_str2wire_eui48_buf(const char* str, uint8_t* rd, size_t* len);
544 
545 /**
546  * Convert rdf of type LDNS_RDF_TYPE_EUI64 from string to wireformat.
547  * @param str: the text to convert for this rdata element.
548  * @param rd: rdata buffer for the wireformat.
549  * @param len: length of rd buffer on input, used length on output.
550  * @return 0 on success, error on failure.
551  */
552 int sldns_str2wire_eui64_buf(const char* str, uint8_t* rd, size_t* len);
553 
554 /**
555  * Convert rdf of type LDNS_RDF_TYPE_TAG from string to wireformat.
556  * @param str: the text to convert for this rdata element.
557  * @param rd: rdata buffer for the wireformat.
558  * @param len: length of rd buffer on input, used length on output.
559  * @return 0 on success, error on failure.
560  */
561 int sldns_str2wire_tag_buf(const char* str, uint8_t* rd, size_t* len);
562 
563 /**
564  * Convert rdf of type LDNS_RDF_TYPE_LONG_STR from string to wireformat.
565  * @param str: the text to convert for this rdata element.
566  * @param rd: rdata buffer for the wireformat.
567  * @param len: length of rd buffer on input, used length on output.
568  * @return 0 on success, error on failure.
569  */
570 int sldns_str2wire_long_str_buf(const char* str, uint8_t* rd, size_t* len);
571 
572 /**
573  * Convert rdf of type LDNS_RDF_TYPE_HIP from string to wireformat.
574  * @param str: the text to convert for this rdata element.
575  * @param rd: rdata buffer for the wireformat.
576  * @param len: length of rd buffer on input, used length on output.
577  * @return 0 on success, error on failure.
578  */
579 int sldns_str2wire_hip_buf(const char* str, uint8_t* rd, size_t* len);
580 
581 /**
582  * Convert rdf of type LDNS_RDF_TYPE_INT16_DATA from string to wireformat.
583  * @param str: the text to convert for this rdata element.
584  * @param rd: rdata buffer for the wireformat.
585  * @param len: length of rd buffer on input, used length on output.
586  * @return 0 on success, error on failure.
587  */
588 int sldns_str2wire_int16_data_buf(const char* str, uint8_t* rd, size_t* len);
589 
590 /**
591  * Strip whitespace from the start and the end of line.
592  * @param line: modified with 0 to shorten it.
593  * @return new start with spaces skipped.
594  */
595 char * sldns_strip_ws(char *line);
596 #ifdef __cplusplus
597 }
598 #endif
599 
600 #endif /* LDNS_STR2WIRE_H */
601