1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

fixup! sock: Introduction of new application layer API

This commit is contained in:
Martine Lenders 2016-08-19 16:17:35 +02:00
parent 44af8765af
commit 6f06deff40
3 changed files with 22 additions and 48 deletions

View File

@ -31,6 +31,7 @@
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/types.h>
#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
}

View File

@ -30,6 +30,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <sys/types.h>
#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
}

View File

@ -31,6 +31,7 @@
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/types.h>
#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
}