;;
esac
+AC_ARG_ENABLE(draft-rrtypes, AS_HELP_STRING([--enable-draft-rrtypes],[Enable all draft RR types.]))
AC_ARG_ENABLE(rrtype-ninfo, AS_HELP_STRING([--enable-rrtype-ninfo],[Enable draft RR type ninfo.]))
+if test "x$enable_draft_rrtypes" = "xyes"; then enable_rrtype_ninfo="yes"; fi
case "$enable_rrtype_ninfo" in
yes)
AC_DEFINE_UNQUOTED([RRTYPE_NINFO], [], [Define this to enable RR type NINFO.])
;;
esac
AC_ARG_ENABLE(rrtype-rkey, AS_HELP_STRING([--enable-rrtype-rkey],[Enable draft RR type rkey.]))
+if test "x$enable_draft_rrtypes" = "xyes"; then enable_rrtype_rkey="yes"; fi
case "$enable_rrtype_rkey" in
yes)
AC_DEFINE_UNQUOTED([RRTYPE_RKEY], [], [Define this to enable RR type RKEY.])
;;
esac
AC_ARG_ENABLE(rrtype-ta, AS_HELP_STRING([--enable-rrtype-ta],[Enable draft RR type ta.]))
+if test "x$enable_draft_rrtypes" = "xyes"; then enable_rrtype_ta="yes"; fi
case "$enable_rrtype_ta" in
yes)
AC_DEFINE_UNQUOTED([RRTYPE_TA], [], [Define this to enable RR type TA.])
;;
esac
AC_ARG_ENABLE(rrtype-avc, AS_HELP_STRING([--enable-rrtype-avc],[Enable draft RR type avc.]))
+if test "x$enable_draft_rrtypes" = "xyes"; then enable_rrtype_avc="yes"; fi
case "$enable_rrtype_avc" in
yes)
AC_DEFINE_UNQUOTED([RRTYPE_AVC], [], [Define this to enable RR type AVC.])
;;
esac
AC_ARG_ENABLE(rrtype-doa, AS_HELP_STRING([--enable-rrtype-doa],[Enable draft RR type DOA.]))
+if test "x$enable_draft_rrtypes" = "xyes"; then enable_rrtype_doa="yes"; fi
case "$enable_rrtype_doa" in
yes)
AC_DEFINE_UNQUOTED([RRTYPE_DOA], [], [Define this to enable RR type DOA.])
AC_DEFINE_UNQUOTED([RRTYPE_SVCB_HTTPS], [], [Define this to enable RR types SVCB and HTTPS.])
;;
esac
-AC_ARG_ENABLE(rrtype-resinfo, AS_HELP_STRING([--enable-rrtype-resinfo],[Disable RR type RESINFO.]))
+AC_ARG_ENABLE(rrtype-resinfo, AS_HELP_STRING([--disable-rrtype-resinfo],[Disable RR type RESINFO.]))
case "$enable_rrtype_resinfo" in
no)
;;
AC_DEFINE_UNQUOTED([RRTYPE_RESINFO], [], [Define this to enable RR type RESINFO.])
;;
esac
+AC_ARG_ENABLE(rrtype-dsync, AS_HELP_STRING([--enable-rrtype-dsync],[Enable draft RR type DSYNC.]))
+if test "x$enable_draft_rrtypes" = "xyes"; then enable_rrtype_dsync="yes"; fi
+case "$enable_rrtype_dsync" in
+ yes)
+ AC_DEFINE_UNQUOTED([RRTYPE_DSYNC], [], [Define this to enable RR type DSYNC.])
+ ;;
+ no|*)
+ ;;
+esac
+AC_ARG_ENABLE(rrtypes-cla-ipn, AS_HELP_STRING([--enable-rrtypes-cla-ipn],[Enable draft RR types CLA and IPN.]))
+if test "x$enable_draft_rrtypes" = "xyes"; then enable_rrtypes_cla_ipn="yes"; fi
+case "$enable_rrtypes_cla_ipn" in
+ yes)
+ AC_DEFINE_UNQUOTED([RRTYPE_CLA_IPN], [], [Define this to enable RR types CLA and IPN.])
+ ;;
+ no|*)
+ ;;
+esac
if echo "$tmp_LIBS" | grep "ws2_32" >/dev/null; then
return ldns_buffer_status(output);
}
+ldns_status
+ldns_rdf2buffer_str_int64(ldns_buffer *output, const ldns_rdf *rdf)
+{
+ uint64_t data = ldns_read_uint64(ldns_rdf_data(rdf));
+ ldns_buffer_printf(output, "%llu", (unsigned long long) data);
+ return ldns_buffer_status(output);
+}
+
ldns_status
ldns_rdf2buffer_str_time(ldns_buffer *output, const ldns_rdf *rdf)
{
case LDNS_RDF_TYPE_INT32:
res = ldns_rdf2buffer_str_int32(buffer, rdf);
break;
+ case LDNS_RDF_TYPE_INT64:
+ case LDNS_RDF_TYPE_IPN:
+ res = ldns_rdf2buffer_str_int64(buffer, rdf);
+ break;
case LDNS_RDF_TYPE_PERIOD:
res = ldns_rdf2buffer_str_period(buffer, rdf);
break;
*/
ldns_status ldns_rdf2buffer_str_int32(ldns_buffer *output, const ldns_rdf *rdf);
+/**
+ * Converts an LDNS_RDF_TYPE_INT64 rdata element to presentation format.
+ * \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_int64(ldns_buffer *output, const ldns_rdf *rdf);
+
/**
* Converts an LDNS_RDF_TYPE_TIME rdata element to string format and adds it to the output buffer
* \param[in] *rdf The rdata to convert
LDNS_RDF_TYPE_INT16,
/** 32 bits */
LDNS_RDF_TYPE_INT32,
+ /** 64 bits */
+ LDNS_RDF_TYPE_INT64,
/** A record */
LDNS_RDF_TYPE_A,
/** AAAA record */
LDNS_RDF_TYPE_HEX,
/** nsec type codes */
LDNS_RDF_TYPE_NSEC,
+ LDNS_RDF_TYPE_BITMAP = LDNS_RDF_TYPE_NSEC,
/** a RR type */
LDNS_RDF_TYPE_TYPE,
/** a class */
/** draft-ietf-dnsop-svcb-https **/
LDNS_RDF_TYPE_SVCPARAMS,
- /* Aliases */
- LDNS_RDF_TYPE_BITMAP = LDNS_RDF_TYPE_NSEC
+ /** draft-johnson-dns-ipn-cla-07 **/
+ LDNS_RDF_TYPE_IPN
};
typedef enum ldns_enum_rdf_type ldns_rdf_type;
LDNS_RR_TYPE_ZONEMD = 63, /* RFC 8976 */
LDNS_RR_TYPE_SVCB = 64, /* RFC 9460 */
LDNS_RR_TYPE_HTTPS = 65, /* RFC 9460 */
+ LDNS_RR_TYPE_DSYNC = 66, /* draft-ietf-dnsop-generalized-notify */
LDNS_RR_TYPE_SPF = 99, /* RFC 4408 */
/** https://iana.org/assignments/dns-parameters/WALLET/wallet-completed-template */
LDNS_RR_TYPE_WALLET = 262,
+ /** https://www.iana.org/assignments/dns-parameters/CLA/cla-completed-template */
+ LDNS_RR_TYPE_CLA = 263,
+
+ /** https://www.iana.org/assignments/dns-parameters/IPN/ipn-completed-template */
+ LDNS_RR_TYPE_IPN = 264,
+
/** DNSSEC Trust Authorities */
LDNS_RR_TYPE_TA = 32768,
/* RFC 4431, 5074, DNSSEC Lookaside Validation */
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_WALLET + 1)
+#define LDNS_RDATA_FIELD_DESCRIPTORS_COMMON (LDNS_RR_TYPE_IPN + 1)
/**
* Resource Record
*/
ldns_status ldns_str2rdf_svcparams(ldns_rdf **rd, const char *str);
+/**
+ * Convert either two unsigned 32 bit decimal numbers seperated by a '.',
+ * or a single unsigned 64 bit decimal number, as described in
+ * [draft-johnson-dns-ipn-cla-07].
+ * \param[out] rd the rdf where to put the data
+ * \param[in] str the string to be converted
+ * \return ldns_status
+ */
+ldns_status ldns_str2rdf_ipn(ldns_rdf **rd, const char *str);
+
#ifdef __cplusplus
}
#endif
}
+INLINE uint64_t
+ldns_read_uint64(const void *src)
+{
+#ifdef ALLOW_UNALIGNED_ACCESSES
+ const uint32_t *p = (const uint32_t *) src;
+ return ( ((uint64_t) ntohl(src[0]) << 32)
+ | (uint64_t) ntohl(src[1]));
+#else
+ const uint8_t *p = (const uint8_t *) src;
+ return ( ((uint64_t) p[0] << 56)
+ | ((uint64_t) p[1] << 48)
+ | ((uint64_t) p[2] << 40)
+ | ((uint64_t) p[3] << 32)
+ | ((uint64_t) p[4] << 24)
+ | ((uint64_t) p[5] << 16)
+ | ((uint64_t) p[6] << 8)
+ | (uint64_t) p[7]);
+#endif
+}
+
/*
* Copy data allowing for unaligned accesses in network byte order
* (big endian).
case LDNS_RDF_TYPE_SVCPARAMS:
status = ldns_str2rdf_svcparams(&rdf, str);
break;
+ case LDNS_RDF_TYPE_IPN:
+ status = ldns_str2rdf_ipn(&rdf, str);
+ break;
case LDNS_RDF_TYPE_NONE:
default:
/* default default ??? */
LDNS_RDF_TYPE_SVCPARAMS
};
#endif
+#ifdef RRTYPE_DSYNC
+static const ldns_rdf_type type_dsync_wireformat[] = {
+ LDNS_RDF_TYPE_TYPE,
+ LDNS_RDF_TYPE_INT8,
+ LDNS_RDF_TYPE_INT16,
+ LDNS_RDF_TYPE_DNAME
+};
+#endif
+
/* nsec3 is some vars, followed by same type of data of nsec */
static const ldns_rdf_type type_nsec3_wireformat[] = {
/* LDNS_RDF_TYPE_NSEC3_VARS, LDNS_RDF_TYPE_NSEC3_NEXT_OWNER, LDNS_RDF_TYPE_NSEC*/
LDNS_RDF_TYPE_AMTRELAY
};
#endif
+#ifdef RRTYPE_CLA_IPN
+static const ldns_rdf_type type_ipn_wireformat[] = {
+ LDNS_RDF_TYPE_IPN
+};
+#endif
+
/** \endcond */
{LDNS_RR_TYPE_NULL, "TYPE64", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE65", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
#endif
+#ifdef RRTYPE_DSYNC
+{LDNS_RR_TYPE_DSYNC, "DSYNC", 4, 4, type_dsync_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+#else
{LDNS_RR_TYPE_NULL, "TYPE66", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+#endif
{LDNS_RR_TYPE_NULL, "TYPE67", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE68", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE69", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE261", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
#endif
/* 262 */
- {LDNS_RR_TYPE_WALLET, "TXT", 1, 0, NULL, LDNS_RDF_TYPE_STR, LDNS_RR_NO_COMPRESS, 0 },
-
+ {LDNS_RR_TYPE_WALLET, "WALLET", 1, 0, NULL, LDNS_RDF_TYPE_STR, LDNS_RR_NO_COMPRESS, 0 },
+#ifdef RRTYPE_CLA_IPN
+ /* 263 */
+ {LDNS_RR_TYPE_CLA, "CLA", 1, 0, NULL, LDNS_RDF_TYPE_STR, LDNS_RR_NO_COMPRESS, 0 },
+ /* 264 */
+ {LDNS_RR_TYPE_IPN, "IPN", 1, 1, type_ipn_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+#else
+{LDNS_RR_TYPE_NULL, "TYPE263", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE264", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+#endif
/* split in array, no longer contiguous */
#ifdef RRTYPE_TA
}
}
+#ifdef __BYTE_ORDER__
+# if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+# define htonll(x) (x)
+# define ntohll(x) (x)
+# else
+# define htonll(x) (((uint64_t)htonl((x) & 0xFFFFFFFF) << 32) | htonl((x) >> 32))
+# define ntohll(x) (((uint64_t)ntohl((x) & 0xFFFFFFFF) << 32) | ntohl((x) >> 32))
+# endif
+#else
+# define htonll(x) ((1==htonl(1)) ? (x) : ((uint64_t)htonl((x) & 0xFFFFFFFF) << 32) | htonl((x) >> 32))
+# define ntohll(x) ((1==ntohl(1)) ? (x) : ((uint64_t)ntohl((x) & 0xFFFFFFFF) << 32) | ntohl((x) >> 32))
+#endif
+
+ldns_status
+ldns_str2rdf_ipn(ldns_rdf **rd, const char *ipnstr)
+{
+ char *end;
+ uint8_t r[sizeof(uint64_t)];
+ char left[21], *right;
+
+ if(strlen(ipnstr) > 21)
+ return LDNS_STATUS_SYNTAX_INTEGER_OVERFLOW;
+ errno = 0; /* must set to zero before call,
+ note race condition on errno */
+ if((right = strchr(ipnstr, '.'))) {
+ uint32_t u32 = strtoul(right + 1, &end, 10);
+
+ if(*end != 0)
+ return LDNS_STATUS_ERR;
+
+ if(errno == ERANGE)
+ return LDNS_STATUS_SYNTAX_INTEGER_OVERFLOW;
+
+ u32 = htonl(u32);
+ memcpy(r + sizeof(uint32_t), &u32, sizeof(uint32_t));
+ memcpy(left, ipnstr, right - ipnstr);
+ left[right - ipnstr] = 0;
+
+ u32 = strtoul(left, &end, 10);
+ if(*end != 0)
+ return LDNS_STATUS_ERR;
+
+ if(errno == ERANGE)
+ return LDNS_STATUS_SYNTAX_INTEGER_OVERFLOW;
+
+ u32 = htonl(u32);
+ memcpy(r, &u32, sizeof(uint32_t));
+ } else {
+ uint64_t u64 = strtoull(ipnstr, &end, 10);
+
+ if(*end != 0)
+ return LDNS_STATUS_ERR;
+
+ if(u64 == ULLONG_MAX && errno == ERANGE)
+ return LDNS_STATUS_SYNTAX_INTEGER_OVERFLOW;
+
+ u64 = htonll(u64);
+ memcpy(r, &u64, sizeof(uint64_t));
+ }
+ *rd = ldns_rdf_new_frm_data(LDNS_RDF_TYPE_IPN, sizeof(r), r);
+ return *rd ? LDNS_STATUS_OK : LDNS_STATUS_MEM_ERR;
+}
+
ldns_status
ldns_str2rdf_int8(ldns_rdf **rd, const char *bytestr)
{
break;
case LDNS_RDF_TYPE_ILNP64:
case LDNS_RDF_TYPE_EUI64:
+ case LDNS_RDF_TYPE_IPN:
+ case LDNS_RDF_TYPE_INT64:
cur_rdf_length = LDNS_RDF_SIZE_8BYTES;
break;
case LDNS_RDF_TYPE_AAAA: