^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (c) 2016 Facebook
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #ifndef __BPF_DISASM_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #define __BPF_DISASM_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/bpf.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/stringify.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #ifndef __KERNEL__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <stdio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) extern const char *const bpf_alu_string[16];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) extern const char *const bpf_class_string[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) const char *func_id_name(int id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) typedef __printf(2, 3) void (*bpf_insn_print_t)(void *private_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) const char *, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) typedef const char *(*bpf_insn_revmap_call_t)(void *private_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) const struct bpf_insn *insn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) typedef const char *(*bpf_insn_print_imm_t)(void *private_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) const struct bpf_insn *insn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) __u64 full_imm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) struct bpf_insn_cbs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) bpf_insn_print_t cb_print;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) bpf_insn_revmap_call_t cb_call;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) bpf_insn_print_imm_t cb_imm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) void *private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) void print_bpf_insn(const struct bpf_insn_cbs *cbs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) const struct bpf_insn *insn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) bool allow_ptr_leaks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #endif