wireless/ieee802154: Add initialization logic for loopback driver; configs/sim: Add configuration for testing 6loWPAN; net/sixlowpan: Fix for compilation with debug output enabled.

This commit is contained in:
Gregory Nutt 2017-04-03 09:15:00 -06:00
parent 068ac948e1
commit e9d831ac60
8 changed files with 98 additions and 45 deletions

View File

@ -42,22 +42,6 @@
#include "sim.h" #include "sim.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Types
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/

View File

@ -47,6 +47,7 @@
#include <nuttx/board.h> #include <nuttx/board.h>
#include <nuttx/clock.h> #include <nuttx/clock.h>
#include <nuttx/timers/oneshot.h> #include <nuttx/timers/oneshot.h>
#include <nuttx/wireless/ieee802154/ieee802154_loopback.h>
#include "up_internal.h" #include "up_internal.h"
#include "sim.h" #include "sim.h"
@ -139,5 +140,15 @@ int sim_bringup(void)
} }
#endif #endif
#ifdef CONFIG_IEEE802154_LOOPBACK
/* Initialize and register the IEEE802.15.4 MAC network loop device */
ret = ieee8021514_loopback();
if (ret < 0)
{
_err("ERROR: ieee8021514_loopback() failed: %d\n", ret);
}
#endif
return OK; return OK;
} }

View File

@ -0,0 +1,73 @@
/****************************************************************************
* include/nuttx/net/ieee802154.h
*
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Includes some definitions that a compatible with the LGPL GNU C Library
* header file of the same name.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_WIRELESS_IEEE802154_IEEE802154_LOOPBACK_H
#define __INCLUDE_NUTTX_WIRELESS_IEEE802154_IEEE802154_LOOPBACK_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#ifdef CONFIG_IEEE802154_LOOPBACK
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Function: ieee8021514_loopback
*
* Description:
* Initialize and register the Ieee802.15.4 MAC loopback network driver.
*
* Parameters:
* None
*
* Returned Value:
* OK on success; Negated errno on failure.
*
* Assumptions:
*
****************************************************************************/
int ieee8021514_loopback(void);
#endif /* CONFIG_IEEE802154_LOOPBACK */
#endif /* __INCLUDE_NUTTX_WIRELESS_IEEE802154_IEEE802154_LOOPBACK_H */

View File

@ -455,7 +455,7 @@ void sixlowpan_compresshdr_hc06(FAR struct ieee802154_driver_s *ieee,
uint8_t iphc1; uint8_t iphc1;
uint8_t tmp; uint8_t tmp;
ninfodumpbuffer("IPv6 before compression", ipv6, sizeof(ipv6_hdr_s)); ninfodumpbuffer("IPv6 before compression", ipv6, sizeof(struct ipv6_hdr_s));
g_hc06ptr = g_rimeptr + 2; g_hc06ptr = g_rimeptr + 2;

View File

@ -470,7 +470,8 @@ copypayload:
} }
#endif /* CONFIG_NET_6LOWPAN_FRAG */ #endif /* CONFIG_NET_6LOWPAN_FRAG */
ninfodumpbuffer("IPv6 header", IPv6BUF(ieee->i_dev), IPv6_HDRLEN) ninfodumpbuffer("IPv6 header", (FAR const uint8_t *)IPv6BUF(&ieee->i_dev),
IPv6_HDRLEN);
return OK; return OK;
} }

View File

@ -249,7 +249,8 @@ ssize_t psock_6lowpan_tcp_send(FAR struct socket *psock, FAR const void *buf,
net_ipv6addr_hdrcopy(ipv6tcp.ipv6.srcipaddr, conn->u.ipv6.laddr); net_ipv6addr_hdrcopy(ipv6tcp.ipv6.srcipaddr, conn->u.ipv6.laddr);
net_ipv6addr_hdrcopy(ipv6tcp.ipv6.destipaddr, conn->u.ipv6.raddr); net_ipv6addr_hdrcopy(ipv6tcp.ipv6.destipaddr, conn->u.ipv6.raddr);
ninfo("IPv6 length: %d\n", ((int)ipv6->len[0] << 8) + ipv6->len[1]); ninfo("IPv6 length: %d\n",
((int)ipv6tcp.ipv6.len[0] << 8) + ipv6tcp.ipv6.len[1]);
#ifdef CONFIG_NET_STATISTICS #ifdef CONFIG_NET_STATISTICS
g_netstats.ipv6.sent++; g_netstats.ipv6.sent++;
@ -289,7 +290,7 @@ ssize_t psock_6lowpan_tcp_send(FAR struct socket *psock, FAR const void *buf,
ipv6tcp.tcp.tcpchksum = 0; ipv6tcp.tcp.tcpchksum = 0;
ipv6tcp.tcp.tcpchksum = ~sixlowpan_tcp_chksum(&ipv6tcp, buf, buflen); ipv6tcp.tcp.tcpchksum = ~sixlowpan_tcp_chksum(&ipv6tcp, buf, buflen);
ninfo("Outgoing TCP packet length: %d bytes\n", iplen + IOPv6_HDRLEN); ninfo("Outgoing TCP packet length: %d bytes\n", iplen + IPv6_HDRLEN);
#ifdef CONFIG_NET_STATISTICS #ifdef CONFIG_NET_STATISTICS
g_netstats.tcp.sent++; g_netstats.tcp.sent++;

View File

@ -263,7 +263,8 @@ ssize_t psock_6lowpan_udp_sendto(FAR struct socket *psock,
net_ipv6addr_hdrcopy(ipv6udp.ipv6.srcipaddr, to6->sin6_addr.in6_u.u6_addr16); net_ipv6addr_hdrcopy(ipv6udp.ipv6.srcipaddr, to6->sin6_addr.in6_u.u6_addr16);
net_ipv6addr_hdrcopy(ipv6udp.ipv6.destipaddr, conn->u.ipv6.raddr); net_ipv6addr_hdrcopy(ipv6udp.ipv6.destipaddr, conn->u.ipv6.raddr);
ninfo("IPv6 length: %d\n", ((int)ipv6->len[0] << 8) + ipv6->len[1]); ninfo("IPv6 length: %d\n",
((int)ipv6udp.ipv6.len[0] << 8) + ipv6udp.ipv6.len[1]);
#ifdef CONFIG_NET_STATISTICS #ifdef CONFIG_NET_STATISTICS
g_netstats.ipv6.sent++; g_netstats.ipv6.sent++;

View File

@ -53,11 +53,8 @@
#include <nuttx/wqueue.h> #include <nuttx/wqueue.h>
#include <nuttx/net/net.h> #include <nuttx/net/net.h>
#include <nuttx/net/ip.h> #include <nuttx/net/ip.h>
#include <nuttx/net/loopback.h> #include <nuttx/net/sixlowpan.h>
#include <nuttx/wireless/ieee802154/ieee802154_loopback.h>
#ifndef CONFIG_NET_LOOPBACK
# include <nuttx/net/sixlowpan.h>
#endif
#ifdef CONFIG_IEEE802154_LOOPBACK #ifdef CONFIG_IEEE802154_LOOPBACK
@ -110,14 +107,6 @@ struct lo_driver_s
static struct lo_driver_s g_loopback; static struct lo_driver_s g_loopback;
static uint8_t g_iobuffer[CONFIG_NET_6LOWPAN_MTU + CONFIG_NET_GUARDSIZE]; static uint8_t g_iobuffer[CONFIG_NET_6LOWPAN_MTU + CONFIG_NET_GUARDSIZE];
#ifndef CONFIG_NET_LOOPBACK
static const net_ipv6addr_t g_lo_ipv6addr =
{
HTONS(0), HTONS(0), HTONS(0), HTONS(0),
HTONS(0), HTONS(0), HTONS(0), HTONS(1)
};
#endif
/**************************************************************************** /****************************************************************************
* Private Function Prototypes * Private Function Prototypes
****************************************************************************/ ****************************************************************************/
@ -520,14 +509,13 @@ static int lo_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac)
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Function: localhost_initialize * Function: ieee8021514_loopback
* *
* Description: * Description:
* Initialize the Ethernet controller and driver * Initialize and register the Ieee802.15.4 MAC loopback network driver.
* *
* Parameters: * Parameters:
* intf - In the case where there are multiple EMACs, this value * None
* identifies which EMAC is to be initialized.
* *
* Returned Value: * Returned Value:
* OK on success; Negated errno on failure. * OK on success; Negated errno on failure.
@ -536,7 +524,7 @@ static int lo_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac)
* *
****************************************************************************/ ****************************************************************************/
int localhost_initialize(void) int ieee8021514_loopback(void)
{ {
FAR struct lo_driver_s *priv; FAR struct lo_driver_s *priv;
FAR struct net_driver_s *dev; FAR struct net_driver_s *dev;
@ -570,12 +558,6 @@ int localhost_initialize(void)
(void)netdev_register(&priv->lo_ieee.i_dev, NET_LL_IEEE802154); (void)netdev_register(&priv->lo_ieee.i_dev, NET_LL_IEEE802154);
/* Set the local loopback IP address */
net_ipv6addr_copy(dev->d_ipv6addr, g_lo_ipv6addr);
net_ipv6addr_copy(dev->d_ipv6draddr, g_lo_ipv6addr);
net_ipv6addr_copy(dev->d_ipv6netmask, g_ipv6_alloneaddr);
/* Put the network in the UP state */ /* Put the network in the UP state */
dev->d_flags = IFF_UP; dev->d_flags = IFF_UP;