mirror of
https://github.com/apache/nuttx.git
synced 2026-05-18 00:34:10 +08:00
6LoWPAN/PF_IEEE802154: Created radiodev.h and renamed various structures to provide a better separation between 6LoWPAN and PF_IEEE802154.
This commit is contained in:
@@ -126,7 +126,7 @@
|
||||
#include <nuttx/mm/iob.h>
|
||||
#include <nuttx/spi/spi.h>
|
||||
#include <nuttx/net/netdev.h>
|
||||
#include <nuttx/net/sixlowpan.h>
|
||||
#include <nuttx/net/radiodev.h>
|
||||
|
||||
#include <nuttx/wireless/spirit.h>
|
||||
#include <nuttx/wireless/pktradio.h>
|
||||
@@ -352,7 +352,7 @@ static int spirit_get_mhrlen(FAR struct radio_driver_s *netdev,
|
||||
static int spirit_req_data(FAR struct radio_driver_s *netdev,
|
||||
FAR const void *meta, FAR struct iob_s *framelist);
|
||||
static int spirit_properties(FAR struct radio_driver_s *netdev,
|
||||
FAR struct sixlowpan_properties_s *properties);
|
||||
FAR struct radiodev_properties_s *properties);
|
||||
|
||||
/* Initialization */
|
||||
|
||||
@@ -2141,8 +2141,8 @@ static int spirit_ioctl(FAR struct net_driver_s *dev, int cmd,
|
||||
{
|
||||
FAR struct radio_driver_s *radio =
|
||||
(FAR struct radio_driver_s *)dev;
|
||||
FAR struct sixlowpan_properties_s *props =
|
||||
(FAR struct sixlowpan_properties_s *)&cmddata->pifr_props;
|
||||
FAR struct radiodev_properties_s *props =
|
||||
(FAR struct radiodev_properties_s *)&cmddata->pifr_props;
|
||||
|
||||
ret = spirit_properties(radio, props);
|
||||
}
|
||||
@@ -2373,10 +2373,10 @@ static int spirit_req_data(FAR struct radio_driver_s *netdev,
|
||||
****************************************************************************/
|
||||
|
||||
static int spirit_properties(FAR struct radio_driver_s *netdev,
|
||||
FAR struct sixlowpan_properties_s *properties)
|
||||
FAR struct radiodev_properties_s *properties)
|
||||
{
|
||||
DEBUGASSERT(netdev != NULL && properties != NULL);
|
||||
memset(properties, 0, sizeof(struct sixlowpan_properties_s));
|
||||
memset(properties, 0, sizeof(struct radiodev_properties_s));
|
||||
|
||||
/* General */
|
||||
|
||||
|
||||
@@ -463,8 +463,9 @@ int ipv6_input(FAR struct net_driver_s *dev);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN
|
||||
struct radio_driver_s; /* See sixlowpan.h */
|
||||
struct iob_s; /* See iob.h */
|
||||
struct radio_driver_s; /* Forward reference. See radiodev.h */
|
||||
struct iob_s; /* Forward reference See iob.h */
|
||||
|
||||
int sixlowpan_input(FAR struct radio_driver_s *ieee,
|
||||
FAR struct iob_s *framelist, FAR const void *metadata);
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,296 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/net/radiodev.h
|
||||
*
|
||||
* 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 of the Institute 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 INSTITUTE 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 INSTITUTE 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_NET_RADIODEV_H
|
||||
#define __INCLUDE_NUTTX_NET_RADIODEV_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <nuttx/clock.h>
|
||||
#include <nuttx/mm/iob.h>
|
||||
#include <nuttx/net/netdev.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* 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 radiodev_properties_s
|
||||
{
|
||||
uint8_t sp_addrlen; /* Length of an address */
|
||||
uint8_t sp_pktlen; /* Fixed packet/frame size (up to 255) */
|
||||
struct netdev_varaddr_s sp_mcast; /* Multicast address */
|
||||
struct netdev_varaddr_s sp_bcast; /* Broadcast address */
|
||||
#ifdef CONFIG_NET_STARPOINT
|
||||
struct netdev_varaddr_s sp_hubnode; /* Address of the hub node in a star */
|
||||
#endif
|
||||
};
|
||||
|
||||
/* 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 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
|
||||
* 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 radio network driver to the network
|
||||
* via an IOB parameter in the sixlowpan_input() pr ieee802154_input()
|
||||
* interface. The length of the frame is io_len.
|
||||
*
|
||||
* - 6LoWPAN frames and will be uncompressed and possibly reassembled in
|
||||
* the d_buf; d_len will hold the size of the reassembled packet.
|
||||
*
|
||||
* In this case, a d_buf of size CONFIG_NET_6LOWPAN_MTU must be provided.
|
||||
*
|
||||
* 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 radio_driver_s' is cast
|
||||
* compatible with 'struct net_driver_s' when dev->d_lltype ==
|
||||
* NET_LL_IEEE802154 or dev->d_lltype == NET_LL_PKTRADIO.
|
||||
*
|
||||
* 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 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.
|
||||
*
|
||||
* After sending each frame through the radio, the MAC driver must
|
||||
* return the frame to the pool of free IOBs using the iob_free().
|
||||
*
|
||||
* 2. When receiving data both buffers must be provided for 6LoWPAN
|
||||
* frames; PF_IEEE802154 frames do not require the d_buf.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* For 6LoWPAN, 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. If fragmentation is enabled, then the logical
|
||||
* packet size may be significantly larger than the size of the frame
|
||||
* buffer. The dev.d_buf is used for de-compressing each frame and
|
||||
* reassembling any fragmented packets to create the full input packet
|
||||
* that is provided to the application.
|
||||
*
|
||||
* The MAC driver should then inform the network of the reciptor of a
|
||||
* frame by calling sixlowpan_input() or ieee802154_input(). That
|
||||
* single frame (or, perhaps, list of frames) should be provided as
|
||||
* second argument of that call.
|
||||
*
|
||||
* The network will free the IOB by calling iob_free after it has
|
||||
* processed the incoming frame. As a complexity, the result of
|
||||
* receiving a frame may be that the network may respond provide an
|
||||
* outgoing frames in the via a nested call to the req_data() method.
|
||||
*/
|
||||
|
||||
struct iob_s; /* Forward reference */
|
||||
|
||||
struct radio_driver_s
|
||||
{
|
||||
/* This definitiona must appear first in the structure definition to
|
||||
* assure cast compatibility.
|
||||
*/
|
||||
|
||||
struct net_driver_s r_dev;
|
||||
|
||||
/* 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
|
||||
*
|
||||
* 1. When you do that data request
|
||||
* 2. When the transmission is complete, the conf_data is called with
|
||||
* that handle so that the user can be notified of the frames success/
|
||||
* failure
|
||||
* 3. For a req_purge, to basically "cancel" the transaction. This is
|
||||
* often particularly useful on a coordinator that has indirect data
|
||||
* waiting to be requested from another device
|
||||
*
|
||||
* Here is a simple frame counter.
|
||||
*/
|
||||
|
||||
uint8_t r_msdu_handle;
|
||||
#endif
|
||||
|
||||
#if CONFIG_NET_6LOWPAN_FRAG
|
||||
/* Fragmentation Support *************************************************/
|
||||
/* Fragmentation is handled frame by frame and requires that certain
|
||||
* state information be retained from frame to frame.
|
||||
*/
|
||||
|
||||
/* 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.
|
||||
*
|
||||
* This is the sender's copy of the tag. It is incremented after each
|
||||
* fragmented packet is sent so that it will be unique to that
|
||||
* sequence fragmentation. Its value is then persistent, the values of
|
||||
* other fragmentation variables are valid on during a single
|
||||
* fragmentation sequence (while r_accumlen > 0)
|
||||
*/
|
||||
|
||||
uint16_t r_dgramtag;
|
||||
|
||||
/* 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 r_dgramtag but is saved on the receiving
|
||||
* side to match all of the fragments of the packet.
|
||||
*/
|
||||
|
||||
uint16_t r_reasstag;
|
||||
|
||||
/* 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 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 r_accumlen;
|
||||
|
||||
/* 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 r_boffset;
|
||||
|
||||
/* The source MAC address of the fragments being merged */
|
||||
|
||||
struct netdev_varaddr_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 r_time;
|
||||
#endif /* CONFIG_NET_6LOWPAN_FRAG */
|
||||
|
||||
/* MAC network driver callback functions **********************************/
|
||||
/**************************************************************************
|
||||
* Name: r_get_mhrlen
|
||||
*
|
||||
* Description:
|
||||
* Calculate the MAC header length given the frame meta-data.
|
||||
*
|
||||
* Input parameters:
|
||||
* netdev - The networkd device that will mediate the MAC interface
|
||||
* meta - Obfuscated metadata structure needed to recreate the
|
||||
* radio MAC header
|
||||
*
|
||||
* Returned Value:
|
||||
* A non-negative MAC headeer length is returned on success; a negated
|
||||
* errno value is returned on any failure.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
CODE int (*r_get_mhrlen)(FAR struct radio_driver_s *netdev,
|
||||
FAR const void *meta);
|
||||
|
||||
/**************************************************************************
|
||||
* Name: r_req_data
|
||||
*
|
||||
* Description:
|
||||
* Requests the transfer of a list of frames to the MAC.
|
||||
*
|
||||
* Input parameters:
|
||||
* netdev - The network device that will mediate the MAC interface
|
||||
* meta - Obfuscated metadata structure needed to create the radio
|
||||
* MAC header
|
||||
* framelist - Head of a list of frames to be transferred.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) returned on success; a negated errno value is returned on
|
||||
* any failure.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
CODE int (*r_req_data)(FAR struct radio_driver_s *netdev,
|
||||
FAR const void *meta, FAR struct iob_s *framelist);
|
||||
|
||||
/**************************************************************************
|
||||
* Name: r_properties
|
||||
*
|
||||
* Description:
|
||||
* 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.
|
||||
*
|
||||
* Input parameters:
|
||||
* netdev - The network device to be queried
|
||||
* properties - Location where radio properities will be returned.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) returned on success; a negated errno value is returned on
|
||||
* any failure.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
CODE int (*r_properties)(FAR struct radio_driver_s *netdev,
|
||||
FAR struct radiodev_properties_s *properties);
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#endif /* __INCLUDE_NUTTX_NET_RADIODEV_H */
|
||||
@@ -54,10 +54,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <nuttx/clock.h>
|
||||
#include <nuttx/mm/iob.h>
|
||||
#include <nuttx/net/netdev.h>
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN
|
||||
|
||||
/****************************************************************************
|
||||
@@ -341,246 +337,6 @@
|
||||
(a)[4] == 0 && (a)[5] == 0 && (a)[6] == 0 && \
|
||||
(((a)[7] & HTONS(0xff00)) == 0x0000))
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* 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 sixlowpan_properties_s
|
||||
{
|
||||
uint8_t sp_addrlen; /* Length of an address */
|
||||
uint8_t sp_pktlen; /* Fixed packet/frame size (up to 255) */
|
||||
struct netdev_varaddr_s sp_mcast; /* Multicast address */
|
||||
struct netdev_varaddr_s sp_bcast; /* Broadcast address */
|
||||
#ifdef CONFIG_NET_STARPOINT
|
||||
struct netdev_varaddr_s sp_hubnode; /* Address of the hub node in a star */
|
||||
#endif
|
||||
};
|
||||
|
||||
/* 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 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
|
||||
* 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 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
|
||||
* reassembled packet.
|
||||
*
|
||||
* In this case, a d_buf of size CONFIG_NET_6LOWPAN_MTU must be provided.
|
||||
*
|
||||
* 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 radio_driver_s' is cast
|
||||
* compatible with 'struct net_driver_s' when dev->d_lltype ==
|
||||
* NET_LL_IEEE802154 or dev->d_lltype == NET_LL_PKTRADIO.
|
||||
*
|
||||
* 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 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.
|
||||
*
|
||||
* After sending each frame through the radio, the MAC driver must
|
||||
* return the frame to the pool of free IOBs using the iob_free().
|
||||
*
|
||||
* 2. When receiving data both buffers must be provided:
|
||||
*
|
||||
* 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.
|
||||
* If fragmentation is enabled, then the logical packet size may be
|
||||
* significantly larger than the size of the frame buffer. The dev.d_buf
|
||||
* is used for de-compressing each frame and reassembling any fragmented
|
||||
* packets to create the full input packet that is provided to the
|
||||
* application.
|
||||
*
|
||||
* The MAC driver should then inform the network of the by calling
|
||||
* sixlowpan_input(). That single frame (or, perhaps, list of frames)
|
||||
* should be provided as second argument of that call.
|
||||
*
|
||||
* The network will free the IOB by calling iob_free after it has
|
||||
* processed the incoming frame. As a complexity, the result of
|
||||
* receiving a frame may be that the network may respond provide an
|
||||
* outgoing frames in the via a nested calle to the req_data() method.
|
||||
*/
|
||||
|
||||
struct iob_s; /* Forward reference */
|
||||
|
||||
struct radio_driver_s
|
||||
{
|
||||
/* This definitiona must appear first in the structure definition to
|
||||
* assure cast compatibility.
|
||||
*/
|
||||
|
||||
struct net_driver_s r_dev;
|
||||
|
||||
/* 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
|
||||
*
|
||||
* 1. When you do that data request
|
||||
* 2. When the transmission is complete, the conf_data is called with
|
||||
* that handle so that the user can be notified of the frames success/
|
||||
* failure
|
||||
* 3. For a req_purge, to basically "cancel" the transaction. This is
|
||||
* often particularly useful on a coordinator that has indirect data
|
||||
* waiting to be requested from another device
|
||||
*
|
||||
* Here is a simple frame counter.
|
||||
*/
|
||||
|
||||
uint8_t r_msdu_handle;
|
||||
#endif
|
||||
|
||||
#if CONFIG_NET_6LOWPAN_FRAG
|
||||
/* Fragmentation Support *************************************************/
|
||||
/* Fragmentation is handled frame by frame and requires that certain
|
||||
* state information be retained from frame to frame.
|
||||
*/
|
||||
|
||||
/* 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.
|
||||
*
|
||||
* This is the sender's copy of the tag. It is incremented after each
|
||||
* fragmented packet is sent so that it will be unique to that
|
||||
* sequence fragmentation. Its value is then persistent, the values of
|
||||
* other fragmentation variables are valid on during a single
|
||||
* fragmentation sequence (while r_accumlen > 0)
|
||||
*/
|
||||
|
||||
uint16_t r_dgramtag;
|
||||
|
||||
/* 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 r_dgramtag but is saved on the receiving
|
||||
* side to match all of the fragments of the packet.
|
||||
*/
|
||||
|
||||
uint16_t r_reasstag;
|
||||
|
||||
/* 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 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 r_accumlen;
|
||||
|
||||
/* 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 r_boffset;
|
||||
|
||||
/* The source MAC address of the fragments being merged */
|
||||
|
||||
struct netdev_varaddr_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 r_time;
|
||||
#endif /* CONFIG_NET_6LOWPAN_FRAG */
|
||||
|
||||
/* MAC network driver callback functions **********************************/
|
||||
/**************************************************************************
|
||||
* Name: r_get_mhrlen
|
||||
*
|
||||
* Description:
|
||||
* Calculate the MAC header length given the frame meta-data.
|
||||
*
|
||||
* Input parameters:
|
||||
* netdev - The networkd device that will mediate the MAC interface
|
||||
* meta - Obfuscated metadata structure needed to recreate the
|
||||
* radio MAC header
|
||||
*
|
||||
* Returned Value:
|
||||
* A non-negative MAC headeer length is returned on success; a negated
|
||||
* errno value is returned on any failure.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
CODE int (*r_get_mhrlen)(FAR struct radio_driver_s *netdev,
|
||||
FAR const void *meta);
|
||||
|
||||
/**************************************************************************
|
||||
* Name: r_req_data
|
||||
*
|
||||
* Description:
|
||||
* Requests the transfer of a list of frames to the MAC.
|
||||
*
|
||||
* Input parameters:
|
||||
* netdev - The network device that will mediate the MAC interface
|
||||
* meta - Obfuscated metadata structure needed to create the radio
|
||||
* MAC header
|
||||
* framelist - Head of a list of frames to be transferred.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) returned on success; a negated errno value is returned on
|
||||
* any failure.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
CODE int (*r_req_data)(FAR struct radio_driver_s *netdev,
|
||||
FAR const void *meta, FAR struct iob_s *framelist);
|
||||
|
||||
/**************************************************************************
|
||||
* Name: r_properties
|
||||
*
|
||||
* Description:
|
||||
* 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.
|
||||
*
|
||||
* Input parameters:
|
||||
* netdev - The network device to be queried
|
||||
* properties - Location where radio properities will be returned.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) returned on success; a negated errno value is returned on
|
||||
* any failure.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
CODE int (*r_properties)(FAR struct radio_driver_s *netdev,
|
||||
FAR struct sixlowpan_properties_s *properties);
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
@@ -651,6 +407,9 @@ struct radio_driver_s
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
struct radio_driver_s; /* Forward reference. See radiodev.h */
|
||||
struct iob_s; /* Forward reference See iob.h */
|
||||
|
||||
int sixlowpan_input(FAR struct radio_driver_s *radio,
|
||||
FAR struct iob_s *framelist, FAR const void *metadata);
|
||||
|
||||
|
||||
@@ -112,8 +112,8 @@ struct pktradio_addr_s
|
||||
* run time. This information is provided to the 6LoWPAN network via the
|
||||
* following structure.
|
||||
*
|
||||
* NOTE: This MUST be the same as the struct sixlowpan_properties_s as
|
||||
* defined in sixlowpan.h. It is duplicated here with a different name in
|
||||
* NOTE: This MUST be the same as the struct radiodev_properties_s as
|
||||
* defined in radiodev.h. It is duplicated here with a different name in
|
||||
* order to avoid circular header file inclusion.
|
||||
*/
|
||||
|
||||
|
||||
@@ -22,6 +22,17 @@ config NET_IEEE802154
|
||||
|
||||
if NET_IEEE802154
|
||||
|
||||
config NET_IEEE802154_FRAMELEN
|
||||
int "IEEE802.15.4 Frame Length"
|
||||
default 127
|
||||
range 1 999999
|
||||
---help---
|
||||
For standard IEEE 802.15.4 radios, this should always be 127 bytes.
|
||||
However, some IEEE 802.15.4 radios may non-standard frame lengths.
|
||||
|
||||
This setting is currently used only for detection data transfers
|
||||
that would exceed the radio frame length.
|
||||
|
||||
config NET_IEEE802154_NCONNS
|
||||
int "Max IEEE 802.15.4 sockets"
|
||||
default 4
|
||||
|
||||
@@ -64,6 +64,22 @@
|
||||
#define IEEE802154_POOL_PREALLOCATED 0
|
||||
#define IEEE802154_POOL_DYNAMIC 1
|
||||
|
||||
/* Frame size */
|
||||
|
||||
/* This maximum size of an IEEE802.15.4 frame. Certain, non-standard
|
||||
* devices may exceed this value, however.
|
||||
*/
|
||||
|
||||
#define IEEE802154_MAC_STDFRAME 127
|
||||
|
||||
/* Space for a two byte FCS must be reserved at the end of the frame */
|
||||
|
||||
#define IEEE802154_MAC_FCSSIZE 2
|
||||
|
||||
/* This, then, is the usable size of the frame */
|
||||
|
||||
#define IEEE802154_FRAMELEN (CONFIG_NET_IEEE802154_FRAMELEN - IEEE802154_MAC_FCSSIZE)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
@@ -126,7 +142,7 @@ EXTERN const struct sock_intf_s g_ieee802154_sockif;
|
||||
****************************************************************************/
|
||||
|
||||
struct ieee802154_data_ind_s; /* Forward reference */
|
||||
struct radio_driver_s; /* Forward reference */
|
||||
struct radio_driver_s; /* Forward reference */
|
||||
struct net_driver_s; /* Forward reference */
|
||||
struct eth_hdr_s; /* Forward reference */
|
||||
struct socket; /* Forward reference */
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/mm/iob.h>
|
||||
#include <nuttx/net/sixlowpan.h>
|
||||
#include <nuttx/net/radiodev.h>
|
||||
#include <nuttx/net/ieee802154.h>
|
||||
|
||||
#include "devif/devif.h"
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include <nuttx/net/net.h>
|
||||
#include <nuttx/net/sixlowpan.h>
|
||||
#include <nuttx/net/radiodev.h>
|
||||
#include <nuttx/net/ieee802154.h>
|
||||
|
||||
#include "netdev/netdev.h"
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/mm/iob.h>
|
||||
#include <nuttx/net/sixlowpan.h>
|
||||
#include <nuttx/net/radiodev.h>
|
||||
#include <nuttx/net/ieee802154.h>
|
||||
|
||||
#include "devif/devif.h"
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/net/netconfig.h>
|
||||
#include <nuttx/net/sixlowpan.h>
|
||||
#include <nuttx/net/radiodev.h>
|
||||
#include <nuttx/net/ieee802154.h>
|
||||
|
||||
#include "devif/devif.h"
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
#include <nuttx/clock.h>
|
||||
#include <nuttx/semaphore.h>
|
||||
#include <nuttx/net/net.h>
|
||||
#include <nuttx/net/sixlowpan.h>
|
||||
#include <nuttx/net/radiodev.h>
|
||||
#include <netpacket/ieee802154.h>
|
||||
|
||||
#include "netdev/netdev.h"
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
#include <nuttx/clock.h>
|
||||
#include <nuttx/semaphore.h>
|
||||
#include <nuttx/mm/iob.h>
|
||||
#include <nuttx/net/sixlowpan.h>
|
||||
#include <nuttx/net/radiodev.h>
|
||||
#include <nuttx/net/net.h>
|
||||
#include <nuttx/net/ip.h>
|
||||
|
||||
@@ -334,8 +334,8 @@ static uint16_t ieee802154_sendto_interrupt(FAR struct net_driver_s *dev,
|
||||
* MAC header.
|
||||
*/
|
||||
|
||||
DEBUGASSERT(CONFIG_NET_6LOWPAN_FRAMELEN <= CONFIG_IOB_BUFSIZE);
|
||||
if (pstate->is_buflen + hdrlen > CONFIG_IOB_BUFSIZE)
|
||||
DEBUGASSERT(CONFIG_NET_IEEE802154_FRAMELEN <= CONFIG_IOB_BUFSIZE);
|
||||
if (pstate->is_buflen + hdrlen > IEEE802154_FRAMELEN)
|
||||
{
|
||||
nerr("ERROR: User buffer will not fit into the frame: %u > %u\n",
|
||||
(unsigned int)(pstate->is_buflen + hdrlen),
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/net/net.h>
|
||||
#include <nuttx/net/radiodev.h>
|
||||
#include <netpacket/packet.h>
|
||||
#include <socket/socket.h>
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include <nuttx/net/netdev.h>
|
||||
#include <nuttx/net/radiodev.h>
|
||||
#include <nuttx/net/arp.h>
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN
|
||||
@@ -866,7 +867,7 @@ static int netdev_ifr_ioctl(FAR struct socket *psock, int cmd,
|
||||
dev->d_lltype == NET_LL_PKTRADIO)
|
||||
{
|
||||
FAR struct radio_driver_s *radio;
|
||||
struct sixlowpan_properties_s properties;
|
||||
struct radiodev_properties_s properties;
|
||||
|
||||
/* Get the radio properties */
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
|
||||
#include <nuttx/net/net.h>
|
||||
#include <nuttx/net/netdev.h>
|
||||
#include <nuttx/net/radiodev.h>
|
||||
#include <nuttx/net/sixlowpan.h>
|
||||
|
||||
#include "netdev/netdev.h"
|
||||
@@ -76,7 +77,7 @@
|
||||
static inline int netdev_pktradio_addrlen(FAR struct net_driver_s *dev)
|
||||
{
|
||||
FAR struct radio_driver_s *radio = (FAR struct radio_driver_s *)dev;
|
||||
struct sixlowpan_properties_s properties;
|
||||
struct radiodev_properties_s properties;
|
||||
int ret;
|
||||
|
||||
DEBUGASSERT(radio != NULL && radio->r_properties != NULL);
|
||||
|
||||
@@ -14,12 +14,13 @@ config NET_6LOWPAN_FRAG
|
||||
used or not. Fragmentation is on by default.
|
||||
|
||||
config NET_6LOWPAN_FRAMELEN
|
||||
int "IEEE802.15.4 MAC Frame Length"
|
||||
int "Max Radio Frame Size"
|
||||
default 127
|
||||
range 1 999999
|
||||
---help---
|
||||
Some wireless devices may use non-standard frame lengths. This
|
||||
setting should never be smaller than 127.
|
||||
Wireless devices use a variety of frame sizes. For IEEE 802.15.4
|
||||
radios, this should be 127 bytes. However, some IEEE 802.15.4
|
||||
radios may non-standard frame lengths.
|
||||
|
||||
choice
|
||||
prompt "6LoWPAN Compression"
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/net/netdev.h>
|
||||
#include <nuttx/net/radiodev.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "sixlowpan/sixlowpan_internal.h"
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include "nuttx/net/net.h"
|
||||
#include "nuttx/net/radiodev.h"
|
||||
#include "nuttx/wireless/ieee802154/ieee802154_mac.h"
|
||||
|
||||
#include "sixlowpan/sixlowpan_internal.h"
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/net/netdev.h>
|
||||
#include <nuttx/net/radiodev.h>
|
||||
#include <nuttx/net/ip.h>
|
||||
|
||||
#include "sixlowpan/sixlowpan_internal.h"
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/net/netdev.h>
|
||||
#include <nuttx/net/radiodev.h>
|
||||
#include "sixlowpan/sixlowpan_internal.h"
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN_COMPRESSION_HC1
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/net/netdev.h>
|
||||
#include <nuttx/net/radiodev.h>
|
||||
#include <nuttx/net/ip.h>
|
||||
|
||||
#include "icmpv6/icmpv6.h"
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
#endif
|
||||
|
||||
#include "nuttx/net/netdev.h"
|
||||
#include "nuttx/net/radiodev.h"
|
||||
#include "nuttx/net/ip.h"
|
||||
#include "nuttx/net/icmpv6.h"
|
||||
#include "nuttx/net/sixlowpan.h"
|
||||
|
||||
@@ -233,7 +233,7 @@ extern uint8_t g_frame_hdrlen;
|
||||
****************************************************************************/
|
||||
|
||||
struct net_driver_s; /* Forward reference */
|
||||
struct radio_driver_s; /* Forward reference */
|
||||
struct radio_driver_s; /* Forward reference */
|
||||
struct devif_callback_s; /* Forward reference */
|
||||
struct ipv6_hdr_s; /* Forward reference */
|
||||
struct netdev_varaddr_s; /* Forward reference */
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include <nuttx/clock.h>
|
||||
#include <nuttx/semaphore.h>
|
||||
#include <nuttx/net/net.h>
|
||||
#include <nuttx/net/radiodev.h>
|
||||
|
||||
#include "netdev/netdev.h"
|
||||
#include "devif/devif.h"
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
|
||||
#include "nuttx/semaphore.h"
|
||||
#include "nuttx/net/netdev.h"
|
||||
#include "nuttx/net/radiodev.h"
|
||||
#include "nuttx/net/netstats.h"
|
||||
|
||||
#include "netdev/netdev.h"
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include "nuttx/net/netdev.h"
|
||||
#include "nuttx/net/radiodev.h"
|
||||
#include "nuttx/net/netstats.h"
|
||||
|
||||
#include "netdev/netdev.h"
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/net/ip.h>
|
||||
#include <nuttx/net/radiodev.h>
|
||||
#include <nuttx/net/sixlowpan.h>
|
||||
#include <nuttx/wireless/pktradio.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||
@@ -192,7 +193,7 @@ int sixlowpan_destaddrfromip(FAR struct radio_driver_s *radio,
|
||||
const net_ipv6addr_t ipaddr,
|
||||
FAR struct netdev_varaddr_s *destaddr)
|
||||
{
|
||||
struct sixlowpan_properties_s properties;
|
||||
struct radiodev_properties_s properties;
|
||||
int ret;
|
||||
|
||||
#ifdef CONFIG_NET_STARPOINT
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
#include <nuttx/wqueue.h>
|
||||
#include <nuttx/net/net.h>
|
||||
#include <nuttx/net/ip.h>
|
||||
#include <nuttx/net/radiodev.h>
|
||||
#include <nuttx/net/ieee802154.h>
|
||||
#include <nuttx/net/sixlowpan.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_loopback.h>
|
||||
@@ -167,7 +168,7 @@ static int lo_get_mhrlen(FAR struct radio_driver_s *netdev,
|
||||
static int lo_req_data(FAR struct radio_driver_s *netdev,
|
||||
FAR const void *meta, FAR struct iob_s *framelist);
|
||||
static int lo_properties(FAR struct radio_driver_s *netdev,
|
||||
FAR struct sixlowpan_properties_s *properties);
|
||||
FAR struct radiodev_properties_s *properties);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
@@ -926,10 +927,10 @@ static int lo_req_data(FAR struct radio_driver_s *netdev,
|
||||
****************************************************************************/
|
||||
|
||||
static int lo_properties(FAR struct radio_driver_s *netdev,
|
||||
FAR struct sixlowpan_properties_s *properties)
|
||||
FAR struct radiodev_properties_s *properties)
|
||||
{
|
||||
DEBUGASSERT(netdev != NULL && properties != NULL);
|
||||
memset(properties, 0, sizeof(struct sixlowpan_properties_s));
|
||||
memset(properties, 0, sizeof(struct radiodev_properties_s));
|
||||
|
||||
/* General */
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
#include <nuttx/mm/iob.h>
|
||||
#include <nuttx/net/arp.h>
|
||||
#include <nuttx/net/netdev.h>
|
||||
#include <nuttx/net/radiodev.h>
|
||||
#include <nuttx/net/ieee802154.h>
|
||||
#include <nuttx/net/sixlowpan.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||
@@ -201,7 +202,7 @@ static int macnet_get_mhrlen(FAR struct radio_driver_s *netdev,
|
||||
static int macnet_req_data(FAR struct radio_driver_s *netdev,
|
||||
FAR const void *meta, FAR struct iob_s *framelist);
|
||||
static int macnet_properties(FAR struct radio_driver_s *netdev,
|
||||
FAR struct sixlowpan_properties_s *properties);
|
||||
FAR struct radiodev_properties_s *properties);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
@@ -1073,10 +1074,10 @@ static int macnet_req_data(FAR struct radio_driver_s *netdev,
|
||||
****************************************************************************/
|
||||
|
||||
static int macnet_properties(FAR struct radio_driver_s *netdev,
|
||||
FAR struct sixlowpan_properties_s *properties)
|
||||
FAR struct radiodev_properties_s *properties)
|
||||
{
|
||||
DEBUGASSERT(netdev != NULL && properties != NULL);
|
||||
memset(properties, 0, sizeof(struct sixlowpan_properties_s));
|
||||
memset(properties, 0, sizeof(struct radiodev_properties_s));
|
||||
|
||||
/* General */
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
#include <nuttx/wqueue.h>
|
||||
#include <nuttx/net/net.h>
|
||||
#include <nuttx/net/ip.h>
|
||||
#include <nuttx/net/radiodev.h>
|
||||
#include <nuttx/net/sixlowpan.h>
|
||||
#include <nuttx/wireless/pktradio.h>
|
||||
|
||||
@@ -177,7 +178,7 @@ static int lo_get_mhrlen(FAR struct radio_driver_s *netdev,
|
||||
static int lo_req_data(FAR struct radio_driver_s *netdev,
|
||||
FAR const void *meta, FAR struct iob_s *framelist);
|
||||
static int lo_properties(FAR struct radio_driver_s *netdev,
|
||||
FAR struct sixlowpan_properties_s *properties);
|
||||
FAR struct radiodev_properties_s *properties);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
@@ -748,8 +749,8 @@ static int lo_ioctl(FAR struct net_driver_s *dev, int cmd,
|
||||
{
|
||||
FAR struct radio_driver_s *radio =
|
||||
(FAR struct radio_driver_s *)dev;
|
||||
FAR struct sixlowpan_properties_s *props =
|
||||
(FAR struct sixlowpan_properties_s *)&cmddata->pifr_props;
|
||||
FAR struct radiodev_properties_s *props =
|
||||
(FAR struct radiodev_properties_s *)&cmddata->pifr_props;
|
||||
|
||||
ret = lo_properties(radio, props);
|
||||
}
|
||||
@@ -929,10 +930,10 @@ static int lo_req_data(FAR struct radio_driver_s *netdev,
|
||||
****************************************************************************/
|
||||
|
||||
static int lo_properties(FAR struct radio_driver_s *netdev,
|
||||
FAR struct sixlowpan_properties_s *properties)
|
||||
FAR struct radiodev_properties_s *properties)
|
||||
{
|
||||
DEBUGASSERT(netdev != NULL && properties != NULL);
|
||||
memset(properties, 0, sizeof(struct sixlowpan_properties_s));
|
||||
memset(properties, 0, sizeof(struct radiodev_properties_s));
|
||||
|
||||
/* General */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user