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

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
else ifeq ($(CONFIG_NET_IPv6),y)
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
ifeq ($(CONFIG_NET_IPv4),y)

View File

@ -519,7 +519,7 @@ int inet_connect(FAR struct socket *psock, FAR const struct sockaddr *addr,
switch (psock->s_type)
{
#ifdef CONFIG_NET_TCP
#if defined(CONFIG_NET_TCP) && defined(NET_TCP_HAVE_STACK)
case SOCK_STREAM:
{
/* 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 */
#ifdef CONFIG_NET_UDP
#if defined(CONFIG_NET_UDP) && defined(NET_UDP_HAVE_STACK)
case SOCK_DGRAM:
{
int ret = udp_connect(psock->s_conn, addr);

View File

@ -53,7 +53,7 @@
#include "usrsock/usrsock.h"
#include "socket/socket.h"
#if defined(CONFIG_NET_IPv4) || defined(CONFIG_NET_IPv6)
#ifdef HAVE_INET_SOCKETS
/****************************************************************************
* 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)
{
#ifdef CONFIG_NET_USRSOCK
int ret;
/* 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 = -ENETDOWN)
if (ret == -ENETDOWN)
{
/* -ENETDOWN means that usrsock daemon is not running. Attempt to
* open socket with kernel networking stack.
*/
warn("WARNING: usrsock daemon is not running\n");
nwarn("WARNING: usrsock daemon is not running\n");
}
else
{
@ -311,8 +313,8 @@ static int inet_setup(FAR struct socket *psock, int protocol)
return inet_tcp_alloc(psock);
#else
warning("WARNING: SOCK_STREAM disabled\n");
return = -ENETDOWN;
nwarn("WARNING: SOCK_STREAM disabled\n");
return -ENETDOWN;
#endif
#endif /* CONFIG_NET_TCP */
@ -329,7 +331,7 @@ static int inet_setup(FAR struct socket *psock, int protocol)
return inet_udp_alloc(psock);
#else
warning("WARNING: SOCK_DGRAM disabled\n");
nwarn("WARNING: SOCK_DGRAM disabled\n");
return -ENETDOWN;
#endif
#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)
nsent = psock_udp_sendto(psock, buf, len, flags, to, tolen);
#else
nwarn("WARNING: UDP not available in this configuiration\n")
nwarn("WARNING: UDP not available in this configuiration\n");
nsent = -ENOSYS;
#endif /* CONFIG_NET_6LOWPAN */
#else
nwarn("WARNING: UDP not enabled in this configuiration\n")
nwarn("WARNING: UDP not enabled in this configuiration\n");
nsent = -EISCONN;
#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 */

View File

@ -49,8 +49,6 @@
#include "pkt/pkt.h"
#include "socket/socket.h"
#ifdef CONFIG_NET
/****************************************************************************
* Public Functions
****************************************************************************/
@ -78,11 +76,11 @@ FAR const struct sock_intf_s *net_sockif(sa_family_t family)
switch (family)
{
#if defined(CONFIG_NET_IPv4) || defined(CONFIG_NET_IPv6)
#ifdef CONFIG_NET_IPv4
#ifdef HAVE_INET_SOCKETS
#ifdef HAVE_PFINET_SOCKETS
case PF_INET:
#endif
#ifdef CONFIG_NET_IPv6
#ifdef HAVE_PFINET6_SOCKETS
case PF_INET6:
#endif
sockif = &g_inet_sockif;
@ -107,5 +105,3 @@ FAR const struct sock_intf_s *net_sockif(sa_family_t family)
return sockif;
}
#endif /* CONFIG_NET */

View File

@ -54,6 +54,25 @@
* 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 */
/* Bits 0-2: Socket state */
@ -148,7 +167,7 @@ extern "C"
#define EXTERN extern
#endif
#if defined(CONFIG_NET_IPv4) || defined(CONFIG_NET_IPv6)
#ifdef HAVE_INET_SOCKETS
EXTERN const struct sock_intf_s g_inet_sockif;
#endif