Add bpf constant on macOS

This commit is contained in:
luozijun 2017-12-26 16:02:17 +08:00
parent 629908abe3
commit 536b5cfa86
3 changed files with 25 additions and 0 deletions

View File

@ -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");

View File

@ -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

View File

@ -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