Repository: rust-lang/socket2 (Rust)

Issue:
`Socket::bind_device_by_index_{v4,v6}` should be available on illumos/Solaris
The `Socket::bind_device_by_index_v4` and `Socket::bind_device_by_index_v6` functions wrap the socket option `IP_BOUND_IF`. Presently, these functions have the following `cfg` attribute:

```rust
    #[cfg(all(
        feature = "all",
        any(
            target_os = "ios",
            target_os = "visionos",
            target_os = "macos",
            target_os = "tvos",
            target_os = "watchos",
        )
    ))]
```
This means that these methods are only available on macOS-like systems. However, the `IP_BOUND_IF` socket option also exists on SunOS-derived systems (e.g. illumos and Solaris); see for instance [the Solaris `man` page for `ip(7p)`](https://docs.oracle.com/cd/E86824_01/html/E54777/ip-7p.html). We should change the list of systems that these methods are available on so that they also exist on these systems.


Discussion:

Patch:
diff --git a/Cargo.toml b/Cargo.toml
index 18331f61..d0566282 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -51,7 +51,7 @@ targets = [
 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 c187d517..37d0c3a6 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;
@@ -1834,6 +1836,8 @@ impl crate::Socket {
             target_os = "macos",
             target_os = "tvos",
             target_os = "watchos",
+            target_os = "illumos",
+            target_os = "solaris",
         )
     ))]
     pub fn bind_device_by_index_v4(&self, interface: Option<NonZeroU32>) -> io::Result<()> {
@@ -1859,6 +1863,8 @@ impl crate::Socket {
             target_os = "macos",
             target_os = "tvos",
             target_os = "watchos",
+            target_os = "illumos",
+            target_os = "solaris",
         )
     ))]
     pub fn bind_device_by_index_v6(&self, interface: Option<NonZeroU32>) -> io::Result<()> {
@@ -1879,6 +1885,8 @@ impl crate::Socket {
             target_os = "macos",
             target_os = "tvos",
             target_os = "watchos",
+            target_os = "illumos",
+            target_os = "solaris",
         )
     ))]
     pub fn device_index_v4(&self) -> io::Result<Option<NonZeroU32>> {
@@ -1900,6 +1908,8 @@ impl crate::Socket {
             target_os = "macos",
             target_os = "tvos",
             target_os = "watchos",
+            target_os = "illumos",
+            target_os = "solaris",
         )
     ))]
     pub fn device_index_v6(&self) -> io::Result<Option<NonZeroU32>> {


Test patch:
diff --git a/tests/socket.rs b/tests/socket.rs
index 3776a4b4..a2dca668 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]