mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
Networking: Hook in send and revcfrom Unix domain socket logic; still needs hooks for sendto logic
This commit is contained in:
+64
-21
@@ -68,6 +68,7 @@
|
|||||||
#include "tcp/tcp.h"
|
#include "tcp/tcp.h"
|
||||||
#include "udp/udp.h"
|
#include "udp/udp.h"
|
||||||
#include "pkt/pkt.h"
|
#include "pkt/pkt.h"
|
||||||
|
#include "local/local.h"
|
||||||
#include "socket/socket.h"
|
#include "socket/socket.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -1580,7 +1581,7 @@ static ssize_t tcp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
ssize_t psock_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
|
ssize_t psock_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
|
||||||
int flags,FAR struct sockaddr *from,
|
int flags, FAR struct sockaddr *from,
|
||||||
FAR socklen_t *fromlen)
|
FAR socklen_t *fromlen)
|
||||||
{
|
{
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
@@ -1645,30 +1646,72 @@ ssize_t psock_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
|
|||||||
/* Read from the network interface driver buffer */
|
/* Read from the network interface driver buffer */
|
||||||
/* Or perform the TCP/IP or UDP recv() operation */
|
/* Or perform the TCP/IP or UDP recv() operation */
|
||||||
|
|
||||||
#if defined(CONFIG_NET_PKT)
|
switch (psock->s_type)
|
||||||
if (psock->s_type == SOCK_RAW)
|
|
||||||
{
|
{
|
||||||
ret = pkt_recvfrom(psock, buf, len, from);
|
#ifdef CONFIG_NET_PKT
|
||||||
}
|
case SOCK_RAW:
|
||||||
else
|
{
|
||||||
|
ret = pkt_recvfrom(psock, buf, len, from);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif /* CONFIG_NET_PKT */
|
||||||
|
|
||||||
|
#if defined(CONFIG_NET_TCP) || defined(CONFIG_NET_LOCAL)
|
||||||
|
case SOCK_STREAM:
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_NET_LOCAL
|
||||||
|
#ifdef CONFIG_NET_TCP
|
||||||
|
if (psock->s_domain == PF_LOCAL)
|
||||||
#endif
|
#endif
|
||||||
#if defined(CONFIG_NET_TCP)
|
{
|
||||||
if (psock->s_type == SOCK_STREAM)
|
ret = psock_local_recvfrom(psock, buf, len, flags,
|
||||||
{
|
from, fromlen);
|
||||||
ret = tcp_recvfrom(psock, buf, len, from);
|
}
|
||||||
}
|
#endif /* CONFIG_NET_LOCAL */
|
||||||
else
|
|
||||||
|
#ifdef CONFIG_NET_TCP
|
||||||
|
#ifdef CONFIG_NET_LOCAL
|
||||||
|
else
|
||||||
#endif
|
#endif
|
||||||
#if defined(CONFIG_NET_UDP)
|
{
|
||||||
if (psock->s_type == SOCK_DGRAM)
|
ret = tcp_recvfrom(psock, buf, len, from);
|
||||||
{
|
}
|
||||||
ret = udp_recvfrom(psock, buf, len, from);
|
#endif /* CONFIG_NET_TCP */
|
||||||
}
|
}
|
||||||
else
|
break;
|
||||||
|
#endif /* CONFIG_NET_TCP || CONFIG_NET_LOCAL */
|
||||||
|
|
||||||
|
#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_LOCAL)
|
||||||
|
case SOCK_DGRAM:
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_NET_LOCAL
|
||||||
|
#ifdef CONFIG_NET_UDP
|
||||||
|
if (psock->s_domain == PF_LOCAL)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
ndbg("ERROR: Unsupported socket type: %d\n", psock->s_type);
|
ret = psock_local_recvfrom(psock, buf, len, flags,
|
||||||
ret = -ENOSYS;
|
from, fromlen);
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_NET_LOCAL */
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_UDP
|
||||||
|
#ifdef CONFIG_NET_LOCAL
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
ret = udp_recvfrom(psock, buf, len, from);
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_NET_UDP */
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif /* CONFIG_NET_UDP || CONFIG_NET_LOCAL */
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
ndbg("ERROR: Unsupported socket type: %d\n", psock->s_type);
|
||||||
|
ret = -ENOSYS;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the socket state to idle */
|
/* Set the socket state to idle */
|
||||||
|
|||||||
+20
-5
@@ -45,6 +45,7 @@
|
|||||||
|
|
||||||
#include "tcp/tcp.h"
|
#include "tcp/tcp.h"
|
||||||
#include "pkt/pkt.h"
|
#include "pkt/pkt.h"
|
||||||
|
#include "local/local.h"
|
||||||
#include "socket/socket.h"
|
#include "socket/socket.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -138,17 +139,31 @@ ssize_t psock_send(FAR struct socket *psock, FAR const void *buf, size_t len,
|
|||||||
case SOCK_RAW:
|
case SOCK_RAW:
|
||||||
{
|
{
|
||||||
ret = psock_pkt_send(psock, buf, len);
|
ret = psock_pkt_send(psock, buf, len);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_NET_TCP)
|
|
||||||
case SOCK_STREAM:
|
case SOCK_STREAM:
|
||||||
{
|
{
|
||||||
ret = psock_tcp_send(psock, buf, len);
|
#ifdef CONFIG_NET_LOCAL
|
||||||
break;
|
#ifdef CONFIG_NET_TCP
|
||||||
}
|
if (psock->s_domain == PF_LOCAL)
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
ret = psock_local_send(psock, buf, len, flags);
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_NET_LOCAL */
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_TCP
|
||||||
|
#ifdef CONFIG_NET_LOCAL
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
ret = psock_tcp_send(psock, buf, len);
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_NET_TCP */
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
|||||||
+11
-1
@@ -467,6 +467,12 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf,
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
case AF_LOCAL:
|
||||||
|
minlen = sizeof(sa_family_t);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ndbg("ERROR: Unrecognized address family: %d\n", to->sa_family);
|
ndbg("ERROR: Unrecognized address family: %d\n", to->sa_family);
|
||||||
err = EAFNOSUPPORT;
|
err = EAFNOSUPPORT;
|
||||||
@@ -511,9 +517,13 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Perform the UDP sendto operation */
|
#ifdef CONFIG_NET_LOCAL
|
||||||
|
/* Perform the Unix domain sendto operation */
|
||||||
|
# warning Missing logic
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_NET_UDP
|
#ifdef CONFIG_NET_UDP
|
||||||
|
/* Perform the UDP sendto operation */
|
||||||
/* Set the socket state to sending */
|
/* Set the socket state to sending */
|
||||||
|
|
||||||
psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_SEND);
|
psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_SEND);
|
||||||
|
|||||||
Reference in New Issue
Block a user