Skip to content
6 changes: 6 additions & 0 deletions src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,7 @@ impl Socket {
target_os = "nto",
target_os = "espidf",
target_os = "vita",
target_os = "cygwin",
)))]
pub fn join_multicast_v4_n(
&self,
Expand Down Expand Up @@ -1287,6 +1288,7 @@ impl Socket {
target_os = "nto",
target_os = "espidf",
target_os = "vita",
target_os = "cygwin",
)))]
pub fn leave_multicast_v4_n(
&self,
Expand Down Expand Up @@ -1577,6 +1579,7 @@ impl Socket {
target_os = "nto",
target_os = "espidf",
target_os = "vita",
target_os = "cygwin",
)))]
pub fn set_recv_tos_v4(&self, recv_tos: bool) -> io::Result<()> {
unsafe {
Expand Down Expand Up @@ -1608,6 +1611,7 @@ impl Socket {
target_os = "nto",
target_os = "espidf",
target_os = "vita",
target_os = "cygwin",
)))]
pub fn recv_tos_v4(&self) -> io::Result<bool> {
unsafe {
Expand Down Expand Up @@ -1978,6 +1982,7 @@ impl Socket {
target_os = "hurd",
target_os = "espidf",
target_os = "vita",
target_os = "cygwin",
))
))]
pub fn recv_hoplimit_v6(&self) -> io::Result<bool> {
Expand Down Expand Up @@ -2006,6 +2011,7 @@ impl Socket {
target_os = "hurd",
target_os = "espidf",
target_os = "vita",
target_os = "cygwin",
))
))]
pub fn set_recv_hoplimit_v6(&self, recv_hoplimit: bool) -> io::Result<()> {
Expand Down
9 changes: 7 additions & 2 deletions src/sys/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ pub(crate) use libc::IPV6_HDRINCL;
target_os = "haiku",
target_os = "espidf",
target_os = "vita",
target_os = "cygwin",
))
))]
pub(crate) use libc::IPV6_RECVHOPLIMIT;
Expand Down Expand Up @@ -173,6 +174,7 @@ pub(crate) use libc::IP_HDRINCL;
target_os = "nto",
target_os = "espidf",
target_os = "vita",
target_os = "cygwin",
)))]
pub(crate) use libc::IP_RECVTOS;
#[cfg(not(any(
Expand Down Expand Up @@ -383,6 +385,7 @@ type IovLen = usize;
target_os = "watchos",
target_os = "espidf",
target_os = "vita",
target_os = "cygwin",
))]
type IovLen = c_int;

Expand Down Expand Up @@ -1200,6 +1203,7 @@ pub(crate) fn set_tcp_keepalive(fd: Socket, keepalive: &TcpKeepalive) -> io::Res
target_os = "netbsd",
target_os = "tvos",
target_os = "watchos",
target_os = "cygwin",
))]
{
if let Some(interval) = keepalive.interval {
Expand Down Expand Up @@ -1333,6 +1337,7 @@ pub(crate) fn from_in6_addr(addr: in6_addr) -> Ipv6Addr {
target_os = "nto",
target_os = "espidf",
target_os = "vita",
target_os = "cygwin",
)))]
pub(crate) const fn to_mreqn(
multiaddr: &Ipv4Addr,
Expand Down Expand Up @@ -1956,7 +1961,7 @@ impl crate::Socket {
/// [`set_reuse_port`]: crate::Socket::set_reuse_port
#[cfg(all(
feature = "all",
not(any(target_os = "solaris", target_os = "illumos"))
not(any(target_os = "solaris", target_os = "illumos", target_os = "cygwin"))
))]
pub fn reuse_port(&self) -> io::Result<bool> {
unsafe {
Expand All @@ -1972,7 +1977,7 @@ impl crate::Socket {
/// there's a socket already listening on this port.
#[cfg(all(
feature = "all",
not(any(target_os = "solaris", target_os = "illumos"))
not(any(target_os = "solaris", target_os = "illumos", target_os = "cygwin"))
))]
pub fn set_reuse_port(&self, reuse: bool) -> io::Result<()> {
unsafe {
Expand Down
26 changes: 21 additions & 5 deletions tests/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,7 @@ fn r#type() {
target_os = "tvos",
target_os = "watchos",
target_os = "vita",
target_os = "cygwin",
)),
feature = "all",
))]
Expand Down Expand Up @@ -1356,12 +1357,21 @@ test!(out_of_band_inline, set_out_of_band_inline(true));
test!(reuse_address, set_reuse_address(true));
#[cfg(all(
feature = "all",
not(any(windows, target_os = "solaris", target_os = "illumos"))
not(any(
windows,
target_os = "solaris",
target_os = "illumos",
target_os = "cygwin",
))
))]
test!(reuse_port, set_reuse_port(true));
#[cfg(all(feature = "all", target_os = "freebsd"))]
test!(reuse_port_lb, set_reuse_port_lb(true));
#[cfg(all(feature = "all", unix, not(target_os = "redox")))]
#[cfg(all(
feature = "all",
unix,
not(any(target_os = "redox", target_os = "cygwin")),
))]
test!(
#[cfg_attr(target_os = "linux", ignore = "Different value returned")]
mss,
Expand Down Expand Up @@ -1413,6 +1423,7 @@ test!(IPv4 ttl_v4, set_ttl_v4(40));
target_os = "solaris",
target_os = "illumos",
target_os = "haiku",
target_os = "cygwin",
)))]
test!(IPv4 tos_v4, set_tos_v4(96));

Expand All @@ -1428,10 +1439,11 @@ test!(IPv4 tos_v4, set_tos_v4(96));
target_os = "windows",
target_os = "vita",
target_os = "haiku",
target_os = "cygwin",
)))]
test!(IPv4 recv_tos_v4, set_recv_tos_v4(true));

#[cfg(not(windows))] // TODO: returns `WSAENOPROTOOPT` (10042) on Windows.
#[cfg(not(any(windows, target_os = "cygwin")))] // TODO: returns `WSAENOPROTOOPT` (10042) on Windows.
test!(IPv4 broadcast, set_broadcast(true));

#[cfg(not(target_os = "vita"))]
Expand All @@ -1442,11 +1454,12 @@ test!(IPv6 unicast_hops_v6, set_unicast_hops_v6(20));
target_os = "dragonfly",
target_os = "freebsd",
target_os = "openbsd",
target_os = "vita"
target_os = "vita",
target_os = "cygwin",
)))]
test!(IPv6 only_v6, set_only_v6(true));
// IPv6 socket are already IPv6 only on FreeBSD and Windows.
#[cfg(any(windows, target_os = "freebsd"))]
#[cfg(any(windows, target_os = "freebsd", target_os = "cygwin"))]
test!(IPv6 only_v6, set_only_v6(false));

#[cfg(all(
Expand Down Expand Up @@ -1476,6 +1489,7 @@ test!(IPv6 tclass_v6, set_tclass_v6(96));
target_os = "windows",
target_os = "vita",
target_os = "haiku",
target_os = "cygwin",
)))]
test!(IPv6 recv_tclass_v6, set_recv_tclass_v6(true));

Expand All @@ -1493,6 +1507,7 @@ test!(IPv6 recv_tclass_v6, set_recv_tclass_v6(true));
target_os = "windows",
target_os = "vita",
target_os = "haiku",
target_os = "cygwin",
))
))]
test!(IPv6 recv_hoplimit_v6, set_recv_hoplimit_v6(true));
Expand Down Expand Up @@ -1520,6 +1535,7 @@ test!(IPv6 multicast_all_v6, set_multicast_all_v6(false));
target_os = "redox",
target_os = "solaris",
target_os = "vita",
target_os = "cygwin",
)))]
fn join_leave_multicast_v4_n() {
let socket = Socket::new(Domain::IPV4, Type::DGRAM, None).unwrap();
Expand Down