From afc35995ab502e6c6ff2f577fe2a199a0df4549a Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Tue, 11 Mar 2025 14:51:06 -0700 Subject: [PATCH] Enable `IP_BOUND_IF` on illumos and Solaris (#561) The `IP_BOUND_IF` socket option, which is wrapped by the `Socket::bind_device_by_index_{v4,v6}` and `Socket::device_index_{v4,v6}` is available on SunOS-like systems, such as illumos and Solaris, as well as macOS-like systems. However, these APIs are currently cfg-flagged to only be available on macOS-like systems. This commit changes the cfg attributes to also enable these APIs on illumos and Solaris. Fixes #560 --- Cargo.toml | 2 +- src/sys/unix.rs | 10 ++++++++++ tests/socket.rs | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index fbb7fea9..94f93c80 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ targets = ["aarch64-apple-ios", "aarch64-linux-android", "x86_64-apple-darwin", features = ["all"] [target."cfg(unix)".dependencies] -libc = "0.2.150" +libc = "0.2.171" [target.'cfg(windows)'.dependencies.windows-sys] version = "0.52" diff --git a/src/sys/unix.rs b/src/sys/unix.rs index b40c3df1..2e90bced 100644 --- a/src/sys/unix.rs +++ b/src/sys/unix.rs @@ -22,6 +22,8 @@ use std::net::{Ipv4Addr, Ipv6Addr}; target_os = "macos", target_os = "tvos", target_os = "watchos", + target_os = "illumos", + target_os = "solaris", ) ))] use std::num::NonZeroU32; @@ -2076,6 +2078,8 @@ impl crate::Socket { target_os = "macos", target_os = "tvos", target_os = "watchos", + target_os = "illumos", + target_os = "solaris", ) ))] #[cfg_attr( @@ -2114,6 +2118,8 @@ impl crate::Socket { target_os = "macos", target_os = "tvos", target_os = "watchos", + target_os = "illumos", + target_os = "solaris", ) ))] #[cfg_attr( @@ -2147,6 +2153,8 @@ impl crate::Socket { target_os = "macos", target_os = "tvos", target_os = "watchos", + target_os = "illumos", + target_os = "solaris", ) ))] #[cfg_attr( @@ -2210,6 +2218,8 @@ impl crate::Socket { target_os = "macos", target_os = "tvos", target_os = "watchos", + target_os = "illumos", + target_os = "solaris", ) ))] #[cfg_attr( diff --git a/tests/socket.rs b/tests/socket.rs index 98a535c7..4180f19c 100644 --- a/tests/socket.rs +++ b/tests/socket.rs @@ -990,6 +990,8 @@ fn device() { target_os = "macos", target_os = "tvos", target_os = "watchos", + target_os = "solaris", + target_os = "illumos", ) ))] #[test] @@ -1036,6 +1038,8 @@ fn device() { target_os = "macos", target_os = "tvos", target_os = "watchos", + target_os = "solaris", + target_os = "illumos", ) ))] #[test]