posix_sockets: port to sock
This commit is contained in:
parent
f57fba5dba
commit
1ccdc4643f
@ -372,6 +372,7 @@ ifneq (,$(filter newlib,$(USEMODULE)))
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq (,$(filter posix_sockets,$(USEMODULE)))
|
ifneq (,$(filter posix_sockets,$(USEMODULE)))
|
||||||
|
USEMODULE += bitfield
|
||||||
USEMODULE += posix
|
USEMODULE += posix
|
||||||
USEMODULE += random
|
USEMODULE += random
|
||||||
endif
|
endif
|
||||||
|
|||||||
@ -52,10 +52,6 @@ PSEUDOMODULES += printf_float
|
|||||||
PSEUDOMODULES += saul_adc
|
PSEUDOMODULES += saul_adc
|
||||||
PSEUDOMODULES += saul_default
|
PSEUDOMODULES += saul_default
|
||||||
PSEUDOMODULES += saul_gpio
|
PSEUDOMODULES += saul_gpio
|
||||||
PSEUDOMODULES += sock
|
|
||||||
PSEUDOMODULES += sock_ip
|
|
||||||
PSEUDOMODULES += sock_tcp
|
|
||||||
PSEUDOMODULES += sock_udp
|
|
||||||
PSEUDOMODULES += schedstatistics
|
PSEUDOMODULES += schedstatistics
|
||||||
PSEUDOMODULES += sock
|
PSEUDOMODULES += sock
|
||||||
PSEUDOMODULES += sock_ip
|
PSEUDOMODULES += sock_ip
|
||||||
|
|||||||
@ -19,7 +19,7 @@ USEMODULE += auto_init_gnrc_netif
|
|||||||
# Specify the mandatory networking modules for socket communication via UDP
|
# Specify the mandatory networking modules for socket communication via UDP
|
||||||
USEMODULE += gnrc_ipv6_default
|
USEMODULE += gnrc_ipv6_default
|
||||||
USEMODULE += gnrc_udp
|
USEMODULE += gnrc_udp
|
||||||
USEMODULE += gnrc_conn_udp
|
USEMODULE += gnrc_sock_udp
|
||||||
USEMODULE += posix_sockets
|
USEMODULE += posix_sockets
|
||||||
# Add also the shell, some shell commands
|
# Add also the shell, some shell commands
|
||||||
USEMODULE += shell
|
USEMODULE += shell
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
ifneq (,$(filter libcoap,$(USEPKG)))
|
ifneq (,$(filter libcoap,$(USEPKG)))
|
||||||
USEMODULE += posix_sockets
|
USEMODULE += posix_sockets
|
||||||
USEMODULE += gnrc_conn_udp
|
USEMODULE += gnrc_sock_udp
|
||||||
endif
|
endif
|
||||||
|
|||||||
@ -50,6 +50,29 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#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.
|
* @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);
|
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.
|
* @brief Receive a message from a socket.
|
||||||
* @details The recvfrom() function shall receive a message from a
|
* @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);
|
socklen_t *__restrict address_len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Send a message on a socket.
|
* @brief Receive a message from a connected socket.
|
||||||
* @details Shall initiate transmission of a message from the specified socket
|
* @details Shall receive a message from a connection-mode or
|
||||||
* to its peer. The send() function shall send a message only when the
|
* connectionless-mode socket. It is normally used with connected
|
||||||
* socket is connected. If the socket is a connectionless-mode socket,
|
* sockets because it does not permit the application to retrieve the
|
||||||
* the message shall be sent to the pre-specified peer address.
|
* source address of received data.
|
||||||
*
|
*
|
||||||
* @see <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/send.html">
|
* @see <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/recv.html">
|
||||||
* The Open Group Base Specification Issue 7, send
|
* The Open Group Base Specification Issue 7, recv
|
||||||
* </a>
|
* </a>
|
||||||
*
|
*
|
||||||
* @param[in] socket Specifies the socket file descriptor.
|
* @param[in] socket Specifies the socket file descriptor.
|
||||||
* @param[in] buffer Points to the buffer containing the message to send.
|
* @param[out] buffer Points to a buffer where the message should be stored.
|
||||||
* @param[in] length Specifies the length of the message in bytes.
|
* @param[in] length Specifies the length in bytes of the buffer pointed to
|
||||||
* @param[in] flags Specifies the type of message reception. Support
|
* by the buffer argument.
|
||||||
* for values other than 0 is not implemented yet.
|
* @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
|
* @return Upon successful completion, recv() shall return the length of the
|
||||||
* sent. Otherwise, -1 shall be returned and errno set to indicate the
|
* message in bytes. If no messages are available to be received and
|
||||||
* error.
|
* 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.
|
* @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,
|
ssize_t sendto(int socket, const void *buffer, size_t length, int flags,
|
||||||
const struct sockaddr *address, socklen_t address_len);
|
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.
|
* @brief Create an endpoint for communication.
|
||||||
* @details Shall create an unbound socket in a communications domain, and
|
* @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
|
nucleo32-f042
|
||||||
|
|
||||||
USEMODULE += gnrc_ipv6
|
USEMODULE += gnrc_ipv6
|
||||||
USEMODULE += gnrc_conn_udp
|
USEMODULE += gnrc_sock_udp
|
||||||
USEMODULE += nhdp
|
USEMODULE += nhdp
|
||||||
|
|
||||||
include $(RIOTBASE)/Makefile.include
|
include $(RIOTBASE)/Makefile.include
|
||||||
|
|||||||
@ -9,7 +9,7 @@ BOARD_INSUFFICIENT_MEMORY := chronos msb-430 msb-430h nucleo-f334 nucleo-f030 \
|
|||||||
nucleo-f070 nucleo32-f042
|
nucleo-f070 nucleo32-f042
|
||||||
|
|
||||||
USEMODULE += gnrc_ipv6
|
USEMODULE += gnrc_ipv6
|
||||||
USEMODULE += gnrc_conn_udp
|
USEMODULE += gnrc_sock_udp
|
||||||
USEPKG += libcoap
|
USEPKG += libcoap
|
||||||
|
|
||||||
include $(RIOTBASE)/Makefile.include
|
include $(RIOTBASE)/Makefile.include
|
||||||
|
|||||||
@ -4,7 +4,7 @@ include ../Makefile.tests_common
|
|||||||
BOARD_WHITELIST := native
|
BOARD_WHITELIST := native
|
||||||
|
|
||||||
USEMODULE += gnrc_ipv6
|
USEMODULE += gnrc_ipv6
|
||||||
USEMODULE += gnrc_conn_udp
|
USEMODULE += gnrc_sock_udp
|
||||||
USEMODULE += oonf_common
|
USEMODULE += oonf_common
|
||||||
USEMODULE += oonf_rfc5444
|
USEMODULE += oonf_rfc5444
|
||||||
USEPKG += oonf_api
|
USEPKG += oonf_api
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user