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 * 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. 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 * Scan wireformat rdf field to string, with user buffers. 499 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 500 * @param data: wireformat data. 501 * @param data_len: length of data buffer. 502 * @param str: string buffer. 503 * @param str_len: length of string buffer. 504 * @param rdftype: the type of the rdata field, enum sldns_rdf_type. 505 * @param pkt: packet for decompression, if NULL no decompression. 506 * @param pktlen: length of packet buffer. 507 * @param comprloop: if pkt, bool detects compression loops. 508 * @return number of characters (except null) needed to print. 509 * Can return -1 on failure. 510 */ 511 int sldns_wire2str_rdf_scan(uint8_t** data, size_t* data_len, char** str, 512 size_t* str_len, int rdftype, uint8_t* pkt, size_t pktlen, 513 int* comprloop); 514 515 /** 516 * Scan wireformat int8 field to string, with user buffers. 517 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 518 * @param data: wireformat data. 519 * @param data_len: length of data buffer. 520 * @param str: string buffer. 521 * @param str_len: length of string buffer. 522 * @return number of characters (except null) needed to print. 523 * Can return -1 on failure. 524 */ 525 int sldns_wire2str_int8_scan(uint8_t** data, size_t* data_len, char** str, 526 size_t* str_len); 527 528 /** 529 * Scan wireformat int16 field to string, with user buffers. 530 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 531 * @param data: wireformat data. 532 * @param data_len: length of data buffer. 533 * @param str: string buffer. 534 * @param str_len: length of string buffer. 535 * @return number of characters (except null) needed to print. 536 * Can return -1 on failure. 537 */ 538 int sldns_wire2str_int16_scan(uint8_t** data, size_t* data_len, char** str, 539 size_t* str_len); 540 541 /** 542 * Scan wireformat int32 field to string, with user buffers. 543 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 544 * @param data: wireformat data. 545 * @param data_len: length of data buffer. 546 * @param str: string buffer. 547 * @param str_len: length of string buffer. 548 * @return number of characters (except null) needed to print. 549 * Can return -1 on failure. 550 */ 551 int sldns_wire2str_int32_scan(uint8_t** data, size_t* data_len, char** str, 552 size_t* str_len); 553 554 /** 555 * Scan wireformat period field to string, with user buffers. 556 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 557 * @param data: wireformat data. 558 * @param data_len: length of data buffer. 559 * @param str: string buffer. 560 * @param str_len: length of string buffer. 561 * @return number of characters (except null) needed to print. 562 * Can return -1 on failure. 563 */ 564 int sldns_wire2str_period_scan(uint8_t** data, size_t* data_len, char** str, 565 size_t* str_len); 566 567 /** 568 * Scan wireformat tsigtime field to string, with user buffers. 569 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 570 * @param data: wireformat data. 571 * @param data_len: length of data buffer. 572 * @param str: string buffer. 573 * @param str_len: length of string buffer. 574 * @return number of characters (except null) needed to print. 575 * Can return -1 on failure. 576 */ 577 int sldns_wire2str_tsigtime_scan(uint8_t** data, size_t* data_len, char** str, 578 size_t* str_len); 579 580 /** 581 * Scan wireformat ip4 A field to string, with user buffers. 582 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 583 * @param data: wireformat data. 584 * @param data_len: length of data buffer. 585 * @param str: string buffer. 586 * @param str_len: length of string buffer. 587 * @return number of characters (except null) needed to print. 588 * Can return -1 on failure. 589 */ 590 int sldns_wire2str_a_scan(uint8_t** data, size_t* data_len, char** str, 591 size_t* str_len); 592 593 /** 594 * Scan wireformat ip6 AAAA field to string, with user buffers. 595 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 596 * @param data: wireformat data. 597 * @param data_len: length of data buffer. 598 * @param str: string buffer. 599 * @param str_len: length of string buffer. 600 * @return number of characters (except null) needed to print. 601 * Can return -1 on failure. 602 */ 603 int sldns_wire2str_aaaa_scan(uint8_t** data, size_t* data_len, char** str, 604 size_t* str_len); 605 606 /** 607 * Scan wireformat str field to string, with user buffers. 608 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 609 * @param data: wireformat data. 610 * @param data_len: length of data buffer. 611 * @param str: string buffer. 612 * @param str_len: length of string buffer. 613 * @return number of characters (except null) needed to print. 614 * Can return -1 on failure. 615 */ 616 int sldns_wire2str_str_scan(uint8_t** data, size_t* data_len, char** str, 617 size_t* str_len); 618 619 /** 620 * Scan wireformat apl field to string, with user buffers. 621 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 622 * @param data: wireformat data. 623 * @param data_len: length of data buffer. 624 * @param str: string buffer. 625 * @param str_len: length of string buffer. 626 * @return number of characters (except null) needed to print. 627 * Can return -1 on failure. 628 */ 629 int sldns_wire2str_apl_scan(uint8_t** data, size_t* data_len, char** str, 630 size_t* str_len); 631 632 /** 633 * Scan wireformat b32_ext field to string, with user buffers. 634 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 635 * @param data: wireformat data. 636 * @param data_len: length of data buffer. 637 * @param str: string buffer. 638 * @param str_len: length of string buffer. 639 * @return number of characters (except null) needed to print. 640 * Can return -1 on failure. 641 */ 642 int sldns_wire2str_b32_ext_scan(uint8_t** data, size_t* data_len, char** str, 643 size_t* str_len); 644 645 /** 646 * Scan wireformat b64 field to string, with user buffers. 647 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 648 * @param data: wireformat data. 649 * @param data_len: length of data buffer. 650 * @param str: string buffer. 651 * @param str_len: length of string buffer. 652 * @return number of characters (except null) needed to print. 653 * Can return -1 on failure. 654 */ 655 int sldns_wire2str_b64_scan(uint8_t** data, size_t* data_len, char** str, 656 size_t* str_len); 657 658 /** 659 * Scan wireformat hex field to string, with user buffers. 660 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 661 * @param data: wireformat data. 662 * @param data_len: length of data buffer. 663 * @param str: string buffer. 664 * @param str_len: length of string buffer. 665 * @return number of characters (except null) needed to print. 666 * Can return -1 on failure. 667 */ 668 int sldns_wire2str_hex_scan(uint8_t** data, size_t* data_len, char** str, 669 size_t* str_len); 670 671 /** 672 * Scan wireformat nsec bitmap field to string, with user buffers. 673 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 674 * @param data: wireformat data. 675 * @param data_len: length of data buffer. 676 * @param str: string buffer. 677 * @param str_len: length of string buffer. 678 * @return number of characters (except null) needed to print. 679 * Can return -1 on failure. 680 */ 681 int sldns_wire2str_nsec_scan(uint8_t** data, size_t* data_len, char** str, 682 size_t* str_len); 683 684 /** 685 * Scan wireformat nsec3_salt field to string, with user buffers. 686 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 687 * @param data: wireformat data. 688 * @param data_len: length of data buffer. 689 * @param str: string buffer. 690 * @param str_len: length of string buffer. 691 * @return number of characters (except null) needed to print. 692 * Can return -1 on failure. 693 */ 694 int sldns_wire2str_nsec3_salt_scan(uint8_t** data, size_t* data_len, char** str, 695 size_t* str_len); 696 697 /** 698 * Scan wireformat cert_alg field to string, with user buffers. 699 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 700 * @param data: wireformat data. 701 * @param data_len: length of data buffer. 702 * @param str: string buffer. 703 * @param str_len: length of string buffer. 704 * @return number of characters (except null) needed to print. 705 * Can return -1 on failure. 706 */ 707 int sldns_wire2str_cert_alg_scan(uint8_t** data, size_t* data_len, char** str, 708 size_t* str_len); 709 710 /** 711 * Scan wireformat alg field to string, with user buffers. 712 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 713 * @param data: wireformat data. 714 * @param data_len: length of data buffer. 715 * @param str: string buffer. 716 * @param str_len: length of string buffer. 717 * @return number of characters (except null) needed to print. 718 * Can return -1 on failure. 719 */ 720 int sldns_wire2str_alg_scan(uint8_t** data, size_t* data_len, char** str, 721 size_t* str_len); 722 723 /** 724 * Scan wireformat type unknown field to string, with user buffers. 725 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 726 * @param data: wireformat data. 727 * @param data_len: length of data buffer. 728 * @param str: string buffer. 729 * @param str_len: length of string buffer. 730 * @return number of characters (except null) needed to print. 731 * Can return -1 on failure. 732 */ 733 int sldns_wire2str_unknown_scan(uint8_t** data, size_t* data_len, char** str, 734 size_t* str_len); 735 736 /** 737 * Scan wireformat time field to string, with user buffers. 738 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 739 * @param data: wireformat data. 740 * @param data_len: length of data buffer. 741 * @param str: string buffer. 742 * @param str_len: length of string buffer. 743 * @return number of characters (except null) needed to print. 744 * Can return -1 on failure. 745 */ 746 int sldns_wire2str_time_scan(uint8_t** data, size_t* data_len, char** str, 747 size_t* str_len); 748 749 /** 750 * Scan wireformat LOC field to string, with user buffers. 751 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 752 * @param data: wireformat data. 753 * @param data_len: length of data buffer. 754 * @param str: string buffer. 755 * @param str_len: length of string buffer. 756 * @return number of characters (except null) needed to print. 757 * Can return -1 on failure. 758 */ 759 int sldns_wire2str_loc_scan(uint8_t** data, size_t* data_len, char** str, 760 size_t* str_len); 761 762 /** 763 * Scan wireformat WKS field to string, with user buffers. 764 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 765 * @param data: wireformat data. 766 * @param data_len: length of data buffer. 767 * @param str: string buffer. 768 * @param str_len: length of string buffer. 769 * @return number of characters (except null) needed to print. 770 * Can return -1 on failure. 771 */ 772 int sldns_wire2str_wks_scan(uint8_t** data, size_t* data_len, char** str, 773 size_t* str_len); 774 775 /** 776 * Scan wireformat NSAP field to string, with user buffers. 777 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 778 * @param data: wireformat data. 779 * @param data_len: length of data buffer. 780 * @param str: string buffer. 781 * @param str_len: length of string buffer. 782 * @return number of characters (except null) needed to print. 783 * Can return -1 on failure. 784 */ 785 int sldns_wire2str_nsap_scan(uint8_t** data, size_t* data_len, char** str, 786 size_t* str_len); 787 788 /** 789 * Scan wireformat ATMA field to string, with user buffers. 790 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 791 * @param data: wireformat data. 792 * @param data_len: length of data buffer. 793 * @param str: string buffer. 794 * @param str_len: length of string buffer. 795 * @return number of characters (except null) needed to print. 796 * Can return -1 on failure. 797 */ 798 int sldns_wire2str_atma_scan(uint8_t** data, size_t* data_len, char** str, 799 size_t* str_len); 800 801 /** 802 * Scan wireformat IPSECKEY field to string, with user buffers. 803 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 804 * @param data: wireformat data. 805 * @param data_len: length of data buffer. 806 * @param str: string buffer. 807 * @param str_len: length of string buffer. 808 * @param pkt: packet for decompression, if NULL no decompression. 809 * @param pktlen: length of packet buffer. 810 * @param comprloop: if pkt, bool detects compression loops. 811 * @return number of characters (except null) needed to print. 812 * Can return -1 on failure. 813 */ 814 int sldns_wire2str_ipseckey_scan(uint8_t** data, size_t* data_len, char** str, 815 size_t* str_len, uint8_t* pkt, size_t pktlen, int* comprloop); 816 817 /** 818 * Scan wireformat HIP (algo, HIT, pubkey) field to string, with user buffers. 819 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 820 * @param data: wireformat data. 821 * @param data_len: length of data buffer. 822 * @param str: string buffer. 823 * @param str_len: length of string buffer. 824 * @return number of characters (except null) needed to print. 825 * Can return -1 on failure. 826 */ 827 int sldns_wire2str_hip_scan(uint8_t** data, size_t* data_len, char** str, 828 size_t* str_len); 829 830 /** 831 * Scan wireformat int16_data field to string, with user buffers. 832 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 833 * @param data: wireformat data. 834 * @param data_len: length of data buffer. 835 * @param str: string buffer. 836 * @param str_len: length of string buffer. 837 * @return number of characters (except null) needed to print. 838 * Can return -1 on failure. 839 */ 840 int sldns_wire2str_int16_data_scan(uint8_t** data, size_t* data_len, char** str, 841 size_t* str_len); 842 843 /** 844 * Scan wireformat tsigerror field to string, with user buffers. 845 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 846 * @param data: wireformat data. 847 * @param data_len: length of data buffer. 848 * @param str: string buffer. 849 * @param str_len: length of string buffer. 850 * @return number of characters (except null) needed to print. 851 * Can return -1 on failure. 852 */ 853 int sldns_wire2str_tsigerror_scan(uint8_t** data, size_t* data_len, char** str, 854 size_t* str_len); 855 856 /** 857 * Scan wireformat nsec3_next_owner field to string, with user buffers. 858 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 859 * @param data: wireformat data. 860 * @param data_len: length of data buffer. 861 * @param str: string buffer. 862 * @param str_len: length of string buffer. 863 * @return number of characters (except null) needed to print. 864 * Can return -1 on failure. 865 */ 866 int sldns_wire2str_nsec3_next_owner_scan(uint8_t** data, size_t* data_len, 867 char** str, size_t* str_len); 868 869 /** 870 * Scan wireformat ILNP64 field to string, with user buffers. 871 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 872 * @param data: wireformat data. 873 * @param data_len: length of data buffer. 874 * @param str: string buffer. 875 * @param str_len: length of string buffer. 876 * @return number of characters (except null) needed to print. 877 * Can return -1 on failure. 878 */ 879 int sldns_wire2str_ilnp64_scan(uint8_t** data, size_t* data_len, char** str, 880 size_t* str_len); 881 882 /** 883 * Scan wireformat EUI48 field to string, with user buffers. 884 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 885 * @param data: wireformat data. 886 * @param data_len: length of data buffer. 887 * @param str: string buffer. 888 * @param str_len: length of string buffer. 889 * @return number of characters (except null) needed to print. 890 * Can return -1 on failure. 891 */ 892 int sldns_wire2str_eui48_scan(uint8_t** data, size_t* data_len, char** str, 893 size_t* str_len); 894 895 /** 896 * Scan wireformat EUI64 field to string, with user buffers. 897 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 898 * @param data: wireformat data. 899 * @param data_len: length of data buffer. 900 * @param str: string buffer. 901 * @param str_len: length of string buffer. 902 * @return number of characters (except null) needed to print. 903 * Can return -1 on failure. 904 */ 905 int sldns_wire2str_eui64_scan(uint8_t** data, size_t* data_len, char** str, 906 size_t* str_len); 907 908 /** 909 * Scan wireformat TAG field to string, with user buffers. 910 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 911 * @param data: wireformat data. 912 * @param data_len: length of data buffer. 913 * @param str: string buffer. 914 * @param str_len: length of string buffer. 915 * @return number of characters (except null) needed to print. 916 * Can return -1 on failure. 917 */ 918 int sldns_wire2str_tag_scan(uint8_t** data, size_t* data_len, char** str, 919 size_t* str_len); 920 921 /** 922 * Scan wireformat long_str field to string, with user buffers. 923 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 924 * @param data: wireformat data. 925 * @param data_len: length of data buffer. 926 * @param str: string buffer. 927 * @param str_len: length of string buffer. 928 * @return number of characters (except null) needed to print. 929 * Can return -1 on failure. 930 */ 931 int sldns_wire2str_long_str_scan(uint8_t** data, size_t* data_len, char** str, 932 size_t* str_len); 933 934 /** 935 * Print EDNS LLQ option data to string. User buffers, moves string pointers. 936 * @param str: string buffer. 937 * @param str_len: length of string buffer. 938 * @param option_data: buffer with EDNS option code data. 939 * @param option_len: length of the data for this option. 940 * @return number of characters (except null) needed to print. 941 */ 942 int sldns_wire2str_edns_llq_print(char** str, size_t* str_len, 943 uint8_t* option_data, size_t option_len); 944 945 /** 946 * Print EDNS UL option data to string. User buffers, moves string pointers. 947 * @param str: string buffer. 948 * @param str_len: length of string buffer. 949 * @param option_data: buffer with EDNS option code data. 950 * @param option_len: length of the data for this option. 951 * @return number of characters (except null) needed to print. 952 */ 953 int sldns_wire2str_edns_ul_print(char** str, size_t* str_len, 954 uint8_t* option_data, size_t option_len); 955 956 /** 957 * Print EDNS NSID option data to string. User buffers, moves string pointers. 958 * @param str: string buffer. 959 * @param str_len: length of string buffer. 960 * @param option_data: buffer with EDNS option code data. 961 * @param option_len: length of the data for this option. 962 * @return number of characters (except null) needed to print. 963 */ 964 int sldns_wire2str_edns_nsid_print(char** str, size_t* str_len, 965 uint8_t* option_data, size_t option_len); 966 967 /** 968 * Print EDNS DAU option data to string. User buffers, moves string pointers. 969 * @param str: string buffer. 970 * @param str_len: length of string buffer. 971 * @param option_data: buffer with EDNS option code data. 972 * @param option_len: length of the data for this option. 973 * @return number of characters (except null) needed to print. 974 */ 975 int sldns_wire2str_edns_dau_print(char** str, size_t* str_len, 976 uint8_t* option_data, size_t option_len); 977 978 /** 979 * Print EDNS DHU option data to string. User buffers, moves string pointers. 980 * @param str: string buffer. 981 * @param str_len: length of string buffer. 982 * @param option_data: buffer with EDNS option code data. 983 * @param option_len: length of the data for this option. 984 * @return number of characters (except null) needed to print. 985 */ 986 int sldns_wire2str_edns_dhu_print(char** str, size_t* str_len, 987 uint8_t* option_data, size_t option_len); 988 989 /** 990 * Print EDNS N3U option data to string. User buffers, moves string pointers. 991 * @param str: string buffer. 992 * @param str_len: length of string buffer. 993 * @param option_data: buffer with EDNS option code data. 994 * @param option_len: length of the data for this option. 995 * @return number of characters (except null) needed to print. 996 */ 997 int sldns_wire2str_edns_n3u_print(char** str, size_t* str_len, 998 uint8_t* option_data, size_t option_len); 999 1000 /** 1001 * Print EDNS SUBNET option data to string. User buffers, moves string pointers. 1002 * @param str: string buffer. 1003 * @param str_len: length of string buffer. 1004 * @param option_data: buffer with EDNS option code data. 1005 * @param option_len: length of the data for this option. 1006 * @return number of characters (except null) needed to print. 1007 */ 1008 int sldns_wire2str_edns_subnet_print(char** str, size_t* str_len, 1009 uint8_t* option_data, size_t option_len); 1010 1011 /** 1012 * Print an EDNS option as OPT: VALUE. User buffers, moves string pointers. 1013 * @param str: string buffer. 1014 * @param str_len: length of string buffer. 1015 * @param option_code: host format EDNS option code. 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_option_print(char** str, size_t* str_len, 1021 uint16_t option_code, uint8_t* option_data, size_t option_len); 1022 1023 /** 1024 * Scan wireformat EDNS OPT to string, with user buffers. 1025 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 1026 * @param data: wireformat data. 1027 * @param data_len: length of data buffer. 1028 * @param str: string buffer. 1029 * @param str_len: length of string buffer. 1030 * @param pkt: packet with header and other info (may be NULL) 1031 * @param pktlen: length of packet buffer. 1032 * @return number of characters (except null) needed to print. 1033 */ 1034 int sldns_wire2str_edns_scan(uint8_t** data, size_t* data_len, char** str, 1035 size_t* str_len, uint8_t* pkt, size_t pktlen); 1036 1037 #ifdef __cplusplus 1038 } 1039 #endif 1040 1041 #endif /* LDNS_WIRE2STR_H */ 1042