aboutgitcodelistschat:MatrixIRC
path: root/src/debug/bpf_dbg.c
diff options
context:
space:
mode:
authorAlice Frosi <afrosi@redhat.com>2023-03-24 10:07:48 +0100
committerAlice Frosi <afrosi@redhat.com>2023-03-24 15:38:07 +0100
commit069009f8e39238ec1a67fba6cfb287b9a0cac83e (patch)
tree77f817eb7b96178b71f3d573a83cec19f7fba09c /src/debug/bpf_dbg.c
parent06b0f6d323c396ca1df000af96fdd07cc69b06e0 (diff)
downloadseitan-069009f8e39238ec1a67fba6cfb287b9a0cac83e.tar
seitan-069009f8e39238ec1a67fba6cfb287b9a0cac83e.tar.gz
seitan-069009f8e39238ec1a67fba6cfb287b9a0cac83e.tar.bz2
seitan-069009f8e39238ec1a67fba6cfb287b9a0cac83e.tar.lz
seitan-069009f8e39238ec1a67fba6cfb287b9a0cac83e.tar.xz
seitan-069009f8e39238ec1a67fba6cfb287b9a0cac83e.tar.zst
seitan-069009f8e39238ec1a67fba6cfb287b9a0cac83e.zip
Re-organize project and add license header
Diffstat (limited to 'src/debug/bpf_dbg.c')
-rw-r--r--src/debug/bpf_dbg.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/debug/bpf_dbg.c b/src/debug/bpf_dbg.c
new file mode 100644
index 0000000..b84c713
--- /dev/null
+++ b/src/debug/bpf_dbg.c
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-3.0-or-later
+ * Copyright 2023 Red Hat GmbH
+ * Author: Alice Frosi <afrosi@redhat.com>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <linux/filter.h>
+#include <unistd.h>
+
+#include "disasm.h"
+
+int main(int argc, char **argv)
+{
+ struct sock_filter *filter;
+ size_t fd, n;
+
+ if (argc < 2) {
+ perror("missing input file");
+ exit(EXIT_FAILURE);
+ }
+ filter = calloc(SIZE_FILTER, sizeof(struct sock_filter));
+ fd = open(argv[1], O_CLOEXEC | O_RDONLY);
+
+ n = read(fd, filter, sizeof(struct sock_filter) * SIZE_FILTER);
+ close(fd);
+ printf("Read %ld entries\n", n / sizeof(struct sock_filter));
+ bpf_disasm_all(filter, n / sizeof(struct sock_filter));
+ free(filter);
+ return 0;
+}