From 6c1e805f9e09e0e0209a3a2687b7901b78a2878b Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Wed, 5 Oct 2016 17:14:39 +0200 Subject: [PATCH] sock: define behavior on invalid addresses --- sys/include/net/sock/ip.h | 10 +++++++--- sys/include/net/sock/tcp.h | 1 + sys/include/net/sock/udp.h | 6 ++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/sys/include/net/sock/ip.h b/sys/include/net/sock/ip.h index baf92d3caf..c1eccda946 100644 --- a/sys/include/net/sock/ip.h +++ b/sys/include/net/sock/ip.h @@ -316,9 +316,10 @@ typedef struct sock_ip sock_ip_t; * elsewhere * @return -EAFNOSUPPORT, if `local != NULL` or `remote != NULL` and * sock_ip_ep_t::family of @p local or @p remote is not supported. - * @return -EINVAL, if `proto` is not supported or if sock_ip_ep_t::netif of - * @p local or @p remote is not a valid interface or contradict each - * other (i.e. `(local->netif != remote->netif) && + * @return -EINVAL, if sock_ip_ep_t::addr of @p remote is an invalid address. + * @return -EINVAL, if sock_ip_ep_t::netif of @p local or @p remote are not + * valid interfaces or contradict each other + * (i.e. `(local->netif != remote->netif) && * ((local->netif != SOCK_ADDR_ANY_NETIF) || * (remote->netif != SOCK_ADDR_ANY_NETIF))` if neither is `NULL`). * @return -ENOMEM, if not enough resources can be provided for `sock` to be @@ -432,6 +433,9 @@ ssize_t sock_ip_recv(sock_ip_t *sock, void *data, size_t max_len, * @return The number of bytes sent on success. * @return -EAFNOSUPPORT, if `remote != NULL` and sock_ip_ep_t::family of * @p remote is != AF_UNSPEC and not supported. + * @return -EINVAL, if sock_ip_ep_t::addr of @p remote is an invalid address. + * @return -EINVAL, if sock_ip_ep_t::netif of @p remote is not a + * valid interface or contradicts the local interface of @p sock. * @return -EHOSTUNREACH, if @p remote or remote end point of @p sock is not * reachable. * @return -ENOMEM, if no memory was available to send @p data. diff --git a/sys/include/net/sock/tcp.h b/sys/include/net/sock/tcp.h index bb71568915..42eb6fe7b6 100644 --- a/sys/include/net/sock/tcp.h +++ b/sys/include/net/sock/tcp.h @@ -83,6 +83,7 @@ typedef struct sock_tcp_queue sock_tcp_queue_t; * @return -EAFNOSUPPORT, if sock_tcp_ep_t::family of @p remote is not * supported. * @return -ECONNREFUSED, if no-one is listening on the @p remote end point. + * @return -EINVAL, if sock_tcp_ep_t::addr of @p remote is an invalid address. * @return -EINVAL, if sock_tcp_ep_t::netif of @p remote is not a valid * interface. * @return -ENETUNREACH, if network defined by @p remote is not reachable. diff --git a/sys/include/net/sock/udp.h b/sys/include/net/sock/udp.h index 59dfead42a..f2f85a5e13 100644 --- a/sys/include/net/sock/udp.h +++ b/sys/include/net/sock/udp.h @@ -322,8 +322,9 @@ typedef struct sock_udp sock_udp_t; * elsewhere * @return -EAFNOSUPPORT, if `local != NULL` or `remote != NULL` and * sock_udp_ep_t::family of @p local or @p remote is not supported. - * @return -EINVAL, if sock_udp_ep_t::netif of @p local or @p remote is not a - * valid interface or contradict each other (i.e. + * @return -EINVAL, if sock_udp_ep_t::addr of @p remote is an invalid address. + * @return -EINVAL, if sock_udp_ep_t::netif of @p local or @p remote are not a + * valid interfaces or contradict each other (i.e. * `(local->netif != remote->netif) && * ((local->netif != SOCK_ADDR_ANY_NETIF) || * (remote->netif != SOCK_ADDR_ANY_NETIF))` if neither is `NULL`). @@ -420,6 +421,7 @@ ssize_t sock_udp_recv(sock_udp_t *sock, void *data, size_t max_len, * @p remote is != AF_UNSPEC and not supported. * @return -EHOSTUNREACH, if @p remote or remote end point of @p sock is not * reachable. + * @return -EINVAL, if sock_udp_ep_t::addr of @p remote is an invalid address. * @return -EINVAL, if sock_udp_ep_t::netif of @p remote is not a valid * interface or contradicts the given local interface (i.e. * neither the local end point of `sock` nor remote are assigned to