Skip to content

Commit 60e8e22

Browse files
committed
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 <wllenyj@gmail.com>
1 parent 3db3b99 commit 60e8e22

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

src/socket.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::io::{self, Read, Write};
1111
#[cfg(not(any(target_os = "redox", target_os = "wasi", target_os = "horizon")))]
1212
use std::io::{IoSlice, IoSliceMut};
1313
use std::mem::MaybeUninit;
14-
#[cfg(not(target_os = "nto"))]
14+
#[cfg(not(any(target_os = "nto", target_os = "nuttx")))]
1515
use std::net::Ipv6Addr;
1616
use std::net::{self, Ipv4Addr, Shutdown};
1717
#[cfg(any(unix, all(target_os = "wasi", not(target_env = "p1"))))]
@@ -785,6 +785,7 @@ fn set_common_flags(socket: Socket) -> io::Result<Socket> {
785785
target_os = "netbsd",
786786
target_os = "openbsd",
787787
target_os = "espidf",
788+
target_os = "nuttx",
788789
target_os = "vita",
789790
target_os = "cygwin",
790791
))
@@ -835,6 +836,7 @@ fn set_common_accept_flags(socket: Socket) -> io::Result<Socket> {
835836
target_os = "netbsd",
836837
target_os = "openbsd",
837838
target_os = "espidf",
839+
target_os = "nuttx",
838840
target_os = "vita",
839841
target_os = "cygwin",
840842
))
@@ -1214,6 +1216,7 @@ impl Socket {
12141216
not(any(
12151217
target_os = "redox",
12161218
target_os = "espidf",
1219+
target_os = "nuttx",
12171220
target_os = "wasi",
12181221
target_os = "horizon"
12191222
))
@@ -1245,6 +1248,7 @@ impl Socket {
12451248
not(any(
12461249
target_os = "redox",
12471250
target_os = "espidf",
1251+
target_os = "nuttx",
12481252
target_os = "wasi",
12491253
target_os = "horizon"
12501254
))
@@ -1686,6 +1690,7 @@ impl Socket {
16861690
target_os = "haiku",
16871691
target_os = "nto",
16881692
target_os = "espidf",
1693+
target_os = "nuttx",
16891694
target_os = "vita",
16901695
target_os = "cygwin",
16911696
target_os = "wasi",
@@ -1720,6 +1725,7 @@ impl Socket {
17201725
target_os = "haiku",
17211726
target_os = "nto",
17221727
target_os = "espidf",
1728+
target_os = "nuttx",
17231729
target_os = "vita",
17241730
target_os = "cygwin",
17251731
target_os = "wasi",
@@ -1763,6 +1769,7 @@ impl Socket {
17631769
not(any(
17641770
target_os = "redox",
17651771
target_os = "espidf",
1772+
target_os = "nuttx",
17661773
target_os = "openbsd",
17671774
target_os = "freebsd",
17681775
target_os = "dragonfly",
@@ -1795,6 +1802,7 @@ impl Socket {
17951802
not(any(
17961803
target_os = "redox",
17971804
target_os = "espidf",
1805+
target_os = "nuttx",
17981806
target_os = "openbsd",
17991807
target_os = "freebsd",
18001808
target_os = "dragonfly",
@@ -1864,7 +1872,7 @@ impl Socket {
18641872
/// This function specifies a new multicast group for this socket to join.
18651873
/// The address must be a valid multicast address, and `interface` is the
18661874
/// index of the interface to join/leave (or 0 to indicate any interface).
1867-
#[cfg(not(target_os = "nto"))]
1875+
#[cfg(not(any(target_os = "nto", target_os = "nuttx")))]
18681876
pub fn join_multicast_v6(&self, multiaddr: &Ipv6Addr, interface: u32) -> io::Result<()> {
18691877
let mreq = sys::Ipv6Mreq {
18701878
ipv6mr_multiaddr: sys::to_in6_addr(multiaddr),
@@ -1888,7 +1896,7 @@ impl Socket {
18881896
/// For more information about this option, see [`join_multicast_v6`].
18891897
///
18901898
/// [`join_multicast_v6`]: Socket::join_multicast_v6
1891-
#[cfg(not(target_os = "nto"))]
1899+
#[cfg(not(any(target_os = "nto", target_os = "nuttx")))]
18921900
pub fn leave_multicast_v6(&self, multiaddr: &Ipv6Addr, interface: u32) -> io::Result<()> {
18931901
let mreq = sys::Ipv6Mreq {
18941902
ipv6mr_multiaddr: sys::to_in6_addr(multiaddr),
@@ -2098,6 +2106,7 @@ impl Socket {
20982106
target_os = "haiku",
20992107
target_os = "hurd",
21002108
target_os = "espidf",
2109+
target_os = "nuttx",
21012110
target_os = "vita",
21022111
target_os = "wasi",
21032112
target_os = "horizon"
@@ -2125,6 +2134,7 @@ impl Socket {
21252134
target_os = "haiku",
21262135
target_os = "hurd",
21272136
target_os = "espidf",
2137+
target_os = "nuttx",
21282138
target_os = "vita",
21292139
target_os = "wasi",
21302140
target_os = "horizon"

src/sys/unix.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ pub(crate) use libc::MSG_TRUNC;
135135
#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
136136
pub(crate) use libc::SO_OOBINLINE;
137137
// Used in `Socket`.
138-
#[cfg(not(target_os = "nto"))]
138+
#[cfg(not(any(target_os = "nto", target_os = "nuttx")))]
139139
pub(crate) use libc::ipv6_mreq as Ipv6Mreq;
140140
#[cfg(all(feature = "all", target_os = "linux"))]
141141
pub(crate) use libc::IPV6_HDRINCL;
@@ -170,6 +170,7 @@ pub(crate) use libc::IPV6_RECVHOPLIMIT;
170170
target_os = "solaris",
171171
target_os = "haiku",
172172
target_os = "espidf",
173+
target_os = "nuttx",
173174
target_os = "vita",
174175
target_os = "wasi",
175176
target_os = "horizon"
@@ -180,6 +181,7 @@ pub(crate) use libc::IPV6_RECVTCLASS;
180181
not(any(
181182
target_os = "redox",
182183
target_os = "espidf",
184+
target_os = "nuttx",
183185
target_os = "wasi",
184186
target_os = "horizon"
185187
))
@@ -198,6 +200,7 @@ pub(crate) use libc::IP_HDRINCL;
198200
target_os = "hurd",
199201
target_os = "nto",
200202
target_os = "espidf",
203+
target_os = "nuttx",
201204
target_os = "vita",
202205
target_os = "wasi",
203206
target_os = "cygwin",
@@ -272,6 +275,7 @@ pub(crate) use libc::{
272275
target_os = "solaris",
273276
target_os = "tvos",
274277
target_os = "watchos",
278+
target_os = "nuttx",
275279
target_os = "wasi",
276280
)))]
277281
pub(crate) use libc::{IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP};
@@ -428,6 +432,7 @@ type IovLen = usize;
428432
target_os = "tvos",
429433
target_os = "watchos",
430434
target_os = "espidf",
435+
target_os = "nuttx",
431436
target_os = "vita",
432437
target_os = "cygwin",
433438
))]
@@ -2212,6 +2217,7 @@ impl crate::Socket {
22122217
target_os = "solaris",
22132218
target_os = "illumos",
22142219
target_os = "cygwin",
2220+
target_os = "nuttx",
22152221
target_os = "wasi"
22162222
))
22172223
))]
@@ -2233,6 +2239,7 @@ impl crate::Socket {
22332239
target_os = "solaris",
22342240
target_os = "illumos",
22352241
target_os = "cygwin",
2242+
target_os = "nuttx",
22362243
target_os = "wasi"
22372244
))
22382245
))]

0 commit comments

Comments
 (0)