Socket I/F: More fixes for USRSOCK. The good link fooled me because a critical file was not included in the link.

This commit is contained in:
Gregory Nutt
2017-07-14 15:24:18 -06:00
parent ef796b2d9e
commit 24dd6d2905
5 changed files with 39 additions and 20 deletions
+2
View File
@@ -47,6 +47,8 @@ ifeq ($(CONFIG_NET_IPv4),y)
SOCK_CSRCS += inet_sockif.c inet_recvfrom.c inet_connect.c inet_close.c SOCK_CSRCS += inet_sockif.c inet_recvfrom.c inet_connect.c inet_close.c
else ifeq ($(CONFIG_NET_IPv6),y) else ifeq ($(CONFIG_NET_IPv6),y)
SOCK_CSRCS += inet_sockif.c inet_recvfrom.c inet_connect.c inet_close.c SOCK_CSRCS += inet_sockif.c inet_recvfrom.c inet_connect.c inet_close.c
else ifeq ($(CONFIG_NET_USRSOCK),y)
SOCK_CSRCS += inet_sockif.c inet_recvfrom.c inet_connect.c inet_close.c
endif endif
ifeq ($(CONFIG_NET_IPv4),y) ifeq ($(CONFIG_NET_IPv4),y)
+2 -2
View File
@@ -519,7 +519,7 @@ int inet_connect(FAR struct socket *psock, FAR const struct sockaddr *addr,
switch (psock->s_type) switch (psock->s_type)
{ {
#ifdef CONFIG_NET_TCP #if defined(CONFIG_NET_TCP) && defined(NET_TCP_HAVE_STACK)
case SOCK_STREAM: case SOCK_STREAM:
{ {
/* Verify that the socket is not already connected */ /* Verify that the socket is not already connected */
@@ -535,7 +535,7 @@ int inet_connect(FAR struct socket *psock, FAR const struct sockaddr *addr,
} }
#endif /* CONFIG_NET_TCP */ #endif /* CONFIG_NET_TCP */
#ifdef CONFIG_NET_UDP #if defined(CONFIG_NET_UDP) && defined(NET_UDP_HAVE_STACK)
case SOCK_DGRAM: case SOCK_DGRAM:
{ {
int ret = udp_connect(psock->s_conn, addr); int ret = udp_connect(psock->s_conn, addr);
+12 -10
View File
@@ -53,7 +53,7 @@
#include "usrsock/usrsock.h" #include "usrsock/usrsock.h"
#include "socket/socket.h" #include "socket/socket.h"
#if defined(CONFIG_NET_IPv4) || defined(CONFIG_NET_IPv6) #ifdef HAVE_INET_SOCKETS
/**************************************************************************** /****************************************************************************
* Private Function Prototypes * Private Function Prototypes
@@ -269,18 +269,20 @@ static int usrsock_socket_setup(int domain, int type, int protocol,
static int inet_setup(FAR struct socket *psock, int protocol) static int inet_setup(FAR struct socket *psock, int protocol)
{ {
#ifdef CONFIG_NET_USRSOCK #ifdef CONFIG_NET_USRSOCK
int ret;
/* Handle special setup for user INET sockets */ /* Handle special setup for user INET sockets */
ret = usrsock_socket_setup(domain, type, protocol, psock); ret = usrsock_socket_setup(psock->s_domain, psock->s_type, protocol, psock);
if (ret < 0) if (ret < 0)
{ {
if (ret = -ENETDOWN) if (ret == -ENETDOWN)
{ {
/* -ENETDOWN means that usrsock daemon is not running. Attempt to /* -ENETDOWN means that usrsock daemon is not running. Attempt to
* open socket with kernel networking stack. * open socket with kernel networking stack.
*/ */
warn("WARNING: usrsock daemon is not running\n"); nwarn("WARNING: usrsock daemon is not running\n");
} }
else else
{ {
@@ -311,8 +313,8 @@ static int inet_setup(FAR struct socket *psock, int protocol)
return inet_tcp_alloc(psock); return inet_tcp_alloc(psock);
#else #else
warning("WARNING: SOCK_STREAM disabled\n"); nwarn("WARNING: SOCK_STREAM disabled\n");
return = -ENETDOWN; return -ENETDOWN;
#endif #endif
#endif /* CONFIG_NET_TCP */ #endif /* CONFIG_NET_TCP */
@@ -329,7 +331,7 @@ static int inet_setup(FAR struct socket *psock, int protocol)
return inet_udp_alloc(psock); return inet_udp_alloc(psock);
#else #else
warning("WARNING: SOCK_DGRAM disabled\n"); nwarn("WARNING: SOCK_DGRAM disabled\n");
return -ENETDOWN; return -ENETDOWN;
#endif #endif
#endif /* CONFIG_NET_UDP */ #endif /* CONFIG_NET_UDP */
@@ -1209,11 +1211,11 @@ static ssize_t inet_sendto(FAR struct socket *psock, FAR const void *buf,
#elif defined(NET_UDP_HAVE_STACK) #elif defined(NET_UDP_HAVE_STACK)
nsent = psock_udp_sendto(psock, buf, len, flags, to, tolen); nsent = psock_udp_sendto(psock, buf, len, flags, to, tolen);
#else #else
nwarn("WARNING: UDP not available in this configuiration\n") nwarn("WARNING: UDP not available in this configuiration\n");
nsent = -ENOSYS; nsent = -ENOSYS;
#endif /* CONFIG_NET_6LOWPAN */ #endif /* CONFIG_NET_6LOWPAN */
#else #else
nwarn("WARNING: UDP not enabled in this configuiration\n") nwarn("WARNING: UDP not enabled in this configuiration\n");
nsent = -EISCONN; nsent = -EISCONN;
#endif /* CONFIG_NET_UDP */ #endif /* CONFIG_NET_UDP */
} }
@@ -1238,4 +1240,4 @@ static ssize_t inet_sendto(FAR struct socket *psock, FAR const void *buf,
* *
****************************************************************************/ ****************************************************************************/
#endif /* CONFIG_NET_IPv4 || CONFIG_NET_IPv6 */ #endif /* HAVE_INET_SOCKETS */
+3 -7
View File
@@ -49,8 +49,6 @@
#include "pkt/pkt.h" #include "pkt/pkt.h"
#include "socket/socket.h" #include "socket/socket.h"
#ifdef CONFIG_NET
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@@ -78,11 +76,11 @@ FAR const struct sock_intf_s *net_sockif(sa_family_t family)
switch (family) switch (family)
{ {
#if defined(CONFIG_NET_IPv4) || defined(CONFIG_NET_IPv6) #ifdef HAVE_INET_SOCKETS
#ifdef CONFIG_NET_IPv4 #ifdef HAVE_PFINET_SOCKETS
case PF_INET: case PF_INET:
#endif #endif
#ifdef CONFIG_NET_IPv6 #ifdef HAVE_PFINET6_SOCKETS
case PF_INET6: case PF_INET6:
#endif #endif
sockif = &g_inet_sockif; sockif = &g_inet_sockif;
@@ -107,5 +105,3 @@ FAR const struct sock_intf_s *net_sockif(sa_family_t family)
return sockif; return sockif;
} }
#endif /* CONFIG_NET */
+20 -1
View File
@@ -54,6 +54,25 @@
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
/* Configuration */
#undef HAVE_INET_SOCKETS
#undef HAVE_PFINET_SOCKETS
#undef HAVE_PFINET6_SOCKETS
#if defined(CONFIG_NET_IPv4) || defined(CONFIG_NET_IPv6) || \
defined(CONFIG_NET_USRSOCK)
# define HAVE_INET_SOCKETS
# if defined(CONFIG_NET_IPv4) || defined(CONFIG_NET_USRSOCK)
# define HAVE_PFINET_SOCKETS
# endif
# if defined(CONFIG_NET_IPv6) || defined(CONFIG_NET_USRSOCK)
# define HAVE_PFINET6_SOCKETS
# endif
#endif
/* Definitions of 8-bit socket flags */ /* Definitions of 8-bit socket flags */
/* Bits 0-2: Socket state */ /* Bits 0-2: Socket state */
@@ -148,7 +167,7 @@ extern "C"
#define EXTERN extern #define EXTERN extern
#endif #endif
#if defined(CONFIG_NET_IPv4) || defined(CONFIG_NET_IPv6) #ifdef HAVE_INET_SOCKETS
EXTERN const struct sock_intf_s g_inet_sockif; EXTERN const struct sock_intf_s g_inet_sockif;
#endif #endif