net: socket: syscall for socketpair(2)
Working: * non-blocking reads / writes * blocking reads / writes * send(2) / recv(2) / sendto(2) / recvfrom(2) / sendmsg(2) * select(2) * poll(2) Fixes #24366 Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
This commit is contained in:
parent
effac5b021
commit
09f957c47a
|
@ -457,6 +457,7 @@
|
|||
/subsys/net/lib/config/ @jukkar @tbursztyka @pfalcon
|
||||
/subsys/net/lib/mqtt/ @jukkar @tbursztyka @rlubos
|
||||
/subsys/net/lib/coap/ @rveerama1
|
||||
/subsys/net/lib/sockets/socketpair.c @cfriedt
|
||||
/subsys/net/lib/sockets/ @jukkar @tbursztyka @pfalcon
|
||||
/subsys/net/lib/tls_credentials/ @rlubos
|
||||
/subsys/net/l2/ @jukkar @tbursztyka
|
||||
|
|
|
@ -45,6 +45,8 @@ extern "C" {
|
|||
#define PF_PACKET 3 /**< Packet family. */
|
||||
#define PF_CAN 4 /**< Controller Area Network. */
|
||||
#define PF_NET_MGMT 5 /**< Network management info. */
|
||||
#define PF_LOCAL 6 /**< Inter-process communication */
|
||||
#define PF_UNIX PF_LOCAL /**< Inter-process communication */
|
||||
|
||||
/* Address families. */
|
||||
#define AF_UNSPEC PF_UNSPEC /**< Unspecified address family. */
|
||||
|
@ -53,6 +55,8 @@ extern "C" {
|
|||
#define AF_PACKET PF_PACKET /**< Packet family. */
|
||||
#define AF_CAN PF_CAN /**< Controller Area Network. */
|
||||
#define AF_NET_MGMT PF_NET_MGMT /**< Network management info. */
|
||||
#define AF_LOCAL PF_LOCAL /**< Inter-process communication */
|
||||
#define AF_UNIX PF_UNIX /**< Inter-process communication */
|
||||
|
||||
/** Protocol numbers from IANA/BSD */
|
||||
enum net_ip_protocol {
|
||||
|
@ -341,6 +345,12 @@ struct sockaddr_storage {
|
|||
char data[NET_SOCKADDR_MAX_SIZE - sizeof(sa_family_t)];
|
||||
};
|
||||
|
||||
/* Socket address struct for UNIX domain sockets */
|
||||
struct sockaddr_un {
|
||||
sa_family_t sun_family; /* AF_UNIX */
|
||||
char sun_path[NET_SOCKADDR_MAX_SIZE - sizeof(sa_family_t)];
|
||||
};
|
||||
|
||||
struct net_addr {
|
||||
sa_family_t family;
|
||||
union {
|
||||
|
|
|
@ -159,6 +159,20 @@ struct zsock_addrinfo {
|
|||
*/
|
||||
__syscall int zsock_socket(int family, int type, int proto);
|
||||
|
||||
/**
|
||||
* @brief Create an unnamed pair of connected sockets
|
||||
*
|
||||
* @details
|
||||
* @rst
|
||||
* See `POSIX.1-2017 article
|
||||
* <https://pubs.opengroup.org/onlinepubs/009695399/functions/socketpair.html>`__
|
||||
* for normative description.
|
||||
* This function is also exposed as ``socketpair()``
|
||||
* if :option:`CONFIG_NET_SOCKETS_POSIX_NAMES` is defined.
|
||||
* @endrst
|
||||
*/
|
||||
__syscall int zsock_socketpair(int family, int type, int proto, int *sv);
|
||||
|
||||
/**
|
||||
* @brief Close a network socket
|
||||
*
|
||||
|
@ -566,6 +580,11 @@ static inline int socket(int family, int type, int proto)
|
|||
return zsock_socket(family, type, proto);
|
||||
}
|
||||
|
||||
static inline int socketpair(int family, int type, int proto, int sv[2])
|
||||
{
|
||||
return zsock_socketpair(family, type, proto, sv);
|
||||
}
|
||||
|
||||
static inline int close(int sock)
|
||||
{
|
||||
return zsock_close(sock);
|
||||
|
|
|
@ -18,6 +18,11 @@ static inline int socket(int family, int type, int proto)
|
|||
return zsock_socket(family, type, proto);
|
||||
}
|
||||
|
||||
static inline int socketpair(int family, int type, int proto, int sv[2])
|
||||
{
|
||||
return zsock_socketpair(family, type, proto, sv);
|
||||
}
|
||||
|
||||
#define SHUT_RD ZSOCK_SHUT_RD
|
||||
#define SHUT_WR ZSOCK_SHUT_WR
|
||||
#define SHUT_RDWR ZSOCK_SHUT_RDWR
|
||||
|
|
|
@ -28,4 +28,6 @@ if(CONFIG_SOCKS)
|
|||
zephyr_include_directories(${ZEPHYR_BASE}/subsys/net/lib/socks)
|
||||
endif()
|
||||
|
||||
zephyr_sources_ifdef(CONFIG_NET_SOCKETPAIR socketpair.c)
|
||||
|
||||
zephyr_link_libraries_ifdef(CONFIG_MBEDTLS mbedTLS)
|
||||
|
|
|
@ -139,6 +139,21 @@ config NET_SOCKETS_CAN_RECEIVERS
|
|||
The value tells how many sockets can receive data from same
|
||||
Socket-CAN interface.
|
||||
|
||||
config NET_SOCKETPAIR
|
||||
bool "Support for the socketpair syscall [EXPERIMENTAL]"
|
||||
depends on HEAP_MEM_POOL_SIZE != 0
|
||||
help
|
||||
Choose y here if you would like to use the socketpair(2)
|
||||
system call.
|
||||
|
||||
config NET_SOCKETPAIR_BUFFER_SIZE
|
||||
int "Size of the intermediate buffer, in bytes"
|
||||
default 64
|
||||
range 1 4096
|
||||
depends on NET_SOCKETPAIR
|
||||
help
|
||||
Buffer size for socketpair(2)
|
||||
|
||||
config NET_SOCKETS_NET_MGMT
|
||||
bool "Enable network management socket support [EXPERIMENTAL]"
|
||||
depends on NET_MGMT_EVENT
|
||||
|
|
1122
subsys/net/lib/sockets/socketpair.c
Normal file
1122
subsys/net/lib/sockets/socketpair.c
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue