From 6f06deff40270da21ef7c9e020c4bc2300a243c9 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Fri, 19 Aug 2016 16:17:35 +0200 Subject: [PATCH] fixup! sock: Introduction of new application layer API --- sys/include/net/sock/ip.h | 23 +++++++---------------- sys/include/net/sock/tcp.h | 24 ++++++++---------------- sys/include/net/sock/udp.h | 23 +++++++---------------- 3 files changed, 22 insertions(+), 48 deletions(-) diff --git a/sys/include/net/sock/ip.h b/sys/include/net/sock/ip.h index 5a0656f07b..46eb6912aa 100644 --- a/sys/include/net/sock/ip.h +++ b/sys/include/net/sock/ip.h @@ -31,6 +31,7 @@ #include #include #include +#include #include "net/sock/addr.h" @@ -59,7 +60,7 @@ typedef struct { /** * @brief Implementation-specific type of a raw IPv4/IPv6 sock object * - * `struct sock_ip` needs to be defined by stack-specific a implementation. + * `struct sock_ip` needs to be defined by stack-specific `sock_types.h`. */ typedef struct sock_ip sock_ip_t; @@ -172,8 +173,8 @@ int sock_ip_get_remote(sock_ip_t *sock, sock_ip_ep_t *ep); * the remote of @p sock. * @return -ETIMEDOUT, if @p timeout expired. */ -int sock_ip_recv(sock_ip_t *sock, void *data, size_t max_len, - uint32_t timeout, sock_ip_ep_t *remote); +ssize_t sock_ip_recv(sock_ip_t *sock, void *data, size_t max_len, + uint32_t timeout, sock_ip_ep_t *remote); /** * @brief Sends a message over IPv4/IPv6 to remote end point @@ -199,20 +200,10 @@ int sock_ip_recv(sock_ip_t *sock, void *data, size_t max_len, * @return -ENOMEM, if no memory was available to send @p data. * @return -ENOTCONN, if `remote == NULL`, but @p sock has no remote end point. */ -int sock_ip_send(sock_ip_t *sock, const void *data, size_t len, - const sock_ip_ep_t *remote); +ssize_t sock_ip_send(sock_ip_t *sock, const void *data, size_t len, + const sock_ip_ep_t *remote); -#ifdef MODULE_EMB6_SOCK_IP -#include "emb6/sock.h" -#endif - -#ifdef MODULE_GNRC_SOCK_IP -#include "net/gnrc/sock.h" -#endif - -#ifdef MODULE_LWIP_SOCK_IP -#include "lwip/sock.h" -#endif +#include "sock_types.h" #ifdef __cplusplus } diff --git a/sys/include/net/sock/tcp.h b/sys/include/net/sock/tcp.h index f1a41d28a3..3339ae1a4b 100644 --- a/sys/include/net/sock/tcp.h +++ b/sys/include/net/sock/tcp.h @@ -30,6 +30,7 @@ #include #include +#include #include "net/sock/addr.h" @@ -59,14 +60,15 @@ typedef struct { /** * @brief Implementation-specific type of a TCP sock object * - * `struct sock_tcp` needs to be defined by stack-specific implementation. + * `struct sock_tcp` needs to be defined by stack-specific `sock_types.h`. */ typedef struct sock_tcp sock_tcp_t; /** * @brief Implementation-specific type of a TCP listening queue * - * `struct sock_tcp_queue` needs to be defined by stack-specific implementation. + * `struct sock_tcp_queue` needs to be defined by stack-specific + * `sock_types.h`. */ typedef struct sock_tcp_queue sock_tcp_queue_t; @@ -213,8 +215,8 @@ int sock_tcp_accept(sock_tcp_queue_t *queue, sock_tcp_t **sock); * @return -ENOTCONN, when @p sock is not connected to a remote end point. * @return -ETIMEDOUT, if @p timeout expired. */ -int sock_tcp_read(sock_tcp_t *sock, void *data, size_t max_len, - uint32_t timeout); +ssize_t sock_tcp_read(sock_tcp_t *sock, void *data, size_t max_len, + uint32_t timeout); /** * @brief Writes data to an established TCP stream @@ -232,19 +234,9 @@ int sock_tcp_read(sock_tcp_t *sock, void *data, size_t max_len, * @return -ENOMEM, if no memory was available to written @p data. * @return -ENOTCONN, if @p sock is not connected to a remote end point. */ -int sock_tcp_write(sock_tcp_t *sock, const void *data, size_t len); +ssize_t sock_tcp_write(sock_tcp_t *sock, const void *data, size_t len); -#ifdef MODULE_EMP6_SOCK_TCP -#include "emb6/sock.h" -#endif - -#ifdef MODULE_GNRC_SOCK_TCP -#include "net/gnrc/sock.h" -#endif - -#ifdef MODULE_LWIP_SOCK_TCP -#include "lwip/sock.h" -#endif +#include "sock_types.h" #ifdef __cplusplus } diff --git a/sys/include/net/sock/udp.h b/sys/include/net/sock/udp.h index 924d63bd8b..fe40c51724 100644 --- a/sys/include/net/sock/udp.h +++ b/sys/include/net/sock/udp.h @@ -31,6 +31,7 @@ #include #include #include +#include #include "net/sock/addr.h" @@ -60,7 +61,7 @@ typedef struct { /** * @brief Implementation-specific type of a UDP sock object * - * `struct sock_udp` needs to be defined by stack-specific implementation. + * `struct sock_udp` needs to be defined by stack-specific `sock_types.h`. */ typedef struct sock_udp sock_udp_t; @@ -172,8 +173,8 @@ int sock_udp_get_remote(sock_udp_t *sock, sock_udp_ep_t *ep); * the remote of @p sock. * @return -ETIMEDOUT, if @p timeout expired. */ -int sock_udp_recv(sock_udp_t *sock, void *data, size_t max_len, - uint32_t timeout, sock_udp_ep_t *remote); +ssize_t sock_udp_recv(sock_udp_t *sock, void *data, size_t max_len, + uint32_t timeout, sock_udp_ep_t *remote); /** * @brief Sends a UDP message to remote end point @@ -205,20 +206,10 @@ int sock_udp_recv(sock_udp_t *sock, void *data, size_t max_len, * @return -ENOMEM, if no memory was available to send @p data. * @return -ENOTCONN, if `remote == NULL`, but @p sock has no remote end point. */ -int sock_udp_send(sock_udp_t *sock, const void *data, size_t len, - const sock_udp_ep_t *remote); +ssize_t sock_udp_send(sock_udp_t *sock, const void *data, size_t len, + const sock_udp_ep_t *remote); -#ifdef MODULE_EMB6_SOCK_UDP -#include "emb6/sock.h" -#endif - -#ifdef MODULE_GNRC_SOCK_UDP -#include "net/gnrc/sock.h" -#endif - -#ifdef MODULE_LWIP_SOCK_UDP -#include "lwip/sock.h" -#endif +#include "sock_types.h" #ifdef __cplusplus }