forked from iovisor/bcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
proto.b
157 lines (137 loc) · 1.9 KB
/
proto.b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
// Copyright (c) PLUMgrid, Inc.
// Licensed under the Apache License, Version 2.0 (the "License")
#packed "true"
struct ethernet {
u64 dst:48;
u64 src:48;
u32 type:16;
};
state ethernet {
switch $ethernet.type {
case 0x0800 {
next proto::ip;
};
case 0x8100 {
next proto::dot1q;
};
case * {
goto EOP;
};
}
}
struct dot1q {
u32 pri:3;
u32 cfi:1;
u32 vlanid:12;
u32 type:16;
};
state dot1q {
switch $dot1q.type {
case 0x0800 {
next proto::ip;
};
case * {
goto EOP;
};
}
}
struct ip {
u32 ver:4;
u32 hlen:4;
u32 tos:8;
u32 tlen:16;
u32 identification:16;
u32 ffo_unused:1;
u32 df:1;
u32 mf:1;
u32 foffset:13;
u32 ttl:8;
u32 nextp:8;
u32 hchecksum:16;
u32 src:32;
u32 dst:32;
};
state ip {
switch $ip.nextp {
case 6 {
next proto::tcp;
};
case 17 {
next proto::udp;
};
case 47 {
next proto::gre;
};
case * {
goto EOP;
};
}
}
struct udp {
u32 sport:16;
u32 dport:16;
u32 length:16;
u32 crc:16;
};
state udp {
switch $udp.dport {
case 8472 {
next proto::vxlan;
};
case * {
goto EOP;
};
}
}
struct tcp {
u16 src_port:16;
u16 dst_port:16;
u32 seq_num:32;
u32 ack_num:32;
u8 offset:4;
u8 reserved:4;
u8 flag_cwr:1;
u8 flag_ece:1;
u8 flag_urg:1;
u8 flag_ack:1;
u8 flag_psh:1;
u8 flag_rst:1;
u8 flag_syn:1;
u8 flag_fin:1;
u16 rcv_wnd:16;
u16 cksum:16;
u16 urg_ptr:16;
};
state tcp {
goto EOP;
}
struct vxlan {
u32 rsv1:4;
u32 iflag:1;
u32 rsv2:3;
u32 rsv3:24;
u32 key:24;
u32 rsv4:8;
};
state vxlan {
goto EOP;
}
struct gre {
u32 cflag:1;
u32 rflag:1;
u32 kflag:1;
u32 snflag:1;
u32 srflag:1;
u32 recurflag:3;
u32 reserved:5;
u32 vflag:3;
u32 protocol:16;
u32 key:32;
};
state gre {
switch $gre.protocol {
case * {
goto EOP;
};
}
}