mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
arch/sim: Add AF_LOCAL support to host usrsock
The sim host usrsock backend only accepted INET/NETLINK domains and
translated socket addresses through plain struct sockaddr. That prevents
simulated applications from using POSIX AF_LOCAL sockets through the
standard socket API when CONFIG_NET_USRSOCK is used.
Add AF_LOCAL address conversion for struct sockaddr_un, allow PF_LOCAL
sockets through usrsock, handle NuttX socket type flags, and poll host
descriptors from the sim usrsock work item so nonblocking
connect/read/write readiness is reported back to NuttX. Use
sockaddr_storage for native address translation so larger address
structures are not truncated.
Testing:
- Host: Ubuntu 22.04 x86_64.
- Board/config: sim:nsh with CONFIG_NET_USRSOCK=y and
CONFIG_EXAMPLES_HELLO=y.
- make clean && make -j16.
- Ran a temporary hello example that connected to host AF_UNIX
SOCK_STREAM and SOCK_SEQPACKET sockets through NuttX socket(),
connect(), write(), and read(). Both received pong and printed
"AF_LOCAL usrsock test passed".
Assisted-by: Claude:Claude-Fable-5
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
This commit is contained in:
parent
e84259cbcc
commit
3d20844903
4 changed files with 203 additions and 66 deletions
|
|
@ -103,10 +103,14 @@ static int usrsock_sockif_setup(FAR struct socket *psock)
|
|||
int ret;
|
||||
|
||||
if (psock->s_domain != PF_INET && psock->s_domain != PF_INET6 &&
|
||||
psock->s_domain != PF_NETLINK)
|
||||
psock->s_domain != PF_NETLINK
|
||||
#ifndef CONFIG_NET_LOCAL
|
||||
&& psock->s_domain != PF_LOCAL
|
||||
#endif
|
||||
)
|
||||
{
|
||||
return -ENOTSUP; /* Only ipv4, ipv6 and netlink support the offload */
|
||||
};
|
||||
return -ENOTSUP; /* Only supported families can use usrsock offload */
|
||||
}
|
||||
|
||||
/* Let the user socket logic handle the setup...
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue