2 * host2str.h - txt presentation of RRs
4 * a Net::DNS like library for C
6 * (c) NLnet Labs, 2005-2006
8 * See the file LICENSE for the license
14 * Contains functions to translate the main structures to their text
15 * representation, as well as functions to print them.
18 #ifndef LDNS_HOST2STR_H
19 #define LDNS_HOST2STR_H
21 #include <ldns/common.h>
22 #include <ldns/error.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>
31 #include "ldns/util.h"
37 #define LDNS_APL_IP4 1
38 #define LDNS_APL_IP6 2
39 #define LDNS_APL_MASK 0x7f
40 #define LDNS_APL_NEGATION 0x80
43 * Represent a NULL pointer (instead of a pointer to a ldns_rr as "; (null)"
44 * as opposed to outputting nothing at all in such a case.
46 /* Flag Name Flag Nr. Has data associated
47 ---------------------------------------------------------------------*/
48 #define LDNS_COMMENT_NULLS (1 << 0)
49 /** Show key id with DNSKEY RR's as comment */
50 #define LDNS_COMMENT_KEY_ID (1 << 1)
51 /** Show if a DNSKEY is a ZSK or KSK as comment */
52 #define LDNS_COMMENT_KEY_TYPE (1 << 2)
53 /** Show DNSKEY key size as comment */
54 #define LDNS_COMMENT_KEY_SIZE (1 << 3)
55 /** Provide bubblebabble representation for DS RR's as comment */
56 #define LDNS_COMMENT_BUBBLEBABBLE (1 << 4)
57 /** Show when a NSEC3 RR has the optout flag set as comment */
58 #define LDNS_COMMENT_FLAGS (1 << 5)
59 /** Show the unhashed owner and next owner names for NSEC3 RR's as comment */
60 #define LDNS_COMMENT_NSEC3_CHAIN (1 << 6) /* yes */
62 #define LDNS_COMMENT_LAYOUT (1 << 7)
63 /** Also comment KEY_ID with RRSIGS **/
64 #define LDNS_COMMENT_RRSIGS (1 << 8)
65 #define LDNS_FMT_ZEROIZE_RRSIGS (1 << 9)
66 #define LDNS_FMT_PAD_SOA_SERIAL (1 << 10)
67 #define LDNS_FMT_RFC3597 (1 << 11) /* yes */
69 #define LDNS_FMT_FLAGS_WITH_DATA 2
71 /** Show key id, type and size as comment for DNSKEY RR's */
72 #define LDNS_COMMENT_KEY (LDNS_COMMENT_KEY_ID \
73 |LDNS_COMMENT_KEY_TYPE\
74 |LDNS_COMMENT_KEY_SIZE)
77 * Output format specifier
79 * Determines how Packets, Resource Records and Resource record data fiels are
80 * formatted when printing or converting to string.
81 * Currently it is only used to specify what aspects of a Resource Record are
82 * annotated in the comment section of the textual representation the record.
83 * This is speciefed with flags and potential exra data (such as for example
84 * a lookup map of hashes to real names for annotation NSEC3 records).
86 struct ldns_struct_output_format
88 /** Specification of how RR's should be formatted in text */
90 /** Potential extra data to be used with formatting RR's in text */
93 typedef struct ldns_struct_output_format ldns_output_format;
96 * Output format struct with additional data for flags that use them.
97 * This struct may not be initialized directly. Use ldns_output_format_init
100 struct ldns_struct_output_format_storage
102 ldns_rbtree_t* hashmap; /* for LDNS_COMMENT_NSEC3_CHAIN */
103 ldns_rdf* bitmap; /* for LDNS_FMT_RFC3597 */
105 typedef struct ldns_struct_output_format_storage ldns_output_format_storage;
108 * Standard output format record that disables commenting in the textual
109 * representation of Resource Records completely.
111 extern const ldns_output_format *ldns_output_format_nocomments;
113 * Standard output format record that annotated only DNSKEY RR's with commenti
116 extern const ldns_output_format *ldns_output_format_onlykeyids;
118 * The default output format record. Same as ldns_output_format_onlykeyids.
120 extern const ldns_output_format *ldns_output_format_default;
122 * Standard output format record that shows all DNSKEY related information in
123 * the comment text, plus the optout flag when set with NSEC3's, plus the
124 * bubblebabble representation of DS RR's.
126 extern const ldns_output_format *ldns_output_format_bubblebabble;
129 * Initialize output format storage to the default value.
130 * \param[in] fmt A reference to an output_format_ storage struct
131 * \return The initialized storage struct typecasted to ldns_output_format
134 ldns_output_format* ldns_output_format_init(ldns_output_format_storage* fmt) {
135 fmt->flags = ldns_output_format_default->flags;
138 return (ldns_output_format*)fmt;
142 * Set an output format flag.
144 INLINE void ldns_output_format_set(ldns_output_format* fmt, int flag) {
149 * Clear an output format flag.
151 INLINE void ldns_output_format_clear(ldns_output_format* fmt, int flag) {
156 * Makes sure the LDNS_FMT_RFC3597 is set in the output format.
157 * Marks the type to be printed in RFC3597 format.
158 * /param[in] fmt the output format to update
159 * /param[in] the type to be printed in RFC3597 format
160 * /return LDNS_STATUS_OK on success
163 ldns_output_format_set_type(ldns_output_format* fmt, ldns_rr_type type);
166 * Makes sure the LDNS_FMT_RFC3597 is set in the output format.
167 * Marks the type to not be printed in RFC3597 format. When no other types
168 * have been marked before, all known types (except the given one) will be
169 * marked for printing in RFC3597 format.
170 * /param[in] fmt the output format to update
171 * /param[in] the type not to be printed in RFC3597 format
172 * /return LDNS_STATUS_OK on success
175 ldns_output_format_clear_type(ldns_output_format* fmt, ldns_rr_type type);
178 * Converts an ldns packet opcode value to its mnemonic, and adds that
179 * to the output buffer
180 * \param[in] *output the buffer to add the data to
181 * \param[in] opcode to find the string representation of
182 * \return LDNS_STATUS_OK on success, or a buffer failure mode on error
185 ldns_pkt_opcode2buffer_str(ldns_buffer *output, ldns_pkt_opcode opcode);
188 * Converts an ldns packet rcode value to its mnemonic, and adds that
189 * to the output buffer
190 * \param[in] *output the buffer to add the data to
191 * \param[in] rcode to find the string representation of
192 * \return LDNS_STATUS_OK on success, or a buffer failure mode on error
195 ldns_pkt_rcode2buffer_str(ldns_buffer *output, ldns_pkt_rcode rcode);
198 * Converts an ldns algorithm type to its mnemonic, and adds that
199 * to the output buffer
200 * \param[in] *output the buffer to add the data to
201 * \param[in] algorithm to find the string representation of
202 * \return LDNS_STATUS_OK on success, or a buffer failure mode on error
205 ldns_algorithm2buffer_str(ldns_buffer *output,
206 ldns_algorithm algorithm);
209 * Converts an ldns certificate algorithm type to its mnemonic,
210 * and adds that to the output buffer
211 * \param[in] *output the buffer to add the data to
212 * \param[in] cert_algorithm to find the string representation of
213 * \return LDNS_STATUS_OK on success, or a buffer failure mode on error
216 ldns_cert_algorithm2buffer_str(ldns_buffer *output,
217 ldns_cert_algorithm cert_algorithm);
221 * Converts a packet opcode to its mnemonic and returns that as
222 * an allocated null-terminated string.
223 * Remember to free it.
225 * \param[in] opcode the opcode to convert to text
226 * \return null terminated char * data, or NULL on error
228 char *ldns_pkt_opcode2str(ldns_pkt_opcode opcode);
231 * Converts a packet rcode to its mnemonic and returns that as
232 * an allocated null-terminated string.
233 * Remember to free it.
235 * \param[in] rcode the rcode to convert to text
236 * \return null terminated char * data, or NULL on error
238 char *ldns_pkt_rcode2str(ldns_pkt_rcode rcode);
241 * Converts a signing algorithms to its mnemonic and returns that as
242 * an allocated null-terminated string.
243 * Remember to free it.
245 * \param[in] algorithm the algorithm to convert to text
246 * \return null terminated char * data, or NULL on error
248 char *ldns_pkt_algorithm2str(ldns_algorithm algorithm);
251 * Converts a cert algorithm to its mnemonic and returns that as
252 * an allocated null-terminated string.
253 * Remember to free it.
255 * \param[in] cert_algorithm to convert to text
256 * \return null terminated char * data, or NULL on error
258 char *ldns_pkt_cert_algorithm2str(ldns_cert_algorithm cert_algorithm);
261 * Converts an LDNS_RDF_TYPE_A rdata element to string format and adds it to the output buffer
262 * \param[in] *rdf The rdata to convert
263 * \param[in] *output The buffer to add the data to
264 * \return LDNS_STATUS_OK on success, and error status on failure
266 ldns_status ldns_rdf2buffer_str_a(ldns_buffer *output, const ldns_rdf *rdf);
269 * Converts an LDNS_RDF_TYPE_AAAA rdata element to string format and adds it to the output buffer
270 * \param[in] *rdf The rdata to convert
271 * \param[in] *output The buffer to add the data to
272 * \return LDNS_STATUS_OK on success, and error status on failure
274 ldns_status ldns_rdf2buffer_str_aaaa(ldns_buffer *output, const ldns_rdf *rdf);
277 * Converts an LDNS_RDF_TYPE_STR rdata element to string format and adds it to the output buffer
278 * \param[in] *rdf The rdata to convert
279 * \param[in] *output The buffer to add the data to
280 * \return LDNS_STATUS_OK on success, and error status on failure
282 ldns_status ldns_rdf2buffer_str_str(ldns_buffer *output, const ldns_rdf *rdf);
285 * Converts an LDNS_RDF_TYPE_B64 rdata element to string format and adds it to the output buffer
286 * \param[in] *rdf The rdata to convert
287 * \param[in] *output The buffer to add the data to
288 * \return LDNS_STATUS_OK on success, and error status on failure
290 ldns_status ldns_rdf2buffer_str_b64(ldns_buffer *output, const ldns_rdf *rdf);
293 * Converts an LDNS_RDF_TYPE_B32_EXT rdata element to string format and adds it to the output buffer
294 * \param[in] *rdf The rdata to convert
295 * \param[in] *output The buffer to add the data to
296 * \return LDNS_STATUS_OK on success, and error status on failure
298 ldns_status ldns_rdf2buffer_str_b32_ext(ldns_buffer *output, const ldns_rdf *rdf);
301 * Converts an LDNS_RDF_TYPE_HEX rdata element to string format and adds it to the output buffer
302 * \param[in] *rdf The rdata to convert
303 * \param[in] *output The buffer to add the data to
304 * \return LDNS_STATUS_OK on success, and error status on failure
306 ldns_status ldns_rdf2buffer_str_hex(ldns_buffer *output, const ldns_rdf *rdf);
309 * Converts an LDNS_RDF_TYPE_TYPE rdata element to string format and adds it to the output buffer
310 * \param[in] *rdf The rdata to convert
311 * \param[in] *output The buffer to add the data to
312 * \return LDNS_STATUS_OK on success, and error status on failure
314 ldns_status ldns_rdf2buffer_str_type(ldns_buffer *output, const ldns_rdf *rdf);
317 * Converts an LDNS_RDF_TYPE_CLASS rdata element to string format and adds it to the output buffer
318 * \param[in] *rdf The rdata to convert
319 * \param[in] *output The buffer to add the data to
320 * \return LDNS_STATUS_OK on success, and error status on failure
322 ldns_status ldns_rdf2buffer_str_class(ldns_buffer *output, const ldns_rdf *rdf);
325 * Converts an LDNS_RDF_TYPE_ALG rdata element to string format and adds it to the output buffer
326 * \param[in] *rdf The rdata to convert
327 * \param[in] *output The buffer to add the data to
328 * \return LDNS_STATUS_OK on success, and error status on failure
330 ldns_status ldns_rdf2buffer_str_alg(ldns_buffer *output, const ldns_rdf *rdf);
333 * Converts an ldns_rr_type value to its string representation,
334 * and places it in the given buffer
335 * \param[in] *output The buffer to add the data to
336 * \param[in] type the ldns_rr_type to convert
337 * \return LDNS_STATUS_OK on success, and error status on failure
339 ldns_status ldns_rr_type2buffer_str(ldns_buffer *output,
340 const ldns_rr_type type);
343 * Converts an ldns_rr_type value to its string representation,
344 * and returns that string. For unknown types, the string
345 * "TYPE<id>" is returned. This function allocates data that must be
346 * freed by the caller
347 * \param[in] type the ldns_rr_type to convert
348 * \return a newly allocated string
350 char *ldns_rr_type2str(const ldns_rr_type type);
353 * Converts an ldns_rr_class value to its string representation,
354 * and places it in the given buffer
355 * \param[in] *output The buffer to add the data to
356 * \param[in] klass the ldns_rr_class to convert
357 * \return LDNS_STATUS_OK on success, and error status on failure
359 ldns_status ldns_rr_class2buffer_str(ldns_buffer *output,
360 const ldns_rr_class klass);
363 * Converts an ldns_rr_class value to its string representation,
364 * and returns that string. For unknown types, the string
365 * "CLASS<id>" is returned. This function allocates data that must be
366 * freed by the caller
367 * \param[in] klass the ldns_rr_class to convert
368 * \return a newly allocated string
370 char *ldns_rr_class2str(const ldns_rr_class klass);
374 * Converts an LDNS_RDF_TYPE_CERT rdata element to string format and adds it to the output buffer
375 * \param[in] *rdf The rdata to convert
376 * \param[in] *output The buffer to add the data to
377 * \return LDNS_STATUS_OK on success, and error status on failure
379 ldns_status ldns_rdf2buffer_str_cert_alg(ldns_buffer *output, const ldns_rdf *rdf);
382 * Converts an LDNS_RDF_TYPE_LOC rdata element to string format and adds it to the output buffer
383 * \param[in] *rdf The rdata to convert
384 * \param[in] *output The buffer to add the data to
385 * \return LDNS_STATUS_OK on success, and error status on failure
387 ldns_status ldns_rdf2buffer_str_loc(ldns_buffer *output, const ldns_rdf *rdf);
390 * Converts an LDNS_RDF_TYPE_UNKNOWN rdata element to string format and adds it to the output buffer
391 * \param[in] *rdf The rdata to convert
392 * \param[in] *output The buffer to add the data to
393 * \return LDNS_STATUS_OK on success, and error status on failure
395 ldns_status ldns_rdf2buffer_str_unknown(ldns_buffer *output, const ldns_rdf *rdf);
398 * Converts an LDNS_RDF_TYPE_NSAP rdata element to string format and adds it to the output buffer
399 * \param[in] *rdf The rdata to convert
400 * \param[in] *output The buffer to add the data to
401 * \return LDNS_STATUS_OK on success, and error status on failure
403 ldns_status ldns_rdf2buffer_str_nsap(ldns_buffer *output, const ldns_rdf *rdf);
406 * Converts an LDNS_RDF_TYPE_ATMA rdata element to string format and adds it to the output buffer
407 * \param[in] *rdf The rdata to convert
408 * \param[in] *output The buffer to add the data to
409 * \return LDNS_STATUS_OK on success, and error status on failure
411 ldns_status ldns_rdf2buffer_str_atma(ldns_buffer *output, const ldns_rdf *rdf);
414 * Converts an LDNS_RDF_TYPE_WKS rdata element to string format and adds it to the output buffer
415 * \param[in] *rdf The rdata to convert
416 * \param[in] *output The buffer to add the data to
417 * \return LDNS_STATUS_OK on success, and error status on failure
419 ldns_status ldns_rdf2buffer_str_wks(ldns_buffer *output, const ldns_rdf *rdf);
422 * Converts an LDNS_RDF_TYPE_NSEC rdata element to string format and adds it to the output buffer
423 * \param[in] *rdf The rdata to convert
424 * \param[in] *output The buffer to add the data to
425 * \return LDNS_STATUS_OK on success, and error status on failure
427 ldns_status ldns_rdf2buffer_str_nsec(ldns_buffer *output, const ldns_rdf *rdf);
430 * Converts an LDNS_RDF_TYPE_PERIOD rdata element to string format and adds it to the output buffer
431 * \param[in] *rdf The rdata to convert
432 * \param[in] *output The buffer to add the data to
433 * \return LDNS_STATUS_OK on success, and error status on failure
435 ldns_status ldns_rdf2buffer_str_period(ldns_buffer *output, const ldns_rdf *rdf);
438 * Converts an LDNS_RDF_TYPE_TSIGTIME rdata element to string format and adds it to the output buffer
439 * \param[in] *rdf The rdata to convert
440 * \param[in] *output The buffer to add the data to
441 * \return LDNS_STATUS_OK on success, and error status on failure
443 ldns_status ldns_rdf2buffer_str_tsigtime(ldns_buffer *output, const ldns_rdf *rdf);
446 * Converts an LDNS_RDF_TYPE_APL rdata element to string format and adds it to the output buffer
447 * \param[in] *rdf The rdata to convert
448 * \param[in] *output The buffer to add the data to
449 * \return LDNS_STATUS_OK on success, and error status on failure
451 ldns_status ldns_rdf2buffer_str_apl(ldns_buffer *output, const ldns_rdf *rdf);
454 * Converts an LDNS_RDF_TYPE_INT16_DATA rdata element to string format and adds it to the output buffer
455 * \param[in] *rdf The rdata to convert
456 * \param[in] *output The buffer to add the data to
457 * \return LDNS_STATUS_OK on success, and error status on failure
459 ldns_status ldns_rdf2buffer_str_int16_data(ldns_buffer *output, const ldns_rdf *rdf);
462 * Converts an LDNS_RDF_TYPE_IPSECKEY rdata element to string format and adds it to the output buffer
463 * \param[in] *rdf The rdata to convert
464 * \param[in] *output The buffer to add the data to
465 * \return LDNS_STATUS_OK on success, and error status on failure
467 ldns_status ldns_rdf2buffer_str_ipseckey(ldns_buffer *output, const ldns_rdf *rdf);
470 * Converts the data in the rdata field to presentation
471 * format (as char *) and appends it to the given buffer
473 * \param[in] output pointer to the buffer to append the data to
474 * \param[in] rdf the pointer to the rdafa field containing the data
477 ldns_status ldns_rdf2buffer_str(ldns_buffer *output, const ldns_rdf *rdf);
480 * Converts the data in the resource record to presentation
481 * format (as char *) and appends it to the given buffer.
482 * The presentation format of DNSKEY record is annotated with comments giving
483 * the id, type and size of the key.
485 * \param[in] output pointer to the buffer to append the data to
486 * \param[in] rr the pointer to the rr field to convert
489 ldns_status ldns_rr2buffer_str(ldns_buffer *output, const ldns_rr *rr);
492 * Converts the data in the resource record to presentation
493 * format (as char *) and appends it to the given buffer.
494 * The presentation format is annotated with comments giving
495 * additional information on the record.
497 * \param[in] output pointer to the buffer to append the data to
498 * \param[in] fmt how to format the textual representation of the
500 * \param[in] rr the pointer to the rr field to convert
503 ldns_status ldns_rr2buffer_str_fmt(ldns_buffer *output,
504 const ldns_output_format *fmt, const ldns_rr *rr);
507 * Converts the data in the DNS packet to presentation
508 * format (as char *) and appends it to the given buffer
510 * \param[in] output pointer to the buffer to append the data to
511 * \param[in] pkt the pointer to the packet to convert
514 ldns_status ldns_pkt2buffer_str(ldns_buffer *output, const ldns_pkt *pkt);
517 * Converts the data in the DNS packet to presentation
518 * format (as char *) and appends it to the given buffer
520 * \param[in] output pointer to the buffer to append the data to
521 * \param[in] fmt how to format the textual representation of the packet
522 * \param[in] pkt the pointer to the packet to convert
525 ldns_status ldns_pkt2buffer_str_fmt(ldns_buffer *output,
526 const ldns_output_format *fmt, const ldns_pkt *pkt);
529 * Converts an LDNS_RDF_TYPE_NSEC3_SALT rdata element to string format and adds it to the output buffer
530 * \param[in] *rdf The rdata to convert
531 * \param[in] *output The buffer to add the data to
532 * \return LDNS_STATUS_OK on success, and error status on failure
534 ldns_status ldns_rdf2buffer_str_nsec3_salt(ldns_buffer *output, const ldns_rdf *rdf);
538 * Converts the data in the DNS packet to presentation
539 * format (as char *) and appends it to the given buffer
541 * \param[in] output pointer to the buffer to append the data to
542 * \param[in] k the pointer to the private key to convert
545 ldns_status ldns_key2buffer_str(ldns_buffer *output, const ldns_key *k);
548 * Converts an LDNS_RDF_TYPE_INT8 rdata element to string format and adds it to the output buffer
549 * \param[in] *rdf The rdata to convert
550 * \param[in] *output The buffer to add the data to
551 * \return LDNS_STATUS_OK on success, and error status on failure
553 ldns_status ldns_rdf2buffer_str_int8(ldns_buffer *output, const ldns_rdf *rdf);
556 * Converts an LDNS_RDF_TYPE_INT16 rdata element to string format and adds it to the output buffer
557 * \param[in] *rdf The rdata to convert
558 * \param[in] *output The buffer to add the data to
559 * \return LDNS_STATUS_OK on success, and error status on failure
561 ldns_status ldns_rdf2buffer_str_int16(ldns_buffer *output, const ldns_rdf *rdf);
564 * Converts an LDNS_RDF_TYPE_INT32 rdata element to string format and adds it to the output buffer
565 * \param[in] *rdf The rdata to convert
566 * \param[in] *output The buffer to add the data to
567 * \return LDNS_STATUS_OK on success, and error status on failure
569 ldns_status ldns_rdf2buffer_str_int32(ldns_buffer *output, const ldns_rdf *rdf);
572 * Converts an LDNS_RDF_TYPE_TIME rdata element to string format and adds it to the output buffer
573 * \param[in] *rdf The rdata to convert
574 * \param[in] *output The buffer to add the data to
575 * \return LDNS_STATUS_OK on success, and error status on failure
577 ldns_status ldns_rdf2buffer_str_time(ldns_buffer *output, const ldns_rdf *rdf);
580 * Converts an LDNS_RDF_TYPE_ILNP64 rdata element to 4 hexadecimal numbers
581 * separated by colons and adds it to the output buffer
582 * \param[in] *rdf The rdata to convert
583 * \param[in] *output The buffer to add the data to
584 * \return LDNS_STATUS_OK on success, and error status on failure
586 ldns_status ldns_rdf2buffer_str_ilnp64(ldns_buffer *output,
587 const ldns_rdf *rdf);
590 * Converts an LDNS_RDF_TYPE_EUI48 rdata element to 6 hexadecimal numbers
591 * separated by dashes and adds it to the output buffer
592 * \param[in] *rdf The rdata to convert
593 * \param[in] *output The buffer to add the data to
594 * \return LDNS_STATUS_OK on success, and error status on failure
596 ldns_status ldns_rdf2buffer_str_eui48(ldns_buffer *output,
597 const ldns_rdf *rdf);
600 * Converts an LDNS_RDF_TYPE_EUI64 rdata element to 8 hexadecimal numbers
601 * separated by dashes and adds it to the output buffer
602 * \param[in] *rdf The rdata to convert
603 * \param[in] *output The buffer to add the data to
604 * \return LDNS_STATUS_OK on success, and error status on failure
606 ldns_status ldns_rdf2buffer_str_eui64(ldns_buffer *output,
607 const ldns_rdf *rdf);
610 * Adds the LDNS_RDF_TYPE_TAG rdata to the output buffer,
611 * provided it contains only alphanumeric characters.
612 * \param[in] *rdf The rdata to convert
613 * \param[in] *output The buffer to add the data to
614 * \return LDNS_STATUS_OK on success, and error status on failure
616 ldns_status ldns_rdf2buffer_str_tag(ldns_buffer *output,
617 const ldns_rdf *rdf);
620 * Adds the LDNS_RDF_TYPE_LONG_STR rdata to the output buffer, in-between
621 * double quotes and all non printable characters properly escaped.
622 * \param[in] *rdf The rdata to convert
623 * \param[in] *output The buffer to add the data to
624 * \return LDNS_STATUS_OK on success, and error status on failure
626 ldns_status ldns_rdf2buffer_str_long_str(ldns_buffer *output,
627 const ldns_rdf *rdf);
630 * Converts an LDNS_RDF_TYPE_HIP rdata element to presentation format for
631 * the algorithm, HIT and Public Key and adds it the output buffer .
632 * \param[in] *rdf The rdata to convert
633 * \param[in] *output The buffer to add the data to
634 * \return LDNS_STATUS_OK on success, and error status on failure
636 ldns_status ldns_rdf2buffer_str_hip(ldns_buffer *output,
637 const ldns_rdf *rdf);
640 * Converts the data in the rdata field to presentation format and
641 * returns that as a char *.
642 * Remember to free it.
644 * \param[in] rdf The rdata field to convert
645 * \return null terminated char * data, or NULL on error
647 char *ldns_rdf2str(const ldns_rdf *rdf);
650 * Converts the data in the resource record to presentation format and
651 * returns that as a char *.
652 * Remember to free it.
654 * \param[in] rr The rdata field to convert
655 * \return null terminated char * data, or NULL on error
657 char *ldns_rr2str(const ldns_rr *rr);
660 * Converts the data in the resource record to presentation format and
661 * returns that as a char *.
662 * Remember to free it.
664 * \param[in] fmt how to format the resource record
665 * \param[in] rr The rdata field to convert
666 * \return null terminated char * data, or NULL on error
668 char *ldns_rr2str_fmt(const ldns_output_format *fmt, const ldns_rr *rr);
671 * Converts the data in the DNS packet to presentation format and
672 * returns that as a char *.
673 * Remember to free it.
675 * \param[in] pkt The rdata field to convert
676 * \return null terminated char * data, or NULL on error
678 char *ldns_pkt2str(const ldns_pkt *pkt);
681 * Converts the data in the DNS packet to presentation format and
682 * returns that as a char *.
683 * Remember to free it.
685 * \param[in] fmt how to format the packet
686 * \param[in] pkt The rdata field to convert
687 * \return null terminated char * data, or NULL on error
689 char *ldns_pkt2str_fmt(const ldns_output_format *fmt, const ldns_pkt *pkt);
692 * Converts a private key to the test presentation fmt and
693 * returns that as a char *.
694 * Remember to free it.
696 * \param[in] k the key to convert to text
697 * \return null terminated char * data, or NULL on error
699 char *ldns_key2str(const ldns_key *k);
702 * Converts a list of resource records to presentation format
703 * and returns that as a char *.
704 * Remember to free it.
706 * \param[in] rr_list the rr_list to convert to text
707 * \return null terminated char * data, or NULL on error
709 char *ldns_rr_list2str(const ldns_rr_list *rr_list);
712 * Converts a list of resource records to presentation format
713 * and returns that as a char *.
714 * Remember to free it.
716 * \param[in] fmt how to format the list of resource records
717 * \param[in] rr_list the rr_list to convert to text
718 * \return null terminated char * data, or NULL on error
720 char *ldns_rr_list2str_fmt(
721 const ldns_output_format *fmt, const ldns_rr_list *rr_list);
724 * Returns a copy of the data in the buffer as a null terminated
725 * char * string. The returned string must be freed by the caller.
726 * The buffer must be in write modus and may thus not have been flipped.
728 * \param[in] buffer buffer containing char * data
729 * \return null terminated char * data, or NULL on error
731 char *ldns_buffer2str(ldns_buffer *buffer);
734 * Exports and returns the data in the buffer as a null terminated
735 * char * string. The returned string must be freed by the caller.
736 * The buffer must be in write modus and may thus not have been flipped.
737 * The buffer is fixed after this function returns.
739 * \param[in] buffer buffer containing char * data
740 * \return null terminated char * data, or NULL on error
742 char *ldns_buffer_export2str(ldns_buffer *buffer);
745 * Prints the data in the rdata field to the given file stream
746 * (in presentation format)
748 * \param[in] output the file stream to print to
749 * \param[in] rdf the rdata field to print
752 void ldns_rdf_print(FILE *output, const ldns_rdf *rdf);
755 * Prints the data in the resource record to the given file stream
756 * (in presentation format)
758 * \param[in] output the file stream to print to
759 * \param[in] rr the resource record to print
762 void ldns_rr_print(FILE *output, const ldns_rr *rr);
765 * Prints the data in the resource record to the given file stream
766 * (in presentation format)
768 * \param[in] output the file stream to print to
769 * \param[in] fmt format of the textual representation
770 * \param[in] rr the resource record to print
773 void ldns_rr_print_fmt(FILE *output,
774 const ldns_output_format *fmt, const ldns_rr *rr);
777 * Prints the data in the DNS packet to the given file stream
778 * (in presentation format)
780 * \param[in] output the file stream to print to
781 * \param[in] pkt the packet to print
784 void ldns_pkt_print(FILE *output, const ldns_pkt *pkt);
787 * Prints the data in the DNS packet to the given file stream
788 * (in presentation format)
790 * \param[in] output the file stream to print to
791 * \param[in] fmt format of the textual representation
792 * \param[in] pkt the packet to print
795 void ldns_pkt_print_fmt(FILE *output,
796 const ldns_output_format *fmt, const ldns_pkt *pkt);
799 * Converts a rr_list to presentation format and appends it to
801 * \param[in] output the buffer to append output to
802 * \param[in] list the ldns_rr_list to print
803 * \return ldns_status
805 ldns_status ldns_rr_list2buffer_str(ldns_buffer *output, const ldns_rr_list *list);
808 * Converts a rr_list to presentation format and appends it to
810 * \param[in] output the buffer to append output to
811 * \param[in] fmt format of the textual representation
812 * \param[in] list the ldns_rr_list to print
813 * \return ldns_status
815 ldns_status ldns_rr_list2buffer_str_fmt(ldns_buffer *output,
816 const ldns_output_format *fmt, const ldns_rr_list *list);
819 * Converts the header of a packet to presentation format and appends it to
821 * \param[in] output the buffer to append output to
822 * \param[in] pkt the packet to convert the header of
823 * \return ldns_status
825 ldns_status ldns_pktheader2buffer_str(ldns_buffer *output, const ldns_pkt *pkt);
828 * print a rr_list to output
829 * \param[in] output the fd to print to
830 * \param[in] list the rr_list to print
832 void ldns_rr_list_print(FILE *output, const ldns_rr_list *list);
835 * print a rr_list to output
836 * \param[in] output the fd to print to
837 * \param[in] fmt format of the textual representation
838 * \param[in] list the rr_list to print
840 void ldns_rr_list_print_fmt(FILE *output,
841 const ldns_output_format *fmt, const ldns_rr_list *list);
844 * Print a resolver (in sofar that is possible) state
846 * \param[in] output the fd to print to
847 * \param[in] r the resolver to print
849 void ldns_resolver_print(FILE *output, const ldns_resolver *r);
852 * Print a resolver (in sofar that is possible) state
854 * \param[in] output the fd to print to
855 * \param[in] fmt format of the textual representation
856 * \param[in] r the resolver to print
858 void ldns_resolver_print_fmt(FILE *output,
859 const ldns_output_format *fmt, const ldns_resolver *r);
862 * Print a zone structure * to output. Note the SOA record
863 * is included in this output
864 * \param[in] output the fd to print to
865 * \param[in] z the zone to print
867 void ldns_zone_print(FILE *output, const ldns_zone *z);
870 * Print a zone structure * to output. Note the SOA record
871 * is included in this output
872 * \param[in] output the fd to print to
873 * \param[in] fmt format of the textual representation
874 * \param[in] z the zone to print
876 void ldns_zone_print_fmt(FILE *output,
877 const ldns_output_format *fmt, const ldns_zone *z);
880 * Print the ldns_rdf containing a dname to the buffer
881 * \param[in] output the buffer to print to
882 * \param[in] dname the dname to print
883 * \return ldns_status message if the printing succeeded
885 ldns_status ldns_rdf2buffer_str_dname(ldns_buffer *output, const ldns_rdf *dname);
891 #endif /* LDNS_HOST2STR_H */