blob: d800a8fe9f34c156c5454c3549045b20610ad73a [file] [log] [blame]
Ben Cheng655a7c02013-10-16 16:09:24 -07001/****************************************************************************
2 ****************************************************************************
3 ***
4 *** This header was automatically generated from a Linux kernel header
5 *** of the same name, to make information necessary for userspace to
6 *** call into the kernel available to libc. It contains only constants,
7 *** structures, and macros generated from the original header, and thus,
8 *** contains no copyrightable information.
9 ***
10 *** To edit the content of this header, modify the corresponding
11 *** source file (e.g. under external/kernel-headers/original/) then
12 *** run bionic/libc/kernel/tools/update_all.py
13 ***
14 *** Any manual change here will be lost the next time this script will
15 *** be run. You've been warned!
16 ***
17 ****************************************************************************
18 ****************************************************************************/
19#ifndef __LINUX_IF_PACKET_H
20#define __LINUX_IF_PACKET_H
21#include <linux/types.h>
22struct sockaddr_pkt {
Tao Baod7db5942015-01-28 10:07:51 -080023 unsigned short spkt_family;
24 unsigned char spkt_device[14];
25 __be16 spkt_protocol;
Ben Cheng655a7c02013-10-16 16:09:24 -070026};
Ben Cheng655a7c02013-10-16 16:09:24 -070027struct sockaddr_ll {
Tao Baod7db5942015-01-28 10:07:51 -080028 unsigned short sll_family;
29 __be16 sll_protocol;
30 int sll_ifindex;
Tao Baod7db5942015-01-28 10:07:51 -080031 unsigned short sll_hatype;
32 unsigned char sll_pkttype;
33 unsigned char sll_halen;
34 unsigned char sll_addr[8];
Ben Cheng655a7c02013-10-16 16:09:24 -070035};
36#define PACKET_HOST 0
37#define PACKET_BROADCAST 1
38#define PACKET_MULTICAST 2
Ben Cheng655a7c02013-10-16 16:09:24 -070039#define PACKET_OTHERHOST 3
40#define PACKET_OUTGOING 4
41#define PACKET_LOOPBACK 5
Christopher Ferris38062f92014-07-09 15:33:25 -070042#define PACKET_USER 6
Christopher Ferris38062f92014-07-09 15:33:25 -070043#define PACKET_KERNEL 7
44#define PACKET_FASTROUTE 6
Ben Cheng655a7c02013-10-16 16:09:24 -070045#define PACKET_ADD_MEMBERSHIP 1
46#define PACKET_DROP_MEMBERSHIP 2
47#define PACKET_RECV_OUTPUT 3
48#define PACKET_RX_RING 5
Ben Cheng655a7c02013-10-16 16:09:24 -070049#define PACKET_STATISTICS 6
50#define PACKET_COPY_THRESH 7
51#define PACKET_AUXDATA 8
52#define PACKET_ORIGDEV 9
Ben Cheng655a7c02013-10-16 16:09:24 -070053#define PACKET_VERSION 10
54#define PACKET_HDRLEN 11
55#define PACKET_RESERVE 12
56#define PACKET_TX_RING 13
Ben Cheng655a7c02013-10-16 16:09:24 -070057#define PACKET_LOSS 14
58#define PACKET_VNET_HDR 15
59#define PACKET_TX_TIMESTAMP 16
60#define PACKET_TIMESTAMP 17
Ben Cheng655a7c02013-10-16 16:09:24 -070061#define PACKET_FANOUT 18
62#define PACKET_TX_HAS_OFF 19
Christopher Ferris38062f92014-07-09 15:33:25 -070063#define PACKET_QDISC_BYPASS 20
Christopher Ferris05d08e92016-02-04 13:16:38 -080064#define PACKET_ROLLOVER_STATS 21
65#define PACKET_FANOUT_DATA 22
Ben Cheng655a7c02013-10-16 16:09:24 -070066#define PACKET_FANOUT_HASH 0
67#define PACKET_FANOUT_LB 1
Ben Cheng655a7c02013-10-16 16:09:24 -070068#define PACKET_FANOUT_CPU 2
Christopher Ferris38062f92014-07-09 15:33:25 -070069#define PACKET_FANOUT_ROLLOVER 3
70#define PACKET_FANOUT_RND 4
71#define PACKET_FANOUT_QM 5
Christopher Ferris05d08e92016-02-04 13:16:38 -080072#define PACKET_FANOUT_CBPF 6
73#define PACKET_FANOUT_EBPF 7
Christopher Ferris38062f92014-07-09 15:33:25 -070074#define PACKET_FANOUT_FLAG_ROLLOVER 0x1000
Christopher Ferris38062f92014-07-09 15:33:25 -070075#define PACKET_FANOUT_FLAG_DEFRAG 0x8000
Ben Cheng655a7c02013-10-16 16:09:24 -070076struct tpacket_stats {
Tao Baod7db5942015-01-28 10:07:51 -080077 unsigned int tp_packets;
78 unsigned int tp_drops;
Christopher Ferris38062f92014-07-09 15:33:25 -070079};
Ben Cheng655a7c02013-10-16 16:09:24 -070080struct tpacket_stats_v3 {
Tao Baod7db5942015-01-28 10:07:51 -080081 unsigned int tp_packets;
82 unsigned int tp_drops;
Tao Baod7db5942015-01-28 10:07:51 -080083 unsigned int tp_freeze_q_cnt;
Ben Cheng655a7c02013-10-16 16:09:24 -070084};
Christopher Ferris05d08e92016-02-04 13:16:38 -080085struct tpacket_rollover_stats {
86 __aligned_u64 tp_all;
Christopher Ferris05d08e92016-02-04 13:16:38 -080087 __aligned_u64 tp_huge;
88 __aligned_u64 tp_failed;
89};
90union tpacket_stats_u {
Christopher Ferris05d08e92016-02-04 13:16:38 -080091 struct tpacket_stats stats1;
Tao Baod7db5942015-01-28 10:07:51 -080092 struct tpacket_stats_v3 stats3;
Ben Cheng655a7c02013-10-16 16:09:24 -070093};
94struct tpacket_auxdata {
Christopher Ferris05d08e92016-02-04 13:16:38 -080095 __u32 tp_status;
Tao Baod7db5942015-01-28 10:07:51 -080096 __u32 tp_len;
97 __u32 tp_snaplen;
98 __u16 tp_mac;
Christopher Ferris05d08e92016-02-04 13:16:38 -080099 __u16 tp_net;
Tao Baod7db5942015-01-28 10:07:51 -0800100 __u16 tp_vlan_tci;
101 __u16 tp_vlan_tpid;
Ben Cheng655a7c02013-10-16 16:09:24 -0700102};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800103#define TP_STATUS_KERNEL 0
Christopher Ferris38062f92014-07-09 15:33:25 -0700104#define TP_STATUS_USER (1 << 0)
Ben Cheng655a7c02013-10-16 16:09:24 -0700105#define TP_STATUS_COPY (1 << 1)
106#define TP_STATUS_LOSING (1 << 2)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800107#define TP_STATUS_CSUMNOTREADY (1 << 3)
Christopher Ferris38062f92014-07-09 15:33:25 -0700108#define TP_STATUS_VLAN_VALID (1 << 4)
Ben Cheng655a7c02013-10-16 16:09:24 -0700109#define TP_STATUS_BLK_TMO (1 << 5)
Christopher Ferris38062f92014-07-09 15:33:25 -0700110#define TP_STATUS_VLAN_TPID_VALID (1 << 6)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800111#define TP_STATUS_CSUM_VALID (1 << 7)
112#define TP_STATUS_AVAILABLE 0
Ben Cheng655a7c02013-10-16 16:09:24 -0700113#define TP_STATUS_SEND_REQUEST (1 << 0)
114#define TP_STATUS_SENDING (1 << 1)
Ben Cheng655a7c02013-10-16 16:09:24 -0700115#define TP_STATUS_WRONG_FORMAT (1 << 2)
116#define TP_STATUS_TS_SOFTWARE (1 << 29)
117#define TP_STATUS_TS_SYS_HARDWARE (1 << 30)
118#define TP_STATUS_TS_RAW_HARDWARE (1 << 31)
Ben Cheng655a7c02013-10-16 16:09:24 -0700119#define TP_FT_REQ_FILL_RXHASH 0x1
120struct tpacket_hdr {
Tao Baod7db5942015-01-28 10:07:51 -0800121 unsigned long tp_status;
122 unsigned int tp_len;
123 unsigned int tp_snaplen;
124 unsigned short tp_mac;
Tao Baod7db5942015-01-28 10:07:51 -0800125 unsigned short tp_net;
126 unsigned int tp_sec;
127 unsigned int tp_usec;
Ben Cheng655a7c02013-10-16 16:09:24 -0700128};
129#define TPACKET_ALIGNMENT 16
Tao Baod7db5942015-01-28 10:07:51 -0800130#define TPACKET_ALIGN(x) (((x) + TPACKET_ALIGNMENT - 1) & ~(TPACKET_ALIGNMENT - 1))
Ben Cheng655a7c02013-10-16 16:09:24 -0700131#define TPACKET_HDRLEN (TPACKET_ALIGN(sizeof(struct tpacket_hdr)) + sizeof(struct sockaddr_ll))
132struct tpacket2_hdr {
Tao Baod7db5942015-01-28 10:07:51 -0800133 __u32 tp_status;
134 __u32 tp_len;
135 __u32 tp_snaplen;
136 __u16 tp_mac;
Tao Baod7db5942015-01-28 10:07:51 -0800137 __u16 tp_net;
138 __u32 tp_sec;
139 __u32 tp_nsec;
140 __u16 tp_vlan_tci;
Tao Baod7db5942015-01-28 10:07:51 -0800141 __u16 tp_vlan_tpid;
142 __u8 tp_padding[4];
Christopher Ferris38062f92014-07-09 15:33:25 -0700143};
Ben Cheng655a7c02013-10-16 16:09:24 -0700144struct tpacket_hdr_variant1 {
Tao Baod7db5942015-01-28 10:07:51 -0800145 __u32 tp_rxhash;
146 __u32 tp_vlan_tci;
147 __u16 tp_vlan_tpid;
148 __u16 tp_padding;
Christopher Ferris38062f92014-07-09 15:33:25 -0700149};
Ben Cheng655a7c02013-10-16 16:09:24 -0700150struct tpacket3_hdr {
Tao Baod7db5942015-01-28 10:07:51 -0800151 __u32 tp_next_offset;
152 __u32 tp_sec;
Tao Baod7db5942015-01-28 10:07:51 -0800153 __u32 tp_nsec;
154 __u32 tp_snaplen;
155 __u32 tp_len;
156 __u32 tp_status;
Tao Baod7db5942015-01-28 10:07:51 -0800157 __u16 tp_mac;
158 __u16 tp_net;
159 union {
160 struct tpacket_hdr_variant1 hv1;
Tao Baod7db5942015-01-28 10:07:51 -0800161 };
162 __u8 tp_padding[8];
Ben Cheng655a7c02013-10-16 16:09:24 -0700163};
164struct tpacket_bd_ts {
Tao Baod7db5942015-01-28 10:07:51 -0800165 unsigned int ts_sec;
166 union {
167 unsigned int ts_usec;
168 unsigned int ts_nsec;
Tao Baod7db5942015-01-28 10:07:51 -0800169 };
Ben Cheng655a7c02013-10-16 16:09:24 -0700170};
Ben Cheng655a7c02013-10-16 16:09:24 -0700171struct tpacket_hdr_v1 {
Tao Baod7db5942015-01-28 10:07:51 -0800172 __u32 block_status;
Tao Baod7db5942015-01-28 10:07:51 -0800173 __u32 num_pkts;
174 __u32 offset_to_first_pkt;
175 __u32 blk_len;
176 __aligned_u64 seq_num;
Tao Baod7db5942015-01-28 10:07:51 -0800177 struct tpacket_bd_ts ts_first_pkt, ts_last_pkt;
Ben Cheng655a7c02013-10-16 16:09:24 -0700178};
Ben Cheng655a7c02013-10-16 16:09:24 -0700179union tpacket_bd_header_u {
Tao Baod7db5942015-01-28 10:07:51 -0800180 struct tpacket_hdr_v1 bh1;
Ben Cheng655a7c02013-10-16 16:09:24 -0700181};
182struct tpacket_block_desc {
Tao Baod7db5942015-01-28 10:07:51 -0800183 __u32 version;
184 __u32 offset_to_priv;
Tao Baod7db5942015-01-28 10:07:51 -0800185 union tpacket_bd_header_u hdr;
Ben Cheng655a7c02013-10-16 16:09:24 -0700186};
Ben Cheng655a7c02013-10-16 16:09:24 -0700187#define TPACKET2_HDRLEN (TPACKET_ALIGN(sizeof(struct tpacket2_hdr)) + sizeof(struct sockaddr_ll))
188#define TPACKET3_HDRLEN (TPACKET_ALIGN(sizeof(struct tpacket3_hdr)) + sizeof(struct sockaddr_ll))
189enum tpacket_versions {
Tao Baod7db5942015-01-28 10:07:51 -0800190 TPACKET_V1,
191 TPACKET_V2,
192 TPACKET_V3
Ben Cheng655a7c02013-10-16 16:09:24 -0700193};
194struct tpacket_req {
Tao Baod7db5942015-01-28 10:07:51 -0800195 unsigned int tp_block_size;
196 unsigned int tp_block_nr;
Tao Baod7db5942015-01-28 10:07:51 -0800197 unsigned int tp_frame_size;
198 unsigned int tp_frame_nr;
Ben Cheng655a7c02013-10-16 16:09:24 -0700199};
200struct tpacket_req3 {
Tao Baod7db5942015-01-28 10:07:51 -0800201 unsigned int tp_block_size;
202 unsigned int tp_block_nr;
203 unsigned int tp_frame_size;
204 unsigned int tp_frame_nr;
Tao Baod7db5942015-01-28 10:07:51 -0800205 unsigned int tp_retire_blk_tov;
206 unsigned int tp_sizeof_priv;
207 unsigned int tp_feature_req_word;
Ben Cheng655a7c02013-10-16 16:09:24 -0700208};
209union tpacket_req_u {
Tao Baod7db5942015-01-28 10:07:51 -0800210 struct tpacket_req req;
211 struct tpacket_req3 req3;
Ben Cheng655a7c02013-10-16 16:09:24 -0700212};
213struct packet_mreq {
Tao Baod7db5942015-01-28 10:07:51 -0800214 int mr_ifindex;
215 unsigned short mr_type;
216 unsigned short mr_alen;
Tao Baod7db5942015-01-28 10:07:51 -0800217 unsigned char mr_address[8];
Ben Cheng655a7c02013-10-16 16:09:24 -0700218};
Ben Cheng655a7c02013-10-16 16:09:24 -0700219#define PACKET_MR_MULTICAST 0
220#define PACKET_MR_PROMISC 1
221#define PACKET_MR_ALLMULTI 2
222#define PACKET_MR_UNICAST 3
Ben Cheng655a7c02013-10-16 16:09:24 -0700223#endif