• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * This header was generated from the Linux kernel headers by update_headers.py,
3  * to provide necessary information from kernel to userspace, such as constants,
4  * structures, and macros, and thus, contains no copyrightable information.
5  */
6 #ifndef __LINUX_IF_PACKET_H
7 #define __LINUX_IF_PACKET_H
8 #include <linux/types.h>
9 struct sockaddr_pkt {
10 	unsigned short spkt_family;
11 	unsigned char spkt_device[14];
12 	__be16 spkt_protocol;
13 };
14 struct sockaddr_ll {
15 	unsigned short	sll_family;
16 	__be16		sll_protocol;
17 	int		sll_ifindex;
18 	unsigned short	sll_hatype;
19 	unsigned char	sll_pkttype;
20 	unsigned char	sll_halen;
21 	unsigned char	sll_addr[8];
22 };
23 #define PACKET_HOST		0
24 #define PACKET_BROADCAST	1
25 #define PACKET_MULTICAST	2
26 #define PACKET_OTHERHOST	3
27 #define PACKET_OUTGOING		4
28 #define PACKET_LOOPBACK		5
29 #define PACKET_USER		6
30 #define PACKET_KERNEL		7
31 #define PACKET_FASTROUTE	6
32 #define PACKET_ADD_MEMBERSHIP		1
33 #define PACKET_DROP_MEMBERSHIP		2
34 #define PACKET_RECV_OUTPUT		3
35 #define PACKET_RX_RING			5
36 #define PACKET_STATISTICS		6
37 #define PACKET_COPY_THRESH		7
38 #define PACKET_AUXDATA			8
39 #define PACKET_ORIGDEV			9
40 #define PACKET_VERSION			10
41 #define PACKET_HDRLEN			11
42 #define PACKET_RESERVE			12
43 #define PACKET_TX_RING			13
44 #define PACKET_LOSS			14
45 #define PACKET_VNET_HDR			15
46 #define PACKET_TX_TIMESTAMP		16
47 #define PACKET_TIMESTAMP		17
48 #define PACKET_FANOUT			18
49 #define PACKET_TX_HAS_OFF		19
50 #define PACKET_QDISC_BYPASS		20
51 #define PACKET_ROLLOVER_STATS		21
52 #define PACKET_FANOUT_DATA		22
53 #define PACKET_FANOUT_HASH		0
54 #define PACKET_FANOUT_LB		1
55 #define PACKET_FANOUT_CPU		2
56 #define PACKET_FANOUT_ROLLOVER		3
57 #define PACKET_FANOUT_RND		4
58 #define PACKET_FANOUT_QM		5
59 #define PACKET_FANOUT_CBPF		6
60 #define PACKET_FANOUT_EBPF		7
61 #define PACKET_FANOUT_FLAG_ROLLOVER	0x1000
62 #define PACKET_FANOUT_FLAG_UNIQUEID	0x2000
63 #define PACKET_FANOUT_FLAG_DEFRAG	0x8000
64 struct tpacket_stats {
65 	unsigned int	tp_packets;
66 	unsigned int	tp_drops;
67 };
68 struct tpacket_stats_v3 {
69 	unsigned int	tp_packets;
70 	unsigned int	tp_drops;
71 	unsigned int	tp_freeze_q_cnt;
72 };
73 struct tpacket_rollover_stats {
74 	__aligned_u64	tp_all;
75 	__aligned_u64	tp_huge;
76 	__aligned_u64	tp_failed;
77 };
78 union tpacket_stats_u {
79 	struct tpacket_stats stats1;
80 	struct tpacket_stats_v3 stats3;
81 };
82 struct tpacket_auxdata {
83 	__u32		tp_status;
84 	__u32		tp_len;
85 	__u32		tp_snaplen;
86 	__u16		tp_mac;
87 	__u16		tp_net;
88 	__u16		tp_vlan_tci;
89 	__u16		tp_vlan_tpid;
90 };
91 #define TP_STATUS_KERNEL		      0
92 #define TP_STATUS_USER			(1 << 0)
93 #define TP_STATUS_COPY			(1 << 1)
94 #define TP_STATUS_LOSING		(1 << 2)
95 #define TP_STATUS_CSUMNOTREADY		(1 << 3)
96 #define TP_STATUS_VLAN_VALID		(1 << 4)
97 #define TP_STATUS_BLK_TMO		(1 << 5)
98 #define TP_STATUS_VLAN_TPID_VALID	(1 << 6)
99 #define TP_STATUS_CSUM_VALID		(1 << 7)
100 #define TP_STATUS_AVAILABLE	      0
101 #define TP_STATUS_SEND_REQUEST	(1 << 0)
102 #define TP_STATUS_SENDING	(1 << 1)
103 #define TP_STATUS_WRONG_FORMAT	(1 << 2)
104 #define TP_STATUS_TS_SOFTWARE		(1 << 29)
105 #define TP_STATUS_TS_SYS_HARDWARE	(1 << 30)
106 #define TP_STATUS_TS_RAW_HARDWARE	(1 << 31)
107 #define TP_FT_REQ_FILL_RXHASH	0x1
108 struct tpacket_hdr {
109 	unsigned long	tp_status;
110 	unsigned int	tp_len;
111 	unsigned int	tp_snaplen;
112 	unsigned short	tp_mac;
113 	unsigned short	tp_net;
114 	unsigned int	tp_sec;
115 	unsigned int	tp_usec;
116 };
117 #define TPACKET_ALIGNMENT	16
118 #define TPACKET_ALIGN(x)	(((x)+TPACKET_ALIGNMENT-1)&~(TPACKET_ALIGNMENT-1))
119 #define TPACKET_HDRLEN		(TPACKET_ALIGN(sizeof(struct tpacket_hdr)) + sizeof(struct sockaddr_ll))
120 struct tpacket2_hdr {
121 	__u32		tp_status;
122 	__u32		tp_len;
123 	__u32		tp_snaplen;
124 	__u16		tp_mac;
125 	__u16		tp_net;
126 	__u32		tp_sec;
127 	__u32		tp_nsec;
128 	__u16		tp_vlan_tci;
129 	__u16		tp_vlan_tpid;
130 	__u8		tp_padding[4];
131 };
132 struct tpacket_hdr_variant1 {
133 	__u32	tp_rxhash;
134 	__u32	tp_vlan_tci;
135 	__u16	tp_vlan_tpid;
136 	__u16	tp_padding;
137 };
138 struct tpacket3_hdr {
139 	__u32		tp_next_offset;
140 	__u32		tp_sec;
141 	__u32		tp_nsec;
142 	__u32		tp_snaplen;
143 	__u32		tp_len;
144 	__u32		tp_status;
145 	__u16		tp_mac;
146 	__u16		tp_net;
147 
148 	union {
149 		struct tpacket_hdr_variant1 hv1;
150 	};
151 	__u8		tp_padding[8];
152 };
153 struct tpacket_bd_ts {
154 	unsigned int ts_sec;
155 	union {
156 		unsigned int ts_usec;
157 		unsigned int ts_nsec;
158 	};
159 };
160 struct tpacket_hdr_v1 {
161 	__u32	block_status;
162 	__u32	num_pkts;
163 	__u32	offset_to_first_pkt;
164 
165 	__u32	blk_len;
166 
167 	__aligned_u64	seq_num;
168 
169 	struct tpacket_bd_ts	ts_first_pkt, ts_last_pkt;
170 };
171 union tpacket_bd_header_u {
172 	struct tpacket_hdr_v1 bh1;
173 };
174 struct tpacket_block_desc {
175 	__u32 version;
176 	__u32 offset_to_priv;
177 	union tpacket_bd_header_u hdr;
178 };
179 #define TPACKET2_HDRLEN		(TPACKET_ALIGN(sizeof(struct tpacket2_hdr)) + sizeof(struct sockaddr_ll))
180 #define TPACKET3_HDRLEN		(TPACKET_ALIGN(sizeof(struct tpacket3_hdr)) + sizeof(struct sockaddr_ll))
181 enum tpacket_versions {
182 	TPACKET_V1,
183 	TPACKET_V2,
184 	TPACKET_V3
185 };
186 struct tpacket_req {
187 	unsigned int	tp_block_size;
188 	unsigned int	tp_block_nr;
189 	unsigned int	tp_frame_size;
190 	unsigned int	tp_frame_nr;
191 };
192 struct tpacket_req3 {
193 	unsigned int	tp_block_size;
194 	unsigned int	tp_block_nr;
195 	unsigned int	tp_frame_size;
196 	unsigned int	tp_frame_nr;
197 	unsigned int	tp_retire_blk_tov;
198 	unsigned int	tp_sizeof_priv;
199 	unsigned int	tp_feature_req_word;
200 };
201 union tpacket_req_u {
202 	struct tpacket_req	req;
203 	struct tpacket_req3	req3;
204 };
205 struct packet_mreq {
206 	int		mr_ifindex;
207 	unsigned short	mr_type;
208 	unsigned short	mr_alen;
209 	unsigned char	mr_address[8];
210 };
211 #define PACKET_MR_MULTICAST	0
212 #define PACKET_MR_PROMISC	1
213 #define PACKET_MR_ALLMULTI	2
214 #define PACKET_MR_UNICAST	3
215 #endif
216