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