0001
0002
0003
0004
0005
0006 #ifndef __BPF_DISASM_H__
0007 #define __BPF_DISASM_H__
0008
0009 #include <linux/bpf.h>
0010 #include <linux/kernel.h>
0011 #include <linux/stringify.h>
0012 #ifndef __KERNEL__
0013 #include <stdio.h>
0014 #include <string.h>
0015 #endif
0016
0017 extern const char *const bpf_alu_string[16];
0018 extern const char *const bpf_class_string[8];
0019
0020 const char *func_id_name(int id);
0021
0022 typedef __printf(2, 3) void (*bpf_insn_print_t)(void *private_data,
0023 const char *, ...);
0024 typedef const char *(*bpf_insn_revmap_call_t)(void *private_data,
0025 const struct bpf_insn *insn);
0026 typedef const char *(*bpf_insn_print_imm_t)(void *private_data,
0027 const struct bpf_insn *insn,
0028 __u64 full_imm);
0029
0030 struct bpf_insn_cbs {
0031 bpf_insn_print_t cb_print;
0032 bpf_insn_revmap_call_t cb_call;
0033 bpf_insn_print_imm_t cb_imm;
0034 void *private_data;
0035 };
0036
0037 void print_bpf_insn(const struct bpf_insn_cbs *cbs,
0038 const struct bpf_insn *insn,
0039 bool allow_ptr_leaks);
0040 #endif