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