1
0
Fork 0
forked from nuttx/nuttx-update

Squashed commit of the following:

commit 5b7b6e6e616c475c782e9883ada9f4a3b7cb4e2c
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Sun Aug 20 11:13:17 2017 -0600

    IEEE 802.15.4 network device:  Make same changes as per loopback device so that it will build with PF_IEEE802154 but without 6LoWPAN.

commit d656a98cf8eab2f20e884224b52cd47ec35df4cc
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Sun Aug 20 10:31:28 2017 -0600

    PF_IEEE802154: More fixes to device registration and to IEEE 802.15.4 loopback driver for PF_IEEE802154 without 6LoWPAN.

commit 866bb9cbb0c5af79734bbd434c07fa2560b6608f
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Sun Aug 20 09:58:13 2017 -0600

    Network: Reorganize some Kconfig selections.

commit 230b4cb48008cba5fccdafa22340df1d43584829
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Sun Aug 20 09:19:53 2017 -0600

    Changes to conditional compilation so that PF_IEEE802154 can build without 6LoWPAN

commit d96cbd6520d40590a740f695c4cd72208ce872da
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Sun Aug 20 09:17:02 2017 -0600

    configs/sim/pf_ieee802154: Disable 6LoWPAN, IPv6, TCP, and UDP.  Now things do not build
This commit is contained in:
Gregory Nutt 2017-08-20 11:14:43 -06:00
parent 6919fb85e4
commit 0438783afa
11 changed files with 201 additions and 109 deletions

View file

@ -2,7 +2,6 @@
# CONFIG_MMCSD_SPI is not set
# CONFIG_NET_ETHERNET is not set
# CONFIG_NET_IPv4 is not set
# CONFIG_NET_UDP_CHECKSUMS is not set
# CONFIG_NSH_CMDOPT_DF_H is not set
# CONFIG_SIM_NETDEV is not set
CONFIG_ARCH_BOARD_SIM=y
@ -23,29 +22,10 @@ CONFIG_DEBUG_FEATURES=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DISABLE_POLL=y
CONFIG_DRIVERS_WIRELESS=y
CONFIG_EXAMPLES_NETTEST_DAEMON_STACKSIZE=4096
CONFIG_EXAMPLES_NETTEST_LOOPBACK=y
CONFIG_EXAMPLES_NETTEST_SERVER_PORTNO=61616
CONFIG_EXAMPLES_NETTEST_SERVERIPv6ADDR_1=0xfe80
CONFIG_EXAMPLES_NETTEST_SERVERIPv6ADDR_6=0x00ff
CONFIG_EXAMPLES_NETTEST_SERVERIPv6ADDR_7=0xfe00
CONFIG_EXAMPLES_NETTEST_SERVERIPv6ADDR_8=0xcda9
CONFIG_EXAMPLES_NETTEST_STACKSIZE1=4096
CONFIG_EXAMPLES_NETTEST=y
CONFIG_EXAMPLES_NSH=y
CONFIG_EXAMPLES_PFIEEE802154_STACKSIZE1=8192
CONFIG_EXAMPLES_PFIEEE802154_STACKSIZE2=8192
CONFIG_EXAMPLES_PFIEEE802154=y
CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_1=0xfe80
CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_6=0x00ff
CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_7=0xfe00
CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_8=0x1034
CONFIG_EXAMPLES_UDPBLASTER_STACKSIZE=8192
CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_1=0xfe80
CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_6=0x00ff
CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_7=0xfe00
CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_8=0xa9cd
CONFIG_EXAMPLES_UDPBLASTER=y
CONFIG_EXPERIMENTAL=y
CONFIG_FAT_LCNAMES=y
CONFIG_FAT_LFN=y
@ -64,24 +44,13 @@ CONFIG_MTD_AT24XX=y
CONFIG_MTD_AT25=y
CONFIG_MTD_CONFIG=y
CONFIG_MTD=y
CONFIG_NET_6LOWPAN_TCP_RECVWNDO=102
CONFIG_NET_6LOWPAN=y
CONFIG_NET_BROADCAST=y
CONFIG_NET_HOSTNAME="SAMV71-XULT"
CONFIG_NET_IEEE802154=y
CONFIG_NET_IEEE802154_NCONNS=4
CONFIG_NET_IPv6=y
CONFIG_NET_SOCKOPTS=y
CONFIG_NET_STATISTICS=y
CONFIG_NET_TCP_WRITE_BUFFERS=y
CONFIG_NET_TCP=y
CONFIG_NET_TCPBACKLOG=y
CONFIG_NET_UDP=y
CONFIG_NET=y
CONFIG_NETDB_DNSCLIENT=y
CONFIG_NETDEV_PHY_IOCTL=y
CONFIG_NETDEV_STATISTICS=y
CONFIG_NETDEV_TELNET=y
CONFIG_NETDEVICES=y
CONFIG_NFILE_DESCRIPTORS=8
CONFIG_NFILE_STREAMS=8

View file

@ -182,7 +182,7 @@ struct netdev_statistics_s
};
#endif
#ifdef CONFIG_NET_6LOWPAN
#if defined(CONFIG_NET_6LOWPAN) || defined(CONFIG_NET_IEEE802154)
/* This structure is used to represent addresses of varying length. This
* structure is used to represent the address assigned to a radio.
*/
@ -236,7 +236,9 @@ struct net_driver_s
uint16_t d_recvwndo; /* TCP receive window size */
#endif
#if defined(CONFIG_NET_ETHERNET) || defined(CONFIG_NET_6LOWPAN)
#if defined(CONFIG_NET_ETHERNET) || defined(CONFIG_NET_6LOWPAN) || \
defined(CONFIG_NET_IEEE802154)
/* Link layer address */
union
@ -251,9 +253,9 @@ struct net_driver_s
/* The address assigned to an IEEE 802.15.4 or generic packet radio. */
struct netdev_varaddr_s radio;
#endif /* CONFIG_NET_6LOWPAN */
#endif /* CONFIG_NET_6LOWPAN || CONFIG_NET_IEEE802154 */
} d_mac;
#endif /* CONFIG_NET_ETHERNET || CONFIG_NET_6LOWPAN */
#endif /* CONFIG_NET_ETHERNET || CONFIG_NET_6LOWPAN || CONFIG_NET_IEEE802154 */
/* Network identity */

View file

@ -51,7 +51,7 @@
#include <stdint.h>
#include <stdbool.h>
#ifdef CONFIG_NET_6LOWPAN
#if defined(CONFIG_NET_6LOWPAN) || defined(CONFIG_NET_IEEE802154)
# include <net/if.h>
#endif
@ -1581,7 +1581,7 @@ union ieee802154_macarg_u
/* To be determined */ /* MAC802154IOC_MLME_CALIBRATE_REQUEST */
};
#ifdef CONFIG_NET_6LOWPAN
#if defined(CONFIG_NET_6LOWPAN) || defined(CONFIG_NET_IEEE802154)
/* For the case of network IOCTLs, the network IOCTL to the MAC network
* driver will include a device name like "wpan0" as the destination of
* the IOCTL command.

View file

@ -108,7 +108,7 @@ config NET_GUARDSIZE
endmenu # Driver buffer configuration
menu "Data link support"
menu "Link layer support"
config NET_USER_DEVFMT
bool "User provided devfmt"
@ -125,15 +125,10 @@ config NET_ETHERNET
no need to define anything special in the configuration file to use
Ethernet -- it is the default).
config NET_6LOWPAN
bool "6LoWPAN support"
default n
select NETDEV_IOCTL
select NET_HAVE_STAR
depends on NET_IPv6
---help---
Enable support for Low power Wireless Personal Area Networking (6LoWPAN)
for IEEE 802.15.4 or other packet radios.
#menu "IEEE 802.15.4"
# depends on WIRELESS_IEEE802154
#
#endmenu # IEEE 802.15.4
config NET_LOOPBACK
bool "Local loopback"
@ -141,7 +136,7 @@ config NET_LOOPBACK
---help---
Add support for the local network loopback device, lo.
config NET_SLIP
menuconfig NET_SLIP
bool "SLIP support"
default n
---help---
@ -186,7 +181,7 @@ config SLIP_DEFPRIO
endif # NET_SLIP
config NET_TUN
menuconfig NET_TUN
bool "TUN Virtual Network Device support"
default n
select ARCH_HAVE_NETDEV_STATISTICS
@ -262,13 +257,24 @@ config NET_IPv4
---help---
Build in support for IPv4.
menuconfig NET_IPv6
config NET_IPv6
bool "IPv6"
default n
---help---
Build in support for IPv6.
source "net/neighbor/Kconfig"
menuconfig NET_6LOWPAN
bool "6LoWPAN support"
default n
select NETDEV_IOCTL
select NET_HAVE_STAR
depends on NET_IPv6
---help---
Enable support for Low power Wireless Personal Area Networking (6LoWPAN)
for IEEE 802.15.4 or other packet radios.
source "net/sixlowpan/Kconfig"
source "net/ipforward/Kconfig"

View file

@ -8,7 +8,7 @@ menu "IEEE 802.15.4 socket support"
config NET_IEEE802154
bool "IEEE 802.15.4 socket support"
default n
depends on NET_IPv6 && WIRELESS_IEEE802154
depends on WIRELESS_IEEE802154
select NETDEV_IOCTL
---help---
Enable support for raw, IEEE 802.15.4 sockets.

View file

@ -76,9 +76,19 @@
#define IEEE802154_MAC_FCSSIZE 2
/* This, then, is the usable size of the frame */
/* This, then, is the usable size of the frame...
* REVISIT: Too many frame length definitions
*/
#define IEEE802154_FRAMELEN (CONFIG_NET_IEEE802154_FRAMELEN - IEEE802154_MAC_FCSSIZE)
#if defined(CONFIG_NET_6LOWPAN_FRAMELEN)
# define IEEE802_MAX_FRAMELEN CONFIG_NET_6LOWPAN_FRAMELEN
#elif defined(CONFIG_NET_IEEE802154_FRAMELEN)
# define IEEE802_MAX_FRAMELEN CONFIG_NET_IEEE802154_FRAMELEN
#else
# define IEEE802_MAX_FRAMELEN IEEE802154_MAC_STDFRAME
#endif
#define IEEE802154_FRAMELEN (IEEE802_MAX_FRAMELEN - IEEE802154_MAC_FCSSIZE)
/****************************************************************************
* Public Type Definitions

View file

@ -214,13 +214,15 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype)
break;
#endif
#ifdef CONFIG_NET_6LOWPAN
#if defined(CONFIG_NET_6LOWPAN) || defined(CONFIG_NET_IEEE802154)
case NET_LL_IEEE802154: /* IEEE 802.15.4 MAC */
case NET_LL_PKTRADIO: /* Non-IEEE 802.15.4 packet radio */
dev->d_llhdrlen = 0;
#ifdef CONFIG_NET_6LOWPAN
dev->d_mtu = CONFIG_NET_6LOWPAN_MTU;
#ifdef CONFIG_NET_TCP
dev->d_recvwndo = CONFIG_NET_6LOWPAN_TCP_RECVWNDO;
#endif
#endif
devfmt = NETDEV_WPAN_FORMAT;
break;

View file

@ -3,8 +3,7 @@
# see the file kconfig-language.txt in the NuttX tools repository.
#
menu "6LoWPAN Configuration"
depends on NET_6LOWPAN
if NET_6LOWPAN
config NET_6LOWPAN_FRAG
bool "6LoWPAN Fragmentation"
@ -13,15 +12,6 @@ config NET_6LOWPAN_FRAG
CONFIG_NET_6LOWPAN_FRAG specifies if 6lowpan fragmentation should be
used or not. Fragmentation is on by default.
config NET_6LOWPAN_FRAMELEN
int "Max Radio Frame Size"
default 127
range 1 999999
---help---
Wireless devices use a variety of frame sizes. For IEEE 802.15.4
radios, this should be 127 bytes. However, some IEEE 802.15.4
radios may non-standard frame lengths.
choice
prompt "6LoWPAN Compression"
default NET_6LOWPAN_COMPRESSION_HC06
@ -200,4 +190,4 @@ config NET_6LOWPAN_DUMPBUFFER
of the 6LoWPAN logic. This will generate a large volume of data if
selected.
endmenu # 6LoWPAN Configuration
endif # NET_6LOWPAN

View file

@ -165,7 +165,7 @@ endif # IEEE802154_MACDEV
config IEEE802154_NETDEV
bool "IEEE802154 6LoWPAN Network Device"
default n
depends on NET_6LOWPAN && NET_IPv6
depends on NET_6LOWPAN || NET_IEEE802154
select ARCH_HAVE_NETDEV_STATISTICS
---help---
Add support for the IEEE802.15.4 6LoWPAN network device built on
@ -224,7 +224,7 @@ endif # IEEE802154_NETDEV
config IEEE802154_LOOPBACK
bool "IEEE802154 6LoWPAN Loopback"
default n
depends on NET_6LOWPAN && NET_IPv6
depends on NET_6LOWPAN || NET_IEEE802154
select ARCH_HAVE_NETDEV_STATISTICS
---help---
Add support for the IEEE802.15.4 6LoWPAN Loopback test device.

View file

@ -80,6 +80,26 @@
# endif
#endif
/* Preferred address size */
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
# define LO_ADDRSIZE IEEE802154_EADDRSIZE
#else
# define LO_ADDRSIZE IEEE802154_SADDRSIZE
#endif
/* Frame size
* REVISIT: Too many frame length definitions
*/
#if defined(CONFIG_NET_6LOWPAN_FRAMELEN)
# define LO_FRAMELEN CONFIG_NET_6LOWPAN_FRAMELEN
#elif defined(CONFIG_NET_IEEE802154_FRAMELEN)
# define LO_FRAMELEN CONFIG_NET_IEEE802154_FRAMELEN
#else
# define LO_FRAMELEN IEEE802154_MAX_PHY_PACKET_SIZE
#endif
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */
#define LO_WDDELAY (1*CLK_TCK)
@ -116,7 +136,9 @@ struct lo_driver_s
****************************************************************************/
static struct lo_driver_s g_loopback;
#ifdef CONFIG_NET_6LOWPAN
static uint8_t g_iobuffer[CONFIG_NET_6LOWPAN_MTU + CONFIG_NET_GUARDSIZE];
#endif
static uint8_t g_eaddr[IEEE802154_EADDRSIZE] =
{
@ -193,9 +215,10 @@ static void lo_addr2ip(FAR struct net_driver_s *dev)
{
/* Set the MAC address as the eaddr */
dev->d_mac.radio.nv_addrlen = NET_6LOWPAN_EADDRSIZE;
dev->d_mac.radio.nv_addrlen = IEEE802154_EADDRSIZE;
IEEE802154_EADDRCOPY(dev->d_mac.radio.nv_addr, g_eaddr);
#ifdef CONFIG_NET_IPv6
/* Set the IP address based on the eaddr */
dev->d_ipv6addr[0] = HTONS(0xfe80);
@ -208,14 +231,16 @@ static void lo_addr2ip(FAR struct net_driver_s *dev)
dev->d_ipv6addr[7] = (uint16_t)g_eaddr[6] << 8 | (uint16_t)g_eaddr[7];
dev->d_ipv6addr[4] ^= 0x200;
}
#endif
#else
static void lo_addr2ip(FAR struct net_driver_s *dev)
{
/* Set the MAC address as the saddr */
dev->d_mac.radio.nv_addrlen = NET_6LOWPAN_SADDRSIZE;
dev->d_mac.radio.nv_addrlen = IEEE802154_SADDRSIZE;
IEEE802154_SADDRCOPY(dev->d_mac.radio.nv_addr, g_saddr);
#ifdef CONFIG_NET_IPv6
/* Set the IP address based on the saddr */
dev->d_ipv6addr[0] = HTONS(0xfe80);
@ -227,6 +252,7 @@ static void lo_addr2ip(FAR struct net_driver_s *dev)
dev->d_ipv6addr[6] = HTONS(0xfe00);
dev->d_ipv6addr[7] = (uint16_t)g_saddr[0] << 8 | (uint16_t)g_saddr[1];
dev->d_ipv6addr[7] ^= 0x200;
#endif
}
#endif
@ -246,6 +272,7 @@ static void lo_addr2ip(FAR struct net_driver_s *dev)
static inline void lo_netmask(FAR struct net_driver_s *dev)
{
#ifdef CONFIG_NET_IPv6
dev->d_ipv6netmask[0] = 0xffff;
dev->d_ipv6netmask[1] = 0xffff;
dev->d_ipv6netmask[2] = 0xffff;
@ -261,6 +288,7 @@ static inline void lo_netmask(FAR struct net_driver_s *dev)
dev->d_ipv6netmask[6] = 0xffff;
dev->d_ipv6netmask[7] = 0;
#endif
#endif
}
/****************************************************************************
@ -496,11 +524,11 @@ static int lo_ifup(FAR struct net_driver_s *dev)
{
FAR struct lo_driver_s *priv = (FAR struct lo_driver_s *)dev->d_private;
#ifdef CONFIG_NET_IPv6
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]);
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
ninfo(" Node: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x PANID=%02x:%02x\n",
dev->d_mac.radio.nv_addr[0], dev->d_mac.radio.nv_addr[1],
@ -513,6 +541,27 @@ static int lo_ifup(FAR struct net_driver_s *dev)
dev->d_mac.radio.nv_addr[0], dev->d_mac.radio.nv_addr[1],
priv->lo_panid[0], priv->lo_panid[1]);
#endif
#else
if (dev->d_mac.radio.nv_addrlen == 8)
{
ninfo("Bringing up: Node: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x PANID=%02x:%02x\n",
dev->d_mac.radio.nv_addr[0], dev->d_mac.radio.nv_addr[1],
dev->d_mac.radio.nv_addr[2], dev->d_mac.radio.nv_addr[3],
dev->d_mac.radio.nv_addr[4], dev->d_mac.radio.nv_addr[5],
dev->d_mac.radio.nv_addr[6], dev->d_mac.radio.nv_addr[7],
priv->lo_panid[0], priv->lo_panid[1]);
}
else if (dev->d_mac.radio.nv_addrlen == 2)
{
ninfo("Bringing up: Node: %02x:%02x PANID=%02x:%02x\n",
dev->d_mac.radio.nv_addr[0], dev->d_mac.radio.nv_addr[1],
priv->lo_panid[0], priv->lo_panid[1]);
}
else
{
nerr("ERROR: No address assigned\n");
}
#endif
/* Set and activate a timer process */
@ -934,8 +983,8 @@ static int lo_properties(FAR struct radio_driver_s *netdev,
/* General */
properties->sp_addrlen = NET_6LOWPAN_ADDRSIZE; /* Length of an address */
properties->sp_pktlen = CONFIG_NET_6LOWPAN_FRAMELEN; /* Fixed frame length */
properties->sp_addrlen = LO_ADDRSIZE; /* Length of an address */
properties->sp_pktlen = LO_FRAMELEN; /* Fixed frame length */
/* Multicast address (uses broadcast address)
*
@ -952,12 +1001,12 @@ static int lo_properties(FAR struct radio_driver_s *netdev,
* (qualified by the destination PANID).
*/
properties->sp_mcast.nv_addrlen = NET_6LOWPAN_SADDRSIZE;
properties->sp_mcast.nv_addrlen = IEEE802154_SADDRSIZE;
memset(properties->sp_mcast.nv_addr, 0xff, RADIO_MAX_ADDRLEN);
/* Broadcast address */
properties->sp_bcast.nv_addrlen = NET_6LOWPAN_SADDRSIZE;
properties->sp_bcast.nv_addrlen = IEEE802154_SADDRSIZE;
memset(properties->sp_mcast.nv_addr, 0xff, RADIO_MAX_ADDRLEN);
#ifdef CONFIG_NET_STARPOINT
@ -1015,7 +1064,9 @@ int ieee8021514_loopback(void)
#ifdef CONFIG_NETDEV_IOCTL
dev->d_ioctl = lo_ioctl; /* Handle network IOCTL commands */
#endif
#ifdef CONFIG_NET_6LOWPAN
dev->d_buf = g_iobuffer; /* Attach the IO buffer */
#endif
dev->d_private = (FAR void *)priv; /* Used to recover private state from dev */
/* Set the network mask and advertise our MAC-based IP address */

View file

@ -64,7 +64,7 @@
#include "mac802154.h"
#ifdef CONFIG_NET_6LOWPAN
#if defined(CONFIG_NET_6LOWPAN) || defined(CONFIG_NET_IEEE802154)
/****************************************************************************
* Pre-processor Definitions
@ -97,6 +97,26 @@
# define CONFIG_IEEE802154_NETDEV_NINTERFACES 1
#endif
/* Preferred address size */
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
# define MACNET_ADDRSIZE IEEE802154_EADDRSIZE
#else
# define MACNET_ADDRSIZE IEEE802154_SADDRSIZE
#endif
/* Frame size
* REVISIT: Too many frame length definitions
*/
#if defined(CONFIG_NET_6LOWPAN_FRAMELEN)
# define MACNET_FRAMELEN CONFIG_NET_6LOWPAN_FRAMELEN
#elif defined(CONFIG_NET_IEEE802154_FRAMELEN)
# define MACNET_FRAMELEN CONFIG_NET_IEEE802154_FRAMELEN
#else
# define MACNET_FRAMELEN IEEE802154_MAX_PHY_PACKET_SIZE
#endif
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */
#define TXPOLL_WDDELAY (1*CLK_TCK)
@ -252,8 +272,9 @@ static int macnet_advertise(FAR struct net_driver_s *dev)
eaddr = arg.getreq.attrval.mac.eaddr;
IEEE802154_EADDRCOPY(dev->d_mac.radio.nv_addr, eaddr);
dev->d_mac.radio.nv_addrlen = NET_6LOWPAN_EADDRSIZE;
dev->d_mac.radio.nv_addrlen = IEEE802154_EADDRSIZE;
#ifdef CONFIG_NET_IPv6
/* Set the IP address based on the eaddr */
dev->d_ipv6addr[0] = HTONS(0xfe80);
@ -265,6 +286,7 @@ static int macnet_advertise(FAR struct net_driver_s *dev)
dev->d_ipv6addr[6] = (uint16_t)eaddr[4] << 8 | (uint16_t)eaddr[5];
dev->d_ipv6addr[7] = (uint16_t)eaddr[6] << 8 | (uint16_t)eaddr[7];
dev->d_ipv6addr[4] ^= 0x200;
#endif
return OK;
}
@ -290,8 +312,9 @@ static int macnet_advertise(FAR struct net_driver_s *dev)
saddr = arg.getreq.attrval.mac.saddr;
IEEE802154_SADDRCOPY(dev->d_mac.radio.nv_addr, saddr);
dev->d_mac.radio.nv_addrlen = NET_6LOWPAN_SADDRSIZE;
dev->d_mac.radio.nv_addrlen = IEEE802154_SADDRSIZE;
#ifdef CONFIG_NET_IPv6
/* Set the IP address based on the saddr */
dev->d_ipv6addr[0] = HTONS(0xfe80);
@ -303,6 +326,7 @@ static int macnet_advertise(FAR struct net_driver_s *dev)
dev->d_ipv6addr[6] = HTONS(0xfe00);
dev->d_ipv6addr[7] = (uint16_t)saddr[0] << 8 | (uint16_t)saddr[1];
dev->d_ipv6addr[7] ^= 0x200;
#endif
return OK;
}
#endif
@ -324,6 +348,7 @@ static int macnet_advertise(FAR struct net_driver_s *dev)
static inline void macnet_netmask(FAR struct net_driver_s *dev)
{
#ifdef CONFIG_NET_IPv6
dev->d_ipv6netmask[0] = 0xffff;
dev->d_ipv6netmask[1] = 0xffff;
dev->d_ipv6netmask[2] = 0xffff;
@ -339,6 +364,7 @@ static inline void macnet_netmask(FAR struct net_driver_s *dev)
dev->d_ipv6netmask[6] = 0xffff;
dev->d_ipv6netmask[7] = 0;
#endif
#endif
}
/****************************************************************************
@ -395,6 +421,7 @@ static int macnet_rxframe(FAR struct mac802154_maccb_s *maccb,
(FAR struct macnet_callback_s *)maccb;
FAR struct macnet_driver_s *priv;
FAR struct iob_s *iob;
int ret;
DEBUGASSERT(cb != NULL && cb->mc_priv != NULL);
priv = cb->mc_priv;
@ -412,24 +439,6 @@ static int macnet_rxframe(FAR struct mac802154_maccb_s *maccb,
DEBUGASSERT(priv != NULL && ind != NULL && ind->frame != NULL);
iob = ind->frame;
/* If the frame is not a 6LoWPAN frame, then return an error. The first
* byte following the MAC head at the io_offset should be a valid IPHC
* header.
*/
if ((iob->io_data[iob->io_offset] & SIXLOWPAN_DISPATCH_NALP_MASK) ==
SIXLOWPAN_DISPATCH_NALP)
{
wlwarn("WARNING: Dropped... Not a 6LoWPAN frame: %02x\n",
iob->io_data[iob->io_offset]);
return -EINVAL;
}
/* Increment statistics */
NETDEV_RXPACKETS(&priv->md_dev.r_dev);
NETDEV_RXIPV6(&priv->md_dev.r_dev);
/* Remove the IOB containing the frame. */
ind->frame = NULL;
@ -442,17 +451,40 @@ static int macnet_rxframe(FAR struct mac802154_maccb_s *maccb,
* frame and return success.
*/
#ifndef CONFIG_NET_6LOWPAN
(void)ieee802154_input(&priv->md_dev, iob, (FAR void *)ind);
#else
if (ieee802154_input(&priv->md_dev, iob, (FAR void *)ind) < 0)
#endif
ret = ieee802154_input(&priv->md_dev, iob, (FAR void *)ind);
if (ret < 0)
#endif
#ifdef CONFIG_NET_6LOWPAN
{
(void)sixlowpan_input(&priv->md_dev, iob, (FAR void *)ind);
/* If the frame is not a 6LoWPAN frame, then return an error. The
* first byte following the MAC head at the io_offset should be a
* valid IPHC header.
*/
if ((iob->io_data[iob->io_offset] & SIXLOWPAN_DISPATCH_NALP_MASK) ==
SIXLOWPAN_DISPATCH_NALP)
{
wlwarn("WARNING: Dropped... Not a 6LoWPAN frame: %02x\n",
iob->io_data[iob->io_offset]);
ret = -EINVAL;
}
else
{
ret = sixlowpan_input(&priv->md_dev, iob, (FAR void *)ind);
}
}
if (ret < 0)
#endif
{
ind->frame = iob;
return ret;
}
/* Increment statistics */
NETDEV_RXPACKETS(&priv->md_dev.r_dev);
NETDEV_RXIPV6(&priv->md_dev.r_dev);
/* sixlowpan_input() will free the IOB, but we must free the struct
* ieee802154_data_ind_s container here.
@ -676,6 +708,7 @@ static int macnet_ifup(FAR struct net_driver_s *dev)
ret = macnet_advertise(dev);
if (ret >= 0)
{
#ifdef CONFIG_NET_IPv6
wlinfo("Bringing up: %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],
@ -691,6 +724,27 @@ static int macnet_ifup(FAR struct net_driver_s *dev)
wlinfo(" Node: %02x:%02x\n",
dev->d_mac.radio.nv_addr[0], dev->d_mac.radio.nv_addr[1]);
#endif
#else
if (dev->d_mac.radio.nv_addrlen == 8)
{
ninfo("Bringing up: Node: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x PANID=%02x:%02x\n",
dev->d_mac.radio.nv_addr[0], dev->d_mac.radio.nv_addr[1],
dev->d_mac.radio.nv_addr[2], dev->d_mac.radio.nv_addr[3],
dev->d_mac.radio.nv_addr[4], dev->d_mac.radio.nv_addr[5],
dev->d_mac.radio.nv_addr[6], dev->d_mac.radio.nv_addr[7],
priv->lo_panid[0], priv->lo_panid[1]);
}
else if (dev->d_mac.radio.nv_addrlen == 2)
{
ninfo("Bringing up: Node: %02x:%02x PANID=%02x:%02x\n",
dev->d_mac.radio.nv_addr[0], dev->d_mac.radio.nv_addr[1],
priv->lo_panid[0], priv->lo_panid[1]);
}
else
{
nerr("ERROR: No address assigned\n");
}
#endif
/* Set and activate a timer process */
@ -1081,8 +1135,8 @@ static int macnet_properties(FAR struct radio_driver_s *netdev,
/* General */
properties->sp_addrlen = NET_6LOWPAN_ADDRSIZE; /* Length of an address */
properties->sp_pktlen = CONFIG_NET_6LOWPAN_FRAMELEN; /* Fixed frame length */
properties->sp_addrlen = MACNET_ADDRSIZE; /* Length of an address */
properties->sp_pktlen = MACNET_FRAMELEN; /* Fixed frame length */
/* Multicast address (uses broadcast address)
*
@ -1099,12 +1153,12 @@ static int macnet_properties(FAR struct radio_driver_s *netdev,
* (qualified by the destination PANID).
*/
properties->sp_mcast.nv_addrlen = NET_6LOWPAN_SADDRSIZE;
properties->sp_mcast.nv_addrlen = IEEE802154_SADDRSIZE;
memset(properties->sp_mcast.nv_addr, 0xff, RADIO_MAX_ADDRLEN);
/* Broadcast address */
properties->sp_bcast.nv_addrlen = NET_6LOWPAN_SADDRSIZE;
properties->sp_bcast.nv_addrlen = IEEE802154_SADDRSIZE;
memset(properties->sp_mcast.nv_addr, 0xff, RADIO_MAX_ADDRLEN);
#ifdef CONFIG_NET_STARPOINT
@ -1116,10 +1170,10 @@ static int macnet_properties(FAR struct radio_driver_s *netdev,
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
(void)macnet_coord_eaddr(netdev, properties->sp_hubnode.nv_addr);
properties->sp_hubnode.nv_addrlen = NET_6LOWPAN_EADDRSIZE;
properties->sp_hubnode.nv_addrlen = IEEE802154_EADDRSIZE;
#else
(void)macnet_coord_saddr(netdev, properties->sp_hubnode.nv_addr);
properties->sp_hubnode.nv_addrlen = NET_6LOWPAN_SADDRSIZE;
properties->sp_hubnode.nv_addrlen = IEEE802154_SADDRSIZE;
#endif
#endif
@ -1152,7 +1206,9 @@ int mac802154netdev_register(MACHANDLE mac)
FAR struct radio_driver_s *radio;
FAR struct net_driver_s *dev;
FAR struct mac802154_maccb_s *maccb;
#ifdef CONFIG_NET_6LOWPAN
FAR uint8_t *pktbuf;
#endif
int ret;
DEBUGASSERT(mac != NULL);
@ -1168,7 +1224,8 @@ int mac802154netdev_register(MACHANDLE mac)
return -ENOMEM;
}
/* Allocate a packet buffer (not used by this driver, but need by the
#ifdef CONFIG_NET_6LOWPAN
/* Allocate a packet buffer (not used by this driver, but needed by the
* upper networking layer)
*/
@ -1179,12 +1236,15 @@ int mac802154netdev_register(MACHANDLE mac)
kmm_free(priv);
return -ENOMEM;
}
#endif
/* Initialize the driver structure */
radio = &priv->md_dev;
dev = &radio->r_dev;
#ifdef CONFIG_NET_6LOWPAN
dev->d_buf = pktbuf; /* Single packet buffer */
#endif
dev->d_ifup = macnet_ifup; /* I/F up (new IP address) callback */
dev->d_ifdown = macnet_ifdown; /* I/F down callback */
dev->d_txavail = macnet_txavail; /* New TX data callback */
@ -1237,7 +1297,9 @@ int mac802154netdev_register(MACHANDLE mac)
/* Free memory and return the error */
#ifdef CONFIG_NET_6LOWPAN
kmm_free(pktbuf);
#endif
kmm_free(priv);
return ret;
}