mirror of
https://github.com/apache/nuttx.git
synced 2026-06-01 07:45:16 +08:00
6loWPAN: Add support for sendto()
This commit is contained in:
+36
-1
@@ -255,12 +255,45 @@ int ipv6_input(FAR struct net_driver_s *dev)
|
|||||||
{
|
{
|
||||||
#ifdef NET_TCP_HAVE_STACK
|
#ifdef NET_TCP_HAVE_STACK
|
||||||
case IP_PROTO_TCP: /* TCP input */
|
case IP_PROTO_TCP: /* TCP input */
|
||||||
|
/* Forward the IPv6 TCP packet */
|
||||||
|
|
||||||
tcp_ipv6_input(dev);
|
tcp_ipv6_input(dev);
|
||||||
break;
|
|
||||||
|
#ifdef CONFIG_NET_6LOWPAN
|
||||||
|
/* TCP output comes through two different mechansims. Either from:
|
||||||
|
*
|
||||||
|
* 1. TCP socket output. For the case of TCP output to an
|
||||||
|
* IEEE802.15.4, the TCP output is caught in the socket
|
||||||
|
* send()/sendto() logic and and redirected to 6loWPAN logic.
|
||||||
|
* 2. TCP output from the TCP state machine. That will pass
|
||||||
|
* here and can be detected if d_len > 0. It will be redirected
|
||||||
|
* to 6loWPAN logic here.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_MULTILINK
|
||||||
|
/* Handle the case where multiple link layer protocols are supported */
|
||||||
|
|
||||||
|
if (dev->d_len > 0 && dev->d_lltype == CONFIG_NET_6LOWPAN)
|
||||||
|
#else
|
||||||
|
if (dev->d_len > 0)
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
/* Let 6loWPAN handle the TCP output */
|
||||||
|
|
||||||
|
sixlowpan_tcp_send(dev);
|
||||||
|
|
||||||
|
/* Drop the packet in the d_buf */
|
||||||
|
|
||||||
|
goto drop;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_NET_6LOWPAN */
|
||||||
|
break;
|
||||||
|
#endif /* NET_TCP_HAVE_STACK */
|
||||||
|
|
||||||
#ifdef NET_UDP_HAVE_STACK
|
#ifdef NET_UDP_HAVE_STACK
|
||||||
case IP_PROTO_UDP: /* UDP input */
|
case IP_PROTO_UDP: /* UDP input */
|
||||||
|
/* Forward the IPv6 UDP packet */
|
||||||
|
|
||||||
udp_ipv6_input(dev);
|
udp_ipv6_input(dev);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
@@ -269,6 +302,8 @@ int ipv6_input(FAR struct net_driver_s *dev)
|
|||||||
|
|
||||||
#ifdef CONFIG_NET_ICMPv6
|
#ifdef CONFIG_NET_ICMPv6
|
||||||
case IP_PROTO_ICMP6: /* ICMP6 input */
|
case IP_PROTO_ICMP6: /* ICMP6 input */
|
||||||
|
/* Forward the ICMPv6 packet */
|
||||||
|
|
||||||
icmpv6_input(dev);
|
icmpv6_input(dev);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -53,7 +53,8 @@
|
|||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
struct socket; /* Forward reference */
|
struct socket; /* Forward reference */
|
||||||
|
struct sockaddr; /* Forward reference */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: sixlowpan_initialize
|
* Name: sixlowpan_initialize
|
||||||
@@ -132,5 +133,39 @@ ssize_t psock_6lowpan_udp_send(FAR struct socket *psock, FAR const void *buf,
|
|||||||
size_t len);
|
size_t len);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Function: psock_6lowpan_udp_sendto
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* If sendto() is used on a connection-mode (SOCK_STREAM, SOCK_SEQPACKET)
|
||||||
|
* socket, the parameters to and 'tolen' are ignored (and the error EISCONN
|
||||||
|
* may be returned when they are not NULL and 0), and the error ENOTCONN is
|
||||||
|
* returned when the socket was not actually connected.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* psock A pointer to a NuttX-specific, internal socket structure
|
||||||
|
* buf Data to send
|
||||||
|
* len Length of data to send
|
||||||
|
* flags Send flags
|
||||||
|
* to Address of recipient
|
||||||
|
* tolen The length of the address structure
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* On success, returns the number of characters sent. On error,
|
||||||
|
* -1 is returned, and errno is set appropriately. Returned error
|
||||||
|
* number must be consistent with definition of errors reported by
|
||||||
|
* sendto().
|
||||||
|
*
|
||||||
|
* Assumptions:
|
||||||
|
* Called with the network locked.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
ssize_t psock_6lowpan_udp_sendto(FAR struct socket *psock,
|
||||||
|
FAR const void *buf,
|
||||||
|
size_t len, int flags,
|
||||||
|
FAR const struct sockaddr *to,
|
||||||
|
socklen_t tolen);
|
||||||
|
|
||||||
#endif /* CONFIG_NET_6LOWPAN */
|
#endif /* CONFIG_NET_6LOWPAN */
|
||||||
#endif /* _NET_SIXLOWPAN_SIXLOWPAN_H */
|
#endif /* _NET_SIXLOWPAN_SIXLOWPAN_H */
|
||||||
|
|||||||
@@ -39,6 +39,8 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
@@ -56,6 +58,159 @@
|
|||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Function: psock_6lowpan_udp_sendto
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* If sendto() is used on a connection-mode (SOCK_STREAM, SOCK_SEQPACKET)
|
||||||
|
* socket, the parameters to and 'tolen' are ignored (and the error EISCONN
|
||||||
|
* may be returned when they are not NULL and 0), and the error ENOTCONN is
|
||||||
|
* returned when the socket was not actually connected.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* psock A pointer to a NuttX-specific, internal socket structure
|
||||||
|
* buf Data to send
|
||||||
|
* len Length of data to send
|
||||||
|
* flags Send flags
|
||||||
|
* to Address of recipient
|
||||||
|
* tolen The length of the address structure
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* On success, returns the number of characters sent. On error,
|
||||||
|
* -1 is returned, and errno is set appropriately. Returned error
|
||||||
|
* number must be consistent with definition of errors reported by
|
||||||
|
* sendto().
|
||||||
|
*
|
||||||
|
* Assumptions:
|
||||||
|
* Called with the network locked.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
ssize_t psock_6lowpan_udp_sendto(FAR struct socket *psock,
|
||||||
|
FAR const void *buf,
|
||||||
|
size_t len, int flags,
|
||||||
|
FAR const struct sockaddr *to,
|
||||||
|
socklen_t tolen)
|
||||||
|
{
|
||||||
|
FAR struct sockaddr_in6 *to6 = (FAR struct sockaddr_in6 *)to;
|
||||||
|
FAR struct udp_conn_s *conn;
|
||||||
|
FAR struct net_driver_s *dev;
|
||||||
|
struct ipv6udp_hdr_s ipv6udp;
|
||||||
|
struct rimeaddr_s destmac;
|
||||||
|
uint16_t timeout;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
DEBUGASSERT(psock != NULL && psock->s_crefs > 0 && to != NULL);
|
||||||
|
DEBUGASSERT(psock->s_type == SOCK_DGRAM);
|
||||||
|
|
||||||
|
if (psock == NULL || to == NULL)
|
||||||
|
{
|
||||||
|
return (ssize_t)-EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Make sure that this is a datagram valid socket */
|
||||||
|
|
||||||
|
if (psock->s_crefs <= 0 || psock->s_type != SOCK_DGRAM)
|
||||||
|
{
|
||||||
|
nerr("ERROR: Invalid socket\n");
|
||||||
|
return (ssize_t)-EBADF;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Make sure that the destination address is valid */
|
||||||
|
|
||||||
|
if (to6->sin6_family != AF_INET6 || tolen < sizeof(struct sockaddr_in6))
|
||||||
|
{
|
||||||
|
nerr("ERROR: Invalid destination address\n");
|
||||||
|
return (ssize_t)-EAFNOSUPPORT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get the underlying UDP "connection" structure */
|
||||||
|
|
||||||
|
conn = (FAR struct udp_conn_s *)psock->s_conn;
|
||||||
|
DEBUGASSERT(conn != NULL);
|
||||||
|
|
||||||
|
/* Ignore if not IPv6 domain */
|
||||||
|
|
||||||
|
if (conn->domain != PF_INET6)
|
||||||
|
{
|
||||||
|
nwarn("WARNING: Not IPv6\n");
|
||||||
|
return (ssize_t)-EPROTOTYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Route outgoing message to the correct device */
|
||||||
|
|
||||||
|
#ifdef CONFIG_NETDEV_MULTINIC
|
||||||
|
dev = netdev_findby_ipv6addr(conn->u.ipv6.laddr,
|
||||||
|
to6->sin6_addr.in6_u.u6_addr16);
|
||||||
|
#ifdef CONFIG_NETDEV_MULTILINK
|
||||||
|
if (dev == NULL || dev->d_lltype != NET_LL_IEEE802154)
|
||||||
|
#else
|
||||||
|
if (dev == NULL)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
nwarn("WARNING: Not routable or not IEEE802.15.4 MAC\n");
|
||||||
|
return (ssize_t)-ENETUNREACH;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
dev = netdev_findby_ipv6addr(to6->sin6_addr.in6_u.u6_addr16);
|
||||||
|
#ifdef CONFIG_NETDEV_MULTILINK
|
||||||
|
if (dev == NULL || dev->d_lltype != NET_LL_IEEE802154)
|
||||||
|
#else
|
||||||
|
if (dev == NULL)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
nwarn("WARNING: Not routable\n");
|
||||||
|
return (ssize_t)-ENETUNREACH;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_ICMPv6_NEIGHBOR
|
||||||
|
/* Make sure that the IP address mapping is in the Neighbor Table */
|
||||||
|
|
||||||
|
ret = icmpv6_neighbor(to6->sin6_addr.in6_u.u6_addr16);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
nerr("ERROR: Not reachable\n");
|
||||||
|
return (ssize_t)-ENETUNREACH;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Initialize the IPv6/UDP headers */
|
||||||
|
#warning Missing logic
|
||||||
|
|
||||||
|
/* Set the socket state to sending */
|
||||||
|
|
||||||
|
psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_SEND);
|
||||||
|
|
||||||
|
/* Get the Rime MAC address of the destination This assumes an encoding
|
||||||
|
* of the MAC address in the IPv6 address.
|
||||||
|
*/
|
||||||
|
|
||||||
|
sixlowpan_rimefromip(to6->sin6_addr.in6_u.u6_addr16, &destmac);
|
||||||
|
|
||||||
|
/* If routable, then call sixlowpan_send() to format and send the 6loWPAN
|
||||||
|
* packet.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_SOCKOPTS
|
||||||
|
timeout = psock->s_sndtimeo;
|
||||||
|
#else
|
||||||
|
timeout = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ret = sixlowpan_send(dev, (FAR const struct ipv6_hdr_s *)&ipv6udp,
|
||||||
|
buf, len, &destmac, timeout);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
nerr("ERROR: sixlowpan_send() failed: %d\n", ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the socket state to idle */
|
||||||
|
|
||||||
|
psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_IDLE);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: psock_6lowpan_udp_send
|
* Function: psock_6lowpan_udp_send
|
||||||
*
|
*
|
||||||
@@ -71,8 +226,7 @@
|
|||||||
* Returned Value:
|
* Returned Value:
|
||||||
* On success, returns the number of characters sent. On error,
|
* On success, returns the number of characters sent. On error,
|
||||||
* -1 is returned, and errno is set appropriately. Returned error numbers
|
* -1 is returned, and errno is set appropriately. Returned error numbers
|
||||||
* must be consistent with definition of errors reported by send() or
|
* must be consistent with definition of errors reported by send().
|
||||||
* sendto().
|
|
||||||
*
|
*
|
||||||
* Assumptions:
|
* Assumptions:
|
||||||
* Called with the network locked.
|
* Called with the network locked.
|
||||||
@@ -83,11 +237,7 @@ ssize_t psock_6lowpan_udp_send(FAR struct socket *psock, FAR const void *buf,
|
|||||||
size_t len)
|
size_t len)
|
||||||
{
|
{
|
||||||
FAR struct udp_conn_s *conn;
|
FAR struct udp_conn_s *conn;
|
||||||
FAR struct net_driver_s *dev;
|
struct sockaddr_in6 to;
|
||||||
struct ipv6udp_hdr_s ipv6udp;
|
|
||||||
struct rimeaddr_s destmac;
|
|
||||||
uint16_t timeout;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
DEBUGASSERT(psock != NULL && psock->s_crefs > 0);
|
DEBUGASSERT(psock != NULL && psock->s_crefs > 0);
|
||||||
DEBUGASSERT(psock->s_type == SOCK_DGRAM);
|
DEBUGASSERT(psock->s_type == SOCK_DGRAM);
|
||||||
@@ -114,7 +264,6 @@ ssize_t psock_6lowpan_udp_send(FAR struct socket *psock, FAR const void *buf,
|
|||||||
conn = (FAR struct udp_conn_s *)psock->s_conn;
|
conn = (FAR struct udp_conn_s *)psock->s_conn;
|
||||||
DEBUGASSERT(conn != NULL);
|
DEBUGASSERT(conn != NULL);
|
||||||
|
|
||||||
#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6)
|
|
||||||
/* Ignore if not IPv6 domain */
|
/* Ignore if not IPv6 domain */
|
||||||
|
|
||||||
if (conn->domain != PF_INET6)
|
if (conn->domain != PF_INET6)
|
||||||
@@ -122,79 +271,16 @@ ssize_t psock_6lowpan_udp_send(FAR struct socket *psock, FAR const void *buf,
|
|||||||
nwarn("WARNING: Not IPv6\n");
|
nwarn("WARNING: Not IPv6\n");
|
||||||
return (ssize_t)-EPROTOTYPE;
|
return (ssize_t)-EPROTOTYPE;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Route outgoing message to the correct device */
|
/* Create the 'to' address */
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
to.sin6_family = AF_INET6;
|
||||||
dev = netdev_findby_ipv6addr(conn->u.ipv6.laddr, conn->u.ipv6.raddr);
|
to.sin6_port = conn->rport; /* Already network order */
|
||||||
#ifdef CONFIG_NETDEV_MULTILINK
|
memcpy(to.sin6_addr.in6_u.u6_addr16, conn->u.ipv6.raddr, 16);
|
||||||
if (dev == NULL || dev->d_lltype != NET_LL_IEEE802154)
|
|
||||||
#else
|
|
||||||
if (dev == NULL)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
nwarn("WARNING: Not routable or not IEEE802.15.4 MAC\n");
|
|
||||||
return (ssize_t)-ENETUNREACH;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
dev = netdev_findby_ipv6addr(conn->u.ipv6.raddr);
|
|
||||||
#ifdef CONFIG_NETDEV_MULTILINK
|
|
||||||
if (dev == NULL || dev->d_lltype != NET_LL_IEEE802154)
|
|
||||||
#else
|
|
||||||
if (dev == NULL)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
nwarn("WARNING: Not routable\n");
|
|
||||||
return (ssize_t)-ENETUNREACH;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_NET_ICMPv6_NEIGHBOR
|
return psock_6lowpan_udp_sendto(psock, buf, len, 0,
|
||||||
/* Make sure that the IP address mapping is in the Neighbor Table */
|
(FAR const struct sockaddr *)&to,
|
||||||
|
sizeof(struct sockaddr_in6));
|
||||||
ret = icmpv6_neighbor(conn->u.ipv6.raddr);
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
nerr("ERROR: Not reachable\n");
|
|
||||||
return (ssize_t)-ENETUNREACH;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Initialize the IPv6/UDP headers */
|
|
||||||
#warning Missing logic
|
|
||||||
|
|
||||||
/* Set the socket state to sending */
|
|
||||||
|
|
||||||
psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_SEND);
|
|
||||||
|
|
||||||
/* Get the Rime MAC address of the destination This assumes an encoding
|
|
||||||
* of the MAC address in the IPv6 address.
|
|
||||||
*/
|
|
||||||
|
|
||||||
sixlowpan_rimefromip(conn->u.ipv6.raddr, &destmac);
|
|
||||||
|
|
||||||
/* If routable, then call sixlowpan_send() to format and send the 6loWPAN
|
|
||||||
* packet.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef CONFIG_NET_SOCKOPTS
|
|
||||||
timeout = psock->s_sndtimeo;
|
|
||||||
#else
|
|
||||||
timeout = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ret = sixlowpan_send(dev, (FAR const struct ipv6_hdr_s *)&ipv6udp,
|
|
||||||
buf, len, &destmac, timeout);
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
nerr("ERROR: sixlowpan_send() failed: %d\n", ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set the socket state to idle */
|
|
||||||
|
|
||||||
psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_IDLE);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_NET_6LOWPAN && CONFIG_NET_UDP */
|
#endif /* CONFIG_NET_6LOWPAN && CONFIG_NET_UDP */
|
||||||
|
|||||||
+11
-31
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* net/socket/send.c
|
* net/socket/send.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2014, 2016 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007-2014, 2016-2017 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -166,29 +166,18 @@ ssize_t psock_send(FAR struct socket *psock, FAR const void *buf, size_t len,
|
|||||||
|
|
||||||
ret = psock_6lowpan_tcp_send(psock, buf, len);
|
ret = psock_6lowpan_tcp_send(psock, buf, len);
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
#if defined(CONFIG_NETDEV_MULTINIC) && defined(NET_TCP_HAVE_STACK)
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
/* TCP/IP packet send */
|
/* TCP/IP packet send */
|
||||||
|
|
||||||
ret = psock_tcp_send(psock, buf, len);
|
ret = psock_tcp_send(psock, buf, len);
|
||||||
#ifdef NET_TCP_HAVE_STACK
|
|
||||||
ret = psock_tcp_send(psock, buf, len);
|
|
||||||
#else
|
|
||||||
ret = -ENOSYS;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif /* CONFIG_NETDEV_MULTINIC && NET_TCP_HAVE_STACK */
|
||||||
#endif /* CONFIG_NETDEV_MULTINIC */
|
#elif defined(NET_TCP_HAVE_STACK)
|
||||||
#else /* CONFIG_NET_6LOWPAN */
|
nsent = psock_tcp_send(psock, buf, len, flags, to, tolen);
|
||||||
|
|
||||||
/* Only TCP/IP packet send */
|
|
||||||
|
|
||||||
#ifdef NET_TCP_HAVE_STACK
|
|
||||||
ret = psock_tcp_send(psock, buf, len);
|
|
||||||
#else
|
#else
|
||||||
ret = -ENOSYS;
|
nsent = -ENOSYS;
|
||||||
#endif
|
|
||||||
#endif /* CONFIG_NET_6LOWPAN */
|
#endif /* CONFIG_NET_6LOWPAN */
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_TCP */
|
#endif /* CONFIG_NET_TCP */
|
||||||
@@ -215,34 +204,25 @@ ssize_t psock_send(FAR struct socket *psock, FAR const void *buf, size_t len,
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_NET_6LOWPAN
|
#if defined(CONFIG_NET_6LOWPAN)
|
||||||
/* Try 6loWPAN UDP packet send */
|
/* Try 6loWPAN UDP packet send */
|
||||||
|
|
||||||
ret = psock_6lowpan_udp_send(psock, buf, len);
|
ret = psock_6lowpan_udp_send(psock, buf, len);
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
#if defined(CONFIG_NETDEV_MULTINIC) && defined(NET_UDP_HAVE_STACK)
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
/* UDP/IP packet send */
|
/* UDP/IP packet send */
|
||||||
|
|
||||||
ret = psock_udp_send(psock, buf, len);
|
ret = psock_udp_send(psock, buf, len);
|
||||||
#ifdef NET_UDP_HAVE_STACK
|
|
||||||
ret = psock_udp_send(psock, buf, len);
|
|
||||||
#else
|
|
||||||
ret = -ENOSYS;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif /* CONFIG_NETDEV_MULTINIC && NET_UDP_HAVE_STACK */
|
||||||
#endif /* CONFIG_NETDEV_MULTINIC */
|
#elif defined(NET_UDP_HAVE_STACK)
|
||||||
#else /* CONFIG_NET_6LOWPAN */
|
|
||||||
|
|
||||||
/* Only UDP/IP packet send */
|
/* Only UDP/IP packet send */
|
||||||
|
|
||||||
#ifdef NET_UDP_HAVE_STACK
|
|
||||||
ret = psock_udp_send(psock, buf, len);
|
ret = psock_udp_send(psock, buf, len);
|
||||||
#else
|
#else
|
||||||
ret = -ENOSYS;
|
ret = -ENOSYS;
|
||||||
#endif
|
|
||||||
#endif /* CONFIG_NET_6LOWPAN */
|
#endif /* CONFIG_NET_6LOWPAN */
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_UDP */
|
#endif /* CONFIG_NET_UDP */
|
||||||
|
|||||||
+16
-2
@@ -49,6 +49,7 @@
|
|||||||
#include <nuttx/net/net.h>
|
#include <nuttx/net/net.h>
|
||||||
|
|
||||||
#include "udp/udp.h"
|
#include "udp/udp.h"
|
||||||
|
#include "sixlowpan/sixlowpan.h"
|
||||||
#include "local/local.h"
|
#include "local/local.h"
|
||||||
#include "socket/socket.h"
|
#include "socket/socket.h"
|
||||||
#include "usrsock/usrsock.h"
|
#include "usrsock/usrsock.h"
|
||||||
@@ -237,11 +238,24 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf,
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef NET_UDP_HAVE_STACK
|
#if defined(CONFIG_NET_6LOWPAN)
|
||||||
|
/* Try 6loWPAN UDP packet sendto() */
|
||||||
|
|
||||||
|
nsent = psock_6lowpan_udp_sendto(psock, buf, len, flags, to, tolen);
|
||||||
|
|
||||||
|
#if defined(CONFIG_NETDEV_MULTINIC) && defined(NET_UDP_HAVE_STACK)
|
||||||
|
if (nsent < 0)
|
||||||
|
{
|
||||||
|
/* UDP/IP packet sendto */
|
||||||
|
|
||||||
|
nsent = psock_udp_sendto(psock, buf, len, flags, to, tolen);
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_NETDEV_MULTINIC && 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
|
||||||
nsent = -ENOSYS;
|
nsent = -ENOSYS;
|
||||||
#endif
|
#endif /* CONFIG_NET_6LOWPAN */
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_UDP */
|
#endif /* CONFIG_NET_UDP */
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
* net/tcp/tcp_input.c
|
* net/tcp/tcp_input.c
|
||||||
* Handling incoming TCP input
|
* Handling incoming TCP input
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2014 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007-2014, 2017 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Adapted for NuttX from logic in uIP which also has a BSD-like license:
|
* Adapted for NuttX from logic in uIP which also has a BSD-like license:
|
||||||
|
|||||||
Reference in New Issue
Block a user