1 /** 2 * host2str.h - txt presentation of RRs 3 * 4 * a Net::DNS like library for C 5 * 6 * (c) NLnet Labs, 2005-2006 7 * 8 * See the file LICENSE for the license 9 */ 10 11 /** 12 * \file 13 * 14 * Contains functions to translate the main structures to their text 15 * representation, as well as functions to print them. 16 */ 17 18 #ifndef LDNS_HOST2STR_H 19 #define LDNS_HOST2STR_H 20 21 #include <ldns/common.h> 22 #include <ldns/error.h> 23 #include <ldns/rr.h> 24 #include <ldns/rdata.h> 25 #include <ldns/packet.h> 26 #include <ldns/buffer.h> 27 #include <ldns/resolver.h> 28 #include <ldns/zone.h> 29 #include <ctype.h> 30 31 #include "ldns/util.h" 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 #define LDNS_APL_IP4 1 38 #define LDNS_APL_IP6 2 39 #define LDNS_APL_MASK 0x7f 40 #define LDNS_APL_NEGATION 0x80 41 42 /** 43 * Represent a NULL pointer (in stead of a pointer to a ldns_rr as "; (null)" 44 * as opposed to outputting nothing at all in such a case. 45 */ 46 #define LDNS_COMMENT_NULLS 0x0001 47 /** Show key id with DNSKEY RR's as comment */ 48 #define LDNS_COMMENT_KEY_ID 0x0002 49 /** Show if a DNSKEY is a ZSK or KSK as comment */ 50 #define LDNS_COMMENT_KEY_TYPE 0x0004 51 /** Show DNSKEY key size as comment */ 52 #define LDNS_COMMENT_KEY_SIZE 0x0008 53 /** Show key id, type and size as comment for DNSKEY RR's */ 54 #define LDNS_COMMENT_KEY (LDNS_COMMENT_KEY_ID \ 55 |LDNS_COMMENT_KEY_TYPE\ 56 |LDNS_COMMENT_KEY_SIZE) 57 /** Provide bubblebabble representation for DS RR's as comment */ 58 #define LDNS_COMMENT_BUBBLEBABBLE 0x0010 59 /** Show when a NSEC3 RR has the optout flag set as comment */ 60 #define LDNS_COMMENT_FLAGS 0x0020 61 /** Show the unhashed owner and next owner names for NSEC3 RR's as comment */ 62 #define LDNS_COMMENT_NSEC3_CHAIN 0x0040 63 /** Print mark up */ 64 #define LDNS_COMMENT_LAYOUT 0x0080 65 /** Also comment KEY_ID with RRSIGS **/ 66 #define LDNS_COMMENT_RRSIGS 0x0100 67 68 /** 69 * Output format specifier 70 * 71 * Determines how Packets, Resource Records and Resource record data fiels are 72 * formatted when printing or converting to string. 73 * Currently it is only used to specify what aspects of a Resource Record are 74 * annotated in the comment section of the textual representation the record. 75 * This is speciefed with flags and potential exra data (such as for example 76 * a lookup map of hashes to real names for annotation NSEC3 records). 77 */ 78 struct ldns_struct_output_format 79 { 80 /** Specification of how RR's should be formatted in text */ 81 int flags; 82 /** Potential extra data to be used with formatting RR's in text */ 83 void *data; 84 }; 85 typedef struct ldns_struct_output_format ldns_output_format; 86 87 /** 88 * Standard output format record that disables commenting in the textual 89 * representation of Resource Records completely. 90 */ 91 extern const ldns_output_format *ldns_output_format_nocomments; 92 /** 93 * Standard output format record that annotated only DNSKEY RR's with commenti 94 * text. 95 */ 96 extern const ldns_output_format *ldns_output_format_onlykeyids; 97 /** 98 * The default output format record. Same as ldns_output_format_onlykeyids. 99 */ 100 extern const ldns_output_format *ldns_output_format_default; 101 /** 102 * Standard output format record that shows all DNSKEY related information in 103 * the comment text, plus the optout flag when set with NSEC3's, plus the 104 * bubblebabble representation of DS RR's. 105 */ 106 extern const ldns_output_format *ldns_output_format_bubblebabble; 107 108 /** 109 * Converts an ldns packet opcode value to its mnemonic, and adds that 110 * to the output buffer 111 * \param[in] *output the buffer to add the data to 112 * \param[in] opcode to find the string representation of 113 * \return LDNS_STATUS_OK on success, or a buffer failure mode on error 114 */ 115 ldns_status 116 ldns_pkt_opcode2buffer_str(ldns_buffer *output, ldns_pkt_opcode opcode); 117 118 /** 119 * Converts an ldns packet rcode value to its mnemonic, and adds that 120 * to the output buffer 121 * \param[in] *output the buffer to add the data to 122 * \param[in] rcode to find the string representation of 123 * \return LDNS_STATUS_OK on success, or a buffer failure mode on error 124 */ 125 ldns_status 126 ldns_pkt_rcode2buffer_str(ldns_buffer *output, ldns_pkt_rcode rcode); 127 128 /** 129 * Converts an ldns algorithm type to its mnemonic, and adds that 130 * to the output buffer 131 * \param[in] *output the buffer to add the data to 132 * \param[in] algorithm to find the string representation of 133 * \return LDNS_STATUS_OK on success, or a buffer failure mode on error 134 */ 135 ldns_status 136 ldns_algorithm2buffer_str(ldns_buffer *output, 137 ldns_algorithm algorithm); 138 139 /** 140 * Converts an ldns certificate algorithm type to its mnemonic, 141 * and adds that to the output buffer 142 * \param[in] *output the buffer to add the data to 143 * \param[in] cert_algorithm to find the string representation of 144 * \return LDNS_STATUS_OK on success, or a buffer failure mode on error 145 */ 146 ldns_status 147 ldns_cert_algorithm2buffer_str(ldns_buffer *output, 148 ldns_cert_algorithm cert_algorithm); 149 150 151 /** 152 * Converts a packet opcode to its mnemonic and returns that as 153 * an allocated null-terminated string. 154 * Remember to free it. 155 * 156 * \param[in] opcode the opcode to convert to text 157 * \return null terminated char * data, or NULL on error 158 */ 159 char *ldns_pkt_opcode2str(ldns_pkt_opcode opcode); 160 161 /** 162 * Converts a packet rcode to its mnemonic and returns that as 163 * an allocated null-terminated string. 164 * Remember to free it. 165 * 166 * \param[in] rcode the rcode to convert to text 167 * \return null terminated char * data, or NULL on error 168 */ 169 char *ldns_pkt_rcode2str(ldns_pkt_rcode rcode); 170 171 /** 172 * Converts a signing algorithms to its mnemonic and returns that as 173 * an allocated null-terminated string. 174 * Remember to free it. 175 * 176 * \param[in] algorithm the algorithm to convert to text 177 * \return null terminated char * data, or NULL on error 178 */ 179 char *ldns_pkt_algorithm2str(ldns_algorithm algorithm); 180 181 /** 182 * Converts a cert algorithm to its mnemonic and returns that as 183 * an allocated null-terminated string. 184 * Remember to free it. 185 * 186 * \param[in] cert_algorithm to convert to text 187 * \return null terminated char * data, or NULL on error 188 */ 189 char *ldns_pkt_cert_algorithm2str(ldns_cert_algorithm cert_algorithm); 190 191 /** 192 * Converts an LDNS_RDF_TYPE_A rdata element to string format and adds it to the output buffer 193 * \param[in] *rdf The rdata to convert 194 * \param[in] *output The buffer to add the data to 195 * \return LDNS_STATUS_OK on success, and error status on failure 196 */ 197 ldns_status ldns_rdf2buffer_str_a(ldns_buffer *output, const ldns_rdf *rdf); 198 199 /** 200 * Converts an LDNS_RDF_TYPE_AAAA rdata element to string format and adds it to the output buffer 201 * \param[in] *rdf The rdata to convert 202 * \param[in] *output The buffer to add the data to 203 * \return LDNS_STATUS_OK on success, and error status on failure 204 */ 205 ldns_status ldns_rdf2buffer_str_aaaa(ldns_buffer *output, const ldns_rdf *rdf); 206 207 /** 208 * Converts an LDNS_RDF_TYPE_STR rdata element to string format and adds it to the output buffer 209 * \param[in] *rdf The rdata to convert 210 * \param[in] *output The buffer to add the data to 211 * \return LDNS_STATUS_OK on success, and error status on failure 212 */ 213 ldns_status ldns_rdf2buffer_str_str(ldns_buffer *output, const ldns_rdf *rdf); 214 215 /** 216 * Converts an LDNS_RDF_TYPE_B64 rdata element to string format and adds it to the output buffer 217 * \param[in] *rdf The rdata to convert 218 * \param[in] *output The buffer to add the data to 219 * \return LDNS_STATUS_OK on success, and error status on failure 220 */ 221 ldns_status ldns_rdf2buffer_str_b64(ldns_buffer *output, const ldns_rdf *rdf); 222 223 /** 224 * Converts an LDNS_RDF_TYPE_B32_EXT rdata element to string format and adds it to the output buffer 225 * \param[in] *rdf The rdata to convert 226 * \param[in] *output The buffer to add the data to 227 * \return LDNS_STATUS_OK on success, and error status on failure 228 */ 229 ldns_status ldns_rdf2buffer_str_b32_ext(ldns_buffer *output, const ldns_rdf *rdf); 230 231 /** 232 * Converts an LDNS_RDF_TYPE_HEX rdata element to string format and adds it to the output buffer 233 * \param[in] *rdf The rdata to convert 234 * \param[in] *output The buffer to add the data to 235 * \return LDNS_STATUS_OK on success, and error status on failure 236 */ 237 ldns_status ldns_rdf2buffer_str_hex(ldns_buffer *output, const ldns_rdf *rdf); 238 239 /** 240 * Converts an LDNS_RDF_TYPE_TYPE rdata element to string format and adds it to the output buffer 241 * \param[in] *rdf The rdata to convert 242 * \param[in] *output The buffer to add the data to 243 * \return LDNS_STATUS_OK on success, and error status on failure 244 */ 245 ldns_status ldns_rdf2buffer_str_type(ldns_buffer *output, const ldns_rdf *rdf); 246 247 /** 248 * Converts an LDNS_RDF_TYPE_CLASS rdata element to string format and adds it to the output buffer 249 * \param[in] *rdf The rdata to convert 250 * \param[in] *output The buffer to add the data to 251 * \return LDNS_STATUS_OK on success, and error status on failure 252 */ 253 ldns_status ldns_rdf2buffer_str_class(ldns_buffer *output, const ldns_rdf *rdf); 254 255 /** 256 * Converts an LDNS_RDF_TYPE_ALG rdata element to string format and adds it to the output buffer 257 * \param[in] *rdf The rdata to convert 258 * \param[in] *output The buffer to add the data to 259 * \return LDNS_STATUS_OK on success, and error status on failure 260 */ 261 ldns_status ldns_rdf2buffer_str_alg(ldns_buffer *output, const ldns_rdf *rdf); 262 263 /** 264 * Converts an ldns_rr_type value to its string representation, 265 * and places it in the given buffer 266 * \param[in] *output The buffer to add the data to 267 * \param[in] type the ldns_rr_type to convert 268 * \return LDNS_STATUS_OK on success, and error status on failure 269 */ 270 ldns_status ldns_rr_type2buffer_str(ldns_buffer *output, 271 const ldns_rr_type type); 272 273 /** 274 * Converts an ldns_rr_type value to its string representation, 275 * and returns that string. For unknown types, the string 276 * "TYPE<id>" is returned. This function allocates data that must be 277 * freed by the caller 278 * \param[in] type the ldns_rr_type to convert 279 * \return a newly allocated string 280 */ 281 char *ldns_rr_type2str(const ldns_rr_type type); 282 283 /** 284 * Converts an ldns_rr_class value to its string representation, 285 * and places it in the given buffer 286 * \param[in] *output The buffer to add the data to 287 * \param[in] klass the ldns_rr_class to convert 288 * \return LDNS_STATUS_OK on success, and error status on failure 289 */ 290 ldns_status ldns_rr_class2buffer_str(ldns_buffer *output, 291 const ldns_rr_class klass); 292 293 /** 294 * Converts an ldns_rr_class value to its string representation, 295 * and returns that string. For unknown types, the string 296 * "CLASS<id>" is returned. This function allocates data that must be 297 * freed by the caller 298 * \param[in] klass the ldns_rr_class to convert 299 * \return a newly allocated string 300 */ 301 char *ldns_rr_class2str(const ldns_rr_class klass); 302 303 304 /** 305 * Converts an LDNS_RDF_TYPE_CERT rdata element to string format and adds it to the output buffer 306 * \param[in] *rdf The rdata to convert 307 * \param[in] *output The buffer to add the data to 308 * \return LDNS_STATUS_OK on success, and error status on failure 309 */ 310 ldns_status ldns_rdf2buffer_str_cert_alg(ldns_buffer *output, const ldns_rdf *rdf); 311 312 /** 313 * Converts an LDNS_RDF_TYPE_LOC rdata element to string format and adds it to the output buffer 314 * \param[in] *rdf The rdata to convert 315 * \param[in] *output The buffer to add the data to 316 * \return LDNS_STATUS_OK on success, and error status on failure 317 */ 318 ldns_status ldns_rdf2buffer_str_loc(ldns_buffer *output, const ldns_rdf *rdf); 319 320 /** 321 * Converts an LDNS_RDF_TYPE_UNKNOWN rdata element to string format and adds it to the output buffer 322 * \param[in] *rdf The rdata to convert 323 * \param[in] *output The buffer to add the data to 324 * \return LDNS_STATUS_OK on success, and error status on failure 325 */ 326 ldns_status ldns_rdf2buffer_str_unknown(ldns_buffer *output, const ldns_rdf *rdf); 327 328 /** 329 * Converts an LDNS_RDF_TYPE_NSAP rdata element to string format and adds it to the output buffer 330 * \param[in] *rdf The rdata to convert 331 * \param[in] *output The buffer to add the data to 332 * \return LDNS_STATUS_OK on success, and error status on failure 333 */ 334 ldns_status ldns_rdf2buffer_str_nsap(ldns_buffer *output, const ldns_rdf *rdf); 335 336 /** 337 * Converts an LDNS_RDF_TYPE_ATMA rdata element to string format and adds it to the output buffer 338 * \param[in] *rdf The rdata to convert 339 * \param[in] *output The buffer to add the data to 340 * \return LDNS_STATUS_OK on success, and error status on failure 341 */ 342 ldns_status ldns_rdf2buffer_str_atma(ldns_buffer *output, const ldns_rdf *rdf); 343 344 /** 345 * Converts an LDNS_RDF_TYPE_WKS rdata element to string format and adds it to the output buffer 346 * \param[in] *rdf The rdata to convert 347 * \param[in] *output The buffer to add the data to 348 * \return LDNS_STATUS_OK on success, and error status on failure 349 */ 350 ldns_status ldns_rdf2buffer_str_wks(ldns_buffer *output, const ldns_rdf *rdf); 351 352 /** 353 * Converts an LDNS_RDF_TYPE_NSEC rdata element to string format and adds it to the output buffer 354 * \param[in] *rdf The rdata to convert 355 * \param[in] *output The buffer to add the data to 356 * \return LDNS_STATUS_OK on success, and error status on failure 357 */ 358 ldns_status ldns_rdf2buffer_str_nsec(ldns_buffer *output, const ldns_rdf *rdf); 359 360 /** 361 * Converts an LDNS_RDF_TYPE_PERIOD rdata element to string format and adds it to the output buffer 362 * \param[in] *rdf The rdata to convert 363 * \param[in] *output The buffer to add the data to 364 * \return LDNS_STATUS_OK on success, and error status on failure 365 */ 366 ldns_status ldns_rdf2buffer_str_period(ldns_buffer *output, const ldns_rdf *rdf); 367 368 /** 369 * Converts an LDNS_RDF_TYPE_TSIGTIME rdata element to string format and adds it to the output buffer 370 * \param[in] *rdf The rdata to convert 371 * \param[in] *output The buffer to add the data to 372 * \return LDNS_STATUS_OK on success, and error status on failure 373 */ 374 ldns_status ldns_rdf2buffer_str_tsigtime(ldns_buffer *output, const ldns_rdf *rdf); 375 376 /** 377 * Converts an LDNS_RDF_TYPE_APL rdata element to string format and adds it to the output buffer 378 * \param[in] *rdf The rdata to convert 379 * \param[in] *output The buffer to add the data to 380 * \return LDNS_STATUS_OK on success, and error status on failure 381 */ 382 ldns_status ldns_rdf2buffer_str_apl(ldns_buffer *output, const ldns_rdf *rdf); 383 384 /** 385 * Converts an LDNS_RDF_TYPE_INT16_DATA rdata element to string format and adds it to the output buffer 386 * \param[in] *rdf The rdata to convert 387 * \param[in] *output The buffer to add the data to 388 * \return LDNS_STATUS_OK on success, and error status on failure 389 */ 390 ldns_status ldns_rdf2buffer_str_int16_data(ldns_buffer *output, const ldns_rdf *rdf); 391 392 /** 393 * Converts an LDNS_RDF_TYPE_IPSECKEY rdata element to string format and adds it to the output buffer 394 * \param[in] *rdf The rdata to convert 395 * \param[in] *output The buffer to add the data to 396 * \return LDNS_STATUS_OK on success, and error status on failure 397 */ 398 ldns_status ldns_rdf2buffer_str_ipseckey(ldns_buffer *output, const ldns_rdf *rdf); 399 400 /** 401 * Converts an LDNS_RDF_TYPE_TSIG rdata element to string format and adds it to the output buffer 402 * \param[in] *rdf The rdata to convert 403 * \param[in] *output The buffer to add the data to 404 * \return LDNS_STATUS_OK on success, and error status on failure 405 */ 406 ldns_status ldns_rdf2buffer_str_tsig(ldns_buffer *output, const ldns_rdf *rdf); 407 408 409 /** 410 * Converts the data in the rdata field to presentation 411 * format (as char *) and appends it to the given buffer 412 * 413 * \param[in] output pointer to the buffer to append the data to 414 * \param[in] rdf the pointer to the rdafa field containing the data 415 * \return status 416 */ 417 ldns_status ldns_rdf2buffer_str(ldns_buffer *output, const ldns_rdf *rdf); 418 419 /** 420 * Converts the data in the resource record to presentation 421 * format (as char *) and appends it to the given buffer. 422 * The presentation format of DNSKEY record is annotated with comments giving 423 * the id, type and size of the key. 424 * 425 * \param[in] output pointer to the buffer to append the data to 426 * \param[in] rr the pointer to the rr field to convert 427 * \return status 428 */ 429 ldns_status ldns_rr2buffer_str(ldns_buffer *output, const ldns_rr *rr); 430 431 /** 432 * Converts the data in the resource record to presentation 433 * format (as char *) and appends it to the given buffer. 434 * The presentation format is annotated with comments giving 435 * additional information on the record. 436 * 437 * \param[in] output pointer to the buffer to append the data to 438 * \param[in] fmt how to format the textual representation of the 439 * resource record. 440 * \param[in] rr the pointer to the rr field to convert 441 * \return status 442 */ 443 ldns_status ldns_rr2buffer_str_fmt(ldns_buffer *output, 444 const ldns_output_format *fmt, const ldns_rr *rr); 445 446 /** 447 * Converts the data in the DNS packet to presentation 448 * format (as char *) and appends it to the given buffer 449 * 450 * \param[in] output pointer to the buffer to append the data to 451 * \param[in] pkt the pointer to the packet to convert 452 * \return status 453 */ 454 ldns_status ldns_pkt2buffer_str(ldns_buffer *output, const ldns_pkt *pkt); 455 456 /** 457 * Converts the data in the DNS packet to presentation 458 * format (as char *) and appends it to the given buffer 459 * 460 * \param[in] output pointer to the buffer to append the data to 461 * \param[in] fmt how to format the textual representation of the packet 462 * \param[in] pkt the pointer to the packet to convert 463 * \return status 464 */ 465 ldns_status ldns_pkt2buffer_str_fmt(ldns_buffer *output, 466 const ldns_output_format *fmt, const ldns_pkt *pkt); 467 468 /** 469 * Converts an LDNS_RDF_TYPE_NSEC3_SALT rdata element to string format and adds it to the output buffer 470 * \param[in] *rdf The rdata to convert 471 * \param[in] *output The buffer to add the data to 472 * \return LDNS_STATUS_OK on success, and error status on failure 473 */ 474 ldns_status ldns_rdf2buffer_str_nsec3_salt(ldns_buffer *output, const ldns_rdf *rdf); 475 476 477 /** 478 * Converts the data in the DNS packet to presentation 479 * format (as char *) and appends it to the given buffer 480 * 481 * \param[in] output pointer to the buffer to append the data to 482 * \param[in] k the pointer to the private key to convert 483 * \return status 484 */ 485 ldns_status ldns_key2buffer_str(ldns_buffer *output, const ldns_key *k); 486 487 /** 488 * Converts an LDNS_RDF_TYPE_INT8 rdata element to string format and adds it to the output buffer 489 * \param[in] *rdf The rdata to convert 490 * \param[in] *output The buffer to add the data to 491 * \return LDNS_STATUS_OK on success, and error status on failure 492 */ 493 ldns_status ldns_rdf2buffer_str_int8(ldns_buffer *output, const ldns_rdf *rdf); 494 495 /** 496 * Converts an LDNS_RDF_TYPE_INT16 rdata element to string format and adds it to the output buffer 497 * \param[in] *rdf The rdata to convert 498 * \param[in] *output The buffer to add the data to 499 * \return LDNS_STATUS_OK on success, and error status on failure 500 */ 501 ldns_status ldns_rdf2buffer_str_int16(ldns_buffer *output, const ldns_rdf *rdf); 502 503 /** 504 * Converts an LDNS_RDF_TYPE_INT32 rdata element to string format and adds it to the output buffer 505 * \param[in] *rdf The rdata to convert 506 * \param[in] *output The buffer to add the data to 507 * \return LDNS_STATUS_OK on success, and error status on failure 508 */ 509 ldns_status ldns_rdf2buffer_str_int32(ldns_buffer *output, const ldns_rdf *rdf); 510 511 /** 512 * Converts an LDNS_RDF_TYPE_TIME rdata element to string format and adds it to the output buffer 513 * \param[in] *rdf The rdata to convert 514 * \param[in] *output The buffer to add the data to 515 * \return LDNS_STATUS_OK on success, and error status on failure 516 */ 517 ldns_status ldns_rdf2buffer_str_time(ldns_buffer *output, const ldns_rdf *rdf); 518 519 /** 520 * Converts the data in the rdata field to presentation format and 521 * returns that as a char *. 522 * Remember to free it. 523 * 524 * \param[in] rdf The rdata field to convert 525 * \return null terminated char * data, or NULL on error 526 */ 527 char *ldns_rdf2str(const ldns_rdf *rdf); 528 529 /** 530 * Converts the data in the resource record to presentation format and 531 * returns that as a char *. 532 * Remember to free it. 533 * 534 * \param[in] rr The rdata field to convert 535 * \return null terminated char * data, or NULL on error 536 */ 537 char *ldns_rr2str(const ldns_rr *rr); 538 539 /** 540 * Converts the data in the resource record to presentation format and 541 * returns that as a char *. 542 * Remember to free it. 543 * 544 * \param[in] fmt how to format the resource record 545 * \param[in] rr The rdata field to convert 546 * \return null terminated char * data, or NULL on error 547 */ 548 char *ldns_rr2str_fmt(const ldns_output_format *fmt, const ldns_rr *rr); 549 550 /** 551 * Converts the data in the DNS packet to presentation format and 552 * returns that as a char *. 553 * Remember to free it. 554 * 555 * \param[in] pkt The rdata field to convert 556 * \return null terminated char * data, or NULL on error 557 */ 558 char *ldns_pkt2str(const ldns_pkt *pkt); 559 560 /** 561 * Converts the data in the DNS packet to presentation format and 562 * returns that as a char *. 563 * Remember to free it. 564 * 565 * \param[in] fmt how to format the packet 566 * \param[in] pkt The rdata field to convert 567 * \return null terminated char * data, or NULL on error 568 */ 569 char *ldns_pkt2str_fmt(const ldns_output_format *fmt, const ldns_pkt *pkt); 570 571 /** 572 * Converts a private key to the test presentation fmt and 573 * returns that as a char *. 574 * Remember to free it. 575 * 576 * \param[in] k the key to convert to text 577 * \return null terminated char * data, or NULL on error 578 */ 579 char *ldns_key2str(const ldns_key *k); 580 581 /** 582 * Converts a list of resource records to presentation format 583 * and returns that as a char *. 584 * Remember to free it. 585 * 586 * \param[in] rr_list the rr_list to convert to text 587 * \return null terminated char * data, or NULL on error 588 */ 589 char *ldns_rr_list2str(const ldns_rr_list *rr_list); 590 591 /** 592 * Converts a list of resource records to presentation format 593 * and returns that as a char *. 594 * Remember to free it. 595 * 596 * \param[in] fmt how to format the list of resource records 597 * \param[in] rr_list the rr_list to convert to text 598 * \return null terminated char * data, or NULL on error 599 */ 600 char *ldns_rr_list2str_fmt( 601 const ldns_output_format *fmt, const ldns_rr_list *rr_list); 602 603 /** 604 * Returns the data in the buffer as a null terminated char * string 605 * Buffer data must be char * type, and must be freed by the caller 606 * 607 * \param[in] buffer buffer containing char * data 608 * \return null terminated char * data, or NULL on error 609 */ 610 char *ldns_buffer2str(ldns_buffer *buffer); 611 612 /** 613 * Prints the data in the rdata field to the given file stream 614 * (in presentation format) 615 * 616 * \param[in] output the file stream to print to 617 * \param[in] rdf the rdata field to print 618 * \return void 619 */ 620 void ldns_rdf_print(FILE *output, const ldns_rdf *rdf); 621 622 /** 623 * Prints the data in the resource record to the given file stream 624 * (in presentation format) 625 * 626 * \param[in] output the file stream to print to 627 * \param[in] rr the resource record to print 628 * \return void 629 */ 630 void ldns_rr_print(FILE *output, const ldns_rr *rr); 631 632 /** 633 * Prints the data in the resource record to the given file stream 634 * (in presentation format) 635 * 636 * \param[in] output the file stream to print to 637 * \param[in] fmt format of the textual representation 638 * \param[in] rr the resource record to print 639 * \return void 640 */ 641 void ldns_rr_print_fmt(FILE *output, 642 const ldns_output_format *fmt, const ldns_rr *rr); 643 644 /** 645 * Prints the data in the DNS packet to the given file stream 646 * (in presentation format) 647 * 648 * \param[in] output the file stream to print to 649 * \param[in] pkt the packet to print 650 * \return void 651 */ 652 void ldns_pkt_print(FILE *output, const ldns_pkt *pkt); 653 654 /** 655 * Prints the data in the DNS packet to the given file stream 656 * (in presentation format) 657 * 658 * \param[in] output the file stream to print to 659 * \param[in] fmt format of the textual representation 660 * \param[in] pkt the packet to print 661 * \return void 662 */ 663 void ldns_pkt_print_fmt(FILE *output, 664 const ldns_output_format *fmt, const ldns_pkt *pkt); 665 666 /** 667 * Converts a rr_list to presentation format and appends it to 668 * the output buffer 669 * \param[in] output the buffer to append output to 670 * \param[in] list the ldns_rr_list to print 671 * \return ldns_status 672 */ 673 ldns_status ldns_rr_list2buffer_str(ldns_buffer *output, const ldns_rr_list *list); 674 675 /** 676 * Converts a rr_list to presentation format and appends it to 677 * the output buffer 678 * \param[in] output the buffer to append output to 679 * \param[in] fmt format of the textual representation 680 * \param[in] list the ldns_rr_list to print 681 * \return ldns_status 682 */ 683 ldns_status ldns_rr_list2buffer_str_fmt(ldns_buffer *output, 684 const ldns_output_format *fmt, const ldns_rr_list *list); 685 686 /** 687 * Converts the header of a packet to presentation format and appends it to 688 * the output buffer 689 * \param[in] output the buffer to append output to 690 * \param[in] pkt the packet to convert the header of 691 * \return ldns_status 692 */ 693 ldns_status ldns_pktheader2buffer_str(ldns_buffer *output, const ldns_pkt *pkt); 694 695 /** 696 * print a rr_list to output 697 * \param[in] output the fd to print to 698 * \param[in] list the rr_list to print 699 */ 700 void ldns_rr_list_print(FILE *output, const ldns_rr_list *list); 701 702 /** 703 * print a rr_list to output 704 * \param[in] output the fd to print to 705 * \param[in] fmt format of the textual representation 706 * \param[in] list the rr_list to print 707 */ 708 void ldns_rr_list_print_fmt(FILE *output, 709 const ldns_output_format *fmt, const ldns_rr_list *list); 710 711 /** 712 * Print a resolver (in sofar that is possible) state 713 * to output. 714 * \param[in] output the fd to print to 715 * \param[in] r the resolver to print 716 */ 717 void ldns_resolver_print(FILE *output, const ldns_resolver *r); 718 719 /** 720 * Print a resolver (in sofar that is possible) state 721 * to output. 722 * \param[in] output the fd to print to 723 * \param[in] fmt format of the textual representation 724 * \param[in] r the resolver to print 725 */ 726 void ldns_resolver_print_fmt(FILE *output, 727 const ldns_output_format *fmt, const ldns_resolver *r); 728 729 /** 730 * Print a zone structure * to output. Note the SOA record 731 * is included in this output 732 * \param[in] output the fd to print to 733 * \param[in] z the zone to print 734 */ 735 void ldns_zone_print(FILE *output, const ldns_zone *z); 736 737 /** 738 * Print a zone structure * to output. Note the SOA record 739 * is included in this output 740 * \param[in] output the fd to print to 741 * \param[in] fmt format of the textual representation 742 * \param[in] z the zone to print 743 */ 744 void ldns_zone_print_fmt(FILE *output, 745 const ldns_output_format *fmt, const ldns_zone *z); 746 747 /** 748 * Print the ldns_rdf containing a dname to the buffer 749 * \param[in] output the buffer to print to 750 * \param[in] dname the dname to print 751 * \return ldns_status message if the printing succeeded 752 */ 753 ldns_status ldns_rdf2buffer_str_dname(ldns_buffer *output, const ldns_rdf *dname); 754 755 #ifdef __cplusplus 756 } 757 #endif 758 759 #endif /* LDNS_HOST2STR_H */ 760