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 * @return number of characters (except null) needed to print. 160 */ 161 int sldns_wire2str_rr_scan(uint8_t** data, size_t* data_len, char** str, 162 size_t* str_len, uint8_t* pkt, size_t pktlen); 163 164 /** 165 * Scan wireformat question rr to string, with user buffers. 166 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 167 * @param data: wireformat data. 168 * @param data_len: length of data buffer. 169 * @param str: string buffer. 170 * @param str_len: length of string buffer. 171 * @param pkt: packet for decompression, if NULL no decompression. 172 * @param pktlen: length of packet buffer. 173 * @return number of characters (except null) needed to print. 174 */ 175 int sldns_wire2str_rrquestion_scan(uint8_t** data, size_t* data_len, char** str, 176 size_t* str_len, uint8_t* pkt, size_t pktlen); 177 178 /** 179 * Scan wireformat RR to string in unknown RR format, with user buffers. 180 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 181 * @param data: wireformat data. 182 * @param data_len: length of data buffer. 183 * @param str: string buffer. 184 * @param str_len: length of string buffer. 185 * @param pkt: packet for decompression, if NULL no decompression. 186 * @param pktlen: length of packet buffer. 187 * @return number of characters (except null) needed to print. 188 */ 189 int sldns_wire2str_rr_unknown_scan(uint8_t** data, size_t* data_len, char** str, 190 size_t* str_len, uint8_t* pkt, size_t pktlen); 191 192 /** 193 * Print to string the RR-information comment in default format, 194 * with user buffers. Moves string along. 195 * @param str: string buffer. 196 * @param str_len: length of string buffer. 197 * @param rr: wireformat data. 198 * @param rrlen: length of data buffer. 199 * @param dname_off: offset in buffer behind owner dname, the compressed size 200 * of the owner name. 201 * @param rrtype: type of the RR, host format. 202 * @return number of characters (except null) needed to print. 203 */ 204 int sldns_wire2str_rr_comment_print(char** str, size_t* str_len, uint8_t* rr, 205 size_t rrlen, size_t dname_off, uint16_t rrtype); 206 207 /** 208 * Scan wireformat packet header to string, with user buffers. 209 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 210 * @param data: wireformat data. 211 * @param data_len: length of data buffer. 212 * @param str: string buffer. 213 * @param str_len: length of string buffer. 214 * @return number of characters (except null) needed to print. 215 */ 216 int sldns_wire2str_header_scan(uint8_t** data, size_t* data_len, char** str, 217 size_t* str_len); 218 219 /** 220 * Scan wireformat rdata to string, with user buffers. 221 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 222 * @param data: wireformat data. 223 * @param data_len: length of data buffer. The length of the rdata in the 224 * buffer. The rdatalen itself has already been scanned, the data 225 * points to the rdata after the rdatalen. 226 * @param str: string buffer. 227 * @param str_len: length of string buffer. 228 * @param rrtype: RR type of Rdata, host format. 229 * @param pkt: packet for decompression, if NULL no decompression. 230 * @param pktlen: length of packet buffer. 231 * @return number of characters (except null) needed to print. 232 */ 233 int sldns_wire2str_rdata_scan(uint8_t** data, size_t* data_len, char** str, 234 size_t* str_len, uint16_t rrtype, uint8_t* pkt, size_t pktlen); 235 236 /** 237 * Scan wireformat rdata to string in unknown format, with user buffers. 238 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 239 * @param data: wireformat data. 240 * @param data_len: length of data buffer, the length of the rdata in buffer. 241 * @param str: string buffer. 242 * @param str_len: length of string buffer. 243 * @return number of characters (except null) needed to print. 244 */ 245 int sldns_wire2str_rdata_unknown_scan(uint8_t** data, size_t* data_len, 246 char** str, size_t* str_len); 247 248 /** 249 * Scan wireformat domain name to string, with user buffers. 250 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 251 * @param data: wireformat data. 252 * @param data_len: length of data buffer. 253 * @param str: string buffer. 254 * @param str_len: length of string buffer. 255 * @param pkt: packet for decompression, if NULL no decompression. 256 * @param pktlen: length of packet buffer. 257 * @return number of characters (except null) needed to print. 258 */ 259 int sldns_wire2str_dname_scan(uint8_t** data, size_t* data_len, char** str, 260 size_t* str_len, uint8_t* pkt, size_t pktlen); 261 262 /** 263 * Scan wireformat rr type to string, with user buffers. 264 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 265 * @param data: wireformat data. 266 * @param data_len: length of data buffer. 267 * @param str: string buffer. 268 * @param str_len: length of string buffer. 269 * @return number of characters (except null) needed to print. 270 */ 271 int sldns_wire2str_type_scan(uint8_t** data, size_t* data_len, char** str, 272 size_t* str_len); 273 274 /** 275 * Scan wireformat rr class to string, with user buffers. 276 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 277 * @param data: wireformat data. 278 * @param data_len: length of data buffer. 279 * @param str: string buffer. 280 * @param str_len: length of string buffer. 281 * @return number of characters (except null) needed to print. 282 */ 283 int sldns_wire2str_class_scan(uint8_t** data, size_t* data_len, char** str, 284 size_t* str_len); 285 286 /** 287 * Scan wireformat rr ttl to string, with user buffers. 288 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 289 * @param data: wireformat data. 290 * @param data_len: length of data buffer. 291 * @param str: string buffer. 292 * @param str_len: length of string buffer. 293 * @return number of characters (except null) needed to print. 294 */ 295 int sldns_wire2str_ttl_scan(uint8_t** data, size_t* data_len, char** str, 296 size_t* str_len); 297 298 299 /** 300 * Print host format rr type to string. Moves string along, user buffers. 301 * @param str: string buffer. 302 * @param str_len: length of string buffer. 303 * @param rrtype: host format rr type. 304 * @return number of characters (except null) needed to print. 305 */ 306 int sldns_wire2str_type_print(char** str, size_t* str_len, uint16_t rrtype); 307 308 /** 309 * Print host format rr class to string. Moves string along, user buffers. 310 * @param str: string buffer. 311 * @param str_len: length of string buffer. 312 * @param rrclass: host format rr class. 313 * @return number of characters (except null) needed to print. 314 */ 315 int sldns_wire2str_class_print(char** str, size_t* str_len, uint16_t rrclass); 316 317 /** 318 * Print host format rcode to string. Moves string along, user buffers. 319 * @param str: string buffer. 320 * @param str_len: length of string buffer. 321 * @param rcode: host format rcode number. 322 * @return number of characters (except null) needed to print. 323 */ 324 int sldns_wire2str_rcode_print(char** str, size_t* str_len, int rcode); 325 326 /** 327 * Print host format opcode to string. Moves string along, user buffers. 328 * @param str: string buffer. 329 * @param str_len: length of string buffer. 330 * @param opcode: host format opcode number. 331 * @return number of characters (except null) needed to print. 332 */ 333 int sldns_wire2str_opcode_print(char** str, size_t* str_len, int opcode); 334 335 /** 336 * Print host format EDNS0 option to string. Moves string along, user buffers. 337 * @param str: string buffer. 338 * @param str_len: length of string buffer. 339 * @param opcode: host format option number. 340 * @return number of characters (except null) needed to print. 341 */ 342 int sldns_wire2str_edns_option_code_print(char** str, size_t* str_len, 343 uint16_t opcode); 344 345 /** 346 * Convert RR to string presentation format, on one line. User buffer. 347 * @param rr: wireformat RR data 348 * @param rr_len: length of the rr wire data. 349 * @param str: the string buffer to write to. 350 * If you pass NULL as the str, the return value of the function is 351 * the str_len you need for the entire packet. It does not include 352 * the 0 byte at the end. 353 * @param str_len: the size of the string buffer. If more is needed, it'll 354 * silently truncate the output to fit in the buffer. 355 * @return the number of characters for this element, excluding zerobyte. 356 * Is larger or equal than str_len if output was truncated. 357 */ 358 int sldns_wire2str_rr_buf(uint8_t* rr, size_t rr_len, char* str, 359 size_t str_len); 360 361 /** 362 * Convert question RR to string presentation format, on one line. User buffer. 363 * @param rr: wireformat RR data 364 * @param rr_len: length of the rr wire data. 365 * @param str: the string buffer to write to. 366 * If you pass NULL as the str, the return value of the function is 367 * the str_len you need for the entire packet. It does not include 368 * the 0 byte at the end. 369 * @param str_len: the size of the string buffer. If more is needed, it'll 370 * silently truncate the output to fit in the buffer. 371 * @return the number of characters for this element, excluding zerobyte. 372 * Is larger or equal than str_len if output was truncated. 373 */ 374 int sldns_wire2str_rrquestion_buf(uint8_t* rr, size_t rr_len, char* str, 375 size_t str_len); 376 377 /** 378 * 3597 printout of an RR in unknown rr format. 379 * There are more format and comment options available for printout 380 * with the function: TBD(TODO) 381 * @param rr: wireformat RR data 382 * @param rr_len: length of the rr wire data. 383 * @param str: the string buffer to write to. 384 * If you pass NULL as the str, the return value of the function is 385 * the str_len you need for the entire rr. It does not include 386 * the 0 byte at the end. 387 * @param str_len: the size of the string buffer. If more is needed, it'll 388 * silently truncate the output to fit in the buffer. 389 * @return the number of characters for this element, excluding zerobyte. 390 * Is larger or equal than str_len if output was truncated. 391 */ 392 int sldns_wire2str_rr_unknown_buf(uint8_t* rr, size_t rr_len, char* str, 393 size_t str_len); 394 395 /** 396 * This creates the comment to print after the RR. ; keytag=... , and other 397 * basic comments for RRs. 398 * There are more format and comment options available for printout 399 * with the function: TBD(TODO) 400 * @param rr: wireformat RR data 401 * @param rr_len: length of the rr wire data. 402 * @param dname_len: length of the dname in front of the RR. 403 * @param str: the string buffer to write to. 404 * If you pass NULL as the str, the return value of the function is 405 * the str_len you need for the entire comment. It does not include 406 * the 0 byte at the end. 407 * @param str_len: the size of the string buffer. If more is needed, it'll 408 * silently truncate the output to fit in the buffer. 409 * @return the number of characters for this element, excluding zerobyte. 410 * Is larger or equal than str_len if output was truncated. 411 */ 412 int sldns_wire2str_rr_comment_buf(uint8_t* rr, size_t rr_len, size_t dname_len, 413 char* str, size_t str_len); 414 415 /** 416 * Convert RDATA to string presentation format, on one line. User buffer. 417 * @param rdata: wireformat rdata part of an RR. 418 * @param rdata_len: length of the rr wire data. 419 * @param str: the string buffer to write to. 420 * If you pass NULL as the str, the return value of the function is 421 * the str_len you need for the entire packet. It does not include 422 * the 0 byte at the end. 423 * @param str_len: the size of the string buffer. If more is needed, it'll 424 * silently truncate the output to fit in the buffer. 425 * @param rrtype: rr type of the data 426 * @return the number of characters for this element, excluding zerobyte. 427 * Is larger or equal than str_len if output was truncated. 428 */ 429 int sldns_wire2str_rdata_buf(uint8_t* rdata, size_t rdata_len, char* str, 430 size_t str_len, uint16_t rrtype); 431 432 /** 433 * Convert wire RR type to a string, 'MX', 'TYPE12'. With user buffer. 434 * @param rrtype: the RR type in host order. 435 * @param str: the string to write to. 436 * @param len: length of str. 437 * @return the number of characters for this element, excluding zerobyte. 438 * Is larger or equal than str_len if output was truncated. 439 */ 440 int sldns_wire2str_type_buf(uint16_t rrtype, char* str, size_t len); 441 442 /** 443 * Convert wire RR class to a string, 'IN', 'CLASS12'. With user buffer. 444 * @param rrclass: the RR class in host order. 445 * @param str: the string to write to. 446 * @param len: length of str. 447 * @return the number of characters for this element, excluding zerobyte. 448 * Is larger or equal than str_len if output was truncated. 449 */ 450 int sldns_wire2str_class_buf(uint16_t rrclass, char* str, size_t len); 451 452 /** 453 * Convert wire RR rcode to a string, 'NOERROR', 'NXDOMAIN'. With user buffer. 454 * @param rcode: rcode as integer in host order 455 * @param str: the string to write to. 456 * @param len: length of str. 457 * @return the number of characters for this element, excluding zerobyte. 458 * Is larger or equal than str_len if output was truncated. 459 */ 460 int sldns_wire2str_rcode_buf(int rcode, char* str, size_t len); 461 462 /** 463 * Convert host format opcode to a string. 'QUERY', 'NOTIFY', 'UPDATE'. 464 * With user buffer. 465 * @param opcode: opcode as integer in host order 466 * @param str: the string to write to. 467 * @param len: length of str. 468 * @return the number of characters for this element, excluding zerobyte. 469 * Is larger or equal than str_len if output was truncated. 470 */ 471 int sldns_wire2str_opcode_buf(int opcode, char* str, size_t len); 472 473 /** 474 * Convert wire dname to a string, "example.com.". With user buffer. 475 * @param dname: the dname in uncompressed wireformat. 476 * @param dname_len: length of the dname. 477 * @param str: the string to write to. 478 * @param len: length of string. 479 * @return the number of characters for this element, excluding zerobyte. 480 * Is larger or equal than str_len if output was truncated. 481 */ 482 int sldns_wire2str_dname_buf(uint8_t* dname, size_t dname_len, char* str, 483 size_t len); 484 485 /** 486 * Scan wireformat rdf field to string, with user buffers. 487 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 488 * @param data: wireformat data. 489 * @param data_len: length of data buffer. 490 * @param str: string buffer. 491 * @param str_len: length of string buffer. 492 * @param rdftype: the type of the rdata field, enum sldns_rdf_type. 493 * @param pkt: packet for decompression, if NULL no decompression. 494 * @param pktlen: length of packet buffer. 495 * @return number of characters (except null) needed to print. 496 * Can return -1 on failure. 497 */ 498 int sldns_wire2str_rdf_scan(uint8_t** data, size_t* data_len, char** str, 499 size_t* str_len, int rdftype, uint8_t* pkt, size_t pktlen); 500 501 /** 502 * Scan wireformat int8 field to string, with user buffers. 503 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 504 * @param data: wireformat data. 505 * @param data_len: length of data buffer. 506 * @param str: string buffer. 507 * @param str_len: length of string buffer. 508 * @return number of characters (except null) needed to print. 509 * Can return -1 on failure. 510 */ 511 int sldns_wire2str_int8_scan(uint8_t** data, size_t* data_len, char** str, 512 size_t* str_len); 513 514 /** 515 * Scan wireformat int16 field to string, with user buffers. 516 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 517 * @param data: wireformat data. 518 * @param data_len: length of data buffer. 519 * @param str: string buffer. 520 * @param str_len: length of string buffer. 521 * @return number of characters (except null) needed to print. 522 * Can return -1 on failure. 523 */ 524 int sldns_wire2str_int16_scan(uint8_t** data, size_t* data_len, char** str, 525 size_t* str_len); 526 527 /** 528 * Scan wireformat int32 field to string, with user buffers. 529 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 530 * @param data: wireformat data. 531 * @param data_len: length of data buffer. 532 * @param str: string buffer. 533 * @param str_len: length of string buffer. 534 * @return number of characters (except null) needed to print. 535 * Can return -1 on failure. 536 */ 537 int sldns_wire2str_int32_scan(uint8_t** data, size_t* data_len, char** str, 538 size_t* str_len); 539 540 /** 541 * Scan wireformat period field to string, with user buffers. 542 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 543 * @param data: wireformat data. 544 * @param data_len: length of data buffer. 545 * @param str: string buffer. 546 * @param str_len: length of string buffer. 547 * @return number of characters (except null) needed to print. 548 * Can return -1 on failure. 549 */ 550 int sldns_wire2str_period_scan(uint8_t** data, size_t* data_len, char** str, 551 size_t* str_len); 552 553 /** 554 * Scan wireformat tsigtime field to string, with user buffers. 555 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 556 * @param data: wireformat data. 557 * @param data_len: length of data buffer. 558 * @param str: string buffer. 559 * @param str_len: length of string buffer. 560 * @return number of characters (except null) needed to print. 561 * Can return -1 on failure. 562 */ 563 int sldns_wire2str_tsigtime_scan(uint8_t** data, size_t* data_len, char** str, 564 size_t* str_len); 565 566 /** 567 * Scan wireformat ip4 A field to string, with user buffers. 568 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 569 * @param data: wireformat data. 570 * @param data_len: length of data buffer. 571 * @param str: string buffer. 572 * @param str_len: length of string buffer. 573 * @return number of characters (except null) needed to print. 574 * Can return -1 on failure. 575 */ 576 int sldns_wire2str_a_scan(uint8_t** data, size_t* data_len, char** str, 577 size_t* str_len); 578 579 /** 580 * Scan wireformat ip6 AAAA field to string, with user buffers. 581 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 582 * @param data: wireformat data. 583 * @param data_len: length of data buffer. 584 * @param str: string buffer. 585 * @param str_len: length of string buffer. 586 * @return number of characters (except null) needed to print. 587 * Can return -1 on failure. 588 */ 589 int sldns_wire2str_aaaa_scan(uint8_t** data, size_t* data_len, char** str, 590 size_t* str_len); 591 592 /** 593 * Scan wireformat str field to string, with user buffers. 594 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 595 * @param data: wireformat data. 596 * @param data_len: length of data buffer. 597 * @param str: string buffer. 598 * @param str_len: length of string buffer. 599 * @return number of characters (except null) needed to print. 600 * Can return -1 on failure. 601 */ 602 int sldns_wire2str_str_scan(uint8_t** data, size_t* data_len, char** str, 603 size_t* str_len); 604 605 /** 606 * Scan wireformat apl field to string, with user buffers. 607 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 608 * @param data: wireformat data. 609 * @param data_len: length of data buffer. 610 * @param str: string buffer. 611 * @param str_len: length of string buffer. 612 * @return number of characters (except null) needed to print. 613 * Can return -1 on failure. 614 */ 615 int sldns_wire2str_apl_scan(uint8_t** data, size_t* data_len, char** str, 616 size_t* str_len); 617 618 /** 619 * Scan wireformat b32_ext field to string, with user buffers. 620 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 621 * @param data: wireformat data. 622 * @param data_len: length of data buffer. 623 * @param str: string buffer. 624 * @param str_len: length of string buffer. 625 * @return number of characters (except null) needed to print. 626 * Can return -1 on failure. 627 */ 628 int sldns_wire2str_b32_ext_scan(uint8_t** data, size_t* data_len, char** str, 629 size_t* str_len); 630 631 /** 632 * Scan wireformat b64 field to string, with user buffers. 633 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 634 * @param data: wireformat data. 635 * @param data_len: length of data buffer. 636 * @param str: string buffer. 637 * @param str_len: length of string buffer. 638 * @return number of characters (except null) needed to print. 639 * Can return -1 on failure. 640 */ 641 int sldns_wire2str_b64_scan(uint8_t** data, size_t* data_len, char** str, 642 size_t* str_len); 643 644 /** 645 * Scan wireformat hex field to string, with user buffers. 646 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 647 * @param data: wireformat data. 648 * @param data_len: length of data buffer. 649 * @param str: string buffer. 650 * @param str_len: length of string buffer. 651 * @return number of characters (except null) needed to print. 652 * Can return -1 on failure. 653 */ 654 int sldns_wire2str_hex_scan(uint8_t** data, size_t* data_len, char** str, 655 size_t* str_len); 656 657 /** 658 * Scan wireformat nsec bitmap field to string, with user buffers. 659 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 660 * @param data: wireformat data. 661 * @param data_len: length of data buffer. 662 * @param str: string buffer. 663 * @param str_len: length of string buffer. 664 * @return number of characters (except null) needed to print. 665 * Can return -1 on failure. 666 */ 667 int sldns_wire2str_nsec_scan(uint8_t** data, size_t* data_len, char** str, 668 size_t* str_len); 669 670 /** 671 * Scan wireformat nsec3_salt field to string, with user buffers. 672 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 673 * @param data: wireformat data. 674 * @param data_len: length of data buffer. 675 * @param str: string buffer. 676 * @param str_len: length of string buffer. 677 * @return number of characters (except null) needed to print. 678 * Can return -1 on failure. 679 */ 680 int sldns_wire2str_nsec3_salt_scan(uint8_t** data, size_t* data_len, char** str, 681 size_t* str_len); 682 683 /** 684 * Scan wireformat cert_alg field to string, with user buffers. 685 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 686 * @param data: wireformat data. 687 * @param data_len: length of data buffer. 688 * @param str: string buffer. 689 * @param str_len: length of string buffer. 690 * @return number of characters (except null) needed to print. 691 * Can return -1 on failure. 692 */ 693 int sldns_wire2str_cert_alg_scan(uint8_t** data, size_t* data_len, char** str, 694 size_t* str_len); 695 696 /** 697 * Scan wireformat alg field to string, with user buffers. 698 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 699 * @param data: wireformat data. 700 * @param data_len: length of data buffer. 701 * @param str: string buffer. 702 * @param str_len: length of string buffer. 703 * @return number of characters (except null) needed to print. 704 * Can return -1 on failure. 705 */ 706 int sldns_wire2str_alg_scan(uint8_t** data, size_t* data_len, char** str, 707 size_t* str_len); 708 709 /** 710 * Scan wireformat type unknown field to string, with user buffers. 711 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 712 * @param data: wireformat data. 713 * @param data_len: length of data buffer. 714 * @param str: string buffer. 715 * @param str_len: length of string buffer. 716 * @return number of characters (except null) needed to print. 717 * Can return -1 on failure. 718 */ 719 int sldns_wire2str_unknown_scan(uint8_t** data, size_t* data_len, char** str, 720 size_t* str_len); 721 722 /** 723 * Scan wireformat time field to string, with user buffers. 724 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 725 * @param data: wireformat data. 726 * @param data_len: length of data buffer. 727 * @param str: string buffer. 728 * @param str_len: length of string buffer. 729 * @return number of characters (except null) needed to print. 730 * Can return -1 on failure. 731 */ 732 int sldns_wire2str_time_scan(uint8_t** data, size_t* data_len, char** str, 733 size_t* str_len); 734 735 /** 736 * Scan wireformat LOC field to string, with user buffers. 737 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 738 * @param data: wireformat data. 739 * @param data_len: length of data buffer. 740 * @param str: string buffer. 741 * @param str_len: length of string buffer. 742 * @return number of characters (except null) needed to print. 743 * Can return -1 on failure. 744 */ 745 int sldns_wire2str_loc_scan(uint8_t** data, size_t* data_len, char** str, 746 size_t* str_len); 747 748 /** 749 * Scan wireformat WKS field to string, with user buffers. 750 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 751 * @param data: wireformat data. 752 * @param data_len: length of data buffer. 753 * @param str: string buffer. 754 * @param str_len: length of string buffer. 755 * @return number of characters (except null) needed to print. 756 * Can return -1 on failure. 757 */ 758 int sldns_wire2str_wks_scan(uint8_t** data, size_t* data_len, char** str, 759 size_t* str_len); 760 761 /** 762 * Scan wireformat NSAP field to string, with user buffers. 763 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 764 * @param data: wireformat data. 765 * @param data_len: length of data buffer. 766 * @param str: string buffer. 767 * @param str_len: length of string buffer. 768 * @return number of characters (except null) needed to print. 769 * Can return -1 on failure. 770 */ 771 int sldns_wire2str_nsap_scan(uint8_t** data, size_t* data_len, char** str, 772 size_t* str_len); 773 774 /** 775 * Scan wireformat ATMA field to string, with user buffers. 776 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 777 * @param data: wireformat data. 778 * @param data_len: length of data buffer. 779 * @param str: string buffer. 780 * @param str_len: length of string buffer. 781 * @return number of characters (except null) needed to print. 782 * Can return -1 on failure. 783 */ 784 int sldns_wire2str_atma_scan(uint8_t** data, size_t* data_len, char** str, 785 size_t* str_len); 786 787 /** 788 * Scan wireformat IPSECKEY field to string, with user buffers. 789 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 790 * @param data: wireformat data. 791 * @param data_len: length of data buffer. 792 * @param str: string buffer. 793 * @param str_len: length of string buffer. 794 * @param pkt: packet for decompression, if NULL no decompression. 795 * @param pktlen: length of packet buffer. 796 * @return number of characters (except null) needed to print. 797 * Can return -1 on failure. 798 */ 799 int sldns_wire2str_ipseckey_scan(uint8_t** data, size_t* data_len, char** str, 800 size_t* str_len, uint8_t* pkt, size_t pktlen); 801 802 /** 803 * Scan wireformat HIP (algo, HIT, pubkey) field to string, with user buffers. 804 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 805 * @param data: wireformat data. 806 * @param data_len: length of data buffer. 807 * @param str: string buffer. 808 * @param str_len: length of string buffer. 809 * @return number of characters (except null) needed to print. 810 * Can return -1 on failure. 811 */ 812 int sldns_wire2str_hip_scan(uint8_t** data, size_t* data_len, char** str, 813 size_t* str_len); 814 815 /** 816 * Scan wireformat int16_data field to string, with user buffers. 817 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 818 * @param data: wireformat data. 819 * @param data_len: length of data buffer. 820 * @param str: string buffer. 821 * @param str_len: length of string buffer. 822 * @return number of characters (except null) needed to print. 823 * Can return -1 on failure. 824 */ 825 int sldns_wire2str_int16_data_scan(uint8_t** data, size_t* data_len, char** str, 826 size_t* str_len); 827 828 /** 829 * Scan wireformat tsigerror field to string, with user buffers. 830 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 831 * @param data: wireformat data. 832 * @param data_len: length of data buffer. 833 * @param str: string buffer. 834 * @param str_len: length of string buffer. 835 * @return number of characters (except null) needed to print. 836 * Can return -1 on failure. 837 */ 838 int sldns_wire2str_tsigerror_scan(uint8_t** data, size_t* data_len, char** str, 839 size_t* str_len); 840 841 /** 842 * Scan wireformat nsec3_next_owner field to string, with user buffers. 843 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 844 * @param data: wireformat data. 845 * @param data_len: length of data buffer. 846 * @param str: string buffer. 847 * @param str_len: length of string buffer. 848 * @return number of characters (except null) needed to print. 849 * Can return -1 on failure. 850 */ 851 int sldns_wire2str_nsec3_next_owner_scan(uint8_t** data, size_t* data_len, 852 char** str, size_t* str_len); 853 854 /** 855 * Scan wireformat ILNP64 field to string, with user buffers. 856 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 857 * @param data: wireformat data. 858 * @param data_len: length of data buffer. 859 * @param str: string buffer. 860 * @param str_len: length of string buffer. 861 * @return number of characters (except null) needed to print. 862 * Can return -1 on failure. 863 */ 864 int sldns_wire2str_ilnp64_scan(uint8_t** data, size_t* data_len, char** str, 865 size_t* str_len); 866 867 /** 868 * Scan wireformat EUI48 field to string, with user buffers. 869 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 870 * @param data: wireformat data. 871 * @param data_len: length of data buffer. 872 * @param str: string buffer. 873 * @param str_len: length of string buffer. 874 * @return number of characters (except null) needed to print. 875 * Can return -1 on failure. 876 */ 877 int sldns_wire2str_eui48_scan(uint8_t** data, size_t* data_len, char** str, 878 size_t* str_len); 879 880 /** 881 * Scan wireformat EUI64 field to string, with user buffers. 882 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 883 * @param data: wireformat data. 884 * @param data_len: length of data buffer. 885 * @param str: string buffer. 886 * @param str_len: length of string buffer. 887 * @return number of characters (except null) needed to print. 888 * Can return -1 on failure. 889 */ 890 int sldns_wire2str_eui64_scan(uint8_t** data, size_t* data_len, char** str, 891 size_t* str_len); 892 893 /** 894 * Scan wireformat TAG field to string, with user buffers. 895 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 896 * @param data: wireformat data. 897 * @param data_len: length of data buffer. 898 * @param str: string buffer. 899 * @param str_len: length of string buffer. 900 * @return number of characters (except null) needed to print. 901 * Can return -1 on failure. 902 */ 903 int sldns_wire2str_tag_scan(uint8_t** data, size_t* data_len, char** str, 904 size_t* str_len); 905 906 /** 907 * Scan wireformat long_str field to string, with user buffers. 908 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 909 * @param data: wireformat data. 910 * @param data_len: length of data buffer. 911 * @param str: string buffer. 912 * @param str_len: length of string buffer. 913 * @return number of characters (except null) needed to print. 914 * Can return -1 on failure. 915 */ 916 int sldns_wire2str_long_str_scan(uint8_t** data, size_t* data_len, char** str, 917 size_t* str_len); 918 919 /** 920 * Print EDNS LLQ option data to string. User buffers, moves string pointers. 921 * @param str: string buffer. 922 * @param str_len: length of string buffer. 923 * @param option_data: buffer with EDNS option code data. 924 * @param option_len: length of the data for this option. 925 * @return number of characters (except null) needed to print. 926 */ 927 int sldns_wire2str_edns_llq_print(char** str, size_t* str_len, 928 uint8_t* option_data, size_t option_len); 929 930 /** 931 * Print EDNS UL option data to string. User buffers, moves string pointers. 932 * @param str: string buffer. 933 * @param str_len: length of string buffer. 934 * @param option_data: buffer with EDNS option code data. 935 * @param option_len: length of the data for this option. 936 * @return number of characters (except null) needed to print. 937 */ 938 int sldns_wire2str_edns_ul_print(char** str, size_t* str_len, 939 uint8_t* option_data, size_t option_len); 940 941 /** 942 * Print EDNS NSID option data to string. User buffers, moves string pointers. 943 * @param str: string buffer. 944 * @param str_len: length of string buffer. 945 * @param option_data: buffer with EDNS option code data. 946 * @param option_len: length of the data for this option. 947 * @return number of characters (except null) needed to print. 948 */ 949 int sldns_wire2str_edns_nsid_print(char** str, size_t* str_len, 950 uint8_t* option_data, size_t option_len); 951 952 /** 953 * Print EDNS DAU option data to string. User buffers, moves string pointers. 954 * @param str: string buffer. 955 * @param str_len: length of string buffer. 956 * @param option_data: buffer with EDNS option code data. 957 * @param option_len: length of the data for this option. 958 * @return number of characters (except null) needed to print. 959 */ 960 int sldns_wire2str_edns_dau_print(char** str, size_t* str_len, 961 uint8_t* option_data, size_t option_len); 962 963 /** 964 * Print EDNS DHU option data to string. User buffers, moves string pointers. 965 * @param str: string buffer. 966 * @param str_len: length of string buffer. 967 * @param option_data: buffer with EDNS option code data. 968 * @param option_len: length of the data for this option. 969 * @return number of characters (except null) needed to print. 970 */ 971 int sldns_wire2str_edns_dhu_print(char** str, size_t* str_len, 972 uint8_t* option_data, size_t option_len); 973 974 /** 975 * Print EDNS N3U option data to string. User buffers, moves string pointers. 976 * @param str: string buffer. 977 * @param str_len: length of string buffer. 978 * @param option_data: buffer with EDNS option code data. 979 * @param option_len: length of the data for this option. 980 * @return number of characters (except null) needed to print. 981 */ 982 int sldns_wire2str_edns_n3u_print(char** str, size_t* str_len, 983 uint8_t* option_data, size_t option_len); 984 985 /** 986 * Print EDNS SUBNET option data to string. User buffers, moves string pointers. 987 * @param str: string buffer. 988 * @param str_len: length of string buffer. 989 * @param option_data: buffer with EDNS option code data. 990 * @param option_len: length of the data for this option. 991 * @return number of characters (except null) needed to print. 992 */ 993 int sldns_wire2str_edns_subnet_print(char** str, size_t* str_len, 994 uint8_t* option_data, size_t option_len); 995 996 /** 997 * Print an EDNS option as OPT: VALUE. User buffers, moves string pointers. 998 * @param str: string buffer. 999 * @param str_len: length of string buffer. 1000 * @param option_code: host format EDNS option code. 1001 * @param option_data: buffer with EDNS option code data. 1002 * @param option_len: length of the data for this option. 1003 * @return number of characters (except null) needed to print. 1004 */ 1005 int sldns_wire2str_edns_option_print(char** str, size_t* str_len, 1006 uint16_t option_code, uint8_t* option_data, size_t option_len); 1007 1008 /** 1009 * Scan wireformat EDNS OPT to string, with user buffers. 1010 * It shifts the arguments to move along (see sldns_wire2str_pkt_scan). 1011 * @param data: wireformat data. 1012 * @param data_len: length of data buffer. 1013 * @param str: string buffer. 1014 * @param str_len: length of string buffer. 1015 * @param pkt: packet with header and other info (may be NULL) 1016 * @param pktlen: length of packet buffer. 1017 * @return number of characters (except null) needed to print. 1018 */ 1019 int sldns_wire2str_edns_scan(uint8_t** data, size_t* data_len, char** str, 1020 size_t* str_len, uint8_t* pkt, size_t pktlen); 1021 1022 #ifdef __cplusplus 1023 } 1024 #endif 1025 1026 #endif /* LDNS_WIRE2STR_H */ 1027