diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 6775a8bfbcb9..21ef3597f1b2 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -3722,6 +3722,7 @@ epoll_params epoll_pwait epoll_wait erand48 +ethhdr eventfd eventfd_read eventfd_write diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 0fe5117ae5a9..732244663800 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -34,6 +34,7 @@ pub type __u16 = c_ushort; pub type __s16 = c_short; pub type __u32 = c_uint; pub type __s32 = c_int; +pub type __be16 = __u16; // linux/elf.h diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index f17245dfaf43..657848c78b0f 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -28,6 +28,7 @@ pub type __u16 = c_ushort; pub type __s16 = c_short; pub type __u32 = c_uint; pub type __s32 = c_int; +pub type __be16 = __u16; pub type Elf32_Half = u16; pub type Elf32_Word = u32; diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 6678cb6d7487..cd9347666e40 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -303,6 +303,13 @@ s_no_extra_traits! { pub sigev_notify: c_int, pub _sigev_un: __c_anonymous_sigev_un, } + + #[repr(packed)] + pub struct ethhdr { + pub h_dest: [c_uchar; ETH_ALEN as usize], + pub h_source: [c_uchar; ETH_ALEN as usize], + pub h_proto: crate::__be16, + } } cfg_if! { @@ -459,6 +466,32 @@ cfg_if! { .finish() } } + + impl Eq for ethhdr {} + + impl PartialEq for ethhdr { + fn eq(&self, other: ðhdr) -> bool { + self.h_dest + .iter() + .zip(other.h_dest.iter()) + .all(|(a, b)| a == b) + && self.h_source + .iter() + .zip(other.h_source.iter()) + .all(|(a, b)| a == b) + && self.h_proto == other.h_proto + } + } + + impl fmt::Debug for ethhdr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("ethhdr") + .field("h_dest", &self.h_dest) + .field("h_source", &self.h_source) + .field("h_proto", &{self.h_proto}) + .finish() + } + } } }