aboutgitcodelistschat:MatrixIRC
path: root/cooker/emit.c
diff options
context:
space:
mode:
Diffstat (limited to 'cooker/emit.c')
-rw-r--r--cooker/emit.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/cooker/emit.c b/cooker/emit.c
index 41b64a6..57533a1 100644
--- a/cooker/emit.c
+++ b/cooker/emit.c
@@ -11,6 +11,7 @@
#include "cooker.h"
#include "gluten.h"
+#include "filter.h"
#include "util.h"
#include "emit.h"
@@ -536,6 +537,32 @@ static void gluten_link(struct gluten_ctx *g, enum jump_type type,
}
}
+void emit_bpf_arg(int index, enum type type, union value v, union value mask,
+ enum op_cmp_type cmp)
+{
+ struct bpf_arg bpf;
+
+ /* gluten uses the comparison to skip to the next match, the BPF filter
+ * uses it to notify instead.
+ */
+ if (mask.v_num)
+ bpf.cmp = (cmp == CMP_EQ) ? AND_NE : AND_EQ;
+ else
+ bpf.cmp = (cmp == CMP_EQ) ? NE : EQ;
+
+ if (TYPE_IS_64BIT(type)) {
+ bpf.value.v64 = v.v_num;
+ bpf.op2.v64 = mask.v_num;
+ bpf.type = BPF_U64;
+ } else {
+ bpf.value.v32 = v.v_num;
+ bpf.op2.v32 = mask.v_num;
+ bpf.type = BPF_U32;
+ }
+
+ filter_add_arg(index, bpf);
+}
+
void link_block(struct gluten_ctx *g)
{
debug(" Linking block...");