]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
DOA rr type
authorWillem Toorop <willem@nlnetlabs.nl>
Mon, 16 Oct 2017 08:37:02 +0000 (10:37 +0200)
committerWillem Toorop <willem@nlnetlabs.nl>
Mon, 16 Oct 2017 08:37:02 +0000 (10:37 +0200)
configure.ac
host2str.c
ldns/rr.h
rr.c
str2host.c

index 76a35596b49aa4613ef4753f5b041e5d40b256c8..6c8eee26b77235506db304d549601b5b210edde6 100644 (file)
@@ -639,6 +639,15 @@ case "$enable_rrtype_avc" in
        no|*)
                ;;
 esac
+AC_ARG_ENABLE(rrtype-doa, AC_HELP_STRING([--enable-rrtype-doa], [Enable draft RR type DOA.]))
+case "$enable_rrtype_doa" in
+       yes)
+               AC_DEFINE_UNQUOTED([RRTYPE_DOA], [], [Define this to enable RR type DOA.])
+               ;;
+       no|*)
+               ;;
+esac
+
 
 AC_SUBST(LIBSSL_CPPFLAGS)
 AC_SUBST(LIBSSL_LDFLAGS)
index c14025775b10818f333877c5e098f32ce70c642b..7dab51f80ec65c43f1712833f7294ae5bfba0797 100644 (file)
@@ -476,8 +476,17 @@ ldns_status
 ldns_rdf2buffer_str_b64(ldns_buffer *output, const ldns_rdf *rdf)
 {
        size_t size = ldns_b64_ntop_calculate_size(ldns_rdf_size(rdf));
-       char *b64 = LDNS_XMALLOC(char, size);
-       if(!b64) return LDNS_STATUS_MEM_ERR;
+       char *b64;
+
+       if (ldns_rdf_size(rdf) == 0) {
+               ldns_buffer_printf(output, "-");
+               return ldns_buffer_status(output);
+       } else
+               size = ldns_b64_ntop_calculate_size(ldns_rdf_size(rdf));
+
+       if (!(b64 = LDNS_XMALLOC(char, size)))
+               return LDNS_STATUS_MEM_ERR;
+
        if (ldns_b64_ntop(ldns_rdf_data(rdf), ldns_rdf_size(rdf), b64, size)) {
                ldns_buffer_printf(output, "%s", b64);
        }
index 5c53f8293f8fa319ad43670f5f23fa28dbe7f8a8..59c7ce67bc365fae83b47b51aea8696298ad7974 100644 (file)
--- a/ldns/rr.h
+++ b/ldns/rr.h
@@ -36,9 +36,6 @@ extern "C" {
 /** The bytes TTL, CLASS and length use up in an rr */
 #define LDNS_RR_OVERHEAD       10
 
-/* The first fields are contiguous and can be referenced instantly */
-#define LDNS_RDATA_FIELD_DESCRIPTORS_COMMON 259
-
 
 
 /**
@@ -223,6 +220,7 @@ enum ldns_enum_rr_type
        LDNS_RR_TYPE_URI = 256, /* RFC 7553 */
        LDNS_RR_TYPE_CAA = 257, /* RFC 6844 */
        LDNS_RR_TYPE_AVC = 258, /* Cisco's DNS-AS RR, see www.dns-as.org */
+       LDNS_RR_TYPE_DOA = 259, /* draft-durand-doa-over-dns */
 
        /** DNSSEC Trust Authorities */
        LDNS_RR_TYPE_TA = 32768,
@@ -238,6 +236,9 @@ enum ldns_enum_rr_type
 };
 typedef enum ldns_enum_rr_type ldns_rr_type;
 
+/* The first fields are contiguous and can be referenced instantly */
+#define LDNS_RDATA_FIELD_DESCRIPTORS_COMMON (LDNS_RR_TYPE_DOA + 1)
+
 /**
  * Resource Record
  *
diff --git a/rr.c b/rr.c
index dc27dd31ec8606ba9673578ddb92c42d761fb3d7..a1efb2492fa968e6bb968d607babd18be95d86c2 100644 (file)
--- a/rr.c
+++ b/rr.c
@@ -2038,6 +2038,16 @@ static const ldns_rdf_type type_caa_wireformat[] = {
        LDNS_RDF_TYPE_TAG,
        LDNS_RDF_TYPE_LONG_STR
 };
+#ifdef RRTYPE_DOA
+static const ldns_rdf_type type_doa_wireformat[] = {
+       LDNS_RDF_TYPE_INT32,
+       LDNS_RDF_TYPE_INT32,
+       LDNS_RDF_TYPE_INT8,
+       LDNS_RDF_TYPE_STR,
+       LDNS_RDF_TYPE_B64
+};
+#endif
+
 /** \endcond */
 
 /** \cond */
@@ -2426,6 +2436,12 @@ static ldns_rr_descriptor rdata_field_descriptors[] = {
 #else
 {LDNS_RR_TYPE_NULL, "TYPE258", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
 #endif
+#ifdef RRTYPE_DOA
+       /* 259 */
+       {LDNS_RR_TYPE_DOA, "DOA", 5, 5, type_doa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+#else
+{LDNS_RR_TYPE_NULL, "TYPE259", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+#endif
 
 /* split in array, no longer contiguous */
 
index 968429cd5f2431bccff51123214b47001b23c1e8..a3511ad4773d488eacd74710c64e0333dec37176 100644 (file)
@@ -584,6 +584,11 @@ ldns_str2rdf_b64(ldns_rdf **rd, const char *str)
        uint8_t *buffer;
        int16_t i;
 
+       if (*str == '-' && str[1] == '\0') {
+               *rd = ldns_rdf_new_frm_data(LDNS_RDF_TYPE_B64, 0, NULL);
+               return *rd ? LDNS_STATUS_OK : LDNS_STATUS_MEM_ERR;
+       }
+
        buffer = LDNS_XMALLOC(uint8_t, ldns_b64_ntop_calculate_size(strlen(str)));
         if(!buffer) {
                 return LDNS_STATUS_MEM_ERR;