aboutgitcodelistschat:MatrixIRC
path: root/cooker/parse.c
diff options
context:
space:
mode:
authorAlice Frosi <afrosi@redhat.com>2023-05-17 15:46:57 +0200
committerAlice Frosi <afrosi@redhat.com>2023-05-17 16:05:51 +0200
commitef403b6687ec5739933f9f215093e1ea5c923666 (patch)
tree1e13e29251c18541b9b6f915e142aca886806e60 /cooker/parse.c
parent1e78526693d22abe24c98291a782998573f6b01d (diff)
downloadseitan-ef403b6687ec5739933f9f215093e1ea5c923666.tar
seitan-ef403b6687ec5739933f9f215093e1ea5c923666.tar.gz
seitan-ef403b6687ec5739933f9f215093e1ea5c923666.tar.bz2
seitan-ef403b6687ec5739933f9f215093e1ea5c923666.tar.lz
seitan-ef403b6687ec5739933f9f215093e1ea5c923666.tar.xz
seitan-ef403b6687ec5739933f9f215093e1ea5c923666.tar.zst
seitan-ef403b6687ec5739933f9f215093e1ea5c923666.zip
cooker, seitan: simple working example
parser: - add OP_BLOCK and OP_RETURN to the parser seitan: - fix op_cmp in seitan, it was jmp when comparison was true Working example: demo.json: [ { "match": [ /* qemu-pr-helper and similar */ { "connect": { "addr": { "family": "unix", "path": "/tmp/test.sock" } } } ], "return": 0 } ] Create gluten and the bpf filter: $ seitan-cooker demo.hjson demo.gluten demo.bpf Launch the seitan eater with the target program: $ seitan-eater -i demo.bpf -- strace -e connect tests-utils/test-syscalls connect Start seitan with gluten: $ seitan -i demo.gluten -p $(pgrep seitan-eater) Seitan mocks the connect syscall and `connect` returns successfully: $ seitan-eater -i demo.bpf -- strace -e connect tests-utils/test-syscalls connect Test syscall: connect connect(4, {sa_family=AF_UNIX, sun_path="/tmp/test.sock"}, 108) = 0
Diffstat (limited to 'cooker/parse.c')
-rw-r--r--cooker/parse.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/cooker/parse.c b/cooker/parse.c
index 09b1e46..acb6810 100644
--- a/cooker/parse.c
+++ b/cooker/parse.c
@@ -38,14 +38,14 @@ static void handle_limit(struct gluten_ctx *g, JSON_Value *value)
static void handle_return(struct gluten_ctx *g, JSON_Value *value)
{
- (void)g;
- (void)value;
+ union value v = { .v_u64 = json_value_get_number(value) };
+
+ emit_return(g, emit_data(g, U64, sizeof(v.v_u64), &v));
}
static void handle_block(struct gluten_ctx *g, JSON_Value *value)
{
- (void)g;
- (void)value;
+ emit_block(g, json_value_get_number(value));
}
static void handle_context(struct gluten_ctx *g, JSON_Value *value)