Nuttx work with tokio net features#5258
Conversation
There was a problem hiding this comment.
Could you please add permalinks to the nuttx sources in your commits messages?
Cc nuttx maintainer @no1wudi to take a look
|
Reminder, once the PR becomes ready for a review, use |
40fdd3a to
d9f7696
Compare
@tgross35 Added comments about version and repos. |
|
That's not what I meant - please update commit messages adding permalinks to the headers for each added/changed API. The PR template asks for this so maintainers don't need to dig finding the API to check against. |
fixes missing `strerror_r` for compiling errno crate. The original definition at https://github.com/apache/nuttx/blob/releases/13.0/include/string.h#L69 Signed-off-by: wanglei <wllenyj@gmail.com>
Thanks, Done |
| pub const SOCK_CLOEXEC: i32 = 0x02000000; | ||
| pub const SOCK_NONBLOCK: i32 = 0x00004000; |
There was a problem hiding this comment.
"nuttx: add socket structs, functions and constants" these are not correct, the C versions are octal. Use the 0o prefix here.
There was a problem hiding this comment.
Oh, you're right, Thanks for your thorough review, it was my oversight...
Fixed.
| /// SOL_IP protocol-level socket options. | ||
| pub const IP_MULTICAST_IF: i32 = 16 + 1; | ||
| pub const IP_MULTICAST_TTL: i32 = 16 + 2; | ||
| pub const IP_MULTICAST_LOOP: i32 = 16 + 3; | ||
| pub const IP_ADD_MEMBERSHIP: i32 = 16 + 4; | ||
| pub const IP_DROP_MEMBERSHIP: i32 = 16 + 5; | ||
| pub const IP_ADD_SOURCE_MEMBERSHIP: i32 = 16 + 8; | ||
| pub const IP_DROP_SOURCE_MEMBERSHIP: i32 = 16 + 9; | ||
| pub const IP_TOS: i32 = 16 + 13; | ||
| pub const IP_TTL: i32 = 16 + 14; | ||
| /// SOL_IPV6 protocol-level socket options. | ||
| pub const IPV6_JOIN_GROUP: i32 = 16 + 1; | ||
| pub const IPV6_LEAVE_GROUP: i32 = 16 + 2; | ||
| pub const IPV6_MULTICAST_HOPS: i32 = 16 + 3; | ||
| pub const IPV6_MULTICAST_IF: i32 = 16 + 4; | ||
| pub const IPV6_MULTICAST_LOOP: i32 = 16 + 5; | ||
| pub const IPV6_UNICAST_HOPS: i32 = 16 + 6; | ||
| pub const IPV6_V6ONLY: i32 = 16 + 7; | ||
| pub const IPV6_RECVHOPLIMIT: i32 = 16 + 11; |
There was a problem hiding this comment.
"nuttx: add netinet structs and constants": just add const __SO_PROTOCOL: i32 = 16 and use that rather than hardcoding its value.
| pub const TCP_KEEPIDLE: i32 = 0x11; | ||
| pub const TCP_KEEPINTVL: i32 = 0x12; | ||
| pub const TCP_KEEPCNT: i32 = 0x13; | ||
| pub const TCP_MAXSEG: i32 = 0x14; |
There was a problem hiding this comment.
"nuttx: add TCP_MAXSEG definitions": Ditto regarding __SO_PROTOCOL
| /// fcntl() commands | ||
| pub const FIOCLEX: i32 = 0x30b; | ||
| pub const F_SETFL: i32 = 0x9; | ||
| pub const F_DUPFD_CLOEXEC: i32 = 0x12; | ||
| pub const F_GETFD: i32 = 0x1; | ||
| pub const F_GETFL: i32 = 0x2; | ||
| pub const F_SETFD: i32 = 8; | ||
| pub const F_SETFL: i32 = 9; | ||
| /// open flag settings for open() (and related APIs) | ||
| pub const O_RDONLY: i32 = 0x1; |
There was a problem hiding this comment.
Overall comment: in a lot of places you use doc comments that seem like they should be section headers. Change them to regular comments instead, currently they're user-facing documentation for only the first item in the list.
The original definition at https://github.com/apache/nuttx/blob/releases/13.0/include/sys/socket.h Signed-off-by: wanglei <wllenyj@gmail.com>
The original definition at https://github.com/apache/nuttx/blob/releases/13.0/include/netinet/in.h Signed-off-by: wanglei <wllenyj@gmail.com>
The original definition at https://github.com/apache/nuttx/blob/releases/13.0/include/sys/eventfd.h Signed-off-by: wanglei <wllenyj@gmail.com>
The original definition at https://github.com/apache/nuttx/blob/releases/13.0/include/fcntl.h Signed-off-by: wanglei <wllenyj@gmail.com>
The original definition at https://github.com/apache/nuttx/blob/releases/13.0/include/sys/poll.h Signed-off-by: wanglei <wllenyj@gmail.com>
It's used by `mio` crate. The original definition at https://github.com/apache/nuttx/blob/releases/13.0/include/unistd.h Signed-off-by: wanglei <wllenyj@gmail.com>
It's used by `socket2` crate in `tcp_mss` and `set_tcp_mss`. The original definition at https://github.com/apache/nuttx/blob/releases/13.0/include/netinet/tcp.h#L59 Signed-off-by: wanglei <wllenyj@gmail.com>
Signed-off-by: wanglei <wllenyj@gmail.com>
Description
Currently the nuttx rust app is not compiled, when using the tokio net feature.
Therefore, added support Nuttx definitions.
Sources
Added strerror_r function for
errnocrate. Anderrnocrate 's pr lambda-fairy/rust-errno#129.Added socket interrelated structs, functions and constants.
Added netinet interrelated structs and constants.
Added eventfd definitions, and poll/fcntl/tcp/pipe2 definitions.
Other interrelated pr rust-lang/socket2#663, tokio-rs/mio#1966, tokio-rs/tokio#8259.
Checklist
libc-test/semverhave been updated*LASTor*MAXareincluded (see #3131)
cd libc-test && cargo test --target mytarget);especially relevant for platforms that may not be checked in CI