summaryrefslogtreecommitdiff
path: root/src/sys
diff options
context:
space:
mode:
Diffstat (limited to 'src/sys')
-rw-r--r--src/sys/ioctl/bsd.rs7
-rw-r--r--src/sys/ioctl/mod.rs2
-rw-r--r--src/sys/mod.rs1
-rw-r--r--src/sys/socket/addr.rs45
-rw-r--r--src/sys/socket/mod.rs14
-rw-r--r--src/sys/socket/sockopt.rs5
-rw-r--r--src/sys/termios.rs52
7 files changed, 112 insertions, 14 deletions
diff --git a/src/sys/ioctl/bsd.rs b/src/sys/ioctl/bsd.rs
index f39c0eb6..4ce4d332 100644
--- a/src/sys/ioctl/bsd.rs
+++ b/src/sys/ioctl/bsd.rs
@@ -1,6 +1,12 @@
/// The datatype used for the ioctl number
#[doc(hidden)]
+#[cfg(not(target_os = "illumos"))]
pub type ioctl_num_type = ::libc::c_ulong;
+
+#[doc(hidden)]
+#[cfg(target_os = "illumos")]
+pub type ioctl_num_type = ::libc::c_int;
+
/// The datatype used for the 3rd argument
#[doc(hidden)]
pub type ioctl_param_type = ::libc::c_int;
@@ -12,6 +18,7 @@ mod consts {
#[doc(hidden)]
pub const OUT: ioctl_num_type = 0x4000_0000;
#[doc(hidden)]
+ #[allow(overflowing_literals)]
pub const IN: ioctl_num_type = 0x8000_0000;
#[doc(hidden)]
pub const INOUT: ioctl_num_type = IN|OUT;
diff --git a/src/sys/ioctl/mod.rs b/src/sys/ioctl/mod.rs
index 8858a9d5..d543b0cc 100644
--- a/src/sys/ioctl/mod.rs
+++ b/src/sys/ioctl/mod.rs
@@ -232,6 +232,7 @@ pub use self::linux::*;
#[cfg(any(target_os = "dragonfly",
target_os = "freebsd",
+ target_os = "illumos",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
@@ -241,6 +242,7 @@ mod bsd;
#[cfg(any(target_os = "dragonfly",
target_os = "freebsd",
+ target_os = "illumos",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
diff --git a/src/sys/mod.rs b/src/sys/mod.rs
index 438fb4fd..43877a12 100644
--- a/src/sys/mod.rs
+++ b/src/sys/mod.rs
@@ -28,6 +28,7 @@ pub mod eventfd;
target_os = "redox",
target_os = "macos",
target_os = "netbsd",
+ target_os = "illumos",
target_os = "openbsd"))]
#[macro_use]
pub mod ioctl;
diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs
index 2299c57d..1f7f4ec6 100644
--- a/src/sys/socket/addr.rs
+++ b/src/sys/socket/addr.rs
@@ -20,6 +20,7 @@ use crate::sys::socket::addr::sys_control::SysControlAddr;
target_os = "ios",
target_os = "linux",
target_os = "macos",
+ target_os = "illumos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "fuchsia"))]
@@ -42,7 +43,11 @@ pub enum AddressFamily {
#[cfg(any(target_os = "android", target_os = "linux"))]
Netlink = libc::AF_NETLINK,
/// Low level packet interface (see [`packet(7)`](http://man7.org/linux/man-pages/man7/packet.7.html))
- #[cfg(any(target_os = "android", target_os = "linux", target_os = "fuchsia"))]
+ #[cfg(any(target_os = "android",
+ target_os = "linux",
+ target_os = "illumos",
+ target_os = "fuchsia",
+ target_os = "solaris"))]
Packet = libc::AF_PACKET,
/// KEXT Controls and Notifications
#[cfg(any(target_os = "ios", target_os = "macos"))]
@@ -98,12 +103,16 @@ pub enum AddressFamily {
Can = libc::AF_CAN,
#[cfg(any(target_os = "android", target_os = "linux"))]
Tipc = libc::AF_TIPC,
- #[cfg(not(any(target_os = "ios", target_os = "macos")))]
+ #[cfg(not(any(target_os = "illumos",
+ target_os = "ios",
+ target_os = "macos",
+ target_os = "solaris")))]
Bluetooth = libc::AF_BLUETOOTH,
#[cfg(any(target_os = "android", target_os = "linux"))]
Iucv = libc::AF_IUCV,
#[cfg(any(target_os = "android", target_os = "linux"))]
RxRpc = libc::AF_RXRPC,
+ #[cfg(not(any(target_os = "illumos", target_os = "solaris")))]
Isdn = libc::AF_ISDN,
#[cfg(any(target_os = "android", target_os = "linux"))]
Phonet = libc::AF_PHONET,
@@ -190,6 +199,7 @@ pub enum AddressFamily {
target_os = "freebsd",
target_os = "ios",
target_os = "macos",
+ target_os = "illumos",
target_os = "netbsd",
target_os = "openbsd"))]
Link = libc::AF_LINK,
@@ -241,6 +251,7 @@ impl AddressFamily {
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
+ target_os = "illumos",
target_os = "openbsd"))]
libc::AF_LINK => Some(AddressFamily::Link),
#[cfg(any(target_os = "android", target_os = "linux"))]
@@ -645,6 +656,7 @@ pub enum SockAddr {
target_os = "ios",
target_os = "linux",
target_os = "macos",
+ target_os = "illumos",
target_os = "netbsd",
target_os = "openbsd"))]
Link(LinkAddr),
@@ -699,6 +711,7 @@ impl SockAddr {
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
+ target_os = "illumos",
target_os = "openbsd"))]
SockAddr::Link(..) => AddressFamily::Link,
#[cfg(any(target_os = "android", target_os = "linux"))]
@@ -744,6 +757,7 @@ impl SockAddr {
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
+ target_os = "illumos",
target_os = "openbsd"))]
Some(AddressFamily::Link) => {
let ether_addr = LinkAddr(*(addr as *const libc::sockaddr_dl));
@@ -830,6 +844,7 @@ impl SockAddr {
target_os = "freebsd",
target_os = "ios",
target_os = "macos",
+ target_os = "illumos",
target_os = "netbsd",
target_os = "openbsd"))]
SockAddr::Link(LinkAddr(ref addr)) => (
@@ -869,6 +884,7 @@ impl fmt::Display for SockAddr {
target_os = "linux",
target_os = "macos",
target_os = "netbsd",
+ target_os = "illumos",
target_os = "openbsd"))]
SockAddr::Link(ref ether_addr) => ether_addr.fmt(f),
#[cfg(any(target_os = "android", target_os = "linux"))]
@@ -1118,6 +1134,7 @@ mod datalink {
target_os = "freebsd",
target_os = "ios",
target_os = "macos",
+ target_os = "illumos",
target_os = "netbsd",
target_os = "openbsd"))]
mod datalink {
@@ -1129,6 +1146,7 @@ mod datalink {
impl LinkAddr {
/// Total length of sockaddr
+ #[cfg(not(target_os = "illumos"))]
pub fn len(&self) -> usize {
self.0.sdl_len as usize
}
@@ -1280,6 +1298,7 @@ mod tests {
target_os = "linux",
target_os = "macos",
target_os = "netbsd",
+ target_os = "illumos",
target_os = "openbsd"))]
use super::*;
@@ -1324,6 +1343,28 @@ mod tests {
};
}
+ #[cfg(target_os = "illumos")]
+ #[test]
+ fn test_illumos_tap_datalink_addr() {
+ let bytes = [25u8, 0, 0, 0, 6, 0, 6, 0, 24, 101, 144, 221, 76, 176];
+ let ptr = bytes.as_ptr();
+ let sa = ptr as *const libc::sockaddr;
+ let _sock_addr = unsafe { SockAddr::from_libc_sockaddr(sa) };
+
+ assert!(_sock_addr.is_some());
+
+ let sock_addr = _sock_addr.unwrap();
+
+ assert_eq!(sock_addr.family(), AddressFamily::Link);
+
+ match sock_addr {
+ SockAddr::Link(ether_addr) => {
+ assert_eq!(ether_addr.addr(), [24u8, 101, 144, 221, 76, 176]);
+ },
+ _ => { unreachable!() }
+ };
+ }
+
#[cfg(any(target_os = "android", target_os = "linux"))]
#[test]
fn test_abstract_sun_path() {
diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs
index 73f976b8..74a26834 100644
--- a/src/sys/socket/mod.rs
+++ b/src/sys/socket/mod.rs
@@ -19,6 +19,7 @@ pub mod sockopt;
*
*/
+#[cfg(not(any(target_os = "illumos", target_os = "solaris")))]
pub use self::addr::{
AddressFamily,
SockAddr,
@@ -29,6 +30,17 @@ pub use self::addr::{
Ipv6Addr,
LinkAddr,
};
+#[cfg(any(target_os = "illumos", target_os = "solaris"))]
+pub use self::addr::{
+ AddressFamily,
+ SockAddr,
+ InetAddr,
+ UnixAddr,
+ IpAddr,
+ Ipv4Addr,
+ Ipv6Addr,
+};
+
#[cfg(any(target_os = "android", target_os = "linux"))]
pub use crate::sys::socket::addr::netlink::NetlinkAddr;
#[cfg(any(target_os = "android", target_os = "linux"))]
@@ -159,6 +171,7 @@ libc_bitflags!{
#[cfg(any(target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
+ target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd"))]
@@ -167,6 +180,7 @@ libc_bitflags!{
#[cfg(any(target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
+ target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd"))]
diff --git a/src/sys/socket/sockopt.rs b/src/sys/socket/sockopt.rs
index 5b7b4fea..fd9a710c 100644
--- a/src/sys/socket/sockopt.rs
+++ b/src/sys/socket/sockopt.rs
@@ -214,6 +214,7 @@ macro_rules! sockopt_impl {
*/
sockopt_impl!(Both, ReuseAddr, libc::SOL_SOCKET, libc::SO_REUSEADDR, bool);
+#[cfg(not(any(target_os = "illumos", target_os = "solaris")))]
sockopt_impl!(Both, ReusePort, libc::SOL_SOCKET, libc::SO_REUSEPORT, bool);
sockopt_impl!(Both, TcpNoDelay, libc::IPPROTO_TCP, libc::TCP_NODELAY, bool);
sockopt_impl!(Both, Linger, libc::SOL_SOCKET, libc::SO_LINGER, libc::linger);
@@ -225,10 +226,12 @@ cfg_if! {
sockopt_impl!(SetOnly, Ipv6DropMembership, libc::IPPROTO_IPV6, libc::IPV6_DROP_MEMBERSHIP, super::Ipv6MembershipRequest);
} else if #[cfg(any(target_os = "dragonfly",
target_os = "freebsd",
+ target_os = "illumos",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
- target_os = "openbsd"))] {
+ target_os = "openbsd",
+ target_os = "solaris"))] {
sockopt_impl!(SetOnly, Ipv6AddMembership, libc::IPPROTO_IPV6, libc::IPV6_JOIN_GROUP, super::Ipv6MembershipRequest);
sockopt_impl!(SetOnly, Ipv6DropMembership, libc::IPPROTO_IPV6, libc::IPV6_LEAVE_GROUP, super::Ipv6MembershipRequest);
}
diff --git a/src/sys/termios.rs b/src/sys/termios.rs
index c30de80d..f6981db9 100644
--- a/src/sys/termios.rs
+++ b/src/sys/termios.rs
@@ -299,11 +299,17 @@ libc_enum!{
target_os = "openbsd"))]
B76800,
B115200,
+ #[cfg(any(target_os = "illumos", target_os = "solaris"))]
+ B153600,
B230400,
+ #[cfg(any(target_os = "illumos", target_os = "solaris"))]
+ B307200,
#[cfg(any(target_os = "android",
target_os = "freebsd",
+ target_os = "illumos",
target_os = "linux",
- target_os = "netbsd"))]
+ target_os = "netbsd",
+ target_os = "solaris"))]
B460800,
#[cfg(any(target_os = "android", target_os = "linux"))]
B500000,
@@ -311,8 +317,10 @@ libc_enum!{
B576000,
#[cfg(any(target_os = "android",
target_os = "freebsd",
+ target_os = "illumos",
target_os = "linux",
- target_os = "netbsd"))]
+ target_os = "netbsd",
+ target_os = "solaris"))]
B921600,
#[cfg(any(target_os = "android", target_os = "linux"))]
B1000000,
@@ -354,6 +362,8 @@ impl TryFrom<libc::speed_t> for BaudRate {
target_os = "linux",
target_os = "netbsd"))]
use libc::{B460800, B921600};
+ #[cfg(any(target_os = "illumos", target_os = "solaris"))]
+ use libc::{B153600, B307200, B460800, B921600};
match s {
B0 => Ok(BaudRate::B0),
@@ -398,11 +408,19 @@ impl TryFrom<libc::speed_t> for BaudRate {
target_os = "openbsd"))]
B76800 => Ok(BaudRate::B76800),
B115200 => Ok(BaudRate::B115200),
+ #[cfg(any(target_os = "illumos",
+ target_os = "solaris"))]
+ B153600 => Ok(BaudRate::B153600),
B230400 => Ok(BaudRate::B230400),
+ #[cfg(any(target_os = "illumos",
+ target_os = "solaris"))]
+ B307200 => Ok(BaudRate::B307200),
#[cfg(any(target_os = "android",
target_os = "freebsd",
+ target_os = "illumos",
target_os = "linux",
- target_os = "netbsd"))]
+ target_os = "netbsd",
+ target_os = "solaris"))]
B460800 => Ok(BaudRate::B460800),
#[cfg(any(target_os = "android", target_os = "linux"))]
B500000 => Ok(BaudRate::B500000),
@@ -410,8 +428,10 @@ impl TryFrom<libc::speed_t> for BaudRate {
B576000 => Ok(BaudRate::B576000),
#[cfg(any(target_os = "android",
target_os = "freebsd",
+ target_os = "illumos",
target_os = "linux",
- target_os = "netbsd"))]
+ target_os = "netbsd",
+ target_os = "solaris"))]
B921600 => Ok(BaudRate::B921600),
#[cfg(any(target_os = "android", target_os = "linux"))]
B1000000 => Ok(BaudRate::B1000000),
@@ -502,37 +522,46 @@ libc_enum! {
VDISCARD,
#[cfg(any(target_os = "dragonfly",
target_os = "freebsd",
+ target_os = "illumos",
target_os = "macos",
target_os = "netbsd",
- target_os = "openbsd"))]
+ target_os = "openbsd",
+ target_os = "solaris"))]
VDSUSP,
VEOF,
VEOL,
VEOL2,
VERASE,
- #[cfg(any(target_os = "dragonfly", target_os = "freebsd"))]
+ #[cfg(any(target_os = "dragonfly",
+ target_os = "freebsd",
+ target_os = "illumos",
+ target_os = "solaris"))]
VERASE2,
VINTR,
VKILL,
VLNEXT,
- #[cfg(not(all(target_os = "linux", target_arch = "sparc64")))]
+ #[cfg(not(any(all(target_os = "linux", target_arch = "sparc64"),
+ target_os = "illumos", target_os = "solaris")))]
VMIN,
VQUIT,
VREPRINT,
VSTART,
#[cfg(any(target_os = "dragonfly",
target_os = "freebsd",
+ target_os = "illumos",
target_os = "macos",
target_os = "netbsd",
- target_os = "openbsd"))]
+ target_os = "openbsd",
+ target_os = "solaris"))]
VSTATUS,
VSTOP,
VSUSP,
#[cfg(target_os = "linux")]
VSWTC,
- #[cfg(target_os = "haiku")]
+ #[cfg(any(target_os = "haiku", target_os = "illumos", target_os = "solaris"))]
VSWTCH,
- #[cfg(not(all(target_os = "linux", target_arch = "sparc64")))]
+ #[cfg(not(any(all(target_os = "linux", target_arch = "sparc64"),
+ target_os = "illumos", target_os = "solaris")))]
VTIME,
VWERASE,
#[cfg(target_os = "dragonfly")]
@@ -540,7 +569,8 @@ libc_enum! {
}
}
-#[cfg(all(target_os = "linux", target_arch = "sparc64"))]
+#[cfg(any(all(target_os = "linux", target_arch = "sparc64"),
+ target_os = "illumos", target_os = "solaris"))]
impl SpecialCharacterIndices {
pub const VMIN: SpecialCharacterIndices = SpecialCharacterIndices::VEOF;
pub const VTIME: SpecialCharacterIndices = SpecialCharacterIndices::VEOL;