2 * wire2str.h - txt presentation of RRs
4 * (c) NLnet Labs, 2005-2006
6 * See the file LICENSE for the license
12 * Contains functions to translate the wireformat to text
13 * representation, as well as functions to print them.
16 #ifndef LDNS_WIRE2STR_H
17 #define LDNS_WIRE2STR_H
22 struct sldns_struct_lookup_table;
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;
32 extern struct sldns_struct_lookup_table* sldns_rcodes;
33 /** Operation codes */
34 extern struct sldns_struct_lookup_table* sldns_opcodes;
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 /** tsig errors are the rcodes with extra (higher) values */
42 extern struct sldns_struct_lookup_table* sldns_tsig_errors;
45 * Convert wireformat packet to a string representation
46 * @param data: wireformat packet data (starting at ID bytes).
47 * @param len: length of packet.
48 * @return string(malloced) or NULL on failure.
50 char* sldns_wire2str_pkt(uint8_t* data, size_t len);
53 * Convert wireformat RR to a string representation.
54 * @param rr: the wireformat RR, in uncompressed form. Starts at the domain
55 * name start, ends with the rdata of the RR.
56 * @param len: length of the rr wireformat.
57 * @return string(malloced) or NULL on failure.
59 char* sldns_wire2str_rr(uint8_t* rr, size_t len);
62 * Conver wire dname to a string.
63 * @param dname: the dname in uncompressed wireformat.
64 * @param dname_len: length of the dname.
65 * @return string or NULL on failure.
67 char* sldns_wire2str_dname(uint8_t* dname, size_t dname_len);
70 * Convert wire RR type to a string, 'MX', 'TYPE1234'...
71 * @param rrtype: the RR type in host order.
72 * @return malloced string with the RR type or NULL on malloc failure.
74 char* sldns_wire2str_type(uint16_t rrtype);
77 * Convert wire RR class to a string, 'IN', 'CLASS1'.
78 * @param rrclass: the RR class in host order.
79 * @return malloced string with the RR class or NULL on malloc failure.
81 char* sldns_wire2str_class(uint16_t rrclass);
84 * Convert wire packet rcode to a string, 'NOERROR', 'NXDOMAIN'...
85 * @param rcode: as integer, host order
86 * @return malloced string with the rcode or NULL on malloc failure.
88 char* sldns_wire2str_rcode(int rcode);
91 * Print to string, move string along for next content. With va_list.
92 * @param str: string buffer. Adjusted at end to after the output.
93 * @param slen: length of the string buffer. Adjusted at end.
94 * @param format: printf format string.
95 * @param args: arguments for printf.
96 * @return number of characters needed. Can be larger than slen.
98 int sldns_str_vprint(char** str, size_t* slen, const char* format, va_list args);
101 * Print to string, move string along for next content.
102 * @param str: string buffer. Adjusted at end to after the output.
103 * @param slen: length of the string buffer. Adjusted at end.
104 * @param format: printf format string and arguments for it.
105 * @return number of characters needed. Can be larger than slen.
107 int sldns_str_print(char** str, size_t* slen, const char* format, ...)
108 ATTR_FORMAT(printf, 3, 4);
111 * Convert wireformat packet to a string representation with user buffer
112 * It appends every RR with default comments.
113 * For more formatter options use the function: TBD(TODO)
114 * @param data: wireformat packet data (starting at ID bytes).
115 * @param data_len: length of packet.
116 * @param str: the string buffer for the output.
117 * If you pass NULL as the str the return value of the function is
118 * the str_len you need for the entire packet. It does not include
119 * the 0 byte at the end.
120 * @param str_len: the size of the string buffer. If more is needed, it'll
121 * silently truncate the output to fit in the buffer.
122 * @return the number of characters for this element, excluding zerobyte.
123 * Is larger or equal than str_len if output was truncated.
125 int sldns_wire2str_pkt_buf(uint8_t* data, size_t data_len, char* str,
129 * Scan wireformat packet to a string representation with user buffer
130 * It appends every RR with default comments.
131 * For more formatter options use the function: TBD(TODO)
132 * @param data: wireformat packet data (starting at ID bytes).
133 * @param data_len: length of packet.
134 * @param str: the string buffer for the output.
135 * @param str_len: the size of the string buffer.
136 * @return number of characters for string.
137 * returns the number of characters that are needed (except terminating null),
138 * so it may return a value larger than str_len.
139 * On error you get less output (i.e. shorter output in str (null terminated))
140 * On exit the data, data_len, str and str_len values are adjusted to move them
141 * from their original position along the input and output for the content
142 * that has been consumed (and produced) by this function. If the end of the
143 * output string is reached, *str_len is set to 0. The output string is null
144 * terminated (shortening the output if necessary). If the end of the input
145 * is reached *data_len is set to 0.
147 int sldns_wire2str_pkt_scan(uint8_t** data, size_t* data_len, char** str,
151 * Scan wireformat rr to string, with user buffers. It shifts the arguments
152 * to move along (see sldns_wire2str_pkt_scan).
153 * @param data: wireformat data.
154 * @param data_len: length of data buffer.
155 * @param str: string buffer.
156 * @param str_len: length of string buffer.
157 * @param pkt: packet for decompression, if NULL no decompression.
158 * @param pktlen: length of packet buffer.
159 * @return number of characters (except null) needed to print.
161 int sldns_wire2str_rr_scan(uint8_t** data, size_t* data_len, char** str,
162 size_t* str_len, uint8_t* pkt, size_t pktlen);
165 * Scan wireformat question rr to string, with user buffers.
166 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
167 * @param data: wireformat data.
168 * @param data_len: length of data buffer.
169 * @param str: string buffer.
170 * @param str_len: length of string buffer.
171 * @param pkt: packet for decompression, if NULL no decompression.
172 * @param pktlen: length of packet buffer.
173 * @return number of characters (except null) needed to print.
175 int sldns_wire2str_rrquestion_scan(uint8_t** data, size_t* data_len, char** str,
176 size_t* str_len, uint8_t* pkt, size_t pktlen);
179 * Scan wireformat RR to string in unknown RR format, with user buffers.
180 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
181 * @param data: wireformat data.
182 * @param data_len: length of data buffer.
183 * @param str: string buffer.
184 * @param str_len: length of string buffer.
185 * @param pkt: packet for decompression, if NULL no decompression.
186 * @param pktlen: length of packet buffer.
187 * @return number of characters (except null) needed to print.
189 int sldns_wire2str_rr_unknown_scan(uint8_t** data, size_t* data_len, char** str,
190 size_t* str_len, uint8_t* pkt, size_t pktlen);
193 * Print to string the RR-information comment in default format,
194 * with user buffers. Moves string along.
195 * @param str: string buffer.
196 * @param str_len: length of string buffer.
197 * @param rr: wireformat data.
198 * @param rrlen: length of data buffer.
199 * @param dname_off: offset in buffer behind owner dname, the compressed size
201 * @param rrtype: type of the RR, host format.
202 * @return number of characters (except null) needed to print.
204 int sldns_wire2str_rr_comment_print(char** str, size_t* str_len, uint8_t* rr,
205 size_t rrlen, size_t dname_off, uint16_t rrtype);
208 * Scan wireformat packet header to string, with user buffers.
209 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
210 * @param data: wireformat data.
211 * @param data_len: length of data buffer.
212 * @param str: string buffer.
213 * @param str_len: length of string buffer.
214 * @return number of characters (except null) needed to print.
216 int sldns_wire2str_header_scan(uint8_t** data, size_t* data_len, char** str,
220 * Scan wireformat rdata to string, with user buffers.
221 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
222 * @param data: wireformat data.
223 * @param data_len: length of data buffer. The length of the rdata in the
224 * buffer. The rdatalen itself has already been scanned, the data
225 * points to the rdata after the rdatalen.
226 * @param str: string buffer.
227 * @param str_len: length of string buffer.
228 * @param rrtype: RR type of Rdata, host format.
229 * @param pkt: packet for decompression, if NULL no decompression.
230 * @param pktlen: length of packet buffer.
231 * @return number of characters (except null) needed to print.
233 int sldns_wire2str_rdata_scan(uint8_t** data, size_t* data_len, char** str,
234 size_t* str_len, uint16_t rrtype, uint8_t* pkt, size_t pktlen);
237 * Scan wireformat rdata to string in unknown format, with user buffers.
238 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
239 * @param data: wireformat data.
240 * @param data_len: length of data buffer, the length of the rdata in buffer.
241 * @param str: string buffer.
242 * @param str_len: length of string buffer.
243 * @return number of characters (except null) needed to print.
245 int sldns_wire2str_rdata_unknown_scan(uint8_t** data, size_t* data_len,
246 char** str, size_t* str_len);
249 * Scan wireformat domain name to string, with user buffers.
250 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
251 * @param data: wireformat data.
252 * @param data_len: length of data buffer.
253 * @param str: string buffer.
254 * @param str_len: length of string buffer.
255 * @param pkt: packet for decompression, if NULL no decompression.
256 * @param pktlen: length of packet buffer.
257 * @return number of characters (except null) needed to print.
259 int sldns_wire2str_dname_scan(uint8_t** data, size_t* data_len, char** str,
260 size_t* str_len, uint8_t* pkt, size_t pktlen);
263 * Scan wireformat rr type to string, with user buffers.
264 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
265 * @param data: wireformat data.
266 * @param data_len: length of data buffer.
267 * @param str: string buffer.
268 * @param str_len: length of string buffer.
269 * @return number of characters (except null) needed to print.
271 int sldns_wire2str_type_scan(uint8_t** data, size_t* data_len, char** str,
275 * Scan wireformat rr class to string, with user buffers.
276 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
277 * @param data: wireformat data.
278 * @param data_len: length of data buffer.
279 * @param str: string buffer.
280 * @param str_len: length of string buffer.
281 * @return number of characters (except null) needed to print.
283 int sldns_wire2str_class_scan(uint8_t** data, size_t* data_len, char** str,
287 * Scan wireformat rr ttl to string, with user buffers.
288 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
289 * @param data: wireformat data.
290 * @param data_len: length of data buffer.
291 * @param str: string buffer.
292 * @param str_len: length of string buffer.
293 * @return number of characters (except null) needed to print.
295 int sldns_wire2str_ttl_scan(uint8_t** data, size_t* data_len, char** str,
300 * Print host format rr type to string. Moves string along, user buffers.
301 * @param str: string buffer.
302 * @param str_len: length of string buffer.
303 * @param rrtype: host format rr type.
304 * @return number of characters (except null) needed to print.
306 int sldns_wire2str_type_print(char** str, size_t* str_len, uint16_t rrtype);
309 * Print host format rr class to string. Moves string along, user buffers.
310 * @param str: string buffer.
311 * @param str_len: length of string buffer.
312 * @param rrclass: host format rr class.
313 * @return number of characters (except null) needed to print.
315 int sldns_wire2str_class_print(char** str, size_t* str_len, uint16_t rrclass);
318 * Print host format rcode to string. Moves string along, user buffers.
319 * @param str: string buffer.
320 * @param str_len: length of string buffer.
321 * @param rcode: host format rcode number.
322 * @return number of characters (except null) needed to print.
324 int sldns_wire2str_rcode_print(char** str, size_t* str_len, int rcode);
327 * Print host format opcode to string. Moves string along, user buffers.
328 * @param str: string buffer.
329 * @param str_len: length of string buffer.
330 * @param opcode: host format opcode number.
331 * @return number of characters (except null) needed to print.
333 int sldns_wire2str_opcode_print(char** str, size_t* str_len, int opcode);
336 * Print host format EDNS0 option to string. Moves string along, user buffers.
337 * @param str: string buffer.
338 * @param str_len: length of string buffer.
339 * @param opcode: host format option number.
340 * @return number of characters (except null) needed to print.
342 int sldns_wire2str_edns_option_code_print(char** str, size_t* str_len,
346 * Convert RR to string presentation format, on one line. User buffer.
347 * @param rr: wireformat RR data
348 * @param rr_len: length of the rr wire data.
349 * @param str: the string buffer to write to.
350 * If you pass NULL as the str, the return value of the function is
351 * the str_len you need for the entire packet. It does not include
352 * the 0 byte at the end.
353 * @param str_len: the size of the string buffer. If more is needed, it'll
354 * silently truncate the output to fit in the buffer.
355 * @return the number of characters for this element, excluding zerobyte.
356 * Is larger or equal than str_len if output was truncated.
358 int sldns_wire2str_rr_buf(uint8_t* rr, size_t rr_len, char* str,
362 * Convert question RR to string presentation format, on one line. User buffer.
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 packet. 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.
374 int sldns_wire2str_rrquestion_buf(uint8_t* rr, size_t rr_len, char* str,
378 * 3597 printout of an RR in unknown rr format.
379 * There are more format and comment options available for printout
380 * with the function: TBD(TODO)
381 * @param rr: wireformat RR data
382 * @param rr_len: length of the rr wire data.
383 * @param str: the string buffer to write to.
384 * If you pass NULL as the str, the return value of the function is
385 * the str_len you need for the entire rr. It does not include
386 * the 0 byte at the end.
387 * @param str_len: the size of the string buffer. If more is needed, it'll
388 * silently truncate the output to fit in the buffer.
389 * @return the number of characters for this element, excluding zerobyte.
390 * Is larger or equal than str_len if output was truncated.
392 int sldns_wire2str_rr_unknown_buf(uint8_t* rr, size_t rr_len, char* str,
396 * This creates the comment to print after the RR. ; keytag=... , and other
397 * basic comments for RRs.
398 * There are more format and comment options available for printout
399 * with the function: TBD(TODO)
400 * @param rr: wireformat RR data
401 * @param rr_len: length of the rr wire data.
402 * @param dname_len: length of the dname in front of the RR.
403 * @param str: the string buffer to write to.
404 * If you pass NULL as the str, the return value of the function is
405 * the str_len you need for the entire comment. It does not include
406 * the 0 byte at the end.
407 * @param str_len: the size of the string buffer. If more is needed, it'll
408 * silently truncate the output to fit in the buffer.
409 * @return the number of characters for this element, excluding zerobyte.
410 * Is larger or equal than str_len if output was truncated.
412 int sldns_wire2str_rr_comment_buf(uint8_t* rr, size_t rr_len, size_t dname_len,
413 char* str, size_t str_len);
416 * Convert RDATA to string presentation format, on one line. User buffer.
417 * @param rdata: wireformat rdata part of an RR.
418 * @param rdata_len: length of the rr wire data.
419 * @param str: the string buffer to write to.
420 * If you pass NULL as the str, the return value of the function is
421 * the str_len you need for the entire packet. It does not include
422 * the 0 byte at the end.
423 * @param str_len: the size of the string buffer. If more is needed, it'll
424 * silently truncate the output to fit in the buffer.
425 * @param rrtype: rr type of the data
426 * @return the number of characters for this element, excluding zerobyte.
427 * Is larger or equal than str_len if output was truncated.
429 int sldns_wire2str_rdata_buf(uint8_t* rdata, size_t rdata_len, char* str,
430 size_t str_len, uint16_t rrtype);
433 * Convert wire RR type to a string, 'MX', 'TYPE12'. With user buffer.
434 * @param rrtype: the RR type in host order.
435 * @param str: the string to write to.
436 * @param len: length of str.
437 * @return the number of characters for this element, excluding zerobyte.
438 * Is larger or equal than str_len if output was truncated.
440 int sldns_wire2str_type_buf(uint16_t rrtype, char* str, size_t len);
443 * Convert wire RR class to a string, 'IN', 'CLASS12'. With user buffer.
444 * @param rrclass: the RR class in host order.
445 * @param str: the string to write to.
446 * @param len: length of str.
447 * @return the number of characters for this element, excluding zerobyte.
448 * Is larger or equal than str_len if output was truncated.
450 int sldns_wire2str_class_buf(uint16_t rrclass, char* str, size_t len);
453 * Convert wire RR rcode to a string, 'NOERROR', 'NXDOMAIN'. With user buffer.
454 * @param rcode: rcode as integer in host order
455 * @param str: the string to write to.
456 * @param len: length of str.
457 * @return the number of characters for this element, excluding zerobyte.
458 * Is larger or equal than str_len if output was truncated.
460 int sldns_wire2str_rcode_buf(int rcode, char* str, size_t len);
463 * Convert host format opcode to a string. 'QUERY', 'NOTIFY', 'UPDATE'.
465 * @param opcode: opcode as integer in host order
466 * @param str: the string to write to.
467 * @param len: length of str.
468 * @return the number of characters for this element, excluding zerobyte.
469 * Is larger or equal than str_len if output was truncated.
471 int sldns_wire2str_opcode_buf(int opcode, char* str, size_t len);
474 * Convert wire dname to a string, "example.com.". With user buffer.
475 * @param dname: the dname in uncompressed wireformat.
476 * @param dname_len: length of the dname.
477 * @param str: the string to write to.
478 * @param len: length of string.
479 * @return the number of characters for this element, excluding zerobyte.
480 * Is larger or equal than str_len if output was truncated.
482 int sldns_wire2str_dname_buf(uint8_t* dname, size_t dname_len, char* str,
486 * Scan wireformat rdf field to string, with user buffers.
487 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
488 * @param data: wireformat data.
489 * @param data_len: length of data buffer.
490 * @param str: string buffer.
491 * @param str_len: length of string buffer.
492 * @param rdftype: the type of the rdata field, enum sldns_rdf_type.
493 * @param pkt: packet for decompression, if NULL no decompression.
494 * @param pktlen: length of packet buffer.
495 * @return number of characters (except null) needed to print.
496 * Can return -1 on failure.
498 int sldns_wire2str_rdf_scan(uint8_t** data, size_t* data_len, char** str,
499 size_t* str_len, int rdftype, uint8_t* pkt, size_t pktlen);
502 * Scan wireformat int8 field to string, with user buffers.
503 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
504 * @param data: wireformat data.
505 * @param data_len: length of data buffer.
506 * @param str: string buffer.
507 * @param str_len: length of string buffer.
508 * @return number of characters (except null) needed to print.
509 * Can return -1 on failure.
511 int sldns_wire2str_int8_scan(uint8_t** data, size_t* data_len, char** str,
515 * Scan wireformat int16 field to string, with user buffers.
516 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
517 * @param data: wireformat data.
518 * @param data_len: length of data buffer.
519 * @param str: string buffer.
520 * @param str_len: length of string buffer.
521 * @return number of characters (except null) needed to print.
522 * Can return -1 on failure.
524 int sldns_wire2str_int16_scan(uint8_t** data, size_t* data_len, char** str,
528 * Scan wireformat int32 field to string, with user buffers.
529 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
530 * @param data: wireformat data.
531 * @param data_len: length of data buffer.
532 * @param str: string buffer.
533 * @param str_len: length of string buffer.
534 * @return number of characters (except null) needed to print.
535 * Can return -1 on failure.
537 int sldns_wire2str_int32_scan(uint8_t** data, size_t* data_len, char** str,
541 * Scan wireformat period field to string, with user buffers.
542 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
543 * @param data: wireformat data.
544 * @param data_len: length of data buffer.
545 * @param str: string buffer.
546 * @param str_len: length of string buffer.
547 * @return number of characters (except null) needed to print.
548 * Can return -1 on failure.
550 int sldns_wire2str_period_scan(uint8_t** data, size_t* data_len, char** str,
554 * Scan wireformat tsigtime field to string, with user buffers.
555 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
556 * @param data: wireformat data.
557 * @param data_len: length of data buffer.
558 * @param str: string buffer.
559 * @param str_len: length of string buffer.
560 * @return number of characters (except null) needed to print.
561 * Can return -1 on failure.
563 int sldns_wire2str_tsigtime_scan(uint8_t** data, size_t* data_len, char** str,
567 * Scan wireformat ip4 A field to string, with user buffers.
568 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
569 * @param data: wireformat data.
570 * @param data_len: length of data buffer.
571 * @param str: string buffer.
572 * @param str_len: length of string buffer.
573 * @return number of characters (except null) needed to print.
574 * Can return -1 on failure.
576 int sldns_wire2str_a_scan(uint8_t** data, size_t* data_len, char** str,
580 * Scan wireformat ip6 AAAA field to string, with user buffers.
581 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
582 * @param data: wireformat data.
583 * @param data_len: length of data buffer.
584 * @param str: string buffer.
585 * @param str_len: length of string buffer.
586 * @return number of characters (except null) needed to print.
587 * Can return -1 on failure.
589 int sldns_wire2str_aaaa_scan(uint8_t** data, size_t* data_len, char** str,
593 * Scan wireformat str field to string, with user buffers.
594 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
595 * @param data: wireformat data.
596 * @param data_len: length of data buffer.
597 * @param str: string buffer.
598 * @param str_len: length of string buffer.
599 * @return number of characters (except null) needed to print.
600 * Can return -1 on failure.
602 int sldns_wire2str_str_scan(uint8_t** data, size_t* data_len, char** str,
606 * Scan wireformat apl field to string, with user buffers.
607 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
608 * @param data: wireformat data.
609 * @param data_len: length of data buffer.
610 * @param str: string buffer.
611 * @param str_len: length of string buffer.
612 * @return number of characters (except null) needed to print.
613 * Can return -1 on failure.
615 int sldns_wire2str_apl_scan(uint8_t** data, size_t* data_len, char** str,
619 * Scan wireformat b32_ext field to string, with user buffers.
620 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
621 * @param data: wireformat data.
622 * @param data_len: length of data buffer.
623 * @param str: string buffer.
624 * @param str_len: length of string buffer.
625 * @return number of characters (except null) needed to print.
626 * Can return -1 on failure.
628 int sldns_wire2str_b32_ext_scan(uint8_t** data, size_t* data_len, char** str,
632 * Scan wireformat b64 field to string, with user buffers.
633 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
634 * @param data: wireformat data.
635 * @param data_len: length of data buffer.
636 * @param str: string buffer.
637 * @param str_len: length of string buffer.
638 * @return number of characters (except null) needed to print.
639 * Can return -1 on failure.
641 int sldns_wire2str_b64_scan(uint8_t** data, size_t* data_len, char** str,
645 * Scan wireformat hex field to string, with user buffers.
646 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
647 * @param data: wireformat data.
648 * @param data_len: length of data buffer.
649 * @param str: string buffer.
650 * @param str_len: length of string buffer.
651 * @return number of characters (except null) needed to print.
652 * Can return -1 on failure.
654 int sldns_wire2str_hex_scan(uint8_t** data, size_t* data_len, char** str,
658 * Scan wireformat nsec bitmap field to string, with user buffers.
659 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
660 * @param data: wireformat data.
661 * @param data_len: length of data buffer.
662 * @param str: string buffer.
663 * @param str_len: length of string buffer.
664 * @return number of characters (except null) needed to print.
665 * Can return -1 on failure.
667 int sldns_wire2str_nsec_scan(uint8_t** data, size_t* data_len, char** str,
671 * Scan wireformat nsec3_salt field to string, with user buffers.
672 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
673 * @param data: wireformat data.
674 * @param data_len: length of data buffer.
675 * @param str: string buffer.
676 * @param str_len: length of string buffer.
677 * @return number of characters (except null) needed to print.
678 * Can return -1 on failure.
680 int sldns_wire2str_nsec3_salt_scan(uint8_t** data, size_t* data_len, char** str,
684 * Scan wireformat cert_alg field to string, with user buffers.
685 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
686 * @param data: wireformat data.
687 * @param data_len: length of data buffer.
688 * @param str: string buffer.
689 * @param str_len: length of string buffer.
690 * @return number of characters (except null) needed to print.
691 * Can return -1 on failure.
693 int sldns_wire2str_cert_alg_scan(uint8_t** data, size_t* data_len, char** str,
697 * Scan wireformat alg field to string, with user buffers.
698 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
699 * @param data: wireformat data.
700 * @param data_len: length of data buffer.
701 * @param str: string buffer.
702 * @param str_len: length of string buffer.
703 * @return number of characters (except null) needed to print.
704 * Can return -1 on failure.
706 int sldns_wire2str_alg_scan(uint8_t** data, size_t* data_len, char** str,
710 * Scan wireformat type unknown field to string, with user buffers.
711 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
712 * @param data: wireformat data.
713 * @param data_len: length of data buffer.
714 * @param str: string buffer.
715 * @param str_len: length of string buffer.
716 * @return number of characters (except null) needed to print.
717 * Can return -1 on failure.
719 int sldns_wire2str_unknown_scan(uint8_t** data, size_t* data_len, char** str,
723 * Scan wireformat time field to string, with user buffers.
724 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
725 * @param data: wireformat data.
726 * @param data_len: length of data buffer.
727 * @param str: string buffer.
728 * @param str_len: length of string buffer.
729 * @return number of characters (except null) needed to print.
730 * Can return -1 on failure.
732 int sldns_wire2str_time_scan(uint8_t** data, size_t* data_len, char** str,
736 * Scan wireformat LOC field to string, with user buffers.
737 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
738 * @param data: wireformat data.
739 * @param data_len: length of data buffer.
740 * @param str: string buffer.
741 * @param str_len: length of string buffer.
742 * @return number of characters (except null) needed to print.
743 * Can return -1 on failure.
745 int sldns_wire2str_loc_scan(uint8_t** data, size_t* data_len, char** str,
749 * Scan wireformat WKS field to string, with user buffers.
750 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
751 * @param data: wireformat data.
752 * @param data_len: length of data buffer.
753 * @param str: string buffer.
754 * @param str_len: length of string buffer.
755 * @return number of characters (except null) needed to print.
756 * Can return -1 on failure.
758 int sldns_wire2str_wks_scan(uint8_t** data, size_t* data_len, char** str,
762 * Scan wireformat NSAP field to string, with user buffers.
763 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
764 * @param data: wireformat data.
765 * @param data_len: length of data buffer.
766 * @param str: string buffer.
767 * @param str_len: length of string buffer.
768 * @return number of characters (except null) needed to print.
769 * Can return -1 on failure.
771 int sldns_wire2str_nsap_scan(uint8_t** data, size_t* data_len, char** str,
775 * Scan wireformat ATMA field to string, with user buffers.
776 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
777 * @param data: wireformat data.
778 * @param data_len: length of data buffer.
779 * @param str: string buffer.
780 * @param str_len: length of string buffer.
781 * @return number of characters (except null) needed to print.
782 * Can return -1 on failure.
784 int sldns_wire2str_atma_scan(uint8_t** data, size_t* data_len, char** str,
788 * Scan wireformat IPSECKEY field to string, with user buffers.
789 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
790 * @param data: wireformat data.
791 * @param data_len: length of data buffer.
792 * @param str: string buffer.
793 * @param str_len: length of string buffer.
794 * @param pkt: packet for decompression, if NULL no decompression.
795 * @param pktlen: length of packet buffer.
796 * @return number of characters (except null) needed to print.
797 * Can return -1 on failure.
799 int sldns_wire2str_ipseckey_scan(uint8_t** data, size_t* data_len, char** str,
800 size_t* str_len, uint8_t* pkt, size_t pktlen);
803 * Scan wireformat HIP (algo, HIT, pubkey) field to string, with user buffers.
804 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
805 * @param data: wireformat data.
806 * @param data_len: length of data buffer.
807 * @param str: string buffer.
808 * @param str_len: length of string buffer.
809 * @return number of characters (except null) needed to print.
810 * Can return -1 on failure.
812 int sldns_wire2str_hip_scan(uint8_t** data, size_t* data_len, char** str,
816 * Scan wireformat int16_data field to string, with user buffers.
817 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
818 * @param data: wireformat data.
819 * @param data_len: length of data buffer.
820 * @param str: string buffer.
821 * @param str_len: length of string buffer.
822 * @return number of characters (except null) needed to print.
823 * Can return -1 on failure.
825 int sldns_wire2str_int16_data_scan(uint8_t** data, size_t* data_len, char** str,
829 * Scan wireformat tsigerror field to string, with user buffers.
830 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
831 * @param data: wireformat data.
832 * @param data_len: length of data buffer.
833 * @param str: string buffer.
834 * @param str_len: length of string buffer.
835 * @return number of characters (except null) needed to print.
836 * Can return -1 on failure.
838 int sldns_wire2str_tsigerror_scan(uint8_t** data, size_t* data_len, char** str,
842 * Scan wireformat nsec3_next_owner field to string, with user buffers.
843 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
844 * @param data: wireformat data.
845 * @param data_len: length of data buffer.
846 * @param str: string buffer.
847 * @param str_len: length of string buffer.
848 * @return number of characters (except null) needed to print.
849 * Can return -1 on failure.
851 int sldns_wire2str_nsec3_next_owner_scan(uint8_t** data, size_t* data_len,
852 char** str, size_t* str_len);
855 * Scan wireformat ILNP64 field to string, with user buffers.
856 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
857 * @param data: wireformat data.
858 * @param data_len: length of data buffer.
859 * @param str: string buffer.
860 * @param str_len: length of string buffer.
861 * @return number of characters (except null) needed to print.
862 * Can return -1 on failure.
864 int sldns_wire2str_ilnp64_scan(uint8_t** data, size_t* data_len, char** str,
868 * Scan wireformat EUI48 field to string, with user buffers.
869 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
870 * @param data: wireformat data.
871 * @param data_len: length of data buffer.
872 * @param str: string buffer.
873 * @param str_len: length of string buffer.
874 * @return number of characters (except null) needed to print.
875 * Can return -1 on failure.
877 int sldns_wire2str_eui48_scan(uint8_t** data, size_t* data_len, char** str,
881 * Scan wireformat EUI64 field to string, with user buffers.
882 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
883 * @param data: wireformat data.
884 * @param data_len: length of data buffer.
885 * @param str: string buffer.
886 * @param str_len: length of string buffer.
887 * @return number of characters (except null) needed to print.
888 * Can return -1 on failure.
890 int sldns_wire2str_eui64_scan(uint8_t** data, size_t* data_len, char** str,
894 * Scan wireformat TAG field to string, with user buffers.
895 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
896 * @param data: wireformat data.
897 * @param data_len: length of data buffer.
898 * @param str: string buffer.
899 * @param str_len: length of string buffer.
900 * @return number of characters (except null) needed to print.
901 * Can return -1 on failure.
903 int sldns_wire2str_tag_scan(uint8_t** data, size_t* data_len, char** str,
907 * Scan wireformat long_str field to string, with user buffers.
908 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
909 * @param data: wireformat data.
910 * @param data_len: length of data buffer.
911 * @param str: string buffer.
912 * @param str_len: length of string buffer.
913 * @return number of characters (except null) needed to print.
914 * Can return -1 on failure.
916 int sldns_wire2str_long_str_scan(uint8_t** data, size_t* data_len, char** str,
920 * Print EDNS LLQ option data to string. User buffers, moves string pointers.
921 * @param str: string buffer.
922 * @param str_len: length of string buffer.
923 * @param option_data: buffer with EDNS option code data.
924 * @param option_len: length of the data for this option.
925 * @return number of characters (except null) needed to print.
927 int sldns_wire2str_edns_llq_print(char** str, size_t* str_len,
928 uint8_t* option_data, size_t option_len);
931 * Print EDNS UL option data to string. User buffers, moves string pointers.
932 * @param str: string buffer.
933 * @param str_len: length of string buffer.
934 * @param option_data: buffer with EDNS option code data.
935 * @param option_len: length of the data for this option.
936 * @return number of characters (except null) needed to print.
938 int sldns_wire2str_edns_ul_print(char** str, size_t* str_len,
939 uint8_t* option_data, size_t option_len);
942 * Print EDNS NSID option data to string. User buffers, moves string pointers.
943 * @param str: string buffer.
944 * @param str_len: length of string buffer.
945 * @param option_data: buffer with EDNS option code data.
946 * @param option_len: length of the data for this option.
947 * @return number of characters (except null) needed to print.
949 int sldns_wire2str_edns_nsid_print(char** str, size_t* str_len,
950 uint8_t* option_data, size_t option_len);
953 * Print EDNS DAU option data to string. User buffers, moves string pointers.
954 * @param str: string buffer.
955 * @param str_len: length of string buffer.
956 * @param option_data: buffer with EDNS option code data.
957 * @param option_len: length of the data for this option.
958 * @return number of characters (except null) needed to print.
960 int sldns_wire2str_edns_dau_print(char** str, size_t* str_len,
961 uint8_t* option_data, size_t option_len);
964 * Print EDNS DHU option data to string. User buffers, moves string pointers.
965 * @param str: string buffer.
966 * @param str_len: length of string buffer.
967 * @param option_data: buffer with EDNS option code data.
968 * @param option_len: length of the data for this option.
969 * @return number of characters (except null) needed to print.
971 int sldns_wire2str_edns_dhu_print(char** str, size_t* str_len,
972 uint8_t* option_data, size_t option_len);
975 * Print EDNS N3U option data to string. User buffers, moves string pointers.
976 * @param str: string buffer.
977 * @param str_len: length of string buffer.
978 * @param option_data: buffer with EDNS option code data.
979 * @param option_len: length of the data for this option.
980 * @return number of characters (except null) needed to print.
982 int sldns_wire2str_edns_n3u_print(char** str, size_t* str_len,
983 uint8_t* option_data, size_t option_len);
986 * Print EDNS SUBNET option data to string. User buffers, moves string pointers.
987 * @param str: string buffer.
988 * @param str_len: length of string buffer.
989 * @param option_data: buffer with EDNS option code data.
990 * @param option_len: length of the data for this option.
991 * @return number of characters (except null) needed to print.
993 int sldns_wire2str_edns_subnet_print(char** str, size_t* str_len,
994 uint8_t* option_data, size_t option_len);
997 * Print an EDNS option as OPT: VALUE. User buffers, moves string pointers.
998 * @param str: string buffer.
999 * @param str_len: length of string buffer.
1000 * @param option_code: host format EDNS option code.
1001 * @param option_data: buffer with EDNS option code data.
1002 * @param option_len: length of the data for this option.
1003 * @return number of characters (except null) needed to print.
1005 int sldns_wire2str_edns_option_print(char** str, size_t* str_len,
1006 uint16_t option_code, uint8_t* option_data, size_t option_len);
1009 * Scan wireformat EDNS OPT to string, with user buffers.
1010 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
1011 * @param data: wireformat data.
1012 * @param data_len: length of data buffer.
1013 * @param str: string buffer.
1014 * @param str_len: length of string buffer.
1015 * @param pkt: packet with header and other info (may be NULL)
1016 * @param pktlen: length of packet buffer.
1017 * @return number of characters (except null) needed to print.
1019 int sldns_wire2str_edns_scan(uint8_t** data, size_t* data_len, char** str,
1020 size_t* str_len, uint8_t* pkt, size_t pktlen);
1026 #endif /* LDNS_WIRE2STR_H */