Socket interface: Fix some configuration chaos. Sometime CONFIG_NET_UDP/TCP was used when CONFIG_NET_LOCAL_DGRAM/STREAM was intended.

This commit is contained in:
Gregory Nutt 2017-07-14 12:36:54 -06:00
parent b4467a5cf5
commit c964cd4612
3 changed files with 30 additions and 28 deletions

View File

@ -38,7 +38,6 @@
****************************************************************************/
#include <nuttx/config.h>
#if defined(CONFIG_NET) && defined(CONFIG_NET_LOCAL_STREAM)
#include <string.h>
#include <unistd.h>
@ -55,6 +54,8 @@
#include "socket/socket.h"
#include "local/local.h"
#ifdef CONFIG_NET_LOCAL_STREAM
/****************************************************************************
* Private Functions
****************************************************************************/
@ -343,4 +344,4 @@ int psock_local_connect(FAR struct socket *psock,
return -EADDRNOTAVAIL;
}
#endif /* CONFIG_NET && CONFIG_NET_LOCAL_STREAM */
#endif /* CONFIG_NET_LOCAL_STREAM */

View File

@ -38,7 +38,6 @@
****************************************************************************/
#include <nuttx/config.h>
#if defined(CONFIG_NET) && defined(CONFIG_NET_LOCAL_STREAM)
#include <sys/types.h>
#include <errno.h>
@ -49,6 +48,8 @@
#include "local/local.h"
#ifdef CONFIG_NET_LOCAL_STREAM
/****************************************************************************
* Public Functions
****************************************************************************/
@ -101,4 +102,4 @@ ssize_t psock_local_send(FAR struct socket *psock, FAR const void *buf,
return ret < 0 ? ret : len;
}
#endif /* CONFIG_NET && CONFIG_NET_LOCAL_STREAM */
#endif /* CONFIG_NET_LOCAL_STREAM */

View File

@ -126,7 +126,7 @@ const struct sock_intf_s g_local_sockif =
*
****************************************************************************/
#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_UDP)
#if defined(CONFIG_NET_LOCAL_STREAM) || defined(CONFIG_NET_LOCAL_DGRAM)
static int local_sockif_alloc(FAR struct socket *psock)
{
/* Allocate the local connection structure */
@ -182,7 +182,7 @@ static int local_setup(FAR struct socket *psock, int protocol)
switch (psock->s_type)
{
#ifdef CONFIG_NET_TCP
#ifdef CONFIG_NET_LOCAL_STREAM
case SOCK_STREAM:
if (protocol != 0 && protocol != IPPROTO_TCP)
{
@ -192,9 +192,9 @@ static int local_setup(FAR struct socket *psock, int protocol)
/* Allocate and attach the local connection structure */
return local_sockif_alloc(psock);
#endif /* CONFIG_NET_TCP */
#endif /* CONFIG_NET_LOCAL_STREAM */
#ifdef CONFIG_NET_UDP
#ifdef CONFIG_NET_LOCAL_DGRAM
case SOCK_DGRAM:
if (protocol != 0 && protocol != IPPROTO_UDP)
{
@ -204,7 +204,7 @@ static int local_setup(FAR struct socket *psock, int protocol)
/* Allocate and attach the local connection structure */
return local_sockif_alloc(psock);
#endif /* CONFIG_NET_UDP */
#endif /* CONFIG_NET_LOCAL_DGRAM */
default:
return -EPROTONOSUPPORT;
@ -298,11 +298,11 @@ static int local_bind(FAR struct socket *psock,
{
/* Bind a local TCP/IP stream or datagram socket */
#if defined(ONFIG_NET_TCP) || defined(CONFIG_NET_UDP)
#ifdef CONFIG_NET_TCP
#if defined(ONFIG_NET_TCP) || defined(CONFIG_NET_LOCAL_DGRAM)
#ifdef CONFIG_NET_LOCAL_STREAM
case SOCK_STREAM:
#endif
#ifdef CONFIG_NET_UDP
#ifdef CONFIG_NET_LOCAL_DGRAM
case SOCK_DGRAM:
#endif
{
@ -318,7 +318,7 @@ static int local_bind(FAR struct socket *psock,
}
}
break;
#endif /* CONFIG_NET_TCP || CONFIG_NET_UDP*/
#endif /* CONFIG_NET_LOCAL_STREAM || CONFIG_NET_LOCAL_DGRAM*/
default:
ret = -EBADF;
@ -497,7 +497,7 @@ static int local_connect(FAR struct socket *psock,
switch (psock->s_type)
{
#ifdef CONFIG_NET_TCP
#ifdef CONFIG_NET_LOCAL_STREAM
case SOCK_STREAM:
{
/* Verify that the socket is not already connected */
@ -512,17 +512,17 @@ static int local_connect(FAR struct socket *psock,
return psock_local_connect(psock, addr);
}
break;
#endif /* CONFIG_NET_TCP */
#endif /* CONFIG_NET_LOCAL_STREAM */
#ifdef CONFIG_NET_UDP
#ifdef CONFIG_NET_LOCAL_DGRAM
case SOCK_DGRAM:
{
/* Perform the datagram connection logic */
return psock_local_connect(psock, addr);
#warning Missing logic
return -ENOSYS;
}
break;
#endif /* CONFIG_NET_UDP */
#endif /* CONFIG_NET_LOCAL_DGRAM */
default:
return -EBADF;
@ -646,7 +646,7 @@ static ssize_t local_send(FAR struct socket *psock, FAR const void *buf,
switch (psock->s_type)
{
#ifdef CONFIG_NET_TCP
#ifdef CONFIG_NET_LOCAL_STREAM
case SOCK_STREAM:
{
/* Local TCP packet send */
@ -654,9 +654,9 @@ static ssize_t local_send(FAR struct socket *psock, FAR const void *buf,
ret = psock_local_send(psock, buf, len, flags);
}
break;
#endif /* CONFIG_NET_TCP */
#endif /* CONFIG_NET_LOCAL_STREAM */
#ifdef CONFIG_NET_UDP
#ifdef CONFIG_NET_LOCAL_DGRAM
case SOCK_DGRAM:
{
/* Local UDP packet send */
@ -664,7 +664,7 @@ static ssize_t local_send(FAR struct socket *psock, FAR const void *buf,
ret = -ENOSYS;
}
break;
#endif /* CONFIG_NET_UDP */
#endif /* CONFIG_NET_LOCAL_DGRAM */
default:
{
@ -716,7 +716,7 @@ ssize_t local_sendto(FAR struct socket *psock, FAR const void *buf,
return -EAFNOSUPPORT;
}
#ifdef CONFIG_NET_UDP
#ifdef CONFIG_NET_LOCAL_DGRAM
/* If this is a connected socket, then return EISCONN */
if (psock->s_type != SOCK_DGRAM)
@ -757,11 +757,11 @@ static int local_close(FAR struct socket *psock)
switch (psock->s_type)
{
#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_UDP)
#ifdef CONFIG_NET_TCP
#if defined(CONFIG_NET_LOCAL_STREAM) || defined(CONFIG_NET_LOCAL_DGRAM)
#ifdef CONFIG_NET_LOCAL_STREAM
case SOCK_STREAM:
#endif
#ifdef CONFIG_NET_UDP
#ifdef CONFIG_NET_LOCAL_DGRAM
case SOCK_DGRAM:
#endif
{
@ -785,7 +785,7 @@ static int local_close(FAR struct socket *psock)
return OK;
}
#endif /* CONFIG_NET_TCP || CONFIG_NET_UDP*/
#endif /* CONFIG_NET_LOCAL_STREAM || CONFIG_NET_LOCAL_DGRAM*/
default:
return -EBADF;