]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/unbound/sldns/wire2str.h
Upgrade Unbound to 1.6.2. More to follow.
[FreeBSD/FreeBSD.git] / contrib / unbound / sldns / wire2str.h
1 /**
2  * wire2str.h -  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  * Contains functions to translate the wireformat to text
13  * representation, as well as functions to print them.
14  */
15
16 #ifndef LDNS_WIRE2STR_H
17 #define LDNS_WIRE2STR_H
18
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 struct sldns_struct_lookup_table;
23
24 /* lookup tables for standard DNS stuff  */
25 /** Taken from RFC 2535, section 7.  */
26 extern struct sldns_struct_lookup_table* sldns_algorithms;
27 /** DS record hash algorithms */
28 extern struct sldns_struct_lookup_table* sldns_hashes;
29 /** Taken from RFC 2538, section 2.1.  */
30 extern struct sldns_struct_lookup_table* sldns_cert_algorithms;
31 /** Response codes */
32 extern struct sldns_struct_lookup_table* sldns_rcodes;
33 /** Operation codes */
34 extern struct sldns_struct_lookup_table* sldns_opcodes;
35 /** EDNS flags */
36 extern struct sldns_struct_lookup_table* sldns_edns_flags;
37 /** EDNS option codes */
38 extern struct sldns_struct_lookup_table* sldns_edns_options;
39 /** error string from wireparse */
40 extern struct sldns_struct_lookup_table* sldns_wireparse_errors;
41
42 /**
43  * Convert wireformat packet to a string representation
44  * @param data: wireformat packet data (starting at ID bytes).
45  * @param len: length of packet.
46  * @return string(malloced) or NULL on failure.
47  */
48 char* sldns_wire2str_pkt(uint8_t* data, size_t len);
49
50 /**
51  * Convert wireformat RR to a string representation.
52  * @param rr: the wireformat RR, in uncompressed form.  Starts at the domain
53  *      name start, ends with the rdata of the RR.
54  * @param len: length of the rr wireformat.
55  * @return string(malloced) or NULL on failure.
56  */
57 char* sldns_wire2str_rr(uint8_t* rr, size_t len);
58
59 /**
60  * Conver wire dname to a string.
61  * @param dname: the dname in uncompressed wireformat.
62  * @param dname_len: length of the dname.
63  * @return string or NULL on failure.
64  */
65 char* sldns_wire2str_dname(uint8_t* dname, size_t dname_len);
66
67 /**
68  * Convert wire RR type to a string, 'MX', 'TYPE1234'...
69  * @param rrtype: the RR type in host order.
70  * @return malloced string with the RR type or NULL on malloc failure.
71  */
72 char* sldns_wire2str_type(uint16_t rrtype);
73
74 /**
75  * Convert wire RR class to a string, 'IN', 'CLASS1'.
76  * @param rrclass: the RR class in host order.
77  * @return malloced string with the RR class or NULL on malloc failure.
78  */
79 char* sldns_wire2str_class(uint16_t rrclass);
80
81 /**
82  * Convert wire packet rcode to a string, 'NOERROR', 'NXDOMAIN'...
83  * @param rcode: as integer, host order
84  * @return malloced string with the rcode or NULL on malloc failure.
85  */
86 char* sldns_wire2str_rcode(int rcode);
87
88 /**
89  * Print to string, move string along for next content. With va_list.
90  * @param str: string buffer.  Adjusted at end to after the output.
91  * @param slen: length of the string buffer.  Adjusted at end.
92  * @param format: printf format string.
93  * @param args: arguments for printf.
94  * @return number of characters needed. Can be larger than slen.
95  */
96 int sldns_str_vprint(char** str, size_t* slen, const char* format, va_list args);
97
98 /**
99  * Print to string, move string along for next content.
100  * @param str: string buffer.  Adjusted at end to after the output.
101  * @param slen: length of the string buffer.  Adjusted at end.
102  * @param format: printf format string and arguments for it.
103  * @return number of characters needed. Can be larger than slen.
104  */
105 int sldns_str_print(char** str, size_t* slen, const char* format, ...)
106         ATTR_FORMAT(printf, 3, 4);
107
108 /**
109  * Convert wireformat packet to a string representation with user buffer
110  * It appends every RR with default comments.
111  * For more formatter options use the function: TBD(TODO)
112  * @param data: wireformat packet data (starting at ID bytes).
113  * @param data_len: length of packet.
114  * @param str: the string buffer for the output.
115  *      If you pass NULL as the str the return value of the function is
116  *      the str_len you need for the entire packet.  It does not include
117  *      the 0 byte at the end.
118  * @param str_len: the size of the string buffer.  If more is needed, it'll
119  *      silently truncate the output to fit in the buffer.
120  * @return the number of characters for this element, excluding zerobyte.
121  *      Is larger or equal than str_len if output was truncated.
122  */
123 int sldns_wire2str_pkt_buf(uint8_t* data, size_t data_len, char* str,
124         size_t str_len);
125
126 /**
127  * Scan wireformat packet to a string representation with user buffer
128  * It appends every RR with default comments.
129  * For more formatter options use the function: TBD(TODO)
130  * @param data: wireformat packet data (starting at ID bytes).
131  * @param data_len: length of packet.
132  * @param str: the string buffer for the output.
133  * @param str_len: the size of the string buffer.
134  * @return number of characters for string.
135  * returns the number of characters that are needed (except terminating null),
136  * so it may return a value larger than str_len.
137  * On error you get less output (i.e. shorter output in str (null terminated))
138  * On exit the data, data_len, str and str_len values are adjusted to move them
139  * from their original position along the input and output for the content
140  * that has been consumed (and produced) by this function.  If the end of the
141  * output string is reached, *str_len is set to 0.  The output string is null
142  * terminated (shortening the output if necessary).  If the end of the input
143  * is reached *data_len is set to 0.
144  */
145 int sldns_wire2str_pkt_scan(uint8_t** data, size_t* data_len, char** str,
146         size_t* str_len);
147
148 /**
149  * Scan wireformat rr to string, with user buffers.  It shifts the arguments
150  * to move along (see sldns_wire2str_pkt_scan).
151  * @param data: wireformat data.
152  * @param data_len: length of data buffer.
153  * @param str: string buffer.
154  * @param str_len: length of string buffer.
155  * @param pkt: packet for decompression, if NULL no decompression.
156  * @param pktlen: length of packet buffer.
157  * @return number of characters (except null) needed to print.
158  */
159 int sldns_wire2str_rr_scan(uint8_t** data, size_t* data_len, char** str,
160         size_t* str_len, uint8_t* pkt, size_t pktlen);
161
162 /**
163  * Scan wireformat question rr to string, with user buffers.
164  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
165  * @param data: wireformat data.
166  * @param data_len: length of data buffer.
167  * @param str: string buffer.
168  * @param str_len: length of string buffer.
169  * @param pkt: packet for decompression, if NULL no decompression.
170  * @param pktlen: length of packet buffer.
171  * @return number of characters (except null) needed to print.
172  */
173 int sldns_wire2str_rrquestion_scan(uint8_t** data, size_t* data_len, char** str,
174         size_t* str_len, uint8_t* pkt, size_t pktlen);
175
176 /**
177  * Scan wireformat RR to string in unknown RR format, with user buffers.
178  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
179  * @param data: wireformat data.
180  * @param data_len: length of data buffer.
181  * @param str: string buffer.
182  * @param str_len: length of string buffer.
183  * @param pkt: packet for decompression, if NULL no decompression.
184  * @param pktlen: length of packet buffer.
185  * @return number of characters (except null) needed to print.
186  */
187 int sldns_wire2str_rr_unknown_scan(uint8_t** data, size_t* data_len, char** str,
188         size_t* str_len, uint8_t* pkt, size_t pktlen);
189
190 /**
191  * Print to string the RR-information comment in default format,
192  * with user buffers.  Moves string along.
193  * @param str: string buffer.
194  * @param str_len: length of string buffer.
195  * @param rr: wireformat data.
196  * @param rrlen: length of data buffer.
197  * @param dname_off: offset in buffer behind owner dname, the compressed size
198  *      of the owner name.
199  * @param rrtype: type of the RR, host format.
200  * @return number of characters (except null) needed to print.
201  */
202 int sldns_wire2str_rr_comment_print(char** str, size_t* str_len, uint8_t* rr,
203         size_t rrlen, size_t dname_off, uint16_t rrtype);
204
205 /**
206  * Scan wireformat packet header to string, with user buffers.
207  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
208  * @param data: wireformat data.
209  * @param data_len: length of data buffer.
210  * @param str: string buffer.
211  * @param str_len: length of string buffer.
212  * @return number of characters (except null) needed to print.
213  */
214 int sldns_wire2str_header_scan(uint8_t** data, size_t* data_len, char** str,
215         size_t* str_len);
216
217 /**
218  * Scan wireformat rdata to string, with user buffers.
219  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
220  * @param data: wireformat data.
221  * @param data_len: length of data buffer.  The length of the rdata in the
222  *      buffer.  The rdatalen itself has already been scanned, the data
223  *      points to the rdata after the rdatalen.
224  * @param str: string buffer.
225  * @param str_len: length of string buffer.
226  * @param rrtype: RR type of Rdata, host format.
227  * @param pkt: packet for decompression, if NULL no decompression.
228  * @param pktlen: length of packet buffer.
229  * @return number of characters (except null) needed to print.
230  */
231 int sldns_wire2str_rdata_scan(uint8_t** data, size_t* data_len, char** str,
232         size_t* str_len, uint16_t rrtype, uint8_t* pkt, size_t pktlen);
233
234 /**
235  * Scan wireformat rdata to string in unknown format, with user buffers.
236  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
237  * @param data: wireformat data.
238  * @param data_len: length of data buffer, the length of the rdata in buffer.
239  * @param str: string buffer.
240  * @param str_len: length of string buffer.
241  * @return number of characters (except null) needed to print.
242  */
243 int sldns_wire2str_rdata_unknown_scan(uint8_t** data, size_t* data_len,
244         char** str, size_t* str_len);
245
246 /**
247  * Scan wireformat domain name to string, with user buffers.
248  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
249  * @param data: wireformat data.
250  * @param data_len: length of data buffer.
251  * @param str: string buffer.
252  * @param str_len: length of string buffer.
253  * @param pkt: packet for decompression, if NULL no decompression.
254  * @param pktlen: length of packet buffer.
255  * @return number of characters (except null) needed to print.
256  */
257 int sldns_wire2str_dname_scan(uint8_t** data, size_t* data_len, char** str,
258         size_t* str_len, uint8_t* pkt, size_t pktlen);
259
260 /**
261  * Scan wireformat rr type to string, with user buffers.
262  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
263  * @param data: wireformat data.
264  * @param data_len: length of data buffer.
265  * @param str: string buffer.
266  * @param str_len: length of string buffer.
267  * @return number of characters (except null) needed to print.
268  */
269 int sldns_wire2str_type_scan(uint8_t** data, size_t* data_len, char** str,
270         size_t* str_len);
271
272 /**
273  * Scan wireformat rr class to string, with user buffers.
274  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
275  * @param data: wireformat data.
276  * @param data_len: length of data buffer.
277  * @param str: string buffer.
278  * @param str_len: length of string buffer.
279  * @return number of characters (except null) needed to print.
280  */
281 int sldns_wire2str_class_scan(uint8_t** data, size_t* data_len, char** str,
282         size_t* str_len);
283
284 /**
285  * Scan wireformat rr ttl to string, with user buffers.
286  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
287  * @param data: wireformat data.
288  * @param data_len: length of data buffer.
289  * @param str: string buffer.
290  * @param str_len: length of string buffer.
291  * @return number of characters (except null) needed to print.
292  */
293 int sldns_wire2str_ttl_scan(uint8_t** data, size_t* data_len, char** str,
294         size_t* str_len);
295
296
297 /**
298  * Print host format rr type to string.  Moves string along, user buffers.
299  * @param str: string buffer.
300  * @param str_len: length of string buffer.
301  * @param rrtype: host format rr type.
302  * @return number of characters (except null) needed to print.
303  */
304 int sldns_wire2str_type_print(char** str, size_t* str_len, uint16_t rrtype);
305
306 /**
307  * Print host format rr class to string.  Moves string along, user buffers.
308  * @param str: string buffer.
309  * @param str_len: length of string buffer.
310  * @param rrclass: host format rr class.
311  * @return number of characters (except null) needed to print.
312  */
313 int sldns_wire2str_class_print(char** str, size_t* str_len, uint16_t rrclass);
314
315 /**
316  * Print host format rcode to string.  Moves string along, user buffers.
317  * @param str: string buffer.
318  * @param str_len: length of string buffer.
319  * @param rcode: host format rcode number.
320  * @return number of characters (except null) needed to print.
321  */
322 int sldns_wire2str_rcode_print(char** str, size_t* str_len, int rcode);
323
324 /**
325  * Print host format opcode to string.  Moves string along, user buffers.
326  * @param str: string buffer.
327  * @param str_len: length of string buffer.
328  * @param opcode: host format opcode number.
329  * @return number of characters (except null) needed to print.
330  */
331 int sldns_wire2str_opcode_print(char** str, size_t* str_len, int opcode);
332
333 /**
334  * Print host format EDNS0 option to string.  Moves string along, user buffers.
335  * @param str: string buffer.
336  * @param str_len: length of string buffer.
337  * @param opcode: host format option number.
338  * @return number of characters (except null) needed to print.
339  */
340 int sldns_wire2str_edns_option_code_print(char** str, size_t* str_len,
341         uint16_t opcode);
342
343 /**
344  * Convert RR to string presentation format, on one line.  User buffer.
345  * @param rr: wireformat RR data
346  * @param rr_len: length of the rr wire data.
347  * @param str: the string buffer to write to.
348  *      If you pass NULL as the str, the return value of the function is
349  *      the str_len you need for the entire packet.  It does not include
350  *      the 0 byte at the end.
351  * @param str_len: the size of the string buffer.  If more is needed, it'll
352  *      silently truncate the output to fit in the buffer.
353  * @return the number of characters for this element, excluding zerobyte.
354  *      Is larger or equal than str_len if output was truncated.
355  */
356 int sldns_wire2str_rr_buf(uint8_t* rr, size_t rr_len, char* str,
357         size_t str_len);
358
359 /**
360  * 3597 printout of an RR in unknown rr format.
361  * There are more format and comment options available for printout
362  * with the function: TBD(TODO)
363  * @param rr: wireformat RR data
364  * @param rr_len: length of the rr wire data.
365  * @param str: the string buffer to write to.
366  *      If you pass NULL as the str, the return value of the function is
367  *      the str_len you need for the entire rr.  It does not include
368  *      the 0 byte at the end.
369  * @param str_len: the size of the string buffer.  If more is needed, it'll
370  *      silently truncate the output to fit in the buffer.
371  * @return the number of characters for this element, excluding zerobyte.
372  *      Is larger or equal than str_len if output was truncated.
373  */
374 int sldns_wire2str_rr_unknown_buf(uint8_t* rr, size_t rr_len, char* str,
375         size_t str_len);
376
377 /**
378  * This creates the comment to print after the RR. ; keytag=... , and other
379  * basic comments for RRs.
380  * There are more format and comment options available for printout
381  * with the function: TBD(TODO)
382  * @param rr: wireformat RR data
383  * @param rr_len: length of the rr wire data.
384  * @param dname_len: length of the dname in front of the RR.
385  * @param str: the string buffer to write to.
386  *      If you pass NULL as the str, the return value of the function is
387  *      the str_len you need for the entire comment.  It does not include
388  *      the 0 byte at the end.
389  * @param str_len: the size of the string buffer.  If more is needed, it'll
390  *      silently truncate the output to fit in the buffer.
391  * @return the number of characters for this element, excluding zerobyte.
392  *      Is larger or equal than str_len if output was truncated.
393  */
394 int sldns_wire2str_rr_comment_buf(uint8_t* rr, size_t rr_len, size_t dname_len,
395         char* str, size_t str_len);
396
397 /**
398  * Convert RDATA to string presentation format, on one line.  User buffer.
399  * @param rdata: wireformat rdata part of an RR.
400  * @param rdata_len: length of the rr wire data.
401  * @param str: the string buffer to write to.
402  *      If you pass NULL as the str, the return value of the function is
403  *      the str_len you need for the entire packet.  It does not include
404  *      the 0 byte at the end.
405  * @param str_len: the size of the string buffer.  If more is needed, it'll
406  *      silently truncate the output to fit in the buffer.
407  * @param rrtype: rr type of the data
408  * @return the number of characters for this element, excluding zerobyte.
409  *      Is larger or equal than str_len if output was truncated.
410  */
411 int sldns_wire2str_rdata_buf(uint8_t* rdata, size_t rdata_len, char* str,
412         size_t str_len, uint16_t rrtype);
413
414 /**
415  * Convert wire RR type to a string, 'MX', 'TYPE12'.  With user buffer.
416  * @param rrtype: the RR type in host order.
417  * @param str: the string to write to.
418  * @param len: length of str.
419  * @return the number of characters for this element, excluding zerobyte.
420  *      Is larger or equal than str_len if output was truncated.
421  */
422 int sldns_wire2str_type_buf(uint16_t rrtype, char* str, size_t len);
423
424 /**
425  * Convert wire RR class to a string, 'IN', 'CLASS12'.  With user buffer.
426  * @param rrclass: the RR class in host order.
427  * @param str: the string to write to.
428  * @param len: length of str.
429  * @return the number of characters for this element, excluding zerobyte.
430  *      Is larger or equal than str_len if output was truncated.
431  */
432 int sldns_wire2str_class_buf(uint16_t rrclass, char* str, size_t len);
433
434 /**
435  * Convert wire RR rcode to a string, 'NOERROR', 'NXDOMAIN'.  With user buffer.
436  * @param rcode: rcode as integer in host order
437  * @param str: the string to write to.
438  * @param len: length of str.
439  * @return the number of characters for this element, excluding zerobyte.
440  *      Is larger or equal than str_len if output was truncated.
441  */
442 int sldns_wire2str_rcode_buf(int rcode, char* str, size_t len);
443
444 /**
445  * Convert host format opcode to a string. 'QUERY', 'NOTIFY', 'UPDATE'.
446  * With user buffer.
447  * @param opcode: opcode as integer in host order
448  * @param str: the string to write to.
449  * @param len: length of str.
450  * @return the number of characters for this element, excluding zerobyte.
451  *      Is larger or equal than str_len if output was truncated.
452  */
453 int sldns_wire2str_opcode_buf(int opcode, char* str, size_t len);
454
455 /**
456  * Convert wire dname to a string, "example.com.".  With user buffer.
457  * @param dname: the dname in uncompressed wireformat.
458  * @param dname_len: length of the dname.
459  * @param str: the string to write to.
460  * @param len: length of string.
461  * @return the number of characters for this element, excluding zerobyte.
462  *      Is larger or equal than str_len if output was truncated.
463  */
464 int sldns_wire2str_dname_buf(uint8_t* dname, size_t dname_len, char* str,
465         size_t len);
466
467 /**
468  * Scan wireformat rdf field to string, with user buffers.
469  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
470  * @param data: wireformat data.
471  * @param data_len: length of data buffer.
472  * @param str: string buffer.
473  * @param str_len: length of string buffer.
474  * @param rdftype: the type of the rdata field, enum sldns_rdf_type.
475  * @param pkt: packet for decompression, if NULL no decompression.
476  * @param pktlen: length of packet buffer.
477  * @return number of characters (except null) needed to print.
478  *      Can return -1 on failure.
479  */
480 int sldns_wire2str_rdf_scan(uint8_t** data, size_t* data_len, char** str,
481         size_t* str_len, int rdftype, uint8_t* pkt, size_t pktlen);
482
483 /**
484  * Scan wireformat int8 field to string, with user buffers.
485  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
486  * @param data: wireformat data.
487  * @param data_len: length of data buffer.
488  * @param str: string buffer.
489  * @param str_len: length of string buffer.
490  * @return number of characters (except null) needed to print.
491  *      Can return -1 on failure.
492  */
493 int sldns_wire2str_int8_scan(uint8_t** data, size_t* data_len, char** str,
494         size_t* str_len);
495
496 /**
497  * Scan wireformat int16 field to string, with user buffers.
498  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
499  * @param data: wireformat data.
500  * @param data_len: length of data buffer.
501  * @param str: string buffer.
502  * @param str_len: length of string buffer.
503  * @return number of characters (except null) needed to print.
504  *      Can return -1 on failure.
505  */
506 int sldns_wire2str_int16_scan(uint8_t** data, size_t* data_len, char** str,
507         size_t* str_len);
508
509 /**
510  * Scan wireformat int32 field to string, with user buffers.
511  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
512  * @param data: wireformat data.
513  * @param data_len: length of data buffer.
514  * @param str: string buffer.
515  * @param str_len: length of string buffer.
516  * @return number of characters (except null) needed to print.
517  *      Can return -1 on failure.
518  */
519 int sldns_wire2str_int32_scan(uint8_t** data, size_t* data_len, char** str,
520         size_t* str_len);
521
522 /**
523  * Scan wireformat period field to string, with user buffers.
524  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
525  * @param data: wireformat data.
526  * @param data_len: length of data buffer.
527  * @param str: string buffer.
528  * @param str_len: length of string buffer.
529  * @return number of characters (except null) needed to print.
530  *      Can return -1 on failure.
531  */
532 int sldns_wire2str_period_scan(uint8_t** data, size_t* data_len, char** str,
533         size_t* str_len);
534
535 /**
536  * Scan wireformat tsigtime field to string, with user buffers.
537  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
538  * @param data: wireformat data.
539  * @param data_len: length of data buffer.
540  * @param str: string buffer.
541  * @param str_len: length of string buffer.
542  * @return number of characters (except null) needed to print.
543  *      Can return -1 on failure.
544  */
545 int sldns_wire2str_tsigtime_scan(uint8_t** data, size_t* data_len, char** str,
546         size_t* str_len);
547
548 /**
549  * Scan wireformat ip4 A field to string, with user buffers.
550  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
551  * @param data: wireformat data.
552  * @param data_len: length of data buffer.
553  * @param str: string buffer.
554  * @param str_len: length of string buffer.
555  * @return number of characters (except null) needed to print.
556  *      Can return -1 on failure.
557  */
558 int sldns_wire2str_a_scan(uint8_t** data, size_t* data_len, char** str,
559         size_t* str_len);
560
561 /**
562  * Scan wireformat ip6 AAAA field to string, with user buffers.
563  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
564  * @param data: wireformat data.
565  * @param data_len: length of data buffer.
566  * @param str: string buffer.
567  * @param str_len: length of string buffer.
568  * @return number of characters (except null) needed to print.
569  *      Can return -1 on failure.
570  */
571 int sldns_wire2str_aaaa_scan(uint8_t** data, size_t* data_len, char** str,
572         size_t* str_len);
573
574 /**
575  * Scan wireformat str field to string, with user buffers.
576  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
577  * @param data: wireformat data.
578  * @param data_len: length of data buffer.
579  * @param str: string buffer.
580  * @param str_len: length of string buffer.
581  * @return number of characters (except null) needed to print.
582  *      Can return -1 on failure.
583  */
584 int sldns_wire2str_str_scan(uint8_t** data, size_t* data_len, char** str,
585         size_t* str_len);
586
587 /**
588  * Scan wireformat apl field to string, with user buffers.
589  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
590  * @param data: wireformat data.
591  * @param data_len: length of data buffer.
592  * @param str: string buffer.
593  * @param str_len: length of string buffer.
594  * @return number of characters (except null) needed to print.
595  *      Can return -1 on failure.
596  */
597 int sldns_wire2str_apl_scan(uint8_t** data, size_t* data_len, char** str,
598         size_t* str_len);
599
600 /**
601  * Scan wireformat b32_ext field to string, with user buffers.
602  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
603  * @param data: wireformat data.
604  * @param data_len: length of data buffer.
605  * @param str: string buffer.
606  * @param str_len: length of string buffer.
607  * @return number of characters (except null) needed to print.
608  *      Can return -1 on failure.
609  */
610 int sldns_wire2str_b32_ext_scan(uint8_t** data, size_t* data_len, char** str,
611         size_t* str_len);
612
613 /**
614  * Scan wireformat b64 field to string, with user buffers.
615  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
616  * @param data: wireformat data.
617  * @param data_len: length of data buffer.
618  * @param str: string buffer.
619  * @param str_len: length of string buffer.
620  * @return number of characters (except null) needed to print.
621  *      Can return -1 on failure.
622  */
623 int sldns_wire2str_b64_scan(uint8_t** data, size_t* data_len, char** str,
624         size_t* str_len);
625
626 /**
627  * Scan wireformat hex field to string, with user buffers.
628  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
629  * @param data: wireformat data.
630  * @param data_len: length of data buffer.
631  * @param str: string buffer.
632  * @param str_len: length of string buffer.
633  * @return number of characters (except null) needed to print.
634  *      Can return -1 on failure.
635  */
636 int sldns_wire2str_hex_scan(uint8_t** data, size_t* data_len, char** str,
637         size_t* str_len);
638
639 /**
640  * Scan wireformat nsec bitmap field to string, with user buffers.
641  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
642  * @param data: wireformat data.
643  * @param data_len: length of data buffer.
644  * @param str: string buffer.
645  * @param str_len: length of string buffer.
646  * @return number of characters (except null) needed to print.
647  *      Can return -1 on failure.
648  */
649 int sldns_wire2str_nsec_scan(uint8_t** data, size_t* data_len, char** str,
650         size_t* str_len);
651
652 /**
653  * Scan wireformat nsec3_salt field to string, with user buffers.
654  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
655  * @param data: wireformat data.
656  * @param data_len: length of data buffer.
657  * @param str: string buffer.
658  * @param str_len: length of string buffer.
659  * @return number of characters (except null) needed to print.
660  *      Can return -1 on failure.
661  */
662 int sldns_wire2str_nsec3_salt_scan(uint8_t** data, size_t* data_len, char** str,
663         size_t* str_len);
664
665 /**
666  * Scan wireformat cert_alg field to string, with user buffers.
667  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
668  * @param data: wireformat data.
669  * @param data_len: length of data buffer.
670  * @param str: string buffer.
671  * @param str_len: length of string buffer.
672  * @return number of characters (except null) needed to print.
673  *      Can return -1 on failure.
674  */
675 int sldns_wire2str_cert_alg_scan(uint8_t** data, size_t* data_len, char** str,
676         size_t* str_len);
677
678 /**
679  * Scan wireformat alg field to string, with user buffers.
680  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
681  * @param data: wireformat data.
682  * @param data_len: length of data buffer.
683  * @param str: string buffer.
684  * @param str_len: length of string buffer.
685  * @return number of characters (except null) needed to print.
686  *      Can return -1 on failure.
687  */
688 int sldns_wire2str_alg_scan(uint8_t** data, size_t* data_len, char** str,
689         size_t* str_len);
690
691 /**
692  * Scan wireformat type unknown field to string, with user buffers.
693  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
694  * @param data: wireformat data.
695  * @param data_len: length of data buffer.
696  * @param str: string buffer.
697  * @param str_len: length of string buffer.
698  * @return number of characters (except null) needed to print.
699  *      Can return -1 on failure.
700  */
701 int sldns_wire2str_unknown_scan(uint8_t** data, size_t* data_len, char** str,
702         size_t* str_len);
703
704 /**
705  * Scan wireformat time field to string, with user buffers.
706  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
707  * @param data: wireformat data.
708  * @param data_len: length of data buffer.
709  * @param str: string buffer.
710  * @param str_len: length of string buffer.
711  * @return number of characters (except null) needed to print.
712  *      Can return -1 on failure.
713  */
714 int sldns_wire2str_time_scan(uint8_t** data, size_t* data_len, char** str,
715         size_t* str_len);
716
717 /**
718  * Scan wireformat LOC field to string, with user buffers.
719  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
720  * @param data: wireformat data.
721  * @param data_len: length of data buffer.
722  * @param str: string buffer.
723  * @param str_len: length of string buffer.
724  * @return number of characters (except null) needed to print.
725  *      Can return -1 on failure.
726  */
727 int sldns_wire2str_loc_scan(uint8_t** data, size_t* data_len, char** str,
728         size_t* str_len);
729
730 /**
731  * Scan wireformat WKS field to string, with user buffers.
732  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
733  * @param data: wireformat data.
734  * @param data_len: length of data buffer.
735  * @param str: string buffer.
736  * @param str_len: length of string buffer.
737  * @return number of characters (except null) needed to print.
738  *      Can return -1 on failure.
739  */
740 int sldns_wire2str_wks_scan(uint8_t** data, size_t* data_len, char** str,
741         size_t* str_len);
742
743 /**
744  * Scan wireformat NSAP field to string, with user buffers.
745  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
746  * @param data: wireformat data.
747  * @param data_len: length of data buffer.
748  * @param str: string buffer.
749  * @param str_len: length of string buffer.
750  * @return number of characters (except null) needed to print.
751  *      Can return -1 on failure.
752  */
753 int sldns_wire2str_nsap_scan(uint8_t** data, size_t* data_len, char** str,
754         size_t* str_len);
755
756 /**
757  * Scan wireformat ATMA field to string, with user buffers.
758  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
759  * @param data: wireformat data.
760  * @param data_len: length of data buffer.
761  * @param str: string buffer.
762  * @param str_len: length of string buffer.
763  * @return number of characters (except null) needed to print.
764  *      Can return -1 on failure.
765  */
766 int sldns_wire2str_atma_scan(uint8_t** data, size_t* data_len, char** str,
767         size_t* str_len);
768
769 /**
770  * Scan wireformat IPSECKEY field to string, with user buffers.
771  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
772  * @param data: wireformat data.
773  * @param data_len: length of data buffer.
774  * @param str: string buffer.
775  * @param str_len: length of string buffer.
776  * @param pkt: packet for decompression, if NULL no decompression.
777  * @param pktlen: length of packet buffer.
778  * @return number of characters (except null) needed to print.
779  *      Can return -1 on failure.
780  */
781 int sldns_wire2str_ipseckey_scan(uint8_t** data, size_t* data_len, char** str,
782         size_t* str_len, uint8_t* pkt, size_t pktlen);
783
784 /**
785  * Scan wireformat HIP (algo, HIT, pubkey) field to string, with user buffers.
786  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
787  * @param data: wireformat data.
788  * @param data_len: length of data buffer.
789  * @param str: string buffer.
790  * @param str_len: length of string buffer.
791  * @return number of characters (except null) needed to print.
792  *      Can return -1 on failure.
793  */
794 int sldns_wire2str_hip_scan(uint8_t** data, size_t* data_len, char** str,
795         size_t* str_len);
796
797 /**
798  * Scan wireformat int16_data field to string, with user buffers.
799  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
800  * @param data: wireformat data.
801  * @param data_len: length of data buffer.
802  * @param str: string buffer.
803  * @param str_len: length of string buffer.
804  * @return number of characters (except null) needed to print.
805  *      Can return -1 on failure.
806  */
807 int sldns_wire2str_int16_data_scan(uint8_t** data, size_t* data_len, char** str,
808         size_t* str_len);
809
810 /**
811  * Scan wireformat nsec3_next_owner field to string, with user buffers.
812  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
813  * @param data: wireformat data.
814  * @param data_len: length of data buffer.
815  * @param str: string buffer.
816  * @param str_len: length of string buffer.
817  * @return number of characters (except null) needed to print.
818  *      Can return -1 on failure.
819  */
820 int sldns_wire2str_nsec3_next_owner_scan(uint8_t** data, size_t* data_len,
821         char** str, size_t* str_len);
822
823 /**
824  * Scan wireformat ILNP64 field to string, with user buffers.
825  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
826  * @param data: wireformat data.
827  * @param data_len: length of data buffer.
828  * @param str: string buffer.
829  * @param str_len: length of string buffer.
830  * @return number of characters (except null) needed to print.
831  *      Can return -1 on failure.
832  */
833 int sldns_wire2str_ilnp64_scan(uint8_t** data, size_t* data_len, char** str,
834         size_t* str_len);
835
836 /**
837  * Scan wireformat EUI48 field to string, with user buffers.
838  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
839  * @param data: wireformat data.
840  * @param data_len: length of data buffer.
841  * @param str: string buffer.
842  * @param str_len: length of string buffer.
843  * @return number of characters (except null) needed to print.
844  *      Can return -1 on failure.
845  */
846 int sldns_wire2str_eui48_scan(uint8_t** data, size_t* data_len, char** str,
847         size_t* str_len);
848
849 /**
850  * Scan wireformat EUI64 field to string, with user buffers.
851  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
852  * @param data: wireformat data.
853  * @param data_len: length of data buffer.
854  * @param str: string buffer.
855  * @param str_len: length of string buffer.
856  * @return number of characters (except null) needed to print.
857  *      Can return -1 on failure.
858  */
859 int sldns_wire2str_eui64_scan(uint8_t** data, size_t* data_len, char** str,
860         size_t* str_len);
861
862 /**
863  * Scan wireformat TAG field to string, with user buffers.
864  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
865  * @param data: wireformat data.
866  * @param data_len: length of data buffer.
867  * @param str: string buffer.
868  * @param str_len: length of string buffer.
869  * @return number of characters (except null) needed to print.
870  *      Can return -1 on failure.
871  */
872 int sldns_wire2str_tag_scan(uint8_t** data, size_t* data_len, char** str,
873         size_t* str_len);
874
875 /**
876  * Scan wireformat long_str field to string, with user buffers.
877  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
878  * @param data: wireformat data.
879  * @param data_len: length of data buffer.
880  * @param str: string buffer.
881  * @param str_len: length of string buffer.
882  * @return number of characters (except null) needed to print.
883  *      Can return -1 on failure.
884  */
885 int sldns_wire2str_long_str_scan(uint8_t** data, size_t* data_len, char** str,
886         size_t* str_len);
887
888 /**
889  * Print EDNS LLQ option data to string.  User buffers, moves string pointers.
890  * @param str: string buffer.
891  * @param str_len: length of string buffer.
892  * @param option_data: buffer with EDNS option code data.
893  * @param option_len: length of the data for this option.
894  * @return number of characters (except null) needed to print.
895  */
896 int sldns_wire2str_edns_llq_print(char** str, size_t* str_len,
897         uint8_t* option_data, size_t option_len);
898
899 /**
900  * Print EDNS UL option data to string.  User buffers, moves string pointers.
901  * @param str: string buffer.
902  * @param str_len: length of string buffer.
903  * @param option_data: buffer with EDNS option code data.
904  * @param option_len: length of the data for this option.
905  * @return number of characters (except null) needed to print.
906  */
907 int sldns_wire2str_edns_ul_print(char** str, size_t* str_len,
908         uint8_t* option_data, size_t option_len);
909
910 /**
911  * Print EDNS NSID option data to string.  User buffers, moves string pointers.
912  * @param str: string buffer.
913  * @param str_len: length of string buffer.
914  * @param option_data: buffer with EDNS option code data.
915  * @param option_len: length of the data for this option.
916  * @return number of characters (except null) needed to print.
917  */
918 int sldns_wire2str_edns_nsid_print(char** str, size_t* str_len,
919         uint8_t* option_data, size_t option_len);
920
921 /**
922  * Print EDNS DAU option data to string.  User buffers, moves string pointers.
923  * @param str: string buffer.
924  * @param str_len: length of string buffer.
925  * @param option_data: buffer with EDNS option code data.
926  * @param option_len: length of the data for this option.
927  * @return number of characters (except null) needed to print.
928  */
929 int sldns_wire2str_edns_dau_print(char** str, size_t* str_len,
930         uint8_t* option_data, size_t option_len);
931
932 /**
933  * Print EDNS DHU option data to string.  User buffers, moves string pointers.
934  * @param str: string buffer.
935  * @param str_len: length of string buffer.
936  * @param option_data: buffer with EDNS option code data.
937  * @param option_len: length of the data for this option.
938  * @return number of characters (except null) needed to print.
939  */
940 int sldns_wire2str_edns_dhu_print(char** str, size_t* str_len,
941         uint8_t* option_data, size_t option_len);
942
943 /**
944  * Print EDNS N3U option data to string.  User buffers, moves string pointers.
945  * @param str: string buffer.
946  * @param str_len: length of string buffer.
947  * @param option_data: buffer with EDNS option code data.
948  * @param option_len: length of the data for this option.
949  * @return number of characters (except null) needed to print.
950  */
951 int sldns_wire2str_edns_n3u_print(char** str, size_t* str_len,
952         uint8_t* option_data, size_t option_len);
953
954 /**
955  * Print EDNS SUBNET option data to string. User buffers, moves string pointers.
956  * @param str: string buffer.
957  * @param str_len: length of string buffer.
958  * @param option_data: buffer with EDNS option code data.
959  * @param option_len: length of the data for this option.
960  * @return number of characters (except null) needed to print.
961  */
962 int sldns_wire2str_edns_subnet_print(char** str, size_t* str_len,
963         uint8_t* option_data, size_t option_len);
964
965 /**
966  * Print an EDNS option as OPT: VALUE.  User buffers, moves string pointers.
967  * @param str: string buffer.
968  * @param str_len: length of string buffer.
969  * @param option_code: host format EDNS option code.
970  * @param option_data: buffer with EDNS option code data.
971  * @param option_len: length of the data for this option.
972  * @return number of characters (except null) needed to print.
973  */
974 int sldns_wire2str_edns_option_print(char** str, size_t* str_len,
975         uint16_t option_code, uint8_t* option_data, size_t option_len);
976
977 /**
978  * Scan wireformat EDNS OPT to string, with user buffers.
979  * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
980  * @param data: wireformat data.
981  * @param data_len: length of data buffer.
982  * @param str: string buffer.
983  * @param str_len: length of string buffer.
984  * @param pkt: packet with header and other info (may be NULL)
985  * @param pktlen: length of packet buffer.
986  * @return number of characters (except null) needed to print.
987  */
988 int sldns_wire2str_edns_scan(uint8_t** data, size_t* data_len, char** str,
989         size_t* str_len, uint8_t* pkt, size_t pktlen);
990
991 #ifdef __cplusplus
992 }
993 #endif
994
995 #endif /* LDNS_WIRE2STR_H */