• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 R"********(
2 /*
3  * Copyright (c) 2015 PLUMgrid, Inc.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef __BCC_PROTO_H
19 #define __BCC_PROTO_H
20 
21 #include <uapi/linux/if_ether.h>
22 
23 #define BPF_PACKET_HEADER __attribute__((packed)) __attribute__((deprecated("packet")))
24 
25 struct ethernet_t {
26   unsigned long long  dst:48;
27   unsigned long long  src:48;
28   unsigned int        type:16;
29 } BPF_PACKET_HEADER;
30 
31 struct dot1q_t {
32   unsigned short pri:3;
33   unsigned short cfi:1;
34   unsigned short vlanid:12;
35   unsigned short type;
36 } BPF_PACKET_HEADER;
37 
38 struct arp_t {
39   unsigned short      htype;
40   unsigned short      ptype;
41   unsigned char       hlen;
42   unsigned char       plen;
43   unsigned short      oper;
44   unsigned long long  sha:48;
45   unsigned long long  spa:32;
46   unsigned long long  tha:48;
47   unsigned int        tpa;
48 } BPF_PACKET_HEADER;
49 
50 struct ip_t {
51   unsigned char   ver:4;           // byte 0
52   unsigned char   hlen:4;
53   unsigned char   tos;
54   unsigned short  tlen;
55   unsigned short  identification; // byte 4
56   unsigned short  ffo_unused:1;
57   unsigned short  df:1;
58   unsigned short  mf:1;
59   unsigned short  foffset:13;
60   unsigned char   ttl;             // byte 8
61   unsigned char   nextp;
62   unsigned short  hchecksum;
63   unsigned int    src;            // byte 12
64   unsigned int    dst;            // byte 16
65 } BPF_PACKET_HEADER;
66 
67 struct icmp_t {
68   unsigned char   type;
69   unsigned char   code;
70   unsigned short  checksum;
71 } BPF_PACKET_HEADER;
72 
73 struct ip6_t {
74   unsigned int        ver:4;
75   unsigned int        priority:8;
76   unsigned int        flow_label:20;
77   unsigned short      payload_len;
78   unsigned char       next_header;
79   unsigned char       hop_limit;
80   unsigned long long  src_hi;
81   unsigned long long  src_lo;
82   unsigned long long  dst_hi;
83   unsigned long long  dst_lo;
84 } BPF_PACKET_HEADER;
85 
86 struct ip6_opt_t {
87   unsigned char  next_header;
88   unsigned char  ext_len;
89   unsigned char  pad[6];
90 } BPF_PACKET_HEADER;
91 
92 struct icmp6_t {
93   unsigned char   type;
94   unsigned char   code;
95   unsigned short  checksum;
96 } BPF_PACKET_HEADER;
97 
98 struct udp_t {
99   unsigned short sport;
100   unsigned short dport;
101   unsigned short length;
102   unsigned short crc;
103 } BPF_PACKET_HEADER;
104 
105 struct tcp_t {
106   unsigned short  src_port;   // byte 0
107   unsigned short  dst_port;
108   unsigned int    seq_num;    // byte 4
109   unsigned int    ack_num;    // byte 8
110   unsigned char   offset:4;    // byte 12
111   unsigned char   reserved:4;
112   unsigned char   flag_cwr:1;
113   unsigned char   flag_ece:1;
114   unsigned char   flag_urg:1;
115   unsigned char   flag_ack:1;
116   unsigned char   flag_psh:1;
117   unsigned char   flag_rst:1;
118   unsigned char   flag_syn:1;
119   unsigned char   flag_fin:1;
120   unsigned short  rcv_wnd;
121   unsigned short  cksum;      // byte 16
122   unsigned short  urg_ptr;
123 } BPF_PACKET_HEADER;
124 
125 struct vxlan_t {
126   unsigned int rsv1:4;
127   unsigned int iflag:1;
128   unsigned int rsv2:3;
129   unsigned int rsv3:24;
130   unsigned int key:24;
131   unsigned int rsv4:8;
132 } BPF_PACKET_HEADER;
133 
134 struct vxlan_gbp_t {
135   unsigned int gflag:1;
136   unsigned int rsv1:3;
137   unsigned int iflag:1;
138   unsigned int rsv2:3;
139   unsigned int rsv3:1;
140   unsigned int dflag:1;
141   unsigned int rsv4:1;
142   unsigned int aflag:1;
143   unsigned int rsv5:3;
144   unsigned int tag:16;
145   unsigned int key:24;
146   unsigned int rsv6:8;
147 } BPF_PACKET_HEADER;
148 
149 #endif
150 )********"
151