6loWPAN: Updates/fixes from early testing with the IEEE802.15.4 loopback driver.

This commit is contained in:
Gregory Nutt
2017-04-03 12:01:04 -06:00
parent e9d831ac60
commit 2c06f8ab78
6 changed files with 177 additions and 38 deletions
+74
View File
@@ -45,6 +45,7 @@
#include <nuttx/clock.h>
#include <nuttx/net/netconfig.h>
#include <nuttx/net/netdev.h>
#include <nuttx/net/net.h>
#include "devif/devif.h"
#include "arp/arp.h"
@@ -55,6 +56,7 @@
#include "icmp/icmp.h"
#include "icmpv6/icmpv6.h"
#include "igmp/igmp.h"
#include "sixlowpan/sixlowpan.h"
/****************************************************************************
* Public Data
@@ -68,6 +70,50 @@ systime_t g_polltime;
* Private Functions
****************************************************************************/
/****************************************************************************
* Function: devif_packet_conversion
*
* Description:
* TCP output comes through three 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 occur
* during TCP packet processing by the TCP state meachine.
* 3. TCP output resulting from TX or timer polling
*
* Cases 2 is handled here. Logic here detected if (1) an attempt
* to return with d_len > 0 and (2) that the device is an
* IEEE802.15.4 MAC network driver. Under those conditions, 6loWPAN
* logic will be called to create the IEEE80215.4 frames.
*
* Assumptions:
* The network is locked.
*
****************************************************************************/
#ifdef CONFIG_NET_6LOWPAN
static inline void devif_packet_conversion(FAR struct net_driver_s *dev)
{
#ifdef CONFIG_NET_MULTILINK
/* Handle the case where multiple link layer protocols are supported */
if (dev->d_len > 0 && dev->d_lltype == NET_LL_IEEE802154)
#else
if (dev->d_len > 0)
#endif
{
/* Let 6loWPAN convert output into the IEEE802.15.4 frames */
sixlowpan_tcp_send(dev);
dev->d_len = 0;
}
}
#else
# define devif_packet_conversion(dev)
#endif /* CONFIG_NET_6LOWPAN */
/****************************************************************************
* Function: devif_poll_pkt_connections
*
@@ -95,6 +141,10 @@ static int devif_poll_pkt_connections(FAR struct net_driver_s *dev,
pkt_poll(dev, pkt_conn);
/* Perform any necessary conversions on outgoing packets */
devif_packet_conversion(dev);
/* Call back into the driver */
bstop = callback(dev);
@@ -120,6 +170,10 @@ static inline int devif_poll_icmp(FAR struct net_driver_s *dev,
icmp_poll(dev);
/* Perform any necessary conversions on outgoing packets */
devif_packet_conversion(dev);
/* Call back into the driver */
return callback(dev);
@@ -142,6 +196,10 @@ static inline int devif_poll_icmpv6(FAR struct net_driver_s *dev,
icmpv6_poll(dev);
/* Perform any necessary conversions on outgoing packets */
devif_packet_conversion(dev);
/* Call back into the driver */
return callback(dev);
@@ -168,6 +226,10 @@ static inline int devif_poll_igmp(FAR struct net_driver_s *dev,
igmp_poll(dev);
/* Perform any necessary conversions on outgoing packets */
devif_packet_conversion(dev);
/* Call back into the driver */
return callback(dev);
@@ -201,6 +263,10 @@ static int devif_poll_udp_connections(FAR struct net_driver_s *dev,
udp_poll(dev, conn);
/* Perform any necessary conversions on outgoing packets */
devif_packet_conversion(dev);
/* Call back into the driver */
bstop = callback(dev);
@@ -237,6 +303,10 @@ static inline int devif_poll_tcp_connections(FAR struct net_driver_s *dev,
tcp_poll(dev, conn);
/* Perform any necessary conversions on outgoing packets */
devif_packet_conversion(dev);
/* Call back into the driver */
bstop = callback(dev);
@@ -277,6 +347,10 @@ static inline int devif_poll_tcp_timer(FAR struct net_driver_s *dev,
tcp_timer(dev, conn, hsec);
/* Perform any necessary conversions on outgoing packets */
devif_packet_conversion(dev);
/* Call back into the driver */
bstop = callback(dev);
+14 -9
View File
@@ -261,24 +261,29 @@ int ipv6_input(FAR struct net_driver_s *dev)
tcp_ipv6_input(dev);
#ifdef CONFIG_NET_6LOWPAN
/* TCP output comes through two different mechansims. Either from:
/* TCP output comes through three 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.
* 2. TCP output from the TCP state machine. That will occur
* during TCP packet processing by the TCP state meachine.
* 3. TCP output resulting from TX or timer polling
*
* Cases 2 is handled here. Logic here detected if (1) an attempt
* to return with d_len > 0 and (2) that the device is an
* IEEE802.15.4 MAC network driver. Under those conditions, 6loWPAN
* logic will be called to create the IEEE80215.4 frames.
*/
#ifdef CONFIG_NET_MULTILINK
/* Handle the case where multiple link layer protocols are supported */
/* Handle the case where multiple link layer protocols are supported */
if (dev->d_len > 0 && dev->d_lltype == CONFIG_NET_6LOWPAN)
if (dev->d_len > 0 && dev->d_lltype == CONFIG_NET_6LOWPAN)
#else
if (dev->d_len > 0)
if (dev->d_len > 0)
#endif
{
{
/* Let 6loWPAN handle the TCP output */
sixlowpan_tcp_send(dev);
@@ -286,7 +291,7 @@ int ipv6_input(FAR struct net_driver_s *dev)
/* Drop the packet in the d_buf */
goto drop;
}
}
#endif /* CONFIG_NET_6LOWPAN */
break;
#endif /* NET_TCP_HAVE_STACK */