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 /** tsig errors are the rcodes with extra (higher) values */ 42 extern struct sldns_struct_lookup_table* sldns_tsig_errors; 43 44 /** 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. 49 */ 50 char* sldns_wire2str_pkt(uint8_t* data, size_t len); 51 52 /** 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. 58 */ 59 char* sldns_wire2str_rr(uint8_t* rr, size_t len); 60 61 /** 62 * Convert 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. 66 */ 67 char* sldns_wire2str_dname(uint8_t* dname, size_t dname_len); 68 69 /** 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. 73 */ 74 char* sldns_wire2str_type(uint16_t rrtype); 75 76 /** 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. 80 */ 81 char* sldns_wire2str_class(uint16_t rrclass); 82 83 /** 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. 87 */ 88 char* sldns_wire2str_rcode(int rcode); 89 90 /** 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. 97 */ 98 int sldns_str_vprint(char** str, size_t* slen, const char* format, va_list args); 99 100 /** 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. 106 */ 107 int sldns_str_print(char** str, size_t* slen, const char* format, ...) 108 ATTR_FORMAT(printf, 3, 4); 109 110 /** 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. 124 */ 125 int sldns_wire2str_pkt_buf(uint8_t* data, size_t data_len, char* str, 126 size_t str_len); 127 128 /** 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. 146 */ 147 int sldns_wire2str_pkt_scan(uint8_t** data, size_t* data_len, char** str, 148 size_t* str_len); 149 150 /** 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 * @param comprloop: if pkt, bool detects compression loops. 160 * @return number of characters (except null) needed to print. 161 */ 162 int sldns_wire2str_rr_scan(uint8_t** data, size_t* data_len, char** str, 163 size_t* str_len, uint8_t* pkt, size_t pktlen, int* comprloop); 164 165 /** 166 * Scan wireformat question rr to string, with user buffers. 167 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 168 * @param data: wireformat data. 169 * @param data_len: length of data buffer. 170 * @param str: string buffer. 171 * @param str_len: length of string buffer. 172 * @param pkt: packet for decompression, if NULL no decompression. 173 * @param pktlen: length of packet buffer. 174 * @param comprloop: if pkt, bool detects compression loops. 175 * @return number of characters (except null) needed to print. 176 */ 177 int sldns_wire2str_rrquestion_scan(uint8_t** data, size_t* data_len, char** str, 178 size_t* str_len, uint8_t* pkt, size_t pktlen, int* comprloop); 179 180 /** 181 * Scan wireformat RR to string in unknown RR format, with user buffers. 182 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 183 * @param data: wireformat data. 184 * @param data_len: length of data buffer. 185 * @param str: string buffer. 186 * @param str_len: length of string buffer. 187 * @param pkt: packet for decompression, if NULL no decompression. 188 * @param pktlen: length of packet buffer. 189 * @param comprloop: if pkt, bool detects compression loops. 190 * @return number of characters (except null) needed to print. 191 */ 192 int sldns_wire2str_rr_unknown_scan(uint8_t** data, size_t* data_len, char** str, 193 size_t* str_len, uint8_t* pkt, size_t pktlen, int* comprloop); 194 195 /** 196 * Print to string the RR-information comment in default format, 197 * with user buffers. Moves string along. 198 * @param str: string buffer. 199 * @param str_len: length of string buffer. 200 * @param rr: wireformat data. 201 * @param rrlen: length of data buffer. 202 * @param dname_off: offset in buffer behind owner dname, the compressed size 203 * of the owner name. 204 * @param rrtype: type of the RR, host format. 205 * @return number of characters (except null) needed to print. 206 */ 207 int sldns_wire2str_rr_comment_print(char** str, size_t* str_len, uint8_t* rr, 208 size_t rrlen, size_t dname_off, uint16_t rrtype); 209 210 /** 211 * Scan wireformat packet header to string, with user buffers. 212 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 213 * @param data: wireformat data. 214 * @param data_len: length of data buffer. 215 * @param str: string buffer. 216 * @param str_len: length of string buffer. 217 * @return number of characters (except null) needed to print. 218 */ 219 int sldns_wire2str_header_scan(uint8_t** data, size_t* data_len, char** str, 220 size_t* str_len); 221 222 /** 223 * Scan wireformat rdata to string, with user buffers. 224 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 225 * @param data: wireformat data. 226 * @param data_len: length of data buffer. The length of the rdata in the 227 * buffer. The rdatalen itself has already been scanned, the data 228 * points to the rdata after the rdatalen. 229 * @param str: string buffer. 230 * @param str_len: length of string buffer. 231 * @param rrtype: RR type of Rdata, host format. 232 * @param pkt: packet for decompression, if NULL no decompression. 233 * @param pktlen: length of packet buffer. 234 * @param comprloop: if pkt, bool detects compression loops. 235 * @return number of characters (except null) needed to print. 236 */ 237 int sldns_wire2str_rdata_scan(uint8_t** data, size_t* data_len, char** str, 238 size_t* str_len, uint16_t rrtype, uint8_t* pkt, size_t pktlen, 239 int* comprloop); 240 241 /** 242 * Scan wireformat rdata to string in unknown format, with user buffers. 243 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 244 * @param data: wireformat data. 245 * @param data_len: length of data buffer, the length of the rdata in buffer. 246 * @param str: string buffer. 247 * @param str_len: length of string buffer. 248 * @return number of characters (except null) needed to print. 249 */ 250 int sldns_wire2str_rdata_unknown_scan(uint8_t** data, size_t* data_len, 251 char** str, size_t* str_len); 252 253 /** 254 * Scan wireformat domain name to string, with user buffers. 255 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 256 * @param data: wireformat data. 257 * @param data_len: length of data buffer. 258 * @param str: string buffer. 259 * @param str_len: length of string buffer. 260 * @param pkt: packet for decompression, if NULL no decompression. 261 * @param pktlen: length of packet buffer. 262 * @param comprloop: inout bool, that is set true if compression loop failure 263 * happens. Pass in 0, if passsed in as true, a lower bound is set 264 * on compression loops to stop arbitrary long packet parse times. 265 * This is meant so you can set it to 0 at the start of a list of dnames, 266 * and then scan all of them in sequence, if a loop happens, it becomes 267 * true and then it becomes more strict for the next dnames in the list. 268 * You can leave it at NULL if there is no pkt (pkt is NULL too). 269 * @return number of characters (except null) needed to print. 270 */ 271 int sldns_wire2str_dname_scan(uint8_t** data, size_t* data_len, char** str, 272 size_t* str_len, uint8_t* pkt, size_t pktlen, int* comprloop); 273 274 /** 275 * Scan wireformat rr type 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. 282 */ 283 int sldns_wire2str_type_scan(uint8_t** data, size_t* data_len, char** str, 284 size_t* str_len); 285 286 /** 287 * Scan wireformat rr class 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. 294 */ 295 int sldns_wire2str_class_scan(uint8_t** data, size_t* data_len, char** str, 296 size_t* str_len); 297 298 /** 299 * Scan wireformat rr ttl to string, with user buffers. 300 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 301 * @param data: wireformat data. 302 * @param data_len: length of data buffer. 303 * @param str: string buffer. 304 * @param str_len: length of string buffer. 305 * @return number of characters (except null) needed to print. 306 */ 307 int sldns_wire2str_ttl_scan(uint8_t** data, size_t* data_len, char** str, 308 size_t* str_len); 309 310 311 /** 312 * Print host format rr type to string. Moves string along, user buffers. 313 * @param str: string buffer. 314 * @param str_len: length of string buffer. 315 * @param rrtype: host format rr type. 316 * @return number of characters (except null) needed to print. 317 */ 318 int sldns_wire2str_type_print(char** str, size_t* str_len, uint16_t rrtype); 319 320 /** 321 * Print host format rr class to string. Moves string along, user buffers. 322 * @param str: string buffer. 323 * @param str_len: length of string buffer. 324 * @param rrclass: host format rr class. 325 * @return number of characters (except null) needed to print. 326 */ 327 int sldns_wire2str_class_print(char** str, size_t* str_len, uint16_t rrclass); 328 329 /** 330 * Print host format rcode to string. Moves string along, user buffers. 331 * @param str: string buffer. 332 * @param str_len: length of string buffer. 333 * @param rcode: host format rcode number. 334 * @return number of characters (except null) needed to print. 335 */ 336 int sldns_wire2str_rcode_print(char** str, size_t* str_len, int rcode); 337 338 /** 339 * Print host format opcode to string. Moves string along, user buffers. 340 * @param str: string buffer. 341 * @param str_len: length of string buffer. 342 * @param opcode: host format opcode number. 343 * @return number of characters (except null) needed to print. 344 */ 345 int sldns_wire2str_opcode_print(char** str, size_t* str_len, int opcode); 346 347 /** 348 * Print host format EDNS0 option to string. Moves string along, user buffers. 349 * @param str: string buffer. 350 * @param str_len: length of string buffer. 351 * @param opcode: host format option number. 352 * @return number of characters (except null) needed to print. 353 */ 354 int sldns_wire2str_edns_option_code_print(char** str, size_t* str_len, 355 uint16_t opcode); 356 357 /** 358 * Convert RR to string presentation format, on one line. User buffer. 359 * @param rr: wireformat RR data 360 * @param rr_len: length of the rr wire data. 361 * @param str: the string buffer to write to. 362 * If you pass NULL as the str, the return value of the function is 363 * the str_len you need for the entire packet. It does not include 364 * the 0 byte at the end. 365 * @param str_len: the size of the string buffer. If more is needed, it'll 366 * silently truncate the output to fit in the buffer. 367 * @return the number of characters for this element, excluding zerobyte. 368 * Is larger or equal than str_len if output was truncated. 369 */ 370 int sldns_wire2str_rr_buf(uint8_t* rr, size_t rr_len, char* str, 371 size_t str_len); 372 373 /** 374 * Convert question RR to string presentation format, on one line. User buffer. 375 * @param rr: wireformat RR data 376 * @param rr_len: length of the rr wire data. 377 * @param str: the string buffer to write to. 378 * If you pass NULL as the str, the return value of the function is 379 * the str_len you need for the entire packet. It does not include 380 * the 0 byte at the end. 381 * @param str_len: the size of the string buffer. If more is needed, it'll 382 * silently truncate the output to fit in the buffer. 383 * @return the number of characters for this element, excluding zerobyte. 384 * Is larger or equal than str_len if output was truncated. 385 */ 386 int sldns_wire2str_rrquestion_buf(uint8_t* rr, size_t rr_len, char* str, 387 size_t str_len); 388 389 /** 390 * 3597 printout of an RR in unknown rr format. 391 * There are more format and comment options available for printout 392 * with the function: TBD(TODO) 393 * @param rr: wireformat RR data 394 * @param rr_len: length of the rr wire data. 395 * @param str: the string buffer to write to. 396 * If you pass NULL as the str, the return value of the function is 397 * the str_len you need for the entire rr. It does not include 398 * the 0 byte at the end. 399 * @param str_len: the size of the string buffer. If more is needed, it'll 400 * silently truncate the output to fit in the buffer. 401 * @return the number of characters for this element, excluding zerobyte. 402 * Is larger or equal than str_len if output was truncated. 403 */ 404 int sldns_wire2str_rr_unknown_buf(uint8_t* rr, size_t rr_len, char* str, 405 size_t str_len); 406 407 /** 408 * This creates the comment to print after the RR. ; keytag=... , and other 409 * basic comments for RRs. 410 * There are more format and comment options available for printout 411 * with the function: TBD(TODO) 412 * @param rr: wireformat RR data 413 * @param rr_len: length of the rr wire data. 414 * @param dname_len: length of the dname in front of the RR. 415 * @param str: the string buffer to write to. 416 * If you pass NULL as the str, the return value of the function is 417 * the str_len you need for the entire comment. It does not include 418 * the 0 byte at the end. 419 * @param str_len: the size of the string buffer. If more is needed, it'll 420 * silently truncate the output to fit in the buffer. 421 * @return the number of characters for this element, excluding zerobyte. 422 * Is larger or equal than str_len if output was truncated. 423 */ 424 int sldns_wire2str_rr_comment_buf(uint8_t* rr, size_t rr_len, size_t dname_len, 425 char* str, size_t str_len); 426 427 /** 428 * Convert RDATA to string presentation format, on one line. User buffer. 429 * @param rdata: wireformat rdata part of an RR. 430 * @param rdata_len: length of the rr wire data. 431 * @param str: the string buffer to write to. 432 * If you pass NULL as the str, the return value of the function is 433 * the str_len you need for the entire packet. It does not include 434 * the 0 byte at the end. 435 * @param str_len: the size of the string buffer. If more is needed, it'll 436 * silently truncate the output to fit in the buffer. 437 * @param rrtype: rr type of the data 438 * @return the number of characters for this element, excluding zerobyte. 439 * Is larger or equal than str_len if output was truncated. 440 */ 441 int sldns_wire2str_rdata_buf(uint8_t* rdata, size_t rdata_len, char* str, 442 size_t str_len, uint16_t rrtype); 443 444 /** 445 * Convert wire RR type to a string, 'MX', 'TYPE12'. With user buffer. 446 * @param rrtype: the RR type in host order. 447 * @param str: the string to write to. 448 * @param len: length of str. 449 * @return the number of characters for this element, excluding zerobyte. 450 * Is larger or equal than str_len if output was truncated. 451 */ 452 int sldns_wire2str_type_buf(uint16_t rrtype, char* str, size_t len); 453 454 /** 455 * Convert wire RR class to a string, 'IN', 'CLASS12'. With user buffer. 456 * @param rrclass: the RR class in host order. 457 * @param str: the string to write to. 458 * @param len: length of str. 459 * @return the number of characters for this element, excluding zerobyte. 460 * Is larger or equal than str_len if output was truncated. 461 */ 462 int sldns_wire2str_class_buf(uint16_t rrclass, char* str, size_t len); 463 464 /** 465 * Convert wire RR rcode to a string, 'NOERROR', 'NXDOMAIN'. With user buffer. 466 * @param rcode: rcode as integer in host order 467 * @param str: the string to write to. 468 * @param len: length of str. 469 * @return the number of characters for this element, excluding zerobyte. 470 * Is larger or equal than str_len if output was truncated. 471 */ 472 int sldns_wire2str_rcode_buf(int rcode, char* str, size_t len); 473 474 /** 475 * Convert host format opcode to a string. 'QUERY', 'NOTIFY', 'UPDATE'. 476 * With user buffer. 477 * @param opcode: opcode as integer in host order 478 * @param str: the string to write to. 479 * @param len: length of str. 480 * @return the number of characters for this element, excluding zerobyte. 481 * Is larger or equal than str_len if output was truncated. 482 */ 483 int sldns_wire2str_opcode_buf(int opcode, char* str, size_t len); 484 485 /** 486 * Convert wire dname to a string, "example.com.". With user buffer. 487 * @param dname: the dname in uncompressed wireformat. 488 * @param dname_len: length of the dname. 489 * @param str: the string to write to. 490 * @param len: length of string. 491 * @return the number of characters for this element, excluding zerobyte. 492 * Is larger or equal than str_len if output was truncated. 493 */ 494 int sldns_wire2str_dname_buf(uint8_t* dname, size_t dname_len, char* str, 495 size_t len); 496 497 /** 498 * Convert wire SVCB to a string with user buffer. 499 * @param d: the SVCB data in uncompressed wireformat. 500 * @param dlen: length of the SVCB data. 501 * @param s: the string to write to. 502 * @param slen: length of string. 503 * @return the number of characters for this element, excluding zerobyte. 504 * Is larger or equal than str_len if output was truncated. 505 */ 506 int sldns_wire2str_svcparam_scan(uint8_t** d, size_t* dlen, char** s, 507 size_t* slen); 508 509 /** 510 * Scan wireformat rdf 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 * @param rdftype: the type of the rdata field, enum sldns_rdf_type. 517 * @param pkt: packet for decompression, if NULL no decompression. 518 * @param pktlen: length of packet buffer. 519 * @param comprloop: if pkt, bool detects compression loops. 520 * @return number of characters (except null) needed to print. 521 * Can return -1 on failure. 522 */ 523 int sldns_wire2str_rdf_scan(uint8_t** data, size_t* data_len, char** str, 524 size_t* str_len, int rdftype, uint8_t* pkt, size_t pktlen, 525 int* comprloop); 526 527 /** 528 * Scan wireformat int8 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. 536 */ 537 int sldns_wire2str_int8_scan(uint8_t** data, size_t* data_len, char** str, 538 size_t* str_len); 539 540 /** 541 * Scan wireformat int16 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. 549 */ 550 int sldns_wire2str_int16_scan(uint8_t** data, size_t* data_len, char** str, 551 size_t* str_len); 552 553 /** 554 * Scan wireformat int32 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. 562 */ 563 int sldns_wire2str_int32_scan(uint8_t** data, size_t* data_len, char** str, 564 size_t* str_len); 565 566 /** 567 * Scan wireformat period 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. 575 */ 576 int sldns_wire2str_period_scan(uint8_t** data, size_t* data_len, char** str, 577 size_t* str_len); 578 579 /** 580 * Scan wireformat tsigtime 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. 588 */ 589 int sldns_wire2str_tsigtime_scan(uint8_t** data, size_t* data_len, char** str, 590 size_t* str_len); 591 592 /** 593 * Scan wireformat ip4 A 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. 601 */ 602 int sldns_wire2str_a_scan(uint8_t** data, size_t* data_len, char** str, 603 size_t* str_len); 604 605 /** 606 * Scan wireformat ip6 AAAA 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. 614 */ 615 int sldns_wire2str_aaaa_scan(uint8_t** data, size_t* data_len, char** str, 616 size_t* str_len); 617 618 /** 619 * Scan wireformat str 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. 627 */ 628 int sldns_wire2str_str_scan(uint8_t** data, size_t* data_len, char** str, 629 size_t* str_len); 630 631 /** 632 * Scan wireformat apl 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. 640 */ 641 int sldns_wire2str_apl_scan(uint8_t** data, size_t* data_len, char** str, 642 size_t* str_len); 643 644 /** 645 * Scan wireformat b32_ext 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. 653 */ 654 int sldns_wire2str_b32_ext_scan(uint8_t** data, size_t* data_len, char** str, 655 size_t* str_len); 656 657 /** 658 * Scan wireformat b64 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. 666 */ 667 int sldns_wire2str_b64_scan(uint8_t** data, size_t* data_len, char** str, 668 size_t* str_len); 669 670 /** 671 * Scan wireformat hex 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. 679 */ 680 int sldns_wire2str_hex_scan(uint8_t** data, size_t* data_len, char** str, 681 size_t* str_len); 682 683 /** 684 * Scan wireformat nsec bitmap 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. 692 */ 693 int sldns_wire2str_nsec_scan(uint8_t** data, size_t* data_len, char** str, 694 size_t* str_len); 695 696 /** 697 * Scan wireformat nsec3_salt 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. 705 */ 706 int sldns_wire2str_nsec3_salt_scan(uint8_t** data, size_t* data_len, char** str, 707 size_t* str_len); 708 709 /** 710 * Scan wireformat cert_alg 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. 718 */ 719 int sldns_wire2str_cert_alg_scan(uint8_t** data, size_t* data_len, char** str, 720 size_t* str_len); 721 722 /** 723 * Scan wireformat alg 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. 731 */ 732 int sldns_wire2str_alg_scan(uint8_t** data, size_t* data_len, char** str, 733 size_t* str_len); 734 735 /** 736 * Scan wireformat type unknown 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. 744 */ 745 int sldns_wire2str_unknown_scan(uint8_t** data, size_t* data_len, char** str, 746 size_t* str_len); 747 748 /** 749 * Scan wireformat time 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. 757 */ 758 int sldns_wire2str_time_scan(uint8_t** data, size_t* data_len, char** str, 759 size_t* str_len); 760 761 /** 762 * Scan wireformat LOC 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. 770 */ 771 int sldns_wire2str_loc_scan(uint8_t** data, size_t* data_len, char** str, 772 size_t* str_len); 773 774 /** 775 * Scan wireformat WKS 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. 783 */ 784 int sldns_wire2str_wks_scan(uint8_t** data, size_t* data_len, char** str, 785 size_t* str_len); 786 787 /** 788 * Scan wireformat NSAP 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 * @return number of characters (except null) needed to print. 795 * Can return -1 on failure. 796 */ 797 int sldns_wire2str_nsap_scan(uint8_t** data, size_t* data_len, char** str, 798 size_t* str_len); 799 800 /** 801 * Scan wireformat ATMA field to string, with user buffers. 802 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 803 * @param data: wireformat data. 804 * @param data_len: length of data buffer. 805 * @param str: string buffer. 806 * @param str_len: length of string buffer. 807 * @return number of characters (except null) needed to print. 808 * Can return -1 on failure. 809 */ 810 int sldns_wire2str_atma_scan(uint8_t** data, size_t* data_len, char** str, 811 size_t* str_len); 812 813 /** 814 * Scan wireformat IPSECKEY field to string, with user buffers. 815 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 816 * @param data: wireformat data. 817 * @param data_len: length of data buffer. 818 * @param str: string buffer. 819 * @param str_len: length of string buffer. 820 * @param pkt: packet for decompression, if NULL no decompression. 821 * @param pktlen: length of packet buffer. 822 * @param comprloop: if pkt, bool detects compression loops. 823 * @return number of characters (except null) needed to print. 824 * Can return -1 on failure. 825 */ 826 int sldns_wire2str_ipseckey_scan(uint8_t** data, size_t* data_len, char** str, 827 size_t* str_len, uint8_t* pkt, size_t pktlen, int* comprloop); 828 829 /** 830 * Scan wireformat HIP (algo, HIT, pubkey) field to string, with user buffers. 831 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 832 * @param data: wireformat data. 833 * @param data_len: length of data buffer. 834 * @param str: string buffer. 835 * @param str_len: length of string buffer. 836 * @return number of characters (except null) needed to print. 837 * Can return -1 on failure. 838 */ 839 int sldns_wire2str_hip_scan(uint8_t** data, size_t* data_len, char** str, 840 size_t* str_len); 841 842 /** 843 * Scan wireformat int16_data field to string, with user buffers. 844 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 845 * @param data: wireformat data. 846 * @param data_len: length of data buffer. 847 * @param str: string buffer. 848 * @param str_len: length of string buffer. 849 * @return number of characters (except null) needed to print. 850 * Can return -1 on failure. 851 */ 852 int sldns_wire2str_int16_data_scan(uint8_t** data, size_t* data_len, char** str, 853 size_t* str_len); 854 855 /** 856 * Scan wireformat tsigerror field to string, with user buffers. 857 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 858 * @param data: wireformat data. 859 * @param data_len: length of data buffer. 860 * @param str: string buffer. 861 * @param str_len: length of string buffer. 862 * @return number of characters (except null) needed to print. 863 * Can return -1 on failure. 864 */ 865 int sldns_wire2str_tsigerror_scan(uint8_t** data, size_t* data_len, char** str, 866 size_t* str_len); 867 868 /** 869 * Scan wireformat nsec3_next_owner field to string, with user buffers. 870 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 871 * @param data: wireformat data. 872 * @param data_len: length of data buffer. 873 * @param str: string buffer. 874 * @param str_len: length of string buffer. 875 * @return number of characters (except null) needed to print. 876 * Can return -1 on failure. 877 */ 878 int sldns_wire2str_nsec3_next_owner_scan(uint8_t** data, size_t* data_len, 879 char** str, size_t* str_len); 880 881 /** 882 * Scan wireformat ILNP64 field to string, with user buffers. 883 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 884 * @param data: wireformat data. 885 * @param data_len: length of data buffer. 886 * @param str: string buffer. 887 * @param str_len: length of string buffer. 888 * @return number of characters (except null) needed to print. 889 * Can return -1 on failure. 890 */ 891 int sldns_wire2str_ilnp64_scan(uint8_t** data, size_t* data_len, char** str, 892 size_t* str_len); 893 894 /** 895 * Scan wireformat EUI48 field to string, with user buffers. 896 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 897 * @param data: wireformat data. 898 * @param data_len: length of data buffer. 899 * @param str: string buffer. 900 * @param str_len: length of string buffer. 901 * @return number of characters (except null) needed to print. 902 * Can return -1 on failure. 903 */ 904 int sldns_wire2str_eui48_scan(uint8_t** data, size_t* data_len, char** str, 905 size_t* str_len); 906 907 /** 908 * Scan wireformat EUI64 field to string, with user buffers. 909 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 910 * @param data: wireformat data. 911 * @param data_len: length of data buffer. 912 * @param str: string buffer. 913 * @param str_len: length of string buffer. 914 * @return number of characters (except null) needed to print. 915 * Can return -1 on failure. 916 */ 917 int sldns_wire2str_eui64_scan(uint8_t** data, size_t* data_len, char** str, 918 size_t* str_len); 919 920 /** 921 * Scan wireformat TAG field to string, with user buffers. 922 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 923 * @param data: wireformat data. 924 * @param data_len: length of data buffer. 925 * @param str: string buffer. 926 * @param str_len: length of string buffer. 927 * @return number of characters (except null) needed to print. 928 * Can return -1 on failure. 929 */ 930 int sldns_wire2str_tag_scan(uint8_t** data, size_t* data_len, char** str, 931 size_t* str_len); 932 933 /** 934 * Scan wireformat long_str field to string, with user buffers. 935 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 936 * @param data: wireformat data. 937 * @param data_len: length of data buffer. 938 * @param str: string buffer. 939 * @param str_len: length of string buffer. 940 * @return number of characters (except null) needed to print. 941 * Can return -1 on failure. 942 */ 943 int sldns_wire2str_long_str_scan(uint8_t** data, size_t* data_len, char** str, 944 size_t* str_len); 945 946 /** 947 * Print EDNS LLQ option data to string. User buffers, moves string pointers. 948 * @param str: string buffer. 949 * @param str_len: length of string buffer. 950 * @param option_data: buffer with EDNS option code data. 951 * @param option_len: length of the data for this option. 952 * @return number of characters (except null) needed to print. 953 */ 954 int sldns_wire2str_edns_llq_print(char** str, size_t* str_len, 955 uint8_t* option_data, size_t option_len); 956 957 /** 958 * Print EDNS UL option data to string. User buffers, moves string pointers. 959 * @param str: string buffer. 960 * @param str_len: length of string buffer. 961 * @param option_data: buffer with EDNS option code data. 962 * @param option_len: length of the data for this option. 963 * @return number of characters (except null) needed to print. 964 */ 965 int sldns_wire2str_edns_ul_print(char** str, size_t* str_len, 966 uint8_t* option_data, size_t option_len); 967 968 /** 969 * Print EDNS NSID option data to string. User buffers, moves string pointers. 970 * @param str: string buffer. 971 * @param str_len: length of string buffer. 972 * @param option_data: buffer with EDNS option code data. 973 * @param option_len: length of the data for this option. 974 * @return number of characters (except null) needed to print. 975 */ 976 int sldns_wire2str_edns_nsid_print(char** str, size_t* str_len, 977 uint8_t* option_data, size_t option_len); 978 979 /** 980 * Print EDNS DAU option data to string. User buffers, moves string pointers. 981 * @param str: string buffer. 982 * @param str_len: length of string buffer. 983 * @param option_data: buffer with EDNS option code data. 984 * @param option_len: length of the data for this option. 985 * @return number of characters (except null) needed to print. 986 */ 987 int sldns_wire2str_edns_dau_print(char** str, size_t* str_len, 988 uint8_t* option_data, size_t option_len); 989 990 /** 991 * Print EDNS DHU option data to string. User buffers, moves string pointers. 992 * @param str: string buffer. 993 * @param str_len: length of string buffer. 994 * @param option_data: buffer with EDNS option code data. 995 * @param option_len: length of the data for this option. 996 * @return number of characters (except null) needed to print. 997 */ 998 int sldns_wire2str_edns_dhu_print(char** str, size_t* str_len, 999 uint8_t* option_data, size_t option_len); 1000 1001 /** 1002 * Print EDNS N3U option data to string. User buffers, moves string pointers. 1003 * @param str: string buffer. 1004 * @param str_len: length of string buffer. 1005 * @param option_data: buffer with EDNS option code data. 1006 * @param option_len: length of the data for this option. 1007 * @return number of characters (except null) needed to print. 1008 */ 1009 int sldns_wire2str_edns_n3u_print(char** str, size_t* str_len, 1010 uint8_t* option_data, size_t option_len); 1011 1012 /** 1013 * Print EDNS SUBNET option data to string. User buffers, moves string pointers. 1014 * @param str: string buffer. 1015 * @param str_len: length of string buffer. 1016 * @param option_data: buffer with EDNS option code data. 1017 * @param option_len: length of the data for this option. 1018 * @return number of characters (except null) needed to print. 1019 */ 1020 int sldns_wire2str_edns_subnet_print(char** str, size_t* str_len, 1021 uint8_t* option_data, size_t option_len); 1022 1023 /** 1024 * Print an EDNS option as OPT: VALUE. User buffers, moves string pointers. 1025 * @param str: string buffer. 1026 * @param str_len: length of string buffer. 1027 * @param option_code: host format EDNS option code. 1028 * @param option_data: buffer with EDNS option code data. 1029 * @param option_len: length of the data for this option. 1030 * @return number of characters (except null) needed to print. 1031 */ 1032 int sldns_wire2str_edns_option_print(char** str, size_t* str_len, 1033 uint16_t option_code, uint8_t* option_data, size_t option_len); 1034 1035 /** 1036 * Scan wireformat EDNS OPT to string, with user buffers. 1037 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 1038 * @param data: wireformat data. 1039 * @param data_len: length of data buffer. 1040 * @param str: string buffer. 1041 * @param str_len: length of string buffer. 1042 * @param pkt: packet with header and other info (may be NULL) 1043 * @param pktlen: length of packet buffer. 1044 * @return number of characters (except null) needed to print. 1045 */ 1046 int sldns_wire2str_edns_scan(uint8_t** data, size_t* data_len, char** str, 1047 size_t* str_len, uint8_t* pkt, size_t pktlen); 1048 1049 #ifdef __cplusplus 1050 } 1051 #endif 1052 1053 #endif /* LDNS_WIRE2STR_H */ 1054