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