There was a need to add a new rdf type representing 64bits represented as 4 hexidecimal shorts seperated by colons.
Proper testing still pending.
case LDNS_RDF_TYPE_NSEC3_SALT: return "NSEC3_SALT";
case LDNS_RDF_TYPE_NSEC3_NEXT_OWNER:
return "NSEC3_NEXT_OWNER";
+ case LDNS_RDF_TYPE_4_SHORTS: return "4_SHORTS";
}
}
return 0;
{ LDNS_STATUS_DANE_PKIX_NO_SELF_SIGNED_TRUST_ANCHOR,
"The validation path "
"did not end in a self-signed certificate" },
+ { LDNS_STATUS_INVALID_4_SHORTS,
+ "Conversion error, 4 colon seperated hex numbers expected" },
{ 0, NULL }
};
return ldns_rdf2buffer_str_unknown(output, rdf);
}
+ldns_status
+ldns_rdf2buffer_str_4_shorts(ldns_buffer *output, const ldns_rdf *rdf)
+{
+ ldns_buffer_printf(output,"%.4x:%.4x:%.4d:%.4x",
+ ldns_read_uint16(ldns_rdf_data(rdf)),
+ ldns_read_uint16(ldns_rdf_data(rdf)+2),
+ ldns_read_uint16(ldns_rdf_data(rdf)+4),
+ ldns_read_uint16(ldns_rdf_data(rdf)+6));
+ return ldns_buffer_status(output);
+}
ldns_status
ldns_rdf2buffer_str(ldns_buffer *buffer, const ldns_rdf *rdf)
case LDNS_RDF_TYPE_NSEC3_NEXT_OWNER:
res = ldns_rdf2buffer_str_b32_ext(buffer, rdf);
break;
+ case LDNS_RDF_TYPE_4_SHORTS:
+ res = ldns_rdf2buffer_str_4_shorts(buffer, rdf);
+ break;
}
} else {
/** This will write mangled RRs */
LDNS_STATUS_DANE_NON_CA_CERTIFICATE,
LDNS_STATUS_DANE_PKIX_DID_NOT_VALIDATE,
LDNS_STATUS_DANE_PKIX_NO_SELF_SIGNED_TRUST_ANCHOR,
- LDNS_STATUS_EXISTS_ERR
+ LDNS_STATUS_EXISTS_ERR,
+ LDNS_STATUS_INVALID_4_SHORTS
};
typedef enum ldns_enum_status ldns_status;
*/
ldns_status ldns_rdf2buffer_str_time(ldns_buffer *output, const ldns_rdf *rdf);
+/**
+ * Converts an LDNS_RDF_TYPE_4_SHORTS rdata element to 4 hexadecimal numbers
+ * seperated 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_4_shorts(ldns_buffer *output,
+ const ldns_rdf *rdf);
+
/**
* Converts the data in the rdata field to presentation format and
* returns that as a char *.
#define LDNS_RDF_SIZE_WORD 2
#define LDNS_RDF_SIZE_DOUBLEWORD 4
#define LDNS_RDF_SIZE_6BYTES 6
+#define LDNS_RDF_SIZE_8BYTES 8
#define LDNS_RDF_SIZE_16BYTES 16
#define LDNS_NSEC3_VARS_OPTOUT_MASK 0x01
/** nsec3 hash salt */
LDNS_RDF_TYPE_NSEC3_SALT,
/** nsec3 base32 string (with length byte on wire */
- LDNS_RDF_TYPE_NSEC3_NEXT_OWNER
+ LDNS_RDF_TYPE_NSEC3_NEXT_OWNER,
+ /** 4 shorts represented as 4 * 16 bit hex numbers seperated by colons */
+ LDNS_RDF_TYPE_4_SHORTS
};
typedef enum ldns_enum_rdf_type ldns_rdf_type;
LDNS_RR_TYPE_GID = 102,
LDNS_RR_TYPE_UNSPEC = 103,
+ LDNS_RR_TYPE_NID = 104, /* RFC 6742 */
+ LDNS_RR_TYPE_L32 = 105, /* RFC 6742 */
+ LDNS_RR_TYPE_L64 = 106, /* RFC 6742 */
+ LDNS_RR_TYPE_LP = 107, /* RFC 6742 */
+
LDNS_RR_TYPE_TSIG = 250,
LDNS_RR_TYPE_IXFR = 251,
LDNS_RR_TYPE_AXFR = 252,
*/
ldns_status ldns_str2rdf_dname(ldns_rdf **rd, const char *str);
+/**
+ * convert 4 * 16bit hex seperated by colons into wireformat
+ * \param[in] rd the rdf where to put the data
+ * \param[in] str the string to be converted
+ * \return ldns_status
+ */
+ldns_status ldns_str2rdf_4_shorts(ldns_rdf **rd, const char *str);
+
#ifdef __cplusplus
}
#endif
case LDNS_RDF_TYPE_NSEC3_NEXT_OWNER:
status = ldns_str2rdf_b32_ext(&rdf, str);
break;
+ case LDNS_RDF_TYPE_4_SHORTS:
+ status = ldns_str2rdf_4_shorts(&rdf, str);
+ break;
case LDNS_RDF_TYPE_NONE:
default:
/* default default ??? */
LDNS_RDF_TYPE_INT8,
LDNS_RDF_TYPE_HEX
};
+static const ldns_rdf_type type_nid_wireformat[] = {
+ LDNS_RDF_TYPE_INT16,
+ LDNS_RDF_TYPE_4_SHORTS
+};
+static const ldns_rdf_type type_l32_wireformat[] = {
+ LDNS_RDF_TYPE_INT16,
+ LDNS_RDF_TYPE_A
+};
+static const ldns_rdf_type type_l64_wireformat[] = {
+ LDNS_RDF_TYPE_INT16,
+ LDNS_RDF_TYPE_4_SHORTS
+};
+static const ldns_rdf_type type_lp_wireformat[] = {
+ LDNS_RDF_TYPE_INT16,
+ LDNS_RDF_TYPE_DNAME
+};
/** \endcond */
/** \cond */
{LDNS_RR_TYPE_NULL, "TYPE101", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE102", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE103", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
-{LDNS_RR_TYPE_NULL, "TYPE104", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
-{LDNS_RR_TYPE_NULL, "TYPE105", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
-{LDNS_RR_TYPE_NULL, "TYPE106", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
-{LDNS_RR_TYPE_NULL, "TYPE107", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 104 */
+{LDNS_RR_TYPE_NID, "NID", 2, 2, type_nid_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 105 */
+{LDNS_RR_TYPE_NID, "L32", 2, 2, type_l32_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 106 */
+{LDNS_RR_TYPE_NID, "L64", 2, 2, type_l64_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 107 */
+{LDNS_RR_TYPE_NID, "LP", 2, 2, type_lp_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
{LDNS_RR_TYPE_NULL, "TYPE108", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE109", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
{LDNS_RR_TYPE_NULL, "TYPE110", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
if(!*rd) return LDNS_STATUS_MEM_ERR;
return LDNS_STATUS_OK;
}
+
+ldns_status
+ldns_str2rdf_4_shorts(ldns_rdf **rd, const char *str)
+{
+ unsigned int a, b, c, d;
+ uint16_t shorts[4];
+
+ if (sscanf(str, "%x:%x:%x:%x", &a, &b, &c, &d) == EOF) {
+ return LDNS_STATUS_INVALID_4_SHORTS;
+ } else {
+ shorts[0] = htons(shorts[0]);
+ shorts[1] = htons(shorts[1]);
+ shorts[2] = htons(shorts[2]);
+ shorts[3] = htons(shorts[3]);
+ *rd = ldns_rdf_new_frm_data(
+ LDNS_RDF_TYPE_4_SHORTS, 4 * sizeof(uint16_t), &shorts);
+ }
+ return *rd ? LDNS_STATUS_OK : LDNS_STATUS_MEM_ERR;
+}
case LDNS_RDF_TYPE_TSIGTIME:
cur_rdf_length = LDNS_RDF_SIZE_6BYTES;
break;
+ case LDNS_RDF_TYPE_4_SHORTS:
+ cur_rdf_length = LDNS_RDF_SIZE_8BYTES;
+ break;
case LDNS_RDF_TYPE_AAAA:
cur_rdf_length = LDNS_RDF_SIZE_16BYTES;
break;