• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #define BPF_JLT  0xa0
27 #define BPF_JLE  0xb0
28 #define BPF_JSLT 0xc0
29 #define BPF_JSLE 0xd0
30 
31 #define BPF_W 0x00
32 #define BPF_H 0x08
33 #define BPF_B 0x10
34 
35 #define BPF_IMM 0x00
36 #define BPF_ABS 0x20
37 #define BPF_IND 0x40
38 #define BPF_MEM 0x60
39 #define BPF_LEN 0x80
40 #define BPF_MSH 0xa0
41 
42 #define BPF_DW   0x18
43 #define BPF_XADD 0xc0
44 
45 #define BPF_ADD 0x00
46 #define BPF_SUB 0x10
47 #define BPF_MUL 0x20
48 #define BPF_DIV 0x30
49 #define BPF_OR  0x40
50 #define BPF_AND 0x50
51 #define BPF_LSH 0x60
52 #define BPF_RSH 0x70
53 #define BPF_NEG 0x80
54 #define BPF_MOD 0x90
55 #define BPF_XOR 0xa0
56 
57 #define BPF_MOV  0xb0
58 #define BPF_ARSH 0xc0
59 
60 #define BPF_JA   0x00
61 #define BPF_JEQ  0x10
62 #define BPF_JGT  0x20
63 #define BPF_JGE  0x30
64 #define BPF_JSET 0x40
65 
66 #define BPF_K 0x00
67 #define BPF_X 0x08
68 
69 #define BPF_END   0xd0
70 #define BPF_TO_LE 0x00
71 #define BPF_TO_BE 0x08
72 
73 #define BPF_PSEUDO_MAP_FD 1
74 
75 #define MAX_BPF_REG 10
76 
77 struct bpf_insn
78 {
79   uint8_t code;
80   uint8_t dst_reg:4;
81   uint8_t src_reg:4;
82   int16_t off;
83   int32_t imm;
84 };
85 
86 #endif
87