diff --git a/net/socket/Make.defs b/net/socket/Make.defs index 0ce04f106d3..b8e6bdec1ad 100644 --- a/net/socket/Make.defs +++ b/net/socket/Make.defs @@ -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) diff --git a/net/socket/inet_connect.c b/net/socket/inet_connect.c index 49aa17cd75b..cc187e2874c 100644 --- a/net/socket/inet_connect.c +++ b/net/socket/inet_connect.c @@ -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); diff --git a/net/socket/inet_sockif.c b/net/socket/inet_sockif.c index b26167f0eba..3e35e2df90d 100644 --- a/net/socket/inet_sockif.c +++ b/net/socket/inet_sockif.c @@ -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 */ diff --git a/net/socket/net_sockif.c b/net/socket/net_sockif.c index 76e273ff97d..48ccd0496aa 100644 --- a/net/socket/net_sockif.c +++ b/net/socket/net_sockif.c @@ -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 */ diff --git a/net/socket/socket.h b/net/socket/socket.h index f3dd2bf7ab3..d1790007eff 100644 --- a/net/socket/socket.h +++ b/net/socket/socket.h @@ -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