{ L("dns_label"), FLAG_ENCODE_DNS_LABEL },
{ L("encode=dns_label"), FLAG_ENCODE_DNS_LABEL },
{ L("prefix=split"), FLAG_ENCODE_SPLIT_PREFIX },
+ { L("prefix=bits"), FLAG_ENCODE_BITS_PREFIX },
{ L("encode=exists"), FLAG_ENCODE_BOOL_EXISTS },
};
fr_strerror_const("string/octets arrays require the 'length=uint8' flag");
return false;
}
- } else if (flags->array && !flags->length) {
+
+ } else if (flags->array && !flags->length && !flags->is_known_width) {
fr_strerror_const("Variable length attributes cannot be marked as 'array'");
return false;
}
return false;
}
- if ((type != FR_TYPE_IPV4_PREFIX) && (flags->subtype == FLAG_ENCODE_SPLIT_PREFIX)) {
- fr_strerror_const("The 'split' flag can only be used with attributes of type 'ipv4prefix'");
+ if ((type != FR_TYPE_IPV4_PREFIX) &&
+ ((flags->subtype == FLAG_ENCODE_SPLIT_PREFIX) || (flags->subtype == FLAG_ENCODE_BITS_PREFIX))) {
+ fr_strerror_const("The 'prefix=...' flag can only be used with attributes of type 'ipv4prefix'");
return false;
}
FLAG_ENCODE_NONE = 0, //!< no particular encoding for DHCPv6 strings
FLAG_ENCODE_DNS_LABEL, //!< encode as DNS label
FLAG_ENCODE_SPLIT_PREFIX, //!< encode IPv4 prefixes as Policy-Filter, split into IP/mask
+ FLAG_ENCODE_BITS_PREFIX, //!< encode IPv4 prefixes as prefix bits, followed by IP.
FLAG_ENCODE_BOOL_EXISTS, //!< bool as existence checks
};
#define da_is_dns_label(_da) (!(_da)->flags.extra && ((_da)->flags.subtype == FLAG_ENCODE_DNS_LABEL))
#define da_is_split_prefix(_da) (!(_da)->flags.extra && ((_da)->flags.subtype == FLAG_ENCODE_SPLIT_PREFIX))
+#define da_is_bits_prefix(_da) (!(_da)->flags.extra && ((_da)->flags.subtype == FLAG_ENCODE_BITS_PREFIX))
#define da_is_bool_exists(_da) (!(_da)->flags.extra && ((_da)->flags.subtype == FLAG_ENCODE_BOOL_EXISTS))
typedef struct {