diff options
author | bors <bors@rust-lang.org> | 2017-12-27 16:53:30 +0000 |
---|---|---|
committer | bors <bors@rust-lang.org> | 2017-12-27 16:53:30 +0000 |
commit | b8bf3cf0bbb696d22ec5a28a039d2925c12254a1 (patch) | |
tree | 0a45441981ed4c7a8e99c65e607915a0ce6e34f0 | |
parent | 5221616a7714428df82b38605a786bb9988b4391 (diff) | |
parent | 536b5cfa865691465b86942113bfdab082fd2ae3 (diff) | |
download | rust-libc-b8bf3cf0bbb696d22ec5a28a039d2925c12254a1.tar.gz |
Auto merge of #883 - LuoZijun:patch-2, r=alexcrichton
Add some constant and struct on macOS
file: `net/bpf.h`
-rw-r--r-- | libc-test/build.rs | 2 | ||||
-rw-r--r-- | src/unix/bsd/apple/b32.rs | 7 | ||||
-rw-r--r-- | src/unix/bsd/apple/b64.rs | 7 | ||||
-rw-r--r-- | src/unix/bsd/apple/mod.rs | 20 | ||||
-rw-r--r-- | src/unix/bsd/freebsdlike/mod.rs | 4 |
5 files changed, 40 insertions, 0 deletions
diff --git a/libc-test/build.rs b/libc-test/build.rs index a356be20d4..f54f843d4b 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -170,6 +170,7 @@ fn main() { cfg.header("sys/xattr.h"); cfg.header("sys/sys_domain.h"); cfg.header("net/if_utun.h"); + cfg.header("net/bpf.h"); if target.starts_with("x86") { cfg.header("crt_externs.h"); } @@ -182,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/b32.rs b/src/unix/bsd/apple/b32.rs index 53fc0ae19d..5dea472ccb 100644 --- a/src/unix/bsd/apple/b32.rs +++ b/src/unix/bsd/apple/b32.rs @@ -41,6 +41,13 @@ s! { pub ifi_reserved1: u32, pub ifi_reserved2: u32, } + + pub struct bpf_hdr { + pub bh_tstamp: ::timeval, + pub bh_caplen: ::uint32_t, + pub bh_datalen: ::uint32_t, + pub bh_hdrlen: ::c_ushort, + } } pub const __PTHREAD_MUTEX_SIZE__: usize = 40; diff --git a/src/unix/bsd/apple/b64.rs b/src/unix/bsd/apple/b64.rs index e4a3981941..2b34f85345 100644 --- a/src/unix/bsd/apple/b64.rs +++ b/src/unix/bsd/apple/b64.rs @@ -46,6 +46,13 @@ s! { pub ifi_reserved1: u32, pub ifi_reserved2: u32, } + + pub struct bpf_hdr { + pub bh_tstamp: ::timeval32, + pub bh_caplen: ::uint32_t, + pub bh_datalen: ::uint32_t, + pub bh_hdrlen: ::c_ushort, + } } pub const __PTHREAD_MUTEX_SIZE__: usize = 56; 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 |