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