summaryrefslogtreecommitdiff
path: root/src/sys/socket/addr.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/sys/socket/addr.rs')
-rw-r--r--src/sys/socket/addr.rs45
1 files changed, 43 insertions, 2 deletions
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() {