From 619119e0e21c0964028a236dd7c23f3fecc4e044 Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Tue, 25 Jan 2022 14:22:48 +0000 Subject: freebsd add ifconf data. --- libc-test/build.rs | 1 + libc-test/semver/freebsd.txt | 2 ++ src/unix/bsd/freebsdlike/freebsd/mod.rs | 44 +++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 19c5ddce70..4fd9e8b7f3 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2316,6 +2316,7 @@ fn test_freebsd(target: &str) { ("if_data", "__ifi_epoch") => true, ("if_data", "__ifi_lastchange") => true, ("ifreq", "ifr_ifru") => true, + ("ifconf", "ifc_ifcu") => true, // anonymous struct ("devstat", "dev_links") => true, diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 8aff0a5d6c..4772415cda 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -1536,6 +1536,8 @@ idtype_t if_freenameindex if_nameindex ifaddrs +ifconf +ifreq in6_pktinfo initgroups ip_mreqn diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index eeea87bd0b..251f236c58 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -960,6 +960,13 @@ s! { pub sc_ngroups: ::c_int, pub sc_groups: [::gid_t; 1], } + + pub struct ifconf { + pub ifc_len: ::c_int, + #[cfg(libc_union)] + pub ifc_ifcu: __c_anonymous_ifc_ifcu, + } + } s_no_extra_traits! { @@ -1142,6 +1149,12 @@ s_no_extra_traits! { pub ifr_ifru: ::sockaddr, } + #[cfg(libc_union)] + pub union __c_anonymous_ifc_ifcu { + pub ifcu_buf: ::caddr_t, + pub ifcu_req: *mut ifreq, + } + pub struct ifstat { /// if name, e.g. "en0" pub ifs_name: [::c_char; ::IFNAMSIZ as usize], @@ -1549,6 +1562,37 @@ cfg_if! { } } + #[cfg(libc_union)] + impl Eq for __c_anonymous_ifc_ifcu {} + + #[cfg(libc_union)] + impl PartialEq for __c_anonymous_ifc_ifcu { + fn eq(&self, other: &__c_anonymous_ifc_ifcu) -> bool { + unsafe { + self.ifcu_buf == other.ifcu_buf && + self.ifcu_req == other.ifcu_req + } + } + } + + #[cfg(libc_union)] + impl ::fmt::Debug for __c_anonymous_ifc_ifcu { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ifc_ifcu") + .field("ifcu_buf", unsafe { &self.ifcu_buf }) + .field("ifcu_req", unsafe { &self.ifcu_req }) + .finish() + } + } + + #[cfg(libc_union)] + impl ::hash::Hash for __c_anonymous_ifc_ifcu { + fn hash(&self, state: &mut H) { + unsafe { self.ifcu_buf.hash(state) }; + unsafe { self.ifcu_req.hash(state) }; + } + } + impl PartialEq for ifstat { fn eq(&self, other: &ifstat) -> bool { let self_ascii: &[::c_char] = &self.ascii; -- cgit v1.2.1