blob: 1fe897a23946cccce25ea87ff406eb34cd06aedd [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
Christopher Ferris05667cd2021-02-16 16:01:34 -080021#include <asm/byteorder.h>
Ben Cheng655a7c02013-10-16 16:09:24 -070022#include <linux/types.h>
23struct sockaddr_pkt {
Tao Baod7db5942015-01-28 10:07:51 -080024 unsigned short spkt_family;
25 unsigned char spkt_device[14];
26 __be16 spkt_protocol;
Ben Cheng655a7c02013-10-16 16:09:24 -070027};
Ben Cheng655a7c02013-10-16 16:09:24 -070028struct sockaddr_ll {
Tao Baod7db5942015-01-28 10:07:51 -080029 unsigned short sll_family;
30 __be16 sll_protocol;
31 int sll_ifindex;
Tao Baod7db5942015-01-28 10:07:51 -080032 unsigned short sll_hatype;
33 unsigned char sll_pkttype;
34 unsigned char sll_halen;
35 unsigned char sll_addr[8];
Ben Cheng655a7c02013-10-16 16:09:24 -070036};
37#define PACKET_HOST 0
38#define PACKET_BROADCAST 1
39#define PACKET_MULTICAST 2
Ben Cheng655a7c02013-10-16 16:09:24 -070040#define PACKET_OTHERHOST 3
41#define PACKET_OUTGOING 4
42#define PACKET_LOOPBACK 5
Christopher Ferris38062f92014-07-09 15:33:25 -070043#define PACKET_USER 6
Christopher Ferris38062f92014-07-09 15:33:25 -070044#define PACKET_KERNEL 7
45#define PACKET_FASTROUTE 6
Ben Cheng655a7c02013-10-16 16:09:24 -070046#define PACKET_ADD_MEMBERSHIP 1
47#define PACKET_DROP_MEMBERSHIP 2
48#define PACKET_RECV_OUTPUT 3
49#define PACKET_RX_RING 5
Ben Cheng655a7c02013-10-16 16:09:24 -070050#define PACKET_STATISTICS 6
51#define PACKET_COPY_THRESH 7
52#define PACKET_AUXDATA 8
53#define PACKET_ORIGDEV 9
Ben Cheng655a7c02013-10-16 16:09:24 -070054#define PACKET_VERSION 10
55#define PACKET_HDRLEN 11
56#define PACKET_RESERVE 12
57#define PACKET_TX_RING 13
Ben Cheng655a7c02013-10-16 16:09:24 -070058#define PACKET_LOSS 14
59#define PACKET_VNET_HDR 15
60#define PACKET_TX_TIMESTAMP 16
61#define PACKET_TIMESTAMP 17
Ben Cheng655a7c02013-10-16 16:09:24 -070062#define PACKET_FANOUT 18
63#define PACKET_TX_HAS_OFF 19
Christopher Ferris38062f92014-07-09 15:33:25 -070064#define PACKET_QDISC_BYPASS 20
Christopher Ferris05d08e92016-02-04 13:16:38 -080065#define PACKET_ROLLOVER_STATS 21
66#define PACKET_FANOUT_DATA 22
Christopher Ferris86a48372019-01-10 14:14:59 -080067#define PACKET_IGNORE_OUTGOING 23
Christopher Ferris37c3f3c2023-07-10 10:59:05 -070068#define PACKET_VNET_HDR_SZ 24
Ben Cheng655a7c02013-10-16 16:09:24 -070069#define PACKET_FANOUT_HASH 0
70#define PACKET_FANOUT_LB 1
Ben Cheng655a7c02013-10-16 16:09:24 -070071#define PACKET_FANOUT_CPU 2
Christopher Ferris38062f92014-07-09 15:33:25 -070072#define PACKET_FANOUT_ROLLOVER 3
73#define PACKET_FANOUT_RND 4
74#define PACKET_FANOUT_QM 5
Christopher Ferris05d08e92016-02-04 13:16:38 -080075#define PACKET_FANOUT_CBPF 6
76#define PACKET_FANOUT_EBPF 7
Christopher Ferris38062f92014-07-09 15:33:25 -070077#define PACKET_FANOUT_FLAG_ROLLOVER 0x1000
Christopher Ferris525ce912017-07-26 13:12:53 -070078#define PACKET_FANOUT_FLAG_UNIQUEID 0x2000
Christopher Ferris8b7fdc92023-02-21 13:36:32 -080079#define PACKET_FANOUT_FLAG_IGNORE_OUTGOING 0x4000
Christopher Ferris38062f92014-07-09 15:33:25 -070080#define PACKET_FANOUT_FLAG_DEFRAG 0x8000
Ben Cheng655a7c02013-10-16 16:09:24 -070081struct tpacket_stats {
Tao Baod7db5942015-01-28 10:07:51 -080082 unsigned int tp_packets;
83 unsigned int tp_drops;
Christopher Ferris38062f92014-07-09 15:33:25 -070084};
Ben Cheng655a7c02013-10-16 16:09:24 -070085struct tpacket_stats_v3 {
Tao Baod7db5942015-01-28 10:07:51 -080086 unsigned int tp_packets;
87 unsigned int tp_drops;
Tao Baod7db5942015-01-28 10:07:51 -080088 unsigned int tp_freeze_q_cnt;
Ben Cheng655a7c02013-10-16 16:09:24 -070089};
Christopher Ferris05d08e92016-02-04 13:16:38 -080090struct tpacket_rollover_stats {
91 __aligned_u64 tp_all;
Christopher Ferris05d08e92016-02-04 13:16:38 -080092 __aligned_u64 tp_huge;
93 __aligned_u64 tp_failed;
94};
95union tpacket_stats_u {
Christopher Ferris05d08e92016-02-04 13:16:38 -080096 struct tpacket_stats stats1;
Tao Baod7db5942015-01-28 10:07:51 -080097 struct tpacket_stats_v3 stats3;
Ben Cheng655a7c02013-10-16 16:09:24 -070098};
99struct tpacket_auxdata {
Christopher Ferris05d08e92016-02-04 13:16:38 -0800100 __u32 tp_status;
Tao Baod7db5942015-01-28 10:07:51 -0800101 __u32 tp_len;
102 __u32 tp_snaplen;
103 __u16 tp_mac;
Christopher Ferris05d08e92016-02-04 13:16:38 -0800104 __u16 tp_net;
Tao Baod7db5942015-01-28 10:07:51 -0800105 __u16 tp_vlan_tci;
106 __u16 tp_vlan_tpid;
Ben Cheng655a7c02013-10-16 16:09:24 -0700107};
Christopher Ferris05d08e92016-02-04 13:16:38 -0800108#define TP_STATUS_KERNEL 0
Christopher Ferris38062f92014-07-09 15:33:25 -0700109#define TP_STATUS_USER (1 << 0)
Ben Cheng655a7c02013-10-16 16:09:24 -0700110#define TP_STATUS_COPY (1 << 1)
111#define TP_STATUS_LOSING (1 << 2)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800112#define TP_STATUS_CSUMNOTREADY (1 << 3)
Christopher Ferris38062f92014-07-09 15:33:25 -0700113#define TP_STATUS_VLAN_VALID (1 << 4)
Ben Cheng655a7c02013-10-16 16:09:24 -0700114#define TP_STATUS_BLK_TMO (1 << 5)
Christopher Ferris38062f92014-07-09 15:33:25 -0700115#define TP_STATUS_VLAN_TPID_VALID (1 << 6)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800116#define TP_STATUS_CSUM_VALID (1 << 7)
Christopher Ferrisb7cef6d2023-05-09 19:04:15 +0000117#define TP_STATUS_GSO_TCP (1 << 8)
Christopher Ferris05d08e92016-02-04 13:16:38 -0800118#define TP_STATUS_AVAILABLE 0
Ben Cheng655a7c02013-10-16 16:09:24 -0700119#define TP_STATUS_SEND_REQUEST (1 << 0)
120#define TP_STATUS_SENDING (1 << 1)
Ben Cheng655a7c02013-10-16 16:09:24 -0700121#define TP_STATUS_WRONG_FORMAT (1 << 2)
122#define TP_STATUS_TS_SOFTWARE (1 << 29)
123#define TP_STATUS_TS_SYS_HARDWARE (1 << 30)
Christopher Ferrisb8a95e22019-10-02 18:29:20 -0700124#define TP_STATUS_TS_RAW_HARDWARE (1U << 31)
Ben Cheng655a7c02013-10-16 16:09:24 -0700125#define TP_FT_REQ_FILL_RXHASH 0x1
126struct tpacket_hdr {
Tao Baod7db5942015-01-28 10:07:51 -0800127 unsigned long tp_status;
128 unsigned int tp_len;
129 unsigned int tp_snaplen;
130 unsigned short tp_mac;
Tao Baod7db5942015-01-28 10:07:51 -0800131 unsigned short tp_net;
132 unsigned int tp_sec;
133 unsigned int tp_usec;
Ben Cheng655a7c02013-10-16 16:09:24 -0700134};
135#define TPACKET_ALIGNMENT 16
Tao Baod7db5942015-01-28 10:07:51 -0800136#define TPACKET_ALIGN(x) (((x) + TPACKET_ALIGNMENT - 1) & ~(TPACKET_ALIGNMENT - 1))
Ben Cheng655a7c02013-10-16 16:09:24 -0700137#define TPACKET_HDRLEN (TPACKET_ALIGN(sizeof(struct tpacket_hdr)) + sizeof(struct sockaddr_ll))
138struct tpacket2_hdr {
Tao Baod7db5942015-01-28 10:07:51 -0800139 __u32 tp_status;
140 __u32 tp_len;
141 __u32 tp_snaplen;
142 __u16 tp_mac;
Tao Baod7db5942015-01-28 10:07:51 -0800143 __u16 tp_net;
144 __u32 tp_sec;
145 __u32 tp_nsec;
146 __u16 tp_vlan_tci;
Tao Baod7db5942015-01-28 10:07:51 -0800147 __u16 tp_vlan_tpid;
148 __u8 tp_padding[4];
Christopher Ferris38062f92014-07-09 15:33:25 -0700149};
Ben Cheng655a7c02013-10-16 16:09:24 -0700150struct tpacket_hdr_variant1 {
Tao Baod7db5942015-01-28 10:07:51 -0800151 __u32 tp_rxhash;
152 __u32 tp_vlan_tci;
153 __u16 tp_vlan_tpid;
154 __u16 tp_padding;
Christopher Ferris38062f92014-07-09 15:33:25 -0700155};
Ben Cheng655a7c02013-10-16 16:09:24 -0700156struct tpacket3_hdr {
Tao Baod7db5942015-01-28 10:07:51 -0800157 __u32 tp_next_offset;
158 __u32 tp_sec;
Tao Baod7db5942015-01-28 10:07:51 -0800159 __u32 tp_nsec;
160 __u32 tp_snaplen;
161 __u32 tp_len;
162 __u32 tp_status;
Tao Baod7db5942015-01-28 10:07:51 -0800163 __u16 tp_mac;
164 __u16 tp_net;
165 union {
166 struct tpacket_hdr_variant1 hv1;
Tao Baod7db5942015-01-28 10:07:51 -0800167 };
168 __u8 tp_padding[8];
Ben Cheng655a7c02013-10-16 16:09:24 -0700169};
170struct tpacket_bd_ts {
Tao Baod7db5942015-01-28 10:07:51 -0800171 unsigned int ts_sec;
172 union {
173 unsigned int ts_usec;
174 unsigned int ts_nsec;
Tao Baod7db5942015-01-28 10:07:51 -0800175 };
Ben Cheng655a7c02013-10-16 16:09:24 -0700176};
Ben Cheng655a7c02013-10-16 16:09:24 -0700177struct tpacket_hdr_v1 {
Tao Baod7db5942015-01-28 10:07:51 -0800178 __u32 block_status;
Tao Baod7db5942015-01-28 10:07:51 -0800179 __u32 num_pkts;
180 __u32 offset_to_first_pkt;
181 __u32 blk_len;
182 __aligned_u64 seq_num;
Tao Baod7db5942015-01-28 10:07:51 -0800183 struct tpacket_bd_ts ts_first_pkt, ts_last_pkt;
Ben Cheng655a7c02013-10-16 16:09:24 -0700184};
Ben Cheng655a7c02013-10-16 16:09:24 -0700185union tpacket_bd_header_u {
Tao Baod7db5942015-01-28 10:07:51 -0800186 struct tpacket_hdr_v1 bh1;
Ben Cheng655a7c02013-10-16 16:09:24 -0700187};
188struct tpacket_block_desc {
Tao Baod7db5942015-01-28 10:07:51 -0800189 __u32 version;
190 __u32 offset_to_priv;
Tao Baod7db5942015-01-28 10:07:51 -0800191 union tpacket_bd_header_u hdr;
Ben Cheng655a7c02013-10-16 16:09:24 -0700192};
Ben Cheng655a7c02013-10-16 16:09:24 -0700193#define TPACKET2_HDRLEN (TPACKET_ALIGN(sizeof(struct tpacket2_hdr)) + sizeof(struct sockaddr_ll))
194#define TPACKET3_HDRLEN (TPACKET_ALIGN(sizeof(struct tpacket3_hdr)) + sizeof(struct sockaddr_ll))
195enum tpacket_versions {
Tao Baod7db5942015-01-28 10:07:51 -0800196 TPACKET_V1,
197 TPACKET_V2,
198 TPACKET_V3
Ben Cheng655a7c02013-10-16 16:09:24 -0700199};
200struct tpacket_req {
Tao Baod7db5942015-01-28 10:07:51 -0800201 unsigned int tp_block_size;
202 unsigned int tp_block_nr;
Tao Baod7db5942015-01-28 10:07:51 -0800203 unsigned int tp_frame_size;
204 unsigned int tp_frame_nr;
Ben Cheng655a7c02013-10-16 16:09:24 -0700205};
206struct tpacket_req3 {
Tao Baod7db5942015-01-28 10:07:51 -0800207 unsigned int tp_block_size;
208 unsigned int tp_block_nr;
209 unsigned int tp_frame_size;
210 unsigned int tp_frame_nr;
Tao Baod7db5942015-01-28 10:07:51 -0800211 unsigned int tp_retire_blk_tov;
212 unsigned int tp_sizeof_priv;
213 unsigned int tp_feature_req_word;
Ben Cheng655a7c02013-10-16 16:09:24 -0700214};
215union tpacket_req_u {
Tao Baod7db5942015-01-28 10:07:51 -0800216 struct tpacket_req req;
217 struct tpacket_req3 req3;
Ben Cheng655a7c02013-10-16 16:09:24 -0700218};
219struct packet_mreq {
Tao Baod7db5942015-01-28 10:07:51 -0800220 int mr_ifindex;
221 unsigned short mr_type;
222 unsigned short mr_alen;
Tao Baod7db5942015-01-28 10:07:51 -0800223 unsigned char mr_address[8];
Ben Cheng655a7c02013-10-16 16:09:24 -0700224};
Christopher Ferris05667cd2021-02-16 16:01:34 -0800225struct fanout_args {
226#ifdef __LITTLE_ENDIAN_BITFIELD
227 __u16 id;
228 __u16 type_flags;
229#else
230 __u16 type_flags;
231 __u16 id;
232#endif
233 __u32 max_num_members;
234};
Ben Cheng655a7c02013-10-16 16:09:24 -0700235#define PACKET_MR_MULTICAST 0
236#define PACKET_MR_PROMISC 1
237#define PACKET_MR_ALLMULTI 2
238#define PACKET_MR_UNICAST 3
Ben Cheng655a7c02013-10-16 16:09:24 -0700239#endif