6loWPAN: Add IEEE802.15.4 Rime address to union of link layer addresses in the network driver.
This commit is contained in:
parent
79256573e1
commit
7da031aea1
@ -56,12 +56,16 @@
|
||||
#include <net/ethernet.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <nuttx/net/netconfig.h>
|
||||
#include <nuttx/net/ip.h>
|
||||
|
||||
#ifdef CONFIG_NET_IGMP
|
||||
# include <nuttx/net/igmp.h>
|
||||
#endif
|
||||
|
||||
#include <nuttx/net/netconfig.h>
|
||||
#include <nuttx/net/ip.h>
|
||||
#ifdef CONFIG_NET_6LOWPAN
|
||||
# include <nuttx/net/ieee802154.h>
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
@ -207,7 +211,7 @@ struct net_driver_s
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NET_ETHERNET)
|
||||
#if defined(CONFIG_NET_ETHERNET) || defined(CONFIG_NET_6LOWPAN)
|
||||
/* Link layer address */
|
||||
|
||||
union
|
||||
@ -216,6 +220,11 @@ struct net_driver_s
|
||||
/* Ethernet device identity */
|
||||
|
||||
struct ether_addr ether; /* Device Ethernet MAC address */
|
||||
#endif
|
||||
#ifdef CONFIG_NET_6LOWPAN
|
||||
/* The address assigned to an IEEE 802.15.4 radio. */
|
||||
|
||||
struct rimeaddr_s ieee802154; /* IEEE 802.15.4 Radio address */
|
||||
#endif
|
||||
} d_mac;
|
||||
#endif
|
||||
|
@ -366,9 +366,7 @@
|
||||
* 2. i_dsn must be set to a random value. After that, it will be managed
|
||||
* by the network.
|
||||
*
|
||||
* 3. i_nodeaddr must be set after the MAC is assigned an address.
|
||||
*
|
||||
* 4. On a TX poll, the IEEE802.15.4 MAC driver should provide its driver
|
||||
* 3. On a TX poll, the IEEE802.15.4 MAC driver should provide its driver
|
||||
* structure with i_framelist set to NULL. At the conclusion of the
|
||||
* poll, if there are frames to be sent, they will have been added to
|
||||
* the i_framelist. The non-empty frame list at the conclusion of the
|
||||
@ -383,7 +381,7 @@
|
||||
* After sending each frame, the driver must return the IOB to the pool
|
||||
* of free IOBs using the FROM_IOB_FREE() macro.
|
||||
*
|
||||
* 5. When receiving data both buffers must be provided:
|
||||
* 4. When receiving data both buffers must be provided:
|
||||
*
|
||||
* The IEEE802.15.4 MAC driver should receive the frame data directly
|
||||
* into the payload area of an IOB structure. That IOB structure may be
|
||||
@ -444,10 +442,6 @@ struct ieee802154_driver_s
|
||||
|
||||
uint16_t i_panid;
|
||||
|
||||
/* i_node_addr. The address assigned to this node. */
|
||||
|
||||
struct rimeaddr_s i_nodeaddr;
|
||||
|
||||
/* i_dsn. The sequence number in the range 0x00-0xff added to the
|
||||
* transmitted data or MAC command frame. The default is a random value
|
||||
* within that range.
|
||||
|
@ -707,13 +707,9 @@ static int netdev_ifr_ioctl(FAR struct socket *psock, int cmd,
|
||||
if (true)
|
||||
#endif
|
||||
{
|
||||
FAR struct ieee802154_driver_s *ieee =
|
||||
(FAR struct ieee802154_driver_s *)dev;
|
||||
|
||||
req->ifr_hwaddr.sa_family = AF_INETX;
|
||||
memcpy(req->ifr_hwaddr.sa_data, ieee->i_nodeaddr.u8,
|
||||
NET_6LOWPAN_RIMEADDR_SIZE);
|
||||
ret = OK;
|
||||
memcpy(req->ifr_hwaddr.sa_data,
|
||||
dev->d_mac.ieee802154.u8, NET_6LOWPAN_RIMEADDR_SIZE);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
@ -750,13 +746,9 @@ static int netdev_ifr_ioctl(FAR struct socket *psock, int cmd,
|
||||
if (true)
|
||||
#endif
|
||||
{
|
||||
FAR struct ieee802154_driver_s *ieee =
|
||||
(FAR struct ieee802154_driver_s *)dev;
|
||||
|
||||
req->ifr_hwaddr.sa_family = AF_INETX;
|
||||
memcpy(ieee->i_nodeaddr.u8, req->ifr_hwaddr.sa_data,
|
||||
NET_6LOWPAN_RIMEADDR_SIZE);
|
||||
ret = OK;
|
||||
memcpy(dev->d_mac.ieee802154.u8,
|
||||
req->ifr_hwaddr.sa_data, NET_6LOWPAN_RIMEADDR_SIZE);
|
||||
ret = OK;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
@ -112,9 +112,6 @@ static const linegen_t g_linegen[] =
|
||||
static int netprocfs_linklayer(FAR struct netprocfs_file_s *netfile)
|
||||
{
|
||||
FAR struct net_driver_s *dev;
|
||||
#ifdef CONFIG_NET_6LOWPAN
|
||||
FAR struct ieee802154_driver_s *ieee;
|
||||
#endif
|
||||
FAR const char *status;
|
||||
int len = 0;
|
||||
|
||||
@ -154,22 +151,20 @@ static int netprocfs_linklayer(FAR struct netprocfs_file_s *netfile)
|
||||
#ifdef CONFIG_NET_6LOWPAN
|
||||
case NET_LL_IEEE802154:
|
||||
{
|
||||
ieee = (FAR struct ieee802154_driver_s *)dev;
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN_RIMEADDR_EXTENDED
|
||||
len += snprintf(&netfile->line[len], NET_LINELEN - len,
|
||||
"%s\tLink encap:6loWPAN HWaddr "
|
||||
"%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
dev->d_ifname,
|
||||
ieee->i_nodeaddr.u8[0], ieee->i_nodeaddr.u8[1],
|
||||
ieee->i_nodeaddr.u8[2], ieee->i_nodeaddr.u8[3],
|
||||
ieee->i_nodeaddr.u8[4], ieee->i_nodeaddr.u8[5],
|
||||
ieee->i_nodeaddr.u8[6], ieee->i_nodeaddr.u8[7]);
|
||||
dev->d_mac.ieee802154.u8[0], dev->d_mac.ieee802154.u8[1],
|
||||
dev->d_mac.ieee802154.u8[2], dev->d_mac.ieee802154.u8[3],
|
||||
dev->d_mac.ieee802154.u8[4], dev->d_mac.ieee802154.u8[5],
|
||||
dev->d_mac.ieee802154.u8[6], dev->d_mac.ieee802154.u8[7]);
|
||||
#else
|
||||
len += snprintf(&netfile->line[len], NET_LINELEN - len,
|
||||
"%s\tLink encap:6loWPAN HWaddr %02x:%02x",
|
||||
dev->d_ifname,
|
||||
ieee->i_nodeaddr.u8[0], ieee->i_nodeaddr.u8[1]);
|
||||
dev->d_mac.ieee802154.u8[0], dev->d_mac.ieee802154.u8[1]);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
@ -218,23 +213,21 @@ static int netprocfs_linklayer(FAR struct netprocfs_file_s *netfile)
|
||||
dev->d_ifname, ether_ntoa(&dev->d_mac.ether), status);
|
||||
|
||||
#elif defined(CONFIG_NET_6LOWPAN)
|
||||
ieee = (FAR struct ieee802154_driver_s *)dev;
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN_RIMEADDR_EXTENDED
|
||||
len += snprintf(&netfile->line[len], NET_LINELEN - len,
|
||||
"%s\tLink encap:6loWPAN HWaddr "
|
||||
"%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x at %s\n",
|
||||
dev->d_ifname,
|
||||
ieee->i_nodeaddr.u8[0], ieee->i_nodeaddr.u8[1],
|
||||
ieee->i_nodeaddr.u8[2], ieee->i_nodeaddr.u8[3],
|
||||
ieee->i_nodeaddr.u8[4], ieee->i_nodeaddr.u8[5],
|
||||
ieee->i_nodeaddr.u8[6], ieee->i_nodeaddr.u8[7],
|
||||
dev->d_mac.ieee802154.u8[0], dev->d_mac.ieee802154.u8[1],
|
||||
dev->d_mac.ieee802154.u8[2], dev->d_mac.ieee802154.u8[3],
|
||||
dev->d_mac.ieee802154.u8[4], dev->d_mac.ieee802154.u8[5],
|
||||
dev->d_mac.ieee802154.u8[6], dev->d_mac.ieee802154.u8[7],
|
||||
status);
|
||||
#else
|
||||
len += snprintf(&netfile->line[len], NET_LINELEN - len,
|
||||
"%s\tLink encap:6loWPAN HWaddr %02x:%02x at %s\n",
|
||||
dev->d_ifname,
|
||||
ieee->i_nodeaddr.u8[0], ieee->i_nodeaddr.u8[1],
|
||||
dev->d_mac.ieee802154.u8[0], dev->d_mac.ieee802154.u8[1],
|
||||
status);
|
||||
#endif
|
||||
#elif defined(CONFIG_NET_LOOPBACK)
|
||||
|
@ -283,7 +283,8 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
|
||||
|
||||
/* Set the source and destinatino address */
|
||||
|
||||
rimeaddr_copy(&g_pktaddrs[PACKETBUF_ADDR_SENDER], &ieee->i_nodeaddr);
|
||||
rimeaddr_copy(&g_pktaddrs[PACKETBUF_ADDR_SENDER],
|
||||
&ieee->i_dev.d_mac.ieee802154);
|
||||
rimeaddr_copy(&g_pktaddrs[PACKETBUF_ADDR_RECEIVER], destmac);
|
||||
|
||||
/* Pre-calculate frame header length. */
|
||||
|
@ -366,7 +366,8 @@ static void sixlowpan_setup_params(FAR struct ieee802154_driver_s *ieee,
|
||||
|
||||
/* Set the source address to the node address assigned to the device */
|
||||
|
||||
rimeaddr_copy((struct rimeaddr_s *)¶ms->src_addr, &ieee->i_nodeaddr);
|
||||
rimeaddr_copy((struct rimeaddr_s *)¶ms->src_addr,
|
||||
&ieee->i_dev.d_mac.ieee802154);
|
||||
|
||||
/* Use short soruce address mode if so configured */
|
||||
|
||||
|
@ -614,7 +614,8 @@ void sixlowpan_compresshdr_hc06(FAR struct ieee802154_driver_s *ieee,
|
||||
|
||||
/* Compression compare with this nodes address (source) */
|
||||
|
||||
iphc1 |= compress_addr_64(ipv6->srcipaddr, &ieee->i_nodeaddr,
|
||||
iphc1 |= compress_addr_64(ipv6->srcipaddr,
|
||||
&ieee->i_dev.d_mac.ieee802154,
|
||||
SIXLOWPAN_IPHC_SAM_BIT);
|
||||
}
|
||||
|
||||
@ -624,7 +625,8 @@ void sixlowpan_compresshdr_hc06(FAR struct ieee802154_driver_s *ieee,
|
||||
ipv6->destipaddr[1] == 0 && ipv6->destipaddr[2] == 0 &&
|
||||
ipv6->destipaddr[3] == 0)
|
||||
{
|
||||
iphc1 |= compress_addr_64(ipv6->srcipaddr, &ieee->i_nodeaddr,
|
||||
iphc1 |= compress_addr_64(ipv6->srcipaddr,
|
||||
&ieee->i_dev.d_mac.ieee802154,
|
||||
SIXLOWPAN_IPHC_SAM_BIT);
|
||||
}
|
||||
else
|
||||
|
@ -129,7 +129,7 @@ void sixlowpan_compresshdr_hc1(FAR struct ieee802154_driver_s *ieee,
|
||||
|
||||
if (ipv6->vtc != 0x60 || ipv6->tcf != 0 || ipv6->flow != 0 ||
|
||||
!sixlowpan_islinklocal(ipv6->srcipaddr) ||
|
||||
!sixlowpan_ismacbased(ipv6->srcipaddr, &ieee->i_nodeaddr) ||
|
||||
!sixlowpan_ismacbased(ipv6->srcipaddr, &ieee->i_dev.d_mac.ieee802154) ||
|
||||
!sixlowpan_islinklocal(ipv6->destipaddr) ||
|
||||
!sixlowpan_ismacbased(ipv6->destipaddr, destmac) ||
|
||||
(ipv6->proto != IP_PROTO_ICMP6 && ipv6->proto != IP_PROTO_UDP &&
|
||||
|
@ -365,14 +365,14 @@ static int lo_ifup(FAR struct net_driver_s *dev)
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN_RIMEADDR_EXTENDED
|
||||
ninfo(" Node: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x PANID=%04x\n",
|
||||
priv->lo_ieee.i_nodeaddr.u8[0], priv->lo_ieee.i_nodeaddr.u8[1],
|
||||
priv->lo_ieee.i_nodeaddr.u8[2], priv->lo_ieee.i_nodeaddr.u8[3],
|
||||
priv->lo_ieee.i_nodeaddr.u8[4], priv->lo_ieee.i_nodeaddr.u8[5],
|
||||
priv->lo_ieee.i_nodeaddr.u8[6], priv->lo_ieee.i_nodeaddr.u8[7],
|
||||
dev->d_mac.ieee802154.u8[0], dev->d_mac.ieee802154.u8[1],
|
||||
dev->d_mac.ieee802154.u8[2], dev->d_mac.ieee802154.u8[3],
|
||||
dev->d_mac.ieee802154.u8[4], dev->d_mac.ieee802154.u8[5],
|
||||
dev->d_mac.ieee802154.u8[6], dev->d_mac.ieee802154.u8[7],
|
||||
priv->lo_ieee.i_panid);
|
||||
#else
|
||||
ninfo(" Node: %02x:%02x PANID=%04x\n",
|
||||
priv->lo_ieee.i_nodeaddr.u8[0], priv->lo_ieee.i_nodeaddr.u8[1],
|
||||
dev->d_mac.ieee802154.u8[0], dev->d_mac.ieee802154.u8[1],
|
||||
priv->lo_ieee.i_panid);
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user