Skip to content

Commit c412376

Browse files
Added TPACKET_* macro definitions
1 parent b0e9731 commit c412376

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

libc-test/build.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3377,6 +3377,8 @@ fn test_linux(target: &str) {
33773377
// FIXME: This is actually a union, not a struct
33783378
"sigval" => true,
33793379

3380+
"fanout_args" if musl => true,
3381+
33803382
// This type is tested in the `linux_termios.rs` file since there
33813383
// are header conflicts when including them with all the other
33823384
// structs.

src/unix/linux_like/linux/mod.rs

+15
Original file line numberDiff line numberDiff line change
@@ -2917,6 +2917,17 @@ pub const TP_STATUS_TS_SOFTWARE: ::__u32 = 1 << 29;
29172917
pub const TP_STATUS_TS_SYS_HARDWARE: ::__u32 = 1 << 30;
29182918
pub const TP_STATUS_TS_RAW_HARDWARE: ::__u32 = 1 << 31;
29192919

2920+
pub const TPACKET_ALIGNMENT: usize = 16;
2921+
pub const TPACKET_HDRLEN: usize = ((core::mem::size_of::<::tpacket_hdr>() + TPACKET_ALIGNMENT - 1)
2922+
& !(TPACKET_ALIGNMENT - 1))
2923+
+ core::mem::size_of::<::sockaddr_ll>();
2924+
pub const TPACKET2_HDRLEN: usize =
2925+
((core::mem::size_of::<::tpacket2_hdr>() + TPACKET_ALIGNMENT - 1) & !(TPACKET_ALIGNMENT - 1))
2926+
+ core::mem::size_of::<::sockaddr_ll>();
2927+
pub const TPACKET3_HDRLEN: usize =
2928+
((core::mem::size_of::<::tpacket3_hdr>() + TPACKET_ALIGNMENT - 1) & !(TPACKET_ALIGNMENT - 1))
2929+
+ core::mem::size_of::<::sockaddr_ll>();
2930+
29202931
// linux/netfilter.h
29212932
pub const NF_DROP: ::c_int = 0;
29222933
pub const NF_ACCEPT: ::c_int = 1;
@@ -4214,6 +4225,10 @@ f! {
42144225
ee.offset(1) as *mut ::sockaddr
42154226
}
42164227

4228+
pub fn TPACKET_ALIGN(x: usize) -> usize {
4229+
(x + TPACKET_ALIGNMENT - 1) & !(TPACKET_ALIGNMENT - 1)
4230+
}
4231+
42174232
pub fn BPF_RVAL(code: ::__u32) -> ::__u32 {
42184233
code & 0x18
42194234
}

0 commit comments

Comments
 (0)