From 3db3b99562fb2d564699edbbe8870598383f352c Mon Sep 17 00:00:00 2001 From: wanglei Date: Tue, 7 Jul 2026 14:22:37 +0800 Subject: [PATCH 1/2] nuttx: enable keepalive Signed-off-by: wanglei --- src/lib.rs | 2 ++ src/socket.rs | 2 ++ src/sys/unix.rs | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 53f9c591..30eedd62 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -541,6 +541,7 @@ impl TcpKeepalive { target_os = "watchos", target_os = "windows", target_os = "cygwin", + target_os = "nuttx", all(target_os = "wasi", not(target_env = "p1")), ))] pub const fn with_interval(self, interval: Duration) -> Self { @@ -572,6 +573,7 @@ impl TcpKeepalive { target_os = "watchos", target_os = "cygwin", target_os = "windows", + target_os = "nuttx", all(target_os = "wasi", not(target_env = "p1")), ) ))] diff --git a/src/socket.rs b/src/socket.rs index af493f70..3d38ddf7 100644 --- a/src/socket.rs +++ b/src/socket.rs @@ -2262,6 +2262,7 @@ impl Socket { target_os = "tvos", target_os = "watchos", target_os = "cygwin", + target_os = "nuttx", all(target_os = "wasi", not(target_env = "p1")), ) ))] @@ -2295,6 +2296,7 @@ impl Socket { target_os = "watchos", target_os = "cygwin", target_os = "windows", + target_os = "nuttx", all(target_os = "wasi", not(target_env = "p1")), ) ))] diff --git a/src/sys/unix.rs b/src/sys/unix.rs index da6adc8c..2287ed9f 100644 --- a/src/sys/unix.rs +++ b/src/sys/unix.rs @@ -312,6 +312,7 @@ pub(crate) use libc::{IPV6_MULTICAST_HOPS, IPV6_MULTICAST_IF, IP_MULTICAST_IF, M target_os = "tvos", target_os = "watchos", target_os = "cygwin", + target_os = "nuttx", all(target_os = "wasi", not(target_env = "p1")), ) ))] @@ -1295,6 +1296,7 @@ pub(crate) fn set_tcp_keepalive(fd: RawSocket, keepalive: &TcpKeepalive) -> io:: target_os = "tvos", target_os = "watchos", target_os = "cygwin", + target_os = "nuttx", all(target_os = "wasi", not(target_env = "p1")), ))] { From 377ba7b635331baf60c0bad86962d809acd1f885 Mon Sep 17 00:00:00 2001 From: wanglei Date: Tue, 7 Jul 2026 14:34:12 +0800 Subject: [PATCH 2/2] nuttx: disable unsupported capabilities These flags are not modified in Nuttx target. SO_REUSEPORT IP_HDRINCL IP_RECVTOS IPV6_RECVTCLASS IPV6_ADD_MEMBERSHIP IPV6_DROP_MEMBERSHIP Signed-off-by: wanglei --- src/socket.rs | 14 +++++++++++--- src/sys/unix.rs | 9 ++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/socket.rs b/src/socket.rs index 3d38ddf7..da01a77a 100644 --- a/src/socket.rs +++ b/src/socket.rs @@ -11,7 +11,7 @@ use std::io::{self, Read, Write}; #[cfg(not(any(target_os = "redox", target_os = "wasi", target_os = "horizon")))] use std::io::{IoSlice, IoSliceMut}; use std::mem::MaybeUninit; -#[cfg(not(target_os = "nto"))] +#[cfg(not(any(target_os = "nto", target_os = "nuttx")))] use std::net::Ipv6Addr; use std::net::{self, Ipv4Addr, Shutdown}; #[cfg(any(unix, all(target_os = "wasi", not(target_env = "p1"))))] @@ -1214,6 +1214,7 @@ impl Socket { not(any( target_os = "redox", target_os = "espidf", + target_os = "nuttx", target_os = "wasi", target_os = "horizon" )) @@ -1245,6 +1246,7 @@ impl Socket { not(any( target_os = "redox", target_os = "espidf", + target_os = "nuttx", target_os = "wasi", target_os = "horizon" )) @@ -1686,6 +1688,7 @@ impl Socket { target_os = "haiku", target_os = "nto", target_os = "espidf", + target_os = "nuttx", target_os = "vita", target_os = "cygwin", target_os = "wasi", @@ -1720,6 +1723,7 @@ impl Socket { target_os = "haiku", target_os = "nto", target_os = "espidf", + target_os = "nuttx", target_os = "vita", target_os = "cygwin", target_os = "wasi", @@ -1763,6 +1767,7 @@ impl Socket { not(any( target_os = "redox", target_os = "espidf", + target_os = "nuttx", target_os = "openbsd", target_os = "freebsd", target_os = "dragonfly", @@ -1795,6 +1800,7 @@ impl Socket { not(any( target_os = "redox", target_os = "espidf", + target_os = "nuttx", target_os = "openbsd", target_os = "freebsd", target_os = "dragonfly", @@ -1864,7 +1870,7 @@ impl Socket { /// This function specifies a new multicast group for this socket to join. /// The address must be a valid multicast address, and `interface` is the /// index of the interface to join/leave (or 0 to indicate any interface). - #[cfg(not(target_os = "nto"))] + #[cfg(not(any(target_os = "nto", target_os = "nuttx")))] pub fn join_multicast_v6(&self, multiaddr: &Ipv6Addr, interface: u32) -> io::Result<()> { let mreq = sys::Ipv6Mreq { ipv6mr_multiaddr: sys::to_in6_addr(multiaddr), @@ -1888,7 +1894,7 @@ impl Socket { /// For more information about this option, see [`join_multicast_v6`]. /// /// [`join_multicast_v6`]: Socket::join_multicast_v6 - #[cfg(not(target_os = "nto"))] + #[cfg(not(any(target_os = "nto", target_os = "nuttx")))] pub fn leave_multicast_v6(&self, multiaddr: &Ipv6Addr, interface: u32) -> io::Result<()> { let mreq = sys::Ipv6Mreq { ipv6mr_multiaddr: sys::to_in6_addr(multiaddr), @@ -2098,6 +2104,7 @@ impl Socket { target_os = "haiku", target_os = "hurd", target_os = "espidf", + target_os = "nuttx", target_os = "vita", target_os = "wasi", target_os = "horizon" @@ -2125,6 +2132,7 @@ impl Socket { target_os = "haiku", target_os = "hurd", target_os = "espidf", + target_os = "nuttx", target_os = "vita", target_os = "wasi", target_os = "horizon" diff --git a/src/sys/unix.rs b/src/sys/unix.rs index 2287ed9f..74e98ebd 100644 --- a/src/sys/unix.rs +++ b/src/sys/unix.rs @@ -135,7 +135,7 @@ pub(crate) use libc::MSG_TRUNC; #[cfg(not(any(target_os = "redox", target_os = "wasi")))] pub(crate) use libc::SO_OOBINLINE; // Used in `Socket`. -#[cfg(not(target_os = "nto"))] +#[cfg(not(any(target_os = "nto", target_os = "nuttx")))] pub(crate) use libc::ipv6_mreq as Ipv6Mreq; #[cfg(all(feature = "all", target_os = "linux"))] pub(crate) use libc::IPV6_HDRINCL; @@ -170,6 +170,7 @@ pub(crate) use libc::IPV6_RECVHOPLIMIT; target_os = "solaris", target_os = "haiku", target_os = "espidf", + target_os = "nuttx", target_os = "vita", target_os = "wasi", target_os = "horizon" @@ -180,6 +181,7 @@ pub(crate) use libc::IPV6_RECVTCLASS; not(any( target_os = "redox", target_os = "espidf", + target_os = "nuttx", target_os = "wasi", target_os = "horizon" )) @@ -198,6 +200,7 @@ pub(crate) use libc::IP_HDRINCL; target_os = "hurd", target_os = "nto", target_os = "espidf", + target_os = "nuttx", target_os = "vita", target_os = "wasi", target_os = "cygwin", @@ -272,6 +275,7 @@ pub(crate) use libc::{ target_os = "solaris", target_os = "tvos", target_os = "watchos", + target_os = "nuttx", target_os = "wasi", )))] pub(crate) use libc::{IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP}; @@ -428,6 +432,7 @@ type IovLen = usize; target_os = "tvos", target_os = "watchos", target_os = "espidf", + target_os = "nuttx", target_os = "vita", target_os = "cygwin", ))] @@ -2212,6 +2217,7 @@ impl crate::Socket { target_os = "solaris", target_os = "illumos", target_os = "cygwin", + target_os = "nuttx", target_os = "wasi" )) ))] @@ -2233,6 +2239,7 @@ impl crate::Socket { target_os = "solaris", target_os = "illumos", target_os = "cygwin", + target_os = "nuttx", target_os = "wasi" )) ))]