unsigned int is_unsigned : 1; //!< hackity hack for dates and time deltas
+ unsigned int is_counter : 1; //!< integer attribute is actually an impulse / counter
+
/*
* @todo - if we want to clean these fields up, make
* "subtype" and "type_size" both 4-bit bitfields. That
} else if (strcmp(key, "array") == 0) {
flags->array = 1;
+ } else if (strcmp(key, "counter") == 0) {
+ flags->is_counter = 1;
+
} else if (strcmp(key, "virtual") == 0) {
flags->virtual = 1;
uint32_t shift_is_root, shift_internal;
uint32_t shift_array, shift_has_value;
uint32_t shift_virtual, shift_subtype, shift_extra;
+ uint32_t shift_is_counter;
fr_dict_attr_t const *v;
/*
SET_FLAG(has_value);
SET_FLAG(virtual);
SET_FLAG(extra);
+ SET_FLAG(is_counter);
SET_FLAG(subtype);
#define FORBID_OTHER_FLAGS(_flag) do { if (all_flags & ~shift_ ## _flag) { fr_strerror_printf("The '" STRINGIFY(_flag) "' flag cannot be used with any other flag"); return false; } } while (0)
}
}
+ /*
+ * Only numerical types can be counter
+ */
+ if (flags->is_counter) {
+ if (fr_type_is_numeric(type) && !fr_type_is_signed(type)) {
+ ALLOW_FLAG(is_counter);
+ } else {
+ fr_strerror_printf("The 'counter' flag cannot be used with '%s'", fr_type_to_str(type));
+ return false;
+ }
+ }
+
/*
* Check flags against the parent attribute.
*/