Skip to content

Commit 82b7480

Browse files
devnexentgross35
authored andcommitted
adding ethhdr type for linux/android for proper packet filtering.
[ref](https://docs.huihoo.com/doxygen/linux/kernel/3.7/structethhdr.html)
1 parent 551afd1 commit 82b7480

4 files changed

Lines changed: 22 additions & 0 deletions

File tree

libc-test/semver/android.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3425,6 +3425,7 @@ epoll_create1
34253425
epoll_ctl
34263426
epoll_event
34273427
epoll_wait
3428+
ethhdr
34283429
eventfd
34293430
eventfd_read
34303431
eventfd_write

libc-test/semver/linux-gnu.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,7 @@ dlvsym
594594
eaccess
595595
endutxent
596596
epoll_pwait2
597+
ethhdr
597598
euidaccess
598599
execveat
599600
explicit_bzero

src/unix/linux_like/android/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pub type __u16 = c_ushort;
4646
pub type __s16 = c_short;
4747
pub type __u32 = c_uint;
4848
pub type __s32 = c_int;
49+
pub type __be16 = __u16;
4950

5051
// linux/elf.h
5152

@@ -615,6 +616,15 @@ s_no_extra_traits! {
615616
pub ifc_ifcu: __c_anonymous_ifc_ifcu,
616617
}
617618

619+
// linux/if_ether.h
620+
621+
#[repr(C, packed)]
622+
pub struct ethhdr {
623+
pub h_dest: [c_uchar; crate::ETH_ALEN as usize],
624+
pub h_source: [c_uchar; crate::ETH_ALEN as usize],
625+
pub h_proto: crate::__be16,
626+
}
627+
618628
// Internal, for casts to access union fields
619629
struct sifields_sigchld {
620630
si_pid: crate::pid_t,

src/unix/linux_like/linux/gnu/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pub type __rlimit_resource_t = c_uint;
77
pub type Lmid_t = c_long;
88
pub type regoff_t = c_int;
99
pub type __kernel_rwf_t = c_int;
10+
pub type __be16 = crate::__u16;
1011

1112
cfg_if! {
1213
if #[cfg(doc)] {
@@ -405,6 +406,15 @@ s_no_extra_traits! {
405406
__glibc_reserved: Padding<[c_char; 32]>,
406407
}
407408

409+
// linux/if_ether.h
410+
411+
#[repr(C, packed)]
412+
pub struct ethhdr {
413+
pub h_dest: [c_uchar; crate::ETH_ALEN as usize],
414+
pub h_source: [c_uchar; crate::ETH_ALEN as usize],
415+
pub h_proto: crate::__be16,
416+
}
417+
408418
// Internal, for casts to access union fields
409419
struct sifields_sigchld {
410420
si_pid: crate::pid_t,

0 commit comments

Comments
 (0)