diff --git a/configs/sim/src/sim_boot.c b/configs/sim/src/sim_boot.c index 826ca47f90..6e0be20777 100644 --- a/configs/sim/src/sim_boot.c +++ b/configs/sim/src/sim_boot.c @@ -42,22 +42,6 @@ #include "sim.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Types - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/configs/sim/src/sim_bringup.c b/configs/sim/src/sim_bringup.c index 8f0d85c078..8dd0f75bdd 100644 --- a/configs/sim/src/sim_bringup.c +++ b/configs/sim/src/sim_bringup.c @@ -47,6 +47,7 @@ #include #include #include +#include #include "up_internal.h" #include "sim.h" @@ -139,5 +140,15 @@ int sim_bringup(void) } #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; } diff --git a/include/nuttx/wireless/ieee802154/ieee802154_loopback.h b/include/nuttx/wireless/ieee802154/ieee802154_loopback.h new file mode 100644 index 0000000000..d1952df24f --- /dev/null +++ b/include/nuttx/wireless/ieee802154/ieee802154_loopback.h @@ -0,0 +1,73 @@ +/**************************************************************************** + * include/nuttx/net/ieee802154.h + * + * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * 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 + +#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 */ diff --git a/net/sixlowpan/sixlowpan_hc06.c b/net/sixlowpan/sixlowpan_hc06.c index 270c6f6885..d23a392e05 100644 --- a/net/sixlowpan/sixlowpan_hc06.c +++ b/net/sixlowpan/sixlowpan_hc06.c @@ -455,7 +455,7 @@ void sixlowpan_compresshdr_hc06(FAR struct ieee802154_driver_s *ieee, uint8_t iphc1; 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; diff --git a/net/sixlowpan/sixlowpan_input.c b/net/sixlowpan/sixlowpan_input.c index b89af933d8..5ee8b49017 100644 --- a/net/sixlowpan/sixlowpan_input.c +++ b/net/sixlowpan/sixlowpan_input.c @@ -470,7 +470,8 @@ copypayload: } #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; } diff --git a/net/sixlowpan/sixlowpan_tcpsend.c b/net/sixlowpan/sixlowpan_tcpsend.c index 2b0ce15cb3..3fd541999d 100644 --- a/net/sixlowpan/sixlowpan_tcpsend.c +++ b/net/sixlowpan/sixlowpan_tcpsend.c @@ -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.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 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 = ~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 g_netstats.tcp.sent++; diff --git a/net/sixlowpan/sixlowpan_udpsend.c b/net/sixlowpan/sixlowpan_udpsend.c index 61fbe3b237..53c7ead6ce 100644 --- a/net/sixlowpan/sixlowpan_udpsend.c +++ b/net/sixlowpan/sixlowpan_udpsend.c @@ -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.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 g_netstats.ipv6.sent++; diff --git a/wireless/ieee802154/mac802154_loopback.c b/wireless/ieee802154/mac802154_loopback.c index 5bbd6f5beb..595c085e8f 100644 --- a/wireless/ieee802154/mac802154_loopback.c +++ b/wireless/ieee802154/mac802154_loopback.c @@ -53,11 +53,8 @@ #include #include #include -#include - -#ifndef CONFIG_NET_LOOPBACK -# include -#endif +#include +#include #ifdef CONFIG_IEEE802154_LOOPBACK @@ -110,14 +107,6 @@ struct lo_driver_s static struct lo_driver_s g_loopback; 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 ****************************************************************************/ @@ -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: - * Initialize the Ethernet controller and driver + * Initialize and register the Ieee802.15.4 MAC loopback network driver. * * Parameters: - * intf - In the case where there are multiple EMACs, this value - * identifies which EMAC is to be initialized. + * None * * Returned Value: * 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 net_driver_s *dev; @@ -570,12 +558,6 @@ int localhost_initialize(void) (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 */ dev->d_flags = IFF_UP;