mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
posix_sockets: port to sock
This commit is contained in:
parent
f57fba5dba
commit
1ccdc4643f
@ -372,6 +372,7 @@ ifneq (,$(filter newlib,$(USEMODULE)))
|
||||
endif
|
||||
|
||||
ifneq (,$(filter posix_sockets,$(USEMODULE)))
|
||||
USEMODULE += bitfield
|
||||
USEMODULE += posix
|
||||
USEMODULE += random
|
||||
endif
|
||||
|
@ -52,10 +52,6 @@ PSEUDOMODULES += printf_float
|
||||
PSEUDOMODULES += saul_adc
|
||||
PSEUDOMODULES += saul_default
|
||||
PSEUDOMODULES += saul_gpio
|
||||
PSEUDOMODULES += sock
|
||||
PSEUDOMODULES += sock_ip
|
||||
PSEUDOMODULES += sock_tcp
|
||||
PSEUDOMODULES += sock_udp
|
||||
PSEUDOMODULES += schedstatistics
|
||||
PSEUDOMODULES += sock
|
||||
PSEUDOMODULES += sock_ip
|
||||
|
@ -19,7 +19,7 @@ USEMODULE += auto_init_gnrc_netif
|
||||
# Specify the mandatory networking modules for socket communication via UDP
|
||||
USEMODULE += gnrc_ipv6_default
|
||||
USEMODULE += gnrc_udp
|
||||
USEMODULE += gnrc_conn_udp
|
||||
USEMODULE += gnrc_sock_udp
|
||||
USEMODULE += posix_sockets
|
||||
# Add also the shell, some shell commands
|
||||
USEMODULE += shell
|
||||
|
@ -1,4 +1,4 @@
|
||||
ifneq (,$(filter libcoap,$(USEPKG)))
|
||||
USEMODULE += posix_sockets
|
||||
USEMODULE += gnrc_conn_udp
|
||||
USEMODULE += gnrc_sock_udp
|
||||
endif
|
||||
|
@ -50,6 +50,29 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Maximum number of sockets available on for creation with @ref socket()
|
||||
*/
|
||||
#ifndef SOCKET_POOL_SIZE
|
||||
#ifdef MODULE_SOCK_TCP
|
||||
#define SOCKET_POOL_SIZE (6) /* define enough for accepted sockets */
|
||||
#else
|
||||
#define SOCKET_POOL_SIZE (4)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Maximum number of incoming TCP connections a listening socket can
|
||||
* handle
|
||||
*/
|
||||
#ifndef SOCKET_TCP_QUEUE_SIZE
|
||||
#ifdef MODULE_SOCK_TCP
|
||||
#define SOCKET_TCP_QUEUE_SIZE (2)
|
||||
#else
|
||||
#define SOCKET_TCP_QUEUE_SIZE (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Maximum data length for a socket address.
|
||||
*
|
||||
@ -293,31 +316,6 @@ int getsockname(int socket, struct sockaddr *__restrict address,
|
||||
*/
|
||||
int listen(int socket, int backlog);
|
||||
|
||||
/**
|
||||
* @brief Receive a message from a connected socket.
|
||||
* @details Shall receive a message from a connection-mode or
|
||||
* connectionless-mode socket. It is normally used with connected
|
||||
* sockets because it does not permit the application to retrieve the
|
||||
* source address of received data.
|
||||
*
|
||||
* @see <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/recv.html">
|
||||
* The Open Group Base Specification Issue 7, recv
|
||||
* </a>
|
||||
*
|
||||
* @param[in] socket Specifies the socket file descriptor.
|
||||
* @param[out] buffer Points to a buffer where the message should be stored.
|
||||
* @param[in] length Specifies the length in bytes of the buffer pointed to
|
||||
* by the buffer argument.
|
||||
* @param[in] flags Specifies the type of message reception. Support for
|
||||
* values other than 0 is not implemented yet.
|
||||
*
|
||||
* @return Upon successful completion, recv() shall return the length of the
|
||||
* message in bytes. If no messages are available to be received and
|
||||
* the peer has performed an orderly shutdown, recv() shall return 0.
|
||||
* Otherwise, -1 shall be returned and errno set to indicate the error.
|
||||
*/
|
||||
ssize_t recv(int socket, void *buffer, size_t length, int flags);
|
||||
|
||||
/**
|
||||
* @brief Receive a message from a socket.
|
||||
* @details The recvfrom() function shall receive a message from a
|
||||
@ -357,27 +355,32 @@ ssize_t recvfrom(int socket, void *__restrict buffer, size_t length, int flags,
|
||||
socklen_t *__restrict address_len);
|
||||
|
||||
/**
|
||||
* @brief Send a message on a socket.
|
||||
* @details Shall initiate transmission of a message from the specified socket
|
||||
* to its peer. The send() function shall send a message only when the
|
||||
* socket is connected. If the socket is a connectionless-mode socket,
|
||||
* the message shall be sent to the pre-specified peer address.
|
||||
* @brief Receive a message from a connected socket.
|
||||
* @details Shall receive a message from a connection-mode or
|
||||
* connectionless-mode socket. It is normally used with connected
|
||||
* sockets because it does not permit the application to retrieve the
|
||||
* source address of received data.
|
||||
*
|
||||
* @see <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/send.html">
|
||||
* The Open Group Base Specification Issue 7, send
|
||||
* @see <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/recv.html">
|
||||
* The Open Group Base Specification Issue 7, recv
|
||||
* </a>
|
||||
*
|
||||
* @param[in] socket Specifies the socket file descriptor.
|
||||
* @param[in] buffer Points to the buffer containing the message to send.
|
||||
* @param[in] length Specifies the length of the message in bytes.
|
||||
* @param[in] flags Specifies the type of message reception. Support
|
||||
* for values other than 0 is not implemented yet.
|
||||
* @param[out] buffer Points to a buffer where the message should be stored.
|
||||
* @param[in] length Specifies the length in bytes of the buffer pointed to
|
||||
* by the buffer argument.
|
||||
* @param[in] flags Specifies the type of message reception. Support for
|
||||
* values other than 0 is not implemented yet.
|
||||
*
|
||||
* @return Upon successful completion, send() shall return the number of bytes
|
||||
* sent. Otherwise, -1 shall be returned and errno set to indicate the
|
||||
* error.
|
||||
* @return Upon successful completion, recv() shall return the length of the
|
||||
* message in bytes. If no messages are available to be received and
|
||||
* the peer has performed an orderly shutdown, recv() shall return 0.
|
||||
* Otherwise, -1 shall be returned and errno set to indicate the error.
|
||||
*/
|
||||
ssize_t send(int socket, const void *buffer, size_t length, int flags);
|
||||
static inline ssize_t recv(int socket, void *buffer, size_t length, int flags)
|
||||
{
|
||||
return recvfrom(socket, buffer, length, flags, NULL, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Send a message on a socket.
|
||||
@ -423,6 +426,33 @@ ssize_t send(int socket, const void *buffer, size_t length, int flags);
|
||||
ssize_t sendto(int socket, const void *buffer, size_t length, int flags,
|
||||
const struct sockaddr *address, socklen_t address_len);
|
||||
|
||||
/**
|
||||
* @brief Send a message on a socket.
|
||||
* @details Shall initiate transmission of a message from the specified socket
|
||||
* to its peer. The send() function shall send a message only when the
|
||||
* socket is connected. If the socket is a connectionless-mode socket,
|
||||
* the message shall be sent to the pre-specified peer address.
|
||||
*
|
||||
* @see <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/send.html">
|
||||
* The Open Group Base Specification Issue 7, send
|
||||
* </a>
|
||||
*
|
||||
* @param[in] socket Specifies the socket file descriptor.
|
||||
* @param[in] buffer Points to the buffer containing the message to send.
|
||||
* @param[in] length Specifies the length of the message in bytes.
|
||||
* @param[in] flags Specifies the type of message reception. Support
|
||||
* for values other than 0 is not implemented yet.
|
||||
*
|
||||
* @return Upon successful completion, send() shall return the number of bytes
|
||||
* sent. Otherwise, -1 shall be returned and errno set to indicate the
|
||||
* error.
|
||||
*/
|
||||
static inline ssize_t send(int socket, const void *buffer, size_t length,
|
||||
int flags)
|
||||
{
|
||||
return sendto(socket, buffer, length, flags, NULL, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Create an endpoint for communication.
|
||||
* @details Shall create an unbound socket in a communications domain, and
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -8,7 +8,7 @@ BOARD_INSUFFICIENT_MEMORY := nucleo-f334 stm32f0discovery weio nucleo-f030 \
|
||||
nucleo32-f042
|
||||
|
||||
USEMODULE += gnrc_ipv6
|
||||
USEMODULE += gnrc_conn_udp
|
||||
USEMODULE += gnrc_sock_udp
|
||||
USEMODULE += nhdp
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
@ -9,7 +9,7 @@ BOARD_INSUFFICIENT_MEMORY := chronos msb-430 msb-430h nucleo-f334 nucleo-f030 \
|
||||
nucleo-f070 nucleo32-f042
|
||||
|
||||
USEMODULE += gnrc_ipv6
|
||||
USEMODULE += gnrc_conn_udp
|
||||
USEMODULE += gnrc_sock_udp
|
||||
USEPKG += libcoap
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
@ -4,7 +4,7 @@ include ../Makefile.tests_common
|
||||
BOARD_WHITELIST := native
|
||||
|
||||
USEMODULE += gnrc_ipv6
|
||||
USEMODULE += gnrc_conn_udp
|
||||
USEMODULE += gnrc_sock_udp
|
||||
USEMODULE += oonf_common
|
||||
USEMODULE += oonf_rfc5444
|
||||
USEPKG += oonf_api
|
||||
|
Loading…
Reference in New Issue
Block a user