aboutsummaryrefslogtreecommitdiff
path: root/contrib/ldns/ldns/host2str.h
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ldns/ldns/host2str.h')
-rw-r--r--contrib/ldns/ldns/host2str.h168
1 files changed, 143 insertions, 25 deletions
diff --git a/contrib/ldns/ldns/host2str.h b/contrib/ldns/ldns/host2str.h
index bbf932767b3b..e69389e90aee 100644
--- a/contrib/ldns/ldns/host2str.h
+++ b/contrib/ldns/ldns/host2str.h
@@ -40,32 +40,38 @@ extern "C" {
#define LDNS_APL_NEGATION 0x80
/**
- * Represent a NULL pointer (in stead of a pointer to a ldns_rr as "; (null)"
+ * Represent a NULL pointer (instead of a pointer to a ldns_rr as "; (null)"
* as opposed to outputting nothing at all in such a case.
*/
-#define LDNS_COMMENT_NULLS 0x0001
+/* Flag Name Flag Nr. Has data associated
+ ---------------------------------------------------------------------*/
+#define LDNS_COMMENT_NULLS (1 << 0)
/** Show key id with DNSKEY RR's as comment */
-#define LDNS_COMMENT_KEY_ID 0x0002
+#define LDNS_COMMENT_KEY_ID (1 << 1)
/** Show if a DNSKEY is a ZSK or KSK as comment */
-#define LDNS_COMMENT_KEY_TYPE 0x0004
+#define LDNS_COMMENT_KEY_TYPE (1 << 2)
/** Show DNSKEY key size as comment */
-#define LDNS_COMMENT_KEY_SIZE 0x0008
-/** Show key id, type and size as comment for DNSKEY RR's */
-#define LDNS_COMMENT_KEY (LDNS_COMMENT_KEY_ID \
- |LDNS_COMMENT_KEY_TYPE\
- |LDNS_COMMENT_KEY_SIZE)
+#define LDNS_COMMENT_KEY_SIZE (1 << 3)
/** Provide bubblebabble representation for DS RR's as comment */
-#define LDNS_COMMENT_BUBBLEBABBLE 0x0010
+#define LDNS_COMMENT_BUBBLEBABBLE (1 << 4)
/** Show when a NSEC3 RR has the optout flag set as comment */
-#define LDNS_COMMENT_FLAGS 0x0020
+#define LDNS_COMMENT_FLAGS (1 << 5)
/** Show the unhashed owner and next owner names for NSEC3 RR's as comment */
-#define LDNS_COMMENT_NSEC3_CHAIN 0x0040
+#define LDNS_COMMENT_NSEC3_CHAIN (1 << 6) /* yes */
/** Print mark up */
-#define LDNS_COMMENT_LAYOUT 0x0080
+#define LDNS_COMMENT_LAYOUT (1 << 7)
/** Also comment KEY_ID with RRSIGS **/
-#define LDNS_COMMENT_RRSIGS 0x0100
-#define LDNS_FMT_ZEROIZE_RRSIGS 0x0200
-#define LDNS_FMT_PAD_SOA_SERIAL 0x0400
+#define LDNS_COMMENT_RRSIGS (1 << 8)
+#define LDNS_FMT_ZEROIZE_RRSIGS (1 << 9)
+#define LDNS_FMT_PAD_SOA_SERIAL (1 << 10)
+#define LDNS_FMT_RFC3597 (1 << 11) /* yes */
+
+#define LDNS_FMT_FLAGS_WITH_DATA 2
+
+/** Show key id, type and size as comment for DNSKEY RR's */
+#define LDNS_COMMENT_KEY (LDNS_COMMENT_KEY_ID \
+ |LDNS_COMMENT_KEY_TYPE\
+ |LDNS_COMMENT_KEY_SIZE)
/**
* Output format specifier
@@ -87,6 +93,18 @@ struct ldns_struct_output_format
typedef struct ldns_struct_output_format ldns_output_format;
/**
+ * Output format struct with additional data for flags that use them.
+ * This struct may not be initialized directly. Use ldns_output_format_init
+ * to initialize.
+ */
+struct ldns_struct_output_format_storage
+{ int flags;
+ ldns_rbtree_t* hashmap; /* for LDNS_COMMENT_NSEC3_CHAIN */
+ ldns_rdf* bitmap; /* for LDNS_FMT_RFC3597 */
+};
+typedef struct ldns_struct_output_format_storage ldns_output_format_storage;
+
+/**
* Standard output format record that disables commenting in the textual
* representation of Resource Records completely.
*/
@@ -108,6 +126,55 @@ extern const ldns_output_format *ldns_output_format_default;
extern const ldns_output_format *ldns_output_format_bubblebabble;
/**
+ * Initialize output format storage to the default value.
+ * \param[in] fmt A reference to an output_format_ storage struct
+ * \return The initialized storage struct typecasted to ldns_output_format
+ */
+INLINE
+ldns_output_format* ldns_output_format_init(ldns_output_format_storage* fmt) {
+ fmt->flags = ldns_output_format_default->flags;
+ fmt->hashmap = NULL;
+ fmt->bitmap = NULL;
+ return (ldns_output_format*)fmt;
+}
+
+/**
+ * Set an ouput format flag.
+ */
+INLINE void ldns_output_format_set(ldns_output_format* fmt, int flag) {
+ fmt->flags |= flag;
+}
+
+/**
+ * Clear an ouput format flag.
+ */
+INLINE void ldns_output_format_clear(ldns_output_format* fmt, int flag) {
+ fmt->flags &= !flag;
+}
+
+/**
+ * Makes sure the LDNS_FMT_RFC3597 is set in the output format.
+ * Marks the type to be printed in RFC3597 format.
+ * /param[in] fmt the output format to update
+ * /param[in] the type to be printed in RFC3597 format
+ * /return LDNS_STATUS_OK on success
+ */
+ldns_status
+ldns_output_format_set_type(ldns_output_format* fmt, ldns_rr_type type);
+
+/**
+ * Makes sure the LDNS_FMT_RFC3597 is set in the output format.
+ * Marks the type to not be printed in RFC3597 format. When no other types
+ * have been marked before, all known types (except the given one) will be
+ * marked for printing in RFC3597 format.
+ * /param[in] fmt the output format to update
+ * /param[in] the type not to be printed in RFC3597 format
+ * /return LDNS_STATUS_OK on success
+ */
+ldns_status
+ldns_output_format_clear_type(ldns_output_format* fmt, ldns_rr_type type);
+
+/**
* Converts an ldns packet opcode value to its mnemonic, and adds that
* to the output buffer
* \param[in] *output the buffer to add the data to
@@ -399,15 +466,6 @@ ldns_status ldns_rdf2buffer_str_int16_data(ldns_buffer *output, const ldns_rdf *
*/
ldns_status ldns_rdf2buffer_str_ipseckey(ldns_buffer *output, const ldns_rdf *rdf);
-/**
- * Converts an LDNS_RDF_TYPE_TSIG rdata element to string format and adds it to the output buffer
- * \param[in] *rdf The rdata to convert
- * \param[in] *output The buffer to add the data to
- * \return LDNS_STATUS_OK on success, and error status on failure
- */
-ldns_status ldns_rdf2buffer_str_tsig(ldns_buffer *output, const ldns_rdf *rdf);
-
-
/**
* Converts the data in the rdata field to presentation
* format (as char *) and appends it to the given buffer
@@ -518,6 +576,66 @@ ldns_status ldns_rdf2buffer_str_int32(ldns_buffer *output, const ldns_rdf *rdf);
*/
ldns_status ldns_rdf2buffer_str_time(ldns_buffer *output, const ldns_rdf *rdf);
+/**
+ * Converts an LDNS_RDF_TYPE_ILNP64 rdata element to 4 hexadecimal numbers
+ * separated by colons and adds it to the output buffer
+ * \param[in] *rdf The rdata to convert
+ * \param[in] *output The buffer to add the data to
+ * \return LDNS_STATUS_OK on success, and error status on failure
+ */
+ldns_status ldns_rdf2buffer_str_ilnp64(ldns_buffer *output,
+ const ldns_rdf *rdf);
+
+/**
+ * Converts an LDNS_RDF_TYPE_EUI48 rdata element to 6 hexadecimal numbers
+ * separated by dashes and adds it to the output buffer
+ * \param[in] *rdf The rdata to convert
+ * \param[in] *output The buffer to add the data to
+ * \return LDNS_STATUS_OK on success, and error status on failure
+ */
+ldns_status ldns_rdf2buffer_str_eui48(ldns_buffer *output,
+ const ldns_rdf *rdf);
+
+/**
+ * Converts an LDNS_RDF_TYPE_EUI64 rdata element to 8 hexadecimal numbers
+ * separated by dashes and adds it to the output buffer
+ * \param[in] *rdf The rdata to convert
+ * \param[in] *output The buffer to add the data to
+ * \return LDNS_STATUS_OK on success, and error status on failure
+ */
+ldns_status ldns_rdf2buffer_str_eui64(ldns_buffer *output,
+ const ldns_rdf *rdf);
+
+/**
+ * Adds the LDNS_RDF_TYPE_TAG rdata to the output buffer,
+ * provided it contains only alphanumeric characters.
+ * \param[in] *rdf The rdata to convert
+ * \param[in] *output The buffer to add the data to
+ * \return LDNS_STATUS_OK on success, and error status on failure
+ */
+ldns_status ldns_rdf2buffer_str_tag(ldns_buffer *output,
+ const ldns_rdf *rdf);
+
+/**
+ * Adds the LDNS_RDF_TYPE_LONG_STR rdata to the output buffer, in-between
+ * double quotes and all non printable characters properly escaped.
+ * \param[in] *rdf The rdata to convert
+ * \param[in] *output The buffer to add the data to
+ * \return LDNS_STATUS_OK on success, and error status on failure
+ */
+ldns_status ldns_rdf2buffer_str_long_str(ldns_buffer *output,
+ const ldns_rdf *rdf);
+
+/**
+ * Converts an LDNS_RDF_TYPE_HIP rdata element to presentation format for
+ * the algorithm, HIT and Public Key and adds it the output buffer .
+ * \param[in] *rdf The rdata to convert
+ * \param[in] *output The buffer to add the data to
+ * \return LDNS_STATUS_OK on success, and error status on failure
+ */
+ldns_status ldns_rdf2buffer_str_hip(ldns_buffer *output,
+ const ldns_rdf *rdf);
+
/**
* Converts the data in the rdata field to presentation format and
* returns that as a char *.