Elliott Hughes | 180edef | 2023-11-02 00:08:05 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * This file is auto-generated. Modifications will be lost. |
| 3 | * |
| 4 | * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/ |
| 5 | * for more information. |
| 6 | */ |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 7 | #ifndef __LINUX_IF_PACKET_H |
| 8 | #define __LINUX_IF_PACKET_H |
Christopher Ferris | 05667cd | 2021-02-16 16:01:34 -0800 | [diff] [blame] | 9 | #include <asm/byteorder.h> |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 10 | #include <linux/types.h> |
| 11 | struct sockaddr_pkt { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 12 | unsigned short spkt_family; |
| 13 | unsigned char spkt_device[14]; |
| 14 | __be16 spkt_protocol; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 15 | }; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 16 | struct sockaddr_ll { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 17 | unsigned short sll_family; |
| 18 | __be16 sll_protocol; |
| 19 | int sll_ifindex; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 20 | unsigned short sll_hatype; |
| 21 | unsigned char sll_pkttype; |
| 22 | unsigned char sll_halen; |
Christopher Ferris | 67d1e5e | 2023-10-31 13:36:37 -0700 | [diff] [blame] | 23 | unsigned char sll_addr[8]; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 24 | }; |
| 25 | #define PACKET_HOST 0 |
| 26 | #define PACKET_BROADCAST 1 |
| 27 | #define PACKET_MULTICAST 2 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 28 | #define PACKET_OTHERHOST 3 |
| 29 | #define PACKET_OUTGOING 4 |
| 30 | #define PACKET_LOOPBACK 5 |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 31 | #define PACKET_USER 6 |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 32 | #define PACKET_KERNEL 7 |
| 33 | #define PACKET_FASTROUTE 6 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 34 | #define PACKET_ADD_MEMBERSHIP 1 |
| 35 | #define PACKET_DROP_MEMBERSHIP 2 |
| 36 | #define PACKET_RECV_OUTPUT 3 |
| 37 | #define PACKET_RX_RING 5 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 38 | #define PACKET_STATISTICS 6 |
| 39 | #define PACKET_COPY_THRESH 7 |
| 40 | #define PACKET_AUXDATA 8 |
| 41 | #define PACKET_ORIGDEV 9 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 42 | #define PACKET_VERSION 10 |
| 43 | #define PACKET_HDRLEN 11 |
| 44 | #define PACKET_RESERVE 12 |
| 45 | #define PACKET_TX_RING 13 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 46 | #define PACKET_LOSS 14 |
| 47 | #define PACKET_VNET_HDR 15 |
| 48 | #define PACKET_TX_TIMESTAMP 16 |
| 49 | #define PACKET_TIMESTAMP 17 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 50 | #define PACKET_FANOUT 18 |
| 51 | #define PACKET_TX_HAS_OFF 19 |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 52 | #define PACKET_QDISC_BYPASS 20 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 53 | #define PACKET_ROLLOVER_STATS 21 |
| 54 | #define PACKET_FANOUT_DATA 22 |
Christopher Ferris | 86a4837 | 2019-01-10 14:14:59 -0800 | [diff] [blame] | 55 | #define PACKET_IGNORE_OUTGOING 23 |
Christopher Ferris | 37c3f3c | 2023-07-10 10:59:05 -0700 | [diff] [blame] | 56 | #define PACKET_VNET_HDR_SZ 24 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 57 | #define PACKET_FANOUT_HASH 0 |
| 58 | #define PACKET_FANOUT_LB 1 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 59 | #define PACKET_FANOUT_CPU 2 |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 60 | #define PACKET_FANOUT_ROLLOVER 3 |
| 61 | #define PACKET_FANOUT_RND 4 |
| 62 | #define PACKET_FANOUT_QM 5 |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 63 | #define PACKET_FANOUT_CBPF 6 |
| 64 | #define PACKET_FANOUT_EBPF 7 |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 65 | #define PACKET_FANOUT_FLAG_ROLLOVER 0x1000 |
Christopher Ferris | 525ce91 | 2017-07-26 13:12:53 -0700 | [diff] [blame] | 66 | #define PACKET_FANOUT_FLAG_UNIQUEID 0x2000 |
Christopher Ferris | 8b7fdc9 | 2023-02-21 13:36:32 -0800 | [diff] [blame] | 67 | #define PACKET_FANOUT_FLAG_IGNORE_OUTGOING 0x4000 |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 68 | #define PACKET_FANOUT_FLAG_DEFRAG 0x8000 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 69 | struct tpacket_stats { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 70 | unsigned int tp_packets; |
| 71 | unsigned int tp_drops; |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 72 | }; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 73 | struct tpacket_stats_v3 { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 74 | unsigned int tp_packets; |
| 75 | unsigned int tp_drops; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 76 | unsigned int tp_freeze_q_cnt; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 77 | }; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 78 | struct tpacket_rollover_stats { |
| 79 | __aligned_u64 tp_all; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 80 | __aligned_u64 tp_huge; |
| 81 | __aligned_u64 tp_failed; |
| 82 | }; |
| 83 | union tpacket_stats_u { |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 84 | struct tpacket_stats stats1; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 85 | struct tpacket_stats_v3 stats3; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 86 | }; |
| 87 | struct tpacket_auxdata { |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 88 | __u32 tp_status; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 89 | __u32 tp_len; |
| 90 | __u32 tp_snaplen; |
| 91 | __u16 tp_mac; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 92 | __u16 tp_net; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 93 | __u16 tp_vlan_tci; |
| 94 | __u16 tp_vlan_tpid; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 95 | }; |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 96 | #define TP_STATUS_KERNEL 0 |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 97 | #define TP_STATUS_USER (1 << 0) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 98 | #define TP_STATUS_COPY (1 << 1) |
| 99 | #define TP_STATUS_LOSING (1 << 2) |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 100 | #define TP_STATUS_CSUMNOTREADY (1 << 3) |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 101 | #define TP_STATUS_VLAN_VALID (1 << 4) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 102 | #define TP_STATUS_BLK_TMO (1 << 5) |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 103 | #define TP_STATUS_VLAN_TPID_VALID (1 << 6) |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 104 | #define TP_STATUS_CSUM_VALID (1 << 7) |
Christopher Ferris | b7cef6d | 2023-05-09 19:04:15 +0000 | [diff] [blame] | 105 | #define TP_STATUS_GSO_TCP (1 << 8) |
Christopher Ferris | 05d08e9 | 2016-02-04 13:16:38 -0800 | [diff] [blame] | 106 | #define TP_STATUS_AVAILABLE 0 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 107 | #define TP_STATUS_SEND_REQUEST (1 << 0) |
| 108 | #define TP_STATUS_SENDING (1 << 1) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 109 | #define TP_STATUS_WRONG_FORMAT (1 << 2) |
| 110 | #define TP_STATUS_TS_SOFTWARE (1 << 29) |
| 111 | #define TP_STATUS_TS_SYS_HARDWARE (1 << 30) |
Christopher Ferris | b8a95e2 | 2019-10-02 18:29:20 -0700 | [diff] [blame] | 112 | #define TP_STATUS_TS_RAW_HARDWARE (1U << 31) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 113 | #define TP_FT_REQ_FILL_RXHASH 0x1 |
| 114 | struct tpacket_hdr { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 115 | unsigned long tp_status; |
| 116 | unsigned int tp_len; |
| 117 | unsigned int tp_snaplen; |
| 118 | unsigned short tp_mac; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 119 | unsigned short tp_net; |
| 120 | unsigned int tp_sec; |
| 121 | unsigned int tp_usec; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 122 | }; |
| 123 | #define TPACKET_ALIGNMENT 16 |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 124 | #define TPACKET_ALIGN(x) (((x) + TPACKET_ALIGNMENT - 1) & ~(TPACKET_ALIGNMENT - 1)) |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 125 | #define TPACKET_HDRLEN (TPACKET_ALIGN(sizeof(struct tpacket_hdr)) + sizeof(struct sockaddr_ll)) |
| 126 | struct tpacket2_hdr { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 127 | __u32 tp_status; |
| 128 | __u32 tp_len; |
| 129 | __u32 tp_snaplen; |
| 130 | __u16 tp_mac; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 131 | __u16 tp_net; |
| 132 | __u32 tp_sec; |
| 133 | __u32 tp_nsec; |
| 134 | __u16 tp_vlan_tci; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 135 | __u16 tp_vlan_tpid; |
| 136 | __u8 tp_padding[4]; |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 137 | }; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 138 | struct tpacket_hdr_variant1 { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 139 | __u32 tp_rxhash; |
| 140 | __u32 tp_vlan_tci; |
| 141 | __u16 tp_vlan_tpid; |
| 142 | __u16 tp_padding; |
Christopher Ferris | 38062f9 | 2014-07-09 15:33:25 -0700 | [diff] [blame] | 143 | }; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 144 | struct tpacket3_hdr { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 145 | __u32 tp_next_offset; |
| 146 | __u32 tp_sec; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 147 | __u32 tp_nsec; |
| 148 | __u32 tp_snaplen; |
| 149 | __u32 tp_len; |
| 150 | __u32 tp_status; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 151 | __u16 tp_mac; |
| 152 | __u16 tp_net; |
| 153 | union { |
| 154 | struct tpacket_hdr_variant1 hv1; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 155 | }; |
| 156 | __u8 tp_padding[8]; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 157 | }; |
| 158 | struct tpacket_bd_ts { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 159 | unsigned int ts_sec; |
| 160 | union { |
| 161 | unsigned int ts_usec; |
| 162 | unsigned int ts_nsec; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 163 | }; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 164 | }; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 165 | struct tpacket_hdr_v1 { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 166 | __u32 block_status; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 167 | __u32 num_pkts; |
| 168 | __u32 offset_to_first_pkt; |
| 169 | __u32 blk_len; |
| 170 | __aligned_u64 seq_num; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 171 | struct tpacket_bd_ts ts_first_pkt, ts_last_pkt; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 172 | }; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 173 | union tpacket_bd_header_u { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 174 | struct tpacket_hdr_v1 bh1; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 175 | }; |
| 176 | struct tpacket_block_desc { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 177 | __u32 version; |
| 178 | __u32 offset_to_priv; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 179 | union tpacket_bd_header_u hdr; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 180 | }; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 181 | #define TPACKET2_HDRLEN (TPACKET_ALIGN(sizeof(struct tpacket2_hdr)) + sizeof(struct sockaddr_ll)) |
| 182 | #define TPACKET3_HDRLEN (TPACKET_ALIGN(sizeof(struct tpacket3_hdr)) + sizeof(struct sockaddr_ll)) |
| 183 | enum tpacket_versions { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 184 | TPACKET_V1, |
| 185 | TPACKET_V2, |
| 186 | TPACKET_V3 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 187 | }; |
| 188 | struct tpacket_req { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 189 | unsigned int tp_block_size; |
| 190 | unsigned int tp_block_nr; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 191 | unsigned int tp_frame_size; |
| 192 | unsigned int tp_frame_nr; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 193 | }; |
| 194 | struct tpacket_req3 { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 195 | unsigned int tp_block_size; |
| 196 | unsigned int tp_block_nr; |
| 197 | unsigned int tp_frame_size; |
| 198 | unsigned int tp_frame_nr; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 199 | unsigned int tp_retire_blk_tov; |
| 200 | unsigned int tp_sizeof_priv; |
| 201 | unsigned int tp_feature_req_word; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 202 | }; |
| 203 | union tpacket_req_u { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 204 | struct tpacket_req req; |
| 205 | struct tpacket_req3 req3; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 206 | }; |
| 207 | struct packet_mreq { |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 208 | int mr_ifindex; |
| 209 | unsigned short mr_type; |
| 210 | unsigned short mr_alen; |
Tao Bao | d7db594 | 2015-01-28 10:07:51 -0800 | [diff] [blame] | 211 | unsigned char mr_address[8]; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 212 | }; |
Christopher Ferris | 05667cd | 2021-02-16 16:01:34 -0800 | [diff] [blame] | 213 | struct fanout_args { |
| 214 | #ifdef __LITTLE_ENDIAN_BITFIELD |
| 215 | __u16 id; |
| 216 | __u16 type_flags; |
| 217 | #else |
| 218 | __u16 type_flags; |
| 219 | __u16 id; |
| 220 | #endif |
| 221 | __u32 max_num_members; |
| 222 | }; |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 223 | #define PACKET_MR_MULTICAST 0 |
| 224 | #define PACKET_MR_PROMISC 1 |
| 225 | #define PACKET_MR_ALLMULTI 2 |
| 226 | #define PACKET_MR_UNICAST 3 |
Ben Cheng | 655a7c0 | 2013-10-16 16:09:24 -0700 | [diff] [blame] | 227 | #endif |