diff --git a/src/lib.rs b/src/lib.rs index a2e2ffcb..0abc1e9d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -205,13 +205,16 @@ impl Type { pub const DGRAM: Type = Type(sys::SOCK_DGRAM); /// Type corresponding to `SOCK_SEQPACKET`. - #[cfg(feature = "all")] - #[cfg_attr(docsrs, doc(cfg(feature = "all")))] + #[cfg(all(feature = "all", not(target_os = "espidf")))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "all", not(target_os = "espidf")))))] pub const SEQPACKET: Type = Type(sys::SOCK_SEQPACKET); /// Type corresponding to `SOCK_RAW`. - #[cfg(all(feature = "all", not(target_os = "redox")))] - #[cfg_attr(docsrs, doc(cfg(all(feature = "all", not(target_os = "redox")))))] + #[cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))] + #[cfg_attr( + docsrs, + doc(cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))) + )] pub const RAW: Type = Type(sys::SOCK_RAW); } @@ -280,6 +283,7 @@ impl RecvFlags { /// /// On Unix this corresponds to the `MSG_TRUNC` flag. /// On Windows this corresponds to the `WSAEMSGSIZE` error code. + #[cfg(not(target_os = "espidf"))] pub const fn is_truncated(self) -> bool { self.0 & sys::MSG_TRUNC != 0 } @@ -334,6 +338,7 @@ pub struct TcpKeepalive { target_os = "redox", target_os = "solaris", target_os = "nto", + target_os = "espidf", )))] interval: Option, #[cfg(not(any( @@ -342,6 +347,7 @@ pub struct TcpKeepalive { target_os = "solaris", target_os = "windows", target_os = "nto", + target_os = "espidf", )))] retries: Option, } @@ -356,6 +362,7 @@ impl TcpKeepalive { target_os = "redox", target_os = "solaris", target_os = "nto", + target_os = "espidf", )))] interval: None, #[cfg(not(any( @@ -364,6 +371,7 @@ impl TcpKeepalive { target_os = "solaris", target_os = "windows", target_os = "nto", + target_os = "espidf", )))] retries: None, } diff --git a/src/sockaddr.rs b/src/sockaddr.rs index c5047c69..2ddb2626 100644 --- a/src/sockaddr.rs +++ b/src/sockaddr.rs @@ -235,7 +235,8 @@ impl From for SockAddr { target_os = "macos", target_os = "netbsd", target_os = "openbsd", - target_os = "nto" + target_os = "nto", + target_os = "espidf", ))] sin_len: 0, }; @@ -275,7 +276,8 @@ impl From for SockAddr { target_os = "macos", target_os = "netbsd", target_os = "openbsd", - target_os = "nto" + target_os = "nto", + target_os = "espidf", ))] sin6_len: 0, #[cfg(any(target_os = "solaris", target_os = "illumos"))] diff --git a/src/socket.rs b/src/socket.rs index 69d0478d..c4f262a4 100644 --- a/src/socket.rs +++ b/src/socket.rs @@ -729,6 +729,7 @@ fn set_common_flags(socket: Socket) -> io::Result { target_os = "linux", target_os = "netbsd", target_os = "openbsd", + target_os = "espidf", )) ))] socket._set_cloexec(true)?; @@ -1042,8 +1043,11 @@ impl Socket { /// For more information about this option, see [`set_header_included`]. /// /// [`set_header_included`]: Socket::set_header_included - #[cfg(all(feature = "all", not(target_os = "redox")))] - #[cfg_attr(docsrs, doc(all(feature = "all", not(target_os = "redox"))))] + #[cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))] + #[cfg_attr( + docsrs, + doc(cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))) + )] pub fn header_included(&self) -> io::Result { unsafe { getsockopt::(self.as_raw(), sys::IPPROTO_IP, sys::IP_HDRINCL) @@ -1062,8 +1066,11 @@ impl Socket { /// [raw(7)]: https://man7.org/linux/man-pages/man7/raw.7.html /// [`IP_TTL`]: Socket::set_ttl /// [`IP_TOS`]: Socket::set_tos - #[cfg(all(feature = "all", not(target_os = "redox")))] - #[cfg_attr(docsrs, doc(all(feature = "all", not(target_os = "redox"))))] + #[cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))] + #[cfg_attr( + docsrs, + doc(cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))) + )] pub fn set_header_included(&self, included: bool) -> io::Result<()> { unsafe { setsockopt( @@ -1166,6 +1173,7 @@ impl Socket { target_os = "redox", target_os = "solaris", target_os = "nto", + target_os = "espidf", )))] pub fn join_multicast_v4_n( &self, @@ -1196,6 +1204,7 @@ impl Socket { target_os = "redox", target_os = "solaris", target_os = "nto", + target_os = "espidf", )))] pub fn leave_multicast_v4_n( &self, @@ -1228,6 +1237,7 @@ impl Socket { target_os = "redox", target_os = "fuchsia", target_os = "nto", + target_os = "espidf", )))] pub fn join_ssm_v4( &self, @@ -1263,6 +1273,7 @@ impl Socket { target_os = "redox", target_os = "fuchsia", target_os = "nto", + target_os = "espidf", )))] pub fn leave_ssm_v4( &self, @@ -1439,6 +1450,7 @@ impl Socket { target_os = "solaris", target_os = "windows", target_os = "nto", + target_os = "espidf", )))] pub fn set_recv_tos(&self, recv_tos: bool) -> io::Result<()> { let recv_tos = if recv_tos { 1 } else { 0 }; @@ -1468,6 +1480,7 @@ impl Socket { target_os = "solaris", target_os = "windows", target_os = "nto", + target_os = "espidf", )))] pub fn recv_tos(&self) -> io::Result { unsafe { diff --git a/src/sys/unix.rs b/src/sys/unix.rs index 74da8cc2..e9cfddf6 100644 --- a/src/sys/unix.rs +++ b/src/sys/unix.rs @@ -60,9 +60,9 @@ pub(crate) use libc::c_int; // Used in `Domain`. pub(crate) use libc::{AF_INET, AF_INET6}; // Used in `Type`. -#[cfg(all(feature = "all", not(target_os = "redox")))] +#[cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))] pub(crate) use libc::SOCK_RAW; -#[cfg(feature = "all")] +#[cfg(all(feature = "all", not(target_os = "espidf")))] pub(crate) use libc::SOCK_SEQPACKET; pub(crate) use libc::{SOCK_DGRAM, SOCK_STREAM}; // Used in `Protocol`. @@ -72,8 +72,10 @@ pub(crate) use libc::{ sa_family_t, sockaddr, sockaddr_in, sockaddr_in6, sockaddr_storage, socklen_t, }; // Used in `RecvFlags`. +#[cfg(not(any(target_os = "redox", target_os = "espidf")))] +pub(crate) use libc::MSG_TRUNC; #[cfg(not(target_os = "redox"))] -pub(crate) use libc::{MSG_TRUNC, SO_OOBINLINE}; +pub(crate) use libc::SO_OOBINLINE; // Used in `Socket`. #[cfg(not(target_os = "nto"))] pub(crate) use libc::ipv6_mreq as Ipv6Mreq; @@ -89,6 +91,7 @@ pub(crate) use libc::IP_HDRINCL; target_os = "solaris", target_os = "haiku", target_os = "nto", + target_os = "espidf", )))] pub(crate) use libc::IP_RECVTOS; #[cfg(not(any( @@ -117,6 +120,7 @@ pub(crate) use libc::{ target_os = "redox", target_os = "fuchsia", target_os = "nto", + target_os = "espidf", )))] pub(crate) use libc::{ ip_mreq_source as IpMreqSource, IP_ADD_SOURCE_MEMBERSHIP, IP_DROP_SOURCE_MEMBERSHIP, @@ -232,6 +236,7 @@ type IovLen = usize; target_os = "solaris", target_os = "nto", target_vendor = "apple", + target_os = "espidf", ))] type IovLen = c_int; @@ -370,10 +375,11 @@ impl_debug!( Type, libc::SOCK_STREAM, libc::SOCK_DGRAM, - #[cfg(not(target_os = "redox"))] + #[cfg(not(any(target_os = "redox", target_os = "espidf")))] libc::SOCK_RAW, - #[cfg(not(any(target_os = "redox", target_os = "haiku")))] + #[cfg(not(any(target_os = "redox", target_os = "haiku", target_os = "espidf")))] libc::SOCK_RDM, + #[cfg(not(target_os = "espidf"))] libc::SOCK_SEQPACKET, /* TODO: add these optional bit OR-ed flags: #[cfg(any( @@ -417,6 +423,7 @@ impl RecvFlags { /// a record is terminated by sending a message with the end-of-record flag set. /// /// On Unix this corresponds to the MSG_EOR flag. + #[cfg(not(target_os = "espidf"))] pub const fn is_end_of_record(self) -> bool { self.0 & libc::MSG_EOR != 0 } @@ -435,11 +442,13 @@ impl RecvFlags { #[cfg(not(target_os = "redox"))] impl std::fmt::Debug for RecvFlags { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("RecvFlags") - .field("is_end_of_record", &self.is_end_of_record()) - .field("is_out_of_band", &self.is_out_of_band()) - .field("is_truncated", &self.is_truncated()) - .finish() + let mut s = f.debug_struct("RecvFlags"); + #[cfg(not(target_os = "espidf"))] + s.field("is_end_of_record", &self.is_end_of_record()); + s.field("is_out_of_band", &self.is_out_of_band()); + #[cfg(not(target_os = "espidf"))] + s.field("is_truncated", &self.is_truncated()); + s.finish() } } @@ -1056,6 +1065,7 @@ pub(crate) fn from_in6_addr(addr: in6_addr) -> Ipv6Addr { target_os = "redox", target_os = "solaris", target_os = "nto", + target_os = "espidf", )))] pub(crate) fn to_mreqn( multiaddr: &Ipv4Addr,