From: Willem Toorop Date: Mon, 16 Oct 2017 08:37:02 +0000 (+0200) Subject: DOA rr type X-Git-Tag: release-1.7.1-rc1~62 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1999b427e8e331d447e3277616d6b25595045adf;p=thirdparty%2Fldns.git DOA rr type --- diff --git a/configure.ac b/configure.ac index 76a35596..6c8eee26 100644 --- a/configure.ac +++ b/configure.ac @@ -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) diff --git a/host2str.c b/host2str.c index c1402577..7dab51f8 100644 --- a/host2str.c +++ b/host2str.c @@ -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); } diff --git a/ldns/rr.h b/ldns/rr.h index 5c53f829..59c7ce67 100644 --- 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 dc27dd31..a1efb249 100644 --- 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 */ diff --git a/str2host.c b/str2host.c index 968429cd..a3511ad4 100644 --- a/str2host.c +++ b/str2host.c @@ -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;