Skip to content

Commit 5c1f3b0

Browse files
authored
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
1 parent 34aba73 commit 5c1f3b0

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ targets = [
5151
features = ["all"]
5252

5353
[target."cfg(unix)".dependencies]
54-
libc = "0.2.150"
54+
libc = "0.2.171"
5555

5656
[target.'cfg(windows)'.dependencies.windows-sys]
5757
version = "0.52"

src/sys/unix.rs

+10
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ use std::net::{Ipv4Addr, Ipv6Addr};
2222
target_os = "macos",
2323
target_os = "tvos",
2424
target_os = "watchos",
25+
target_os = "illumos",
26+
target_os = "solaris",
2527
)
2628
))]
2729
use std::num::NonZeroU32;
@@ -1834,6 +1836,8 @@ impl crate::Socket {
18341836
target_os = "macos",
18351837
target_os = "tvos",
18361838
target_os = "watchos",
1839+
target_os = "illumos",
1840+
target_os = "solaris",
18371841
)
18381842
))]
18391843
pub fn bind_device_by_index_v4(&self, interface: Option<NonZeroU32>) -> io::Result<()> {
@@ -1859,6 +1863,8 @@ impl crate::Socket {
18591863
target_os = "macos",
18601864
target_os = "tvos",
18611865
target_os = "watchos",
1866+
target_os = "illumos",
1867+
target_os = "solaris",
18621868
)
18631869
))]
18641870
pub fn bind_device_by_index_v6(&self, interface: Option<NonZeroU32>) -> io::Result<()> {
@@ -1879,6 +1885,8 @@ impl crate::Socket {
18791885
target_os = "macos",
18801886
target_os = "tvos",
18811887
target_os = "watchos",
1888+
target_os = "illumos",
1889+
target_os = "solaris",
18821890
)
18831891
))]
18841892
pub fn device_index_v4(&self) -> io::Result<Option<NonZeroU32>> {
@@ -1900,6 +1908,8 @@ impl crate::Socket {
19001908
target_os = "macos",
19011909
target_os = "tvos",
19021910
target_os = "watchos",
1911+
target_os = "illumos",
1912+
target_os = "solaris",
19031913
)
19041914
))]
19051915
pub fn device_index_v6(&self) -> io::Result<Option<NonZeroU32>> {

tests/socket.rs

+4
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,8 @@ fn device() {
990990
target_os = "macos",
991991
target_os = "tvos",
992992
target_os = "watchos",
993+
target_os = "solaris",
994+
target_os = "illumos",
993995
)
994996
))]
995997
#[test]
@@ -1036,6 +1038,8 @@ fn device() {
10361038
target_os = "macos",
10371039
target_os = "tvos",
10381040
target_os = "watchos",
1041+
target_os = "solaris",
1042+
target_os = "illumos",
10391043
)
10401044
))]
10411045
#[test]

0 commit comments

Comments
 (0)