diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index cf1d92de132dc..1b5c45e7685a8 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -1826,6 +1826,8 @@ backtrace_symbols_fd basename boolean_t bpf_hdr +bpf_insn +bpf_program brk bsearch chflags diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 5d070f952f3cc..696d958bf2887 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -335,6 +335,20 @@ DAY_5 DAY_6 DAY_7 DEAD_PROCESS +DLT_ARCNET +DLT_ATM_RFC1483 +DLT_AX25 +DLT_CHAOS +DLT_EN10MB +DLT_EN3MB +DLT_FDDI +DLT_IEEE802 +DLT_LOOP +DLT_NULL +DLT_PPP +DLT_PRONET +DLT_RAW +DLT_SLIP DT_UNKNOWN D_FMT D_MD_ORDER diff --git a/src/new/apple/xnu/mod.rs b/src/new/apple/xnu/mod.rs index 8b8afb6bc39d3..2cc3ffbd56cfb 100644 --- a/src/new/apple/xnu/mod.rs +++ b/src/new/apple/xnu/mod.rs @@ -27,4 +27,6 @@ pub(crate) mod machine { pub(crate) mod _mcontext; } +pub(crate) mod net; + pub(crate) mod sys; diff --git a/src/new/apple/xnu/net/bpf.rs b/src/new/apple/xnu/net/bpf.rs new file mode 100644 index 0000000000000..8242a724f71ca --- /dev/null +++ b/src/new/apple/xnu/net/bpf.rs @@ -0,0 +1,44 @@ +//! Header: `net/bpf.h` +//! +//! + +use crate::prelude::*; + +s! { + pub struct bpf_insn { + pub code: c_ushort, + pub jt: c_uchar, + pub jf: c_uchar, + pub k: u32, + } + + pub struct bpf_program { + pub bf_len: c_uint, + pub bf_insns: *mut bpf_insn, + } +} + +pub const DLT_NULL: c_uint = 0; // no link-layer encapsulation +pub const DLT_EN10MB: c_uint = 1; // Ethernet (10Mb) +pub const DLT_EN3MB: c_uint = 2; // Experimental Ethernet (3Mb) +pub const DLT_AX25: c_uint = 3; // Amateur Radio AX.25 +pub const DLT_PRONET: c_uint = 4; // Proteon ProNET Token Ring +pub const DLT_CHAOS: c_uint = 5; // Chaos +pub const DLT_IEEE802: c_uint = 6; // IEEE 802 Networks +pub const DLT_ARCNET: c_uint = 7; // ARCNET +pub const DLT_SLIP: c_uint = 8; // Serial Line IP +pub const DLT_PPP: c_uint = 9; // Point-to-point Protocol +pub const DLT_FDDI: c_uint = 10; // FDDI +pub const DLT_ATM_RFC1483: c_uint = 11; // LLC/SNAP encapsulated atm +pub const DLT_RAW: c_uint = 12; // raw IP +pub const DLT_LOOP: c_uint = 108; + +// sizeof(i32) +pub const BPF_ALIGNMENT: c_int = 4; + +pub const BIOCGRSIG: c_ulong = 0x40044272; +pub const BIOCSRSIG: c_ulong = 0x80044273; +pub const BIOCSDLT: c_ulong = 0x80044278; +pub const BIOCGSEESENT: c_ulong = 0x40044276; +pub const BIOCSSEESENT: c_ulong = 0x80044277; +pub const BIOCGDLTLIST: c_ulong = 0xc00c4279; diff --git a/src/new/apple/xnu/net/mod.rs b/src/new/apple/xnu/net/mod.rs new file mode 100644 index 0000000000000..c2844db51cf88 --- /dev/null +++ b/src/new/apple/xnu/net/mod.rs @@ -0,0 +1,5 @@ +//! Directory: `net/` +//! +//! + +pub(crate) mod bpf; diff --git a/src/new/freebsd/mod.rs b/src/new/freebsd/mod.rs index eedf235d1e235..20af53183c410 100644 --- a/src/new/freebsd/mod.rs +++ b/src/new/freebsd/mod.rs @@ -3,5 +3,6 @@ //! * Headers: //! * Symbol map: +pub(crate) mod net; pub(crate) mod sys; pub(crate) mod unistd; diff --git a/src/new/freebsd/net/dlt.rs b/src/new/freebsd/net/dlt.rs new file mode 100644 index 0000000000000..e3dddce93040c --- /dev/null +++ b/src/new/freebsd/net/dlt.rs @@ -0,0 +1,20 @@ +//! Header: `net/dlt.h` +//! +//! https://github.com/freebsd/freebsd-src/blob/main/sys/net/dlt.h + +use crate::prelude::*; + +pub const DLT_NULL: c_uint = 0; // no link-layer encapsulation +pub const DLT_EN10MB: c_uint = 1; // Ethernet (10Mb) +pub const DLT_EN3MB: c_uint = 2; // Experimental Ethernet (3Mb) +pub const DLT_AX25: c_uint = 3; // Amateur Radio AX.25 +pub const DLT_PRONET: c_uint = 4; // Proteon ProNET Token Ring +pub const DLT_CHAOS: c_uint = 5; // Chaos +pub const DLT_IEEE802: c_uint = 6; // IEEE 802 Networks +pub const DLT_ARCNET: c_uint = 7; // ARCNET +pub const DLT_SLIP: c_uint = 8; // Serial Line IP +pub const DLT_PPP: c_uint = 9; // Point-to-point Protocol +pub const DLT_FDDI: c_uint = 10; // FDDI +pub const DLT_ATM_RFC1483: c_uint = 11; // LLC/SNAP encapsulated atm +pub const DLT_RAW: c_uint = 12; // raw IP +pub const DLT_LOOP: c_uint = 108; diff --git a/src/new/freebsd/net/mod.rs b/src/new/freebsd/net/mod.rs new file mode 100644 index 0000000000000..e270c54938cb5 --- /dev/null +++ b/src/new/freebsd/net/mod.rs @@ -0,0 +1,5 @@ +//! Directory: `net/` +//! +//! https://github.com/freebsd/freebsd-src/tree/main/sys/net + +pub(crate) mod dlt; diff --git a/src/new/mod.rs b/src/new/mod.rs index 073041842026c..cdb8fa8e9fd48 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -197,6 +197,7 @@ cfg_if! { #[cfg(target_env = "gnu")] pub use net::route::*; } else if #[cfg(target_vendor = "apple")] { + pub use net::bpf::*; pub use pthread_::introspection::*; pub use pthread_::pthread_spis::*; pub use pthread_::spawn::*; @@ -221,6 +222,7 @@ cfg_if! { pub use net::bpf::*; pub use net::if_::*; } else if #[cfg(target_os = "freebsd")] { + pub use net::dlt::*; pub use sys::file::*; } } diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index d757935ae85be..e12185282a21c 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -2307,13 +2307,6 @@ pub const TIOCSETA: c_ulong = 0x80487414; pub const TIOCSETAW: c_ulong = 0x80487415; pub const TIOCSETAF: c_ulong = 0x80487416; -pub const BIOCGRSIG: c_ulong = 0x40044272; -pub const BIOCSRSIG: c_ulong = 0x80044273; -pub const BIOCSDLT: c_ulong = 0x80044278; -pub const BIOCGSEESENT: c_ulong = 0x40044276; -pub const BIOCSSEESENT: c_ulong = 0x80044277; -pub const BIOCGDLTLIST: c_ulong = 0xc00c4279; - pub const FIODTYPE: c_ulong = 0x4004667a; pub const B0: speed_t = 0; @@ -3634,26 +3627,6 @@ pub const MH_MAGIC_64: u32 = 0xfeedfacf; pub const UTUN_OPT_FLAGS: c_int = 1; pub const UTUN_OPT_IFNAME: c_int = 2; -// net/bpf.h -pub const DLT_NULL: c_uint = 0; // no link-layer encapsulation -pub const DLT_EN10MB: c_uint = 1; // Ethernet (10Mb) -pub const DLT_EN3MB: c_uint = 2; // Experimental Ethernet (3Mb) -pub const DLT_AX25: c_uint = 3; // Amateur Radio AX.25 -pub const DLT_PRONET: c_uint = 4; // Proteon ProNET Token Ring -pub const DLT_CHAOS: c_uint = 5; // Chaos -pub const DLT_IEEE802: c_uint = 6; // IEEE 802 Networks -pub const DLT_ARCNET: c_uint = 7; // ARCNET -pub const DLT_SLIP: c_uint = 8; // Serial Line IP -pub const DLT_PPP: c_uint = 9; // Point-to-point Protocol -pub const DLT_FDDI: c_uint = 10; // FDDI -pub const DLT_ATM_RFC1483: c_uint = 11; // LLC/SNAP encapsulated atm -pub const DLT_RAW: c_uint = 12; // raw IP -pub const DLT_LOOP: c_uint = 108; - -// https://github.com/apple/darwin-xnu/blob/HEAD/bsd/net/bpf.h#L100 -// sizeof(i32) -pub const BPF_ALIGNMENT: c_int = 4; - // sys/mount.h pub const MNT_NODEV: c_int = 0x00000010; pub const MNT_UNION: c_int = 0x00000020;