diff --git a/TODO b/TODO index 79ca78ab3b1..fe150357f3c 100644 --- a/TODO +++ b/TODO @@ -1260,7 +1260,7 @@ o Network (net/, drivers/net) implementation. If we want to use IPv6 neighbor discovery, we could dispense - with the all MAC based addressing. But if we want to retain + with the all MAC based addressing. But if we want to retain the more compact MAC-based addressing, then we don't need IPv6 neighbor discovery. diff --git a/net/sixlowpan/README.txt b/net/sixlowpan/README.txt index 4031af925d0..775357260bc 100644 --- a/net/sixlowpan/README.txt +++ b/net/sixlowpan/README.txt @@ -3,16 +3,41 @@ The current 6LoWPAN implementation uses only link local, MAC-based addressing addressing (as discussed in more detail below). Thus if you know -the node addressing, then you know the IPv6 address (and vice-versa) +the node addressing, then you know the IPv6 address (and vice-versa). + +As a configuration option, the 6LoWPAN implementation will use either the +node's 2-byte short address or 8-byte extended address as the MAC address +that the IPv6 address is based on. This is determined by the configuration +setting CONFIG_NET_6LOWPAN_EXTENDEDADDR. By default, the 2-byte short +address is used for the IEEE802.15.4 MAC device's link layer address. If +this option is selected, then an 8-byte extended address will be used, +instead. + +All nodes operating on a network have unique, 8-byte extended address, +that was assigned before the network is configured. 6LoWPAN will use +either the extended address for direct communication within the PAN or +the short 2-byte address. The short 2-byte address, however, is allocated +by the PAN coordinator when the device associated. If short addresses are +used, the network cannot be brought up until is is associated. + +Node addressing is modified through IOCTL calls from application logic. +The network must be in the DOWN state when ever the node addressing is +modified. The modified node addresses will have no effect on the reported +IPv6 address until the network is brought to the UP state. The new IPv6 +MAC-based addresses are only instantiated when the network transitions +from the DOWN to UP state. + +IPv6 Neighbor Discovery +----------------------- IPv6 Neighbor Discovery is not supported. The current ICMPv6 and neighbor- -related logic only works with Ethernet MAC. For 6LoWPAN, a -new more conservative IPv6 neigbor discovery is provided by RFC 6775 which -is not currently suppored. With IPv6 neighbor discovery, any IPv6 address -may be associated with any short or extended address. In fact, that is the -whole purpose of the neighbor discover logic: It plays the same role as ARP -in IPv4; it ultimately just manages a neighbor table that, like the arp -table, provides the mapping between IP addresses and node addresses. +related logic only works with Ethernet MAC. For 6LoWPAN, a new more +conservative IPv6 neigbor discovery is provided by RFC 6775 which is not +currently supported. With IPv6 neighbor discovery, any IPv6 address may be +associated with any short or extended address. In fact, that is the whole +purpose of the neighbor discover logic: It plays the same role as ARP in +IPv4; it ultimately just manages a neighbor table that, like the arp table, +provides the mapping between IP addresses and node addresses. The NuttX, Contiki-based 6LoWPAN implementation circumvents the need for the neighbor discovery logic by using only MAC-based addressing, i.e., the diff --git a/wireless/ieee802154/mac802154_netdev.c b/wireless/ieee802154/mac802154_netdev.c index 15124347146..d30320efb7b 100644 --- a/wireless/ieee802154/mac802154_netdev.c +++ b/wireless/ieee802154/mac802154_netdev.c @@ -276,6 +276,8 @@ static int macnet_advertise(FAR struct net_driver_s *dev) } #else + uint8_t *saddr; + /* Get the saddr from the MAC */ memcpy(arg.ifr_name, dev->d_ifname, IFNAMSIZ); @@ -289,15 +291,8 @@ static int macnet_advertise(FAR struct net_driver_s *dev) } else { - union - { - uint16_t u16; - uint8_t u8[2]; - } u; - - u.u16 = arg.u.getreq.attrval.mac.saddr; - dev->d_mac.ieee802154.u8[0] = u.u8[0]; - dev->d_mac.ieee802154.u8[1] = u.u8[1]; + saddr = arg.u.getreq.attrval.mac.saddr; + IEEE802154_SADDRCOPY(dev->d_mac.ieee802154.u8, saddr); /* Set the IP address based on the saddr */ @@ -308,7 +303,7 @@ static int macnet_advertise(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] = u.u16; + dev->d_ipv6addr[7] = (uint16_t)saddr[0] << 8 | (uint16_t)saddr[1]; dev->d_ipv6addr[7] ^= 0x200; return OK; }