summaryrefslogtreecommitdiff
path: root/set.h
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2019-11-19 00:18:17 (GMT)
committerStefano Brivio <sbrivio@redhat.com>2019-11-19 00:18:17 (GMT)
commita724e8dbd67ce3d9bf5a24bd836dea4ad3a5516f (patch)
tree8575f185b5f2e773a7334ffe1dd5891a70bb2151 /set.h
pipapo: Initial importHEADmaster
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'set.h')
-rw-r--r--set.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/set.h b/set.h
new file mode 100644
index 0000000..37845d3
--- /dev/null
+++ b/set.h
@@ -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