-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for the ESP-IDF framework #452
Changes from 3 commits
71fbf6b
d55d2f4
10a88c0
a607e6b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,9 +81,9 @@ pub(crate) use libc::{AF_INET, AF_INET6, AF_UNIX}; | |
// Used in `Type`. | ||
#[cfg(all(feature = "all", target_os = "linux"))] | ||
pub(crate) use libc::SOCK_DCCP; | ||
#[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`. | ||
|
@@ -111,8 +111,13 @@ 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; | ||
// TODO: Expose in libc for ESP-IDF/LwIP | ||
#[cfg(target_os = "espidf")] | ||
pub(crate) const MSG_TRUNC: libc::c_int = 4; | ||
// Used in `Socket`. | ||
#[cfg(not(target_os = "nto"))] | ||
pub(crate) use libc::ipv6_mreq as Ipv6Mreq; | ||
|
@@ -125,6 +130,7 @@ pub(crate) use libc::ipv6_mreq as Ipv6Mreq; | |
target_os = "redox", | ||
target_os = "solaris", | ||
target_os = "haiku", | ||
target_os = "espidf", | ||
)))] | ||
pub(crate) use libc::IPV6_RECVTCLASS; | ||
#[cfg(all(feature = "all", not(target_os = "redox")))] | ||
|
@@ -140,6 +146,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( | ||
|
@@ -178,6 +185,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, | ||
|
@@ -329,6 +337,7 @@ type IovLen = usize; | |
target_os = "solaris", | ||
target_os = "tvos", | ||
target_os = "watchos", | ||
target_os = "espidf", | ||
))] | ||
type IovLen = c_int; | ||
|
||
|
@@ -471,10 +480,11 @@ impl_debug!( | |
libc::SOCK_DGRAM, | ||
#[cfg(all(feature = "all", target_os = "linux"))] | ||
libc::SOCK_DCCP, | ||
#[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( | ||
|
@@ -539,7 +549,14 @@ impl RecvFlags { | |
/// | ||
/// [`SEQPACKET`]: Type::SEQPACKET | ||
pub const fn is_end_of_record(self) -> bool { | ||
self.0 & libc::MSG_EOR != 0 | ||
// TODO: Expose this constant in libc for the ESP-IDF/LwIP framework | ||
#[cfg(target_os = "espidf")] | ||
const MSG_EOR: libc::c_int = 8; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't want to maintain these constants so please add them to libc instead. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we might have alternatives here, let me do a little digging and get back to you with options. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops yeah we can follow redox's example here and just conditionally remove the feature. I'll work on that soon and update. Thanks for the review! |
||
|
||
#[cfg(not(target_os = "espidf"))] | ||
use libc::MSG_EOR; | ||
|
||
self.0 & MSG_EOR != 0 | ||
} | ||
|
||
/// Check if the message contains out-of-band data. | ||
|
@@ -1264,6 +1281,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) const fn to_mreqn( | ||
multiaddr: &Ipv4Addr, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to maintain these constants so please add them to libc instead.