From 629908abe33f4594a04dd4b4091e6eaca4056302 Mon Sep 17 00:00:00 2001 From: luozijun Date: Tue, 26 Dec 2017 15:57:11 +0800 Subject: [PATCH] Add struct `bpf_hdr` on macOS --- libc-test/build.rs | 1 + src/unix/bsd/apple/b32.rs | 7 +++++++ src/unix/bsd/apple/b64.rs | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index a356be20..cc4ec04c 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"); } diff --git a/src/unix/bsd/apple/b32.rs b/src/unix/bsd/apple/b32.rs index 53fc0ae1..5dea472c 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 e4a39819..2b34f853 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;