diff options
author | Jake McGinty <me@jake.su> | 2018-04-22 15:09:20 -0700 |
---|---|---|
committer | Jake McGinty <me@jake.su> | 2018-04-22 21:24:33 -0700 |
commit | 0e3cf4737bff35b252736cb2888c20c5a89fa5bb (patch) | |
tree | c21f3481557ce55f52c4828532264f3cb2b40c56 | |
parent | 73af363c8452ab54f1b0595914edf1ed535130c1 (diff) | |
download | rust-libc-0e3cf4737bff35b252736cb2888c20c5a89fa5bb.tar.gz |
add pktinfo consts and structs for linux and apple
-rw-r--r-- | libc-test/build.rs | 3 | ||||
-rw-r--r-- | src/unix/bsd/apple/mod.rs | 14 | ||||
-rw-r--r-- | src/unix/notbsd/android/mod.rs | 5 | ||||
-rw-r--r-- | src/unix/notbsd/linux/mod.rs | 5 | ||||
-rw-r--r-- | src/unix/notbsd/mod.rs | 9 |
5 files changed, 36 insertions, 0 deletions
diff --git a/libc-test/build.rs b/libc-test/build.rs index 74a0b4b101..1262eea1bd 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -33,6 +33,8 @@ fn main() { cfg.define("_GNU_SOURCE", None); } else if netbsd { cfg.define("_NETBSD_SOURCE", Some("1")); + } else if apple { + cfg.define("__APPLE_USE_RFC_3542", None); } else if windows { cfg.define("_WIN32_WINNT", Some("0x8000")); } else if solaris { @@ -178,6 +180,7 @@ fn main() { } cfg.header("net/route.h"); cfg.header("netinet/if_ether.h"); + cfg.header("netinet/in.h"); cfg.header("sys/proc_info.h"); cfg.header("sys/kern_control.h"); cfg.header("sys/ipc.h"); diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 8fb1a1251d..d97eb3f4f6 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -512,6 +512,17 @@ s! { pub sc_reserved: [::uint32_t; 5], } + pub struct in_pktinfo { + pub ipi_ifindex: ::c_uint, + pub ipi_spec_dst: ::in_addr, + pub ipi_addr: ::in_addr, + } + + pub struct in6_pktinfo { + pub ipi6_addr: ::in6_addr, + pub ipi6_ifindex: ::c_uint, + } + // sys/ipc.h: pub struct ipc_perm { @@ -1503,8 +1514,11 @@ pub const IP_TTL: ::c_int = 4; pub const IP_HDRINCL: ::c_int = 2; pub const IP_ADD_MEMBERSHIP: ::c_int = 12; pub const IP_DROP_MEMBERSHIP: ::c_int = 13; +pub const IP_PKTINFO: ::c_int = 26; pub const IPV6_JOIN_GROUP: ::c_int = 12; pub const IPV6_LEAVE_GROUP: ::c_int = 13; +pub const IPV6_PKTINFO: ::c_int = 46; +pub const IPV6_RECVPKTINFO: ::c_int = 61; pub const TCP_NODELAY: ::c_int = 0x01; pub const TCP_KEEPALIVE: ::c_int = 0x10; diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index 239770edd4..b7a184c9d0 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -229,6 +229,11 @@ s! { pub nla_len: u16, pub nla_type: u16, } + + pub struct in6_pktinfo { + pub ipi6_addr: ::in6_addr, + pub ipi6_ifindex: ::c_int, + } } pub const O_TRUNC: ::c_int = 512; diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index d4a3bb9cd7..87b48456fd 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -469,6 +469,11 @@ s! { pub version: u8, pub reserved: u16, } + + pub struct in6_pktinfo { + pub ipi6_addr: ::in6_addr, + pub ipi6_ifindex: ::c_uint, + } } pub const ABDAY_1: ::nl_item = 0x20000; diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 92dfad6b9f..a7f6da5b74 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -177,6 +177,12 @@ s! { #[cfg(target_pointer_width = "32")] __unused1: [::c_int; 12] } + + pub struct in_pktinfo { + pub ipi_ifindex: ::c_int, + pub ipi_spec_dst: ::in_addr, + pub ipi_addr: ::in_addr, + } } // intentionally not public, only used for fd_set @@ -573,6 +579,7 @@ pub const IP_MULTICAST_TTL: ::c_int = 33; pub const IP_MULTICAST_LOOP: ::c_int = 34; pub const IP_TTL: ::c_int = 2; pub const IP_HDRINCL: ::c_int = 3; +pub const IP_PKTINFO: ::c_int = 8; pub const IP_ADD_MEMBERSHIP: ::c_int = 35; pub const IP_DROP_MEMBERSHIP: ::c_int = 36; pub const IP_TRANSPARENT: ::c_int = 19; @@ -583,6 +590,8 @@ pub const IPV6_MULTICAST_LOOP: ::c_int = 19; pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20; pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21; pub const IPV6_V6ONLY: ::c_int = 26; +pub const IPV6_RECVPKTINFO: ::c_int = 49; +pub const IPV6_PKTINFO: ::c_int = 50; pub const TCP_NODELAY: ::c_int = 1; pub const TCP_MAXSEG: ::c_int = 2; |