libc/new/linux_uapi/linux/
if_packet.rs1use crate::prelude::*;
4
5#[automatically_derived]
#[allow(deprecated)]
impl ::core::clone::Clone for sockaddr_pkt {
#[inline]
fn clone(&self) -> sockaddr_pkt {
let _: ::core::clone::AssertParamIsClone<c_ushort>;
let _: ::core::clone::AssertParamIsClone<[c_uchar; 14]>;
*self
}
}
#[automatically_derived]
#[allow(deprecated)]
impl ::core::marker::Copy for sockaddr_pkt { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::fmt::Debug for sockaddr_pkt {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "sockaddr_pkt",
"spkt_family", &self.spkt_family, "spkt_device",
&self.spkt_device, "spkt_protocol", &&self.spkt_protocol)
}
}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
14pub const PACKET_HOST: c_uchar = 0;
15pub const PACKET_BROADCAST: c_uchar = 1;
16pub const PACKET_MULTICAST: c_uchar = 2;
17pub const PACKET_OTHERHOST: c_uchar = 3;
18pub const PACKET_OUTGOING: c_uchar = 4;
19pub const PACKET_LOOPBACK: c_uchar = 5;
20pub const PACKET_USER: c_uchar = 6;
21pub const PACKET_KERNEL: c_uchar = 7;
22
23pub const PACKET_ADD_MEMBERSHIP: c_int = 1;
24pub const PACKET_DROP_MEMBERSHIP: c_int = 2;
25pub const PACKET_RECV_OUTPUT: c_int = 3;
26pub const PACKET_RX_RING: c_int = 5;
27pub const PACKET_STATISTICS: c_int = 6;
28pub const PACKET_COPY_THRESH: c_int = 7;
29pub const PACKET_AUXDATA: c_int = 8;
30pub const PACKET_ORIGDEV: c_int = 9;
31pub const PACKET_VERSION: c_int = 10;
32pub const PACKET_HDRLEN: c_int = 11;
33pub const PACKET_RESERVE: c_int = 12;
34pub const PACKET_TX_RING: c_int = 13;
35pub const PACKET_LOSS: c_int = 14;
36pub const PACKET_VNET_HDR: c_int = 15;
37pub const PACKET_TX_TIMESTAMP: c_int = 16;
38pub const PACKET_TIMESTAMP: c_int = 17;
39pub const PACKET_FANOUT: c_int = 18;
40pub const PACKET_TX_HAS_OFF: c_int = 19;
41pub const PACKET_QDISC_BYPASS: c_int = 20;
42pub const PACKET_ROLLOVER_STATS: c_int = 21;
43pub const PACKET_FANOUT_DATA: c_int = 22;
44pub const PACKET_IGNORE_OUTGOING: c_int = 23;
45pub const PACKET_VNET_HDR_SZ: c_int = 24;
46
47pub const PACKET_FANOUT_HASH: c_uint = 0;
48pub const PACKET_FANOUT_LB: c_uint = 1;
49pub const PACKET_FANOUT_CPU: c_uint = 2;
50pub const PACKET_FANOUT_ROLLOVER: c_uint = 3;
51pub const PACKET_FANOUT_RND: c_uint = 4;
52pub const PACKET_FANOUT_QM: c_uint = 5;
53pub const PACKET_FANOUT_CBPF: c_uint = 6;
54pub const PACKET_FANOUT_EBPF: c_uint = 7;
55pub const PACKET_FANOUT_FLAG_ROLLOVER: c_uint = 0x1000;
56pub const PACKET_FANOUT_FLAG_UNIQUEID: c_uint = 0x2000;
57pub const PACKET_FANOUT_FLAG_IGNORE_OUTGOING: c_uint = 0x4000;
58pub const PACKET_FANOUT_FLAG_DEFRAG: c_uint = 0x8000;
59
60#[automatically_derived]
#[allow(deprecated)]
impl ::core::clone::Clone for tpacket_auxdata {
#[inline]
fn clone(&self) -> tpacket_auxdata {
let _: ::core::clone::AssertParamIsClone<u32>;
let _: ::core::clone::AssertParamIsClone<u16>;
*self
}
}
#[automatically_derived]
#[allow(deprecated)]
impl ::core::marker::Copy for tpacket_auxdata { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::fmt::Debug for tpacket_auxdata {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["tp_status", "tp_len", "tp_snaplen", "tp_mac", "tp_net",
"tp_vlan_tci", "tp_vlan_tpid"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.tp_status, &self.tp_len, &self.tp_snaplen, &self.tp_mac,
&self.tp_net, &self.tp_vlan_tci, &&self.tp_vlan_tpid];
::core::fmt::Formatter::debug_struct_fields_finish(f,
"tpacket_auxdata", names, values)
}
}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
90pub const TP_STATUS_KERNEL: u32 = 0;
91pub const TP_STATUS_USER: u32 = 1 << 0;
92pub const TP_STATUS_COPY: u32 = 1 << 1;
93pub const TP_STATUS_LOSING: u32 = 1 << 2;
94pub const TP_STATUS_CSUMNOTREADY: u32 = 1 << 3;
95pub const TP_STATUS_VLAN_VALID: u32 = 1 << 4;
96pub const TP_STATUS_BLK_TMO: u32 = 1 << 5;
97pub const TP_STATUS_VLAN_TPID_VALID: u32 = 1 << 6;
98pub const TP_STATUS_CSUM_VALID: u32 = 1 << 7;
99
100pub const TP_STATUS_AVAILABLE: u32 = 0;
101pub const TP_STATUS_SEND_REQUEST: u32 = 1 << 0;
102pub const TP_STATUS_SENDING: u32 = 1 << 1;
103pub const TP_STATUS_WRONG_FORMAT: u32 = 1 << 2;
104
105pub const TP_STATUS_TS_SOFTWARE: u32 = 1 << 29;
106pub const TP_STATUS_TS_SYS_HARDWARE: u32 = 1 << 30;
107pub const TP_STATUS_TS_RAW_HARDWARE: u32 = 1 << 31;
108
109pub const TP_FT_REQ_FILL_RXHASH: u32 = 1;
110
111#[automatically_derived]
#[allow(deprecated)]
impl ::core::clone::Clone for tpacket_hdr {
#[inline]
fn clone(&self) -> tpacket_hdr {
let _: ::core::clone::AssertParamIsClone<c_ulong>;
let _: ::core::clone::AssertParamIsClone<c_uint>;
let _: ::core::clone::AssertParamIsClone<c_ushort>;
*self
}
}
#[automatically_derived]
#[allow(deprecated)]
impl ::core::marker::Copy for tpacket_hdr { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::fmt::Debug for tpacket_hdr {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["tp_status", "tp_len", "tp_snaplen", "tp_mac", "tp_net",
"tp_sec", "tp_usec"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.tp_status, &self.tp_len, &self.tp_snaplen, &self.tp_mac,
&self.tp_net, &self.tp_sec, &&self.tp_usec];
::core::fmt::Formatter::debug_struct_fields_finish(f, "tpacket_hdr",
names, values)
}
}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
123pub const TPACKET_ALIGNMENT: usize = 16;
124#[inline]
pub unsafe extern "C" fn TPACKET_ALIGN(x: usize) -> usize {
(x + TPACKET_ALIGNMENT - 1) & !(TPACKET_ALIGNMENT - 1)
}f! {
125 pub unsafe fn TPACKET_ALIGN(x: usize) -> usize {
126 (x + TPACKET_ALIGNMENT - 1) & !(TPACKET_ALIGNMENT - 1)
127 }
128}
129pub const TPACKET_HDRLEN: usize = ((size_of::<tpacket_hdr>() + TPACKET_ALIGNMENT - 1)
130 & !(TPACKET_ALIGNMENT - 1))
131 + size_of::<crate::sockaddr_ll>();
132
133#[automatically_derived]
#[allow(deprecated)]
impl ::core::clone::Clone for tpacket_hdr_v1 {
#[inline]
fn clone(&self) -> tpacket_hdr_v1 {
let _: ::core::clone::AssertParamIsClone<u32>;
let _: ::core::clone::AssertParamIsClone<crate::__u64>;
let _: ::core::clone::AssertParamIsClone<tpacket_bd_ts>;
*self
}
}
#[automatically_derived]
#[allow(deprecated)]
impl ::core::marker::Copy for tpacket_hdr_v1 { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::fmt::Debug for tpacket_hdr_v1 {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["block_status", "num_pkts", "offset_to_first_pkt", "blk_len",
"seq_num", "ts_first_pkt", "ts_last_pkt"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.block_status, &self.num_pkts, &self.offset_to_first_pkt,
&self.blk_len, &self.seq_num, &self.ts_first_pkt,
&&self.ts_last_pkt];
::core::fmt::Formatter::debug_struct_fields_finish(f,
"tpacket_hdr_v1", names, values)
}
}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#[automatically_derived]
impl ::core::clone::Clone for tpacket_bd_header_u {
#[inline]
fn clone(&self) -> tpacket_bd_header_u {
let _: ::core::clone::AssertParamIsCopy<Self>;
*self
}
}
#[automatically_derived]
impl ::core::marker::Copy for tpacket_bd_header_u { }
impl ::core::fmt::Debug for tpacket_bd_header_u {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
f.debug_struct("tpacket_bd_header_u").finish_non_exhaustive()
}
}
#[repr(C)]
pub struct tpacket_block_desc {
pub version: u32,
pub offset_to_priv: u32,
pub hdr: tpacket_bd_header_u,
}
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for tpacket_block_desc { }
#[automatically_derived]
impl ::core::clone::Clone for tpacket_block_desc {
#[inline]
fn clone(&self) -> tpacket_block_desc {
let _: ::core::clone::AssertParamIsClone<u32>;
let _: ::core::clone::AssertParamIsClone<tpacket_bd_header_u>;
*self
}
}
#[automatically_derived]
impl ::core::marker::Copy for tpacket_block_desc { }
#[automatically_derived]
impl ::core::fmt::Debug for tpacket_block_desc {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"tpacket_block_desc", "version", &self.version, "offset_to_priv",
&self.offset_to_priv, "hdr", &&self.hdr)
}
}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
196pub const TPACKET2_HDRLEN: usize = ((size_of::<tpacket2_hdr>() + TPACKET_ALIGNMENT - 1)
197 & !(TPACKET_ALIGNMENT - 1))
198 + size_of::<crate::sockaddr_ll>();
199pub const TPACKET3_HDRLEN: usize = ((size_of::<tpacket3_hdr>() + TPACKET_ALIGNMENT - 1)
200 & !(TPACKET_ALIGNMENT - 1))
201 + size_of::<crate::sockaddr_ll>();
202
203#[automatically_derived]
impl ::core::clone::Clone for tpacket_versions {
#[inline]
fn clone(&self) -> tpacket_versions { *self }
}
#[automatically_derived]
impl ::core::marker::Copy for tpacket_versions { }
#[automatically_derived]
impl ::core::fmt::Debug for tpacket_versions {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
tpacket_versions::TPACKET_V1 => "TPACKET_V1",
tpacket_versions::TPACKET_V2 => "TPACKET_V2",
tpacket_versions::TPACKET_V3 => "TPACKET_V3",
})
}
}e! {
204 #[repr(u32)]
205 pub enum tpacket_versions {
206 TPACKET_V1,
207 TPACKET_V2,
208 TPACKET_V3,
209 }
210}
211
212#[automatically_derived]
#[allow(deprecated)]
impl ::core::clone::Clone for tpacket_req3 {
#[inline]
fn clone(&self) -> tpacket_req3 {
let _: ::core::clone::AssertParamIsClone<c_uint>;
*self
}
}
#[automatically_derived]
#[allow(deprecated)]
impl ::core::marker::Copy for tpacket_req3 { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::fmt::Debug for tpacket_req3 {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["tp_block_size", "tp_block_nr", "tp_frame_size", "tp_frame_nr",
"tp_retire_blk_tov", "tp_sizeof_priv",
"tp_feature_req_word"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.tp_block_size, &self.tp_block_nr, &self.tp_frame_size,
&self.tp_frame_nr, &self.tp_retire_blk_tov,
&self.tp_sizeof_priv, &&self.tp_feature_req_word];
::core::fmt::Formatter::debug_struct_fields_finish(f, "tpacket_req3",
names, values)
}
}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#[automatically_derived]
impl ::core::clone::Clone for tpacket_req_u {
#[inline]
fn clone(&self) -> tpacket_req_u {
let _: ::core::clone::AssertParamIsCopy<Self>;
*self
}
}
#[automatically_derived]
impl ::core::marker::Copy for tpacket_req_u { }
impl ::core::fmt::Debug for tpacket_req_u {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
f.debug_struct("tpacket_req_u").finish_non_exhaustive()
}
}s_no_extra_traits! {
232 pub union tpacket_req_u {
233 pub req: tpacket_req,
234 pub req3: tpacket_req3,
235 }
236}
237
238#[automatically_derived]
#[allow(deprecated)]
impl ::core::clone::Clone for fanout_args {
#[inline]
fn clone(&self) -> fanout_args {
let _: ::core::clone::AssertParamIsClone<u16>;
let _: ::core::clone::AssertParamIsClone<u32>;
*self
}
}
#[automatically_derived]
#[allow(deprecated)]
impl ::core::marker::Copy for fanout_args { }
#[automatically_derived]
#[allow(deprecated)]
impl ::core::fmt::Debug for fanout_args {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "fanout_args",
"id", &self.id, "type_flags", &self.type_flags, "max_num_members",
&&self.max_num_members)
}
}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
256pub const PACKET_MR_MULTICAST: c_int = 0;
257pub const PACKET_MR_PROMISC: c_int = 1;
258pub const PACKET_MR_ALLMULTI: c_int = 2;