switch (vp->vp_type) {
case FR_TYPE_VARIABLE_SIZE:
#ifndef NDEBUG
- if (!vp->da->flags.extra &&
- (vp->da->flags.subtype == FLAG_ENCODE_DNS_LABEL)) {
+ if (da_is_dns_label(vp->da)) {
fr_assert_fail("DNS labels MUST be encoded/decoded with their own function, and not with generic 'string' functions");
return 0;
}
*/
if (flags->extra || !flags->subtype) return true;
- if (type != FR_TYPE_STRING) {
+ if ((type != FR_TYPE_STRING) && (flags->subtype == FLAG_ENCODE_DNS_LABEL)) {
fr_strerror_const("The 'dns_label' flag can only be used with attributes of type 'string'");
return false;
}
/*
* @todo - we might need to limit this to only one DNS label.
*/
- if ((parent->type == FR_TYPE_STRING) && !parent->flags.extra &&
- (parent->flags.subtype == FLAG_ENCODE_DNS_LABEL)) {
+ if ((parent->type == FR_TYPE_STRING) && da_is_dns_label(parent)) {
return decode_dns_labels(ctx, out, parent, data, data_len, decode_ctx);
}
}
FR_PROTO_TRACE("decode context changed %s -> %s",da->parent->name, da->name);
- if ((da->type == FR_TYPE_STRING) && !da->flags.extra &&
- (da->flags.subtype == FLAG_ENCODE_DNS_LABEL)) {
+ if ((da->type == FR_TYPE_STRING) && da_is_dns_label(da)) {
fr_pair_list_t tmp;
fr_pair_list_init(&tmp);
FLAG_ENCODE_DNS_LABEL, //!< encode as DNS label
};
+#define da_is_dns_label(_da) (!(_da)->flags.extra && ((_da)->flags.subtype == FLAG_ENCODE_DNS_LABEL))
+
+
typedef struct {
uint8_t opcode;
uint8_t htype;
*
* https://tools.ietf.org/html/rfc8415#section-10
*/
- if (!da->flags.extra && (da->flags.subtype == FLAG_ENCODE_DNS_LABEL)) {
+ if (da_is_dns_label(da)) {
fr_dbuff_marker_t last_byte, src;
fr_dbuff_marker(&last_byte, &work_dbuff);
* DNS labels have internalized length, so we don't need
* length headers.
*/
- if ((da->type == FR_TYPE_STRING) && !da->flags.extra && (da->flags.subtype == FLAG_ENCODE_DNS_LABEL)) {
+ if ((da->type == FR_TYPE_STRING) && da_is_dns_label(da)) {
while (fr_dbuff_extend(&work_dbuff)) {
vp = fr_dcursor_current(cursor);