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