Squashed commit of the following:

commit 7029dffd02156bcbfa84262671c2ca766a117191
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Sat Jul 29 12:02:13 2017 -0600

    6LoWPAN PktRadio: Add missing MetaData-related prototypes and initialization logic.  Perform a major renaming to make room in the 6LoWPAN name space for packet radios.

commit e2012f7c1df14155c0bfd45d7f1cb3f71b259f48
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Sat Jul 29 10:16:23 2017 -0600

    6LoWPAN PktRadio:  Some initial changes to support raw packet radios without IEEE 802.15.4 with 6LoWPAN.

commit c6dbf9178539b7da75e492ffd1d1f93c9c326299
Merge: da782d6cdf 5889ce65f5
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Sat Jul 29 07:30:08 2017 -0600

    Merge remote-tracking branch 'origin/master' into spirit

commit da782d6cdff5980d71aaa2da5f9c28ab3438d085
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Sat Jul 29 07:26:48 2017 -0600

    Spirit:  Completes port of the spirit radio library to NuttX.

commit 63f3595c47dca13952d28b518c7f0a8d6ae9037a
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Fri Jul 28 17:42:51 2017 -0600

    Spirit:  Bring in a couple ore more radio interface functions.

commit 692a27da396b7683749790923d8fa085091764f1
Merge: 27c0a6ec08 38f79543dc
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Fri Jul 28 15:49:37 2017 -0600

    Merge remote-tracking branch 'origin/master' into spirit

commit 27c0a6ec0813187f125922c81189a70cf04d83d4
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Fri Jul 28 15:47:27 2017 -0600

    Spirit:  Bring in a couple ore more radio interface functions.

commit 96657af2831487724723a60084831619257fd953
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Fri Jul 28 14:20:14 2017 -0600

    Spirit:  Bring in more radio interface functions.

commit 640d55399b54a019be68825668fca1446abd082f
Merge: 3fcf84a9a2 47791442a0
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Fri Jul 28 12:01:43 2017 -0600

    Merge remote-tracking branch 'origin/master' into spirit

commit 3fcf84a9a2673e1e1466ce5b114d7b73c257e515
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Fri Jul 28 12:00:31 2017 -0600

    Spirit: Brings in the last of the PktCommon interfaces.

commit d26ebd901ba4ba84910e99b4e728b98c30fa4c0b
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Fri Jul 28 09:54:52 2017 -0600

    Spirit: Add a few more PktCommon interfaces.

commit b5cb8041d50233a4abb8fb4d1dcef5428ae2c2b2
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Fri Jul 28 09:33:31 2017 -0600

    libc/termios:  Remember block comments before empty file sections.

commit 0fcab2c1c8c74442d40bd5e8c6af50a34f8a5821
Author: Sebastien Lorquet <sebastien@lorquet.fr>
Date:   Fri Jul 28 09:31:00 2017 -0600

    tcdrain implementation based on a new term ioctl

commit 797d4adf7d41068c671f0217d369b797b269de1a
Author: Stefan Kolb <Stefan.Kolb@avat.de>
Date:   Fri Jul 28 09:19:04 2017 -0600

    We discovered a problem with the samv7 mcan driver which results, under some circumstances, in a very high CPU load.

    The problem occurs, and is easily reproducible, if the device is connected to a CAN network with a wrongly configured CAN speed (baud rate). In our tests we set the CAN speed of the device to 1000000 and the speed of the other CAN nodes to 500000. The device is restarted and sends a CANopen “bootup message” to the CAN network. This results in huge amount of errors messages on the CAN bus, probably because of the CAN feature for acknowledging error messages. The error messages can’t be read by the device because of the misconfigured CAN speed, instead the CAN chip reports lots of errors, which are reported to the application which uses the CAN driver (CONFIG_CAN_ERRORS is enabled).

    The CAN errors are reported from the CAN chip via interrupts and thus the interrupt load is very high in this scenario. To fix the problem the driver now disables each RX error interrupt after it is occurred. The RX error interrupts are turned back on if at least one CAN message is received successfully.

commit e298f48e96d9e34017dcab8e4d87032862ae9322
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Fri Jul 28 09:06:26 2017 -0600

    Spirit:  Bring in PktStack interfaces.

commit 4a0f00a7058312dcf6ac392689b9f69112f613ec
Merge: 855cf97130 b458934ac4
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Thu Jul 27 18:05:02 2017 -0600

    Merge remote-tracking branch 'origin/master' into spirit

commit 855cf9713052a851a1daeb3842db2edd6ff6f658
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Thu Jul 27 18:03:56 2017 -0600

    Spirit Network Driver:  Add some hooks that will eventually support address filtering.

commit 3b3fb24ea86cf8233b034871d5c550f47ab852e6
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Thu Jul 27 17:13:21 2017 -0600

    Spirit: Add a PktStack header file.

commit 705e8fff6a21264ab751fb34c107cb109430ac89
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Thu Jul 27 15:00:03 2017 -0600

    Spirit:  Bring in last of timer interfaces.

commit f8984b2f82e165f5bba132d6b099222d1beb1fbd
Merge: cb79778a30 f287cc25d6
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Thu Jul 27 11:57:01 2017 -0600

    Merge remote-tracking branch 'origin/master' into spirit

commit cb79778a3044ae97a1cc615dfa24099144f04bd0
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Thu Jul 27 11:46:31 2017 -0600

    Spirit:  Bring in last of QI interfaces.

commit 0245b330a33aa73531b82ae261b1312be9922e0f
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Thu Jul 27 10:14:34 2017 -0600

    Spirit:  Add general interfaces.

commit 121845a8f229ec2c88e5721da5512135f6624ee5
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Thu Jul 27 09:41:23 2017 -0600

    Spirit:  Bring in last of GPIO interfaces.

commit 279bfcc92bcd0cfa48c0ed7862fa2b75fbee99b8
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Wed Jul 26 17:09:19 2017 -0600

    Spirit: Add some missing configuration options: Add register -level debug options.

commit 4be89324a5908e35afc70373c279f4d05f62b48f
Merge: 66e87f9bb3 598386ef90
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Wed Jul 26 15:36:20 2017 -0600

    Merge remote-tracking branch 'origin/master' into spirit

commit 66e87f9bb3ef75fddf25400bc08475c5e6ad4c30
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Wed Jul 26 15:19:56 2017 -0600

    Spirit:  Brings in last of PktBasic logic.

commit 8b4c89d6a103003fa04363e2c2ae7b9ee390bf49
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Wed Jul 26 11:55:50 2017 -0600

    Spirit:  Bring in AES and MBUS logic.

commit d00022d39ab0ce839de29386949481e5c24feff3
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Wed Jul 26 09:22:03 2017 -0600

    Spirit:  Bring in remainder of calibration interfaces.

commit 40b4b2f902e04293f8940551a97a9a24a48988dd
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Wed Jul 26 08:44:32 2017 -0600

    Spirit:  Bring in DirectRF interfaces.

commit 7c109608e1a2989f3edbc2fd939a2d225fff382a
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Wed Jul 26 07:46:19 2017 -0600

    Spirit: Add CSMA support.

commit 0f88896595d162c4ac6138e7b1af2fc35c865b3d
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Tue Jul 25 18:57:43 2017 -0600

    Spirit:  Add some initial TX logic to network driver.

commit 4dc7058dfcdcf40980578680b7e1a4206dea4ea2
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Tue Jul 25 17:02:11 2017 -0600

    Spirit: Completes ports of spirit_management.* files

commit c904eef51d929e041b87d0c8aff6fa3c2f895341
Merge: 91e985a877 c9ff8cbab9
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Tue Jul 25 15:15:04 2017 -0600

    Merge remote-tracking branch 'origin/master' into spirit

commit 91e985a87729017a66d19276c4d47681064f95ea
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Tue Jul 25 15:13:54 2017 -0600

    Spirit:  Add a few more functions that will soon be needed for packet transmission.

commit b5981d29983907c2194fbc26af4b72ad532bee78
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Tue Jul 25 13:30:07 2017 -0600

    Spirit:  Finish off some initialization issues; Started some interrupt handling logic.

commit c21073e0bc2870b3d9ba40bdfdfd5151ce4f5890
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Tue Jul 25 09:35:52 2017 -0600

    Spirit:  Completes very basic radio initialization for network driver

commit 1b544334361c54f46bcf0ba313c125932e8dafc6
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Tue Jul 25 07:58:30 2017 -0600

    Spirit: Add more radio initialization logic... getting closer.

commit 45d1047db60843c57d394ec910c63e7c127671e0
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Mon Jul 24 19:15:33 2017 -0600

    Spirit: add some CSMA initialization logic

commit bcf55c71336d48947fe19bb09a799169852301c2
Merge: 89e9d426e9 2fc0fbcf7e
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Mon Jul 24 16:47:11 2017 -0600

    Merge remote-tracking branch 'origin/master' into spirit

commit 89e9d426e91c056e659fccf5e5c4392618f8f777
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Mon Jul 24 16:44:19 2017 -0600

    Update some comments

commit 9c5d8a5833350006ed389e898b11c8c8a20e5f4f
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Mon Jul 24 16:15:54 2017 -0600

    Spirit:  Rename drivers/wireless/spirit/src to lib.  Move Spirit network driver out of IEEE802.15.4 into drivers/wireless/spirit/drivers

commit cabc0ec9e6eb558dcb715ab17264383aa0105e7a
Merge: 87b616414a 6bd744c4b3
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Mon Jul 24 15:38:40 2017 -0600

    Merge remote-tracking branch 'origin/master' into spirit

commit 87b616414a79c01a71acea78f8258e05325c1996
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Mon Jul 24 15:37:27 2017 -0600

    Spirit radio driver is mutating into a standalone network driver.

commit 507798233868a661ae8adad3e3aa117075a7a146
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Mon Jul 24 13:32:08 2017 -0600

    Spirit: More radio initialization logic

commit 33af25704ce9ca83d576300d153cfe31cc6d2576
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Mon Jul 24 12:19:14 2017 -0600

    Spirit:  Beginning of radio initialization logic

commit 97b20014c016e55952a8f9d8f4ae29e2cc555b23
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Mon Jul 24 09:42:06 2017 -0600

    Spirit: More initialization logic.

commit 295d8e27824c0417fccea2344b30bb5c93ffbabe
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Sun Jul 23 15:39:53 2017 -0600

    Spirit:  Add header file containing enumeration of commands.

commit 8a2d9dd8eb9cc70cbcdd1b913fc9022b9c9ec8da
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Sun Jul 23 11:33:50 2017 -0600

    Spirit:  Add GPIO initialization logic

commit 8b6d80c44f92024c45a6ba63ba1af3fdafe94dc3
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Sun Jul 23 10:07:25 2017 -0600

    Spirit:  Add interrupt control logic.

commit 423f846fe5c914f92a4bfea4d9d1fa33de1c77a5
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Sat Jul 22 19:06:52 2017 -0600

    Spirit: Yet a little more radio initialization logic.

commit 5895b979823e51ddde5ad52e6de66a8ad662e883
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Sat Jul 22 15:36:05 2017 -0600

    Spirit: A little more radio initialization logic.

commit 86311ab30aad386203c181c792847dd1d37f9a02
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Sat Jul 22 13:02:32 2017 -0600

    Spirit: A miniscule amount of radio initialization logic.

commit ad55e89d5ee12ea1eeea95fcd38ff3da0db4416a
Merge: 90a7666655 f4e46b0da7
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Sat Jul 22 10:56:30 2017 -0600

    Merge remote-tracking branch 'origin/master' into spirit

commit 90a766665534b05da0157dbc383cb06a98c86a79
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Sat Jul 22 10:52:52 2017 -0600

    Spirit1:  A few fixes for a clean build of initial configuration (not much there yet)

commit bbbf04c223230a52a7705a2161128265cfbaa480
Merge: 623d54a7f7 2319ea53a9
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Sat Jul 22 09:53:57 2017 -0600

    Merge remote-tracking branch 'origin/master' into spirit

commit 623d54a7f719e9032099f88f38203efee4b80722
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Sat Jul 22 09:43:52 2017 -0600

    b-l475e-iot01a: Add a configuration for testing sprit radio.

commit d309d73d9f4665f9d870eb03531f450043d9389d
Merge: 52c3ddfae6 d88dc9b2e5
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Sat Jul 22 09:02:06 2017 -0600

    Merge remote-tracking branch 'origin/master' into spirit

commit 52c3ddfae6802e111c2b5cf1207baf21a61dd00b
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Sat Jul 22 08:33:04 2017 -0600

    Spirit:  Add register definition header file.

commit 8d842ab5e8f9ca653b42f9ee88dc279f06b4fa98
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Fri Jul 21 17:27:03 2017 -0600

    b-l475e-iot01a: Add initial, unverified support for the SPSRGF/Spirit1 module.

commit 73d902a1048616fb9c2dd2147cabcd8ee78e19ac
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Fri Jul 21 15:49:43 2017 -0600

    Spirit: Fixes to get skeleton IEEE 802.15.4 driver build.

commit ebc5a8387bb94f0cc3827533795f3e4a33207e67
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Fri Jul 21 15:16:29 2017 -0600

    Spirit1:  Add framework for IEEE 802.15.4 driver.  Does not yet build.

commit 52e195a7ae14ddb18bdd56258f4877381d2501ca
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Fri Jul 21 14:02:42 2017 -0600

    Spirit:  A little more SPI logic.

commit 90048d0c5b8a5af4d81a15d99535c84ed38d8ae9
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Fri Jul 21 11:19:06 2017 -0600

    Spirit: Build directories setup.  Some initial files added, mostly just to verify build.

commit 8273a381ac1f6bb081b292b5e73226185e9e634c
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Fri Jul 21 08:34:04 2017 -0600

    USB composite:  Remove references to CDC/ACM and USB MSC from composite logic.  They are no longer coupled.
This commit is contained in:
Gregory Nutt 2017-07-29 13:42:26 -06:00
parent 5889ce65f5
commit 7f53e08917
33 changed files with 981 additions and 473 deletions

View File

@ -13,14 +13,11 @@ CONFIG_ARCH="arm"
CONFIG_BOARD_LOOPSPERMSEC=16717
CONFIG_BUILTIN=y
CONFIG_DISABLE_POLL=y
CONFIG_DRIVERS_IEEE802154=y
CONFIG_DRIVERS_WIRELESS=y
CONFIG_EXAMPLES_NSH=y
CONFIG_FS_PROCFS=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_IEEE802154_I8SAK=y
CONFIG_IEEE802154_MACDEV=y
CONFIG_INTELHEX_BINARY=y
CONFIG_LIBM=y
CONFIG_MAX_TASKS=16
@ -57,5 +54,5 @@ CONFIG_STM32L4_UART4=y
CONFIG_UART4_SERIAL_CONSOLE=y
CONFIG_USER_ENTRYPOINT="nsh_main"
CONFIG_WATCHDOG=y
CONFIG_WIRELESS_IEEE802154=y
CONFIG_WIRELESS_PKTRADIO=y
CONFIG_WIRELESS=y

View File

@ -47,16 +47,6 @@ config SPIRIT_PKTLEN
Fixed pkt sizes are used. This setting describes that fixed packet
size.
config SPIRIT_MTU
int "MTU"
default 596
---help---
6LoWPAN support fragmenting and reassembly of large IPv6 packets.
Each fragment will be up CONFIG_SPIRIT_PKTLEN in length. An single
IPv6 packet maybe fragment into several such frames. This setting
provides the MTU which is the largest fully assembled IPv6 packet
that can be sent.
config SPIRIT_PROMISICUOUS
bool "Promiscuous mode"
default n

View File

@ -61,7 +61,7 @@
#include <nuttx/net/sixlowpan.h>
#include <nuttx/wireless/spirit.h>
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/wireless/pktradio.h>
#include "spirit_types.h"
#include "spirit_general.h"
@ -99,10 +99,6 @@
# define CONFIG_SPIRIT_PKTLEN 96
#endif
#ifndef CONFIG_SPIRIT_MTU
# define CONFIG_SPIRIT_MTU 596
#endif
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */
#define SPIRIT_WDDELAY (1*CLK_TCK)
@ -130,7 +126,7 @@ enum spirit_driver_state_e
struct spirit_driver_s
{
struct ieee802154_driver_s ieee; /* Interface understood by the network */
struct sixlowpan_driver_s radio; /* Interface understood by the network */
struct spirit_library_s spirit; /* Spirit library state */
FAR const struct spirit_lower_s *lower; /* Low-level MCU-specific support */
FAR struct iob_s *txhead; /* Head of pending TX transfers */
@ -144,15 +140,6 @@ struct spirit_driver_s
sem_t exclsem; /* Mutually exclusive access */
bool ifup; /* Spirit is on and interface is up */
uint8_t state; /* See enum spirit_driver_state_e */
uint8_t panid[2]; /* PAN identifier, ffff = not set */
uint16_t saddr; /* Short address, ffff = not set */
uint8_t eaddr[8]; /* Extended address, ffffffffffffffff = not set */
uint8_t channel; /* 11 to 26 for the 2.4 GHz band */
uint8_t devmode; /* Device mode: device, coord, pancoord */
uint8_t paenabled; /* Enable usage of PA */
uint8_t rxmode; /* Reception mode: Main, no CRC, promiscuous */
int32_t txpower; /* TX power in mBm = dBm/100 */
struct ieee802154_cca_s cca; /* Clear channel assessement method */
};
/****************************************************************************
@ -217,9 +204,9 @@ static void spirit_ipv6multicast(FAR struct spirit_driver_s *priv);
static int spirit_ioctl(FAR struct net_driver_s *dev, int cmd,
unsigned long arg);
#endif
static int spirit_get_mhrlen(FAR struct ieee802154_driver_s *netdev,
static int spirit_get_mhrlen(FAR struct sixlowpan_driver_s *netdev,
FAR const struct ieee802154_frame_meta_s *meta);
static int spirit_req_data(FAR struct ieee802154_driver_s *netdev,
static int spirit_req_data(FAR struct sixlowpan_driver_s *netdev,
FAR const struct ieee802154_frame_meta_s *meta,
FAR struct iob_s *framelist);
@ -497,7 +484,7 @@ static int spirit_transmit(FAR struct spirit_driver_s *priv)
if (iob->io_len > CONFIG_SPIRIT_PKTLEN)
{
NETDEV_RXDROPPED(&priv->ieee.i_dev);
NETDEV_RXDROPPED(&priv->radio.r_dev);
iob_free(iob);
continue;
}
@ -584,7 +571,7 @@ static int spirit_transmit(FAR struct spirit_driver_s *priv)
errout_with_iob:
spirit_unlock(priv);
NETDEV_RXDROPPED(&priv->ieee.i_dev);
NETDEV_RXDROPPED(&priv->radio.r_dev);
iob_free(iob);
return ret;
}
@ -759,7 +746,7 @@ static void spirit_interrupt_work(FAR void *arg)
DEBUGVERIFY(spirit_command(spirit, CMD_FLUSHRXFIFO));
priv->state = DRIVER_STATE_IDLE;
NETDEV_RXERRORS(&priv->ieee.i_dev);
NETDEV_RXERRORS(&priv->radio.r_dev);
/* Send any pending packets */
@ -773,7 +760,7 @@ static void spirit_interrupt_work(FAR void *arg)
DEBUGVERIFY(spirit_command(spirit, COMMAND_FLUSHTXFIFO));
priv->state = DRIVER_STATE_IDLE;
NETDEV_TXERRORS(&priv->ieee.i_dev);
NETDEV_TXERRORS(&priv->radio.r_dev);
/* Send any pending packets */
@ -790,7 +777,7 @@ static void spirit_interrupt_work(FAR void *arg)
DEBUGVERIFY(spirit_management_rxstrobe(spirit));
DEBUGVERIFY(spirit_command(spirit, CMD_RX));
NETDEV_TXDONE(&priv->ieee.i_dev)
NETDEV_TXDONE(&priv->radio.r_dev)
spirit_csma_enable(spirit, S_DISABLE);
/* Check if there are more packets to send */
@ -853,7 +840,7 @@ static void spirit_interrupt_work(FAR void *arg)
DEBUGVERIFY(spirit_command(spirit, CMD_FLUSHRXFIFO));
priv->state = DRIVER_STATE_IDLE;
NETDEV_RXDROPPED(&priv->ieee.i_dev);
NETDEV_RXDROPPED(&priv->radio.r_dev);
/* Send any pending packets */
@ -870,7 +857,7 @@ static void spirit_interrupt_work(FAR void *arg)
DEBUGVERIFY(spirit_command(spirit, CMD_FLUSHRXFIFO));
priv->state = DRIVER_STATE_IDLE;
NETDEV_RXPACKETS(&priv->ieee.i_dev);
NETDEV_RXPACKETS(&priv->radio.r_dev);
/* Add the IO buffer to the tail of the completed RX transfers */
@ -917,7 +904,7 @@ static void spirit_interrupt_work(FAR void *arg)
{
DEBUGVERIFY(spirit_command(spirit, CMD_FLUSHRXFIFO));
priv->state = DRIVER_STATE_IDLE;
NETDEV_RXDROPPED(&priv->ieee.i_dev);
NETDEV_RXDROPPED(&priv->radio.r_dev);
}
/* Check the Spirit status. If it is IDLE, the setup to receive more */
@ -1012,13 +999,13 @@ static void spirit_txtimeout_work(FAR void *arg)
/* Increment statistics and dump debug info */
NETDEV_TXTIMEOUTS(&priv->ieee.i_dev);
NETDEV_TXTIMEOUTS(&priv->radio.r_dev);
/* Then reset the hardware */
/* Then poll the network for new XMIT data */
(void)devif_poll(&priv->ieee.i_dev, spirit_txpoll_callback);
(void)devif_poll(&priv->radio.r_dev, spirit_txpoll_callback);
net_unlock();
}
@ -1113,7 +1100,7 @@ static void spirit_poll_work(FAR void *arg)
/* Perform the periodic poll */
(void)devif_timer(&priv->ieee.i_dev, spirit_txpoll_callback);
(void)devif_timer(&priv->radio.r_dev, spirit_txpoll_callback);
/* Setup the watchdog poll timer again */
@ -1380,7 +1367,7 @@ static void spirit_txavail_work(FAR void *arg)
/* If so, then poll the network for new XMIT data */
(void)devif_poll(&priv->ieee.i_dev, spirit_txpoll_callback);
(void)devif_poll(&priv->radio.r_dev, spirit_txpoll_callback);
}
net_unlock();
@ -1556,13 +1543,13 @@ static int spirit_ioctl(FAR struct net_driver_s *dev, int cmd,
*
****************************************************************************/
static int spirit_get_mhrlen(FAR struct ieee802154_driver_s *netdev,
static int spirit_get_mhrlen(FAR struct sixlowpan_driver_s *netdev,
FAR const struct ieee802154_frame_meta_s *meta)
{
FAR struct spirit_driver_s *priv;
DEBUGASSERT(netdev != NULL && netdev->i_dev.d_private != NULL && meta != NULL);
priv = (FAR struct spirit_driver_s *)netdev->i_dev.d_private;
DEBUGASSERT(netdev != NULL && netdev->r_dev.d_private != NULL && meta != NULL);
priv = (FAR struct spirit_driver_s *)netdev->r_dev.d_private;
spirit_lock(priv);
#warning Missing logic
@ -1590,7 +1577,7 @@ static int spirit_get_mhrlen(FAR struct ieee802154_driver_s *netdev,
*
****************************************************************************/
static int spirit_req_data(FAR struct ieee802154_driver_s *netdev,
static int spirit_req_data(FAR struct sixlowpan_driver_s *netdev,
FAR const struct ieee802154_frame_meta_s *meta,
FAR struct iob_s *framelist)
{
@ -1599,8 +1586,8 @@ static int spirit_req_data(FAR struct ieee802154_driver_s *netdev,
wlinfo("Received framelist\n");
DEBUGASSERT(netdev != NULL && netdev->i_dev.d_private != NULL);
priv = (FAR struct spirit_driver_s *)netdev->i_dev.d_private;
DEBUGASSERT(netdev != NULL && netdev->r_dev.d_private != NULL);
priv = (FAR struct spirit_driver_s *)netdev->r_dev.d_private;
DEBUGASSERT(meta != NULL && framelist != NULL);
@ -1611,7 +1598,7 @@ static int spirit_req_data(FAR struct ieee802154_driver_s *netdev,
{
/* Increment statistics */
NETDEV_TXPACKETS(&priv->md_dev.i_dev);
NETDEV_TXPACKETS(&priv->md_dev.r_dev);
/* Remove the IOB from the queue */
@ -1889,7 +1876,7 @@ int spirit_netdev_initialize(FAR struct spi_dev_s *spi,
FAR const struct spirit_lower_s *lower)
{
FAR struct spirit_driver_s *priv;
FAR struct ieee802154_driver_s *ieee;
FAR struct sixlowpan_driver_s *radio;
FAR struct net_driver_s *dev;
FAR uint8_t *pktbuf;
int ret;
@ -1905,7 +1892,7 @@ int spirit_netdev_initialize(FAR struct spi_dev_s *spi,
/* Allocate a packet buffer */
pktbuf = (uint8_t *)kmm_zalloc(CONFIG_SPIRIT_MTU + CONFIG_NET_GUARDSIZE);
pktbuf = (uint8_t *)kmm_zalloc(CONFIG_NET_6LOWPAN_MTU + CONFIG_NET_GUARDSIZE);
if (priv == NULL)
{
wlerr("ERROR: Failed to allocate a packet buffer\n");
@ -1928,13 +1915,13 @@ int spirit_netdev_initialize(FAR struct spi_dev_s *spi,
/* Initialize the IEEE 802.15.4 network device fields */
ieee = &priv->ieee;
ieee->i_get_mhrlen = spirit_get_mhrlen; /* Get MAC header length */
ieee->i_req_data = spirit_req_data; /* Enqueue frame for transmission */
radio = &priv->radio;
radio->r_get_mhrlen = spirit_get_mhrlen; /* Get MAC header length */
radio->r_req_data = spirit_req_data; /* Enqueue frame for transmission */
/* Initialize the common network device fields */
dev = &ieee->i_dev;
dev = &radio->r_dev;
dev->d_buf = pktbuf; /* Single packet buffer */
dev->d_ifup = spirit_ifup; /* I/F up (new IP address) callback */
dev->d_ifdown = spirit_ifdown; /* I/F down callback */
@ -1954,11 +1941,9 @@ int spirit_netdev_initialize(FAR struct spi_dev_s *spi,
/* Read the MAC address from the hardware into dev->d_mac.ether.ether_addr_octet */
/* Register the device with the OS so that socket IOCTLs can be performed.
* REVISIT: What kind of a device is this?
*/
/* Register the device with the OS so that socket IOCTLs can be performed. */
(void)netdev_register(dev, NET_LL_IEEE802154);
(void)netdev_register(dev, NET_LL_PKTRADIO);
/* Attach irq */
@ -1977,7 +1962,9 @@ int spirit_netdev_initialize(FAR struct spi_dev_s *spi,
goto errout_with_attach;
}
/* Put the Device to RX ON Mode */
/* Make sure that the PktRadio common logic has been initialized */
pktradio_metadata_initialize();
/* Enable Radio IRQ */

View File

@ -84,7 +84,8 @@ enum net_lltype_e
NET_LL_SLIP, /* Serial Line Internet Protocol (SLIP) */
NET_LL_TUN, /* TUN Virtual Network Device */
NET_LL_IEEE80211, /* IEEE 802.11 */
NET_LL_IEEE802154 /* IEEE 802.15.4 MAC */
NET_LL_IEEE802154, /* IEEE 802.15.4 MAC */
NET_LL_PKTRADIO /* Non-standard packet radio */
};
/* This defines a bitmap big enough for one bit for each socket option */

View File

@ -437,10 +437,10 @@ int ipv6_input(FAR struct net_driver_s *dev);
#endif
#ifdef CONFIG_NET_6LOWPAN
struct ieee802154_driver_s; /* See sixlowpan.h */
struct sixlowpan_driver_s; /* See sixlowpan.h */
struct ieee802154_data_ind_s; /* See ieee8021454_mac.h */
struct iob_s; /* See iob.h */
int sixlowpan_input(FAR struct ieee802154_driver_s *ieee,
int sixlowpan_input(FAR struct sixlowpan_driver_s *ieee,
FAR struct iob_s *framelist,
FAR const struct ieee802154_data_ind_s *ind);
#endif

View File

@ -69,8 +69,8 @@
/* Fragment header.
*
* The fragment header is used when the payload is too large to fit in a
* single IEEE 802.15.4 frame. The fragment header contains three fields:
* Datagram size, datagram tag and datagram offset.
* single radio frame. The fragment header contains three fields: Datagram
* size, datagram tag and datagram offset.
*
* 1. Datagram size describes the total (un-fragmented) payload.
* 2. Datagram tag identifies the set of fragments and is used to match
@ -300,22 +300,22 @@
* Public Types
****************************************************************************/
/* The device structure for IEEE802.15.4 MAC network device differs from the
* standard Ethernet MAC device structure. The main reason for this
* difference is that fragmentation must be supported.
/* The device structure for radio network device differs from the standard
* Ethernet MAC device structure. The main reason for this difference is
* that fragmentation must be supported.
*
* The IEEE802.15.4 MAC does not use the d_buf packet buffer directly.
* The radio network driver does not use the d_buf packet buffer directly.
* Rather, it uses a list smaller frame buffers.
*
* - The packet fragment data is provided in an IOB in the via the
* i_req_data() interface method each time that the IEEE802.15.4 MAC
* needs to send more data. The length of the frame is provided in the
* io_len field of the IOB.
* r_req_data() interface method each time that the radio needs to
* send more data. The length of the frame is provided in the io_len
* field of the IOB.
*
* In this case, the d_buf is not used at all and, if fact, may be
* NULL.
*
* - Received frames are provided by IEEE802.15.4 MAC to the network
* - Received frames are provided by radio network driver to the network
* via an IOB parameter in the sixlowpan_submit() interface. The
* length of the frawme is io_len and will be uncompressed and possibly
* reassembled in the d_buf; d_len will hold the size of the
@ -325,15 +325,15 @@
*
* This is accomplished by "inheriting" the standard 'struct net_driver_s'
* and appending the frame buffer as well as other metadata needed to
* manage the fragmentation. 'struct ieee802154_driver_s' is cast
* manage the fragmentation. 'struct sixlowpan_driver_s' is cast
* compatible with 'struct net_driver_s' when CONFIG_NET_MULTINIC is not
* defined or when dev->d_lltype == NET_LL_IEEE802154.
* defined or when dev->d_lltype == NET_LL_IEEE802154 or dev->d_lltype ==
* NET_LL_PKTRADIO.
*
* The IEEE802.15.4 MAC network driver has reponsibility for initializing
* this structure. In general, all fields must be set to NULL. In
* addtion:
* The radio network driver has reponsibility for initializing this
* structure. In general, all fields must be set to NULL. In addition:
*
* 1. On a TX poll, the IEEE802.15.4 MAC driver should provide its driver
* 1. On a TX poll, the radio network driver should provide its driver
* structure. During the course of the poll, the networking layer may
* generate outgoing frames. These frames will by provided to the MAC
* driver via the req_data() method.
@ -343,9 +343,9 @@
*
* 2. When receiving data both buffers must be provided:
*
* The IEEE802.15.4 MAC driver should receive the frame data directly
* into the payload area of an IOB frame structure. That IOB structure
* may be obtained using the iob_alloc() function.
* The radio driver should receive the frame data directly into the
* payload area of an IOB frame structure. That IOB structure may be
* obtained using the iob_alloc() function.
*
* The larger dev.d_buf must have a size of at least the advertised MTU
* of the protocol, CONFIG_NET_6LOWPAN_MTU, plus CONFIG_NET_GUARDSIZE.
@ -369,16 +369,17 @@ struct ieee802154_frame_meta_s; /* Forward reference */
struct ieee802154_data_ind_s; /* Forward reference */
struct iob_s; /* Forward reference */
struct ieee802154_driver_s
struct sixlowpan_driver_s
{
/* This definitiona must appear first in the structure definition to
* assure cast compatibility.
*/
struct net_driver_s i_dev;
struct net_driver_s r_dev;
/* IEEE802.15.4 MAC-specific definitions follow. */
/* Radio network driver-specific definitions follow. */
#ifdef CONFIG_WIRELESS_IEEE802154
/* The msdu_handle is basically an id for the frame. The standard just
* says that the next highest layer should determine it. It is used in
* three places
@ -394,7 +395,8 @@ struct ieee802154_driver_s
* Here is a simple frame counter.
*/
uint8_t i_msdu_handle;
uint8_t r_msdu_handle;
#endif
#if CONFIG_NET_6LOWPAN_FRAG
/* Fragmentation Support *************************************************/
@ -402,7 +404,7 @@ struct ieee802154_driver_s
* state information be retained from frame to frame.
*/
/* i_dgramtag. Datagram tag to be put in the header of the set of
/* r_dgramtag. Datagram tag to be put in the header of the set of
* fragments. It is used by the recipient to match fragments of the
* same payload.
*
@ -410,54 +412,54 @@ struct ieee802154_driver_s
* fragmented packet is sent so that it will be unique to that
* sequence fragmentation. Its value is then persistent, the values of
* other fragmentatin variables are valid on during a single
* fragmentation sequence (while i_accumlen > 0)
* fragmentation sequence (while r_accumlen > 0)
*/
uint16_t i_dgramtag;
uint16_t r_dgramtag;
/* i_reasstag. Each frame in the reassembly has a tag. That tag must
/* r_reasstag. Each frame in the reassembly has a tag. That tag must
* match the reassembly tag in the fragments being merged.
*
* This is the same tag as i_dgramtag but is saved on the receiving
* This is the same tag as r_dgramtag but is saved on the receiving
* side to match all of the fragments of the packet.
*/
uint16_t i_reasstag;
uint16_t r_reasstag;
/* i_pktlen. The total length of the IPv6 packet to be re-assembled in
/* r_pktlen. The total length of the IPv6 packet to be re-assembled in
* d_buf. Used to determine when the re-assembly is complete.
*/
uint16_t i_pktlen;
uint16_t r_pktlen;
/* The current accumulated length of the packet being received in d_buf.
* Included IPv6 and protocol headers. Currently used only to determine
* there is a fragmentation sequence in progress.
*/
uint16_t i_accumlen;
uint16_t r_accumlen;
/* i_boffset. Offset to the beginning of data in d_buf. As each fragment
/* r_boffset. Offset to the beginning of data in d_buf. As each fragment
* is received, data is placed at an appriate offset added to this.
*/
uint16_t i_boffset;
uint16_t r_boffset;
/* The source MAC address of the fragments being merged */
struct sixlowpan_tagaddr_s i_fragsrc;
struct sixlowpan_tagaddr_s r_fragsrc;
/* That time at which reassembly was started. If the elapsed time
* exceeds CONFIG_NET_6LOWPAN_MAXAGE, then the reassembly will
* be cancelled.
*/
systime_t i_time;
systime_t r_time;
#endif /* CONFIG_NET_6LOWPAN_FRAG */
/* MAC network driver callback functions **********************************/
/**************************************************************************
* Name: mac802154_get_mhrlen
* Name: r_get_mhrlen
*
* Description:
* Calculate the MAC header length given the frame meta-data.
@ -472,11 +474,11 @@ struct ieee802154_driver_s
*
**************************************************************************/
CODE int (*i_get_mhrlen)(FAR struct ieee802154_driver_s *netdev,
CODE int (*r_get_mhrlen)(FAR struct sixlowpan_driver_s *netdev,
FAR const struct ieee802154_frame_meta_s *meta);
/**************************************************************************
* Name: mac802154_req_data
* Name: r_req_data
*
* Description:
* Requests the transfer of a list of frames to the MAC.
@ -492,7 +494,7 @@ struct ieee802154_driver_s
*
**************************************************************************/
CODE int (*i_req_data)(FAR struct ieee802154_driver_s *netdev,
CODE int (*r_req_data)(FAR struct sixlowpan_driver_s *netdev,
FAR const struct ieee802154_frame_meta_s *meta,
FAR struct iob_s *framelist);
};
@ -507,15 +509,14 @@ struct ieee802154_driver_s
* Description:
* Process an incoming 6LoWPAN frame.
*
* This function is called when the device driver has received an
* IEEE802.15.4 frame from the network. The frame from the device
* driver must be provided in by the IOB frame argument of the
* function call:
* This function is called when the radio device driver has received an
* frame from the network. The frame from the device driver must be
* provided in by the IOB frame argument of the function call:
*
* - The frame data is in the IOB io_data[] buffer,
* - The length of the frame is in the IOB io_len field, and
* - The offset past the IEEE802.15.4 MAC header is provided in the
* io_offset field.
* - The offset past and radio MAC header is provided in the io_offset
* field.
*
* The frame argument may refer to a single frame (a list of length one)
* or may it be the head of a list of multiple frames.
@ -531,8 +532,8 @@ struct ieee802154_driver_s
*
* After each frame is processed into d_buf, the IOB is deallocated. If
* reassembly is incomplete, the partially reassembled packet must be
* preserved by the IEEE802.15.4 MAC network drvier sand provided again
* when the next frame is received.
* preserved by the radio network drvier and provided again when the next
* frame is received.
*
* When the packet in the d_buf is fully reassembled, it will be provided
* to the network as with any other received packet. d_len will be set
@ -549,7 +550,7 @@ struct ieee802154_driver_s
* network driver via the req_data() method as with other TX operations.
*
* Input Parameters:
* ieee - The IEEE802.15.4 MAC network driver interface.
* radio The radio network driver interface.
* framelist - The head of an incoming list of frames. Normally this
* would be a single frame. A list may be provided if
* appropriate, however.
@ -562,7 +563,7 @@ struct ieee802154_driver_s
*
****************************************************************************/
int sixlowpan_input(FAR struct ieee802154_driver_s *ieee,
int sixlowpan_input(FAR struct sixlowpan_driver_s *radio,
FAR struct iob_s *framelist,
FAR const struct ieee802154_data_ind_s *ind);

View File

@ -0,0 +1,169 @@
/****************************************************************************
* include/nuttx/wireless/pktradio.h
*
* Copyright (C) 2017 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_PKTRADIO_H
#define __INCLUDE_NUTTX_WIRELESS_PKTRADIO_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Memory Pools */
#define PKTRADIO_POOL_PREALLOCATED 0
#define PKTRADIO_POOL_DYNAMIC 1
/****************************************************************************
* Public Types
****************************************************************************/
/* This describes an address used by the packet radio. There is no standard
* size for such an address. Hence, it is represented simply as a arry of
* bytes.
*/
struct pktradio_addr_s
{
uint8_t pa_addrlen; /* Length of the following address */
uint8_t pa_addr[CONFIG_PKTRADIO_ADDRLEN];
};
/* This is the form of the meta data that provides the radio-specific
* information necessary to send and receive packets to and from the radio.
*/
struct pktradio_metadata_s
{
struct pktradio_metadata_s *pm_flink; /* Supports a singly linked list */
struct pktradio_addr_s pm_src; /* Source of the packet */
struct pktradio_addr_s pm_dest; /* Destination of the packet */
uint8_t pm_pool; /* See PKTRADIO_POOL_* definitions */
};
/* Different packet radios may have different properties. If there are
* multiple packet radios, then those properties have to be queried at
* run time. This information is provided to the 6LoWPAN network via the
* following structure.
*/
struct pktradio_properties_s
{
uint8_t pp_addrlen; /* Length of an address */
uint8_t pp_pktlen; /* Fixed packet/frame size (up to 255) */
};
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: pktradio_metadata_initialize
*
* Description:
* This function initializes the meta-data allocator. This function must
* be called early in the initialization sequence before any radios
* begin operation.
*
* This function is idempotent: It may be called numerous times. The
* initialization will be performed only on the first time that it is
* called. Therefore, it may be called during packet radio driver
* initialization, even if there are multiple packet radio drivers.
*
* Inputs:
* None
*
* Return Value:
* None
*
****************************************************************************/
void pktradio_metadata_initialize(void);
/****************************************************************************
* Name: pktradio_metadata_allocate
*
* Description:
* The pktradio_metadata_allocate function will get a free meta-data
* structure for use by the packet radio.
*
* This function will first attempt to allocate from the g_free_metadata
* list. If that the list is empty, then the meta-data structure will be
* allocated from the dynamic memory pool.
*
* Inputs:
* None
*
* Return Value:
* A reference to the allocated metadata structure. All user fields in this
* structure have been zeroed. On a failure to allocate, NULL is
* returned.
*
****************************************************************************/
FAR struct pktradio_metadata_s *pktradio_metadata_allocate(void);
/****************************************************************************
* Name: pktradio_metadata_free
*
* Description:
* The pktradio_metadata_free function will return a metadata structure
* to the free list of messages if it was a pre-allocated metadata
* structure. If the metadata structure was allocated dynamically it will
* be deallocated.
*
* Inputs:
* metadata - metadata structure to free
*
* Return Value:
* None
*
****************************************************************************/
void pktradio_metadata_free(FAR struct pktradio_metadata_s *metadata);
#endif /* __INCLUDE_NUTTX_WIRELESS_PKTRADIO_H */

View File

@ -132,7 +132,7 @@ config NET_ETHERNET
Ethernet -- it is the default).
config NET_6LOWPAN
bool "IEEE 802.15.4 6LoWPAN support"
bool "6LoWPAN support"
default n
select NETDEV_MULTINIC if NET_ETHERNET || NET_LOOPBACK || NET_SLIP || NET_TUN
select NET_MULTILINK if NET_ETHERNET || NET_LOOPBACK || NET_SLIP || NET_TUN
@ -140,8 +140,8 @@ config NET_6LOWPAN
select NET_HAVE_STAR
depends on NET_IPv6
---help---
Enable support for IEEE 802.15.4 Low power Wireless Personal Area
Networking (6LoWPAN).
Enable support for Low power Wireless Personal Area Networking (6LoWPAN)
for IEEE 802.15.4 or other packet radios.
config NET_LOOPBACK
bool "Local loopback"

View File

@ -1,7 +1,7 @@
/****************************************************************************
* net/devif/devif_poll.c
*
* Copyright (C) 2007-2010, 2012, 2014, 2016 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2010, 2012, 2014, 2016-2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -89,23 +89,23 @@ systime_t g_polltime;
* Name: devif_packet_conversion
*
* Description:
* Generic output conversion hook. Only needed for IEEE802.15.4 for now
* but this is a point where support for other conversions may be
* provided.
* Generic output conversion hook. Only needed for IEEE802.15.4 (and
* other non-standard packet radios) for now but this 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.
* 1. TCP socket output. For the case of TCP output to a radio,
* the TCP output is caught in the socket send()/sendto() logic 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.
* to return with d_len > 0 and (2) that the device is a radio
* network driver. Under those conditions, 6LoWPAN logic will be called
* to create the radio frames.
*
* All outgoing ICMPv6 messages come through one of two mechanisms:
*
@ -122,79 +122,81 @@ systime_t g_polltime;
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
{
FAR struct ipv6_hdr_s *ipv6 = (FAR struct ipv6_hdr_s *)dev->d_buf;
#ifdef CONFIG_NET_MULTILINK
/* Handle the case where multiple link layer protocols are supported */
if (dev->d_lltype == NET_LL_IEEE802154 ||
dev->d_lltype == NET_LL_PKTRADIO)
#endif
{
FAR struct ipv6_hdr_s *ipv6 = (FAR struct ipv6_hdr_s *)dev->d_buf;
#ifdef CONFIG_NET_IPv4
if ((ipv6->vtc & IP_VERSION_MASK) != IPv6_VERSION)
{
nerr("ERROR: IPv6 version error: %02x... Packet dropped\n",
ipv6->vtc);
}
else
if ((ipv6->vtc & IP_VERSION_MASK) != IPv6_VERSION)
{
nerr("ERROR: IPv6 version error: %02x... Packet dropped\n",
ipv6->vtc);
}
else
#endif
#ifdef CONFIG_NET_TCP
if (pkttype == DEVIF_TCP)
{
/* 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->proto == IP_PROTO_TCP)
if (pkttype == DEVIF_TCP)
{
/* Let 6LoWPAN convert IPv6 TCP output into IEEE802.15.4 frames. */
/* This packet came from a response to TCP polling and is
* directed to an radio driver using 6LoWPAN. Verify that the
* outgoing packet is IPv6 with TCP protocol.
*/
sixlowpan_tcp_send(dev, dev, ipv6);
if (ipv6->proto == IP_PROTO_TCP)
{
/* Let 6LoWPAN convert IPv6 TCP output into radio frames. */
sixlowpan_tcp_send(dev, dev, ipv6);
}
else
{
nerr("ERROR: TCP protocol error: %u... Packet dropped\n",
ipv6->proto);
}
}
else
{
nerr("ERROR: TCP protocol error: %u... Packet dropped\n",
ipv6->proto);
}
}
else
#endif
#ifdef CONFIG_NET_ICMPv6
if (pkttype == DEVIF_ICMP6)
{
/* 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->proto == IP_PROTO_ICMP6)
if (pkttype == DEVIF_ICMP6)
{
/* Let 6LoWPAN convert IPv6 ICMPv6 output into IEEE802.15.4 frames. */
/* This packet came from a response to TCP polling and is
* directed to a radio using 6LoWPAN. Verify that the outgoing
* packet is IPv6 with TCP protocol.
*/
sixlowpan_icmpv6_send(dev, dev, ipv6);
if (ipv6->proto == IP_PROTO_ICMP6)
{
/* Let 6LoWPAN convert IPv6 ICMPv6 output into radio frames. */
sixlowpan_icmpv6_send(dev, dev, ipv6);
}
else
{
nerr("ERROR: ICMPv6 protocol error: %u... Packet dropped\n",
ipv6->proto);
}
}
else
{
nerr("ERROR: ICMPv6 protocol error: %u... Packet dropped\n",
ipv6->proto);
}
}
else
#endif
{
nerr("ERROR: Unhandled packet dropped. pkttype=%u protocol=%u\n",
pkttype, ipv6->proto);
}
{
nerr("ERROR: Unhandled packet dropped. pkttype=%u protocol=%u\n",
pkttype, ipv6->proto);
}
UNUSED(ipv6);
dev->d_len = 0;
UNUSED(ipv6);
dev->d_len = 0;
}
}
}
#else
# define devif_packet_conversion(dev,pkttype)
# define devif_packet_conversion(dev,pkttype)
#endif /* CONFIG_NET_6LOWPAN */
/****************************************************************************

View File

@ -79,7 +79,11 @@
#elif defined(CONFIG_NET_ETHERNET)
# define DEV_LLTYPE(d) NET_LL_ETHERNET
#elif defined(CONFIG_NET_6LOWPAN)
# define DEV_LLTYPE(d) NET_LL_IEEE802154
# if defined(CONFIG_WIRELESS_IEEE802154)
# define DEV_LLTYPE(d) NET_LL_IEEE802154
# elif defined(CONFIG_WIRELESS_PKTRADIO)
# define DEV_LLTYPE(d) NET_LL_PKTRADIO
# endif
#elif defined(CONFIG_NET_SLIP)
# define DEV_LLTYPE(d) NET_LL_SLIP
#elif defined(CONFIG_NET_TUN)

View File

@ -56,9 +56,9 @@
* Name: ipfwd_packet_proto
*
* Description:
* Generic output conversion hook. Only needed for IEEE802.15.4 for now
* but this is a point where support for other conversions may be
* provided.
* Generic output conversion hook. Only needed for IEEE802.15.4 (and
* other, non-standard packet radios) for now but this is a point where
* support for other conversions may be provided.
*
****************************************************************************/
@ -77,10 +77,11 @@ static int ipfwd_packet_proto(FAR struct net_driver_s *dev)
#ifdef CONFIG_NET_MULTILINK
/* Handle the case where multiple link layer protocols are supported */
if (dev->d_lltype == NET_LL_IEEE802154)
if (dev->d_lltype == NET_LL_IEEE802154 ||
dev->d_lltype == NET_LL_PKTRADIO)
#endif
{
/* There should be an IPv6 packet in the at the beginning of the debugger */
/* There should be an IPv6 packet at the beginning of the buffer */
ipv6 = (FAR struct ipv6_hdr_s *)&dev->d_buf[llhdrlen];
if ((ipv6->vtc & IP_VERSION_MASK) == IPv6_VERSION)
@ -100,55 +101,57 @@ static int ipfwd_packet_proto(FAR struct net_driver_s *dev)
* Name: ipfwd_packet_conversion
*
* Description:
* Generic output conversion hook. Only needed for IEEE802.15.4 for now
* but this is a point where support for other conversions may be
* provided.
* Generic output conversion hook. Only needed for IEEE802.15.4 (and
* other, non-standard packet radios) for now but this is a point where
* support for other conversions may be provided.
*
****************************************************************************/
#ifdef CONFIG_NET_6LOWPAN
static void ipfwd_packet_conversion(FAR struct net_driver_s *dev, int proto)
{
#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
{
#ifdef CONFIG_NET_TCP
if (proto == IP_PROTO_TCP)
{
/* Let 6LoWPAN convert IPv6 TCP output into IEEE802.15.4 frames. */
#ifdef CONFIG_NET_MULTILINK
/* Handle the case where multiple link layer protocols are supported */
sixlowpan_tcp_send(dev, dev, ipv6);
}
else
if (dev->d_lltype == NET_LL_IEEE802154 ||
dev->d_lltype == NET_LL_PKTRADIO)
#endif
{
#ifdef CONFIG_NET_TCP
if (proto == IP_PROTO_TCP)
{
/* Let 6LoWPAN convert IPv6 TCP output into radio frames. */
sixlowpan_tcp_send(dev, dev, ipv6);
}
else
#endif
#ifdef CONFIG_NET_UDP
if (proto == IP_PROTO_UDP)
{
/* Let 6LoWPAN convert IPv6 UDP output into IEEE802.15.4 frames. */
if (proto == IP_PROTO_UDP)
{
/* Let 6LoWPAN convert IPv6 UDP output into radio frames. */
sixlowpan_udp_send(dev, dev, ipv6);
}
else
sixlowpan_udp_send(dev, dev, ipv6);
}
else
#endif
#ifdef CONFIG_NET_ICMPv6
if (proto == IP_PROTO_ICMP6)
{
/* Let 6LoWPAN convert IPv6 UDP output into IEEE802.15.4 frames. */
if (proto == IP_PROTO_ICMP6)
{
/* Let 6LoWPAN convert IPv6 UDP output into radio frames. */
sixlowpan_icmpv6_send(dev, dev, ipv6);
}
else
sixlowpan_icmpv6_send(dev, dev, ipv6);
}
else
#endif
{
nwarn("WARNING: Non-TCP packet dropped. Packet type: %u\n", proto);
}
{
nwarn("WARNING: Unsupported protocol (%u). Packet dropped\n", proto);
}
dev->d_len = 0;
dev->d_len = 0;
}
}
}
#endif /* CONFIG_NET_6LOWPAN */

View File

@ -208,7 +208,8 @@ static int ipv6_packet_conversion(FAR struct net_driver_s *dev,
#ifdef CONFIG_NET_MULTILINK
/* Handle the case where multiple link layer protocols are supported */
if (fwddev->d_lltype == NET_LL_IEEE802154)
if (fwddev->d_lltype != NET_LL_IEEE802154 &&
fwddev->d_lltype != NET_LL_PKTRADIO)
{
nwarn("WARNING: Unsupported link layer... Not forwarded\n");
}

View File

@ -231,6 +231,7 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype)
#ifdef CONFIG_NET_6LOWPAN
case NET_LL_IEEE802154: /* IEEE 802.15.4 MAC */
case NET_LL_PKTRADIO: /* Non-IEEE 802.15.4 packet radio */
dev->d_llhdrlen = 0;
dev->d_mtu = CONFIG_NET_6LOWPAN_MTU;
#ifdef CONFIG_NET_TCP

View File

@ -86,7 +86,7 @@ void sixlowpan_initialize(void);
* psock_6lowpan_tcp_send() call may be used only when the TCP socket is in a
* connected state (so that the intended recipient is known).
*
* Parameters:
* Input Parmeters
* psock - An instance of the internal socket structure.
* buf - Data to send
* len - Length of data to send
@ -126,7 +126,7 @@ ssize_t psock_6lowpan_tcp_send(FAR struct socket *psock, FAR const void *buf,
* driver. Under those conditions, this function will be called to create
* the IEEE80215.4 frames.
*
* Parameters:
* Input Parmeters
* dev - The network device containing the packet to be sent.
* fwddev - The network device used to send the data. This will be the
* same device except for the IP forwarding case where packets
@ -159,7 +159,7 @@ void sixlowpan_tcp_send(FAR struct net_driver_s *dev,
*
* Both cases are handled here.
*
* Parameters:
* Input Parmeters
* dev - The network device containing the packet to be sent.
* fwddev - The network device used to send the data. This will be the
* same device except for the IP forwarding case where packets
@ -189,7 +189,7 @@ void sixlowpan_icmpv6_send(FAR struct net_driver_s *dev,
* psock_6lowpan_udp_send() call may be used with connectionlesss UDP
* sockets.
*
* Parameters:
* Input Parmeters
* psock - An instance of the internal socket structure.
* buf - Data to send
* len - Length of data to send
@ -219,7 +219,7 @@ ssize_t psock_6lowpan_udp_send(FAR struct socket *psock, FAR const void *buf,
* may be returned when they are not NULL and 0), and the error ENOTCONN is
* returned when the socket was not actually connected.
*
* Parameters:
* Input Parmeters
* psock A pointer to a NuttX-specific, internal socket structure
* buf Data to send
* len Length of data to send
@ -251,7 +251,7 @@ ssize_t psock_6lowpan_udp_sendto(FAR struct socket *psock,
* Handles forwarding a UDP packet via 6LoWPAN. This is currently only
* used by the IPv6 forwarding logic.
*
* Parameters:
* Input Parmeters
* dev - An instance of nework device state structure
* fwddev - The network device used to send the data. This will be the
* same device except for the IP forwarding case where packets

View File

@ -211,7 +211,7 @@ static uint16_t sixlowpan_protosize(FAR const struct ipv6_hdr_s *ipv6hdr,
* where they are queue for transfer.
*
* Input Parameters:
* ieee - The IEEE802.15.4 MAC driver instance
* radio - The radio network driver instance
* ipv6 - IPv6 header followed by TCP, UDP, or ICMPv6 header.
* buf - Beginning of the packet packet to send (with IPv6 + protocol
* headers)
@ -229,7 +229,7 @@ static uint16_t sixlowpan_protosize(FAR const struct ipv6_hdr_s *ipv6hdr,
*
****************************************************************************/
int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
int sixlowpan_queue_frames(FAR struct sixlowpan_driver_s *radio,
FAR const struct ipv6_hdr_s *ipv6,
FAR const void *buf, size_t buflen,
FAR const struct sixlowpan_tagaddr_s *destmac)
@ -318,10 +318,10 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
pktmeta.sextended = TRUE;
sixlowpan_eaddrcopy(pktmeta.source.eaddr.u8,
&ieee->i_dev.d_mac.ieee802154);
&radio->r_dev.d_mac.ieee802154);
#else
sixlowpan_saddrcopy(pktmeta.source.saddr.u8,
&ieee->i_dev.d_mac.ieee802154);
&radio->r_dev.d_mac.ieee802154);
#endif
/* Copy the destination node address into the meta data */
@ -342,14 +342,14 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
* PAN IDs are the same.
*/
(void)sixlowpan_src_panid(ieee, pktmeta.dpanid);
(void)sixlowpan_src_panid(radio, pktmeta.dpanid);
/* Based on the collected attributes and addresses, construct the MAC meta
* data structure that we need to interface with the IEEE802.15.4 MAC (we
* will update the MSDU payload size when the IOB has been setup).
*/
ret = sixlowpan_meta_data(ieee, &pktmeta, &meta, 0);
ret = sixlowpan_meta_data(radio, &pktmeta, &meta, 0);
if (ret < 0)
{
nerr("ERROR: sixlowpan_meta_data() failed: %d\n", ret);
@ -357,7 +357,7 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
/* Pre-calculate frame header length. */
framer_hdrlen = sixlowpan_frame_hdrlen(ieee, &meta);
framer_hdrlen = sixlowpan_frame_hdrlen(radio, &meta);
if (framer_hdrlen < 0)
{
/* Failed to determine the size of the header failed. */
@ -379,9 +379,9 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
/* Try to compress the headers */
#if defined(CONFIG_NET_6LOWPAN_COMPRESSION_HC1)
ret = sixlowpan_compresshdr_hc1(ieee, ipv6, destmac, fptr);
ret = sixlowpan_compresshdr_hc1(radio, ipv6, destmac, fptr);
#elif defined(CONFIG_NET_6LOWPAN_COMPRESSION_HC06)
ret = sixlowpan_compresshdr_hc06(ieee, ipv6, destmac, fptr);
ret = sixlowpan_compresshdr_hc06(radio, ipv6, destmac, fptr);
#else
# error No compression specified
#endif
@ -455,7 +455,7 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
pktlen = buflen + g_uncomp_hdrlen + protosize;
PUTHOST16(fragptr, SIXLOWPAN_FRAG_DISPATCH_SIZE,
((SIXLOWPAN_DISPATCH_FRAG1 << 8) | pktlen));
PUTHOST16(fragptr, SIXLOWPAN_FRAG_TAG, ieee->i_dgramtag);
PUTHOST16(fragptr, SIXLOWPAN_FRAG_TAG, radio->r_dgramtag);
g_frame_hdrlen += SIXLOWPAN_FRAG1_HDR_LEN;
@ -482,7 +482,7 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
outlen = paysize;
ninfo("First fragment: length %d, tag %d\n",
paysize, ieee->i_dgramtag);
paysize, radio->r_dgramtag);
sixlowpan_dumpbuffer("Outgoing frame",
(FAR const uint8_t *)iob->io_data, iob->io_len);
@ -537,7 +537,7 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
PUTHOST16(fragptr, SIXLOWPAN_FRAG_DISPATCH_SIZE,
((SIXLOWPAN_DISPATCH_FRAGN << 8) | pktlen));
PUTHOST16(fragptr, SIXLOWPAN_FRAG_TAG, ieee->i_dgramtag);
PUTHOST16(fragptr, SIXLOWPAN_FRAG_TAG, radio->r_dgramtag);
fragptr[SIXLOWPAN_FRAG_OFFSET] = outlen >> 3;
fragn_hdrlen += SIXLOWPAN_FRAGN_HDR_LEN;
@ -561,8 +561,8 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
iob->io_len = paysize + fragn_hdrlen;
outlen += paysize;
ninfo("Fragment offset=%d, paysize=%d, i_dgramtag=%d\n",
outlen >> 3, paysize, ieee->i_dgramtag);
ninfo("Fragment offset=%d, paysize=%d, r_dgramtag=%d\n",
outlen >> 3, paysize, radio->r_dgramtag);
sixlowpan_dumpbuffer("Outgoing frame",
(FAR const uint8_t *)iob->io_data,
iob->io_len);
@ -595,7 +595,7 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
/* And submit the frame to the MAC */
ninfo("Submitting frame\n");
ret = sixlowpan_frame_submit(ieee, &meta, iob);
ret = sixlowpan_frame_submit(radio, &meta, iob);
if (ret < 0)
{
nerr("ERROR: sixlowpan_frame_submit() failed: %d\n", ret);
@ -604,7 +604,7 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
/* Update the datagram TAG value */
ieee->i_dgramtag++;
radio->r_dgramtag++;
#else
nerr("ERROR: Packet too large: %d\n", buflen);
nerr(" Cannot to be sent without fragmentation support\n");
@ -644,7 +644,7 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
ninfo("Submitting frame length=%u io_offset=%u\n",
iob->io_len, iob->io_offset);
ret = sixlowpan_frame_submit(ieee, &meta, iob);
ret = sixlowpan_frame_submit(radio, &meta, iob);
if (ret < 0)
{
nerr("ERROR: sixlowpan_frame_submit() failed: %d\n", ret);

View File

@ -137,7 +137,7 @@ static inline bool sixlowpan_eaddrnull(FAR const uint8_t *eaddr)
* data structure that we need to interface with the IEEE802.15.4 MAC.
*
* Input Parameters:
* ieee - IEEE 802.15.4 MAC driver state reference.
* radio - Radio network driver state instance.
* pktmeta - Meta-data specific to the current outgoing frame
* meta - Location to return the corresponding meta data.
* paylen - The size of the data payload to be sent.
@ -150,7 +150,7 @@ static inline bool sixlowpan_eaddrnull(FAR const uint8_t *eaddr)
*
****************************************************************************/
int sixlowpan_meta_data(FAR struct ieee802154_driver_s *ieee,
int sixlowpan_meta_data(FAR struct sixlowpan_driver_s *radio,
FAR const struct packet_metadata_s *pktmeta,
FAR struct ieee802154_frame_meta_s *meta,
uint16_t paylen)
@ -223,7 +223,7 @@ int sixlowpan_meta_data(FAR struct ieee802154_driver_s *ieee,
* fragment of a disassembled packet.
*/
meta->handle = ieee->i_msdu_handle++;
meta->handle = radio->r_msdu_handle++;
#ifdef CONFIG_IEEE802154_SECURITY
# warning CONFIG_IEEE802154_SECURITY not yet supported
@ -247,7 +247,7 @@ int sixlowpan_meta_data(FAR struct ieee802154_driver_s *ieee,
* buffer is required to make this determination.
*
* Input parameters:
* ieee - A reference IEEE802.15.4 MAC network device structure.
* radio - A reference IEEE802.15.4 MAC network device structure.
* meta - Meta data that describes the MAC header
*
* Returned Value:
@ -256,10 +256,10 @@ int sixlowpan_meta_data(FAR struct ieee802154_driver_s *ieee,
*
****************************************************************************/
int sixlowpan_frame_hdrlen(FAR struct ieee802154_driver_s *ieee,
int sixlowpan_frame_hdrlen(FAR struct sixlowpan_driver_s *radio,
FAR const struct ieee802154_frame_meta_s *meta)
{
return ieee->i_get_mhrlen(ieee, meta);
return radio->r_get_mhrlen(radio, meta);
}
/****************************************************************************
@ -272,7 +272,7 @@ int sixlowpan_frame_hdrlen(FAR struct ieee802154_driver_s *ieee,
* submits any new outgoing frame to the MAC.
*
* Input parameters:
* ieee - A reference IEEE802.15.4 MAC network device structure.
* radio - A reference to a radio network device instance.
* meta - Meta data that describes the MAC header
* frame - The IOB containing the frame to be submitted.
*
@ -282,11 +282,11 @@ int sixlowpan_frame_hdrlen(FAR struct ieee802154_driver_s *ieee,
*
****************************************************************************/
int sixlowpan_frame_submit(FAR struct ieee802154_driver_s *ieee,
int sixlowpan_frame_submit(FAR struct sixlowpan_driver_s *radio,
FAR const struct ieee802154_frame_meta_s *meta,
FAR struct iob_s *frame)
{
return ieee->i_req_data(ieee, meta, frame);
return radio->r_req_data(radio, meta, frame);
}
#endif /* CONFIG_NET_6LOWPAN */

View File

@ -589,7 +589,7 @@ void sixlowpan_hc06_initialize(void)
* neither compress the IID.
*
* Input Parameters:
* ieee - A reference to the IEE802.15.4 network device state
* radio - A reference to a radio network device instance
* ipv6 - The IPv6 header to be compressed
* destmac - L2 destination address, needed to compress the IP
* destination field
@ -601,7 +601,7 @@ void sixlowpan_hc06_initialize(void)
*
****************************************************************************/
int sixlowpan_compresshdr_hc06(FAR struct ieee802154_driver_s *ieee,
int sixlowpan_compresshdr_hc06(FAR struct sixlowpan_driver_s *radio,
FAR const struct ipv6_hdr_s *ipv6,
FAR const struct sixlowpan_tagaddr_s *destmac,
FAR uint8_t *fptr)
@ -772,7 +772,7 @@ int sixlowpan_compresshdr_hc06(FAR struct ieee802154_driver_s *ieee,
/* Compression compare with this nodes address (source) */
iphc1 |= compress_laddr(ipv6->srcipaddr,
&ieee->i_dev.d_mac.ieee802154,
&radio->r_dev.d_mac.ieee802154,
SIXLOWPAN_IPHC_SAM_BIT);
}
@ -783,7 +783,7 @@ int sixlowpan_compresshdr_hc06(FAR struct ieee802154_driver_s *ieee,
ipv6->srcipaddr[3] == 0)
{
iphc1 |= compress_laddr(ipv6->srcipaddr,
&ieee->i_dev.d_mac.ieee802154,
&radio->r_dev.d_mac.ieee802154,
SIXLOWPAN_IPHC_SAM_BIT);
}
else

View File

@ -132,7 +132,7 @@ static void sixlowpan_uncompress_addr(FAR const struct ieee802154_addr_s *addr,
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*
* Input Parmeters:
* ieee - A reference to the IEE802.15.4 network device state
* radio - A reference to a radio network device instance
* ipv6 - The IPv6 header followd by TCP, UDP, or ICMPv6 header to be
* compressed
* destmac - L2 destination address, needed to compress the IP
@ -145,7 +145,7 @@ static void sixlowpan_uncompress_addr(FAR const struct ieee802154_addr_s *addr,
*
****************************************************************************/
int sixlowpan_compresshdr_hc1(FAR struct ieee802154_driver_s *ieee,
int sixlowpan_compresshdr_hc1(FAR struct sixlowpan_driver_s *radio,
FAR const struct ipv6_hdr_s *ipv6,
FAR const struct sixlowpan_tagaddr_s *destmac,
FAR uint8_t *fptr)
@ -157,7 +157,7 @@ int sixlowpan_compresshdr_hc1(FAR struct ieee802154_driver_s *ieee,
if (ipv6->vtc != 0x60 || ipv6->tcf != 0 || ipv6->flow != 0 ||
!sixlowpan_islinklocal(ipv6->srcipaddr) ||
!sixlowpan_isaddrbased(ipv6->srcipaddr, &ieee->i_dev.d_mac.ieee802154) ||
!sixlowpan_isaddrbased(ipv6->srcipaddr, &radio->r_dev.d_mac.ieee802154) ||
!sixlowpan_islinklocal(ipv6->destipaddr) ||
!sixlowpan_ismacbased(ipv6->destipaddr, destmac) ||
( 1

View File

@ -61,7 +61,7 @@
* Handles forwarding a ICMPv6 packet via 6LoWPAN. This is currently only
* used by the IPv6 forwarding logic.
*
* Parameters:
* Input Parmeters
* dev - An instance of nework device state structure
* fwddev - The network device used to send the data. This will be the
* same device except for the IP forwarding case where packets
@ -117,7 +117,7 @@ void sixlowpan_icmpv6_send(FAR struct net_driver_s *dev,
* assumes an encoding of the MAC address in the IPv6 address.
*/
ret = sixlowpan_destaddrfromip((FAR struct ieee802154_driver_s *)dev,
ret = sixlowpan_destaddrfromip((FAR struct sixlowpan_driver_s *)dev,
ipv6icmpv6->ipv6.destipaddr, &destmac);
if (ret < 0)
{
@ -147,7 +147,7 @@ void sixlowpan_icmpv6_send(FAR struct net_driver_s *dev,
buflen = dev->d_len - hdrlen;
(void)sixlowpan_queue_frames(
(FAR struct ieee802154_driver_s *)fwddev,
(FAR struct sixlowpan_driver_s *)fwddev,
&ipv6icmpv6->ipv6, buf, buflen, &destmac);
}
}

View File

@ -139,15 +139,15 @@ static uint8_t g_bitbucket[UNCOMP_MAXHDR];
* the previosly received fragements.
*
* Input Parameters:
* ieee - IEEE 802.15.4 MAC driver state reference
* ind - Characteristics of the newly received frame
* radio - Radio network device driver state instance
* ind - Characteristics of the newly received frame
*
* Returned Value:
* true if the sources are the same.
*
****************************************************************************/
static bool sixlowpan_compare_fragsrc(FAR struct ieee802154_driver_s *ieee,
static bool sixlowpan_compare_fragsrc(FAR struct sixlowpan_driver_s *radio,
FAR const struct ieee802154_data_ind_s *ind)
{
/* Check for an extended source address */
@ -156,22 +156,22 @@ static bool sixlowpan_compare_fragsrc(FAR struct ieee802154_driver_s *ieee,
{
/* Was the first source address also extended? */
if (ieee->i_fragsrc.extended)
if (radio->r_fragsrc.extended)
{
/* Yes.. perform the extended address comparison */
return sixlowpan_eaddrcmp(ieee->i_fragsrc.u.eaddr.u8, ind->src.eaddr);
return sixlowpan_eaddrcmp(radio->r_fragsrc.u.eaddr.u8, ind->src.eaddr);
}
}
else
{
/* Short source address. Was the first source address also short? */
if (!ieee->i_fragsrc.extended)
if (!radio->r_fragsrc.extended)
{
/* Yes.. perform the extended short comparison */
return sixlowpan_saddrcmp(ieee->i_fragsrc.u.saddr.u8, &ind->src.saddr);
return sixlowpan_saddrcmp(radio->r_fragsrc.u.saddr.u8, &ind->src.saddr);
}
}
@ -286,9 +286,9 @@ static void sixlowpan_uncompress_ipv6hdr(FAR uint8_t *fptr, FAR uint8_t *bptr)
* SHALL in the RFC 4944 and should never happen)
*
* Input Parameters:
* ieee - The IEEE802.15.4 MAC network driver interface.
* ind - Meta data characterizing the received frame.
* iob - The IOB containing the frame.
* radio - The radio network device driver interface.
* ind - Meta data characterizing the received frame.
* iob - The IOB containing the frame.
*
* Returned Value:
* On success, a value greater than equal to zero is returned, either:
@ -304,7 +304,7 @@ static void sixlowpan_uncompress_ipv6hdr(FAR uint8_t *fptr, FAR uint8_t *bptr)
*
****************************************************************************/
static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
static int sixlowpan_frame_process(FAR struct sixlowpan_driver_s *radio,
FAR const struct ieee802154_data_ind_s *ind,
FAR struct iob_s *iob)
{
@ -381,8 +381,8 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
ninfo("FRAGN: fragsize=%d fragtag=%d fragoffset=%d\n",
fragsize, fragtag, fragoffset);
ninfo("FRAGN: i_accumlen=%d paysize=%u fragsize=%u\n",
ieee->i_accumlen, iob->io_len - g_frame_hdrlen, fragsize);
ninfo("FRAGN: r_accumlen=%d paysize=%u fragsize=%u\n",
radio->r_accumlen, iob->io_len - g_frame_hdrlen, fragsize);
/* Indicate that this frame is a another fragment for reassembly */
@ -398,17 +398,17 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
/* Check if we are currently reassembling a packet */
bptr = ieee->i_dev.d_buf;
if (ieee->i_accumlen > 0)
bptr = radio->r_dev.d_buf;
if (radio->r_accumlen > 0)
{
/* If reassembly timed out, cancel it */
elapsed = clock_systimer() - ieee->i_time;
elapsed = clock_systimer() - radio->r_time;
if (elapsed > NET_6LOWPAN_TIMEOUT)
{
nwarn("WARNING: Reassembly timed out\n");
ieee->i_pktlen = 0;
ieee->i_accumlen = 0;
radio->r_pktlen = 0;
radio->r_accumlen = 0;
}
/* In this case what we expect is that the next frame will hold the
@ -433,8 +433,8 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
/* Discard the partially assembled packet */
nwarn("WARNING: Non-fragment frame received during reassembly\n");
ieee->i_pktlen = 0;
ieee->i_accumlen = 0;
radio->r_pktlen = 0;
radio->r_accumlen = 0;
}
/* It is a fragment of some kind. Drop any zero length fragments */
@ -452,14 +452,14 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
else if (isfirstfrag)
{
nwarn("WARNING: First fragment frame received during reassembly\n");
ieee->i_pktlen = 0;
ieee->i_accumlen = 0;
radio->r_pktlen = 0;
radio->r_accumlen = 0;
}
/* Verify that this fragment is part of that reassembly sequence */
else if (fragsize != ieee->i_pktlen || ieee->i_reasstag != fragtag ||
!sixlowpan_compare_fragsrc(ieee, ind))
else if (fragsize != radio->r_pktlen || radio->r_reasstag != fragtag ||
!sixlowpan_compare_fragsrc(radio, ind))
{
/* The packet is a fragment that does not belong to the packet
* being reassembled or the packet is not a fragment.
@ -504,12 +504,12 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
return -ENOSPC;
}
ieee->i_pktlen = fragsize;
ieee->i_reasstag = fragtag;
ieee->i_time = clock_systimer();
radio->r_pktlen = fragsize;
radio->r_reasstag = fragtag;
radio->r_time = clock_systimer();
ninfo("Starting reassembly: i_pktlen %u, i_reasstag %d\n",
ieee->i_pktlen, ieee->i_reasstag);
ninfo("Starting reassembly: r_pktlen %u, r_reasstag %d\n",
radio->r_pktlen, radio->r_reasstag);
/* Extract the source address from the 'ind' meta data. NOTE that the
* size of the source address may be different that our local, destination
@ -518,13 +518,13 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
if (ind->src.mode == IEEE802154_ADDRMODE_EXTENDED)
{
ieee->i_fragsrc.extended = true;
sixlowpan_eaddrcopy(ieee->i_fragsrc.u.eaddr.u8, ind->src.eaddr);
radio->r_fragsrc.extended = true;
sixlowpan_eaddrcopy(radio->r_fragsrc.u.eaddr.u8, ind->src.eaddr);
}
else
{
memset(&ieee->i_fragsrc, 0, sizeof(struct sixlowpan_tagaddr_s));
sixlowpan_saddrcopy(ieee->i_fragsrc.u.saddr.u8, &ind->src.saddr);
memset(&radio->r_fragsrc, 0, sizeof(struct sixlowpan_tagaddr_s));
sixlowpan_saddrcopy(radio->r_fragsrc.u.saddr.u8, &ind->src.saddr);
}
}
#endif /* CONFIG_NET_6LOWPAN_FRAG */
@ -573,7 +573,7 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
* begin placing the data payload.
*/
ieee->i_boffset = g_uncomp_hdrlen;
radio->r_boffset = g_uncomp_hdrlen;
}
/* No.. is this a subsequent fragment in the same sequence? */
@ -584,7 +584,7 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
* we began placing payload data.
*/
g_uncomp_hdrlen = ieee->i_boffset;
g_uncomp_hdrlen = radio->r_boffset;
}
#endif /* CONFIG_NET_6LOWPAN_FRAG */
@ -613,11 +613,11 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
return -ENOMEM;
}
memcpy(ieee->i_dev.d_buf + g_uncomp_hdrlen + (fragoffset << 3),
memcpy(radio->r_dev.d_buf + g_uncomp_hdrlen + (fragoffset << 3),
fptr + g_frame_hdrlen, paysize);
#ifdef CONFIG_NET_6LOWPAN_FRAG
/* Update ieee->i_accumlen if the frame is a fragment, ieee->i_pktlen
/* Update radio->r_accumlen if the frame is a fragment, radio->r_pktlen
* otherwise.
*/
@ -629,27 +629,27 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
* bytes at the end. We must be liberal in what we accept.
*/
ieee->i_accumlen = g_uncomp_hdrlen + (fragoffset << 3) + paysize;
radio->r_accumlen = g_uncomp_hdrlen + (fragoffset << 3) + paysize;
}
else
{
ieee->i_pktlen = paysize + g_uncomp_hdrlen;
radio->r_pktlen = paysize + g_uncomp_hdrlen;
}
/* If we have a full IP packet in sixlowpan_buf, deliver it to
* the IP stack
*/
ninfo("i_accumlen=%d i_pktlen=%d paysize=%d\n",
ieee->i_accumlen, ieee->i_pktlen, paysize);
ninfo("r_accumlen=%d r_pktlen=%d paysize=%d\n",
radio->r_accumlen, radio->r_pktlen, paysize);
if (ieee->i_accumlen == 0 || ieee->i_accumlen >= ieee->i_pktlen)
if (radio->r_accumlen == 0 || radio->r_accumlen >= radio->r_pktlen)
{
ninfo("IP packet ready (length %d)\n", ieee->i_pktlen);
ninfo("IP packet ready (length %d)\n", radio->r_pktlen);
ieee->i_dev.d_len = ieee->i_pktlen;
ieee->i_pktlen = 0;
ieee->i_accumlen = 0;
radio->r_dev.d_len = radio->r_pktlen;
radio->r_pktlen = 0;
radio->r_accumlen = 0;
return INPUT_COMPLETE;
}
@ -657,7 +657,7 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
#else
/* Deliver the packet to the IP stack */
ieee->i_dev.d_len = paysize + g_uncomp_hdrlen;
radio->r_dev.d_len = paysize + g_uncomp_hdrlen;
return INPUT_COMPLETE;
#endif /* CONFIG_NET_6LOWPAN_FRAG */
}
@ -668,38 +668,38 @@ static int sixlowpan_frame_process(FAR struct ieee802154_driver_s *ieee,
* Description:
* Inject the packet in d_buf into the network for normal packet processing.
*
* Parameters:
* ieee - The IEEE802.15.4 MAC network driver interface.
* Input Parmeters
* radio - The IEEE802.15.4 MAC network driver interface.
*
* Returned Value:
* None
*
****************************************************************************/
static int sixlowpan_dispatch(FAR struct ieee802154_driver_s *ieee)
static int sixlowpan_dispatch(FAR struct sixlowpan_driver_s *radio)
{
sixlowpan_dumpbuffer("Incoming packet",
(FAR const uint8_t *)IPv6BUF(&ieee->i_dev),
ieee->i_dev.d_len);
(FAR const uint8_t *)IPv6BUF(&radio->r_dev),
radio->r_dev.d_len);
#ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the packet tap */
ninfo("Packet tap\n");
pkt_input(&ieee->i_dev);
pkt_input(&radio->r_dev);
#endif
/* We only accept IPv6 packets. */
ninfo("IPv6 packet dispatch\n");
NETDEV_RXIPV6(&ieee->i_dev);
NETDEV_RXIPV6(&radio->r_dev);
/* Give the IPv6 packet to the network layer. NOTE: If there is a
* problem with IPv6 header, it will be silently dropped and d_len will
* be set to zero. Oddly, ipv6_input() will return OK in this case.
*/
return ipv6_input(&ieee->i_dev);
return ipv6_input(&radio->r_dev);
}
/****************************************************************************
@ -712,15 +712,14 @@ static int sixlowpan_dispatch(FAR struct ieee802154_driver_s *ieee)
* Description:
* Process an incoming 6LoWPAN frame.
*
* This function is called when the device driver has received an
* IEEE802.15.4 frame from the network. The frame from the device
* driver must be provided in by the IOB frame argument of the
* function call:
* This function is called when the radio device driver has received an
* frame from the network. The frame from the device driver must be
* provided in by the IOB frame argument of the function call:
*
* - The frame data is in the IOB io_data[] buffer,
* - The length of the frame is in the IOB io_len field, and
* - The offset past the IEEE802.15.4 MAC header is provided in the
* io_offset field.
* - The offset past and radio MAC header is provided in the io_offset
* field.
*
* The frame argument may refer to a single frame (a list of length one)
* or may it be the head of a list of multiple frames.
@ -736,8 +735,8 @@ static int sixlowpan_dispatch(FAR struct ieee802154_driver_s *ieee)
*
* After each frame is processed into d_buf, the IOB is deallocated. If
* reassembly is incomplete, the partially reassembled packet must be
* preserved by the IEEE802.15.4 MAC network drvier sand provided again
* when the next frame is received.
* preserved by the radio network drvier and provided again when the next
* frame is received.
*
* When the packet in the d_buf is fully reassembled, it will be provided
* to the network as with any other received packet. d_len will be set
@ -754,11 +753,11 @@ static int sixlowpan_dispatch(FAR struct ieee802154_driver_s *ieee)
* network driver via the req_data() method as with other TX operations.
*
* Input Parameters:
* ieee - The IEEE802.15.4 MAC network driver interface.
* radio The radio network driver interface.
* framelist - The head of an incoming list of frames. Normally this
* would be a single frame. A list may be provided if
* appropriate, however.
* ind - Meta data characterizing the received frame. If there are
* ind - Meta data characterizing the received packet. If there are
* multilple frames in the list, this meta data must apply to
* all of the frames!
*
@ -767,13 +766,13 @@ static int sixlowpan_dispatch(FAR struct ieee802154_driver_s *ieee)
*
****************************************************************************/
int sixlowpan_input(FAR struct ieee802154_driver_s *ieee,
int sixlowpan_input(FAR struct sixlowpan_driver_s *radio,
FAR struct iob_s *framelist,
FAR const struct ieee802154_data_ind_s *ind)
{
int ret = -EINVAL;
DEBUGASSERT(ieee != NULL && framelist != NULL);
DEBUGASSERT(radio != NULL && framelist != NULL);
/* Verify that an frame has been provided. */
@ -790,7 +789,7 @@ int sixlowpan_input(FAR struct ieee802154_driver_s *ieee,
/* Process the frame, decompressing it into the packet buffer */
ret = sixlowpan_frame_process(ieee, ind, iob);
ret = sixlowpan_frame_process(radio, ind, iob);
/* Free the IOB the held the consumed frame */
@ -804,14 +803,14 @@ int sixlowpan_input(FAR struct ieee802154_driver_s *ieee,
{
/* Inject the uncompressed, reassembled packet into the network */
ret = sixlowpan_dispatch(ieee);
ret = sixlowpan_dispatch(radio);
if (ret >= 0)
{
/* Check if this resulted in a request to send an outgoing
* packet.
*/
if (ieee->i_dev.d_len > 0)
if (radio->r_dev.d_len > 0)
{
FAR struct ipv6_hdr_s *ipv6hdr;
FAR uint8_t *buffer;
@ -824,14 +823,14 @@ int sixlowpan_input(FAR struct ieee802154_driver_s *ieee,
* layer protocol header.
*/
ipv6hdr = IPv6BUF(&ieee->i_dev);
ipv6hdr = IPv6BUF(&radio->r_dev);
/* Get the IEEE 802.15.4 MAC address of the destination.
* This assumes an encoding of the MAC address in the IPv6
* address.
*/
ret = sixlowpan_destaddrfromip(ieee, ipv6hdr->destipaddr,
ret = sixlowpan_destaddrfromip(radio, ipv6hdr->destipaddr,
&destmac);
if (ret < 0)
{
@ -848,7 +847,7 @@ int sixlowpan_input(FAR struct ieee802154_driver_s *ieee,
#ifdef CONFIG_NET_TCP
case IP_PROTO_TCP:
{
FAR struct tcp_hdr_s *tcp = TCPBUF(&ieee->i_dev);
FAR struct tcp_hdr_s *tcp = TCPBUF(&radio->r_dev);
uint16_t tcplen;
/* The TCP header length is encoded in the top 4 bits
@ -883,23 +882,23 @@ int sixlowpan_input(FAR struct ieee802154_driver_s *ieee,
}
}
if (hdrlen < ieee->i_dev.d_len)
if (hdrlen < radio->r_dev.d_len)
{
nwarn("WARNING: Packet to small: Have %u need >%u\n",
ieee->i_dev.d_len, hdrlen);
radio->r_dev.d_len, hdrlen);
ret = -ENOBUFS;
goto drop;
}
/* Convert the outgoing packet into a frame list. */
buffer = ieee->i_dev.d_buf + hdrlen;
buflen = ieee->i_dev.d_len - hdrlen;
buffer = radio->r_dev.d_buf + hdrlen;
buflen = radio->r_dev.d_len - hdrlen;
ret = sixlowpan_queue_frames(ieee, ipv6hdr, buffer, buflen,
ret = sixlowpan_queue_frames(radio, ipv6hdr, buffer, buflen,
&destmac);
drop:
ieee->i_dev.d_len = 0;
radio->r_dev.d_len = 0;
}
}
}

View File

@ -225,7 +225,7 @@ extern uint8_t g_frame_hdrlen;
****************************************************************************/
struct net_driver_s; /* Forward reference */
struct ieee802154_driver_s; /* Forward reference */
struct sixlowpan_driver_s; /* Forward reference */
struct devif_callback_s; /* Forward reference */
struct ipv6_hdr_s; /* Forward reference */
struct sixlowpan_addr_s; /* Forward reference */
@ -242,7 +242,7 @@ struct iob_s; /* Forward reference */
* The payload data is in the caller 'buf' and is of length 'buflen'.
* Compressed headers will be added and if necessary the packet is
* fragmented. The resulting packet/fragments are submitted to the MAC
* via the network driver i_req_data method.
* via the network driver r_req_data method.
*
* Input Parameters:
* dev - The IEEE802.15.4 MAC network driver interface.
@ -278,7 +278,7 @@ int sixlowpan_send(FAR struct net_driver_s *dev,
* data structure that we need to interface with the IEEE802.15.4 MAC.
*
* Input Parameters:
* ieee - IEEE 802.15.4 MAC driver state reference.
* radio - Reference to a radio network driver state instance.
* pktmeta - Meta-data specific to the current outgoing frame
* meta - Location to return the corresponding meta data.
* paylen - The size of the data payload to be sent.
@ -291,7 +291,7 @@ int sixlowpan_send(FAR struct net_driver_s *dev,
*
****************************************************************************/
int sixlowpan_meta_data(FAR struct ieee802154_driver_s *ieee,
int sixlowpan_meta_data(FAR struct sixlowpan_driver_s *radio,
FAR const struct packet_metadata_s *pktmeta,
FAR struct ieee802154_frame_meta_s *meta,
uint16_t paylen);
@ -305,8 +305,8 @@ int sixlowpan_meta_data(FAR struct ieee802154_driver_s *ieee,
* buffer is required to make this determination.
*
* Input parameters:
* ieee - A reference IEEE802.15.4 MAC network device structure.
* meta - Meta data that describes the MAC header
* radio - Reference to a radio network driver state instance.
* meta - Meta data that describes the MAC header
*
* Returned Value:
* The frame header length is returnd on success; otherwise, a negated
@ -314,7 +314,7 @@ int sixlowpan_meta_data(FAR struct ieee802154_driver_s *ieee,
*
****************************************************************************/
int sixlowpan_frame_hdrlen(FAR struct ieee802154_driver_s *ieee,
int sixlowpan_frame_hdrlen(FAR struct sixlowpan_driver_s *radio,
FAR const struct ieee802154_frame_meta_s *meta);
/****************************************************************************
@ -327,7 +327,7 @@ int sixlowpan_frame_hdrlen(FAR struct ieee802154_driver_s *ieee,
* submits any new outgoing frame to the MAC.
*
* Input parameters:
* ieee - A reference IEEE802.15.4 MAC network device structure.
* radio - Reference to a radio network driver state instance.
* meta - Meta data that describes the MAC header
* frame - The IOB containing the frame to be submitted.
*
@ -337,7 +337,7 @@ int sixlowpan_frame_hdrlen(FAR struct ieee802154_driver_s *ieee,
*
****************************************************************************/
int sixlowpan_frame_submit(FAR struct ieee802154_driver_s *ieee,
int sixlowpan_frame_submit(FAR struct sixlowpan_driver_s *radio,
FAR const struct ieee802154_frame_meta_s *meta,
FAR struct iob_s *frame);
@ -352,10 +352,10 @@ int sixlowpan_frame_submit(FAR struct ieee802154_driver_s *ieee,
* The payload data is in the caller 'buf' and is of length 'buflen'.
* Compressed headers will be added and if necessary the packet is
* fragmented. The resulting packet/fragments are submitted to the MAC
* via the network driver i_req_data method.
* via the network driver r_req_data method.
*
* Input Parameters:
* ieee - The IEEE802.15.4 MAC driver instance
* radio - Reference to a radio network driver state instance.
* ipv6 - IPv6 header followed by TCP or UDP header.
* buf - Beginning of the packet packet to send (with IPv6 + protocol
* headers)
@ -373,7 +373,7 @@ int sixlowpan_frame_submit(FAR struct ieee802154_driver_s *ieee,
*
****************************************************************************/
int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
int sixlowpan_queue_frames(FAR struct sixlowpan_driver_s *radio,
FAR const struct ipv6_hdr_s *ipv6,
FAR const void *buf, size_t buflen,
FAR const struct sixlowpan_tagaddr_s *destmac);
@ -418,11 +418,11 @@ void sixlowpan_hc06_initialize(void);
* compression
*
* Input Parameters:
* ieee - A reference to the IEE802.15.4 network device state
* ipv6 - The IPv6 header to be compressed
* destmac - L2 destination address, needed to compress the IP
* destination field
* fptr - Pointer to frame to be compressed.
* radio - Reference to a radio network driver state instance.
* ipv6 - The IPv6 header to be compressed
* destmac - L2 destination address, needed to compress the IP
* destination field
* fptr - Pointer to frame to be compressed.
*
* Returned Value:
* On success the indications of the defines COMPRESS_HDR_* are returned.
@ -431,7 +431,7 @@ void sixlowpan_hc06_initialize(void);
****************************************************************************/
#ifdef CONFIG_NET_6LOWPAN_COMPRESSION_HC06
int sixlowpan_compresshdr_hc06(FAR struct ieee802154_driver_s *ieee,
int sixlowpan_compresshdr_hc06(FAR struct sixlowpan_driver_s *radio,
FAR const struct ipv6_hdr_s *ipv6,
FAR const struct sixlowpan_tagaddr_s *destmac,
FAR uint8_t *fptr);
@ -482,7 +482,7 @@ void sixlowpan_uncompresshdr_hc06(FAR const struct ieee802154_data_ind_s *ind,
* uip_buf buffer.
*
* Input Parmeters:
* ieee - A reference to the IEE802.15.4 network device state
* radio - Reference to a radio network driver state instance.
* ipv6 - The IPv6 header to be compressed
* destmac - L2 destination address, needed to compress the IP
* destination field
@ -495,7 +495,7 @@ void sixlowpan_uncompresshdr_hc06(FAR const struct ieee802154_data_ind_s *ind,
****************************************************************************/
#ifdef CONFIG_NET_6LOWPAN_COMPRESSION_HC1
int sixlowpan_compresshdr_hc1(FAR struct ieee802154_driver_s *ieee,
int sixlowpan_compresshdr_hc1(FAR struct sixlowpan_driver_s *radio,
FAR const struct ipv6_hdr_s *ipv6,
FAR const struct sixlowpan_tagaddr_s *destmac,
FAR uint8_t *fptr);
@ -568,7 +568,7 @@ int sixlowpan_uncompresshdr_hc1(FAR const struct ieee802154_data_ind_s *ind,
#define sixlowpan_islinklocal(ipaddr) ((ipaddr)[0] == NTOHS(0xfe80))
int sixlowpan_destaddrfromip(FAR struct ieee802154_driver_s *ieee,
int sixlowpan_destaddrfromip(FAR struct sixlowpan_driver_s *radio,
const net_ipv6addr_t ipaddr,
FAR struct sixlowpan_tagaddr_s *addr);
@ -600,7 +600,7 @@ bool sixlowpan_ismacbased(const net_ipv6addr_t ipaddr,
* Get the source PAN ID from the IEEE802.15.4 radio.
*
* Input parameters:
* ieee - A reference IEEE802.15.4 MAC network device structure.
* radio - Reference to a radio network driver state instance.
* panid - The location in which to return the PAN ID. 0xfff may be
* returned if the device is not associated.
*
@ -609,7 +609,8 @@ bool sixlowpan_ismacbased(const net_ipv6addr_t ipaddr,
*
****************************************************************************/
int sixlowpan_src_panid(FAR struct ieee802154_driver_s *ieee,
int sixlowpan_src_panid(FAR struct sixlowpan_driver_s *radio,
FAR uint8_t *panid);
#endif /* CONFIG_NET_6LOWPAN */
#endif /* _NET_SIXLOWPAN_SIXLOWPAN_INTERNAL_H */

View File

@ -140,7 +140,7 @@ static inline bool send_timeout(FAR struct sixlowpan_send_s *sinfo)
* This function is called from the interrupt level to perform the actual
* send operation when polled by the lower, device interfacing layer.
*
* Parameters:
* Input Parmeters
* dev - The structure of the network driver that caused the interrupt
* conn - The connection structure associated with the socket
* flags - Set of events describing why the callback was invoked
@ -162,10 +162,12 @@ static uint16_t send_interrupt(FAR struct net_driver_s *dev,
ninfo("flags: %04x: %d\n", flags);
#ifdef CONFIG_NET_MULTILINK
/* Verify that this is an IEEE802.15.4 network driver. */
/* Verify that this is a compatible network driver. */
if (dev->d_lltype != NET_LL_IEEE802154)
if (dev->d_lltype != NET_LL_IEEE802154 &&
dev->d_lltype != NET_LL_PKTRADIO)
{
ninfo("Not a compatible network device\n");
return flags;
}
#endif
@ -196,7 +198,7 @@ static uint16_t send_interrupt(FAR struct net_driver_s *dev,
/* Transfer the frame list to the IEEE802.15.4 MAC device */
sinfo->s_result =
sixlowpan_queue_frames((FAR struct ieee802154_driver_s *)dev,
sixlowpan_queue_frames((FAR struct sixlowpan_driver_s *)dev,
sinfo->s_ipv6hdr, sinfo->s_buf, sinfo->s_len,
sinfo->s_destmac);
@ -249,7 +251,7 @@ end_wait:
* The payload data is in the caller 'buf' and is of length 'buflen'.
* Compressed headers will be added and if necessary the packet is
* fragmented. The resulting packet/fragments are submitted to the MAC
* via the network driver i_req_data method.
* via the network driver r_req_data method.
*
* Input Parameters:
* dev - The IEEE802.15.4 MAC network driver interface.

View File

@ -176,7 +176,7 @@ static uint16_t sixlowpan_tcp_chksum(FAR const struct ipv6tcp_hdr_s *ipv6tcp,
* Description:
* sixlowpan_tcp_header() will construct the IPv6 and TCP headers
*
* Parameters:
* Input Parmeters
* conn - An instance of the TCP connection structure.
* dev - The network device that will route the packet
* buf - Data to send
@ -328,7 +328,7 @@ static inline bool send_timeout(FAR struct sixlowpan_send_s *sinfo)
* This function is called from the interrupt level to perform the actual
* TCP send operation when polled by the lower, device interfacing layer.
*
* Parameters:
* Input Parmeters
* dev - The structure of the network driver that caused the interrupt
* pvconn - The connection structure associated with the socket
* pvpriv - The interrupt handler's private data argument
@ -354,9 +354,10 @@ static uint16_t tcp_send_interrupt(FAR struct net_driver_s *dev,
#ifdef CONFIG_NET_MULTILINK
/* Verify that this is an IEEE802.15.4 network driver. */
if (dev->d_lltype != NET_LL_IEEE802154)
if (dev->d_lltype != NET_LL_IEEE802154 &&
dev->d_lltype != NET_LL_PKTRADIO)
{
ninfo("Not a NET_LL_IEEE802154 device\n");
ninfo("Not a compatible network device\n");
return flags;
}
#endif
@ -525,7 +526,7 @@ static uint16_t tcp_send_interrupt(FAR struct net_driver_s *dev,
/* Transfer the frame list to the IEEE802.15.4 MAC device */
ret = sixlowpan_queue_frames((FAR struct ieee802154_driver_s *)dev,
ret = sixlowpan_queue_frames((FAR struct sixlowpan_driver_s *)dev,
&ipv6tcp.ipv6,
&sinfo->s_buf[sinfo->s_sent], sndlen,
sinfo->s_destmac);
@ -612,7 +613,7 @@ end_wait:
* The payload data is in the caller 'buf' and is of length 'buflen'.
* Compressed headers will be added and if necessary the packet is
* fragmented. The resulting packet/fragments are submitted to the MAC
* via the network driver i_req_data method.
* via the network driver r_req_data method.
*
* Input Parameters:
* psock - An instance of the internal socket structure.
@ -734,7 +735,7 @@ static int sixlowpan_send_packet(FAR struct socket *psock,
* psock_6lowpan_tcp_send() call may be used only when the TCP socket is in a
* connected state (so that the intended recipient is known).
*
* Parameters:
* Input Parmeters
* psock - An instance of the internal socket structure.
* buf - Data to send
* bulen - Length of data to send
@ -799,23 +800,33 @@ ssize_t psock_6lowpan_tcp_send(FAR struct socket *psock, FAR const void *buf,
/* Route outgoing message to the correct device */
#ifdef CONFIG_NETDEV_MULTINIC
/* There are multiple network devices */
dev = netdev_findby_ipv6addr(conn->u.ipv6.laddr, conn->u.ipv6.raddr);
#ifdef CONFIG_NETDEV_MULTILINK
if (dev == NULL || dev->d_lltype != NET_LL_IEEE802154)
#else
if (dev == NULL)
#endif
{
nwarn("WARNING: Not routable or not IEEE802.15.4 MAC\n");
nwarn("WARNING: Not routable\n");
return (ssize_t)-ENETUNREACH;
}
#else
dev = netdev_findby_ipv6addr(conn->u.ipv6.raddr);
#ifdef CONFIG_NETDEV_MULTILINK
if (dev == NULL || dev->d_lltype != NET_LL_IEEE802154)
#else
if (dev == NULL)
/* Some network devices support different link layer protocols.
* Check if this device has the hooks to support 6LoWPAN.
*/
if (dev->d_lltype != NET_LL_IEEE802154 &&
dev->d_lltype != NET_LL_PKTRADIO)
{
nwarn("WARNING: Not a compatible network device\n");
return (ssize_t)-ENONET;
}
#endif
#else
/* There is a single network device */
dev = netdev_findby_ipv6addr(conn->u.ipv6.raddr);
if (dev == NULL)
{
nwarn("WARNING: Not routable\n");
return (ssize_t)-ENETUNREACH;
@ -837,7 +848,7 @@ ssize_t psock_6lowpan_tcp_send(FAR struct socket *psock, FAR const void *buf,
* an encoding of the MAC address in the IPv6 address.
*/
ret = sixlowpan_destaddrfromip((FAR struct ieee802154_driver_s *)dev,
ret = sixlowpan_destaddrfromip((FAR struct sixlowpan_driver_s *)dev,
conn->u.ipv6.raddr, &destmac);
if (ret < 0)
{
@ -895,7 +906,7 @@ ssize_t psock_6lowpan_tcp_send(FAR struct socket *psock, FAR const void *buf,
* driver. Under those conditions, this function will be called to create
* the IEEE80215.4 frames.
*
* Parameters:
* Input Parmeters
* dev - The network device containing the packet to be sent.
* fwddev - The network device used to send the data. This will be the
* same device except for the IP forwarding case where packets
@ -956,7 +967,7 @@ void sixlowpan_tcp_send(FAR struct net_driver_s *dev,
* assumes an encoding of the MAC address in the IPv6 address.
*/
ret = sixlowpan_destaddrfromip((FAR struct ieee802154_driver_s *)dev,
ret = sixlowpan_destaddrfromip((FAR struct sixlowpan_driver_s *)dev,
ipv6hdr->ipv6.destipaddr, &destmac);
if (ret < 0)
{
@ -986,7 +997,7 @@ void sixlowpan_tcp_send(FAR struct net_driver_s *dev,
buflen = dev->d_len - hdrlen;
(void)sixlowpan_queue_frames(
(FAR struct ieee802154_driver_s *)fwddev,
(FAR struct sixlowpan_driver_s *)fwddev,
&ipv6hdr->ipv6, buf, buflen, &destmac);
}
}

View File

@ -134,7 +134,7 @@ static uint16_t sixlowpan_udp_chksum(FAR const struct ipv6udp_hdr_s *ipv6udp,
* may be returned when they are not NULL and 0), and the error ENOTCONN is
* returned when the socket was not actually connected.
*
* Parameters:
* Input Parmeters
* psock A pointer to a NuttX-specific, internal socket structure
* buf Data to send
* buflen Length of data to send
@ -205,26 +205,34 @@ ssize_t psock_6lowpan_udp_sendto(FAR struct socket *psock,
/* Route outgoing message to the correct device */
#ifdef CONFIG_NETDEV_MULTINIC
/* There are multiple network devices */
dev = netdev_findby_ipv6addr(conn->u.ipv6.laddr,
to6->sin6_addr.in6_u.u6_addr16);
#ifdef CONFIG_NETDEV_MULTILINK
if (dev == NULL || dev->d_lltype != NET_LL_IEEE802154)
#else
if (dev == NULL)
#endif
{
nwarn("WARNING: Not routable or not IEEE802.15.4 MAC\n");
nwarn("WARNING: Not routable\n");
return (ssize_t)-ENETUNREACH;
}
#ifdef CONFIG_NETDEV_MULTILINK
/* Some network devices support different link layer protocols.
* Check if this device has the hooks to support 6LoWPAN.
*/
if (dev->d_lltype != NET_LL_IEEE802154 &&
dev->d_lltype != NET_LL_PKTRADIO)
{
nwarn("WARNING: Not a compatible network device\n");
return (ssize_t)-ENONET;
}
#endif
#else
dev = netdev_findby_ipv6addr(to6->sin6_addr.in6_u.u6_addr16);
#ifdef CONFIG_NETDEV_MULTILINK
if (dev == NULL || dev->d_lltype != NET_LL_IEEE802154)
#else
if (dev == NULL)
#endif
{
nwarn("WARNING: Not routable or not IEEE802.15.4 MAC\n");
nwarn("WARNING: Not routable\n");
return (ssize_t)-ENETUNREACH;
}
#endif
@ -302,7 +310,7 @@ ssize_t psock_6lowpan_udp_sendto(FAR struct socket *psock,
* encoding of the MAC address in the IPv6 address.
*/
ret = sixlowpan_destaddrfromip((FAR struct ieee802154_driver_s *)dev,
ret = sixlowpan_destaddrfromip((FAR struct sixlowpan_driver_s *)dev,
to6->sin6_addr.in6_u.u6_addr16, &destmac);
if (ret < 0)
{
@ -345,7 +353,7 @@ ssize_t psock_6lowpan_udp_sendto(FAR struct socket *psock,
* psock_6lowpan_udp_send() call may be used with connectionlesss UDP
* sockets.
*
* Parameters:
* Input Parmeters
* psock - An instance of the internal socket structure.
* buf - Data to send
* buflen - Length of data to send
@ -421,7 +429,7 @@ ssize_t psock_6lowpan_udp_send(FAR struct socket *psock, FAR const void *buf,
* Handles forwarding a UDP packet via 6LoWPAN. This is currently only
* used by the IPv6 forwarding logic.
*
* Parameters:
* Input Parmeters
* dev - An instance of nework device state structure
* fwddev - The network device used to send the data. This will be the
* same device except for the IP forwarding case where packets
@ -478,7 +486,7 @@ void sixlowpan_udp_send(FAR struct net_driver_s *dev,
* assumes an encoding of the MAC address in the IPv6 address.
*/
ret = sixlowpan_destaddrfromip((FAR struct ieee802154_driver_s *)dev,
ret = sixlowpan_destaddrfromip((FAR struct sixlowpan_driver_s *)dev,
ipv6udp->ipv6.destipaddr, &destmac);
if (ret < 0)
{
@ -505,7 +513,7 @@ void sixlowpan_udp_send(FAR struct net_driver_s *dev,
buflen = dev->d_len - hdrlen;
(void)sixlowpan_queue_frames(
(FAR struct ieee802154_driver_s *)fwddev,
(FAR struct sixlowpan_driver_s *)fwddev,
&ipv6udp->ipv6, buf, buflen, &destmac);
}
}

View File

@ -123,7 +123,7 @@ static void sixlowpan_eaddrfromip(const net_ipv6addr_t ipaddr,
* Get the extended address of the PAN coordinator.
*
* Input parameters:
* ieee - A reference IEEE802.15.4 MAC network device structure.
* radio - Reference to a radio network driver state instance.
* eaddr - The location in which to return the extended address.
*
* Returned Value:
@ -132,14 +132,14 @@ static void sixlowpan_eaddrfromip(const net_ipv6addr_t ipaddr,
****************************************************************************/
#if defined(CONFIG_NET_STARPOINT) && defined(CONFIG_NET_6LOWPAN_EXTENDEDADDR)
static int sixlowpan_coord_eaddr(FAR struct ieee802154_driver_s *ieee,
static int sixlowpan_coord_eaddr(FAR struct sixlowpan_driver_s *radio,
FAR struct sixlowpan_eaddr_s *eaddr)
{
FAR struct net_driver_s *dev = &ieee->i_dev;
FAR struct net_driver_s *dev = &radio->r_dev;
struct ieee802154_netmac_s arg;
int ret;
memcpy(arg.ifr_name, ieee->i_dev.d_ifname, IFNAMSIZ);
memcpy(arg.ifr_name, radio->r_dev.d_ifname, IFNAMSIZ);
arg.u.getreq.attr = IEEE802154_ATTR_MAC_COORD_EADDR ;
ret = dev->d_ioctl(dev, MAC802154IOC_MLME_GET_REQUEST,
(unsigned long)((uintptr_t)&arg));
@ -161,7 +161,7 @@ static int sixlowpan_coord_eaddr(FAR struct ieee802154_driver_s *ieee,
* Get the short address of the PAN coordinator.
*
* Input parameters:
* ieee - A reference IEEE802.15.4 MAC network device structure.
* radio - Reference to a radio network driver state instance.
* saddr - The location in which to return the short address.
*
* Returned Value:
@ -170,14 +170,14 @@ static int sixlowpan_coord_eaddr(FAR struct ieee802154_driver_s *ieee,
****************************************************************************/
#if defined(CONFIG_NET_STARPOINT) && !defined(CONFIG_NET_6LOWPAN_EXTENDEDADDR)
static int sixlowpan_coord_saddr(FAR struct ieee802154_driver_s *ieee,
static int sixlowpan_coord_saddr(FAR struct sixlowpan_driver_s *radio,
FAR struct sixlowpan_saddr_s *saddr)
{
FAR struct net_driver_s *dev = &ieee->i_dev;
FAR struct net_driver_s *dev = &radio->r_dev;
struct ieee802154_netmac_s arg;
int ret;
memcpy(arg.ifr_name, ieee->i_dev.d_ifname, IFNAMSIZ);
memcpy(arg.ifr_name, radio->r_dev.d_ifname, IFNAMSIZ);
arg.u.getreq.attr = IEEE802154_ATTR_MAC_COORD_SADDR ;
ret = dev->d_ioctl(dev, MAC802154IOC_MLME_GET_REQUEST,
(unsigned long)((uintptr_t)&arg));
@ -216,7 +216,7 @@ static int sixlowpan_coord_saddr(FAR struct ieee802154_driver_s *ieee,
*
****************************************************************************/
int sixlowpan_destaddrfromip(FAR struct ieee802154_driver_s *ieee,
int sixlowpan_destaddrfromip(FAR struct sixlowpan_driver_s *radio,
const net_ipv6addr_t ipaddr,
FAR struct sixlowpan_tagaddr_s *destaddr)
{
@ -228,11 +228,11 @@ int sixlowpan_destaddrfromip(FAR struct ieee802154_driver_s *ieee,
*/
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
ret = sixlowpan_coord_eaddr(ieee, &destaddr->u.eaddr);
ret = sixlowpan_coord_eaddr(radio, &destaddr->u.eaddr);
destaddr->extended = true;
#else
memset(destaddr, 0, sizeof(struct sixlowpan_tagaddr_s));
ret = sixlowpan_coord_saddr(ieee, &destaddr->u.saddr);
ret = sixlowpan_coord_saddr(radio, &destaddr->u.saddr);
#endif
return ret;
@ -359,7 +359,7 @@ bool sixlowpan_ismacbased(const net_ipv6addr_t ipaddr,
* Get the source PAN ID from the IEEE802.15.4 MAC layer.
*
* Input parameters:
* ieee - A reference IEEE802.15.4 MAC network device structure.
* radio - Reference to a radio network driver state instance.
* panid - The location in which to return the PAN ID. 0xfff may be
* returned if the device is not associated.
*
@ -368,14 +368,14 @@ bool sixlowpan_ismacbased(const net_ipv6addr_t ipaddr,
*
****************************************************************************/
int sixlowpan_src_panid(FAR struct ieee802154_driver_s *ieee,
int sixlowpan_src_panid(FAR struct sixlowpan_driver_s *radio,
FAR uint8_t *panid)
{
FAR struct net_driver_s *dev = &ieee->i_dev;
FAR struct net_driver_s *dev = &radio->r_dev;
struct ieee802154_netmac_s arg;
int ret;
memcpy(arg.ifr_name, ieee->i_dev.d_ifname, IFNAMSIZ);
memcpy(arg.ifr_name, radio->r_dev.d_ifname, IFNAMSIZ);
arg.u.getreq.attr = IEEE802154_ATTR_MAC_PANID;
ret = dev->d_ioctl(dev, MAC802154IOC_MLME_GET_REQUEST,
(unsigned long)((uintptr_t)&arg));

View File

@ -12,5 +12,6 @@ config WIRELESS
if WIRELESS
source wireless/ieee802154/Kconfig
source wireless/pktradio/Kconfig
endif # WIRELESS

View File

@ -51,6 +51,7 @@ VPATH = .
# Add IEEE 802.15.4 files to the build
include ieee802154$(DELIM)Make.defs
include pktradio$(DELIM)Make.defs
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))

View File

@ -1,5 +1,5 @@
/****************************************************************************
* wireless/ieee802154_indalloc.c
* wireless/ieee802154/ieee802154_indalloc.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>

View File

@ -106,7 +106,7 @@ struct lo_driver_s
/* This holds the information visible to the NuttX network */
struct ieee802154_driver_s lo_ieee; /* Interface understood by the network */
struct sixlowpan_driver_s lo_ieee; /* Interface understood by the network */
};
/****************************************************************************
@ -163,9 +163,9 @@ static int lo_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac);
static int lo_ioctl(FAR struct net_driver_s *dev, int cmd,
unsigned long arg);
#endif
static int lo_get_mhrlen(FAR struct ieee802154_driver_s *netdev,
static int lo_get_mhrlen(FAR struct sixlowpan_driver_s *netdev,
FAR const struct ieee802154_frame_meta_s *meta);
static int lo_req_data(FAR struct ieee802154_driver_s *netdev,
static int lo_req_data(FAR struct sixlowpan_driver_s *netdev,
FAR const struct ieee802154_frame_meta_s *meta,
FAR struct iob_s *framelist);
@ -320,7 +320,7 @@ static int lo_loopback(FAR struct net_driver_s *dev)
/* Increment statistics */
NETDEV_RXPACKETS(&priv->lo_ieee.i_dev);
NETDEV_RXPACKETS(&priv->lo_ieee.r_dev);
/* Remove the IOB from the queue */
@ -344,13 +344,13 @@ static int lo_loopback(FAR struct net_driver_s *dev)
/* Increment statistics */
NETDEV_TXPACKETS(&priv->lo_ieee.i_dev);
NETDEV_TXPACKETS(&priv->lo_ieee.r_dev);
if (ret < 0)
{
nerr("ERROR: sixlowpan_input returned %d\n", ret);
NETDEV_TXERRORS(&priv->lo_ieee.i_dev);
NETDEV_ERRORS(&priv->lo_ieee.i_dev);
NETDEV_TXERRORS(&priv->lo_ieee.r_dev);
NETDEV_ERRORS(&priv->lo_ieee.r_dev);
}
}
@ -381,7 +381,7 @@ static void lo_loopback_work(FAR void *arg)
/* Perform the loopback */
net_lock();
(void)lo_loopback(&priv->lo_ieee.i_dev);
(void)lo_loopback(&priv->lo_ieee.r_dev);
net_unlock();
}
@ -409,7 +409,7 @@ static void lo_poll_work(FAR void *arg)
/* Perform the poll */
net_lock();
(void)devif_timer(&priv->lo_ieee.i_dev, lo_loopback);
(void)devif_timer(&priv->lo_ieee.r_dev, lo_loopback);
/* Setup the watchdog poll timer again */
@ -563,7 +563,7 @@ static void lo_txavail_work(FAR void *arg)
{
/* If so, then poll the network for new XMIT data */
(void)devif_poll(&priv->lo_ieee.i_dev, lo_loopback);
(void)devif_poll(&priv->lo_ieee.r_dev, lo_loopback);
}
net_unlock();
@ -809,7 +809,7 @@ static int lo_ioctl(FAR struct net_driver_s *dev, int cmd,
*
****************************************************************************/
static int lo_get_mhrlen(FAR struct ieee802154_driver_s *netdev,
static int lo_get_mhrlen(FAR struct sixlowpan_driver_s *netdev,
FAR const struct ieee802154_frame_meta_s *meta)
{
return MAC_HDRLEN;
@ -832,16 +832,16 @@ static int lo_get_mhrlen(FAR struct ieee802154_driver_s *netdev,
*
****************************************************************************/
static int lo_req_data(FAR struct ieee802154_driver_s *netdev,
static int lo_req_data(FAR struct sixlowpan_driver_s *netdev,
FAR const struct ieee802154_frame_meta_s *meta,
FAR struct iob_s *framelist)
{
FAR struct lo_driver_s *priv;
FAR struct iob_s *iob;
DEBUGASSERT(netdev != NULL && netdev->i_dev.d_private != NULL &&
DEBUGASSERT(netdev != NULL && netdev->r_dev.d_private != NULL &&
framelist != NULL);
priv = (FAR struct lo_driver_s *)netdev->i_dev.d_private;
priv = (FAR struct lo_driver_s *)netdev->r_dev.d_private;
/* Add the incoming list of framelist to queue of framelist to loopback */
@ -849,7 +849,7 @@ static int lo_req_data(FAR struct ieee802154_driver_s *netdev,
{
/* Increment statistics */
NETDEV_RXPACKETS(&priv->lo_ieee.i_dev);
NETDEV_RXPACKETS(&priv->lo_ieee.r_dev);
/* Remove the IOB from the queue */
@ -906,7 +906,7 @@ static int lo_req_data(FAR struct ieee802154_driver_s *netdev,
int ieee8021514_loopback(void)
{
FAR struct lo_driver_s *priv;
FAR struct ieee802154_driver_s *ieee;
FAR struct sixlowpan_driver_s *radio;
FAR struct net_driver_s *dev;
ninfo("Initializing\n");
@ -919,20 +919,20 @@ int ieee8021514_loopback(void)
memset(priv, 0, sizeof(struct lo_driver_s));
ieee = &priv->lo_ieee;
dev = &ieee->i_dev;
dev->d_ifup = lo_ifup; /* I/F up (new IP address) callback */
dev->d_ifdown = lo_ifdown; /* I/F down callback */
dev->d_txavail = lo_txavail; /* New TX data callback */
radio = &priv->lo_ieee;
dev = &radio->r_dev;
dev->d_ifup = lo_ifup; /* I/F up (new IP address) callback */
dev->d_ifdown = lo_ifdown; /* I/F down callback */
dev->d_txavail = lo_txavail; /* New TX data callback */
#ifdef CONFIG_NET_IGMP
dev->d_addmac = lo_addmac; /* Add multicast MAC address */
dev->d_rmmac = lo_rmmac; /* Remove multicast MAC address */
dev->d_addmac = lo_addmac; /* Add multicast MAC address */
dev->d_rmmac = lo_rmmac; /* Remove multicast MAC address */
#endif
#ifdef CONFIG_NETDEV_IOCTL
dev->d_ioctl = lo_ioctl; /* Handle network IOCTL commands */
dev->d_ioctl = lo_ioctl; /* Handle network IOCTL commands */
#endif
dev->d_buf = g_iobuffer; /* Attach the IO buffer */
dev->d_private = (FAR void *)priv; /* Used to recover private state from dev */
dev->d_buf = g_iobuffer; /* Attach the IO buffer */
dev->d_private = (FAR void *)priv; /* Used to recover private state from dev */
/* Set the network mask and advertise our MAC-based IP address */
@ -941,23 +941,23 @@ int ieee8021514_loopback(void)
/* Initialize the Network frame-related callbacks */
ieee->i_get_mhrlen = lo_get_mhrlen; /* Get MAC header length */
ieee->i_req_data = lo_req_data; /* Enqueue frame for transmission */
radio->r_get_mhrlen = lo_get_mhrlen; /* Get MAC header length */
radio->r_req_data = lo_req_data; /* Enqueue frame for transmission */
/* Create a watchdog for timing polling for and timing of transmissions */
priv->lo_polldog = wd_create(); /* Create periodic poll timer */
priv->lo_polldog = wd_create(); /* Create periodic poll timer */
/* Register the loopabck device with the OS so that socket IOCTLs can be
* performed.
*/
(void)netdev_register(&priv->lo_ieee.i_dev, NET_LL_IEEE802154);
(void)netdev_register(&priv->lo_ieee.r_dev, NET_LL_IEEE802154);
/* Put the network in the UP state */
dev->d_flags = IFF_UP;
return lo_ifup(&priv->lo_ieee.i_dev);
return lo_ifup(&priv->lo_ieee.r_dev);
}
#endif /* CONFIG_IEEE802154_LOOPBACK */

View File

@ -121,7 +121,7 @@ struct macnet_driver_s
{
/* This holds the information visible to the NuttX network */
struct ieee802154_driver_s md_dev; /* Interface understood by the network */
struct sixlowpan_driver_s md_dev; /* Interface understood by the network */
/* For internal use by this driver */
@ -211,9 +211,9 @@ static int macnet_rmmac(FAR struct net_driver_s *dev,
static int macnet_ioctl(FAR struct net_driver_s *dev, int cmd,
unsigned long arg);
#endif
static int macnet_get_mhrlen(FAR struct ieee802154_driver_s *netdev,
static int macnet_get_mhrlen(FAR struct sixlowpan_driver_s *netdev,
FAR const struct ieee802154_frame_meta_s *meta);
static int macnet_req_data(FAR struct ieee802154_driver_s *netdev,
static int macnet_req_data(FAR struct sixlowpan_driver_s *netdev,
FAR const struct ieee802154_frame_meta_s *meta,
FAR struct iob_s *framelist);
@ -433,8 +433,8 @@ static int macnet_rxframe(FAR struct mac802154_maccb_s *maccb,
/* Increment statistics */
NETDEV_RXPACKETS(&priv->md_dev.i_dev);
NETDEV_RXIPV6(&priv->md_dev.i_dev);
NETDEV_RXPACKETS(&priv->md_dev.r_dev);
NETDEV_RXIPV6(&priv->md_dev.r_dev);
/* Remove the IOB containing the frame. */
@ -719,7 +719,7 @@ static void macnet_txpoll_work(FAR void *arg)
/* Perform the poll */
(void)devif_timer(&priv->md_dev.i_dev, macnet_txpoll_callback);
(void)devif_timer(&priv->md_dev.r_dev, macnet_txpoll_callback);
/* Setup the watchdog poll timer again */
@ -893,7 +893,7 @@ static void macnet_txavail_work(FAR void *arg)
/* If so, then poll the network for new XMIT data */
(void)devif_poll(&priv->md_dev.i_dev, macnet_txpoll_callback);
(void)devif_poll(&priv->md_dev.r_dev, macnet_txpoll_callback);
}
net_unlock();
@ -1070,13 +1070,13 @@ static int macnet_ioctl(FAR struct net_driver_s *dev, int cmd,
*
****************************************************************************/
static int macnet_get_mhrlen(FAR struct ieee802154_driver_s *netdev,
static int macnet_get_mhrlen(FAR struct sixlowpan_driver_s *netdev,
FAR const struct ieee802154_frame_meta_s *meta)
{
FAR struct macnet_driver_s *priv;
DEBUGASSERT(netdev != NULL && netdev->i_dev.d_private != NULL && meta != NULL);
priv = (FAR struct macnet_driver_s *)netdev->i_dev.d_private;
DEBUGASSERT(netdev != NULL && netdev->r_dev.d_private != NULL && meta != NULL);
priv = (FAR struct macnet_driver_s *)netdev->r_dev.d_private;
return mac802154_get_mhrlen(priv->md_mac, meta);
}
@ -1098,7 +1098,7 @@ static int macnet_get_mhrlen(FAR struct ieee802154_driver_s *netdev,
*
****************************************************************************/
static int macnet_req_data(FAR struct ieee802154_driver_s *netdev,
static int macnet_req_data(FAR struct sixlowpan_driver_s *netdev,
FAR const struct ieee802154_frame_meta_s *meta,
FAR struct iob_s *framelist)
{
@ -1108,8 +1108,8 @@ static int macnet_req_data(FAR struct ieee802154_driver_s *netdev,
wlinfo("Received framelist\n");
DEBUGASSERT(netdev != NULL && netdev->i_dev.d_private != NULL);
priv = (FAR struct macnet_driver_s *)netdev->i_dev.d_private;
DEBUGASSERT(netdev != NULL && netdev->r_dev.d_private != NULL);
priv = (FAR struct macnet_driver_s *)netdev->r_dev.d_private;
DEBUGASSERT(meta != NULL && framelist != NULL);
@ -1119,7 +1119,7 @@ static int macnet_req_data(FAR struct ieee802154_driver_s *netdev,
{
/* Increment statistics */
NETDEV_TXPACKETS(&priv->md_dev.i_dev);
NETDEV_TXPACKETS(&priv->md_dev.r_dev);
/* Remove the IOB from the queue */
@ -1150,11 +1150,11 @@ static int macnet_req_data(FAR struct ieee802154_driver_s *netdev,
iob_free(iob);
}
NETDEV_TXERRORS(&priv->md_dev.i_dev);
NETDEV_TXERRORS(&priv->md_dev.r_dev);
return ret;
}
NETDEV_TXDONE(&priv->md_dev.i_dev);
NETDEV_TXDONE(&priv->md_dev.r_dev);
}
return OK;
@ -1183,7 +1183,7 @@ static int macnet_req_data(FAR struct ieee802154_driver_s *netdev,
int mac802154netdev_register(MACHANDLE mac)
{
FAR struct macnet_driver_s *priv;
FAR struct ieee802154_driver_s *ieee;
FAR struct sixlowpan_driver_s *radio;
FAR struct net_driver_s *dev;
FAR struct mac802154_maccb_s *maccb;
FAR uint8_t *pktbuf;
@ -1216,8 +1216,8 @@ int mac802154netdev_register(MACHANDLE mac)
/* Initialize the driver structure */
ieee = &priv->md_dev;
dev = &ieee->i_dev;
radio = &priv->md_dev;
dev = &radio->r_dev;
dev->d_buf = pktbuf; /* Single packet buffer */
dev->d_ifup = macnet_ifup; /* I/F up (new IP address) callback */
dev->d_ifdown = macnet_ifdown; /* I/F down callback */
@ -1244,8 +1244,8 @@ int mac802154netdev_register(MACHANDLE mac)
/* Initialize the Network frame-related callbacks */
ieee->i_get_mhrlen = macnet_get_mhrlen; /* Get MAC header length */
ieee->i_req_data = macnet_req_data; /* Enqueue frame for transmission */
radio->r_get_mhrlen = macnet_get_mhrlen; /* Get MAC header length */
radio->r_req_data = macnet_req_data; /* Enqueue frame for transmission */
/* Initialize the MAC callbacks */
@ -1281,7 +1281,7 @@ int mac802154netdev_register(MACHANDLE mac)
/* Register the device with the OS so that socket IOCTLs can be performed */
(void)netdev_register(&priv->md_dev.i_dev, NET_LL_IEEE802154);
(void)netdev_register(&priv->md_dev.r_dev, NET_LL_IEEE802154);
return OK;
}

35
wireless/pktradio/Kconfig Normal file
View File

@ -0,0 +1,35 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
menuconfig WIRELESS_PKTRADIO
bool "Packet Radio Support"
default n
select MM_IOB
depends on WIRELESS
---help---
Enables support for non-standard packet radios. This option enables
special hooks to support interoperability of these non-standard
radios to support 6LoWPAN networking. This option should not be
selected for standard IEEE 802.15.4.
if WIRELESS_PKTRADIO
config PKTRADIO_ADDRLEN
int "Maximum address size"
default 1
---help---
This value provides the size of the MAC address used by the packet
radio. If there are multiple packet radios in the configuration,
then this must be set to the a value greater than or equal to the
maximum of address lengths used by the radios.
config PKTRADIO_NRXMETA
int "Number of pre-allocated meta-data structures"
default 20
---help---
This specifies the total number of preallocated meta data structures
must be allocated with each incoming packet.
endif # WIRELESS_PKTRADIO

View File

@ -0,0 +1,46 @@
############################################################################
# wireless/pktradio/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.
#
############################################################################
ifeq ($(CONFIG_WIRELESS_PKTRADIO),y)
# Include packet radio support
CSRCS += pktradio_metadata.c
DEPPATH += --dep-path pktradio
VPATH += :pktradio
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)wireless$(DELIM)pktradio}
endif # CONFIG_WIRELESS_PKTRADIO

View File

@ -0,0 +1,248 @@
/****************************************************************************
* wireless/pktradio/pktradio_metadata.c
*
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <semaphore.h>
#include <assert.h>
#include <errno.h>
#include <nuttx/kmalloc.h>
#include <nuttx/mm/iob.h>
#include <nuttx/wireless/pktradio.h>
/****************************************************************************
* Private Data
****************************************************************************/
/* The g_free_metadata is a list of meta-data structures that are available for
* general use. The number of messages in this list is a system configuration
* item.
*/
static struct pktradio_metadata_s *g_free_metadata;
/* Supports mutually exclusive access to the free list */
static sem_t g_metadata_sem;
/* Idempotence support */
static bool g_metadata_initialized;
/* Pool of pre-allocated meta-data stuctures */
static struct pktradio_metadata_s g_metadata_pool[CONFIG_PKTRADIO_NRXMETA];
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: pktradio_metadata_initialize
*
* Description:
* This function initializes the meta-data allocator. This function must
* be called early in the initialization sequence before any radios
* begin operation.
*
* Inputs:
* None
*
* Return Value:
* None
*
****************************************************************************/
void pktradio_metadata_initialize(void)
{
FAR struct pktradio_metadata_s *metadata;
int i;
if (!g_metadata_initialized)
{
/* Initialize g_free_metadata, the list of meta-data structures that
* are available for allocation.
*/
g_free_metadata = NULL;
for (i = 0, metadata = g_metadata_pool;
i < CONFIG_PKTRADIO_NRXMETA;
i++, metadata++)
{
/* Add the next meta data structure from the pool to the list of
* general structures.
*/
metadata->pm_flink = g_free_metadata;
g_free_metadata = metadata;
}
/* Initialize the mutual exclusion semaphore */
sem_init(&g_metadata_sem, 0, 1);
g_metadata_initialized = true;
}
}
/****************************************************************************
* Name: pktradio_metadata_allocate
*
* Description:
* The pktradio_metadata_allocate function will get a free meta-data
* structure for use by the packet radio.
*
* This function will first attempt to allocate from the g_free_metadata
* list. If that the list is empty, then the meta-data structure will be
* allocated from the dynamic memory pool.
*
* Inputs:
* None
*
* Return Value:
* A reference to the allocated metadata structure. All user fields in this
* structure have been zeroed. On a failure to allocate, NULL is
* returned.
*
****************************************************************************/
FAR struct pktradio_metadata_s *pktradio_metadata_allocate(void)
{
FAR struct pktradio_metadata_s *metadata;
uint8_t pool;
/* Get exclusive access to the free list */
while (sem_wait(&g_metadata_sem) < 0)
{
DEBUGASSERT(errno == EINTR);
}
/* Try the free list first */
if (g_free_metadata != NULL)
{
metadata = g_free_metadata;
g_free_metadata = metadata->pm_flink;
pool = PKTRADIO_POOL_PREALLOCATED;
/* We are finished with the free list */
sem_post(&g_metadata_sem);
}
else
{
/* If we cannot get a meta-data instance from the free list, then we
* will have to allocate one from the kernal memory pool. We won't
* access the free list.
*/
sem_post(&g_metadata_sem);
metadata = (FAR struct pktradio_metadata_s *)
kmm_malloc((sizeof (struct pktradio_metadata_s)));
pool = PKTRADIO_POOL_DYNAMIC;
}
/* We have successfully allocated memory from some source? */
if (metadata != NULL)
{
/* Zero and tag the alloated meta-data structure. */
memset(&metadata, 0, sizeof(struct pktradio_metadata_s));
metadata->pm_pool = pool;
}
return metadata;
}
/****************************************************************************
* Name: pktradio_metadata_free
*
* Description:
* The pktradio_metadata_free function will return a metadata structure
* to the free list of messages if it was a pre-allocated metadata
* structure. If the metadata structure was allocated dynamically it will
* be deallocated.
*
* Inputs:
* metadata - metadata structure to free
*
* Return Value:
* None
*
****************************************************************************/
void pktradio_metadata_free(FAR struct pktradio_metadata_s *metadata)
{
/* Get exclusive access to the free list */
while (sem_wait(&g_metadata_sem) < 0)
{
DEBUGASSERT(errno == EINTR);
}
/* If this is a pre-allocated meta-data structure, then just put it back
* in the free list.
*/
if (metadata->pm_pool == PKTRADIO_POOL_PREALLOCATED)
{
metadata->pm_flink = g_free_metadata;
g_free_metadata = metadata;
/* We are finished with the free list */
sem_post(&g_metadata_sem);
}
else
{
DEBUGASSERT(metadata->pm_pool == PKTRADIO_POOL_DYNAMIC);
/* Otherwise, deallocate it. We won't access the free list */
sem_post(&g_metadata_sem);
sched_kfree(metadata);
}
}