diff options
Diffstat (limited to 'set.h')
-rw-r--r-- | set.h | 43 |
1 files changed, 43 insertions, 0 deletions
@@ -0,0 +1,43 @@ +/** + * struct field - Pre-computed field data + * @offset: Offset in packet header, bytes + * @groups: Number of 4-bit groups + * @rules: Number of inserted rules + * @bsize: Lookup table bucket size, bytes + * @lt: Lookup table + * @mt: Mapping table (n:m rules in next field) + */ +struct field { + int offset; + int groups; + int rules; + + int bsize; + uint8_t *lt; + union map_bucket *mt; +}; + +/** + * struct set - Array of sets + * @fields: Composing fields + */ +struct set { + struct field *fields; +}; + +#define for_each_field(f, s, layout) \ + for ((i) = 0, (f) = (s)->fields; \ + (layout)[(i)]->type != KEY; \ + i++, f++) + +int init(struct set *s, struct desc_spec **layout); +int add(struct set *s, struct desc_spec **layout, uint8_t *data); +int list_or_del(struct set *s, struct desc_spec **layout, uint8_t *match); + +#ifdef VERBOSE +void show_lookup(struct field *f); +void show_mapping(struct field *f, int to_key); +#else +#define show_lookup(...) do { } while (0) +#define show_mapping(...) do { } while (0) +#endif |