Merged in antmerlino/nuttx/sixlowpan-removeconversions (pull request #997)
ieee802154/sixlowpan: Removes unnecessary conversions that were happening due to a misunderstanding of byte ordering with EUI-64 # Conflicts: # drivers/wireless/ieee802154/xbee/xbee_netdev.c Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
parent
223722d6d3
commit
fc1780d63e
@ -261,6 +261,11 @@ static int xbeenet_set_ipaddress(FAR struct net_driver_s *dev)
|
||||
union ieee802154_macarg_u arg;
|
||||
int ret;
|
||||
|
||||
dev->d_ipv6addr[0] = HTONS(CONFIG_XBEE_DEFAULT_PREFIX_0);
|
||||
dev->d_ipv6addr[1] = HTONS(CONFIG_XBEE_DEFAULT_PREFIX_1);
|
||||
dev->d_ipv6addr[2] = HTONS(CONFIG_XBEE_DEFAULT_PREFIX_2);
|
||||
dev->d_ipv6addr[3] = HTONS(CONFIG_XBEE_DEFAULT_PREFIX_3);
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
|
||||
uint8_t *eaddr;
|
||||
|
||||
@ -279,37 +284,21 @@ static int xbeenet_set_ipaddress(FAR struct net_driver_s *dev)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Set the MAC address as the eaddr */
|
||||
|
||||
eaddr = arg.getreq.attrval.mac.eaddr;
|
||||
|
||||
/* Network layers expect address in Network Order (Big Endian) */
|
||||
|
||||
dev->d_mac.radio.nv_addr[0] = eaddr[7];
|
||||
dev->d_mac.radio.nv_addr[1] = eaddr[6];
|
||||
dev->d_mac.radio.nv_addr[2] = eaddr[5];
|
||||
dev->d_mac.radio.nv_addr[3] = eaddr[4];
|
||||
dev->d_mac.radio.nv_addr[4] = eaddr[3];
|
||||
dev->d_mac.radio.nv_addr[5] = eaddr[2];
|
||||
dev->d_mac.radio.nv_addr[6] = eaddr[1];
|
||||
dev->d_mac.radio.nv_addr[7] = eaddr[0];
|
||||
|
||||
IEEE802154_EADDRCOPY(dev->d_mac.radio.nv_addr, arg.getreq.attrval.mac.eaddr);
|
||||
dev->d_mac.radio.nv_addrlen = IEEE802154_EADDRSIZE;
|
||||
|
||||
/* Set the IP address based on the eaddr */
|
||||
|
||||
dev->d_ipv6addr[0] = HTONS(0xfe80);
|
||||
dev->d_ipv6addr[1] = 0;
|
||||
dev->d_ipv6addr[2] = 0;
|
||||
dev->d_ipv6addr[3] = 0;
|
||||
dev->d_ipv6addr[4] = HTONS((uint16_t)eaddr[7] << 8 | (uint16_t)eaddr[6]);
|
||||
dev->d_ipv6addr[5] = HTONS((uint16_t)eaddr[5] << 8 | (uint16_t)eaddr[4]);
|
||||
dev->d_ipv6addr[6] = HTONS((uint16_t)eaddr[3] << 8 | (uint16_t)eaddr[2]);
|
||||
dev->d_ipv6addr[7] = HTONS((uint16_t)eaddr[1] << 8 | (uint16_t)eaddr[0]);
|
||||
dev->d_ipv6addr[4] = HTONS((uint16_t)eaddr[0] << 8 | (uint16_t)eaddr[1]);
|
||||
dev->d_ipv6addr[5] = HTONS((uint16_t)eaddr[2] << 8 | (uint16_t)eaddr[3]);
|
||||
dev->d_ipv6addr[6] = HTONS((uint16_t)eaddr[4] << 8 | (uint16_t)eaddr[5]);
|
||||
dev->d_ipv6addr[7] = HTONS((uint16_t)eaddr[6] << 8 | (uint16_t)eaddr[7]);
|
||||
|
||||
/* Invert the U/L bit */
|
||||
|
||||
dev->d_ipv6addr[4] ^= HTONS(0x0200);
|
||||
|
||||
dev->d_mac.radio.nv_addrlen = IEEE802154_EADDRSIZE;
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -344,14 +333,10 @@ static int xbeenet_set_ipaddress(FAR struct net_driver_s *dev)
|
||||
|
||||
/* Set the IP address based on the saddr */
|
||||
|
||||
dev->d_ipv6addr[0] = HTONS(0xfe80);
|
||||
dev->d_ipv6addr[1] = 0;
|
||||
dev->d_ipv6addr[2] = 0;
|
||||
dev->d_ipv6addr[3] = 0;
|
||||
dev->d_ipv6addr[4] = 0;
|
||||
dev->d_ipv6addr[5] = HTONS(0x00ff);
|
||||
dev->d_ipv6addr[6] = HTONS(0xfe00);
|
||||
dev->d_ipv6addr[7] = HTONS((uint16_t)saddr[1] << 8 | (uint16_t)saddr[0]);
|
||||
dev->d_ipv6addr[7] = HTONS((uint16_t)saddr[0] << 8 | (uint16_t)saddr[1]);
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
@ -206,17 +206,7 @@ int sixlowpan_meta_data(FAR struct radio_driver_s *radio,
|
||||
/* Extended destination address mode */
|
||||
|
||||
meta->destaddr.mode = IEEE802154_ADDRMODE_EXTENDED;
|
||||
|
||||
/* 802.15.4 layer expects address in Little-Endian byte order */
|
||||
|
||||
meta->destaddr.eaddr[0] = pktmeta->dest.nm_addr[7];
|
||||
meta->destaddr.eaddr[1] = pktmeta->dest.nm_addr[6];
|
||||
meta->destaddr.eaddr[2] = pktmeta->dest.nm_addr[5];
|
||||
meta->destaddr.eaddr[3] = pktmeta->dest.nm_addr[4];
|
||||
meta->destaddr.eaddr[4] = pktmeta->dest.nm_addr[3];
|
||||
meta->destaddr.eaddr[5] = pktmeta->dest.nm_addr[2];
|
||||
meta->destaddr.eaddr[6] = pktmeta->dest.nm_addr[1];
|
||||
meta->destaddr.eaddr[7] = pktmeta->dest.nm_addr[0];
|
||||
sixlowpan_eaddrcopy(&meta->destaddr.eaddr, pktmeta->dest.nm_addr);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -703,20 +703,8 @@ int sixlowpan_extract_srcaddr(FAR struct radio_driver_s *radio,
|
||||
else
|
||||
{
|
||||
srcaddr->nv_addrlen = NET_6LOWPAN_EADDRSIZE;
|
||||
|
||||
/* MAC802154 gives us Extended Address in Little Endinan Order, but
|
||||
* we need it in Network Order.
|
||||
*/
|
||||
|
||||
srcaddr->nv_addr[0] = ind->src.eaddr[7];
|
||||
srcaddr->nv_addr[1] = ind->src.eaddr[6];
|
||||
srcaddr->nv_addr[2] = ind->src.eaddr[5];
|
||||
srcaddr->nv_addr[3] = ind->src.eaddr[4];
|
||||
srcaddr->nv_addr[4] = ind->src.eaddr[3];
|
||||
srcaddr->nv_addr[5] = ind->src.eaddr[2];
|
||||
srcaddr->nv_addr[6] = ind->src.eaddr[1];
|
||||
srcaddr->nv_addr[7] = ind->src.eaddr[0];
|
||||
}
|
||||
memcpy(srcaddr->nv_addr, ind->src.eaddr, NET_6LOWPAN_EADDRSIZE);
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
@ -788,19 +776,7 @@ int sixlowpan_extract_destaddr(FAR struct radio_driver_s *radio,
|
||||
else
|
||||
{
|
||||
destaddr->nv_addrlen = NET_6LOWPAN_EADDRSIZE;
|
||||
|
||||
/* MAC802154 gives us Extended Address in Little Endinan Order, but
|
||||
* we need it in Network Order.
|
||||
*/
|
||||
|
||||
destaddr->nv_addr[0] = ind->dest.eaddr[7];
|
||||
destaddr->nv_addr[1] = ind->dest.eaddr[6];
|
||||
destaddr->nv_addr[2] = ind->dest.eaddr[5];
|
||||
destaddr->nv_addr[3] = ind->dest.eaddr[4];
|
||||
destaddr->nv_addr[4] = ind->dest.eaddr[3];
|
||||
destaddr->nv_addr[5] = ind->dest.eaddr[2];
|
||||
destaddr->nv_addr[6] = ind->dest.eaddr[1];
|
||||
destaddr->nv_addr[7] = ind->dest.eaddr[0];
|
||||
memcpy(destaddr->nv_addr, ind->dest.eaddr, NET_6LOWPAN_EADDRSIZE);
|
||||
}
|
||||
|
||||
return OK;
|
||||
|
@ -225,10 +225,10 @@ static void lo_addr2ip(FAR struct net_driver_s *dev)
|
||||
dev->d_ipv6addr[1] = 0;
|
||||
dev->d_ipv6addr[2] = 0;
|
||||
dev->d_ipv6addr[3] = 0;
|
||||
dev->d_ipv6addr[4] = HTONS((uint16_t)g_eaddr[7] << 8 | (uint16_t)g_eaddr[6]);
|
||||
dev->d_ipv6addr[5] = HTONS((uint16_t)g_eaddr[5] << 8 | (uint16_t)g_eaddr[4]);
|
||||
dev->d_ipv6addr[6] = HTONS((uint16_t)g_eaddr[3] << 8 | (uint16_t)g_eaddr[2]);
|
||||
dev->d_ipv6addr[7] = HTONS((uint16_t)g_eaddr[1] << 8 | (uint16_t)g_eaddr[0]);
|
||||
dev->d_ipv6addr[4] = HTONS((uint16_t)g_eaddr[0] << 8 | (uint16_t)g_eaddr[1]);
|
||||
dev->d_ipv6addr[5] = HTONS((uint16_t)g_eaddr[2] << 8 | (uint16_t)g_eaddr[3]);
|
||||
dev->d_ipv6addr[6] = HTONS((uint16_t)g_eaddr[4] << 8 | (uint16_t)g_eaddr[5]);
|
||||
dev->d_ipv6addr[7] = HTONS((uint16_t)g_eaddr[6] << 8 | (uint16_t)g_eaddr[7]);
|
||||
|
||||
/* Invert the U/L bit */
|
||||
|
||||
@ -253,7 +253,7 @@ static void lo_addr2ip(FAR struct net_driver_s *dev)
|
||||
dev->d_ipv6addr[4] = 0;
|
||||
dev->d_ipv6addr[5] = HTONS(0x00ff);
|
||||
dev->d_ipv6addr[6] = HTONS(0xfe00);
|
||||
dev->d_ipv6addr[7] = HTONS((uint16_t)g_saddr[1] << 8 | (uint16_t)g_saddr[0]);
|
||||
dev->d_ipv6addr[7] = HTONS((uint16_t)g_saddr[0] << 8 | (uint16_t)g_saddr[1]);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
@ -258,7 +258,6 @@ static int macnet_update_nvaddr(FAR struct net_driver_s *dev)
|
||||
priv = (FAR struct macnet_driver_s *)dev->d_private;
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
|
||||
uint8_t *eaddr;
|
||||
|
||||
/* Get the eaddr from the MAC */
|
||||
|
||||
@ -272,21 +271,7 @@ static int macnet_update_nvaddr(FAR struct net_driver_s *dev)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Set the MAC address as the eaddr */
|
||||
|
||||
eaddr = arg.getreq.attrval.mac.eaddr;
|
||||
|
||||
/* Network layers expect address in Network Order (Big Endian) */
|
||||
|
||||
dev->d_mac.radio.nv_addr[0] = eaddr[7];
|
||||
dev->d_mac.radio.nv_addr[1] = eaddr[6];
|
||||
dev->d_mac.radio.nv_addr[2] = eaddr[5];
|
||||
dev->d_mac.radio.nv_addr[3] = eaddr[4];
|
||||
dev->d_mac.radio.nv_addr[4] = eaddr[3];
|
||||
dev->d_mac.radio.nv_addr[5] = eaddr[2];
|
||||
dev->d_mac.radio.nv_addr[6] = eaddr[1];
|
||||
dev->d_mac.radio.nv_addr[7] = eaddr[0];
|
||||
|
||||
IEEE802154_EADDRCOPY(dev->d_mac.radio.nv_addr, arg.getreq.attrval.mac.eaddr);
|
||||
dev->d_mac.radio.nv_addrlen = IEEE802154_EADDRSIZE;
|
||||
return OK;
|
||||
}
|
||||
@ -740,10 +725,10 @@ static int macnet_ifup(FAR struct net_driver_s *dev)
|
||||
dev->d_ipv6addr[3] = HTONS(CONFIG_IEEE802154_NETDEV_DEFAULT_PREFIX_3);
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
|
||||
dev->d_ipv6addr[4] = HTONS((uint16_t)nvaddr[7] << 8 | (uint16_t)nvaddr[6]);
|
||||
dev->d_ipv6addr[5] = HTONS((uint16_t)nvaddr[5] << 8 | (uint16_t)nvaddr[4]);
|
||||
dev->d_ipv6addr[6] = HTONS((uint16_t)nvaddr[3] << 8 | (uint16_t)nvaddr[2]);
|
||||
dev->d_ipv6addr[7] = HTONS((uint16_t)nvaddr[1] << 8 | (uint16_t)nvaddr[0]);
|
||||
dev->d_ipv6addr[4] = HTONS((uint16_t)nvaddr[0] << 8 | (uint16_t)nvaddr[1]);
|
||||
dev->d_ipv6addr[5] = HTONS((uint16_t)nvaddr[2] << 8 | (uint16_t)nvaddr[3]);
|
||||
dev->d_ipv6addr[6] = HTONS((uint16_t)nvaddr[4] << 8 | (uint16_t)nvaddr[5]);
|
||||
dev->d_ipv6addr[7] = HTONS((uint16_t)nvaddr[6] << 8 | (uint16_t)nvaddr[7]);
|
||||
|
||||
/* Invert the U/L bit */
|
||||
|
||||
@ -753,7 +738,7 @@ static int macnet_ifup(FAR struct net_driver_s *dev)
|
||||
dev->d_ipv6addr[4] = 0;
|
||||
dev->d_ipv6addr[5] = HTONS(0x00ff);
|
||||
dev->d_ipv6addr[6] = HTONS(0xfe00);
|
||||
dev->d_ipv6addr[7] = HTONS((uint16_t)nvaddr[1] << 8 | (uint16_t)nvaddr[0]);
|
||||
dev->d_ipv6addr[7] = HTONS((uint16_t)nvaddr[0] << 8 | (uint16_t)nvaddr[1]);
|
||||
#endif
|
||||
|
||||
wlinfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
|
||||
|
Loading…
Reference in New Issue
Block a user