mirror of
https://github.com/apache/nuttx.git
synced 2026-05-24 16:11:56 +08:00
Squashed commit of the following:
commit 2a3ab1652a2c95bcfc8be8380fc7cbdcb6472938
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Sat Aug 19 08:44:31 2017 -0600
PF_IEEE802154: Finish some missing bind() logic. Add configs/sim configuration for testing.
commit 59be4b846a6e3bfe82087a888e3fdac9c3c414e5
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Fri Aug 18 19:30:04 2017 -0600
PF_IEEE802154: More renaming to decouple 6LoPAN from radios in general.
commit 69fabb1aea76e54381bdc13de28a3f1441fb42f4
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Fri Aug 18 19:21:11 2017 -0600
PF_IEEE802154: Missed a few renamings.
commit ff0af1bb25567720934cc1c2a721ccd92cc35f89
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Fri Aug 18 17:46:58 2017 -0600
PF_IEEE802154: A few bugfixes
commit 01c7c84afd00cf907d280d30cfaf0fb2cf90e02e
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Fri Aug 18 17:01:31 2017 -0600
PF_IEEE802154: A few bugfixes
commit dcef4056d1c1488c93151135f3b7106977faa903
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Fri Aug 18 16:31:05 2017 -0600
PF_IEEE802154: Bring in framework for sendto/recvfrom. Currently just a crude port of functions from net/pkt and do not provide the implemenation needed.
commit 68c5b7b6dd3ab7eb2d0c19890abb38e6561b140e
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Fri Aug 18 15:18:31 2017 -0600
Trivial fix to typo in comment
commit fd0af534c089569ccdbd59f13b85453de0a653ad
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Fri Aug 18 15:07:20 2017 -0600
PF_IEEE802154: Add device lookup logic; Rename some things that used to be used only by 6LoWPAN but now must be shared with PF_IEEE802154 and need more generic naming.
commit 4fc80a1659f1c699b050775cefc7f6b631b46114
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Fri Aug 18 13:49:54 2017 -0600
PF_IEEE802154: Add driver poll logic.
commit d83f71992df8764faa93f9425f1a7602a758f730
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Fri Aug 18 13:28:59 2017 -0600
PF_IEEE802154: Add frame input function.
commit 77561b8c4d5d7be1f8d8eb62cf1a07229afe2048
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Fri Aug 18 12:46:29 2017 -0600
PF_IEEE802154: Socket type should be SOCK_DGRAM. Hook in socket interface.
commit c0f90350282e9905d7f26a1b30f04cc6d6794648
Merge: 8b518abfd0 169c55e546
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Fri Aug 18 09:36:32 2017 -0600
Merge remote-tracking branch 'origin/master' into pf_ieee802154
commit 8b518abfd07d492f5148f2c5fdf65604de9822da
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Fri Aug 18 09:35:39 2017 -0600
PF_IEEE802154: Add initialization and connection management logic.
commit 98b62620b3cb420041d8ad14204f9410a8aace8c
Author: Gregory Nutt <gnutt@nuttx.org>
Date: Fri Aug 18 07:52:51 2017 -0600
PF_IEEE802154: Add basic build support and socket interface framework.
This commit is contained in:
@@ -829,6 +829,13 @@ pashello
|
||||
|
||||
Configures to use apps/examples/pashello.
|
||||
|
||||
pf_ieee802154
|
||||
|
||||
This is the configuration that used for unit level test of the
|
||||
socket support for the PF_IEEE802154 address family. It uses
|
||||
the IEEE 802.15.4 loopback network driver and the test at
|
||||
apps/examples/pf_ieee802154.
|
||||
|
||||
pktradio
|
||||
|
||||
This configuration is identical to the 'sixlowpan configuration
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
# CONFIG_MMCSD_MMCSUPPORT is not set
|
||||
# CONFIG_MMCSD_SPI is not set
|
||||
# CONFIG_NET_ETHERNET is not set
|
||||
# CONFIG_NET_IPv4 is not set
|
||||
# CONFIG_NET_UDP_CHECKSUMS is not set
|
||||
# CONFIG_NSH_CMDOPT_DF_H is not set
|
||||
# CONFIG_SIM_NETDEV is not set
|
||||
CONFIG_ARCH_BOARD_SIM=y
|
||||
CONFIG_ARCH_BOARD="sim"
|
||||
CONFIG_ARCH_SIM=y
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH="sim"
|
||||
CONFIG_AT24XX_ADDR=0x57
|
||||
CONFIG_AT24XX_EXTENDED=y
|
||||
CONFIG_AT24XX_EXTSIZE=160
|
||||
CONFIG_AT24XX_SIZE=2
|
||||
CONFIG_BOARD_LOOPSPERMSEC=51262
|
||||
CONFIG_BOARDCTL_POWEROFF=y
|
||||
CONFIG_BUILTIN_PROXY_STACKSIZE=2048
|
||||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEBUG_ASSERTIONS=y
|
||||
CONFIG_DEBUG_FEATURES=y
|
||||
CONFIG_DEBUG_SYMBOLS=y
|
||||
CONFIG_DISABLE_POLL=y
|
||||
CONFIG_DRIVERS_WIRELESS=y
|
||||
CONFIG_EXAMPLES_NETTEST_DAEMON_STACKSIZE=4096
|
||||
CONFIG_EXAMPLES_NETTEST_LOOPBACK=y
|
||||
CONFIG_EXAMPLES_NETTEST_SERVER_PORTNO=61616
|
||||
CONFIG_EXAMPLES_NETTEST_SERVERIPv6ADDR_1=0xfe80
|
||||
CONFIG_EXAMPLES_NETTEST_SERVERIPv6ADDR_6=0x00ff
|
||||
CONFIG_EXAMPLES_NETTEST_SERVERIPv6ADDR_7=0xfe00
|
||||
CONFIG_EXAMPLES_NETTEST_SERVERIPv6ADDR_8=0xcda9
|
||||
CONFIG_EXAMPLES_NETTEST_STACKSIZE1=4096
|
||||
CONFIG_EXAMPLES_NETTEST=y
|
||||
CONFIG_EXAMPLES_NSH=y
|
||||
CONFIG_EXAMPLES_PFIEEE802154_STACKSIZE1=8192
|
||||
CONFIG_EXAMPLES_PFIEEE802154_STACKSIZE2=8192
|
||||
CONFIG_EXAMPLES_PFIEEE802154=y
|
||||
CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_1=0xfe80
|
||||
CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_6=0x00ff
|
||||
CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_7=0xfe00
|
||||
CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_8=0x1034
|
||||
CONFIG_EXAMPLES_UDPBLASTER_STACKSIZE=8192
|
||||
CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_1=0xfe80
|
||||
CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_6=0x00ff
|
||||
CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_7=0xfe00
|
||||
CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_8=0xa9cd
|
||||
CONFIG_EXAMPLES_UDPBLASTER=y
|
||||
CONFIG_EXPERIMENTAL=y
|
||||
CONFIG_FAT_LCNAMES=y
|
||||
CONFIG_FAT_LFN=y
|
||||
CONFIG_FS_FAT=y
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_I2C_DRIVER=y
|
||||
CONFIG_IDLETHREAD_STACKSIZE=4096
|
||||
CONFIG_IEEE802154_LOOPBACK=y
|
||||
CONFIG_IOB_BUFSIZE=128
|
||||
CONFIG_IOB_NBUFFERS=48
|
||||
CONFIG_MAX_TASKS=16
|
||||
CONFIG_MAX_WDOGPARMS=2
|
||||
CONFIG_MMCSD_MULTIBLOCK_DISABLE=y
|
||||
CONFIG_MMCSD=y
|
||||
CONFIG_MTD_AT24XX=y
|
||||
CONFIG_MTD_AT25=y
|
||||
CONFIG_MTD_CONFIG=y
|
||||
CONFIG_MTD=y
|
||||
CONFIG_NET_6LOWPAN_TCP_RECVWNDO=102
|
||||
CONFIG_NET_6LOWPAN=y
|
||||
CONFIG_NET_BROADCAST=y
|
||||
CONFIG_NET_HOSTNAME="SAMV71-XULT"
|
||||
CONFIG_NET_IEEE802154=y
|
||||
CONFIG_NET_IPv6=y
|
||||
CONFIG_NET_SOCKOPTS=y
|
||||
CONFIG_NET_STATISTICS=y
|
||||
CONFIG_NET_TCP_WRITE_BUFFERS=y
|
||||
CONFIG_NET_TCP=y
|
||||
CONFIG_NET_TCPBACKLOG=y
|
||||
CONFIG_NET_UDP=y
|
||||
CONFIG_NET=y
|
||||
CONFIG_NETDB_DNSCLIENT=y
|
||||
CONFIG_NETDEV_PHY_IOCTL=y
|
||||
CONFIG_NETDEV_STATISTICS=y
|
||||
CONFIG_NETDEV_TELNET=y
|
||||
CONFIG_NETDEVICES=y
|
||||
CONFIG_NFILE_DESCRIPTORS=8
|
||||
CONFIG_NFILE_STREAMS=8
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
CONFIG_NSH_BUILTIN_APPS=y
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_NOMAC=y
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=2048
|
||||
CONFIG_PREALLOC_MQ_MSGS=4
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_PTHREAD_STACK_DEFAULT=4096
|
||||
CONFIG_RAM_SIZE=393216
|
||||
CONFIG_RAM_START=0x20400000
|
||||
CONFIG_RAW_BINARY=y
|
||||
CONFIG_RR_INTERVAL=200
|
||||
CONFIG_SCHED_HPWORK=y
|
||||
CONFIG_SCHED_HPWORKSTACKSIZE=4096
|
||||
CONFIG_SCHED_WAITPID=y
|
||||
CONFIG_SDCLONE_DISABLE=y
|
||||
CONFIG_STANDARD_SERIAL=y
|
||||
CONFIG_START_DAY=10
|
||||
CONFIG_START_MONTH=3
|
||||
CONFIG_START_YEAR=2014
|
||||
CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=4096
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
CONFIG_USERMAIN_STACKSIZE=8192
|
||||
CONFIG_WIRELESS_IEEE802154=y
|
||||
CONFIG_WIRELESS=y
|
||||
@@ -265,7 +265,7 @@ enum spirit_driver_state_e
|
||||
|
||||
struct spirit_driver_s
|
||||
{
|
||||
struct sixlowpan_driver_s radio; /* Interface understood by the network */
|
||||
struct radio_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 pktradio_metadata_s *txhead; /* Head of pending TX transfers */
|
||||
@@ -347,11 +347,11 @@ static int spirit_ioctl(FAR struct net_driver_s *dev, int cmd,
|
||||
unsigned long arg);
|
||||
#endif
|
||||
|
||||
static int spirit_get_mhrlen(FAR struct sixlowpan_driver_s *netdev,
|
||||
static int spirit_get_mhrlen(FAR struct radio_driver_s *netdev,
|
||||
FAR const void *meta);
|
||||
static int spirit_req_data(FAR struct sixlowpan_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 sixlowpan_driver_s *netdev,
|
||||
static int spirit_properties(FAR struct radio_driver_s *netdev,
|
||||
FAR struct sixlowpan_properties_s *properties);
|
||||
|
||||
/* Initialization */
|
||||
@@ -567,7 +567,7 @@ static void spirit_set_ipaddress(FAR struct net_driver_s *dev)
|
||||
|
||||
/* Get a convenient pointer to the PktRadio variable length address struct */
|
||||
|
||||
addr = (FAR struct netdev_varaddr_s *)&dev->d_mac.sixlowpan;
|
||||
addr = (FAR struct netdev_varaddr_s *)&dev->d_mac.radio;
|
||||
|
||||
/* Has a node address been assigned? */
|
||||
|
||||
@@ -1894,12 +1894,12 @@ static int spirit_ifup(FAR struct net_driver_s *dev)
|
||||
|
||||
/* Instantiate the assigned node address in hardware */
|
||||
|
||||
DEBUGASSERT(dev->d_mac.sixlowpan.nv_addrlen == 1);
|
||||
DEBUGASSERT(dev->d_mac.radio.nv_addrlen == 1);
|
||||
wlinfo("Set node address to %02x\n",
|
||||
dev->d_mac.sixlowpan.nv_addr[0]);
|
||||
dev->d_mac.radio.nv_addr[0]);
|
||||
|
||||
ret = spirit_pktcommon_set_nodeaddress(spirit,
|
||||
dev->d_mac.sixlowpan.nv_addr[0]);
|
||||
dev->d_mac.radio.nv_addr[0]);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("ERROR: Failed to set node address: %d\n", ret);
|
||||
@@ -2139,8 +2139,8 @@ static int spirit_ioctl(FAR struct net_driver_s *dev, int cmd,
|
||||
|
||||
case SIOCPKTRADIOGGPROPS:
|
||||
{
|
||||
FAR struct sixlowpan_driver_s *radio =
|
||||
(FAR struct sixlowpan_driver_s *)dev;
|
||||
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;
|
||||
|
||||
@@ -2166,7 +2166,7 @@ static int spirit_ioctl(FAR struct net_driver_s *dev, int cmd,
|
||||
}
|
||||
else
|
||||
{
|
||||
FAR struct netdev_varaddr_s *devaddr = &dev->d_mac.sixlowpan;
|
||||
FAR struct netdev_varaddr_s *devaddr = &dev->d_mac.radio;
|
||||
|
||||
devaddr->nv_addrlen = 1;
|
||||
devaddr->nv_addr[0] = newaddr->pa_addr[0];
|
||||
@@ -2190,7 +2190,7 @@ static int spirit_ioctl(FAR struct net_driver_s *dev, int cmd,
|
||||
{
|
||||
FAR struct pktradio_addr_s *retaddr =
|
||||
(FAR struct pktradio_addr_s *)&cmddata->pifr_hwaddr;
|
||||
FAR struct netdev_varaddr_s *devaddr = &dev->d_mac.sixlowpan;
|
||||
FAR struct netdev_varaddr_s *devaddr = &dev->d_mac.radio;
|
||||
|
||||
retaddr->pa_addrlen = devaddr->nv_addrlen;
|
||||
retaddr->pa_addr[0] = devaddr->nv_addr[0];
|
||||
@@ -2231,7 +2231,7 @@ static int spirit_ioctl(FAR struct net_driver_s *dev, int cmd,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int spirit_get_mhrlen(FAR struct sixlowpan_driver_s *netdev,
|
||||
static int spirit_get_mhrlen(FAR struct radio_driver_s *netdev,
|
||||
FAR const void *meta)
|
||||
{
|
||||
DEBUGASSERT(netdev != NULL && netdev->r_dev.d_private != NULL && meta != NULL);
|
||||
@@ -2265,7 +2265,7 @@ static int spirit_get_mhrlen(FAR struct sixlowpan_driver_s *netdev,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int spirit_req_data(FAR struct sixlowpan_driver_s *netdev,
|
||||
static int spirit_req_data(FAR struct radio_driver_s *netdev,
|
||||
FAR const void *meta, FAR struct iob_s *framelist)
|
||||
{
|
||||
FAR struct spirit_driver_s *priv;
|
||||
@@ -2372,7 +2372,7 @@ static int spirit_req_data(FAR struct sixlowpan_driver_s *netdev,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int spirit_properties(FAR struct sixlowpan_driver_s *netdev,
|
||||
static int spirit_properties(FAR struct radio_driver_s *netdev,
|
||||
FAR struct sixlowpan_properties_s *properties)
|
||||
{
|
||||
DEBUGASSERT(netdev != NULL && properties != NULL);
|
||||
@@ -2750,7 +2750,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 sixlowpan_driver_s *radio;
|
||||
FAR struct radio_driver_s *radio;
|
||||
FAR struct net_driver_s *dev;
|
||||
FAR uint8_t *pktbuf;
|
||||
int ret;
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
* See also the definitions above for portable union selectors.
|
||||
*/
|
||||
|
||||
struct ieee802154_addr_s
|
||||
struct ieee802154_saddr_s
|
||||
{
|
||||
uint8_t s_mode; /* Address mode (see enum
|
||||
* ieee802154_addrmode_e) */
|
||||
@@ -91,7 +91,7 @@ struct ieee802154_addr_s
|
||||
struct sockaddr_ieee802154_s
|
||||
{
|
||||
sa_family_t sa_family; /* AF_IEEE802154 */
|
||||
struct ieee802154_addr_s sa_addr; /* Radio address */
|
||||
struct ieee802154_saddr_s sa_addr; /* Radio address */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/net/ieee802154.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 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_NET_IEEE802154_H
|
||||
#define __INCLUDE_NUTTX_NET_IEEE802154_H
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ieee802154_input
|
||||
*
|
||||
* Description:
|
||||
* Handle incoming IEEE 802.15.4 input
|
||||
*
|
||||
* 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 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.
|
||||
*
|
||||
* - The io_flink field points to the next frame in the list (if enable)
|
||||
* - The last frame in the list will have io_flink == NULL.
|
||||
*
|
||||
* Parameters:
|
||||
* 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.
|
||||
* meta - Meta data characterizing the received frame.
|
||||
*
|
||||
* If there are multilple frames in the list, this metadata
|
||||
* must apply to all of the frames in the list.
|
||||
*
|
||||
* Return:
|
||||
* OK The IEEE 802.15.4 has been processed and can be deleted
|
||||
* ERROR Hold the IEEE 802.15.4 and try again later. There is a listening
|
||||
* socket but no recv in place to catch the IEEE 802.15.4 yet.
|
||||
* Useful when a packet arrives before a recv call is in place.
|
||||
*
|
||||
* Assumptions:
|
||||
* Called from the network diver with the network locked.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
struct radio_driver_s; /* Forward reference */
|
||||
struct ieee802154_data_ind_s; /* Forward reference */
|
||||
struct iob_s; /* Forward reference */
|
||||
|
||||
int ieee802154_input(FAR struct radio_driver_s *radio,
|
||||
FAR struct iob_s *framelist,
|
||||
FAR const struct ieee802154_data_ind_s *meta);
|
||||
|
||||
#endif /* __INCLUDE_NUTTX_NET_IEEE802154_H */
|
||||
@@ -247,10 +247,10 @@ struct net_driver_s
|
||||
struct ether_addr ether; /* Device Ethernet MAC address */
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN
|
||||
#if defined(CONFIG_NET_6LOWPAN) || defined(CONFIG_NET_IEEE802154)
|
||||
/* The address assigned to an IEEE 802.15.4 or generic packet radio. */
|
||||
|
||||
struct netdev_varaddr_s sixlowpan;
|
||||
struct netdev_varaddr_s radio;
|
||||
#endif /* CONFIG_NET_6LOWPAN */
|
||||
} d_mac;
|
||||
#endif /* CONFIG_NET_ETHERNET || CONFIG_NET_6LOWPAN */
|
||||
@@ -463,9 +463,9 @@ int ipv6_input(FAR struct net_driver_s *dev);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN
|
||||
struct sixlowpan_driver_s; /* See sixlowpan.h */
|
||||
struct radio_driver_s; /* See sixlowpan.h */
|
||||
struct iob_s; /* See iob.h */
|
||||
int sixlowpan_input(FAR struct sixlowpan_driver_s *ieee,
|
||||
int sixlowpan_input(FAR struct radio_driver_s *ieee,
|
||||
FAR struct iob_s *framelist, FAR const void *metadata);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -387,7 +387,7 @@ struct sixlowpan_properties_s
|
||||
*
|
||||
* 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 sixlowpan_driver_s' is cast
|
||||
* 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.
|
||||
*
|
||||
@@ -428,7 +428,7 @@ struct sixlowpan_properties_s
|
||||
|
||||
struct iob_s; /* Forward reference */
|
||||
|
||||
struct sixlowpan_driver_s
|
||||
struct radio_driver_s
|
||||
{
|
||||
/* This definitiona must appear first in the structure definition to
|
||||
* assure cast compatibility.
|
||||
@@ -534,7 +534,7 @@ struct sixlowpan_driver_s
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
CODE int (*r_get_mhrlen)(FAR struct sixlowpan_driver_s *netdev,
|
||||
CODE int (*r_get_mhrlen)(FAR struct radio_driver_s *netdev,
|
||||
FAR const void *meta);
|
||||
|
||||
/**************************************************************************
|
||||
@@ -555,7 +555,7 @@ struct sixlowpan_driver_s
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
CODE int (*r_req_data)(FAR struct sixlowpan_driver_s *netdev,
|
||||
CODE int (*r_req_data)(FAR struct radio_driver_s *netdev,
|
||||
FAR const void *meta, FAR struct iob_s *framelist);
|
||||
|
||||
/**************************************************************************
|
||||
@@ -577,7 +577,7 @@ struct sixlowpan_driver_s
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
CODE int (*r_properties)(FAR struct sixlowpan_driver_s *netdev,
|
||||
CODE int (*r_properties)(FAR struct radio_driver_s *netdev,
|
||||
FAR struct sixlowpan_properties_s *properties);
|
||||
};
|
||||
|
||||
@@ -651,7 +651,7 @@ struct sixlowpan_driver_s
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_input(FAR struct sixlowpan_driver_s *radio,
|
||||
int sixlowpan_input(FAR struct radio_driver_s *radio,
|
||||
FAR struct iob_s *framelist, FAR const void *metadata);
|
||||
|
||||
#endif /* CONFIG_NET_6LOWPAN */
|
||||
|
||||
@@ -280,6 +280,7 @@ source "net/pkt/Kconfig"
|
||||
source "net/local/Kconfig"
|
||||
source "net/tcp/Kconfig"
|
||||
source "net/udp/Kconfig"
|
||||
source "net/ieee802154/Kconfig"
|
||||
source "net/icmp/Kconfig"
|
||||
source "net/icmpv6/Kconfig"
|
||||
source "net/igmp/Kconfig"
|
||||
|
||||
@@ -68,6 +68,7 @@ include local/Make.defs
|
||||
include tcp/Make.defs
|
||||
include udp/Make.defs
|
||||
include sixlowpan/Make.defs
|
||||
include ieee802154/Make.defs
|
||||
include devif/Make.defs
|
||||
include ipforward/Make.defs
|
||||
include loopback/Make.defs
|
||||
|
||||
+19
-17
@@ -8,23 +8,25 @@ Directory Structure
|
||||
|
|
||||
`- net/
|
||||
|
|
||||
+- arp - Address resolution protocol (IPv4)
|
||||
+- devif - Stack/device interface layer
|
||||
+- icmp - Internet Control Message Protocol (IPv4)
|
||||
+- icmpv6 - Internet Control Message Protocol (IPv6)
|
||||
+- inet - PF_INET/PF_INET6 socket interface
|
||||
+- ipforward - IP forwarding logic
|
||||
+- local - Unix domain (local) sockets
|
||||
+- loopback - Local loopback
|
||||
+- neighbor - Neighbor Discovery Protocol (IPv6)
|
||||
+- netdev - Socket network device interface
|
||||
+- pkt - "Raw" packet socket support
|
||||
+- socket - BSD socket interface
|
||||
+- route - Routing table support
|
||||
+- tcp - Transmission Control Protocol
|
||||
+- udp - User Datagram Protocol
|
||||
+- usrsock - User socket API for user-space networking stack
|
||||
`- utils - Miscellaneous utility functions
|
||||
+- arp - Address resolution protocol (IPv4)
|
||||
+- devif - Stack/device interface layer
|
||||
+- icmp - Internet Control Message Protocol (IPv4)
|
||||
+- icmpv6 - Internet Control Message Protocol (IPv6)
|
||||
+- ieee802154 - PF_IEEE802154 socket interface
|
||||
+- inet - PF_INET/PF_INET6 socket interface
|
||||
+- ipforward - IP forwarding logic
|
||||
+- local - Unix domain (local) sockets
|
||||
+- loopback - Local loopback
|
||||
+- neighbor - Neighbor Discovery Protocol (IPv6)
|
||||
+- netdev - Socket network device interface
|
||||
+- pkt - "Raw" packet socket support
|
||||
+- sixlowpan - 6LoWPAN implementation
|
||||
+- socket - BSD socket interface
|
||||
+- route - Routing table support
|
||||
+- tcp - Transmission Control Protocol
|
||||
+- udp - User Datagram Protocol
|
||||
+- usrsock - User socket API for user-space networking stack
|
||||
`- utils - Miscellaneous utility functions
|
||||
|
||||
|
||||
+-------------------------------------------------------------------++------------------------+
|
||||
|
||||
+33
-31
@@ -74,7 +74,7 @@
|
||||
* TCP_NEWDATA IN: Set to indicate that the peer has sent us new data.
|
||||
* UDP_NEWDATA OUT: Cleared (only) by the socket layer logic to indicate
|
||||
* PKT_NEWDATA that the new data was consumed, suppressing further
|
||||
* attempts to process the new data.
|
||||
* IEEE802154_NEWDATA attempts to process the new data.
|
||||
*
|
||||
* TCP_SNDACK IN: Not used; always zero
|
||||
* OUT: Set by the socket layer if the new data was consumed
|
||||
@@ -87,7 +87,7 @@
|
||||
* TCP_POLL IN: Used for polling the socket layer. This is provided
|
||||
* UDP_POLL periodically from the drivers to support (1) timed
|
||||
* PKT_POLL operations, and (2) to check if the socket layer has
|
||||
* data that it wants to send. These are socket oriented
|
||||
* IEEE802154_POLL data that it wants to send. These are socket oriented
|
||||
* callbacks where the context depends on the specific
|
||||
* set
|
||||
* OUT: Not used
|
||||
@@ -174,31 +174,33 @@
|
||||
|
||||
/* Bits 0-9: Connection specific event bits */
|
||||
|
||||
#define TCP_ACKDATA (1 << 0)
|
||||
#define TCP_NEWDATA (1 << 1)
|
||||
#define UDP_NEWDATA TCP_NEWDATA
|
||||
#define PKT_NEWDATA TCP_NEWDATA
|
||||
#define WPAN_NEWDATA TCP_NEWDATA
|
||||
#define IPFWD_NEWDATA TCP_NEWDATA
|
||||
#define TCP_SNDACK (1 << 2)
|
||||
#define TCP_REXMIT (1 << 3)
|
||||
#define TCP_POLL (1 << 4)
|
||||
#define UDP_POLL TCP_POLL
|
||||
#define PKT_POLL TCP_POLL
|
||||
#define WPAN_POLL TCP_POLL
|
||||
#define TCP_BACKLOG (1 << 5)
|
||||
#define TCP_CLOSE (1 << 6)
|
||||
#define TCP_ABORT (1 << 7)
|
||||
#define TCP_CONNECTED (1 << 8)
|
||||
#define TCP_TIMEDOUT (1 << 9)
|
||||
#define TCP_ACKDATA (1 << 0)
|
||||
#define TCP_NEWDATA (1 << 1)
|
||||
#define UDP_NEWDATA TCP_NEWDATA
|
||||
#define IEEE802154_NEWDATA TCP_NEWDATA
|
||||
#define PKT_NEWDATA TCP_NEWDATA
|
||||
#define WPAN_NEWDATA TCP_NEWDATA
|
||||
#define IPFWD_NEWDATA TCP_NEWDATA
|
||||
#define TCP_SNDACK (1 << 2)
|
||||
#define TCP_REXMIT (1 << 3)
|
||||
#define TCP_POLL (1 << 4)
|
||||
#define UDP_POLL TCP_POLL
|
||||
#define PKT_POLL TCP_POLL
|
||||
#define IEEE802154_POLL TCP_POLL
|
||||
#define WPAN_POLL TCP_POLL
|
||||
#define TCP_BACKLOG (1 << 5)
|
||||
#define TCP_CLOSE (1 << 6)
|
||||
#define TCP_ABORT (1 << 7)
|
||||
#define TCP_CONNECTED (1 << 8)
|
||||
#define TCP_TIMEDOUT (1 << 9)
|
||||
|
||||
/* Bits 10-12: Device specific event bits */
|
||||
|
||||
#define ICMP_NEWDATA TCP_NEWDATA
|
||||
#define ICMPv6_NEWDATA TCP_NEWDATA
|
||||
#define ICMP_ECHOREPLY (1 << 10)
|
||||
#define ICMPv6_ECHOREPLY (1 << 11)
|
||||
#define NETDEV_DOWN (1 << 12)
|
||||
#define ICMP_NEWDATA TCP_NEWDATA
|
||||
#define ICMPv6_NEWDATA TCP_NEWDATA
|
||||
#define ICMP_ECHOREPLY (1 << 10)
|
||||
#define ICMPv6_ECHOREPLY (1 << 11)
|
||||
#define NETDEV_DOWN (1 << 12)
|
||||
|
||||
/* Bits 13-15: Encoded device specific poll events. Unlike connection
|
||||
* oriented poll events, device related poll events must distinguish
|
||||
@@ -206,13 +208,13 @@
|
||||
* the same list in the network device structure.
|
||||
*/
|
||||
|
||||
#define DEVPOLL_SHIFT (13)
|
||||
#define DEVPOLL_MASK (7 << DEVPOLL_SHIFT)
|
||||
# define DEVPOLL_NONE (0 << DEVPOLL_SHIFT)
|
||||
# define ARP_POLL (1 << DEVPOLL_SHIFT)
|
||||
# define ICMP_POLL (2 << DEVPOLL_SHIFT)
|
||||
# define ICMPv6_POLL (3 << DEVPOLL_SHIFT)
|
||||
# define IPFWD_POLL (4 << DEVPOLL_SHIFT)
|
||||
#define DEVPOLL_SHIFT (13)
|
||||
#define DEVPOLL_MASK (7 << DEVPOLL_SHIFT)
|
||||
# define DEVPOLL_NONE (0 << DEVPOLL_SHIFT)
|
||||
# define ARP_POLL (1 << DEVPOLL_SHIFT)
|
||||
# define ICMP_POLL (2 << DEVPOLL_SHIFT)
|
||||
# define ICMPv6_POLL (3 << DEVPOLL_SHIFT)
|
||||
# define IPFWD_POLL (4 << DEVPOLL_SHIFT)
|
||||
|
||||
/* The set of events that and implications to the TCP connection state */
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
#include "tcp/tcp.h"
|
||||
#include "udp/udp.h"
|
||||
#include "pkt/pkt.h"
|
||||
#include "ieee802154/ieee802154.h"
|
||||
#include "icmp/icmp.h"
|
||||
#include "icmpv6/icmpv6.h"
|
||||
#include "igmp/igmp.h"
|
||||
@@ -237,6 +238,42 @@ static int devif_poll_pkt_connections(FAR struct net_driver_s *dev,
|
||||
}
|
||||
#endif /* CONFIG_NET_PKT */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: devif_poll_ieee802154_connections
|
||||
*
|
||||
* Description:
|
||||
* Poll all packet connections for available packets to send.
|
||||
*
|
||||
* Assumptions:
|
||||
* This function is called from the MAC device driver with the network
|
||||
* locked.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_IEEE802154
|
||||
static int devif_poll_ieee802154_connections(FAR struct net_driver_s *dev,
|
||||
devif_poll_callback_t callback)
|
||||
{
|
||||
FAR struct ieee802154_conn_s *ieee802154_conn = NULL;
|
||||
int bstop = 0;
|
||||
|
||||
/* Traverse all of the allocated packet connections and perform the poll action */
|
||||
|
||||
while (!bstop && (ieee802154_conn = ieee802154_nextconn(ieee802154_conn)))
|
||||
{
|
||||
/* Perform the packet TX poll */
|
||||
|
||||
ieee802154_poll(dev, ieee802154_conn);
|
||||
|
||||
/* Call back into the driver */
|
||||
|
||||
bstop = callback(dev);
|
||||
}
|
||||
|
||||
return bstop;
|
||||
}
|
||||
#endif /* CONFIG_NET_PKT */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: devif_poll_icmp
|
||||
*
|
||||
@@ -524,6 +561,15 @@ int devif_poll(FAR struct net_driver_s *dev, devif_poll_callback_t callback)
|
||||
|
||||
if (!bstop)
|
||||
#endif
|
||||
#ifdef CONFIG_NET_IEEE802154
|
||||
{
|
||||
/* Check for pending PF_IEEE802154 socket transfer */
|
||||
|
||||
bstop = devif_poll_ieee802154_connections(dev, callback);
|
||||
}
|
||||
|
||||
if (!bstop)
|
||||
#endif
|
||||
#ifdef CONFIG_NET_IGMP
|
||||
{
|
||||
/* Check for pending IGMP messages */
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
menu "IEEE 802.15.4 socket support"
|
||||
|
||||
config NET_IEEE802154
|
||||
bool "IEEE 802.15.4 socket support"
|
||||
default n
|
||||
depends on NET_IPv6 && WIRELESS_IEEE802154
|
||||
select NETDEV_IOCTL
|
||||
---help---
|
||||
Enable support for raw, IEEE 802.15.4 sockets.
|
||||
|
||||
Raw sockets allow receiving and transmitting IEEE 802.15.3 radio
|
||||
frames without a layer2 protocol such as 6LoWPAN in between. Frames
|
||||
received are copied into a IEEE 802.15.4 socket tap before they
|
||||
enter the network. Frames written into a IEEE 802.15.4 socket will
|
||||
bypass the network altogether and will be sent directly to the
|
||||
IEEE 802.15.4 MAC network interface driver outgoing frame queue.
|
||||
|
||||
if NET_IEEE802154
|
||||
|
||||
config NET_IEEE802154_NCONNS
|
||||
int "Max IEEE 802.15.4 sockets"
|
||||
default 1
|
||||
|
||||
endif # NET_IEEE802154
|
||||
endmenu # IEEE 802.15.4 Socket Support
|
||||
@@ -0,0 +1,59 @@
|
||||
############################################################################
|
||||
# net/ieee802154/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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
# Packet socket support
|
||||
|
||||
ifeq ($(CONFIG_NET_IEEE802154),y)
|
||||
|
||||
# Socket layer
|
||||
|
||||
SOCK_CSRCS += ieee802154_sockif.c
|
||||
SOCK_CSRCS += ieee802154_sendto.c
|
||||
SOCK_CSRCS += ieee802154_recvfrom.c
|
||||
|
||||
# Transport layer
|
||||
|
||||
NET_CSRCS += ieee802154_conn.c
|
||||
NET_CSRCS += ieee802154_input.c
|
||||
NET_CSRCS += ieee802154_callback.c
|
||||
NET_CSRCS += ieee802154_poll.c
|
||||
NET_CSRCS += ieee802154_finddev.c
|
||||
|
||||
# Include packet socket build support
|
||||
|
||||
DEPPATH += --dep-path ieee802154
|
||||
VPATH += :ieee802154
|
||||
|
||||
endif # CONFIG_NET_IEEE802154
|
||||
@@ -0,0 +1,346 @@
|
||||
/****************************************************************************
|
||||
* net/ieee802154/ieee802154.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 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 _NET_IEEE802154_IEEE802154_H
|
||||
#define _NET_IEEE802154_IEEE802154_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <queue.h>
|
||||
#include <netpacket/ieee802154.h>
|
||||
|
||||
#ifdef CONFIG_NET_IEEE802154
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Allocate a new IEEE 802.15.4 socket data callback */
|
||||
|
||||
#define ieee802154_callback_alloc(dev,conn) \
|
||||
devif_callback_alloc(dev, &conn->list)
|
||||
#define ieee802154_callback_free(dev,conn,cb) \
|
||||
devif_conn_callback_free(dev, cb, &conn->list)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Representation of a IEEE 802.15.4 socket connection */
|
||||
|
||||
struct devif_callback_s; /* Forward reference */
|
||||
|
||||
struct ieee802154_conn_s
|
||||
{
|
||||
dq_entry_t node; /* Supports a double linked list */
|
||||
struct ieee802154_saddr_s laddr; /* Locally bound address */
|
||||
struct ieee802154_saddr_s raddr; /* Connected remote address */
|
||||
uint8_t crefs; /* Reference counts on this instance */
|
||||
|
||||
/* Defines the list of IEEE 802.15.4 callbacks */
|
||||
|
||||
struct devif_callback_s *list;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
# define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
# define EXTERN extern
|
||||
#endif
|
||||
|
||||
/* The IEEE 802.15.4 socket interface */
|
||||
|
||||
EXTERN const struct sock_intf_s g_ieee802154_sockif;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
struct ieee802154_data_ind_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 */
|
||||
struct sockaddr; /* Forward reference */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ieee802154_initialize()
|
||||
*
|
||||
* Description:
|
||||
* Initialize the IEEE 802.15.4 socket connection structures. Called
|
||||
* once and only from the network initialization logic.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void ieee802154_initialize(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ieee802154_alloc()
|
||||
*
|
||||
* Description:
|
||||
* Allocate a new, uninitialized IEEE 802.15.4 socket connection
|
||||
* structure. This is normally something done by the implementation of
|
||||
* the socket() API
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct ieee802154_conn_s *ieee802154_alloc(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ieee802154_free()
|
||||
*
|
||||
* Description:
|
||||
* Free a IEEE 802.15.4 socket connection structure that is no longer in
|
||||
* use. This should be done by the implementation of close().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void ieee802154_free(FAR struct ieee802154_conn_s *conn);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ieee802154_active()
|
||||
*
|
||||
* Description:
|
||||
* Find a connection structure that is the appropriate
|
||||
* connection to be used with the provided Ethernet header
|
||||
*
|
||||
* Assumptions:
|
||||
* This function is called from network logic at with the network locked.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct ieee802154_conn_s *
|
||||
ieee802154_active(FAR const struct ieee802154_data_ind_s *meta);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ieee802154_nextconn()
|
||||
*
|
||||
* Description:
|
||||
* Traverse the list of allocated IEEE 802.15.4 connections
|
||||
*
|
||||
* Assumptions:
|
||||
* This function is called from network logic at with the network locked.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct ieee802154_conn_s *
|
||||
ieee802154_nextconn(FAR struct ieee802154_conn_s *conn);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ieee802154_input
|
||||
*
|
||||
* Description:
|
||||
* Handle incoming IEEE 802.15.4 input
|
||||
*
|
||||
* 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 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.
|
||||
*
|
||||
* - The io_flink field points to the next frame in the list (if enable)
|
||||
* - The last frame in the list will have io_flink == NULL.
|
||||
*
|
||||
* Parameters:
|
||||
* 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.
|
||||
* meta - Meta data characterizing the received frame.
|
||||
*
|
||||
* If there are multilple frames in the list, this metadata
|
||||
* must apply to all of the frames in the list.
|
||||
*
|
||||
* Return:
|
||||
* OK The IEEE 802.15.4 has been processed and can be deleted
|
||||
* ERROR Hold the IEEE 802.15.4 and try again later. There is a listening
|
||||
* socket but no recv in place to catch the IEEE 802.15.4 yet.
|
||||
* Useful when a packet arrives before a recv call is in place.
|
||||
*
|
||||
* Assumptions:
|
||||
* Called from the network diver with the network locked.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/* ieee802154_input() is prototyped in include/nuttx/net/ieee802154.h */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ieee802154_callback
|
||||
*
|
||||
* Description:
|
||||
* Inform the application holding the IEEE 802.15.4 socket of a change in state.
|
||||
*
|
||||
* Returned Value:
|
||||
* OK if IEEE 802.15.4 has been processed, otherwise ERROR.
|
||||
*
|
||||
* Assumptions:
|
||||
* This function is called from network logic at with the network locked.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
uint16_t ieee802154_callback(FAR struct radio_driver_s *radio,
|
||||
FAR struct ieee802154_conn_s *conn,
|
||||
uint16_t flags);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ieee802154_recvfrom
|
||||
*
|
||||
* Description:
|
||||
* Implements the socket recvfrom interface for the case of the AF_INET
|
||||
* and AF_INET6 address families. ieee802154_recvfrom() receives messages from
|
||||
* a socket, and may be used to receive data on a socket whether or not it
|
||||
* is connection-oriented.
|
||||
*
|
||||
* If 'from' is not NULL, and the underlying protocol provides the source
|
||||
* address, this source address is filled in. The argument 'fromlen' is
|
||||
* initialized to the size of the buffer associated with from, and
|
||||
* modified on return to indicate the actual size of the address stored
|
||||
* there.
|
||||
*
|
||||
* Parameters:
|
||||
* psock A pointer to a NuttX-specific, internal socket structure
|
||||
* buf Buffer to receive data
|
||||
* len Length of buffer
|
||||
* flags Receive flags
|
||||
* from Address of source (may be NULL)
|
||||
* fromlen The length of the address structure
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, returns the number of characters received. If no data is
|
||||
* available to be received and the peer has performed an orderly shutdown,
|
||||
* recv() will return 0. Otherwise, on errors, a negated errno value is
|
||||
* returned (see recvfrom() for the list of appropriate error values).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t ieee802154_recvfrom(FAR struct socket *psock, FAR void *buf,
|
||||
size_t len, int flags, FAR struct sockaddr *from,
|
||||
FAR socklen_t *fromlen);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ieee802154_find_device
|
||||
*
|
||||
* Description:
|
||||
* Select the network driver to use with the IEEE802154 transaction.
|
||||
*
|
||||
* Input Parameters:
|
||||
* conn - IEEE802154 connection structure (not currently used).
|
||||
* addr - The address to match the devices assigned address
|
||||
*
|
||||
* Returned Value:
|
||||
* A pointer to the network driver to use. NULL is returned on any
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct radio_driver_s *
|
||||
ieee802154_find_device(FAR struct ieee802154_conn_s *conn,
|
||||
FAR const struct ieee802154_saddr_s *addr);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ieee802154_poll
|
||||
*
|
||||
* Description:
|
||||
* Poll a IEEE 802.15.4 "connection" structure for availability of TX data
|
||||
*
|
||||
* Parameters:
|
||||
* dev - The device driver structure to use in the send operation
|
||||
* conn - The IEEE 802.15.4 "connection" to poll for TX data
|
||||
*
|
||||
* Return:
|
||||
* None
|
||||
*
|
||||
* Assumptions:
|
||||
* Called from the network device interface (devif) with the network
|
||||
* locked.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void ieee802154_poll(FAR struct net_driver_s *dev,
|
||||
FAR struct ieee802154_conn_s *conn);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: psock_ieee802154_sendto
|
||||
*
|
||||
* Description:
|
||||
* If sendto() is used on a connection-mode (SOCK_STREAM, SOCK_SEQPACKET)
|
||||
* socket, the parameters to and 'tolen' are ignored (and the error EISCONN
|
||||
* may be returned when they are not NULL and 0), and the error ENOTCONN is
|
||||
* returned when the socket was not actually connected.
|
||||
*
|
||||
* Parameters:
|
||||
* psock A pointer to a NuttX-specific, internal socket structure
|
||||
* buf Data to send
|
||||
* len Length of data to send
|
||||
* flags Send flags
|
||||
* to Address of recipient
|
||||
* tolen The length of the address structure
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, returns the number of characters sent. On error,
|
||||
* -1 is returned, and errno is set appropriately. See sendto()
|
||||
* for the complete list of return values.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t psock_ieee802154_sendto(FAR struct socket *psock,
|
||||
FAR const void *buf,
|
||||
size_t len, int flags,
|
||||
FAR const struct sockaddr *to, socklen_t tolen);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_NET_IEEE802154 */
|
||||
#endif /* _NET_IEEE802154_IEEE802154_H */
|
||||
@@ -0,0 +1,88 @@
|
||||
/****************************************************************************
|
||||
* net/ieee802154/ieee802154_callback.c
|
||||
* Forward events to waiting PF_IEEE802154 sockets.
|
||||
*
|
||||
* 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. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 <debug.h>
|
||||
|
||||
#include <nuttx/mm/iob.h>
|
||||
#include <nuttx/net/sixlowpan.h>
|
||||
#include <nuttx/net/ieee802154.h>
|
||||
|
||||
#include "devif/devif.h"
|
||||
#include "ieee802154/ieee802154.h"
|
||||
|
||||
#ifdef CONFIG_NET_IEEE802154
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ieee802154_callback
|
||||
*
|
||||
* Description:
|
||||
* Inform the application holding the packet socket of a change in state.
|
||||
*
|
||||
* Returned Value:
|
||||
* OK if packet has been processed, otherwise ERROR.
|
||||
*
|
||||
* Assumptions:
|
||||
* This function is called at the interrupt level with interrupts disabled.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
uint16_t ieee802154_callback(FAR struct radio_driver_s *radio,
|
||||
FAR struct ieee802154_conn_s *conn,
|
||||
uint16_t flags)
|
||||
{
|
||||
ninfo("flags: %04x\n", flags);
|
||||
|
||||
/* Some sanity checking */
|
||||
|
||||
if (conn != NULL)
|
||||
{
|
||||
/* Perform the callback */
|
||||
|
||||
flags = devif_conn_event(&radio->r_dev, conn, flags, conn->list);
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET_IEEE802154 */
|
||||
@@ -0,0 +1,298 @@
|
||||
/****************************************************************************
|
||||
* net/ieee802154/ieee802154_conn.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. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 <semaphore.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <arch/irq.h>
|
||||
|
||||
#include <nuttx/net/netconfig.h>
|
||||
#include <nuttx/net/net.h>
|
||||
#include <nuttx/net/netdev.h>
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
#include "devif/devif.h"
|
||||
#include "ieee802154/ieee802154.h"
|
||||
|
||||
#ifdef CONFIG_NET_IEEE802154
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/* The array containing all packet socket connections */
|
||||
|
||||
static struct ieee802154_conn_s
|
||||
g_ieee802154_connections[CONFIG_NET_IEEE802154_NCONNS];
|
||||
|
||||
/* A list of all free packet socket connections */
|
||||
|
||||
static dq_queue_t g_free_ieee802154_connections;
|
||||
static sem_t g_free_sem;
|
||||
|
||||
/* A list of all allocated packet socket connections */
|
||||
|
||||
static dq_queue_t g_active_ieee802154_connections;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: _ieee802154_semtake() and _ieee802154_semgive()
|
||||
*
|
||||
* Description:
|
||||
* Take/give semaphore
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline void _ieee802154_semtake(sem_t *sem)
|
||||
{
|
||||
/* Take the semaphore (perhaps waiting) */
|
||||
|
||||
while (net_lockedwait(sem) != 0)
|
||||
{
|
||||
/* The only case that an error should occur here is if
|
||||
* the wait was awakened by a signal.
|
||||
*/
|
||||
|
||||
DEBUGASSERT(get_errno() == EINTR);
|
||||
}
|
||||
}
|
||||
|
||||
#define _ieee802154_semgive(sem) sem_post(sem)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ieee802154_initialize()
|
||||
*
|
||||
* Description:
|
||||
* Initialize the packet socket connection structures. Called once and
|
||||
* only from the network logic early in initialization.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void ieee802154_initialize(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Initialize the queues */
|
||||
|
||||
dq_init(&g_free_ieee802154_connections);
|
||||
dq_init(&g_active_ieee802154_connections);
|
||||
sem_init(&g_free_sem, 0, 1);
|
||||
|
||||
for (i = 0; i < CONFIG_NET_IEEE802154_NCONNS; i++)
|
||||
{
|
||||
/* Link each pre-allocated connection structure into the free list. */
|
||||
|
||||
dq_addlast(&g_ieee802154_connections[i].node,
|
||||
&g_free_ieee802154_connections);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ieee802154_alloc()
|
||||
*
|
||||
* Description:
|
||||
* Allocate a new, uninitialized packet socket connection structure. This
|
||||
* is normally something done by the implementation of the socket() API
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct ieee802154_conn_s *ieee802154_alloc(void)
|
||||
{
|
||||
FAR struct ieee802154_conn_s *conn;
|
||||
|
||||
/* The free list is only accessed from user, non-interrupt level and
|
||||
* is protected by a semaphore (that behaves like a mutex).
|
||||
*/
|
||||
|
||||
_ieee802154_semtake(&g_free_sem);
|
||||
conn = (FAR struct ieee802154_conn_s *)
|
||||
dq_remfirst(&g_free_ieee802154_connections);
|
||||
|
||||
if (conn)
|
||||
{
|
||||
/* Enqueue the connection into the active list */
|
||||
|
||||
dq_addlast(&conn->node, &g_active_ieee802154_connections);
|
||||
}
|
||||
|
||||
_ieee802154_semgive(&g_free_sem);
|
||||
return conn;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ieee802154_free()
|
||||
*
|
||||
* Description:
|
||||
* Free a packet socket connection structure that is no longer in use.
|
||||
* This should be done by the implementation of close().
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void ieee802154_free(FAR struct ieee802154_conn_s *conn)
|
||||
{
|
||||
/* The free list is only accessed from user, non-interrupt level and
|
||||
* is protected by a semaphore (that behaves like a mutex).
|
||||
*/
|
||||
|
||||
DEBUGASSERT(conn->crefs == 0);
|
||||
|
||||
_ieee802154_semtake(&g_free_sem);
|
||||
|
||||
/* Remove the connection from the active list */
|
||||
|
||||
dq_rem(&conn->node, &g_active_ieee802154_connections);
|
||||
|
||||
/* Free the connection */
|
||||
|
||||
dq_addlast(&conn->node, &g_free_ieee802154_connections);
|
||||
_ieee802154_semgive(&g_free_sem);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ieee802154_active()
|
||||
*
|
||||
* Description:
|
||||
* Find a connection structure that is the appropriate
|
||||
* connection to be used with the provided IEEE 802.15.4 header
|
||||
*
|
||||
* Assumptions:
|
||||
* This function is called from network logic at with the network locked.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct ieee802154_conn_s *
|
||||
ieee802154_active(FAR const struct ieee802154_data_ind_s *meta)
|
||||
{
|
||||
FAR struct ieee802154_conn_s *conn;
|
||||
|
||||
DEBUGASSERT(meta != NULL);
|
||||
|
||||
for (conn = (FAR struct ieee802154_conn_s *)g_active_ieee802154_connections.head;
|
||||
conn != NULL;
|
||||
conn = (FAR struct ieee802154_conn_s *)conn->node.flink)
|
||||
{
|
||||
/* Does the destination address match the bound address of the socket. */
|
||||
/* REVISIT: Currently and explict address must be assigned. Should we
|
||||
* support some moral equivalent to INADDR_ANY?
|
||||
*/
|
||||
|
||||
if (meta->dest.mode != conn->laddr.s_mode)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (meta->dest.mode == IEEE802154_ADDRMODE_SHORT &&
|
||||
!IEEE802154_SADDRCMP(meta->dest.saddr, conn->laddr.s_saddr))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (meta->dest.mode == IEEE802154_ADDRMODE_EXTENDED &&
|
||||
!IEEE802154_EADDRCMP(meta->dest.saddr, conn->laddr.s_eaddr))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Is the socket "connected?" to a remote peer? If so, check if the
|
||||
* source address matches the connected remote adress.
|
||||
*/
|
||||
|
||||
switch (conn->raddr.s_mode)
|
||||
{
|
||||
case IEEE802154_ADDRMODE_NONE:
|
||||
return conn; /* No.. accept the connection */
|
||||
|
||||
case IEEE802154_ADDRMODE_SHORT:
|
||||
if (IEEE802154_SADDRCMP(meta->dest.saddr, conn->raddr.s_saddr))
|
||||
{
|
||||
return conn;
|
||||
}
|
||||
break;
|
||||
|
||||
case IEEE802154_ADDRMODE_EXTENDED:
|
||||
if (IEEE802154_EADDRCMP(meta->dest.eaddr, conn->raddr.s_eaddr))
|
||||
{
|
||||
return conn;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
nerr("ERROR: Invalid address mode: %u\n", conn->raddr.s_mode);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return conn;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ieee802154_nextconn()
|
||||
*
|
||||
* Description:
|
||||
* Traverse the list of allocated packet connections
|
||||
*
|
||||
* Assumptions:
|
||||
* This function is called from network logic at with the network locked.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct ieee802154_conn_s *
|
||||
ieee802154_nextconn(FAR struct ieee802154_conn_s *conn)
|
||||
{
|
||||
if (!conn)
|
||||
{
|
||||
return (FAR struct ieee802154_conn_s *)
|
||||
g_active_ieee802154_connections.head;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (FAR struct ieee802154_conn_s *)conn->node.flink;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET_IEEE802154 */
|
||||
@@ -0,0 +1,190 @@
|
||||
/****************************************************************************
|
||||
* net/ieee802154/ieee802154_finddev.c
|
||||
*
|
||||
* Copyright (C) 2015 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 <assert.h>
|
||||
|
||||
#include <nuttx/net/net.h>
|
||||
#include <nuttx/net/sixlowpan.h>
|
||||
#include <nuttx/net/ieee802154.h>
|
||||
|
||||
#include "netdev/netdev.h"
|
||||
#include "ieee802154/ieee802154.h"
|
||||
|
||||
#ifdef CONFIG_NET_IEEE802154
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
struct ieee802154_finddev_s
|
||||
{
|
||||
FAR const struct ieee802154_saddr_s *addr;
|
||||
FAR struct radio_driver_s *radio;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ieee8021545_dev_callback
|
||||
*
|
||||
* Description:
|
||||
* Check if this device matches the connections local address.
|
||||
*
|
||||
* Input Parameters:
|
||||
* dev - The next network device in the enumeration
|
||||
*
|
||||
* Returned Value:
|
||||
* 0 if there is no match (meaning to continue looking); 1 if there is a
|
||||
* match (meaning to stop the search).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int ieee8021545_dev_callback(FAR struct net_driver_s *dev, FAR void *arg)
|
||||
{
|
||||
FAR struct ieee802154_finddev_s *match =
|
||||
(FAR struct ieee802154_finddev_s *)arg;
|
||||
|
||||
DEBUGASSERT(dev != NULL && match != NULL && match->addr != NULL);
|
||||
|
||||
/* First, check if this network device is an IEEE 802.15.4 radio and that
|
||||
* it has an assigned IEEE 802.15.4 address.
|
||||
*/
|
||||
|
||||
if (dev->d_lltype == NET_LL_IEEE802154 && dev->d_mac.radio.nv_addrlen > 0)
|
||||
{
|
||||
DEBUGASSERT(dev->d_mac.radio.nv_addrlen == 2 ||
|
||||
dev->d_mac.radio.nv_addrlen == 8);
|
||||
|
||||
/* Does the address mode match? */
|
||||
|
||||
if (match->addr->s_mode == IEEE802154_ADDRMODE_SHORT &&
|
||||
dev->d_mac.radio.nv_addrlen == 2)
|
||||
{
|
||||
/* Does the device address match */
|
||||
|
||||
if (IEEE802154_SADDRCMP(dev->d_mac.radio.nv_addr,
|
||||
match->addr->s_saddr))
|
||||
{
|
||||
/* Yes.. save the match and return 1 to stop the search */
|
||||
|
||||
match->radio = (FAR struct radio_driver_s *)dev;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (match->addr->s_mode == IEEE802154_ADDRMODE_EXTENDED &&
|
||||
dev->d_mac.radio.nv_addrlen == 8)
|
||||
{
|
||||
/* Does the device address match */
|
||||
|
||||
if (IEEE802154_EADDRCMP(dev->d_mac.radio.nv_addr,
|
||||
match->addr->s_eaddr))
|
||||
{
|
||||
/* Yes.. save the match and return 1 to stop the search */
|
||||
|
||||
match->radio = (FAR struct radio_driver_s *)dev;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Keep looking */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ieee802154_find_device
|
||||
*
|
||||
* Description:
|
||||
* Select the network driver to use with the IEEE802154 transaction.
|
||||
*
|
||||
* Input Parameters:
|
||||
* conn - IEEE802154 connection structure (not currently used).
|
||||
* addr - The address to match the devices assigned address
|
||||
*
|
||||
* Returned Value:
|
||||
* A pointer to the network driver to use. NULL is returned on any
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct radio_driver_s *
|
||||
ieee802154_find_device(FAR struct ieee802154_conn_s *conn,
|
||||
FAR const struct ieee802154_saddr_s *addr)
|
||||
{
|
||||
struct ieee802154_finddev_s match;
|
||||
int ret;
|
||||
|
||||
DEBUGASSERT(conn != NULL);
|
||||
match.addr = addr;
|
||||
match.radio = NULL;
|
||||
|
||||
/* If the socket is not bound to a local address, then return a failure */
|
||||
|
||||
if (addr->s_mode == IEEE802154_ADDRMODE_NONE)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DEBUGASSERT(addr->s_mode == IEEE802154_ADDRMODE_SHORT ||
|
||||
addr->s_mode == IEEE802154_ADDRMODE_EXTENDED);
|
||||
|
||||
/* Other, search for the IEEE 802.15.4 network device whose MAC is equal to
|
||||
* the sockets bount local address.
|
||||
*/
|
||||
|
||||
ret = netdev_foreach(ieee8021545_dev_callback, (FAR void *)&match);
|
||||
if (ret == 1)
|
||||
{
|
||||
DEBUGASSERT(match.radio != NULL);
|
||||
return match.radio;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET_IEEE802154 */
|
||||
@@ -0,0 +1,150 @@
|
||||
/****************************************************************************
|
||||
* net/ieee802154/ieee802154_input.c
|
||||
* Handle incoming IEEE 802.15.4 frame input
|
||||
*
|
||||
* 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. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 <debug.h>
|
||||
|
||||
#include <nuttx/mm/iob.h>
|
||||
#include <nuttx/net/sixlowpan.h>
|
||||
#include <nuttx/net/ieee802154.h>
|
||||
|
||||
#include "devif/devif.h"
|
||||
#include "ieee802154/ieee802154.h"
|
||||
|
||||
#ifdef CONFIG_NET_IEEE802154
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ieee802154_input
|
||||
*
|
||||
* Description:
|
||||
* Handle incoming IEEE 802.15.4 input
|
||||
*
|
||||
* 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 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.
|
||||
*
|
||||
* - The io_flink field points to the next frame in the list (if enable)
|
||||
* - The last frame in the list will have io_flink == NULL.
|
||||
*
|
||||
* Parameters:
|
||||
* 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.
|
||||
* meta - Meta data characterizing the received frane.
|
||||
*
|
||||
* If there are multilple frames in the list, this metadata
|
||||
* must apply to all of the frames in the list.
|
||||
*
|
||||
* Return:
|
||||
* OK The IEEE 802.15.4 has been processed and can be deleted
|
||||
* ERROR Hold the IEEE 802.15.4 and try again later. There is a listening
|
||||
* socket but no recv in place to catch the IEEE 802.15.4 yet.
|
||||
* Useful when a packet arrives before a recv call is in place.
|
||||
*
|
||||
* Assumptions:
|
||||
* Called from the network diver with the network locked.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ieee802154_input(FAR struct radio_driver_s *radio,
|
||||
FAR struct iob_s *framelist,
|
||||
FAR const struct ieee802154_data_ind_s *meta)
|
||||
{
|
||||
FAR struct ieee802154_conn_s *conn;
|
||||
int ret = OK;
|
||||
|
||||
/* Check if there is a connection that will accept this packet */
|
||||
|
||||
conn = ieee802154_active(meta);
|
||||
if (conn)
|
||||
{
|
||||
uint16_t flags;
|
||||
|
||||
/* Setup for the application callback (NOTE: These should not be
|
||||
* used by PF_IEEE802154 sockets).
|
||||
*/
|
||||
|
||||
radio->r_dev.d_appdata = radio->r_dev.d_buf;
|
||||
radio->r_dev.d_len = 0;
|
||||
radio->r_dev.d_sndlen = 0;
|
||||
|
||||
/* Perform the application callback */
|
||||
/* REVISIT: Need to pass the meta data and the IOB through the callback */
|
||||
#warning Missing logic
|
||||
|
||||
flags = ieee802154_callback(radio, conn, IEEE802154_NEWDATA);
|
||||
|
||||
/* If the operation was successful, the PKT_NEWDATA flag is removed
|
||||
* and thus the packet can be deleted (OK will be returned).
|
||||
*/
|
||||
|
||||
if ((flags & PKT_NEWDATA) != 0)
|
||||
{
|
||||
/* No.. the packet was not processed now. Return ERROR so
|
||||
* that the driver may retry again later. We still need to
|
||||
* set d_len to zero so that the driver is aware that there
|
||||
* is nothing to be sent.
|
||||
*/
|
||||
|
||||
nwarn("WARNING: Packet not processed\n");
|
||||
ret = ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nerr("ERROR: No listener\n");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET_IEEE802154 */
|
||||
@@ -0,0 +1,105 @@
|
||||
/****************************************************************************
|
||||
* net/ieee802154/ieee802154_poll.c
|
||||
* Poll for the availability of ougoing IEEE 802.15.4 frames
|
||||
*
|
||||
* 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. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/net/netconfig.h>
|
||||
#include <nuttx/net/sixlowpan.h>
|
||||
#include <nuttx/net/ieee802154.h>
|
||||
|
||||
#include "devif/devif.h"
|
||||
#include "ieee802154/ieee802154.h"
|
||||
|
||||
#ifdef CONFIG_NET_IEEE802154
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ieee802154_poll
|
||||
*
|
||||
* Description:
|
||||
* Poll a packet "connection" structure for availability of TX data
|
||||
*
|
||||
* Parameters:
|
||||
* dev - The device driver structure to use in the send operation
|
||||
* conn - The packet "connection" to poll for TX data
|
||||
*
|
||||
* Return:
|
||||
* None
|
||||
*
|
||||
* Assumptions:
|
||||
* Called from the interrupt level or with interrupts disabled.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void ieee802154_poll(FAR struct net_driver_s *dev,
|
||||
FAR struct ieee802154_conn_s *conn)
|
||||
{
|
||||
FAR struct radio_driver_s *radio;
|
||||
|
||||
DEBUGASSERT(dev != NULL && conn != NULL);
|
||||
radio = (FAR struct radio_driver_s *)dev;
|
||||
|
||||
/* Verify that the packet connection is valid */
|
||||
|
||||
if (conn != NULL)
|
||||
{
|
||||
/* Setup for the application callback (NOTE: These should not be
|
||||
* used by PF_IEEE802154 sockets).
|
||||
*/
|
||||
|
||||
radio->r_dev.d_appdata = radio->r_dev.d_buf;
|
||||
radio->r_dev.d_len = 0;
|
||||
radio->r_dev.d_sndlen = 0;
|
||||
|
||||
/* Perform the application callback */
|
||||
/* REVISIT: Need to pass the meta data and the IOB through the callback */
|
||||
#warning Missing logic
|
||||
|
||||
/* Perform the application callback */
|
||||
|
||||
(void)ieee802154_callback(radio, conn, IEEE802154_POLL);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET && CONFIG_NET_PKT */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,318 @@
|
||||
/****************************************************************************
|
||||
* net/ieee802154/ieee802154_sendto.c
|
||||
*
|
||||
* Copyright (C) 2014, 2016 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2014, 2016 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 <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <arch/irq.h>
|
||||
|
||||
#include <nuttx/clock.h>
|
||||
#include <nuttx/semaphore.h>
|
||||
#include <nuttx/net/sixlowpan.h>
|
||||
#include <nuttx/net/net.h>
|
||||
#include <nuttx/net/ip.h>
|
||||
|
||||
#include "netdev/netdev.h"
|
||||
#include "devif/devif.h"
|
||||
#include "socket/socket.h"
|
||||
#include "ieee802154/ieee802154.h"
|
||||
|
||||
#ifdef CONFIG_NET_IEEE802154
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/* This structure holds the state of the send operation until it can be
|
||||
* operated upon from the interrupt level.
|
||||
*/
|
||||
|
||||
struct send_s
|
||||
{
|
||||
FAR struct socket *snd_sock; /* Points to the parent socket structure */
|
||||
FAR struct devif_callback_s *snd_cb; /* Reference to callback instance */
|
||||
sem_t snd_sem; /* Used to wake up the waiting thread */
|
||||
FAR const uint8_t *snd_buffer; /* Points to the buffer of data to send */
|
||||
size_t snd_buflen; /* Number of bytes in the buffer to send */
|
||||
ssize_t snd_sent; /* The number of bytes sent */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: psock_send_interrupt
|
||||
****************************************************************************/
|
||||
|
||||
static uint16_t psock_send_interrupt(FAR struct net_driver_s *dev,
|
||||
FAR void *pvconn,
|
||||
FAR void *pvpriv, uint16_t flags)
|
||||
{
|
||||
FAR struct send_s *pstate;
|
||||
FAR struct radio_driver_s *radio;
|
||||
|
||||
DEBUGASSERT(pvpriv != NULL && dev != NULL && pvconn != NULL);
|
||||
|
||||
/* Ignore polls from non IEEE 802.15.4 network drivers */
|
||||
|
||||
if (dev->d_lltype != NET_LL_IEEE802154)
|
||||
{
|
||||
return flags;
|
||||
}
|
||||
|
||||
/* Make sure that this is the driver to which the socket is connected. */
|
||||
#warning Missing logic
|
||||
|
||||
pstate = (FAR struct send_s *)pvpriv;
|
||||
radio = (FAR struct radio_driver_s *)dev;
|
||||
|
||||
ninfo("flags: %04x sent: %d\n", flags, pstate->snd_sent);
|
||||
|
||||
if (pstate)
|
||||
{
|
||||
/* Check if the outgoing packet is available. It may have been claimed
|
||||
* by a send interrupt serving a different thread -OR- if the output
|
||||
* buffer currently contains unprocessed incoming data. In these cases
|
||||
* we will just have to wait for the next polling cycle.
|
||||
*/
|
||||
|
||||
if (radio->r_dev.d_sndlen > 0 || (flags & PKT_NEWDATA) != 0)
|
||||
{
|
||||
/* Another thread has beat us sending data or the buffer is busy,
|
||||
* Check for a timeout. If not timed out, wait for the next
|
||||
* polling cycle and check again.
|
||||
*/
|
||||
|
||||
/* No timeout. Just wait for the next polling cycle */
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
/* It looks like we are good to send the data */
|
||||
|
||||
else
|
||||
{
|
||||
/* Copy the packet data into the device packet buffer and send it */
|
||||
#warning Missing logic
|
||||
//devif_ieee802154_send(radio, pstate->snd_buffer, pstate->snd_buflen);
|
||||
pstate->snd_sent = pstate->snd_buflen;
|
||||
|
||||
/* Make sure no ARP request overwrites this ARP request. This
|
||||
* flag will be cleared in arp_out().
|
||||
*/
|
||||
|
||||
IFF_SET_NOARP(radio->r_dev.d_flags);
|
||||
}
|
||||
|
||||
/* Don't allow any further call backs. */
|
||||
|
||||
pstate->snd_cb->flags = 0;
|
||||
pstate->snd_cb->priv = NULL;
|
||||
pstate->snd_cb->event = NULL;
|
||||
|
||||
/* Wake up the waiting thread */
|
||||
|
||||
sem_post(&pstate->snd_sem);
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: psock_ieee802154_sendto
|
||||
*
|
||||
* Description:
|
||||
* If sendto() is used on a connection-mode (SOCK_STREAM, SOCK_SEQPACKET)
|
||||
* socket, the parameters to and 'tolen' are ignored (and the error EISCONN
|
||||
* may be returned when they are not NULL and 0), and the error ENOTCONN is
|
||||
* returned when the socket was not actually connected.
|
||||
*
|
||||
* Parameters:
|
||||
* psock A pointer to a NuttX-specific, internal socket structure
|
||||
* buf Data to send
|
||||
* len Length of data to send
|
||||
* flags Send flags
|
||||
* to Address of recipient
|
||||
* tolen The length of the address structure
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, returns the number of characters sent. On error,
|
||||
* -1 is returned, and errno is set appropriately. See sendto()
|
||||
* for the complete list of return values.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t psock_ieee802154_sendto(FAR struct socket *psock, FAR const void *buf,
|
||||
size_t len, int flags,
|
||||
FAR const struct sockaddr *to, socklen_t tolen)
|
||||
{
|
||||
FAR struct radio_driver_s *radio;
|
||||
FAR struct ieee802154_conn_s *conn;
|
||||
struct send_s state;
|
||||
int errcode;
|
||||
int ret = OK;
|
||||
|
||||
/* Verify that the sockfd corresponds to valid, allocated socket */
|
||||
|
||||
if (psock == NULL || psock->s_crefs <= 0)
|
||||
{
|
||||
errcode = EBADF;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
conn = (FAR struct ieee802154_conn_s *)psock->s_conn;
|
||||
DEBUGASSERT(conn != NULL);
|
||||
|
||||
/* Get the device driver that will service this transfer */
|
||||
|
||||
radio = ieee802154_find_device(conn, &conn->laddr);
|
||||
if (radio == NULL)
|
||||
{
|
||||
errcode = ENODEV;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Set the socket state to sending */
|
||||
|
||||
psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_SEND);
|
||||
|
||||
/* Perform the send operation */
|
||||
|
||||
/* Initialize the state structure. This is done with interrupts
|
||||
* disabled because we don't want anything to happen until we
|
||||
* are ready.
|
||||
*/
|
||||
|
||||
net_lock();
|
||||
memset(&state, 0, sizeof(struct send_s));
|
||||
|
||||
/* This semaphore is used for signaling and, hence, should not have
|
||||
* priority inheritance enabled.
|
||||
*/
|
||||
|
||||
(void)sem_init(&state.snd_sem, 0, 0); /* Doesn't really fail */
|
||||
(void)sem_setprotocol(&state.snd_sem, SEM_PRIO_NONE);
|
||||
|
||||
state.snd_sock = psock; /* Socket descriptor to use */
|
||||
state.snd_buflen = len; /* Number of bytes to send */
|
||||
state.snd_buffer = buf; /* Buffer to send from */
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
/* Allocate resource to receive a callback */
|
||||
|
||||
state.snd_cb = ieee802154_callback_alloc(&radio->r_dev, conn);
|
||||
if (state.snd_cb)
|
||||
{
|
||||
/* Set up the callback in the connection */
|
||||
|
||||
state.snd_cb->flags = PKT_POLL;
|
||||
state.snd_cb->priv = (FAR void *)&state;
|
||||
state.snd_cb->event = psock_send_interrupt;
|
||||
|
||||
/* Notify the device driver that new TX data is available. */
|
||||
|
||||
netdev_txnotify_dev(&radio->r_dev);
|
||||
|
||||
/* Wait for the send to complete or an error to occur: NOTES: (1)
|
||||
* net_lockedwait will also terminate if a signal is received, (2)
|
||||
* interrupts may be disabled! They will be re-enabled while the
|
||||
* task sleeps and automatically re-enabled when the task restarts.
|
||||
*/
|
||||
|
||||
ret = net_lockedwait(&state.snd_sem);
|
||||
|
||||
/* Make sure that no further interrupts are processed */
|
||||
|
||||
ieee802154_callback_free(&radio->r_dev, conn, state.snd_cb);
|
||||
}
|
||||
}
|
||||
|
||||
sem_destroy(&state.snd_sem);
|
||||
net_unlock();
|
||||
|
||||
/* Set the socket state to idle */
|
||||
|
||||
psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_IDLE);
|
||||
|
||||
/* Check for a errors, Errors are signalled by negative errno values
|
||||
* for the send length
|
||||
*/
|
||||
|
||||
if (state.snd_sent < 0)
|
||||
{
|
||||
errcode = state.snd_sent;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* If net_lockedwait failed, then we were probably reawakened by a signal. In
|
||||
* this case, net_lockedwait will have set errno appropriately.
|
||||
*/
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
errcode = -ret;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Return the number of bytes actually sent */
|
||||
|
||||
return state.snd_sent;
|
||||
|
||||
errout:
|
||||
set_errno(errcode);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET_IEEE802154 */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -54,6 +54,7 @@
|
||||
#include "tcp/tcp.h"
|
||||
#include "udp/udp.h"
|
||||
#include "pkt/pkt.h"
|
||||
#include "ieee802154/ieee802154.h"
|
||||
#include "local/local.h"
|
||||
#include "igmp/igmp.h"
|
||||
#include "route/route.h"
|
||||
@@ -125,6 +126,12 @@ void net_setup(void)
|
||||
pkt_initialize();
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_IEEE802154
|
||||
/* Initialize IEEE 802.15.4 socket support */
|
||||
|
||||
ieee802154_initialize();
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_LOCAL
|
||||
/* Initialize the local, "Unix domain" socket support */
|
||||
|
||||
|
||||
@@ -833,8 +833,8 @@ static int netdev_ifr_ioctl(FAR struct socket *psock, int cmd,
|
||||
{
|
||||
req->ifr_hwaddr.sa_family = AF_INETX;
|
||||
memcpy(req->ifr_hwaddr.sa_data,
|
||||
dev->d_mac.sixlowpan.nv_addr,
|
||||
dev->d_mac.sixlowpan.nv_addrlen);
|
||||
dev->d_mac.radio.nv_addr,
|
||||
dev->d_mac.radio.nv_addrlen);
|
||||
ret = OK;
|
||||
}
|
||||
else
|
||||
@@ -865,19 +865,19 @@ static int netdev_ifr_ioctl(FAR struct socket *psock, int cmd,
|
||||
if (dev->d_lltype == NET_LL_IEEE802154 ||
|
||||
dev->d_lltype == NET_LL_PKTRADIO)
|
||||
{
|
||||
FAR struct sixlowpan_driver_s *radio;
|
||||
FAR struct radio_driver_s *radio;
|
||||
struct sixlowpan_properties_s properties;
|
||||
|
||||
/* Get the radio properties */
|
||||
|
||||
radio = (FAR struct sixlowpan_driver_s *)dev;
|
||||
radio = (FAR struct radio_driver_s *)dev;
|
||||
DEBUGASSERT(radio->r_properties != NULL);
|
||||
|
||||
ret = radio->r_properties(radio, &properties);
|
||||
if (ret >= 0)
|
||||
{
|
||||
dev->d_mac.sixlowpan.nv_addrlen = properties.sp_addrlen;
|
||||
memcpy(dev->d_mac.sixlowpan.nv_addr,
|
||||
dev->d_mac.radio.nv_addrlen = properties.sp_addrlen;
|
||||
memcpy(dev->d_mac.radio.nv_addr,
|
||||
req->ifr_hwaddr.sa_data, NET_6LOWPAN_ADDRSIZE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
#if defined(CONFIG_NET_6LOWPAN) && defined(CONFIG_WIRELESS_PKTRADIO)
|
||||
static inline int netdev_pktradio_addrlen(FAR struct net_driver_s *dev)
|
||||
{
|
||||
FAR struct sixlowpan_driver_s *radio = (FAR struct sixlowpan_driver_s *)dev;
|
||||
FAR struct radio_driver_s *radio = (FAR struct radio_driver_s *)dev;
|
||||
struct sixlowpan_properties_s properties;
|
||||
int ret;
|
||||
|
||||
|
||||
@@ -78,8 +78,6 @@
|
||||
|
||||
void pkt_poll(FAR struct net_driver_s *dev, FAR struct pkt_conn_s *conn)
|
||||
{
|
||||
ninfo("IN\n");
|
||||
|
||||
/* Verify that the packet connection is valid */
|
||||
|
||||
if (conn)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* net/socket/pkt_recvfrom.c
|
||||
* net/pkt/pkt_recvfrom.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2011-2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
|
||||
@@ -120,7 +120,7 @@ static int netprocfs_6lowpan_linklayer(FAR struct netprocfs_file_s *netfile,
|
||||
|
||||
DEBUGASSERT(netfile != NULL && netfile->dev != NULL);
|
||||
dev = netfile->dev;
|
||||
addr = &dev->d_mac.sixlowpan;
|
||||
addr = &dev->d_mac.radio;
|
||||
|
||||
len += snprintf(&netfile->line[len], NET_LINELEN - len,
|
||||
"%s\tLink encap:6LoWPAN HWaddr ",
|
||||
|
||||
@@ -210,7 +210,7 @@ static uint16_t sixlowpan_protosize(FAR const struct ipv6_hdr_s *ipv6hdr,
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_WIRELESS_IEEE802154
|
||||
static int sixlowpan_ieee802154_metadata(FAR struct sixlowpan_driver_s *radio,
|
||||
static int sixlowpan_ieee802154_metadata(FAR struct radio_driver_s *radio,
|
||||
FAR const struct netdev_varaddr_s *destmac,
|
||||
FAR union sixlowpan_metadata_u *meta)
|
||||
{
|
||||
@@ -250,10 +250,10 @@ static int sixlowpan_ieee802154_metadata(FAR struct sixlowpan_driver_s *radio,
|
||||
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
|
||||
pktmeta.sextended = TRUE;
|
||||
sixlowpan_eaddrcopy(pktmeta.source.nm_addr,
|
||||
&radio->r_dev.d_mac.sixlowpan.nv_addr);
|
||||
&radio->r_dev.d_mac.radio.nv_addr);
|
||||
#else
|
||||
sixlowpan_saddrcopy(pktmeta.source.nm_addr,
|
||||
&radio->r_dev.d_mac.sixlowpan.nv_addr);
|
||||
&radio->r_dev.d_mac.radio.nv_addr);
|
||||
#endif
|
||||
|
||||
/* Copy the destination node address into the meta data */
|
||||
@@ -309,7 +309,7 @@ static int sixlowpan_ieee802154_metadata(FAR struct sixlowpan_driver_s *radio,
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_WIRELESS_PKTRADIO
|
||||
static int sixlowpan_pktradio_metadata(FAR struct sixlowpan_driver_s *radio,
|
||||
static int sixlowpan_pktradio_metadata(FAR struct radio_driver_s *radio,
|
||||
FAR const struct netdev_varaddr_s *destmac,
|
||||
FAR union sixlowpan_metadata_u *meta)
|
||||
{
|
||||
@@ -321,10 +321,10 @@ static int sixlowpan_pktradio_metadata(FAR struct sixlowpan_driver_s *radio,
|
||||
|
||||
/* Set the source address */
|
||||
|
||||
pktmeta->pm_src.pa_addrlen = radio->r_dev.d_mac.sixlowpan.nv_addrlen;
|
||||
pktmeta->pm_src.pa_addrlen = radio->r_dev.d_mac.radio.nv_addrlen;
|
||||
memcpy(pktmeta->pm_src.pa_addr,
|
||||
radio->r_dev.d_mac.sixlowpan.nv_addr,
|
||||
radio->r_dev.d_mac.sixlowpan.nv_addrlen);
|
||||
radio->r_dev.d_mac.radio.nv_addr,
|
||||
radio->r_dev.d_mac.radio.nv_addrlen);
|
||||
|
||||
/* Set the destination address.
|
||||
* REVISIT: Do we need to check for multicast or broadcast addresses
|
||||
@@ -373,7 +373,7 @@ static int sixlowpan_pktradio_metadata(FAR struct sixlowpan_driver_s *radio,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_queue_frames(FAR struct sixlowpan_driver_s *radio,
|
||||
int sixlowpan_queue_frames(FAR struct radio_driver_s *radio,
|
||||
FAR const struct ipv6_hdr_s *ipv6,
|
||||
FAR const void *buf, size_t buflen,
|
||||
FAR const struct netdev_varaddr_s *destmac)
|
||||
|
||||
@@ -151,7 +151,7 @@ static inline bool sixlowpan_eaddrnull(FAR const uint8_t *eaddr)
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_WIRELESS_IEEE802154
|
||||
int sixlowpan_meta_data(FAR struct sixlowpan_driver_s *radio,
|
||||
int sixlowpan_meta_data(FAR struct radio_driver_s *radio,
|
||||
FAR const struct ieee802_txmetadata_s *pktmeta,
|
||||
FAR struct ieee802154_frame_meta_s *meta,
|
||||
uint16_t paylen)
|
||||
@@ -258,7 +258,7 @@ int sixlowpan_meta_data(FAR struct sixlowpan_driver_s *radio,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_frame_hdrlen(FAR struct sixlowpan_driver_s *radio,
|
||||
int sixlowpan_frame_hdrlen(FAR struct radio_driver_s *radio,
|
||||
FAR const void *meta)
|
||||
{
|
||||
return radio->r_get_mhrlen(radio, meta);
|
||||
@@ -284,7 +284,7 @@ int sixlowpan_frame_hdrlen(FAR struct sixlowpan_driver_s *radio,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_frame_submit(FAR struct sixlowpan_driver_s *radio,
|
||||
int sixlowpan_frame_submit(FAR struct radio_driver_s *radio,
|
||||
FAR const void *meta, FAR struct iob_s *frame)
|
||||
{
|
||||
return radio->r_req_data(radio, meta, frame);
|
||||
|
||||
@@ -623,7 +623,7 @@ void sixlowpan_hc06_initialize(void)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_compresshdr_hc06(FAR struct sixlowpan_driver_s *radio,
|
||||
int sixlowpan_compresshdr_hc06(FAR struct radio_driver_s *radio,
|
||||
FAR const struct ipv6_hdr_s *ipv6,
|
||||
FAR const struct netdev_varaddr_s *destmac,
|
||||
FAR uint8_t *fptr)
|
||||
@@ -794,7 +794,7 @@ int sixlowpan_compresshdr_hc06(FAR struct sixlowpan_driver_s *radio,
|
||||
/* Compression compare with this nodes address (source) */
|
||||
|
||||
iphc1 |= compress_laddr(ipv6->srcipaddr,
|
||||
&radio->r_dev.d_mac.sixlowpan,
|
||||
&radio->r_dev.d_mac.radio,
|
||||
SIXLOWPAN_IPHC_SAM_BIT);
|
||||
}
|
||||
|
||||
@@ -805,7 +805,7 @@ int sixlowpan_compresshdr_hc06(FAR struct sixlowpan_driver_s *radio,
|
||||
ipv6->srcipaddr[3] == 0)
|
||||
{
|
||||
iphc1 |= compress_laddr(ipv6->srcipaddr,
|
||||
&radio->r_dev.d_mac.sixlowpan,
|
||||
&radio->r_dev.d_mac.radio,
|
||||
SIXLOWPAN_IPHC_SAM_BIT);
|
||||
}
|
||||
else
|
||||
@@ -1037,7 +1037,7 @@ int sixlowpan_compresshdr_hc06(FAR struct sixlowpan_driver_s *radio,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void sixlowpan_uncompresshdr_hc06(FAR struct sixlowpan_driver_s *radio,
|
||||
void sixlowpan_uncompresshdr_hc06(FAR struct radio_driver_s *radio,
|
||||
FAR const void *metadata,
|
||||
uint16_t iplen, FAR struct iob_s *iob,
|
||||
FAR uint8_t *fptr, FAR uint8_t *bptr)
|
||||
|
||||
@@ -120,7 +120,7 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_compresshdr_hc1(FAR struct sixlowpan_driver_s *radio,
|
||||
int sixlowpan_compresshdr_hc1(FAR struct radio_driver_s *radio,
|
||||
FAR const struct ipv6_hdr_s *ipv6,
|
||||
FAR const struct netdev_varaddr_s *destmac,
|
||||
FAR uint8_t *fptr)
|
||||
@@ -132,7 +132,7 @@ int sixlowpan_compresshdr_hc1(FAR struct sixlowpan_driver_s *radio,
|
||||
|
||||
if (ipv6->vtc != 0x60 || ipv6->tcf != 0 || ipv6->flow != 0 ||
|
||||
!sixlowpan_islinklocal(ipv6->srcipaddr) ||
|
||||
!sixlowpan_ismacbased(ipv6->srcipaddr, &radio->r_dev.d_mac.sixlowpan) ||
|
||||
!sixlowpan_ismacbased(ipv6->srcipaddr, &radio->r_dev.d_mac.radio) ||
|
||||
!sixlowpan_islinklocal(ipv6->destipaddr) ||
|
||||
!sixlowpan_ismacbased(ipv6->destipaddr, destmac) ||
|
||||
( 1
|
||||
@@ -292,7 +292,7 @@ int sixlowpan_compresshdr_hc1(FAR struct sixlowpan_driver_s *radio,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_uncompresshdr_hc1(FAR struct sixlowpan_driver_s *radio,
|
||||
int sixlowpan_uncompresshdr_hc1(FAR struct radio_driver_s *radio,
|
||||
FAR const void *metadata, uint16_t iplen,
|
||||
FAR struct iob_s *iob, FAR uint8_t *fptr,
|
||||
FAR uint8_t *bptr)
|
||||
|
||||
@@ -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 sixlowpan_driver_s *)dev,
|
||||
ret = sixlowpan_destaddrfromip((FAR struct radio_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 sixlowpan_driver_s *)fwddev,
|
||||
(FAR struct radio_driver_s *)fwddev,
|
||||
&ipv6icmpv6->ipv6, buf, buflen, &destmac);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ static uint8_t g_bitbucket[UNCOMP_MAXHDR];
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static bool sixlowpan_compare_fragsrc(FAR struct sixlowpan_driver_s *radio,
|
||||
static bool sixlowpan_compare_fragsrc(FAR struct radio_driver_s *radio,
|
||||
FAR const void *metadata)
|
||||
{
|
||||
struct netdev_varaddr_s fragsrc;
|
||||
@@ -299,7 +299,7 @@ static void sixlowpan_uncompress_ipv6hdr(FAR uint8_t *fptr, FAR uint8_t *bptr)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int sixlowpan_frame_process(FAR struct sixlowpan_driver_s *radio,
|
||||
static int sixlowpan_frame_process(FAR struct radio_driver_s *radio,
|
||||
FAR const void *metadata, FAR struct iob_s *iob)
|
||||
{
|
||||
FAR uint8_t *fptr; /* Convenience pointer to beginning of the frame */
|
||||
@@ -667,7 +667,7 @@ static int sixlowpan_frame_process(FAR struct sixlowpan_driver_s *radio,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int sixlowpan_dispatch(FAR struct sixlowpan_driver_s *radio)
|
||||
static int sixlowpan_dispatch(FAR struct radio_driver_s *radio)
|
||||
{
|
||||
sixlowpan_dumpbuffer("Incoming packet",
|
||||
(FAR const uint8_t *)IPv6BUF(&radio->r_dev),
|
||||
@@ -763,7 +763,7 @@ static int sixlowpan_dispatch(FAR struct sixlowpan_driver_s *radio)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_input(FAR struct sixlowpan_driver_s *radio,
|
||||
int sixlowpan_input(FAR struct radio_driver_s *radio,
|
||||
FAR struct iob_s *framelist, FAR const void *metadata)
|
||||
{
|
||||
int ret = -EINVAL;
|
||||
|
||||
@@ -233,7 +233,7 @@ extern uint8_t g_frame_hdrlen;
|
||||
****************************************************************************/
|
||||
|
||||
struct net_driver_s; /* Forward reference */
|
||||
struct sixlowpan_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 */
|
||||
@@ -301,7 +301,7 @@ int sixlowpan_send(FAR struct net_driver_s *dev,
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_WIRELESS_IEEE802154
|
||||
int sixlowpan_meta_data(FAR struct sixlowpan_driver_s *radio,
|
||||
int sixlowpan_meta_data(FAR struct radio_driver_s *radio,
|
||||
FAR const struct ieee802_txmetadata_s *pktmeta,
|
||||
FAR struct ieee802154_frame_meta_s *meta,
|
||||
uint16_t paylen);
|
||||
@@ -325,7 +325,7 @@ int sixlowpan_meta_data(FAR struct sixlowpan_driver_s *radio,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_frame_hdrlen(FAR struct sixlowpan_driver_s *radio,
|
||||
int sixlowpan_frame_hdrlen(FAR struct radio_driver_s *radio,
|
||||
FAR const void *meta);
|
||||
|
||||
/****************************************************************************
|
||||
@@ -348,7 +348,7 @@ int sixlowpan_frame_hdrlen(FAR struct sixlowpan_driver_s *radio,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_frame_submit(FAR struct sixlowpan_driver_s *radio,
|
||||
int sixlowpan_frame_submit(FAR struct radio_driver_s *radio,
|
||||
FAR const void *meta, FAR struct iob_s *frame);
|
||||
|
||||
/****************************************************************************
|
||||
@@ -383,7 +383,7 @@ int sixlowpan_frame_submit(FAR struct sixlowpan_driver_s *radio,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_queue_frames(FAR struct sixlowpan_driver_s *radio,
|
||||
int sixlowpan_queue_frames(FAR struct radio_driver_s *radio,
|
||||
FAR const struct ipv6_hdr_s *ipv6,
|
||||
FAR const void *buf, size_t buflen,
|
||||
FAR const struct netdev_varaddr_s *destmac);
|
||||
@@ -441,7 +441,7 @@ void sixlowpan_hc06_initialize(void);
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN_COMPRESSION_HC06
|
||||
int sixlowpan_compresshdr_hc06(FAR struct sixlowpan_driver_s *radio,
|
||||
int sixlowpan_compresshdr_hc06(FAR struct radio_driver_s *radio,
|
||||
FAR const struct ipv6_hdr_s *ipv6,
|
||||
FAR const struct netdev_varaddr_s *destmac,
|
||||
FAR uint8_t *fptr);
|
||||
@@ -479,7 +479,7 @@ int sixlowpan_compresshdr_hc06(FAR struct sixlowpan_driver_s *radio,
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN_COMPRESSION_HC06
|
||||
void sixlowpan_uncompresshdr_hc06(FAR struct sixlowpan_driver_s *radio,
|
||||
void sixlowpan_uncompresshdr_hc06(FAR struct radio_driver_s *radio,
|
||||
FAR const void *metadata,
|
||||
uint16_t iplen, FAR struct iob_s *iob,
|
||||
FAR uint8_t *fptr, FAR uint8_t *bptr);
|
||||
@@ -509,7 +509,7 @@ void sixlowpan_uncompresshdr_hc06(FAR struct sixlowpan_driver_s *radio,
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN_COMPRESSION_HC1
|
||||
int sixlowpan_compresshdr_hc1(FAR struct sixlowpan_driver_s *radio,
|
||||
int sixlowpan_compresshdr_hc1(FAR struct radio_driver_s *radio,
|
||||
FAR const struct ipv6_hdr_s *ipv6,
|
||||
FAR const struct netdev_varaddr_s *destmac,
|
||||
FAR uint8_t *fptr);
|
||||
@@ -547,7 +547,7 @@ int sixlowpan_compresshdr_hc1(FAR struct sixlowpan_driver_s *radio,
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN_COMPRESSION_HC1
|
||||
int sixlowpan_uncompresshdr_hc1(FAR struct sixlowpan_driver_s *radio,
|
||||
int sixlowpan_uncompresshdr_hc1(FAR struct radio_driver_s *radio,
|
||||
FAR const void *metadata, uint16_t iplen,
|
||||
FAR struct iob_s *iob, FAR uint8_t *fptr,
|
||||
FAR uint8_t *bptr);
|
||||
@@ -586,7 +586,7 @@ int sixlowpan_uncompresshdr_hc1(FAR struct sixlowpan_driver_s *radio,
|
||||
|
||||
#define sixlowpan_islinklocal(ipaddr) ((ipaddr)[0] == NTOHS(0xfe80))
|
||||
|
||||
int sixlowpan_destaddrfromip(FAR struct sixlowpan_driver_s *radio,
|
||||
int sixlowpan_destaddrfromip(FAR struct radio_driver_s *radio,
|
||||
const net_ipv6addr_t ipaddr,
|
||||
FAR struct netdev_varaddr_s *addr);
|
||||
|
||||
@@ -613,7 +613,7 @@ bool sixlowpan_ismacbased(const net_ipv6addr_t ipaddr,
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_WIRELESS_IEEE802154
|
||||
int sixlowpan_src_panid(FAR struct sixlowpan_driver_s *radio,
|
||||
int sixlowpan_src_panid(FAR struct radio_driver_s *radio,
|
||||
FAR uint8_t *panid);
|
||||
#endif
|
||||
|
||||
@@ -634,7 +634,7 @@ int sixlowpan_src_panid(FAR struct sixlowpan_driver_s *radio,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_extract_srcaddr(FAR struct sixlowpan_driver_s *radio,
|
||||
int sixlowpan_extract_srcaddr(FAR struct radio_driver_s *radio,
|
||||
FAR const void *metadata,
|
||||
FAR struct netdev_varaddr_s *srcaddr);
|
||||
|
||||
@@ -655,7 +655,7 @@ int sixlowpan_extract_srcaddr(FAR struct sixlowpan_driver_s *radio,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_extract_destaddr(FAR struct sixlowpan_driver_s *radio,
|
||||
int sixlowpan_extract_destaddr(FAR struct radio_driver_s *radio,
|
||||
FAR const void *metadata,
|
||||
FAR struct netdev_varaddr_s *destaddr);
|
||||
|
||||
|
||||
@@ -193,7 +193,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 sixlowpan_driver_s *)dev,
|
||||
sixlowpan_queue_frames((FAR struct radio_driver_s *)dev,
|
||||
sinfo->s_ipv6hdr, sinfo->s_buf, sinfo->s_len,
|
||||
sinfo->s_destmac);
|
||||
|
||||
|
||||
@@ -521,7 +521,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 sixlowpan_driver_s *)dev,
|
||||
ret = sixlowpan_queue_frames((FAR struct radio_driver_s *)dev,
|
||||
&ipv6tcp.ipv6,
|
||||
&sinfo->s_buf[sinfo->s_sent], sndlen,
|
||||
sinfo->s_destmac);
|
||||
@@ -827,7 +827,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 sixlowpan_driver_s *)dev,
|
||||
ret = sixlowpan_destaddrfromip((FAR struct radio_driver_s *)dev,
|
||||
conn->u.ipv6.raddr, &destmac);
|
||||
if (ret < 0)
|
||||
{
|
||||
@@ -946,7 +946,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 sixlowpan_driver_s *)dev,
|
||||
ret = sixlowpan_destaddrfromip((FAR struct radio_driver_s *)dev,
|
||||
ipv6hdr->ipv6.destipaddr, &destmac);
|
||||
if (ret < 0)
|
||||
{
|
||||
@@ -976,7 +976,7 @@ void sixlowpan_tcp_send(FAR struct net_driver_s *dev,
|
||||
buflen = dev->d_len - hdrlen;
|
||||
|
||||
(void)sixlowpan_queue_frames(
|
||||
(FAR struct sixlowpan_driver_s *)fwddev,
|
||||
(FAR struct radio_driver_s *)fwddev,
|
||||
&ipv6hdr->ipv6, buf, buflen, &destmac);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,7 +295,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 sixlowpan_driver_s *)dev,
|
||||
ret = sixlowpan_destaddrfromip((FAR struct radio_driver_s *)dev,
|
||||
to6->sin6_addr.in6_u.u6_addr16, &destmac);
|
||||
if (ret < 0)
|
||||
{
|
||||
@@ -471,7 +471,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 sixlowpan_driver_s *)dev,
|
||||
ret = sixlowpan_destaddrfromip((FAR struct radio_driver_s *)dev,
|
||||
ipv6udp->ipv6.destipaddr, &destmac);
|
||||
if (ret < 0)
|
||||
{
|
||||
@@ -498,7 +498,7 @@ void sixlowpan_udp_send(FAR struct net_driver_s *dev,
|
||||
buflen = dev->d_len - hdrlen;
|
||||
|
||||
(void)sixlowpan_queue_frames(
|
||||
(FAR struct sixlowpan_driver_s *)fwddev,
|
||||
(FAR struct radio_driver_s *)fwddev,
|
||||
&ipv6udp->ipv6, buf, buflen, &destmac);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ static void sixlowpan_eaddrfromip(const net_ipv6addr_t ipaddr, FAR uint8_t *eadd
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_destaddrfromip(FAR struct sixlowpan_driver_s *radio,
|
||||
int sixlowpan_destaddrfromip(FAR struct radio_driver_s *radio,
|
||||
const net_ipv6addr_t ipaddr,
|
||||
FAR struct netdev_varaddr_s *destaddr)
|
||||
{
|
||||
@@ -524,7 +524,7 @@ bool sixlowpan_ismacbased(const net_ipv6addr_t ipaddr,
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_WIRELESS_IEEE802154
|
||||
int sixlowpan_src_panid(FAR struct sixlowpan_driver_s *radio,
|
||||
int sixlowpan_src_panid(FAR struct radio_driver_s *radio,
|
||||
FAR uint8_t *panid)
|
||||
{
|
||||
FAR struct net_driver_s *dev = &radio->r_dev;
|
||||
@@ -563,7 +563,7 @@ int sixlowpan_src_panid(FAR struct sixlowpan_driver_s *radio,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_extract_srcaddr(FAR struct sixlowpan_driver_s *radio,
|
||||
int sixlowpan_extract_srcaddr(FAR struct radio_driver_s *radio,
|
||||
FAR const void *metadata,
|
||||
FAR struct netdev_varaddr_s *srcaddr)
|
||||
{
|
||||
@@ -630,7 +630,7 @@ int sixlowpan_extract_srcaddr(FAR struct sixlowpan_driver_s *radio,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int sixlowpan_extract_destaddr(FAR struct sixlowpan_driver_s *radio,
|
||||
int sixlowpan_extract_destaddr(FAR struct radio_driver_s *radio,
|
||||
FAR const void *metadata,
|
||||
FAR struct netdev_varaddr_s *destaddr)
|
||||
{
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include "inet/inet.h"
|
||||
#include "local/local.h"
|
||||
#include "pkt/pkt.h"
|
||||
#include "ieee802154/ieee802154.h"
|
||||
#include "socket/socket.h"
|
||||
|
||||
/****************************************************************************
|
||||
@@ -100,6 +101,12 @@ FAR const struct sock_intf_s *net_sockif(sa_family_t family)
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_IEEE802154
|
||||
case PF_IEEE802154:
|
||||
sockif = &g_ieee802154_sockif;
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
nerr("ERROR: Address family unsupported: %d\n", family);
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ struct lo_driver_s
|
||||
|
||||
/* This holds the information visible to the NuttX network */
|
||||
|
||||
struct sixlowpan_driver_s lo_radio; /* Interface understood by the network */
|
||||
struct radio_driver_s lo_radio; /* Interface understood by the network */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -161,11 +161,11 @@ 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 sixlowpan_driver_s *netdev,
|
||||
static int lo_get_mhrlen(FAR struct radio_driver_s *netdev,
|
||||
FAR const void *meta);
|
||||
static int lo_req_data(FAR struct sixlowpan_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 sixlowpan_driver_s *netdev,
|
||||
static int lo_properties(FAR struct radio_driver_s *netdev,
|
||||
FAR struct sixlowpan_properties_s *properties);
|
||||
|
||||
/****************************************************************************
|
||||
@@ -191,8 +191,8 @@ static void lo_addr2ip(FAR struct net_driver_s *dev)
|
||||
{
|
||||
/* Set the MAC address as the eaddr */
|
||||
|
||||
dev->d_mac.sixlowpan.nv_addrlen = NET_6LOWPAN_EADDRSIZE;
|
||||
IEEE802154_EADDRCOPY(dev->d_mac.sixlowpan.nv_addr, g_eaddr);
|
||||
dev->d_mac.radio.nv_addrlen = NET_6LOWPAN_EADDRSIZE;
|
||||
IEEE802154_EADDRCOPY(dev->d_mac.radio.nv_addr, g_eaddr);
|
||||
|
||||
/* Set the IP address based on the eaddr */
|
||||
|
||||
@@ -211,8 +211,8 @@ static void lo_addr2ip(FAR struct net_driver_s *dev)
|
||||
{
|
||||
/* Set the MAC address as the saddr */
|
||||
|
||||
dev->d_mac.sixlowpan.nv_addrlen = NET_6LOWPAN_SADDRSIZE;
|
||||
IEEE802154_SADDRCOPY(dev->d_mac.sixlowpan.nv_addr, g_saddr);
|
||||
dev->d_mac.radio.nv_addrlen = NET_6LOWPAN_SADDRSIZE;
|
||||
IEEE802154_SADDRCOPY(dev->d_mac.radio.nv_addr, g_saddr);
|
||||
|
||||
/* Set the IP address based on the saddr */
|
||||
|
||||
@@ -482,14 +482,14 @@ static int lo_ifup(FAR struct net_driver_s *dev)
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
|
||||
ninfo(" Node: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x PANID=%02x:%02x\n",
|
||||
dev->d_mac.sixlowpan.nv_addr[0], dev->d_mac.sixlowpan.nv_addr[1],
|
||||
dev->d_mac.sixlowpan.nv_addr[2], dev->d_mac.sixlowpan.nv_addr[3],
|
||||
dev->d_mac.sixlowpan.nv_addr[4], dev->d_mac.sixlowpan.nv_addr[5],
|
||||
dev->d_mac.sixlowpan.nv_addr[6], dev->d_mac.sixlowpan.nv_addr[7],
|
||||
dev->d_mac.radio.nv_addr[0], dev->d_mac.radio.nv_addr[1],
|
||||
dev->d_mac.radio.nv_addr[2], dev->d_mac.radio.nv_addr[3],
|
||||
dev->d_mac.radio.nv_addr[4], dev->d_mac.radio.nv_addr[5],
|
||||
dev->d_mac.radio.nv_addr[6], dev->d_mac.radio.nv_addr[7],
|
||||
priv->lo_panid[0], priv->lo_panid[1]);
|
||||
#else
|
||||
ninfo(" Node: %02x:%02x PANID=%02x:%02x\n",
|
||||
dev->d_mac.sixlowpan.nv_addr[0], dev->d_mac.sixlowpan.nv_addr[1],
|
||||
dev->d_mac.radio.nv_addr[0], dev->d_mac.radio.nv_addr[1],
|
||||
priv->lo_panid[0], priv->lo_panid[1]);
|
||||
#endif
|
||||
|
||||
@@ -811,7 +811,7 @@ static int lo_ioctl(FAR struct net_driver_s *dev, int cmd,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int lo_get_mhrlen(FAR struct sixlowpan_driver_s *netdev,
|
||||
static int lo_get_mhrlen(FAR struct radio_driver_s *netdev,
|
||||
FAR const void *meta)
|
||||
{
|
||||
return MAC_HDRLEN;
|
||||
@@ -835,7 +835,7 @@ static int lo_get_mhrlen(FAR struct sixlowpan_driver_s *netdev,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int lo_req_data(FAR struct sixlowpan_driver_s *netdev,
|
||||
static int lo_req_data(FAR struct radio_driver_s *netdev,
|
||||
FAR const void *meta, FAR struct iob_s *framelist)
|
||||
{
|
||||
FAR struct lo_driver_s *priv;
|
||||
@@ -905,7 +905,7 @@ static int lo_req_data(FAR struct sixlowpan_driver_s *netdev,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int lo_properties(FAR struct sixlowpan_driver_s *netdev,
|
||||
static int lo_properties(FAR struct radio_driver_s *netdev,
|
||||
FAR struct sixlowpan_properties_s *properties)
|
||||
{
|
||||
DEBUGASSERT(netdev != NULL && properties != NULL);
|
||||
@@ -969,7 +969,7 @@ static int lo_properties(FAR struct sixlowpan_driver_s *netdev,
|
||||
int ieee8021514_loopback(void)
|
||||
{
|
||||
FAR struct lo_driver_s *priv;
|
||||
FAR struct sixlowpan_driver_s *radio;
|
||||
FAR struct radio_driver_s *radio;
|
||||
FAR struct net_driver_s *dev;
|
||||
|
||||
ninfo("Initializing\n");
|
||||
|
||||
@@ -121,7 +121,7 @@ struct macnet_driver_s
|
||||
{
|
||||
/* This holds the information visible to the NuttX network */
|
||||
|
||||
struct sixlowpan_driver_s md_dev; /* Interface understood by the network */
|
||||
struct radio_driver_s md_dev; /* Interface understood by the network */
|
||||
/* Cast compatible with struct macnet_driver_s */
|
||||
|
||||
/* For internal use by this driver */
|
||||
@@ -169,10 +169,10 @@ static void macnet_txpoll_expiry(int argc, wdparm_t arg, ...);
|
||||
|
||||
#ifdef CONFIG_NET_STARPOINT
|
||||
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
|
||||
static int macnet_coord_eaddr(FAR struct sixlowpan_driver_s *radio,
|
||||
static int macnet_coord_eaddr(FAR struct radio_driver_s *radio,
|
||||
FAR uint8_t *eaddr);
|
||||
#else
|
||||
static int macnet_coord_saddr(FAR struct sixlowpan_driver_s *radio,
|
||||
static int macnet_coord_saddr(FAR struct radio_driver_s *radio,
|
||||
FAR uint8_t *saddr);
|
||||
#endif
|
||||
#endif
|
||||
@@ -195,11 +195,11 @@ 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 sixlowpan_driver_s *netdev,
|
||||
static int macnet_get_mhrlen(FAR struct radio_driver_s *netdev,
|
||||
FAR const void *meta);
|
||||
static int macnet_req_data(FAR struct sixlowpan_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 sixlowpan_driver_s *netdev,
|
||||
static int macnet_properties(FAR struct radio_driver_s *netdev,
|
||||
FAR struct sixlowpan_properties_s *properties);
|
||||
|
||||
/****************************************************************************
|
||||
@@ -249,8 +249,8 @@ static int macnet_advertise(FAR struct net_driver_s *dev)
|
||||
/* Set the MAC address as the eaddr */
|
||||
|
||||
eaddr = arg.getreq.attrval.mac.eaddr;
|
||||
IEEE802154_EADDRCOPY(dev->d_mac.sixlowpan.nv_addr, eaddr);
|
||||
dev->d_mac.sixlowpan.nv_addrlen = NET_6LOWPAN_EADDRSIZE;
|
||||
IEEE802154_EADDRCOPY(dev->d_mac.radio.nv_addr, eaddr);
|
||||
dev->d_mac.radio.nv_addrlen = NET_6LOWPAN_EADDRSIZE;
|
||||
|
||||
/* Set the IP address based on the eaddr */
|
||||
|
||||
@@ -287,8 +287,8 @@ static int macnet_advertise(FAR struct net_driver_s *dev)
|
||||
/* Set the MAC address as the saddr */
|
||||
|
||||
saddr = arg.getreq.attrval.mac.saddr;
|
||||
IEEE802154_SADDRCOPY(dev->d_mac.sixlowpan.nv_addr, saddr);
|
||||
dev->d_mac.sixlowpan.nv_addrlen = NET_6LOWPAN_SADDRSIZE;
|
||||
IEEE802154_SADDRCOPY(dev->d_mac.radio.nv_addr, saddr);
|
||||
dev->d_mac.radio.nv_addrlen = NET_6LOWPAN_SADDRSIZE;
|
||||
|
||||
/* Set the IP address based on the saddr */
|
||||
|
||||
@@ -572,7 +572,7 @@ static void macnet_txpoll_expiry(int argc, wdparm_t arg, ...)
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_NET_STARPOINT) && defined(CONFIG_NET_6LOWPAN_EXTENDEDADDR)
|
||||
static int macnet_coord_eaddr(FAR struct sixlowpan_driver_s *radio,
|
||||
static int macnet_coord_eaddr(FAR struct radio_driver_s *radio,
|
||||
FAR uint8_t *eaddr)
|
||||
{
|
||||
FAR struct macnet_driver_s *priv = (FAR struct macnet_driver_s *)radio;
|
||||
@@ -609,7 +609,7 @@ static int macnet_coord_eaddr(FAR struct sixlowpan_driver_s *radio,
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_NET_STARPOINT) && !defined(CONFIG_NET_6LOWPAN_EXTENDEDADDR)
|
||||
static int macnet_coord_saddr(FAR struct sixlowpan_driver_s *radio,
|
||||
static int macnet_coord_saddr(FAR struct radio_driver_s *radio,
|
||||
FAR uint8_t *saddr)
|
||||
{
|
||||
FAR struct macnet_driver_s *priv = (FAR struct macnet_driver_s *)radio;
|
||||
@@ -665,13 +665,13 @@ static int macnet_ifup(FAR struct net_driver_s *dev)
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
|
||||
wlinfo(" Node: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
dev->d_mac.sixlowpan.nv_addr[0], dev->d_mac.sixlowpan.nv_addr[1],
|
||||
dev->d_mac.sixlowpan.nv_addr[2], dev->d_mac.sixlowpan.nv_addr[3],
|
||||
dev->d_mac.sixlowpan.nv_addr[4], dev->d_mac.sixlowpan.nv_addr[5],
|
||||
dev->d_mac.sixlowpan.nv_addr[6], dev->d_mac.sixlowpan.nv_addr[7]);
|
||||
dev->d_mac.radio.nv_addr[0], dev->d_mac.radio.nv_addr[1],
|
||||
dev->d_mac.radio.nv_addr[2], dev->d_mac.radio.nv_addr[3],
|
||||
dev->d_mac.radio.nv_addr[4], dev->d_mac.radio.nv_addr[5],
|
||||
dev->d_mac.radio.nv_addr[6], dev->d_mac.radio.nv_addr[7]);
|
||||
#else
|
||||
wlinfo(" Node: %02x:%02x\n",
|
||||
dev->d_mac.sixlowpan.nv_addr[0], dev->d_mac.sixlowpan.nv_addr[1]);
|
||||
dev->d_mac.radio.nv_addr[0], dev->d_mac.radio.nv_addr[1]);
|
||||
#endif
|
||||
|
||||
/* Set and activate a timer process */
|
||||
@@ -945,7 +945,7 @@ static int macnet_ioctl(FAR struct net_driver_s *dev, int cmd,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int macnet_get_mhrlen(FAR struct sixlowpan_driver_s *netdev,
|
||||
static int macnet_get_mhrlen(FAR struct radio_driver_s *netdev,
|
||||
FAR const void *meta)
|
||||
{
|
||||
FAR struct macnet_driver_s *priv =
|
||||
@@ -975,7 +975,7 @@ static int macnet_get_mhrlen(FAR struct sixlowpan_driver_s *netdev,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int macnet_req_data(FAR struct sixlowpan_driver_s *netdev,
|
||||
static int macnet_req_data(FAR struct radio_driver_s *netdev,
|
||||
FAR const void *meta, FAR struct iob_s *framelist)
|
||||
{
|
||||
FAR struct macnet_driver_s *priv =
|
||||
@@ -1055,7 +1055,7 @@ static int macnet_req_data(FAR struct sixlowpan_driver_s *netdev,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int macnet_properties(FAR struct sixlowpan_driver_s *netdev,
|
||||
static int macnet_properties(FAR struct radio_driver_s *netdev,
|
||||
FAR struct sixlowpan_properties_s *properties)
|
||||
{
|
||||
DEBUGASSERT(netdev != NULL && properties != NULL);
|
||||
@@ -1131,7 +1131,7 @@ static int macnet_properties(FAR struct sixlowpan_driver_s *netdev,
|
||||
int mac802154netdev_register(MACHANDLE mac)
|
||||
{
|
||||
FAR struct macnet_driver_s *priv;
|
||||
FAR struct sixlowpan_driver_s *radio;
|
||||
FAR struct radio_driver_s *radio;
|
||||
FAR struct net_driver_s *dev;
|
||||
FAR struct mac802154_maccb_s *maccb;
|
||||
FAR uint8_t *pktbuf;
|
||||
|
||||
@@ -121,7 +121,7 @@ struct lo_driver_s
|
||||
|
||||
/* This holds the information visible to the NuttX network */
|
||||
|
||||
struct sixlowpan_driver_s lo_radio; /* Interface understood by the network */
|
||||
struct radio_driver_s lo_radio; /* Interface understood by the network */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -172,11 +172,11 @@ 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 sixlowpan_driver_s *netdev,
|
||||
static int lo_get_mhrlen(FAR struct radio_driver_s *netdev,
|
||||
FAR const void *meta);
|
||||
static int lo_req_data(FAR struct sixlowpan_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 sixlowpan_driver_s *netdev,
|
||||
static int lo_properties(FAR struct radio_driver_s *netdev,
|
||||
FAR struct sixlowpan_properties_s *properties);
|
||||
|
||||
/****************************************************************************
|
||||
@@ -201,8 +201,8 @@ static void lo_addr2ip(FAR struct net_driver_s *dev)
|
||||
{
|
||||
/* Set the MAC address as the saddr */
|
||||
|
||||
dev->d_mac.sixlowpan.nv_addrlen = CONFIG_PKTRADIO_ADDRLEN;
|
||||
memcpy(dev->d_mac.sixlowpan.nv_addr, g_mac_addr, CONFIG_PKTRADIO_ADDRLEN);
|
||||
dev->d_mac.radio.nv_addrlen = CONFIG_PKTRADIO_ADDRLEN;
|
||||
memcpy(dev->d_mac.radio.nv_addr, g_mac_addr, CONFIG_PKTRADIO_ADDRLEN);
|
||||
|
||||
/* Set the IP address */
|
||||
|
||||
@@ -491,18 +491,18 @@ static int lo_ifup(FAR struct net_driver_s *dev)
|
||||
|
||||
#if CONFIG_PKTRADIO_ADDRLEN == 1
|
||||
ninfo(" Node: %02x\n",
|
||||
dev->d_mac.sixlowpan.nv_addr[0]);
|
||||
dev->d_mac.radio.nv_addr[0]);
|
||||
|
||||
#elif CONFIG_PKTRADIO_ADDRLEN == 2
|
||||
ninfo(" Node: %02x:%02x\n",
|
||||
dev->d_mac.sixlowpan.nv_addr[0], dev->d_mac.sixlowpan.nv_addr[1]);
|
||||
dev->d_mac.radio.nv_addr[0], dev->d_mac.radio.nv_addr[1]);
|
||||
|
||||
#elif CONFIG_PKTRADIO_ADDRLEN == 8
|
||||
ninfo(" Node: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x PANID=%02x:%02x\n",
|
||||
dev->d_mac.sixlowpan.nv_addr[0], dev->d_mac.sixlowpan.nv_addr[1],
|
||||
dev->d_mac.sixlowpan.nv_addr[2], dev->d_mac.sixlowpan.nv_addr[3],
|
||||
dev->d_mac.sixlowpan.nv_addr[4], dev->d_mac.sixlowpan.nv_addr[5],
|
||||
dev->d_mac.sixlowpan.nv_addr[6], dev->d_mac.sixlowpan.nv_addr[7]);
|
||||
dev->d_mac.radio.nv_addr[0], dev->d_mac.radio.nv_addr[1],
|
||||
dev->d_mac.radio.nv_addr[2], dev->d_mac.radio.nv_addr[3],
|
||||
dev->d_mac.radio.nv_addr[4], dev->d_mac.radio.nv_addr[5],
|
||||
dev->d_mac.radio.nv_addr[6], dev->d_mac.radio.nv_addr[7]);
|
||||
#endif
|
||||
|
||||
/* Set and activate a timer process */
|
||||
@@ -746,8 +746,8 @@ static int lo_ioctl(FAR struct net_driver_s *dev, int cmd,
|
||||
|
||||
case SIOCPKTRADIOGGPROPS:
|
||||
{
|
||||
FAR struct sixlowpan_driver_s *radio =
|
||||
(FAR struct sixlowpan_driver_s *)dev;
|
||||
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;
|
||||
|
||||
@@ -773,7 +773,7 @@ static int lo_ioctl(FAR struct net_driver_s *dev, int cmd,
|
||||
}
|
||||
else
|
||||
{
|
||||
FAR const struct netdev_varaddr_s *devaddr = &dev->d_mac.sixlowpan;
|
||||
FAR const struct netdev_varaddr_s *devaddr = &dev->d_mac.radio;
|
||||
|
||||
devaddr->nv_addrlen = 1;
|
||||
devaddr->nv_addr[0] = newaddr->pa_addr[0];
|
||||
@@ -797,7 +797,7 @@ static int lo_ioctl(FAR struct net_driver_s *dev, int cmd,
|
||||
{
|
||||
FAR struct pktradio_addr_s *retaddr =
|
||||
(FAR struct pktradio_addr_s *)&cmddata->pifr_hwaddr;
|
||||
FAR const struct netdev_varaddr_s *devaddr = &dev->d_mac.sixlowpan;
|
||||
FAR const struct netdev_varaddr_s *devaddr = &dev->d_mac.radio;
|
||||
|
||||
retaddr->pa_addrlen = devaddr->nv_addrlen;
|
||||
retaddr->pa_addr[0] = devaddr->nv_addr[0];
|
||||
@@ -834,7 +834,7 @@ static int lo_ioctl(FAR struct net_driver_s *dev, int cmd,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int lo_get_mhrlen(FAR struct sixlowpan_driver_s *netdev,
|
||||
static int lo_get_mhrlen(FAR struct radio_driver_s *netdev,
|
||||
FAR const void *meta)
|
||||
{
|
||||
return MAC_HDRLEN;
|
||||
@@ -858,7 +858,7 @@ static int lo_get_mhrlen(FAR struct sixlowpan_driver_s *netdev,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int lo_req_data(FAR struct sixlowpan_driver_s *netdev,
|
||||
static int lo_req_data(FAR struct radio_driver_s *netdev,
|
||||
FAR const void *meta, FAR struct iob_s *framelist)
|
||||
{
|
||||
FAR struct lo_driver_s *priv;
|
||||
@@ -928,7 +928,7 @@ static int lo_req_data(FAR struct sixlowpan_driver_s *netdev,
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static int lo_properties(FAR struct sixlowpan_driver_s *netdev,
|
||||
static int lo_properties(FAR struct radio_driver_s *netdev,
|
||||
FAR struct sixlowpan_properties_s *properties)
|
||||
{
|
||||
DEBUGASSERT(netdev != NULL && properties != NULL);
|
||||
@@ -982,7 +982,7 @@ static int lo_properties(FAR struct sixlowpan_driver_s *netdev,
|
||||
int pktradio_loopback(void)
|
||||
{
|
||||
FAR struct lo_driver_s *priv;
|
||||
FAR struct sixlowpan_driver_s *radio;
|
||||
FAR struct radio_driver_s *radio;
|
||||
FAR struct net_driver_s *dev;
|
||||
|
||||
ninfo("Initializing\n");
|
||||
|
||||
Reference in New Issue
Block a user