xref: /dragonfly/contrib/ldns/ldns/host2str.h (revision ee791feb)
1825eb42bSJan Lentfer /**
2825eb42bSJan Lentfer  * host2str.h -  txt presentation of RRs
3825eb42bSJan Lentfer  *
4825eb42bSJan Lentfer  * a Net::DNS like library for C
5825eb42bSJan Lentfer  *
6825eb42bSJan Lentfer  * (c) NLnet Labs, 2005-2006
7825eb42bSJan Lentfer  *
8825eb42bSJan Lentfer  * See the file LICENSE for the license
9825eb42bSJan Lentfer  */
10825eb42bSJan Lentfer 
11825eb42bSJan Lentfer /**
12825eb42bSJan Lentfer  * \file
13825eb42bSJan Lentfer  *
14825eb42bSJan Lentfer  * Contains functions to translate the main structures to their text
15825eb42bSJan Lentfer  * representation, as well as functions to print them.
16825eb42bSJan Lentfer  */
17825eb42bSJan Lentfer 
18825eb42bSJan Lentfer #ifndef LDNS_HOST2STR_H
19825eb42bSJan Lentfer #define LDNS_HOST2STR_H
20825eb42bSJan Lentfer 
21825eb42bSJan Lentfer #include <ldns/common.h>
22825eb42bSJan Lentfer #include <ldns/error.h>
23825eb42bSJan Lentfer #include <ldns/rr.h>
24825eb42bSJan Lentfer #include <ldns/rdata.h>
25825eb42bSJan Lentfer #include <ldns/packet.h>
26825eb42bSJan Lentfer #include <ldns/buffer.h>
27825eb42bSJan Lentfer #include <ldns/resolver.h>
28825eb42bSJan Lentfer #include <ldns/zone.h>
29825eb42bSJan Lentfer #include <ctype.h>
30825eb42bSJan Lentfer 
31825eb42bSJan Lentfer #include "ldns/util.h"
32825eb42bSJan Lentfer 
33ac996e71SJan Lentfer #ifdef __cplusplus
34ac996e71SJan Lentfer extern "C" {
35ac996e71SJan Lentfer #endif
36ac996e71SJan Lentfer 
37825eb42bSJan Lentfer #define LDNS_APL_IP4            1
38825eb42bSJan Lentfer #define LDNS_APL_IP6            2
39825eb42bSJan Lentfer #define LDNS_APL_MASK           0x7f
40825eb42bSJan Lentfer #define LDNS_APL_NEGATION       0x80
41825eb42bSJan Lentfer 
42825eb42bSJan Lentfer /**
43b5dedccaSJan Lentfer  * Represent a NULL pointer (instead of a pointer to a ldns_rr as "; (null)"
44b5dedccaSJan Lentfer  * as opposed to outputting nothing at all in such a case.
45b5dedccaSJan Lentfer  */
465340022aSzrj /*	Flag Name			Flag Nr.	Has data associated
475340022aSzrj 	---------------------------------------------------------------------*/
485340022aSzrj #define LDNS_COMMENT_NULLS		(1 <<  0)
49b5dedccaSJan Lentfer /** Show key id with DNSKEY RR's as comment */
505340022aSzrj #define LDNS_COMMENT_KEY_ID		(1 <<  1)
51b5dedccaSJan Lentfer /** Show if a DNSKEY is a ZSK or KSK as comment */
525340022aSzrj #define LDNS_COMMENT_KEY_TYPE		(1 <<  2)
53b5dedccaSJan Lentfer /** Show DNSKEY key size as comment */
545340022aSzrj #define LDNS_COMMENT_KEY_SIZE		(1 <<  3)
555340022aSzrj /** Provide bubblebabble representation for DS RR's as comment */
565340022aSzrj #define LDNS_COMMENT_BUBBLEBABBLE	(1 <<  4)
575340022aSzrj /** Show when a NSEC3 RR has the optout flag set as comment */
585340022aSzrj #define LDNS_COMMENT_FLAGS		(1 <<  5)
595340022aSzrj /** Show the unhashed owner and next owner names for NSEC3 RR's as comment */
605340022aSzrj #define LDNS_COMMENT_NSEC3_CHAIN	(1 <<  6)	/* yes */
615340022aSzrj /** Print mark up */
625340022aSzrj #define LDNS_COMMENT_LAYOUT		(1 <<  7)
635340022aSzrj /** Also comment KEY_ID with RRSIGS **/
645340022aSzrj #define LDNS_COMMENT_RRSIGS		(1 <<  8)
655340022aSzrj #define LDNS_FMT_ZEROIZE_RRSIGS		(1 <<  9)
665340022aSzrj #define LDNS_FMT_PAD_SOA_SERIAL		(1 << 10)
675340022aSzrj #define LDNS_FMT_RFC3597		(1 << 11)	/* yes */
68*ee791febSAntonio Huete Jimenez /** Prints only answer section of packets and only rdata of RRs **/
69*ee791febSAntonio Huete Jimenez #define LDNS_FMT_SHORT			(1 << 12)
705340022aSzrj 
715340022aSzrj #define LDNS_FMT_FLAGS_WITH_DATA			    2
725340022aSzrj 
73b5dedccaSJan Lentfer /** Show key id, type and size as comment for DNSKEY RR's */
74b5dedccaSJan Lentfer #define LDNS_COMMENT_KEY		(LDNS_COMMENT_KEY_ID  \
75b5dedccaSJan Lentfer 					|LDNS_COMMENT_KEY_TYPE\
76b5dedccaSJan Lentfer 					|LDNS_COMMENT_KEY_SIZE)
77b5dedccaSJan Lentfer 
78b5dedccaSJan Lentfer /**
79b5dedccaSJan Lentfer  * Output format specifier
80b5dedccaSJan Lentfer  *
81*ee791febSAntonio Huete Jimenez  * Determines how Packets, Resource Records and Resource record data field are
82b5dedccaSJan Lentfer  * formatted when printing or converting to string.
83b5dedccaSJan Lentfer  * Currently it is only used to specify what aspects of a Resource Record are
84b5dedccaSJan Lentfer  * annotated in the comment section of the textual representation the record.
85*ee791febSAntonio Huete Jimenez  * This is specified with flags and potential extra data (such as for example
86b5dedccaSJan Lentfer  * a lookup map of hashes to real names for annotation NSEC3 records).
87b5dedccaSJan Lentfer  */
88b5dedccaSJan Lentfer struct ldns_struct_output_format
89b5dedccaSJan Lentfer {
90b5dedccaSJan Lentfer 	/** Specification of how RR's should be formatted in text */
91b5dedccaSJan Lentfer 	int   flags;
92b5dedccaSJan Lentfer 	/** Potential extra data to be used with formatting RR's in text */
93b5dedccaSJan Lentfer 	void *data;
94b5dedccaSJan Lentfer };
95b5dedccaSJan Lentfer typedef struct ldns_struct_output_format ldns_output_format;
96b5dedccaSJan Lentfer 
97b5dedccaSJan Lentfer /**
985340022aSzrj  * Output format struct with additional data for flags that use them.
995340022aSzrj  * This struct may not be initialized directly. Use ldns_output_format_init
1005340022aSzrj  * to initialize.
1015340022aSzrj  */
1025340022aSzrj struct ldns_struct_output_format_storage
1035340022aSzrj {	int   flags;
1045340022aSzrj 	ldns_rbtree_t* hashmap;    /* for LDNS_COMMENT_NSEC3_CHAIN */
1055340022aSzrj 	ldns_rdf*      bitmap;     /* for LDNS_FMT_RFC3597     */
1065340022aSzrj };
1075340022aSzrj typedef struct ldns_struct_output_format_storage ldns_output_format_storage;
1085340022aSzrj 
1095340022aSzrj /**
110b5dedccaSJan Lentfer  * Standard output format record that disables commenting in the textual
111b5dedccaSJan Lentfer  * representation of Resource Records completely.
112b5dedccaSJan Lentfer  */
113b5dedccaSJan Lentfer extern const ldns_output_format *ldns_output_format_nocomments;
114b5dedccaSJan Lentfer /**
115*ee791febSAntonio Huete Jimenez  * Standard output format record that annotated only DNSKEY RR's with comment
116b5dedccaSJan Lentfer  * text.
117b5dedccaSJan Lentfer  */
118b5dedccaSJan Lentfer extern const ldns_output_format *ldns_output_format_onlykeyids;
119b5dedccaSJan Lentfer /**
120b5dedccaSJan Lentfer  * The default output format record. Same as ldns_output_format_onlykeyids.
121b5dedccaSJan Lentfer  */
122b5dedccaSJan Lentfer extern const ldns_output_format *ldns_output_format_default;
123b5dedccaSJan Lentfer /**
124b5dedccaSJan Lentfer  * Standard output format record that shows all DNSKEY related information in
125b5dedccaSJan Lentfer  * the comment text, plus the optout flag when set with NSEC3's, plus the
126b5dedccaSJan Lentfer  * bubblebabble representation of DS RR's.
127b5dedccaSJan Lentfer  */
128b5dedccaSJan Lentfer extern const ldns_output_format *ldns_output_format_bubblebabble;
129b5dedccaSJan Lentfer 
130b5dedccaSJan Lentfer /**
1315340022aSzrj  * Initialize output format storage to the default value.
1325340022aSzrj  * \param[in] fmt A reference to an output_format_ storage struct
1335340022aSzrj  * \return The initialized storage struct typecasted to ldns_output_format
1345340022aSzrj  */
1355340022aSzrj INLINE
ldns_output_format_init(ldns_output_format_storage * fmt)1365340022aSzrj ldns_output_format* ldns_output_format_init(ldns_output_format_storage* fmt) {
1375340022aSzrj 	fmt->flags   = ldns_output_format_default->flags;
1385340022aSzrj 	fmt->hashmap = NULL;
1395340022aSzrj 	fmt->bitmap  = NULL;
1405340022aSzrj 	return (ldns_output_format*)fmt;
1415340022aSzrj }
1425340022aSzrj 
1435340022aSzrj /**
1445340022aSzrj  * Set an output format flag.
1455340022aSzrj  */
ldns_output_format_set(ldns_output_format * fmt,int flag)1465340022aSzrj INLINE void ldns_output_format_set(ldns_output_format* fmt, int flag) {
1475340022aSzrj         fmt->flags |= flag;
1485340022aSzrj }
1495340022aSzrj 
1505340022aSzrj /**
1515340022aSzrj  * Clear an output format flag.
1525340022aSzrj  */
ldns_output_format_clear(ldns_output_format * fmt,int flag)1535340022aSzrj INLINE void ldns_output_format_clear(ldns_output_format* fmt, int flag) {
1545340022aSzrj         fmt->flags &= !flag;
1555340022aSzrj }
1565340022aSzrj 
1575340022aSzrj /**
1585340022aSzrj  * Makes sure the LDNS_FMT_RFC3597 is set in the output format.
1595340022aSzrj  * Marks the type to be printed in RFC3597 format.
1605340022aSzrj  * /param[in] fmt the output format to update
1615340022aSzrj  * /param[in] the type to be printed in RFC3597 format
1625340022aSzrj  * /return LDNS_STATUS_OK on success
1635340022aSzrj  */
1645340022aSzrj ldns_status
1655340022aSzrj ldns_output_format_set_type(ldns_output_format* fmt, ldns_rr_type type);
1665340022aSzrj 
1675340022aSzrj /**
1685340022aSzrj  * Makes sure the LDNS_FMT_RFC3597 is set in the output format.
1695340022aSzrj  * Marks the type to not be printed in RFC3597 format. When no other types
1705340022aSzrj  * have been marked before, all known types (except the given one) will be
1715340022aSzrj  * marked for printing in RFC3597 format.
1725340022aSzrj  * /param[in] fmt the output format to update
1735340022aSzrj  * /param[in] the type not to be printed in RFC3597 format
1745340022aSzrj  * /return LDNS_STATUS_OK on success
1755340022aSzrj  */
1765340022aSzrj ldns_status
1775340022aSzrj ldns_output_format_clear_type(ldns_output_format* fmt, ldns_rr_type type);
1785340022aSzrj 
1795340022aSzrj /**
180825eb42bSJan Lentfer  * Converts an ldns packet opcode value to its mnemonic, and adds that
181825eb42bSJan Lentfer  * to the output buffer
182825eb42bSJan Lentfer  * \param[in] *output the buffer to add the data to
183825eb42bSJan Lentfer  * \param[in] opcode to find the string representation of
184825eb42bSJan Lentfer  * \return LDNS_STATUS_OK on success, or a buffer failure mode on error
185825eb42bSJan Lentfer  */
186825eb42bSJan Lentfer ldns_status
187825eb42bSJan Lentfer ldns_pkt_opcode2buffer_str(ldns_buffer *output, ldns_pkt_opcode opcode);
188825eb42bSJan Lentfer 
189825eb42bSJan Lentfer /**
190825eb42bSJan Lentfer  * Converts an ldns packet rcode value to its mnemonic, and adds that
191825eb42bSJan Lentfer  * to the output buffer
192825eb42bSJan Lentfer  * \param[in] *output the buffer to add the data to
193825eb42bSJan Lentfer  * \param[in] rcode to find the string representation of
194825eb42bSJan Lentfer  * \return LDNS_STATUS_OK on success, or a buffer failure mode on error
195825eb42bSJan Lentfer  */
196825eb42bSJan Lentfer ldns_status
197825eb42bSJan Lentfer ldns_pkt_rcode2buffer_str(ldns_buffer *output, ldns_pkt_rcode rcode);
198825eb42bSJan Lentfer 
199825eb42bSJan Lentfer /**
200825eb42bSJan Lentfer  * Converts an ldns algorithm type to its mnemonic, and adds that
201825eb42bSJan Lentfer  * to the output buffer
202825eb42bSJan Lentfer  * \param[in] *output the buffer to add the data to
203825eb42bSJan Lentfer  * \param[in] algorithm to find the string representation of
204825eb42bSJan Lentfer  * \return LDNS_STATUS_OK on success, or a buffer failure mode on error
205825eb42bSJan Lentfer  */
206825eb42bSJan Lentfer ldns_status
207825eb42bSJan Lentfer ldns_algorithm2buffer_str(ldns_buffer *output,
208825eb42bSJan Lentfer                           ldns_algorithm algorithm);
209825eb42bSJan Lentfer 
210825eb42bSJan Lentfer /**
211825eb42bSJan Lentfer  * Converts an ldns certificate algorithm type to its mnemonic,
212825eb42bSJan Lentfer  * and adds that to the output buffer
213825eb42bSJan Lentfer  * \param[in] *output the buffer to add the data to
214825eb42bSJan Lentfer  * \param[in] cert_algorithm to find the string representation of
215825eb42bSJan Lentfer  * \return LDNS_STATUS_OK on success, or a buffer failure mode on error
216825eb42bSJan Lentfer  */
217825eb42bSJan Lentfer ldns_status
218825eb42bSJan Lentfer ldns_cert_algorithm2buffer_str(ldns_buffer *output,
219825eb42bSJan Lentfer                                ldns_cert_algorithm cert_algorithm);
220825eb42bSJan Lentfer 
221825eb42bSJan Lentfer 
222825eb42bSJan Lentfer /**
223825eb42bSJan Lentfer  * Converts a packet opcode to its mnemonic and returns that as
224825eb42bSJan Lentfer  * an allocated null-terminated string.
225825eb42bSJan Lentfer  * Remember to free it.
226825eb42bSJan Lentfer  *
227825eb42bSJan Lentfer  * \param[in] opcode the opcode to convert to text
228825eb42bSJan Lentfer  * \return null terminated char * data, or NULL on error
229825eb42bSJan Lentfer  */
230825eb42bSJan Lentfer char *ldns_pkt_opcode2str(ldns_pkt_opcode opcode);
231825eb42bSJan Lentfer 
232825eb42bSJan Lentfer /**
233825eb42bSJan Lentfer  * Converts a packet rcode to its mnemonic and returns that as
234825eb42bSJan Lentfer  * an allocated null-terminated string.
235825eb42bSJan Lentfer  * Remember to free it.
236825eb42bSJan Lentfer  *
237825eb42bSJan Lentfer  * \param[in] rcode the rcode to convert to text
238825eb42bSJan Lentfer  * \return null terminated char * data, or NULL on error
239825eb42bSJan Lentfer  */
240825eb42bSJan Lentfer char *ldns_pkt_rcode2str(ldns_pkt_rcode rcode);
241825eb42bSJan Lentfer 
242825eb42bSJan Lentfer /**
243825eb42bSJan Lentfer  * Converts a signing algorithms to its mnemonic and returns that as
244825eb42bSJan Lentfer  * an allocated null-terminated string.
245825eb42bSJan Lentfer  * Remember to free it.
246825eb42bSJan Lentfer  *
247825eb42bSJan Lentfer  * \param[in] algorithm the algorithm to convert to text
248825eb42bSJan Lentfer  * \return null terminated char * data, or NULL on error
249825eb42bSJan Lentfer  */
250825eb42bSJan Lentfer char *ldns_pkt_algorithm2str(ldns_algorithm algorithm);
251825eb42bSJan Lentfer 
252825eb42bSJan Lentfer /**
253825eb42bSJan Lentfer  * Converts a cert algorithm to its mnemonic and returns that as
254825eb42bSJan Lentfer  * an allocated null-terminated string.
255825eb42bSJan Lentfer  * Remember to free it.
256825eb42bSJan Lentfer  *
257825eb42bSJan Lentfer  * \param[in] cert_algorithm to convert to text
258825eb42bSJan Lentfer  * \return null terminated char * data, or NULL on error
259825eb42bSJan Lentfer  */
260825eb42bSJan Lentfer char *ldns_pkt_cert_algorithm2str(ldns_cert_algorithm cert_algorithm);
261825eb42bSJan Lentfer 
262825eb42bSJan Lentfer /**
263825eb42bSJan Lentfer  * Converts an LDNS_RDF_TYPE_A rdata element to string format and adds it to the output buffer
264825eb42bSJan Lentfer  * \param[in] *rdf The rdata to convert
265825eb42bSJan Lentfer  * \param[in] *output The buffer to add the data to
266825eb42bSJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
267825eb42bSJan Lentfer  */
268825eb42bSJan Lentfer ldns_status ldns_rdf2buffer_str_a(ldns_buffer *output, const ldns_rdf *rdf);
269825eb42bSJan Lentfer 
270825eb42bSJan Lentfer /**
271825eb42bSJan Lentfer  * Converts an LDNS_RDF_TYPE_AAAA rdata element to string format and adds it to the output buffer
272825eb42bSJan Lentfer  * \param[in] *rdf The rdata to convert
273825eb42bSJan Lentfer  * \param[in] *output The buffer to add the data to
274825eb42bSJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
275825eb42bSJan Lentfer  */
276825eb42bSJan Lentfer ldns_status ldns_rdf2buffer_str_aaaa(ldns_buffer *output, const ldns_rdf *rdf);
277825eb42bSJan Lentfer 
278825eb42bSJan Lentfer /**
279825eb42bSJan Lentfer  * Converts an LDNS_RDF_TYPE_STR rdata element to string format and adds it to the output buffer
280825eb42bSJan Lentfer  * \param[in] *rdf The rdata to convert
281825eb42bSJan Lentfer  * \param[in] *output The buffer to add the data to
282825eb42bSJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
283825eb42bSJan Lentfer  */
284825eb42bSJan Lentfer ldns_status ldns_rdf2buffer_str_str(ldns_buffer *output, const ldns_rdf *rdf);
285825eb42bSJan Lentfer 
286825eb42bSJan Lentfer /**
287825eb42bSJan Lentfer  * Converts an LDNS_RDF_TYPE_B64 rdata element to string format and adds it to the output buffer
288825eb42bSJan Lentfer  * \param[in] *rdf The rdata to convert
289825eb42bSJan Lentfer  * \param[in] *output The buffer to add the data to
290825eb42bSJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
291825eb42bSJan Lentfer  */
292825eb42bSJan Lentfer ldns_status ldns_rdf2buffer_str_b64(ldns_buffer *output, const ldns_rdf *rdf);
293825eb42bSJan Lentfer 
294825eb42bSJan Lentfer /**
295ac996e71SJan Lentfer  * Converts an LDNS_RDF_TYPE_B32_EXT rdata element to string format and adds it to the output buffer
296ac996e71SJan Lentfer  * \param[in] *rdf The rdata to convert
297ac996e71SJan Lentfer  * \param[in] *output The buffer to add the data to
298ac996e71SJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
299ac996e71SJan Lentfer  */
300ac996e71SJan Lentfer ldns_status ldns_rdf2buffer_str_b32_ext(ldns_buffer *output, const ldns_rdf *rdf);
301ac996e71SJan Lentfer 
302ac996e71SJan Lentfer /**
303825eb42bSJan Lentfer  * Converts an LDNS_RDF_TYPE_HEX rdata element to string format and adds it to the output buffer
304825eb42bSJan Lentfer  * \param[in] *rdf The rdata to convert
305825eb42bSJan Lentfer  * \param[in] *output The buffer to add the data to
306825eb42bSJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
307825eb42bSJan Lentfer  */
308825eb42bSJan Lentfer ldns_status ldns_rdf2buffer_str_hex(ldns_buffer *output, const ldns_rdf *rdf);
309825eb42bSJan Lentfer 
310825eb42bSJan Lentfer /**
311825eb42bSJan Lentfer  * Converts an LDNS_RDF_TYPE_TYPE rdata element to string format and adds it to the output buffer
312825eb42bSJan Lentfer  * \param[in] *rdf The rdata to convert
313825eb42bSJan Lentfer  * \param[in] *output The buffer to add the data to
314825eb42bSJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
315825eb42bSJan Lentfer  */
316825eb42bSJan Lentfer ldns_status ldns_rdf2buffer_str_type(ldns_buffer *output, const ldns_rdf *rdf);
317825eb42bSJan Lentfer 
318825eb42bSJan Lentfer /**
319825eb42bSJan Lentfer  * Converts an LDNS_RDF_TYPE_CLASS rdata element to string format and adds it to the output buffer
320825eb42bSJan Lentfer  * \param[in] *rdf The rdata to convert
321825eb42bSJan Lentfer  * \param[in] *output The buffer to add the data to
322825eb42bSJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
323825eb42bSJan Lentfer  */
324825eb42bSJan Lentfer ldns_status ldns_rdf2buffer_str_class(ldns_buffer *output, const ldns_rdf *rdf);
325825eb42bSJan Lentfer 
326825eb42bSJan Lentfer /**
327825eb42bSJan Lentfer  * Converts an LDNS_RDF_TYPE_ALG rdata element to string format and adds it to the output buffer
328825eb42bSJan Lentfer  * \param[in] *rdf The rdata to convert
329825eb42bSJan Lentfer  * \param[in] *output The buffer to add the data to
330825eb42bSJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
331825eb42bSJan Lentfer  */
332825eb42bSJan Lentfer ldns_status ldns_rdf2buffer_str_alg(ldns_buffer *output, const ldns_rdf *rdf);
333825eb42bSJan Lentfer 
334825eb42bSJan Lentfer /**
335825eb42bSJan Lentfer  * Converts an ldns_rr_type value to its string representation,
336825eb42bSJan Lentfer  * and places it in the given buffer
337825eb42bSJan Lentfer  * \param[in] *output The buffer to add the data to
338825eb42bSJan Lentfer  * \param[in] type the ldns_rr_type to convert
339825eb42bSJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
340825eb42bSJan Lentfer  */
341825eb42bSJan Lentfer ldns_status ldns_rr_type2buffer_str(ldns_buffer *output,
342825eb42bSJan Lentfer                                     const ldns_rr_type type);
343825eb42bSJan Lentfer 
344825eb42bSJan Lentfer /**
345825eb42bSJan Lentfer  * Converts an ldns_rr_type value to its string representation,
346825eb42bSJan Lentfer  * and returns that string. For unknown types, the string
347825eb42bSJan Lentfer  * "TYPE<id>" is returned. This function allocates data that must be
348825eb42bSJan Lentfer  * freed by the caller
349825eb42bSJan Lentfer  * \param[in] type the ldns_rr_type to convert
350825eb42bSJan Lentfer  * \return a newly allocated string
351825eb42bSJan Lentfer  */
352825eb42bSJan Lentfer char *ldns_rr_type2str(const ldns_rr_type type);
353825eb42bSJan Lentfer 
354825eb42bSJan Lentfer /**
355825eb42bSJan Lentfer  * Converts an ldns_rr_class value to its string representation,
356825eb42bSJan Lentfer  * and places it in the given buffer
357825eb42bSJan Lentfer  * \param[in] *output The buffer to add the data to
358825eb42bSJan Lentfer  * \param[in] klass the ldns_rr_class to convert
359825eb42bSJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
360825eb42bSJan Lentfer  */
361825eb42bSJan Lentfer ldns_status ldns_rr_class2buffer_str(ldns_buffer *output,
362825eb42bSJan Lentfer                                      const ldns_rr_class klass);
363825eb42bSJan Lentfer 
364825eb42bSJan Lentfer /**
365825eb42bSJan Lentfer  * Converts an ldns_rr_class value to its string representation,
366825eb42bSJan Lentfer  * and returns that string. For unknown types, the string
367825eb42bSJan Lentfer  * "CLASS<id>" is returned. This function allocates data that must be
368825eb42bSJan Lentfer  * freed by the caller
369825eb42bSJan Lentfer  * \param[in] klass the ldns_rr_class to convert
370825eb42bSJan Lentfer  * \return a newly allocated string
371825eb42bSJan Lentfer  */
372825eb42bSJan Lentfer char *ldns_rr_class2str(const ldns_rr_class klass);
373825eb42bSJan Lentfer 
374825eb42bSJan Lentfer 
375825eb42bSJan Lentfer /**
376825eb42bSJan Lentfer  * Converts an LDNS_RDF_TYPE_CERT rdata element to string format and adds it to the output buffer
377825eb42bSJan Lentfer  * \param[in] *rdf The rdata to convert
378825eb42bSJan Lentfer  * \param[in] *output The buffer to add the data to
379825eb42bSJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
380825eb42bSJan Lentfer  */
381825eb42bSJan Lentfer ldns_status ldns_rdf2buffer_str_cert_alg(ldns_buffer *output, const ldns_rdf *rdf);
382825eb42bSJan Lentfer 
383825eb42bSJan Lentfer /**
384825eb42bSJan Lentfer  * Converts an LDNS_RDF_TYPE_LOC rdata element to string format and adds it to the output buffer
385825eb42bSJan Lentfer  * \param[in] *rdf The rdata to convert
386825eb42bSJan Lentfer  * \param[in] *output The buffer to add the data to
387825eb42bSJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
388825eb42bSJan Lentfer  */
389825eb42bSJan Lentfer ldns_status ldns_rdf2buffer_str_loc(ldns_buffer *output, const ldns_rdf *rdf);
390825eb42bSJan Lentfer 
391825eb42bSJan Lentfer /**
392825eb42bSJan Lentfer  * Converts an LDNS_RDF_TYPE_UNKNOWN rdata element to string format and adds it to the output buffer
393825eb42bSJan Lentfer  * \param[in] *rdf The rdata to convert
394825eb42bSJan Lentfer  * \param[in] *output The buffer to add the data to
395825eb42bSJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
396825eb42bSJan Lentfer  */
397825eb42bSJan Lentfer ldns_status ldns_rdf2buffer_str_unknown(ldns_buffer *output, const ldns_rdf *rdf);
398825eb42bSJan Lentfer 
399825eb42bSJan Lentfer /**
400825eb42bSJan Lentfer  * Converts an LDNS_RDF_TYPE_NSAP rdata element to string format and adds it to the output buffer
401825eb42bSJan Lentfer  * \param[in] *rdf The rdata to convert
402825eb42bSJan Lentfer  * \param[in] *output The buffer to add the data to
403825eb42bSJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
404825eb42bSJan Lentfer  */
405825eb42bSJan Lentfer ldns_status ldns_rdf2buffer_str_nsap(ldns_buffer *output, const ldns_rdf *rdf);
406825eb42bSJan Lentfer 
407825eb42bSJan Lentfer /**
408ac996e71SJan Lentfer  * Converts an LDNS_RDF_TYPE_ATMA rdata element to string format and adds it to the output buffer
409ac996e71SJan Lentfer  * \param[in] *rdf The rdata to convert
410ac996e71SJan Lentfer  * \param[in] *output The buffer to add the data to
411ac996e71SJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
412ac996e71SJan Lentfer  */
413ac996e71SJan Lentfer ldns_status ldns_rdf2buffer_str_atma(ldns_buffer *output, const ldns_rdf *rdf);
414ac996e71SJan Lentfer 
415ac996e71SJan Lentfer /**
416825eb42bSJan Lentfer  * Converts an LDNS_RDF_TYPE_WKS rdata element to string format and adds it to the output buffer
417825eb42bSJan Lentfer  * \param[in] *rdf The rdata to convert
418825eb42bSJan Lentfer  * \param[in] *output The buffer to add the data to
419825eb42bSJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
420825eb42bSJan Lentfer  */
421825eb42bSJan Lentfer ldns_status ldns_rdf2buffer_str_wks(ldns_buffer *output, const ldns_rdf *rdf);
422825eb42bSJan Lentfer 
423825eb42bSJan Lentfer /**
424825eb42bSJan Lentfer  * Converts an LDNS_RDF_TYPE_NSEC rdata element to string format and adds it to the output buffer
425825eb42bSJan Lentfer  * \param[in] *rdf The rdata to convert
426825eb42bSJan Lentfer  * \param[in] *output The buffer to add the data to
427825eb42bSJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
428825eb42bSJan Lentfer  */
429825eb42bSJan Lentfer ldns_status ldns_rdf2buffer_str_nsec(ldns_buffer *output, const ldns_rdf *rdf);
430825eb42bSJan Lentfer 
431825eb42bSJan Lentfer /**
432825eb42bSJan Lentfer  * Converts an LDNS_RDF_TYPE_PERIOD rdata element to string format and adds it to the output buffer
433825eb42bSJan Lentfer  * \param[in] *rdf The rdata to convert
434825eb42bSJan Lentfer  * \param[in] *output The buffer to add the data to
435825eb42bSJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
436825eb42bSJan Lentfer  */
437825eb42bSJan Lentfer ldns_status ldns_rdf2buffer_str_period(ldns_buffer *output, const ldns_rdf *rdf);
438825eb42bSJan Lentfer 
439825eb42bSJan Lentfer /**
440825eb42bSJan Lentfer  * Converts an LDNS_RDF_TYPE_TSIGTIME rdata element to string format and adds it to the output buffer
441825eb42bSJan Lentfer  * \param[in] *rdf The rdata to convert
442825eb42bSJan Lentfer  * \param[in] *output The buffer to add the data to
443825eb42bSJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
444825eb42bSJan Lentfer  */
445825eb42bSJan Lentfer ldns_status ldns_rdf2buffer_str_tsigtime(ldns_buffer *output, const ldns_rdf *rdf);
446825eb42bSJan Lentfer 
447825eb42bSJan Lentfer /**
448825eb42bSJan Lentfer  * Converts an LDNS_RDF_TYPE_APL rdata element to string format and adds it to the output buffer
449825eb42bSJan Lentfer  * \param[in] *rdf The rdata to convert
450825eb42bSJan Lentfer  * \param[in] *output The buffer to add the data to
451825eb42bSJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
452825eb42bSJan Lentfer  */
453825eb42bSJan Lentfer ldns_status ldns_rdf2buffer_str_apl(ldns_buffer *output, const ldns_rdf *rdf);
454825eb42bSJan Lentfer 
455825eb42bSJan Lentfer /**
456825eb42bSJan Lentfer  * Converts an LDNS_RDF_TYPE_INT16_DATA rdata element to string format and adds it to the output buffer
457825eb42bSJan Lentfer  * \param[in] *rdf The rdata to convert
458825eb42bSJan Lentfer  * \param[in] *output The buffer to add the data to
459825eb42bSJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
460825eb42bSJan Lentfer  */
461825eb42bSJan Lentfer ldns_status ldns_rdf2buffer_str_int16_data(ldns_buffer *output, const ldns_rdf *rdf);
462825eb42bSJan Lentfer 
463825eb42bSJan Lentfer /**
464825eb42bSJan Lentfer  * Converts an LDNS_RDF_TYPE_IPSECKEY rdata element to string format and adds it to the output buffer
465825eb42bSJan Lentfer  * \param[in] *rdf The rdata to convert
466825eb42bSJan Lentfer  * \param[in] *output The buffer to add the data to
467825eb42bSJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
468825eb42bSJan Lentfer  */
469825eb42bSJan Lentfer ldns_status ldns_rdf2buffer_str_ipseckey(ldns_buffer *output, const ldns_rdf *rdf);
470825eb42bSJan Lentfer 
471825eb42bSJan Lentfer /**
472825eb42bSJan Lentfer  * Converts the data in the rdata field to presentation
473825eb42bSJan Lentfer  * format (as char *) and appends it to the given buffer
474825eb42bSJan Lentfer  *
475825eb42bSJan Lentfer  * \param[in] output pointer to the buffer to append the data to
476825eb42bSJan Lentfer  * \param[in] rdf the pointer to the rdafa field containing the data
477825eb42bSJan Lentfer  * \return status
478825eb42bSJan Lentfer  */
479825eb42bSJan Lentfer ldns_status ldns_rdf2buffer_str(ldns_buffer *output, const ldns_rdf *rdf);
480825eb42bSJan Lentfer 
481825eb42bSJan Lentfer /**
482825eb42bSJan Lentfer  * Converts the data in the resource record to presentation
483b5dedccaSJan Lentfer  * format (as char *) and appends it to the given buffer.
484b5dedccaSJan Lentfer  * The presentation format of DNSKEY record is annotated with comments giving
485b5dedccaSJan Lentfer  * the id, type and size of the key.
486825eb42bSJan Lentfer  *
487825eb42bSJan Lentfer  * \param[in] output pointer to the buffer to append the data to
488825eb42bSJan Lentfer  * \param[in] rr the pointer to the rr field to convert
489825eb42bSJan Lentfer  * \return status
490825eb42bSJan Lentfer  */
491825eb42bSJan Lentfer ldns_status ldns_rr2buffer_str(ldns_buffer *output, const ldns_rr *rr);
492825eb42bSJan Lentfer 
493825eb42bSJan Lentfer /**
494b5dedccaSJan Lentfer  * Converts the data in the resource record to presentation
495b5dedccaSJan Lentfer  * format (as char *) and appends it to the given buffer.
496b5dedccaSJan Lentfer  * The presentation format is annotated with comments giving
497b5dedccaSJan Lentfer  * additional information on the record.
498b5dedccaSJan Lentfer  *
499b5dedccaSJan Lentfer  * \param[in] output pointer to the buffer to append the data to
500b5dedccaSJan Lentfer  * \param[in] fmt how to format the textual representation of the
501b5dedccaSJan Lentfer  *            resource record.
502b5dedccaSJan Lentfer  * \param[in] rr the pointer to the rr field to convert
503b5dedccaSJan Lentfer  * \return status
504b5dedccaSJan Lentfer  */
505b5dedccaSJan Lentfer ldns_status ldns_rr2buffer_str_fmt(ldns_buffer *output,
506b5dedccaSJan Lentfer 		const ldns_output_format *fmt, const ldns_rr *rr);
507b5dedccaSJan Lentfer 
508b5dedccaSJan Lentfer /**
509825eb42bSJan Lentfer  * Converts the data in the DNS packet to presentation
510825eb42bSJan Lentfer  * format (as char *) and appends it to the given buffer
511825eb42bSJan Lentfer  *
512825eb42bSJan Lentfer  * \param[in] output pointer to the buffer to append the data to
513825eb42bSJan Lentfer  * \param[in] pkt the pointer to the packet to convert
514825eb42bSJan Lentfer  * \return status
515825eb42bSJan Lentfer  */
516825eb42bSJan Lentfer ldns_status ldns_pkt2buffer_str(ldns_buffer *output, const ldns_pkt *pkt);
517825eb42bSJan Lentfer 
518825eb42bSJan Lentfer /**
519*ee791febSAntonio Huete Jimenez  * Converts the list of EDNS options to presentation
520*ee791febSAntonio Huete Jimenez  * format (as char *) and appends it to the given buffer
521*ee791febSAntonio Huete Jimenez  *
522*ee791febSAntonio Huete Jimenez  * \param[in] output pointer to the buffer to append the data to
523*ee791febSAntonio Huete Jimenez  * \param[in] edns_list the list of EDNS options
524*ee791febSAntonio Huete Jimenez  * \return status
525*ee791febSAntonio Huete Jimenez  */
526*ee791febSAntonio Huete Jimenez ldns_status ldns_edns_option_list2buffer_str(ldns_buffer *output,
527*ee791febSAntonio Huete Jimenez         ldns_edns_option_list* edns_list);
528*ee791febSAntonio Huete Jimenez 
529*ee791febSAntonio Huete Jimenez /**
530b5dedccaSJan Lentfer  * Converts the data in the DNS packet to presentation
531b5dedccaSJan Lentfer  * format (as char *) and appends it to the given buffer
532b5dedccaSJan Lentfer  *
533b5dedccaSJan Lentfer  * \param[in] output pointer to the buffer to append the data to
534b5dedccaSJan Lentfer  * \param[in] fmt how to format the textual representation of the packet
535b5dedccaSJan Lentfer  * \param[in] pkt the pointer to the packet to convert
536b5dedccaSJan Lentfer  * \return status
537b5dedccaSJan Lentfer  */
538b5dedccaSJan Lentfer ldns_status ldns_pkt2buffer_str_fmt(ldns_buffer *output,
539b5dedccaSJan Lentfer 		const ldns_output_format *fmt, const ldns_pkt *pkt);
540b5dedccaSJan Lentfer 
541b5dedccaSJan Lentfer /**
542ac996e71SJan Lentfer  * Converts an LDNS_RDF_TYPE_NSEC3_SALT rdata element to string format and adds it to the output buffer
543ac996e71SJan Lentfer  * \param[in] *rdf The rdata to convert
544ac996e71SJan Lentfer  * \param[in] *output The buffer to add the data to
545ac996e71SJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
546ac996e71SJan Lentfer  */
547ac996e71SJan Lentfer ldns_status ldns_rdf2buffer_str_nsec3_salt(ldns_buffer *output, const ldns_rdf *rdf);
548ac996e71SJan Lentfer 
549ac996e71SJan Lentfer 
550ac996e71SJan Lentfer /**
551825eb42bSJan Lentfer  * Converts the data in the DNS packet to presentation
552825eb42bSJan Lentfer  * format (as char *) and appends it to the given buffer
553825eb42bSJan Lentfer  *
554825eb42bSJan Lentfer  * \param[in] output pointer to the buffer to append the data to
555825eb42bSJan Lentfer  * \param[in] k the pointer to the private key to convert
556825eb42bSJan Lentfer  * \return status
557825eb42bSJan Lentfer  */
558825eb42bSJan Lentfer ldns_status ldns_key2buffer_str(ldns_buffer *output, const ldns_key *k);
559825eb42bSJan Lentfer 
560825eb42bSJan Lentfer /**
561ac996e71SJan Lentfer  * Converts an LDNS_RDF_TYPE_INT8 rdata element to string format and adds it to the output buffer
562ac996e71SJan Lentfer  * \param[in] *rdf The rdata to convert
563ac996e71SJan Lentfer  * \param[in] *output The buffer to add the data to
564ac996e71SJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
565ac996e71SJan Lentfer  */
566ac996e71SJan Lentfer ldns_status ldns_rdf2buffer_str_int8(ldns_buffer *output, const ldns_rdf *rdf);
567ac996e71SJan Lentfer 
568ac996e71SJan Lentfer /**
569ac996e71SJan Lentfer  * Converts an LDNS_RDF_TYPE_INT16 rdata element to string format and adds it to the output buffer
570ac996e71SJan Lentfer  * \param[in] *rdf The rdata to convert
571ac996e71SJan Lentfer  * \param[in] *output The buffer to add the data to
572ac996e71SJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
573825eb42bSJan Lentfer  */
574825eb42bSJan Lentfer ldns_status ldns_rdf2buffer_str_int16(ldns_buffer *output, const ldns_rdf *rdf);
575825eb42bSJan Lentfer 
576825eb42bSJan Lentfer /**
577ac996e71SJan Lentfer  * Converts an LDNS_RDF_TYPE_INT32 rdata element to string format and adds it to the output buffer
578ac996e71SJan Lentfer  * \param[in] *rdf The rdata to convert
579ac996e71SJan Lentfer  * \param[in] *output The buffer to add the data to
580ac996e71SJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
581ac996e71SJan Lentfer  */
582ac996e71SJan Lentfer ldns_status ldns_rdf2buffer_str_int32(ldns_buffer *output, const ldns_rdf *rdf);
583ac996e71SJan Lentfer 
584ac996e71SJan Lentfer /**
585ac996e71SJan Lentfer  * Converts an LDNS_RDF_TYPE_TIME rdata element to string format and adds it to the output buffer
586ac996e71SJan Lentfer  * \param[in] *rdf The rdata to convert
587ac996e71SJan Lentfer  * \param[in] *output The buffer to add the data to
588ac996e71SJan Lentfer  * \return LDNS_STATUS_OK on success, and error status on failure
589ac996e71SJan Lentfer  */
590ac996e71SJan Lentfer ldns_status ldns_rdf2buffer_str_time(ldns_buffer *output, const ldns_rdf *rdf);
591ac996e71SJan Lentfer 
592ac996e71SJan Lentfer /**
5935340022aSzrj  * Converts an LDNS_RDF_TYPE_ILNP64 rdata element to 4 hexadecimal numbers
5945340022aSzrj  * separated by colons and adds it to the output buffer
5955340022aSzrj  * \param[in] *rdf The rdata to convert
5965340022aSzrj  * \param[in] *output The buffer to add the data to
5975340022aSzrj  * \return LDNS_STATUS_OK on success, and error status on failure
5985340022aSzrj  */
5995340022aSzrj ldns_status ldns_rdf2buffer_str_ilnp64(ldns_buffer *output,
6005340022aSzrj 		const ldns_rdf *rdf);
6015340022aSzrj 
6025340022aSzrj /**
6035340022aSzrj  * Converts an LDNS_RDF_TYPE_EUI48 rdata element to 6 hexadecimal numbers
6045340022aSzrj  * separated by dashes and adds it to the output buffer
6055340022aSzrj  * \param[in] *rdf The rdata to convert
6065340022aSzrj  * \param[in] *output The buffer to add the data to
6075340022aSzrj  * \return LDNS_STATUS_OK on success, and error status on failure
6085340022aSzrj  */
6095340022aSzrj ldns_status ldns_rdf2buffer_str_eui48(ldns_buffer *output,
6105340022aSzrj 		const ldns_rdf *rdf);
6115340022aSzrj 
6125340022aSzrj /**
6135340022aSzrj  * Converts an LDNS_RDF_TYPE_EUI64 rdata element to 8 hexadecimal numbers
6145340022aSzrj  * separated by dashes and adds it to the output buffer
6155340022aSzrj  * \param[in] *rdf The rdata to convert
6165340022aSzrj  * \param[in] *output The buffer to add the data to
6175340022aSzrj  * \return LDNS_STATUS_OK on success, and error status on failure
6185340022aSzrj  */
6195340022aSzrj ldns_status ldns_rdf2buffer_str_eui64(ldns_buffer *output,
6205340022aSzrj 		const ldns_rdf *rdf);
6215340022aSzrj 
6225340022aSzrj /**
6235340022aSzrj  * Adds the LDNS_RDF_TYPE_TAG rdata to the output buffer,
6245340022aSzrj  * provided it contains only alphanumeric characters.
6255340022aSzrj  * \param[in] *rdf The rdata to convert
6265340022aSzrj  * \param[in] *output The buffer to add the data to
6275340022aSzrj  * \return LDNS_STATUS_OK on success, and error status on failure
6285340022aSzrj  */
6295340022aSzrj ldns_status ldns_rdf2buffer_str_tag(ldns_buffer *output,
6305340022aSzrj 		const ldns_rdf *rdf);
6315340022aSzrj 
6325340022aSzrj /**
6335340022aSzrj  * Adds the LDNS_RDF_TYPE_LONG_STR rdata to the output buffer, in-between
6345340022aSzrj  * double quotes and all non printable characters properly escaped.
6355340022aSzrj  * \param[in] *rdf The rdata to convert
6365340022aSzrj  * \param[in] *output The buffer to add the data to
6375340022aSzrj  * \return LDNS_STATUS_OK on success, and error status on failure
6385340022aSzrj  */
6395340022aSzrj ldns_status ldns_rdf2buffer_str_long_str(ldns_buffer *output,
6405340022aSzrj 	       	const ldns_rdf *rdf);
6415340022aSzrj 
6425340022aSzrj /**
6435340022aSzrj  * Converts an LDNS_RDF_TYPE_HIP rdata element to presentation format for
6445340022aSzrj  * the algorithm, HIT and Public Key and adds it the output buffer .
6455340022aSzrj  * \param[in] *rdf The rdata to convert
6465340022aSzrj  * \param[in] *output The buffer to add the data to
6475340022aSzrj  * \return LDNS_STATUS_OK on success, and error status on failure
6485340022aSzrj  */
6495340022aSzrj ldns_status ldns_rdf2buffer_str_hip(ldns_buffer *output,
6505340022aSzrj 		const ldns_rdf *rdf);
6515340022aSzrj 
6525340022aSzrj /**
653819dec71SDaniel Fojt  * Converts an LDNS_RDF_TYPE_AMTRELAY rdata element to presentation format for
654819dec71SDaniel Fojt  * the precedence, D-bit, type and relay and adds it to the output buffer
655819dec71SDaniel Fojt  * \param[in] *rdf The rdata to convert
656819dec71SDaniel Fojt  * \param[in] *output The buffer to add the data to
657819dec71SDaniel Fojt  * \return LDNS_STATUS_OK on success, and error status on failure
658819dec71SDaniel Fojt  */
659819dec71SDaniel Fojt ldns_status ldns_rdf2buffer_str_amtrelay(ldns_buffer *output,
660819dec71SDaniel Fojt 		const ldns_rdf *rdf);
661819dec71SDaniel Fojt 
662*ee791febSAntonio Huete Jimenez /**
663*ee791febSAntonio Huete Jimenez  * Converts an LDNS_RDF_TYPE_SVCPARAMS rdata element to presentation format.
664*ee791febSAntonio Huete Jimenez  * \param[in] *rdf The rdata to convert
665*ee791febSAntonio Huete Jimenez  * \param[in] *output The buffer to add the data to
666*ee791febSAntonio Huete Jimenez  * \return LDNS_STATUS_OK on success, and error status on failure
667*ee791febSAntonio Huete Jimenez  */
668*ee791febSAntonio Huete Jimenez ldns_status ldns_rdf2buffer_str_svcparams(ldns_buffer *output,
669*ee791febSAntonio Huete Jimenez 		const ldns_rdf *rdf);
670819dec71SDaniel Fojt 
671819dec71SDaniel Fojt /**
672825eb42bSJan Lentfer  * Converts the data in the rdata field to presentation format and
673825eb42bSJan Lentfer  * returns that as a char *.
674825eb42bSJan Lentfer  * Remember to free it.
675825eb42bSJan Lentfer  *
676825eb42bSJan Lentfer  * \param[in] rdf The rdata field to convert
677825eb42bSJan Lentfer  * \return null terminated char * data, or NULL on error
678825eb42bSJan Lentfer  */
679825eb42bSJan Lentfer char *ldns_rdf2str(const ldns_rdf *rdf);
680825eb42bSJan Lentfer 
681825eb42bSJan Lentfer /**
682825eb42bSJan Lentfer  * Converts the data in the resource record to presentation format and
683825eb42bSJan Lentfer  * returns that as a char *.
684825eb42bSJan Lentfer  * Remember to free it.
685825eb42bSJan Lentfer  *
686825eb42bSJan Lentfer  * \param[in] rr The rdata field to convert
687825eb42bSJan Lentfer  * \return null terminated char * data, or NULL on error
688825eb42bSJan Lentfer  */
689825eb42bSJan Lentfer char *ldns_rr2str(const ldns_rr *rr);
690825eb42bSJan Lentfer 
691825eb42bSJan Lentfer /**
692b5dedccaSJan Lentfer  * Converts the data in the resource record to presentation format and
693b5dedccaSJan Lentfer  * returns that as a char *.
694b5dedccaSJan Lentfer  * Remember to free it.
695b5dedccaSJan Lentfer  *
696b5dedccaSJan Lentfer  * \param[in] fmt how to format the resource record
697b5dedccaSJan Lentfer  * \param[in] rr The rdata field to convert
698b5dedccaSJan Lentfer  * \return null terminated char * data, or NULL on error
699b5dedccaSJan Lentfer  */
700b5dedccaSJan Lentfer char *ldns_rr2str_fmt(const ldns_output_format *fmt, const ldns_rr *rr);
701b5dedccaSJan Lentfer 
702b5dedccaSJan Lentfer /**
703825eb42bSJan Lentfer  * Converts the data in the DNS packet to presentation format and
704825eb42bSJan Lentfer  * returns that as a char *.
705825eb42bSJan Lentfer  * Remember to free it.
706825eb42bSJan Lentfer  *
707825eb42bSJan Lentfer  * \param[in] pkt The rdata field to convert
708825eb42bSJan Lentfer  * \return null terminated char * data, or NULL on error
709825eb42bSJan Lentfer  */
710825eb42bSJan Lentfer char *ldns_pkt2str(const ldns_pkt *pkt);
711825eb42bSJan Lentfer 
712825eb42bSJan Lentfer /**
713b5dedccaSJan Lentfer  * Converts the data in the DNS packet to presentation format and
714b5dedccaSJan Lentfer  * returns that as a char *.
715b5dedccaSJan Lentfer  * Remember to free it.
716b5dedccaSJan Lentfer  *
717b5dedccaSJan Lentfer  * \param[in] fmt how to format the packet
718b5dedccaSJan Lentfer  * \param[in] pkt The rdata field to convert
719b5dedccaSJan Lentfer  * \return null terminated char * data, or NULL on error
720b5dedccaSJan Lentfer  */
721b5dedccaSJan Lentfer char *ldns_pkt2str_fmt(const ldns_output_format *fmt, const ldns_pkt *pkt);
722b5dedccaSJan Lentfer 
723b5dedccaSJan Lentfer /**
724825eb42bSJan Lentfer  * Converts a private key to the test presentation fmt and
725825eb42bSJan Lentfer  * returns that as a char *.
726825eb42bSJan Lentfer  * Remember to free it.
727825eb42bSJan Lentfer  *
728825eb42bSJan Lentfer  * \param[in] k the key to convert to text
729825eb42bSJan Lentfer  * \return null terminated char * data, or NULL on error
730825eb42bSJan Lentfer  */
731825eb42bSJan Lentfer char *ldns_key2str(const ldns_key *k);
732825eb42bSJan Lentfer 
733825eb42bSJan Lentfer /**
734825eb42bSJan Lentfer  * Converts a list of resource records to presentation format
735825eb42bSJan Lentfer  * and returns that as a char *.
736825eb42bSJan Lentfer  * Remember to free it.
737825eb42bSJan Lentfer  *
738825eb42bSJan Lentfer  * \param[in] rr_list the rr_list to convert to text
739825eb42bSJan Lentfer  * \return null terminated char * data, or NULL on error
740825eb42bSJan Lentfer  */
741825eb42bSJan Lentfer char *ldns_rr_list2str(const ldns_rr_list *rr_list);
742825eb42bSJan Lentfer 
743825eb42bSJan Lentfer /**
744b5dedccaSJan Lentfer  * Converts a list of resource records to presentation format
745b5dedccaSJan Lentfer  * and returns that as a char *.
746b5dedccaSJan Lentfer  * Remember to free it.
747b5dedccaSJan Lentfer  *
748b5dedccaSJan Lentfer  * \param[in] fmt how to format the list of resource records
749b5dedccaSJan Lentfer  * \param[in] rr_list the rr_list to convert to text
750b5dedccaSJan Lentfer  * \return null terminated char * data, or NULL on error
751b5dedccaSJan Lentfer  */
752b5dedccaSJan Lentfer char *ldns_rr_list2str_fmt(
753b5dedccaSJan Lentfer 		const ldns_output_format *fmt, const ldns_rr_list *rr_list);
754b5dedccaSJan Lentfer 
755b5dedccaSJan Lentfer /**
756d1b2b5caSJohn Marino  * Returns a copy of the data in the buffer as a null terminated
757d1b2b5caSJohn Marino  * char * string. The returned string must be freed by the caller.
758d1b2b5caSJohn Marino  * The buffer must be in write modus and may thus not have been flipped.
759825eb42bSJan Lentfer  *
760825eb42bSJan Lentfer  * \param[in] buffer buffer containing char * data
761825eb42bSJan Lentfer  * \return null terminated char * data, or NULL on error
762825eb42bSJan Lentfer  */
763825eb42bSJan Lentfer char *ldns_buffer2str(ldns_buffer *buffer);
764825eb42bSJan Lentfer 
765825eb42bSJan Lentfer /**
766d1b2b5caSJohn Marino  * Exports and returns the data in the buffer as a null terminated
767d1b2b5caSJohn Marino  * char * string. The returned string must be freed by the caller.
768d1b2b5caSJohn Marino  * The buffer must be in write modus and may thus not have been flipped.
769d1b2b5caSJohn Marino  * The buffer is fixed after this function returns.
770d1b2b5caSJohn Marino  *
771d1b2b5caSJohn Marino  * \param[in] buffer buffer containing char * data
772d1b2b5caSJohn Marino  * \return null terminated char * data, or NULL on error
773d1b2b5caSJohn Marino  */
774d1b2b5caSJohn Marino char *ldns_buffer_export2str(ldns_buffer *buffer);
775d1b2b5caSJohn Marino 
776d1b2b5caSJohn Marino /**
777825eb42bSJan Lentfer  * Prints the data in the rdata field to the given file stream
778825eb42bSJan Lentfer  * (in presentation format)
779825eb42bSJan Lentfer  *
780825eb42bSJan Lentfer  * \param[in] output the file stream to print to
781825eb42bSJan Lentfer  * \param[in] rdf the rdata field to print
782825eb42bSJan Lentfer  * \return void
783825eb42bSJan Lentfer  */
784825eb42bSJan Lentfer void ldns_rdf_print(FILE *output, const ldns_rdf *rdf);
785825eb42bSJan Lentfer 
786825eb42bSJan Lentfer /**
787825eb42bSJan Lentfer  * Prints the data in the resource record to the given file stream
788825eb42bSJan Lentfer  * (in presentation format)
789825eb42bSJan Lentfer  *
790825eb42bSJan Lentfer  * \param[in] output the file stream to print to
791825eb42bSJan Lentfer  * \param[in] rr the resource record to print
792825eb42bSJan Lentfer  * \return void
793825eb42bSJan Lentfer  */
794825eb42bSJan Lentfer void ldns_rr_print(FILE *output, const ldns_rr *rr);
795825eb42bSJan Lentfer 
796825eb42bSJan Lentfer /**
797b5dedccaSJan Lentfer  * Prints the data in the resource record to the given file stream
798b5dedccaSJan Lentfer  * (in presentation format)
799b5dedccaSJan Lentfer  *
800b5dedccaSJan Lentfer  * \param[in] output the file stream to print to
801b5dedccaSJan Lentfer  * \param[in] fmt format of the textual representation
802b5dedccaSJan Lentfer  * \param[in] rr the resource record to print
803b5dedccaSJan Lentfer  * \return void
804b5dedccaSJan Lentfer  */
805b5dedccaSJan Lentfer void ldns_rr_print_fmt(FILE *output,
806b5dedccaSJan Lentfer 		const ldns_output_format *fmt, const ldns_rr *rr);
807b5dedccaSJan Lentfer 
808b5dedccaSJan Lentfer /**
809825eb42bSJan Lentfer  * Prints the data in the DNS packet to the given file stream
810825eb42bSJan Lentfer  * (in presentation format)
811825eb42bSJan Lentfer  *
812825eb42bSJan Lentfer  * \param[in] output the file stream to print to
813825eb42bSJan Lentfer  * \param[in] pkt the packet to print
814825eb42bSJan Lentfer  * \return void
815825eb42bSJan Lentfer  */
816825eb42bSJan Lentfer void ldns_pkt_print(FILE *output, const ldns_pkt *pkt);
817825eb42bSJan Lentfer 
818825eb42bSJan Lentfer /**
819b5dedccaSJan Lentfer  * Prints the data in the DNS packet to the given file stream
820b5dedccaSJan Lentfer  * (in presentation format)
821b5dedccaSJan Lentfer  *
822b5dedccaSJan Lentfer  * \param[in] output the file stream to print to
823b5dedccaSJan Lentfer  * \param[in] fmt format of the textual representation
824b5dedccaSJan Lentfer  * \param[in] pkt the packet to print
825b5dedccaSJan Lentfer  * \return void
826b5dedccaSJan Lentfer  */
827b5dedccaSJan Lentfer void ldns_pkt_print_fmt(FILE *output,
828b5dedccaSJan Lentfer 		const ldns_output_format *fmt, const ldns_pkt *pkt);
829b5dedccaSJan Lentfer 
830b5dedccaSJan Lentfer /**
831825eb42bSJan Lentfer  * Converts a rr_list to presentation format and appends it to
832825eb42bSJan Lentfer  * the output buffer
833825eb42bSJan Lentfer  * \param[in] output the buffer to append output to
834825eb42bSJan Lentfer  * \param[in] list the ldns_rr_list to print
835825eb42bSJan Lentfer  * \return ldns_status
836825eb42bSJan Lentfer  */
837825eb42bSJan Lentfer ldns_status ldns_rr_list2buffer_str(ldns_buffer *output, const ldns_rr_list *list);
838825eb42bSJan Lentfer 
839825eb42bSJan Lentfer /**
840b5dedccaSJan Lentfer  * Converts a rr_list to presentation format and appends it to
841b5dedccaSJan Lentfer  * the output buffer
842b5dedccaSJan Lentfer  * \param[in] output the buffer to append output to
843b5dedccaSJan Lentfer  * \param[in] fmt format of the textual representation
844b5dedccaSJan Lentfer  * \param[in] list the ldns_rr_list to print
845b5dedccaSJan Lentfer  * \return ldns_status
846b5dedccaSJan Lentfer  */
847b5dedccaSJan Lentfer ldns_status ldns_rr_list2buffer_str_fmt(ldns_buffer *output,
848b5dedccaSJan Lentfer 		const ldns_output_format *fmt, const ldns_rr_list *list);
849b5dedccaSJan Lentfer 
850b5dedccaSJan Lentfer /**
851825eb42bSJan Lentfer  * Converts the header of a packet to presentation format and appends it to
852825eb42bSJan Lentfer  * the output buffer
853825eb42bSJan Lentfer  * \param[in] output the buffer to append output to
854825eb42bSJan Lentfer  * \param[in] pkt the packet to convert the header of
855825eb42bSJan Lentfer  * \return ldns_status
856825eb42bSJan Lentfer  */
857825eb42bSJan Lentfer ldns_status ldns_pktheader2buffer_str(ldns_buffer *output, const ldns_pkt *pkt);
858825eb42bSJan Lentfer 
859825eb42bSJan Lentfer /**
860825eb42bSJan Lentfer  * print a rr_list to output
861b5dedccaSJan Lentfer  * \param[in] output the fd to print to
862b5dedccaSJan Lentfer  * \param[in] list the rr_list to print
863825eb42bSJan Lentfer  */
864825eb42bSJan Lentfer void ldns_rr_list_print(FILE *output, const ldns_rr_list *list);
865825eb42bSJan Lentfer 
866825eb42bSJan Lentfer /**
867b5dedccaSJan Lentfer  * print a rr_list to output
868b5dedccaSJan Lentfer  * \param[in] output the fd to print to
869b5dedccaSJan Lentfer  * \param[in] fmt format of the textual representation
870b5dedccaSJan Lentfer  * \param[in] list the rr_list to print
871b5dedccaSJan Lentfer  */
872b5dedccaSJan Lentfer void ldns_rr_list_print_fmt(FILE *output,
873b5dedccaSJan Lentfer 		const ldns_output_format *fmt, const ldns_rr_list *list);
874b5dedccaSJan Lentfer 
875b5dedccaSJan Lentfer /**
876825eb42bSJan Lentfer  * Print a resolver (in sofar that is possible) state
877825eb42bSJan Lentfer  * to output.
878825eb42bSJan Lentfer  * \param[in] output the fd to print to
879825eb42bSJan Lentfer  * \param[in] r the resolver to print
880825eb42bSJan Lentfer  */
881825eb42bSJan Lentfer void ldns_resolver_print(FILE *output, const ldns_resolver *r);
882825eb42bSJan Lentfer 
883825eb42bSJan Lentfer /**
884b5dedccaSJan Lentfer  * Print a resolver (in sofar that is possible) state
885b5dedccaSJan Lentfer  * to output.
886b5dedccaSJan Lentfer  * \param[in] output the fd to print to
887b5dedccaSJan Lentfer  * \param[in] fmt format of the textual representation
888b5dedccaSJan Lentfer  * \param[in] r the resolver to print
889b5dedccaSJan Lentfer  */
890b5dedccaSJan Lentfer void ldns_resolver_print_fmt(FILE *output,
891b5dedccaSJan Lentfer 		const ldns_output_format *fmt, const ldns_resolver *r);
892b5dedccaSJan Lentfer 
893b5dedccaSJan Lentfer /**
894825eb42bSJan Lentfer  * Print a zone structure * to output. Note the SOA record
895825eb42bSJan Lentfer  * is included in this output
896825eb42bSJan Lentfer  * \param[in] output the fd to print to
897825eb42bSJan Lentfer  * \param[in] z the zone to print
898825eb42bSJan Lentfer  */
899825eb42bSJan Lentfer void ldns_zone_print(FILE *output, const ldns_zone *z);
900825eb42bSJan Lentfer 
901825eb42bSJan Lentfer /**
902b5dedccaSJan Lentfer  * Print a zone structure * to output. Note the SOA record
903b5dedccaSJan Lentfer  * is included in this output
904b5dedccaSJan Lentfer  * \param[in] output the fd to print to
905b5dedccaSJan Lentfer  * \param[in] fmt format of the textual representation
906b5dedccaSJan Lentfer  * \param[in] z the zone to print
907b5dedccaSJan Lentfer  */
908b5dedccaSJan Lentfer void ldns_zone_print_fmt(FILE *output,
909b5dedccaSJan Lentfer 		const ldns_output_format *fmt, const ldns_zone *z);
910b5dedccaSJan Lentfer 
911b5dedccaSJan Lentfer /**
912825eb42bSJan Lentfer  * Print the ldns_rdf containing a dname to the buffer
913825eb42bSJan Lentfer  * \param[in] output the buffer to print to
914825eb42bSJan Lentfer  * \param[in] dname the dname to print
915825eb42bSJan Lentfer  * \return ldns_status message if the printing succeeded
916825eb42bSJan Lentfer  */
917825eb42bSJan Lentfer ldns_status ldns_rdf2buffer_str_dname(ldns_buffer *output, const ldns_rdf *dname);
918825eb42bSJan Lentfer 
919ac996e71SJan Lentfer #ifdef __cplusplus
920ac996e71SJan Lentfer }
921ac996e71SJan Lentfer #endif
922825eb42bSJan Lentfer 
923825eb42bSJan Lentfer #endif /* LDNS_HOST2STR_H */
924