Merge remote-tracking branch 'origin/master' into ieee802154
This commit is contained in:
commit
ca7040b7c1
@ -807,6 +807,12 @@ pashello
|
||||
|
||||
Configures to use apps/examples/pashello.
|
||||
|
||||
sixlowpan
|
||||
|
||||
This configuration was intended only for unit-level testing of the
|
||||
6loWPAN stack. It enables networking with 6loWPAN support and uses
|
||||
only a IEEE802.15.4 MAC loopback network device to supported testing.
|
||||
|
||||
touchscreen
|
||||
|
||||
This configuration uses the simple touchscreen test at
|
||||
|
128
configs/sim/sixlowpan/Make.defs
Normal file
128
configs/sim/sixlowpan/Make.defs
Normal file
@ -0,0 +1,128 @@
|
||||
############################################################################
|
||||
# configs/sim/sixlowpan/Make.defs
|
||||
#
|
||||
# Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
include ${TOPDIR}/.config
|
||||
include ${TOPDIR}/tools/Config.mk
|
||||
|
||||
HOSTOS = ${shell uname -o 2>/dev/null || echo "Other"}
|
||||
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
ARCHOPTIMIZATION = -g
|
||||
endif
|
||||
|
||||
ifneq ($(CONFIG_DEBUG_NOOPT),y)
|
||||
ARCHOPTIMIZATION += -O2
|
||||
endif
|
||||
|
||||
ARCHCPUFLAGS = -fno-builtin
|
||||
ARCHCPUFLAGSXX = -fno-builtin -fno-exceptions -fcheck-new -fno-rtti
|
||||
ARCHPICFLAGS = -fpic
|
||||
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef
|
||||
ARCHWARNINGSXX = -Wall -Wshadow -Wundef
|
||||
ARCHDEFINES =
|
||||
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
|
||||
ARCHINCLUDESXX = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx
|
||||
ARCHSCRIPT =
|
||||
|
||||
ifeq ($(CONFIG_SIM_M32),y)
|
||||
ARCHCPUFLAGS += -m32
|
||||
ARCHCPUFLAGSXX += -m32
|
||||
endif
|
||||
|
||||
CROSSDEV =
|
||||
CC = $(CROSSDEV)gcc
|
||||
CXX = $(CROSSDEV)g++
|
||||
CPP = $(CROSSDEV)gcc -E
|
||||
LD = $(CROSSDEV)ld
|
||||
AR = $(CROSSDEV)ar rcs
|
||||
NM = $(CROSSDEV)nm
|
||||
OBJCOPY = $(CROSSDEV)objcopy
|
||||
OBJDUMP = $(CROSSDEV)objdump
|
||||
|
||||
CFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
|
||||
$(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
|
||||
CXXFLAGS = $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) \
|
||||
$(ARCHCPUFLAGSXX) $(ARCHINCLUDESXX) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
|
||||
CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES)
|
||||
AFLAGS = $(CFLAGS) -D__ASSEMBLY__
|
||||
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
CELFFLAGS = $(CFLAGS)
|
||||
CXXELFFLAGS = $(CXXFLAGS)
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
ifeq ($(WINTOOL),y)
|
||||
LDELFFLAGS += -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/gnu-elf.ld}"
|
||||
else
|
||||
LDELFFLAGS += -T $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/gnu-elf.ld
|
||||
endif
|
||||
|
||||
|
||||
ASMEXT = .S
|
||||
OBJEXT = .o
|
||||
LIBEXT = .a
|
||||
|
||||
ifeq ($(HOSTOS),Cygwin)
|
||||
EXEEXT = .exe
|
||||
else
|
||||
EXEEXT =
|
||||
endif
|
||||
|
||||
LDLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(LD)
|
||||
CCLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(CC)
|
||||
LDFLAGS = $(ARCHSCRIPT) # For backward compatibility, same as CCLINKFLAGS
|
||||
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
LDLINKFLAGS += -g
|
||||
CCLINKFLAGS += -g
|
||||
LDFLAGS += -g
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SIM_M32),y)
|
||||
LDLINKFLAGS += -melf_i386
|
||||
CCLINKFLAGS += -m32
|
||||
LDFLAGS += -m32
|
||||
endif
|
||||
|
||||
|
||||
MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT)
|
||||
|
||||
HOSTCC = gcc
|
||||
HOSTINCLUDES = -I.
|
||||
HOSTCFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
|
||||
$(ARCHCPUFLAGS) $(HOSTINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
|
||||
HOSTLDFLAGS =
|
1175
configs/sim/sixlowpan/defconfig
Normal file
1175
configs/sim/sixlowpan/defconfig
Normal file
File diff suppressed because it is too large
Load Diff
45
configs/sim/sixlowpan/setenv.sh
Normal file
45
configs/sim/sixlowpan/setenv.sh
Normal file
@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
# sim/sixlowpan/setenv.sh
|
||||
#
|
||||
# Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
if [ "$(basename $0)" = "setenv.sh" ] ; then
|
||||
echo "You must source this script, not run it!" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z ${PATH_ORIG} ]; then export PATH_ORIG=${PATH}; fi
|
||||
|
||||
#export NUTTX_BIN=
|
||||
#export PATH=${NUTTX_BIN}:/sbin:/usr/sbin:${PATH_ORIG}
|
||||
|
||||
echo "PATH : ${PATH}"
|
@ -42,22 +42,6 @@
|
||||
|
||||
#include "sim.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/clock.h>
|
||||
#include <nuttx/timers/oneshot.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_loopback.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
@ -547,7 +547,7 @@ bool net_ipv6addr_maskcmp(const net_ipv6addr_t addr1,
|
||||
|
||||
#define net_is_addr_loopback(a) \
|
||||
((a)[0] == 0 && (a)[1] == 0 && (a)[2] == 0 && (a)[3] == 0 && \
|
||||
(a)[4] == 0 && (a)[5] == 0 && (a)[6] == 0 && (a)[7] == 0x0001)
|
||||
(a)[4] == 0 && (a)[5] == 0 && (a)[6] == 0 && (a)[7] == HTONS(0x0001))
|
||||
|
||||
/****************************************************************************
|
||||
* Name: net_is_addr_unspecified
|
||||
@ -569,7 +569,7 @@ bool net_ipv6addr_maskcmp(const net_ipv6addr_t addr1,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#define net_is_addr_mcast(a) (((a)[0] & 0xff00) == 0xff00)
|
||||
#define net_is_addr_mcast(a) (((a)[0] & HTONS(0xff00)) == HTONS(0xff00))
|
||||
|
||||
/****************************************************************************
|
||||
* Name: net_is_addr_linklocal_allnodes_mcast
|
||||
@ -580,8 +580,8 @@ bool net_ipv6addr_maskcmp(const net_ipv6addr_t addr1,
|
||||
****************************************************************************/
|
||||
|
||||
#define net_is_addr_linklocal_allnodes_mcast(a) \
|
||||
((a)[0] == 0xff02 && (a)[1] == 0 && (a)[2] == 0 && (a)[3] == 0 && \
|
||||
(a)[4] == 0 && (a)[5] == 0 && (a)[6] == 0 && (a)[7] == 0x0001)
|
||||
((a)[0] == HTONS(0xff02) && (a)[1] == 0 && (a)[2] == 0 && (a)[3] == 0 && \
|
||||
(a)[4] == 0 && (a)[5] == 0 && (a)[6] == 0 && (a)[7] == HTONS(0x0001))
|
||||
|
||||
/****************************************************************************
|
||||
* Name: net_is_addr_linklocal_allrouters_mcast
|
||||
@ -592,8 +592,8 @@ bool net_ipv6addr_maskcmp(const net_ipv6addr_t addr1,
|
||||
****************************************************************************/
|
||||
|
||||
#define net_is_addr_linklocal_allrouters_mcast(a) \
|
||||
((a)[0] == 0xff02 && (a)[1] == 0 && (a)[2] == 0 && (a)[3] == 0 && \
|
||||
(a)[4] == 0 && (a)[5] == 0 && (a)[6] == 0 && (a)[7] == 0x0002)
|
||||
((a)[0] == HTONS(0xff02) && (a)[1] == 0 && (a)[2] == 0 && (a)[3] == 0 && \
|
||||
(a)[4] == 0 && (a)[5] == 0 && (a)[6] == 0 && (a)[7] == HTOS(0x0002))
|
||||
|
||||
/****************************************************************************
|
||||
* Name: net_is_addr_linklocal
|
||||
@ -603,7 +603,7 @@ bool net_ipv6addr_maskcmp(const net_ipv6addr_t addr1,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#define net_is_addr_linklocal(a) ((a)[0] == 0xfe80)
|
||||
#define net_is_addr_linklocal(a) ((a)[0] == HTONS(0xfe80))
|
||||
|
||||
/****************************************************************************
|
||||
* Name: net_ipaddr_mask
|
||||
|
73
include/nuttx/wireless/ieee802154/ieee802154_loopback.h
Normal file
73
include/nuttx/wireless/ieee802154/ieee802154_loopback.h
Normal 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 */
|
@ -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,21 @@
|
||||
#include "icmp/icmp.h"
|
||||
#include "icmpv6/icmpv6.h"
|
||||
#include "igmp/igmp.h"
|
||||
#include "sixlowpan/sixlowpan.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
enum devif_packet_type
|
||||
{
|
||||
DEVIF_PKT = 0,
|
||||
DEVIF_ICMP,
|
||||
DEVIF_IGMP,
|
||||
DEVIF_TCP,
|
||||
DEVIF_UDP,
|
||||
DEVIF_ICMP6
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
@ -68,6 +84,78 @@ systime_t g_polltime;
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Function: devif_packet_conversion
|
||||
*
|
||||
* Description:
|
||||
* Generic output conversion hook. Only needed for IEEE802.15.4 for now
|
||||
* is a point where support for other conversions may be provided.
|
||||
*
|
||||
* 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 void devif_packet_conversion(FAR struct net_driver_s *dev,
|
||||
enum devif_packet_type pkttype)
|
||||
{
|
||||
#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
|
||||
{
|
||||
if (pkttype == DEVIF_TCP)
|
||||
{
|
||||
FAR struct ipv6_hdr_s *ipv6 = (FAR struct ipv6_hdr_s *)dev->d_buf;
|
||||
|
||||
/* This packet came from a response to TCP polling and is directed
|
||||
* to an IEEE802.15.4 device using 6loWPAN. Verify that the outgoing
|
||||
* packet is IPv6 with TCP protocol.
|
||||
*/
|
||||
|
||||
if (ipv6->vtc == IPv6_VERSION && ipv6->proto == IP_PROTO_TCP)
|
||||
{
|
||||
/* Let 6loWPAN convert IPv6 TCP output into IEEE802.15.4 frames. */
|
||||
|
||||
sixlowpan_tcp_send(dev);
|
||||
}
|
||||
else
|
||||
{
|
||||
nerr("ERROR: IPv6 version or protocol error. Packet dropped\n");
|
||||
nerr(" IP version: %02x proocol: %u\n",
|
||||
ipv6->vtc, ipv6->proto);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nerr("ERROR: Non-TCP packet dropped. Packet type: %u\n", pkttype);
|
||||
}
|
||||
|
||||
dev->d_len = 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
# define devif_packet_conversion(dev,pkttype)
|
||||
#endif /* CONFIG_NET_6LOWPAN */
|
||||
|
||||
/****************************************************************************
|
||||
* Function: devif_poll_pkt_connections
|
||||
*
|
||||
@ -95,6 +183,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, DEVIF_PKT);
|
||||
|
||||
/* Call back into the driver */
|
||||
|
||||
bstop = callback(dev);
|
||||
@ -120,6 +212,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, DEVIF_ICMP);
|
||||
|
||||
/* Call back into the driver */
|
||||
|
||||
return callback(dev);
|
||||
@ -142,6 +238,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, DEVIF_ICMP6);
|
||||
|
||||
/* Call back into the driver */
|
||||
|
||||
return callback(dev);
|
||||
@ -168,6 +268,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, DEVIF_IGMP);
|
||||
|
||||
/* Call back into the driver */
|
||||
|
||||
return callback(dev);
|
||||
@ -201,6 +305,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, DEVIF_UDP);
|
||||
|
||||
/* Call back into the driver */
|
||||
|
||||
bstop = callback(dev);
|
||||
@ -237,6 +345,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, DEVIF_TCP);
|
||||
|
||||
/* Call back into the driver */
|
||||
|
||||
bstop = callback(dev);
|
||||
@ -277,6 +389,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, DEVIF_TCP);
|
||||
|
||||
/* Call back into the driver */
|
||||
|
||||
bstop = callback(dev);
|
||||
|
@ -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 */
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* net/procfs/netdev_statistics.c
|
||||
*
|
||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -47,6 +47,7 @@
|
||||
#include <netinet/ether.h>
|
||||
|
||||
#include <nuttx/net/netdev.h>
|
||||
#include <nuttx/net/sixlowpan.h>
|
||||
|
||||
#include "netdev/netdev.h"
|
||||
#include "utils/utils.h"
|
||||
@ -106,6 +107,9 @@ static const linegen_t g_linegen[] =
|
||||
static int netprocfs_linklayer(FAR struct netprocfs_file_s *netfile)
|
||||
{
|
||||
FAR struct net_driver_s *dev;
|
||||
#ifdef CONFIG_NET_6LOWPAN
|
||||
FAR struct ieee802154_driver_s *ieee;
|
||||
#endif
|
||||
FAR const char *status;
|
||||
int len = 0;
|
||||
|
||||
@ -142,6 +146,30 @@ static int netprocfs_linklayer(FAR struct netprocfs_file_s *netfile)
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN
|
||||
case NET_LL_IEEE802154:
|
||||
{
|
||||
ieee = (FAR struct ieee802154_driver_s *)dev;
|
||||
|
||||
#if CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 2
|
||||
len += snprintf(&netfile->line[len], NET_LINELEN - len,
|
||||
"%s\tLink encap:6loWPAN HWaddr %02x:%02x",
|
||||
dev->d_ifname,
|
||||
ieee->i_nodeaddr.u8[0], ieee->i_nodeaddr.u8[1]);
|
||||
#else /* CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 8 */
|
||||
len += snprintf(&netfile->line[len], NET_LINELEN - len,
|
||||
"%s\tLink encap:6loWPAN HWaddr "
|
||||
"%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
dev->d_ifname,
|
||||
ieee->i_nodeaddr.u8[0], ieee->i_nodeaddr.u8[1],
|
||||
ieee->i_nodeaddr.u8[2], ieee->i_nodeaddr.u8[3],
|
||||
ieee->i_nodeaddr.u8[4], ieee->i_nodeaddr.u8[5],
|
||||
ieee->i_nodeaddr.u8[6], ieee->i_nodeaddr.u8[7]);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_LOOPBACK
|
||||
case NET_LL_LOOPBACK:
|
||||
len += snprintf(&netfile->line[len], NET_LINELEN - len,
|
||||
@ -184,6 +212,26 @@ static int netprocfs_linklayer(FAR struct netprocfs_file_s *netfile)
|
||||
"%s\tLink encap:Ethernet HWaddr %s at %s\n",
|
||||
dev->d_ifname, ether_ntoa(&dev->d_mac), status);
|
||||
|
||||
#elif defined(CONFIG_NET_6LOWPAN)
|
||||
ieee = (FAR struct ieee802154_driver_s *)dev;
|
||||
|
||||
#if CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 2
|
||||
len += snprintf(&netfile->line[len], NET_LINELEN - len,
|
||||
"%s\tLink encap:6loWPAN HWaddr %02x:%02x at %s",
|
||||
dev->d_ifname,
|
||||
ieee->i_nodeaddr.u8[0], ieee->i_nodeaddr.u8[1],
|
||||
status);
|
||||
#else /* CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 8 */
|
||||
len += snprintf(&netfile->line[len], NET_LINELEN - len,
|
||||
"%s\tLink encap:6loWPAN HWaddr "
|
||||
"%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x at %s",
|
||||
dev->d_ifname,
|
||||
ieee->i_nodeaddr.u8[0], ieee->i_nodeaddr.u8[1],
|
||||
ieee->i_nodeaddr.u8[2], ieee->i_nodeaddr.u8[3],
|
||||
ieee->i_nodeaddr.u8[4], ieee->i_nodeaddr.u8[5],
|
||||
ieee->i_nodeaddr.u8[6], ieee->i_nodeaddr.u8[7],
|
||||
status);
|
||||
#endif
|
||||
#elif defined(CONFIG_NET_LOOPBACK)
|
||||
len += snprintf(&netfile->line[len], NET_LINELEN - len,
|
||||
"%s\tLink encap:Local Loopback at %s\n",
|
||||
|
@ -110,15 +110,20 @@ ssize_t psock_6lowpan_tcp_send(FAR struct socket *psock, FAR const void *buf,
|
||||
* Function: sixlowpan_tcp_send
|
||||
*
|
||||
* Description:
|
||||
* 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 psock_6lowpan_tcp_send().
|
||||
* 2. TCP output from the TCP state machine. That will occur
|
||||
* during TCP packet processing by the TCP state meachine. It
|
||||
* is detected there when ipv6_tcp_input() returns with d_len > 0. This
|
||||
* will be redirected here.
|
||||
* during TCP packet processing by the TCP state meachine.
|
||||
* 3. TCP output resulting from TX or timer polling
|
||||
*
|
||||
* Cases 2 and 3 will be handled here. Logic in ipv6_tcp_input(),
|
||||
* devif_poll(), and devif_timer() detect 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, this function will be called to create
|
||||
* the IEEE80215.4 frames.
|
||||
*
|
||||
* Parameters:
|
||||
* dev - An instance of nework device state structure
|
||||
|
@ -455,7 +455,8 @@ 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", (FAR const uint8_t *)ipv6,
|
||||
sizeof(struct ipv6_hdr_s));
|
||||
|
||||
g_hc06ptr = g_rimeptr + 2;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -243,7 +243,8 @@
|
||||
*/
|
||||
|
||||
#define SIXLOWPAN_IS_IID_16BIT_COMPRESSABLE(a) \
|
||||
((((a)[4]) == 0x0000) && (((a)[5]) == 0x00ff) && (((a)[6]) == 0xfe00))
|
||||
((((a)[4]) == 0x0000) && (((a)[5]) == HTONS(0x00ff)) && \
|
||||
(((a)[6]) == 0xfe00))
|
||||
|
||||
/* Check whether the 9-bit group-id of the compressed multicast address is
|
||||
* known. It is true if the 9-bit group is the all nodes or all routers
|
||||
@ -265,27 +266,27 @@
|
||||
#define SIXLOWPAN_IS_MCASTADDR_COMPRESSABLE(a) \
|
||||
((a)[1] == 0 && (a)[2] == 0 && (a)[3] == 0 && \
|
||||
(a)[4] == 0 && (a)[5] == 0 && (a)[6] == 0 && \
|
||||
((a)[7] == 0x0001 || (a)[7] == 0x0002))
|
||||
((a)[7] == HTONS(0x0001) || (a)[7] == HTONS(0x0002)))
|
||||
|
||||
/* FFXX:0000:0000:0000:0000:00XX:XXXX:XXXX */
|
||||
|
||||
#define SIXLOWPAN_IS_MCASTADDR_COMPRESSABLE48(a) \
|
||||
((a)[1] == 0 && (a)[2] == 0 && (a)[3] == 0 && \
|
||||
(a)[4] == 0 && (((a)[5] & 0xff00) == 0))
|
||||
(a)[4] == 0 && (((a)[5] & HTONS(0xff00)) == 0))
|
||||
|
||||
/* FFXX:0000:0000:0000:0000:0000:00XX:XXXX */
|
||||
|
||||
#define SIXLOWPAN_IS_MCASTADDR_COMPRESSABLE32(a) \
|
||||
((a)[1] == 0 && (a)[2] == 0 && (a)[3] == 0 && \
|
||||
(a)[4] == 0 && (a)[5] == 0 && ((a)[6] & 0xff00) == 0)
|
||||
(a)[4] == 0 && (a)[5] == 0 && ((a)[6] & HTONS(0xff00)) == 0)
|
||||
|
||||
/* FF02:0000:0000:0000:0000:0000:0000:00XX */
|
||||
|
||||
#define SIXLOWPAN_IS_MCASTADDR_COMPRESSABLE8(a) \
|
||||
((((a)[0] & 0x00ff) == 0x0002) && \
|
||||
((((a)[0] & HTONS(0x00ff)) == HTONS(0x0002)) && \
|
||||
(a)[1] == 0 && (a)[2] == 0 && (a)[3] == 0 && \
|
||||
(a)[4] == 0 && (a)[5] == 0 && (a)[6] == 0 && \
|
||||
(((a)[7] & 0xff00) == 0x0000))
|
||||
(((a)[7] & HTONS(0xff00)) == 0x0000))
|
||||
|
||||
/* General helper macros ****************************************************/
|
||||
|
||||
|
@ -155,6 +155,8 @@ ssize_t psock_6lowpan_tcp_send(FAR struct socket *psock, FAR const void *buf,
|
||||
uint16_t iplen;
|
||||
int ret;
|
||||
|
||||
ninfo("buflen %lu\n", (unsigned long)buflen);
|
||||
|
||||
DEBUGASSERT(psock != NULL && psock->s_crefs > 0);
|
||||
DEBUGASSERT(psock->s_type == SOCK_STREAM);
|
||||
|
||||
@ -249,7 +251,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 +292,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++;
|
||||
@ -332,15 +335,20 @@ ssize_t psock_6lowpan_tcp_send(FAR struct socket *psock, FAR const void *buf,
|
||||
* Function: sixlowpan_tcp_send
|
||||
*
|
||||
* Description:
|
||||
* 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 psock_6lowpan_tcp_send().
|
||||
* 2. TCP output from the TCP state machine. That will occur
|
||||
* during TCP packet processing by the TCP state meachine. It
|
||||
* is detected there when ipv6_tcp_input() returns with d_len > 0. This
|
||||
* will be redirected here.
|
||||
* during TCP packet processing by the TCP state meachine.
|
||||
* 3. TCP output resulting from TX or timer polling
|
||||
*
|
||||
* Cases 2 and 3 will be handled here. Logic in ipv6_tcp_input(),
|
||||
* devif_poll(), and devif_timer() detect 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, this function will be called to create
|
||||
* the IEEE80215.4 frames.
|
||||
*
|
||||
* Parameters:
|
||||
* dev - An instance of nework device state structure
|
||||
@ -359,6 +367,8 @@ void sixlowpan_tcp_send(FAR struct net_driver_s *dev)
|
||||
|
||||
/* Double check */
|
||||
|
||||
ninfo("d_len %u\n", dev->d_len);
|
||||
|
||||
if (dev != NULL && dev->d_len > 0)
|
||||
{
|
||||
FAR struct ipv6_hdr_s *ipv6hdr;
|
||||
@ -383,10 +393,10 @@ void sixlowpan_tcp_send(FAR struct net_driver_s *dev)
|
||||
size_t hdrlen;
|
||||
|
||||
hdrlen = IPv6_HDRLEN + TCP_HDRLEN;
|
||||
if (hdrlen < dev->d_len)
|
||||
if (hdrlen > dev->d_len)
|
||||
{
|
||||
nwarn("WARNING: Packet to small: Have %u need >%u\n",
|
||||
dev->d_len, hdrlen);
|
||||
dev->d_len, hdrlen);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -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++;
|
||||
|
@ -116,7 +116,7 @@ void sixlowpan_ipfromrime(FAR const struct rimeaddr_s *rime,
|
||||
net_ipv6addr_t ipaddr)
|
||||
{
|
||||
memset(ipaddr, 0, sizeof(net_ipv6addr_t));
|
||||
ipaddr[0] = 0xfe80;
|
||||
ipaddr[0] = HTONS(0xfe80);
|
||||
|
||||
/* We consider only links with IEEE EUI-64 identifier or IEEE 48-bit MAC
|
||||
* addresses. NOTE: that CONFIG_NET_6LOWPAN_RIMEADDR_SIZE may be 2 or
|
||||
@ -128,7 +128,7 @@ void sixlowpan_ipfromrime(FAR const struct rimeaddr_s *rime,
|
||||
*/
|
||||
|
||||
memcpy(&ipaddr[4], rime, CONFIG_NET_6LOWPAN_RIMEADDR_SIZE);
|
||||
ipaddr[4] ^= 0x0200;
|
||||
ipaddr[4] ^= HTONS(0x0200);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -174,10 +174,10 @@ bool sixlowpan_ismacbased(const net_ipv6addr_t ipaddr,
|
||||
FAR const uint8_t *rimeptr = rime->u8;
|
||||
|
||||
#if CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 2
|
||||
return ((ipaddr[4] == (GETINT16(rimeptr, 0) ^ 0x0200)) &&
|
||||
return ((ipaddr[4] == htons((GETINT16(rimeptr, 0) ^ 0x0200))) &&
|
||||
ipaddr[5] == 0 && ipaddr[6] == 0 && ipaddr[7] == 0);
|
||||
#else /* CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 8 */
|
||||
return ((ipaddr[4] == (GETINT16(rimeptr, 0) ^ 0x0200)) &&
|
||||
return ((ipaddr[4] == htons((GETINT16(rimeptr, 0) ^ 0x0200))) &&
|
||||
ipaddr[5] == GETINT16(rimeptr, 2) &&
|
||||
ipaddr[6] == GETINT16(rimeptr, 4) &&
|
||||
ipaddr[7] == GETINT16(rimeptr, 6));
|
||||
|
@ -250,7 +250,6 @@ int tcp_local_ipv6_device(FAR struct tcp_conn_s *conn)
|
||||
#else
|
||||
return tcp_find_ipv6_device(conn, NULL);
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
|
||||
|
@ -45,29 +45,6 @@ config IEEE802154_LOOPBACK
|
||||
---help---
|
||||
Add support for the IEEE802154 6loWPAN Loopback test device.
|
||||
|
||||
if IEEE802154_LOOPBACK
|
||||
|
||||
choice
|
||||
prompt "Work queue"
|
||||
default IEEE802154_LOOPBACK_LPWORK if SCHED_LPWORK
|
||||
default IEEE802154_LOOPBACK_HPWORK if !SCHED_LPWORK && SCHED_HPWORK
|
||||
depends on SCHED_WORKQUEUE
|
||||
---help---
|
||||
Work queue support is required to use the loopback driver. If the
|
||||
low priority work queue is available, then it should be used by the
|
||||
loopback driver.
|
||||
|
||||
config IEEE802154_LOOPBACK_HPWORK
|
||||
bool "High priority"
|
||||
depends on SCHED_HPWORK
|
||||
|
||||
config IEEE802154_LOOPBACK_LPWORK
|
||||
bool "Low priority"
|
||||
depends on SCHED_LPWORK
|
||||
|
||||
endchoice # Work queue
|
||||
endif # IEEE802154_LOOPBACK
|
||||
|
||||
config IEEE802154_LOOPBACK
|
||||
bool "IEEE802154 6loWPAN Loopback"
|
||||
default n
|
||||
@ -99,4 +76,4 @@ config IEEE802154_LOOPBACK_LPWORK
|
||||
endchoice # Work queue
|
||||
endif # IEEE802154_LOOPBACK
|
||||
|
||||
endif # IEEE802154
|
||||
endif # WIRELESS_IEEE802154
|
||||
|
@ -53,11 +53,8 @@
|
||||
#include <nuttx/wqueue.h>
|
||||
#include <nuttx/net/net.h>
|
||||
#include <nuttx/net/ip.h>
|
||||
#include <nuttx/net/loopback.h>
|
||||
|
||||
#ifndef CONFIG_NET_LOOPBACK
|
||||
# include <nuttx/net/sixlowpan.h>
|
||||
#endif
|
||||
#include <nuttx/net/sixlowpan.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_loopback.h>
|
||||
|
||||
#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
|
||||
****************************************************************************/
|
||||
@ -173,6 +162,22 @@ static int lo_txpoll(FAR struct net_driver_s *dev)
|
||||
FAR struct iob_s *iob;
|
||||
int ret;
|
||||
|
||||
if (dev->d_len > 0 || priv->lo_ieee.i_framelist != NULL)
|
||||
{
|
||||
ninfo("d_len: %u i_framelist: %p\n",
|
||||
dev->d_len, priv->lo_ieee.i_framelist);
|
||||
|
||||
/* The only two valid settings are:
|
||||
*
|
||||
* 1. Nothing to send:
|
||||
* dev->d_len == 0 && priv->lo_ieee.i_framelist == NULL
|
||||
* 2. Outgoing packet has been converted to IEEE802.15.4 frames:
|
||||
* dev->d_len == 0 && priv->lo_ieee.i_framelist != NULL
|
||||
*/
|
||||
|
||||
DEBUGASSERT(dev->d_len == 0 && priv->lo_ieee.i_framelist != NULL);
|
||||
}
|
||||
|
||||
/* Remove the queued IOBs from driver structure */
|
||||
|
||||
head = priv->lo_ieee.i_framelist;
|
||||
@ -309,6 +314,11 @@ static void lo_poll_expiry(int argc, wdparm_t arg, ...)
|
||||
{
|
||||
FAR struct lo_driver_s *priv = (FAR struct lo_driver_s *)arg;
|
||||
|
||||
if (!work_available(&priv->lo_work))
|
||||
{
|
||||
nwarn("WARNING: lo_work NOT available\n");
|
||||
}
|
||||
|
||||
/* Schedule to perform the interrupt processing on the worker thread. */
|
||||
|
||||
work_queue(LPBKWORK, &priv->lo_work, lo_poll_work, priv, 0);
|
||||
@ -335,14 +345,22 @@ static int lo_ifup(FAR struct net_driver_s *dev)
|
||||
{
|
||||
FAR struct lo_driver_s *priv = (FAR struct lo_driver_s *)dev->d_private;
|
||||
|
||||
#if CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 2
|
||||
ninfo("Bringing up: Rime %02x:%02x PANID=%04x\n",
|
||||
dev->d_ipv6addr[0], dev->d_ipv6addr[1], priv->lo_ieee.i_panid);
|
||||
#elif CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 8
|
||||
ninfo("Bringing up: Rime %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x PANID=%04x\n",
|
||||
ninfo("Bringing up: IPv6 %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
|
||||
dev->d_ipv6addr[0], dev->d_ipv6addr[1], dev->d_ipv6addr[2],
|
||||
dev->d_ipv6addr[3], dev->d_ipv6addr[4], dev->d_ipv6addr[5],
|
||||
dev->d_ipv6addr[6], dev->d_ipv6addr[7], priv->lo_ieee.i_panid);
|
||||
dev->d_ipv6addr[6], dev->d_ipv6addr[7]);
|
||||
|
||||
#if CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 2
|
||||
ninfo(" Node: %02x:%02x PANID=%04x\n",
|
||||
priv->lo_ieee.i_nodeaddr.u8[0], priv->lo_ieee.i_nodeaddr.u8[1],
|
||||
priv->lo_ieee.i_panid);
|
||||
#else /* CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 8 */
|
||||
ninfo(" Node: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x PANID=%04x\n",
|
||||
priv->lo_ieee.i_nodeaddr.u8[0], priv->lo_ieee.i_nodeaddr.u8[1],
|
||||
priv->lo_ieee.i_nodeaddr.u8[2], priv->lo_ieee.i_nodeaddr.u8[3],
|
||||
priv->lo_ieee.i_nodeaddr.u8[4], priv->lo_ieee.i_nodeaddr.u8[5],
|
||||
priv->lo_ieee.i_nodeaddr.u8[6], priv->lo_ieee.i_nodeaddr.u8[7],
|
||||
priv->lo_ieee.i_panid);
|
||||
#endif
|
||||
|
||||
/* Set and activate a timer process */
|
||||
@ -374,6 +392,8 @@ static int lo_ifdown(FAR struct net_driver_s *dev)
|
||||
{
|
||||
FAR struct lo_driver_s *priv = (FAR struct lo_driver_s *)dev->d_private;
|
||||
|
||||
ninfo("IP up: %u\n", priv->lo_bifup);
|
||||
|
||||
/* Cancel the TX poll timer and TX timeout timers */
|
||||
|
||||
wd_cancel(priv->lo_polldog);
|
||||
@ -405,6 +425,8 @@ static void lo_txavail_work(FAR void *arg)
|
||||
{
|
||||
FAR struct lo_driver_s *priv = (FAR struct lo_driver_s *)arg;
|
||||
|
||||
ninfo("IP up: %u\n", priv->lo_bifup);
|
||||
|
||||
/* Ignore the notification if the interface is not yet up */
|
||||
|
||||
net_lock();
|
||||
@ -446,6 +468,8 @@ static int lo_txavail(FAR struct net_driver_s *dev)
|
||||
{
|
||||
FAR struct lo_driver_s *priv = (FAR struct lo_driver_s *)dev->d_private;
|
||||
|
||||
ninfo("Available: %u\n", work_available(&priv->lo_work));
|
||||
|
||||
/* Is our single work structure available? It may not be if there are
|
||||
* pending interrupt actions and we will have to ignore the Tx
|
||||
* availability action.
|
||||
@ -482,6 +506,14 @@ static int lo_txavail(FAR struct net_driver_s *dev)
|
||||
#if defined(CONFIG_NET_IGMP) || defined(CONFIG_NET_ICMPv6)
|
||||
static int lo_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac)
|
||||
{
|
||||
#if CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 2
|
||||
ninfo("MAC: %02x:%02x\n",
|
||||
mac[0], mac[1]);
|
||||
#else /* CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 8 */
|
||||
ninfo("MAC: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], mac[6], mac[7]);
|
||||
#endif
|
||||
|
||||
/* There is no multicast support in the loopback driver */
|
||||
|
||||
return OK;
|
||||
@ -509,6 +541,14 @@ static int lo_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac)
|
||||
#ifdef CONFIG_NET_IGMP
|
||||
static int lo_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac)
|
||||
{
|
||||
#if CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 2
|
||||
ninfo("MAC: %02x:%02x\n",
|
||||
mac[0], mac[1]);
|
||||
#else /* CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 8 */
|
||||
ninfo("MAC: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], mac[6], mac[7]);
|
||||
#endif
|
||||
|
||||
/* There is no multicast support in the loopback driver */
|
||||
|
||||
return OK;
|
||||
@ -520,14 +560,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,11 +575,13 @@ 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;
|
||||
|
||||
ninfo("Initializing\n");
|
||||
|
||||
/* Get the interface structure associated with this interface number. */
|
||||
|
||||
priv = &g_loopback;
|
||||
@ -570,12 +611,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;
|
||||
|
Loading…
Reference in New Issue
Block a user