Brian Silverman | 8649792 | 2018-02-10 19:28:39 -0500 | [diff] [blame^] | 1 | /* Minimal extended BPF constants as alternative for linux/bpf.h. */ |
2 | |||||
3 | #ifndef _ELFUTILS_BPF_H | ||||
4 | #define _ELFUTILS_BPF_H 1 | ||||
5 | |||||
6 | #include <stdint.h> | ||||
7 | |||||
8 | #define BPF_CLASS(code) ((code) & 0x07) | ||||
9 | |||||
10 | #define BPF_LD 0x00 | ||||
11 | #define BPF_LDX 0x01 | ||||
12 | #define BPF_ST 0x02 | ||||
13 | #define BPF_STX 0x03 | ||||
14 | #define BPF_ALU 0x04 | ||||
15 | #define BPF_JMP 0x05 | ||||
16 | #define BPF_RET 0x06 | ||||
17 | #define BPF_MISC 0x07 | ||||
18 | |||||
19 | #define BPF_ALU64 0x07 | ||||
20 | |||||
21 | #define BPF_JNE 0x50 | ||||
22 | #define BPF_JSGT 0x60 | ||||
23 | #define BPF_JSGE 0x70 | ||||
24 | #define BPF_CALL 0x80 | ||||
25 | #define BPF_EXIT 0x90 | ||||
26 | |||||
27 | #define BPF_W 0x00 | ||||
28 | #define BPF_H 0x08 | ||||
29 | #define BPF_B 0x10 | ||||
30 | |||||
31 | #define BPF_IMM 0x00 | ||||
32 | #define BPF_ABS 0x20 | ||||
33 | #define BPF_IND 0x40 | ||||
34 | #define BPF_MEM 0x60 | ||||
35 | #define BPF_LEN 0x80 | ||||
36 | #define BPF_MSH 0xa0 | ||||
37 | |||||
38 | #define BPF_DW 0x18 | ||||
39 | #define BPF_XADD 0xc0 | ||||
40 | |||||
41 | #define BPF_ADD 0x00 | ||||
42 | #define BPF_SUB 0x10 | ||||
43 | #define BPF_MUL 0x20 | ||||
44 | #define BPF_DIV 0x30 | ||||
45 | #define BPF_OR 0x40 | ||||
46 | #define BPF_AND 0x50 | ||||
47 | #define BPF_LSH 0x60 | ||||
48 | #define BPF_RSH 0x70 | ||||
49 | #define BPF_NEG 0x80 | ||||
50 | #define BPF_MOD 0x90 | ||||
51 | #define BPF_XOR 0xa0 | ||||
52 | |||||
53 | #define BPF_MOV 0xb0 | ||||
54 | #define BPF_ARSH 0xc0 | ||||
55 | |||||
56 | #define BPF_JA 0x00 | ||||
57 | #define BPF_JEQ 0x10 | ||||
58 | #define BPF_JGT 0x20 | ||||
59 | #define BPF_JGE 0x30 | ||||
60 | #define BPF_JSET 0x40 | ||||
61 | |||||
62 | #define BPF_K 0x00 | ||||
63 | #define BPF_X 0x08 | ||||
64 | |||||
65 | #define BPF_END 0xd0 | ||||
66 | #define BPF_TO_LE 0x00 | ||||
67 | #define BPF_TO_BE 0x08 | ||||
68 | |||||
69 | #define BPF_PSEUDO_MAP_FD 1 | ||||
70 | |||||
71 | #define MAX_BPF_REG 10 | ||||
72 | |||||
73 | struct bpf_insn | ||||
74 | { | ||||
75 | uint8_t code; | ||||
76 | uint8_t dst_reg:4; | ||||
77 | uint8_t src_reg:4; | ||||
78 | int16_t off; | ||||
79 | int32_t imm; | ||||
80 | }; | ||||
81 | |||||
82 | #endif |