From 4bb032174ed3e4289f0dc65ba3c635da33d6520d Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Wed, 27 Sep 2023 14:30:38 +0200 Subject: [PATCH] freebsd: move `net/if_mib.h` to `src/new` module There is a conflict of `NETLINK_GENERIC` definitions between `net/if_mib.h` and `netlink/netlink.h`. `netlink.h` is already exported in the crate root for Linux (and those definitions are already used by at least crates neli and netlink-packet-route.) `if_mib` does not seem to be too widely used just yet, so this moves the `if_mib` module contents into a namespace of their own to make space for `netlink` support on FreeBSD (rust-lang/libc#3194.) Signed-off-by: Yann Dirson Co-authored-by: dybucc <149513579+dybucc@users.noreply.github.com> --- src/new/freebsd/net/if_mib.rs | 48 +++++++++++++++++++++++++ src/new/freebsd/net/mod.rs | 1 + src/new/mod.rs | 2 ++ src/unix/bsd/freebsdlike/freebsd/mod.rs | 45 ----------------------- 4 files changed, 51 insertions(+), 45 deletions(-) create mode 100644 src/new/freebsd/net/if_mib.rs diff --git a/src/new/freebsd/net/if_mib.rs b/src/new/freebsd/net/if_mib.rs new file mode 100644 index 0000000000000..67e989085b2c0 --- /dev/null +++ b/src/new/freebsd/net/if_mib.rs @@ -0,0 +1,48 @@ +//! Header: `net/if_mib.h` +//! +//! https://github.com/freebsd/freebsd-src/blob/86691d52a6d3796ad36ba474cf0a9493f6d99202/sys/net/if_mib.h + +use crate::prelude::*; + +/// non-interface-specific +pub const IFMIB_SYSTEM: c_int = 1; +/// per-interface data table +pub const IFMIB_IFDATA: c_int = 2; + +/// generic stats for all kinds of ifaces +pub const IFDATA_GENERAL: c_int = 1; +/// specific to the type of interface +pub const IFDATA_LINKSPECIFIC: c_int = 2; +/// driver name and unit +pub const IFDATA_DRIVERNAME: c_int = 3; + +/// number of interfaces configured +pub const IFMIB_IFCOUNT: c_int = 1; + +/// functions not specific to a type of iface +pub const NETLINK_GENERIC: c_int = 0; + +pub const DOT3COMPLIANCE_STATS: c_int = 1; +pub const DOT3COMPLIANCE_COLLS: c_int = 2; + +pub const dot3ChipSetAMD7990: c_int = 1; +pub const dot3ChipSetAMD79900: c_int = 2; +pub const dot3ChipSetAMD79C940: c_int = 3; + +pub const dot3ChipSetIntel82586: c_int = 1; +pub const dot3ChipSetIntel82596: c_int = 2; +pub const dot3ChipSetIntel82557: c_int = 3; + +pub const dot3ChipSetNational8390: c_int = 1; +pub const dot3ChipSetNationalSonic: c_int = 2; + +pub const dot3ChipSetFujitsu86950: c_int = 1; + +pub const dot3ChipSetDigitalDC21040: c_int = 1; +pub const dot3ChipSetDigitalDC21140: c_int = 2; +pub const dot3ChipSetDigitalDC21041: c_int = 3; +pub const dot3ChipSetDigitalDC21140A: c_int = 4; +pub const dot3ChipSetDigitalDC21142: c_int = 5; + +pub const dot3ChipSetWesternDigital83C690: c_int = 1; +pub const dot3ChipSetWesternDigital83C790: c_int = 2; diff --git a/src/new/freebsd/net/mod.rs b/src/new/freebsd/net/mod.rs index e270c54938cb5..c8d8c3690111b 100644 --- a/src/new/freebsd/net/mod.rs +++ b/src/new/freebsd/net/mod.rs @@ -3,3 +3,4 @@ //! https://github.com/freebsd/freebsd-src/tree/main/sys/net pub(crate) mod dlt; +pub(crate) mod if_mib; diff --git a/src/new/mod.rs b/src/new/mod.rs index f4387e7aa9dac..52212334e661f 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -227,6 +227,8 @@ cfg_if! { pub use net::if_::*; } else if #[cfg(target_os = "freebsd")] { pub use net::dlt::*; + // FIXME(1.0,remove): these bindings should be left in a public submodule. + pub use net::if_mib::*; pub use netinet6::in6_var::*; pub use sys::file::*; pub use sys::ioccom::*; diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 13f9a2fc17007..06b68752459a7 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -2830,51 +2830,6 @@ pub const IFDR_MSG_SIZE: c_int = 64; pub const IFDR_REASON_MSG: c_int = 1; pub const IFDR_REASON_VENDOR: c_int = 2; -// sys/net/if_mib.h - -/// non-interface-specific -pub const IFMIB_SYSTEM: c_int = 1; -/// per-interface data table -pub const IFMIB_IFDATA: c_int = 2; - -/// generic stats for all kinds of ifaces -pub const IFDATA_GENERAL: c_int = 1; -/// specific to the type of interface -pub const IFDATA_LINKSPECIFIC: c_int = 2; -/// driver name and unit -pub const IFDATA_DRIVERNAME: c_int = 3; - -/// number of interfaces configured -pub const IFMIB_IFCOUNT: c_int = 1; - -/// functions not specific to a type of iface -pub const NETLINK_GENERIC: c_int = 0; - -pub const DOT3COMPLIANCE_STATS: c_int = 1; -pub const DOT3COMPLIANCE_COLLS: c_int = 2; - -pub const dot3ChipSetAMD7990: c_int = 1; -pub const dot3ChipSetAMD79900: c_int = 2; -pub const dot3ChipSetAMD79C940: c_int = 3; - -pub const dot3ChipSetIntel82586: c_int = 1; -pub const dot3ChipSetIntel82596: c_int = 2; -pub const dot3ChipSetIntel82557: c_int = 3; - -pub const dot3ChipSetNational8390: c_int = 1; -pub const dot3ChipSetNationalSonic: c_int = 2; - -pub const dot3ChipSetFujitsu86950: c_int = 1; - -pub const dot3ChipSetDigitalDC21040: c_int = 1; -pub const dot3ChipSetDigitalDC21140: c_int = 2; -pub const dot3ChipSetDigitalDC21041: c_int = 3; -pub const dot3ChipSetDigitalDC21140A: c_int = 4; -pub const dot3ChipSetDigitalDC21142: c_int = 5; - -pub const dot3ChipSetWesternDigital83C690: c_int = 1; -pub const dot3ChipSetWesternDigital83C790: c_int = 2; - // sys/netinet/in.h // Protocols (RFC 1700) // NOTE: These are in addition to the constants defined in src/unix/mod.rs