aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / vendor / libc / src / new / linux_uapi / linux / if_packet.rs
| 1 | //! Header: `uapi/linux/if_packet.h` |
| 2 | |
| 3 | use crate::prelude::*; |
| 4 | |
| 5 | s! { |
| 6 | #[deprecated(since = "0.2.70", note = "sockaddr_ll type should be used instead")] |
| 7 | pub struct sockaddr_pkt { |
| 8 | pub spkt_family: c_ushort, |
| 9 | pub spkt_device: [c_uchar; 14], |
| 10 | pub spkt_protocol: c_ushort, |
| 11 | } |
| 12 | } |
| 13 | |
| 14 | pub const PACKET_HOST: c_uchar = 0; |
| 15 | pub const PACKET_BROADCAST: c_uchar = 1; |
| 16 | pub const PACKET_MULTICAST: c_uchar = 2; |
| 17 | pub const PACKET_OTHERHOST: c_uchar = 3; |
| 18 | pub const PACKET_OUTGOING: c_uchar = 4; |
| 19 | pub const PACKET_LOOPBACK: c_uchar = 5; |
| 20 | pub const PACKET_USER: c_uchar = 6; |
| 21 | pub const PACKET_KERNEL: c_uchar = 7; |
| 22 | |
| 23 | pub const PACKET_ADD_MEMBERSHIP: c_int = 1; |
| 24 | pub const PACKET_DROP_MEMBERSHIP: c_int = 2; |
| 25 | pub const PACKET_RECV_OUTPUT: c_int = 3; |
| 26 | pub const PACKET_RX_RING: c_int = 5; |
| 27 | pub const PACKET_STATISTICS: c_int = 6; |
| 28 | pub const PACKET_COPY_THRESH: c_int = 7; |
| 29 | pub const PACKET_AUXDATA: c_int = 8; |
| 30 | pub const PACKET_ORIGDEV: c_int = 9; |
| 31 | pub const PACKET_VERSION: c_int = 10; |
| 32 | pub const PACKET_HDRLEN: c_int = 11; |
| 33 | pub const PACKET_RESERVE: c_int = 12; |
| 34 | pub const PACKET_TX_RING: c_int = 13; |
| 35 | pub const PACKET_LOSS: c_int = 14; |
| 36 | pub const PACKET_VNET_HDR: c_int = 15; |
| 37 | pub const PACKET_TX_TIMESTAMP: c_int = 16; |
| 38 | pub const PACKET_TIMESTAMP: c_int = 17; |
| 39 | pub const PACKET_FANOUT: c_int = 18; |
| 40 | pub const PACKET_TX_HAS_OFF: c_int = 19; |
| 41 | pub const PACKET_QDISC_BYPASS: c_int = 20; |
| 42 | pub const PACKET_ROLLOVER_STATS: c_int = 21; |
| 43 | pub const PACKET_FANOUT_DATA: c_int = 22; |
| 44 | pub const PACKET_IGNORE_OUTGOING: c_int = 23; |
| 45 | pub const PACKET_VNET_HDR_SZ: c_int = 24; |
| 46 | |
| 47 | pub const PACKET_FANOUT_HASH: c_uint = 0; |
| 48 | pub const PACKET_FANOUT_LB: c_uint = 1; |
| 49 | pub const PACKET_FANOUT_CPU: c_uint = 2; |
| 50 | pub const PACKET_FANOUT_ROLLOVER: c_uint = 3; |
| 51 | pub const PACKET_FANOUT_RND: c_uint = 4; |
| 52 | pub const PACKET_FANOUT_QM: c_uint = 5; |
| 53 | pub const PACKET_FANOUT_CBPF: c_uint = 6; |
| 54 | pub const PACKET_FANOUT_EBPF: c_uint = 7; |
| 55 | pub const PACKET_FANOUT_FLAG_ROLLOVER: c_uint = 0x1000; |
| 56 | pub const PACKET_FANOUT_FLAG_UNIQUEID: c_uint = 0x2000; |
| 57 | pub const PACKET_FANOUT_FLAG_IGNORE_OUTGOING: c_uint = 0x4000; |
| 58 | pub const PACKET_FANOUT_FLAG_DEFRAG: c_uint = 0x8000; |
| 59 | |
| 60 | s! { |
| 61 | pub struct tpacket_stats { |
| 62 | pub tp_packets: c_uint, |
| 63 | pub tp_drops: c_uint, |
| 64 | } |
| 65 | |
| 66 | pub struct tpacket_stats_v3 { |
| 67 | pub tp_packets: c_uint, |
| 68 | pub tp_drops: c_uint, |
| 69 | pub tp_freeze_q_cnt: c_uint, |
| 70 | } |
| 71 | |
| 72 | #[repr(align(8))] |
| 73 | pub struct tpacket_rollover_stats { |
| 74 | pub tp_all: crate::__u64, |
| 75 | pub tp_huge: crate::__u64, |
| 76 | pub tp_failed: crate::__u64, |
| 77 | } |
| 78 | |
| 79 | pub struct tpacket_auxdata { |
| 80 | pub tp_status: u32, |
| 81 | pub tp_len: u32, |
| 82 | pub tp_snaplen: u32, |
| 83 | pub tp_mac: u16, |
| 84 | pub tp_net: u16, |
| 85 | pub tp_vlan_tci: u16, |
| 86 | pub tp_vlan_tpid: u16, |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | pub const TP_STATUS_KERNEL: u32 = 0; |
| 91 | pub const TP_STATUS_USER: u32 = 1 << 0; |
| 92 | pub const TP_STATUS_COPY: u32 = 1 << 1; |
| 93 | pub const TP_STATUS_LOSING: u32 = 1 << 2; |
| 94 | pub const TP_STATUS_CSUMNOTREADY: u32 = 1 << 3; |
| 95 | pub const TP_STATUS_VLAN_VALID: u32 = 1 << 4; |
| 96 | pub const TP_STATUS_BLK_TMO: u32 = 1 << 5; |
| 97 | pub const TP_STATUS_VLAN_TPID_VALID: u32 = 1 << 6; |
| 98 | pub const TP_STATUS_CSUM_VALID: u32 = 1 << 7; |
| 99 | |
| 100 | pub const TP_STATUS_AVAILABLE: u32 = 0; |
| 101 | pub const TP_STATUS_SEND_REQUEST: u32 = 1 << 0; |
| 102 | pub const TP_STATUS_SENDING: u32 = 1 << 1; |
| 103 | pub const TP_STATUS_WRONG_FORMAT: u32 = 1 << 2; |
| 104 | |
| 105 | pub const TP_STATUS_TS_SOFTWARE: u32 = 1 << 29; |
| 106 | pub const TP_STATUS_TS_SYS_HARDWARE: u32 = 1 << 30; |
| 107 | pub const TP_STATUS_TS_RAW_HARDWARE: u32 = 1 << 31; |
| 108 | |
| 109 | pub const TP_FT_REQ_FILL_RXHASH: u32 = 1; |
| 110 | |
| 111 | s! { |
| 112 | pub struct tpacket_hdr { |
| 113 | pub tp_status: c_ulong, |
| 114 | pub tp_len: c_uint, |
| 115 | pub tp_snaplen: c_uint, |
| 116 | pub tp_mac: c_ushort, |
| 117 | pub tp_net: c_ushort, |
| 118 | pub tp_sec: c_uint, |
| 119 | pub tp_usec: c_uint, |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | pub const TPACKET_ALIGNMENT: usize = 16; |
| 124 | f! { |
| 125 | pub unsafe fn TPACKET_ALIGN(x: usize) -> usize { |
| 126 | (x + TPACKET_ALIGNMENT - 1) & !(TPACKET_ALIGNMENT - 1) |
| 127 | } |
| 128 | } |
| 129 | pub const TPACKET_HDRLEN: usize = ((size_of::<tpacket_hdr>() + TPACKET_ALIGNMENT - 1) |
| 130 | & !(TPACKET_ALIGNMENT - 1)) |
| 131 | + size_of::<crate::sockaddr_ll>(); |
| 132 | |
| 133 | s! { |
| 134 | pub struct tpacket2_hdr { |
| 135 | pub tp_status: u32, |
| 136 | pub tp_len: u32, |
| 137 | pub tp_snaplen: u32, |
| 138 | pub tp_mac: u16, |
| 139 | pub tp_net: u16, |
| 140 | pub tp_sec: u32, |
| 141 | pub tp_nsec: u32, |
| 142 | pub tp_vlan_tci: u16, |
| 143 | pub tp_vlan_tpid: u16, |
| 144 | pub tp_padding: [u8; 4], |
| 145 | } |
| 146 | |
| 147 | pub struct tpacket_hdr_variant1 { |
| 148 | pub tp_rxhash: u32, |
| 149 | pub tp_vlan_tci: u32, |
| 150 | pub tp_vlan_tpid: u16, |
| 151 | pub tp_padding: u16, |
| 152 | } |
| 153 | |
| 154 | pub struct tpacket3_hdr { |
| 155 | pub tp_next_offset: u32, |
| 156 | pub tp_sec: u32, |
| 157 | pub tp_nsec: u32, |
| 158 | pub tp_snaplen: u32, |
| 159 | pub tp_len: u32, |
| 160 | pub tp_status: u32, |
| 161 | pub tp_mac: u16, |
| 162 | pub tp_net: u16, |
| 163 | pub hv1: tpacket_hdr_variant1, |
| 164 | pub tp_padding: [u8; 8], |
| 165 | } |
| 166 | |
| 167 | pub struct tpacket_bd_ts { |
| 168 | pub ts_sec: c_uint, |
| 169 | pub ts_usec: c_uint, |
| 170 | } |
| 171 | |
| 172 | #[repr(align(8))] |
| 173 | pub struct tpacket_hdr_v1 { |
| 174 | pub block_status: u32, |
| 175 | pub num_pkts: u32, |
| 176 | pub offset_to_first_pkt: u32, |
| 177 | pub blk_len: u32, |
| 178 | pub seq_num: crate::__u64, |
| 179 | pub ts_first_pkt: tpacket_bd_ts, |
| 180 | pub ts_last_pkt: tpacket_bd_ts, |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | s_no_extra_traits! { |
| 185 | pub union tpacket_bd_header_u { |
| 186 | pub bh1: tpacket_hdr_v1, |
| 187 | } |
| 188 | |
| 189 | pub struct tpacket_block_desc { |
| 190 | pub version: u32, |
| 191 | pub offset_to_priv: u32, |
| 192 | pub hdr: tpacket_bd_header_u, |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | pub const TPACKET2_HDRLEN: usize = ((size_of::<tpacket2_hdr>() + TPACKET_ALIGNMENT - 1) |
| 197 | & !(TPACKET_ALIGNMENT - 1)) |
| 198 | + size_of::<crate::sockaddr_ll>(); |
| 199 | pub const TPACKET3_HDRLEN: usize = ((size_of::<tpacket3_hdr>() + TPACKET_ALIGNMENT - 1) |
| 200 | & !(TPACKET_ALIGNMENT - 1)) |
| 201 | + size_of::<crate::sockaddr_ll>(); |
| 202 | |
| 203 | e! { |
| 204 | #[repr(u32)] |
| 205 | pub enum tpacket_versions { |
| 206 | TPACKET_V1, |
| 207 | TPACKET_V2, |
| 208 | TPACKET_V3, |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | s! { |
| 213 | pub struct tpacket_req { |
| 214 | pub tp_block_size: c_uint, |
| 215 | pub tp_block_nr: c_uint, |
| 216 | pub tp_frame_size: c_uint, |
| 217 | pub tp_frame_nr: c_uint, |
| 218 | } |
| 219 | |
| 220 | pub struct tpacket_req3 { |
| 221 | pub tp_block_size: c_uint, |
| 222 | pub tp_block_nr: c_uint, |
| 223 | pub tp_frame_size: c_uint, |
| 224 | pub tp_frame_nr: c_uint, |
| 225 | pub tp_retire_blk_tov: c_uint, |
| 226 | pub tp_sizeof_priv: c_uint, |
| 227 | pub tp_feature_req_word: c_uint, |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | s_no_extra_traits! { |
| 232 | pub union tpacket_req_u { |
| 233 | pub req: tpacket_req, |
| 234 | pub req3: tpacket_req3, |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | s! { |
| 239 | pub struct packet_mreq { |
| 240 | pub mr_ifindex: c_int, |
| 241 | pub mr_type: c_ushort, |
| 242 | pub mr_alen: c_ushort, |
| 243 | pub mr_address: [c_uchar; 8], |
| 244 | } |
| 245 | |
| 246 | pub struct fanout_args { |
| 247 | #[cfg(target_endian = "little")] |
| 248 | pub id: u16, |
| 249 | pub type_flags: u16, |
| 250 | #[cfg(target_endian = "big")] |
| 251 | pub id: u16, |
| 252 | pub max_num_members: u32, |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | pub const PACKET_MR_MULTICAST: c_int = 0; |
| 257 | pub const PACKET_MR_PROMISC: c_int = 1; |
| 258 | pub const PACKET_MR_ALLMULTI: c_int = 2; |