knot_quic_table_rem@Base 3.5.0
knot_quic_table_sweep@Base 3.5.0
knot_rcode_names@Base 3.5.0
+ knot_rdata_to_canonical@Base 3.5.0
knot_rdataset_add@Base 3.5.0
knot_rdataset_at@Base 3.5.0
knot_rdataset_clear@Base 3.5.0
return cmp;
}
+/*!
+ * \brief Converts rdata into canonical format.
+ *
+ * Rdata domain names are converted only for types listed in RFC 4034,
+ * Section 6.2, except for NSEC (updated by RFC 6840, Section 5.1) and
+ * A6 (not supported).
+ *
+ * \warning This function expects either empty rdata or full, not malformed
+ * rdata. If malformed rdata is passed to this function, memory errors
+ * may occur.
+ *
+ * \param rdata Rdata to convert.
+ * \param type Rdata type.
+ *
+ * \return Error code, KNOT_EOK if successful.
+ */
+int knot_rdata_to_canonical(knot_rdata_t *rdata, uint16_t type);
+
/*! @} */
}
_public_
-int knot_rrset_rr_to_canonical(knot_rrset_t *rrset)
+int knot_rdata_to_canonical(knot_rdata_t *rdata, uint16_t type)
{
- if (rrset == NULL || rrset->rrs.count != 1) {
+ if (rdata == NULL) {
return KNOT_EINVAL;
}
- /* Convert owner for all RRSets. */
- knot_dname_to_lower(rrset->owner);
-
/* Convert DNAMEs in RDATA only for RFC4034 types. */
- if (!knot_rrtype_should_be_lowercased(rrset->type)) {
+ if (!knot_rrtype_should_be_lowercased(type)) {
return KNOT_EOK;
}
- const knot_rdata_descriptor_t *desc = knot_get_rdata_descriptor(rrset->type);
+ const knot_rdata_descriptor_t *desc = knot_get_rdata_descriptor(type);
if (desc->type_name == NULL) {
- desc = knot_get_obsolete_rdata_descriptor(rrset->type);
+ desc = knot_get_obsolete_rdata_descriptor(type);
}
- uint16_t rdlen = rrset->rrs.rdata->len;
- uint8_t *pos = rrset->rrs.rdata->data;
+ uint16_t rdlen = rdata->len;
+ uint8_t *pos = rdata->data;
uint8_t *endpos = pos + rdlen;
/* No RDATA */
/* Otherwise, whole and not malformed RDATA are expected. */
for (int i = 0; desc->block_types[i] != KNOT_RDATA_WF_END; ++i) {
- int type = desc->block_types[i];
- switch (type) {
+ int block_type = desc->block_types[i];
+ switch (block_type) {
case KNOT_RDATA_WF_COMPRESSIBLE_DNAME:
case KNOT_RDATA_WF_DECOMPRESSIBLE_DNAME:
case KNOT_RDATA_WF_FIXED_DNAME:
break;
default:
/* Fixed size block */
- assert(type > 0);
- pos += type;
+ assert(block_type > 0);
+ pos += block_type;
}
}
return KNOT_EOK;
}
+_public_
+int knot_rrset_rr_to_canonical(knot_rrset_t *rrset)
+{
+ if (rrset == NULL || rrset->rrs.count != 1) {
+ return KNOT_EINVAL;
+ }
+
+ /* Convert owner for all RRSets. */
+ knot_dname_to_lower(rrset->owner);
+
+ return knot_rdata_to_canonical(rrset->rrs.rdata, rrset->type);
+}
+
_public_
size_t knot_rrset_size(const knot_rrset_t *rrset)
{
bool knot_rrset_is_nsec3rel(const knot_rrset_t *rr);
/*!
- * \brief Convert one RR into canonical format.
+ * \brief Converts RRSet with one RR into canonical format.
*
- * Owner is always converted to lowercase. RDATA domain names are converted only
- * for types listed in RFC 4034, Section 6.2, except for NSEC (updated by
- * RFC 6840, Section 5.1) and A6 (not supported).
+ * The RRSet owner is always converted to lowercase.
*
- * \note If RRSet with more RRs is given to this function, only the first RR
- * will be converted.
- * \warning This function expects either empty RDATA or full, not malformed
- * RDATA. If malformed RRSet is passed to this function, memory errors
- * may occur.
+ * \note See knot_rdata_to_canonical() for more details.
*
- * \param rrset RR to convert.
+ * \param rrset RRSet to convert.
+ *
+ * \return Error code, KNOT_EOK if successful.
*/
int knot_rrset_rr_to_canonical(knot_rrset_t *rrset);