diff options
author | luozijun <gnulinux@126.com> | 2017-12-26 16:02:17 +0800 |
---|---|---|
committer | luozijun <gnulinux@126.com> | 2017-12-27 04:04:46 +0800 |
commit | 536b5cfa865691465b86942113bfdab082fd2ae3 (patch) | |
tree | 0a45441981ed4c7a8e99c65e607915a0ce6e34f0 | |
parent | 629908abe33f4594a04dd4b4091e6eaca4056302 (diff) | |
download | rust-libc-536b5cfa865691465b86942113bfdab082fd2ae3.tar.gz |
Add bpf constant on macOS
-rw-r--r-- | libc-test/build.rs | 1 | ||||
-rw-r--r-- | src/unix/bsd/apple/mod.rs | 20 | ||||
-rw-r--r-- | src/unix/bsd/freebsdlike/mod.rs | 4 |
3 files changed, 25 insertions, 0 deletions
diff --git a/libc-test/build.rs b/libc-test/build.rs index cc4ec04c93..f54f843d4b 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -183,6 +183,7 @@ fn main() { cfg.header("sys/event.h"); cfg.header("net/if_dl.h"); if freebsd { + cfg.header("net/bpf.h"); cfg.header("libutil.h"); } else { cfg.header("util.h"); diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 5584b17439..7281f91968 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -2167,6 +2167,26 @@ 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/master/bsd/net/bpf.h#L100 +// sizeof(int32_t) +pub const BPF_ALIGNMENT: ::c_int = 4; + f! { pub fn WSTOPSIG(status: ::c_int) -> ::c_int { status >> 8 diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index a37abadd52..5cea759591 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -956,6 +956,10 @@ pub const ONLRET: ::tcflag_t = 0x40; pub const CMGROUP_MAX: usize = 16; +// https://github.com/freebsd/freebsd/blob/master/sys/net/bpf.h +// sizeof(long) +pub const BPF_ALIGNMENT: ::c_int = 8; + f! { pub fn WIFCONTINUED(status: ::c_int) -> bool { status == 0x13 |