diff --git a/configs/sim/sixlowpan/defconfig b/configs/sim/sixlowpan/defconfig index 01751fb243..b3b1a72930 100644 --- a/configs/sim/sixlowpan/defconfig +++ b/configs/sim/sixlowpan/defconfig @@ -712,6 +712,7 @@ CONFIG_WIRELESS_IEEE802154=y CONFIG_IEEE802154_DEFAULT_EADDR=0x00fade00deadbeef CONFIG_MAC802154_HPWORK=y CONFIG_MAC802154_NTXDESC=3 +CONFIG_MAC802154_NNOTIF=3 CONFIG_IEEE802154_IND_PREALLOC=20 CONFIG_IEEE802154_IND_IRQRESERVE=10 # CONFIG_IEEE802154_MACDEV is not set diff --git a/include/nuttx/net/netdev.h b/include/nuttx/net/netdev.h index 18ea237945..7c34217ae9 100644 --- a/include/nuttx/net/netdev.h +++ b/include/nuttx/net/netdev.h @@ -3,7 +3,7 @@ * Defines architecture-specific device driver interfaces to the NuttX * network. * - * Copyright (C) 2007, 2009, 2011-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2011-2017 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Derived largely from portions of uIP with has a similar BSD-styple license: diff --git a/net/sixlowpan/sixlowpan_framelist.c b/net/sixlowpan/sixlowpan_framelist.c index ed6d2d82ed..dbd902a1cf 100644 --- a/net/sixlowpan/sixlowpan_framelist.c +++ b/net/sixlowpan/sixlowpan_framelist.c @@ -236,7 +236,7 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee, #endif int ret; - ninfo("buflen=%lu", (unsigned long)buflen); + ninfo("buflen=%lu\n", (unsigned long)buflen); /* Initialize global data. Locking the network guarantees that we have * exclusive use of the global values for intermediate calculations. diff --git a/net/sixlowpan/sixlowpan_hc06.c b/net/sixlowpan/sixlowpan_hc06.c index c6681b2724..99e71d860f 100644 --- a/net/sixlowpan/sixlowpan_hc06.c +++ b/net/sixlowpan/sixlowpan_hc06.c @@ -303,7 +303,7 @@ static void uncompress_addr(FAR net_ipv6addr_t ipaddr, uint8_t const prefix[], uint8_t prefcount = prefpost >> 4; uint8_t postcount = prefpost & 0x0f; - /* Full nibble 15 => 16 */ + /* The value 16 is encoded as 0xf in the 4 bit-fields. */ prefcount = prefcount == 15 ? 16 : prefcount; postcount = postcount == 15 ? 16 : postcount; @@ -758,7 +758,7 @@ void sixlowpan_compresshdr_hc06(FAR struct ieee802154_driver_s *ieee, FAR struct udp_hdr_s *udp = (FAR struct udp_hdr_s *)((FAR uint8_t *)ipv6 + IPv6_HDRLEN); - ninfo("Uncompressed UDP ports on send side: srcport=%04x destport=%04x\n", + ninfo("Uncompressed UDP ports: srcport=%04x destport=%04x\n", ntohs(udp->srcport), ntohs(udp->destport)); /* Mask out the last 4 bits can be used as a mask */ @@ -770,7 +770,7 @@ void sixlowpan_compresshdr_hc06(FAR struct ieee802154_driver_s *ieee, *g_hc06ptr = SIXLOWPAN_NHC_UDP_CS_P_11; - ninfo("Remove 12b of both source & dest with prefix 0xfob\n"); + ninfo("Remove 12b of both source & dest with prefix 0xf0b*\n"); *(g_hc06ptr + 1) = (uint8_t)((ntohs(udp->srcport) - SIXLOWPAN_UDP_4_BIT_PORT_MIN) << 4) + diff --git a/net/sixlowpan/sixlowpan_utils.c b/net/sixlowpan/sixlowpan_utils.c index 5dde9106a5..2ed73d609b 100644 --- a/net/sixlowpan/sixlowpan_utils.c +++ b/net/sixlowpan/sixlowpan_utils.c @@ -156,7 +156,8 @@ bool sixlowpan_issaddrbased(const net_ipv6addr_t ipaddr, { FAR const uint8_t *byteptr = saddr->u8; - return (ipaddr[5] == HTONS(0x00ff) && ipaddr[6] == HTONS(0xfe00) && + return (ipaddr[5] == HTONS(0x00ff) && + ipaddr[6] == HTONS(0xfe00) && ipaddr[7] == (GETUINT16(byteptr, 0) ^ 0x0200)); } diff --git a/wireless/ieee802154/mac802154_loopback.c b/wireless/ieee802154/mac802154_loopback.c index 3e3b7c1123..26c8879a0b 100644 --- a/wireless/ieee802154/mac802154_loopback.c +++ b/wireless/ieee802154/mac802154_loopback.c @@ -190,6 +190,12 @@ static int lo_req_data(FAR struct ieee802154_driver_s *netdev, #ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR static void lo_addr2ip(FAR struct net_driver_s *dev) { + /* Set the MAC address as the eaddr */ + + IEEE802154_EADDRCOPY(dev->d_mac.ieee802154.u8, g_eaddr); + + /* Set the IP address based on the eaddr */ + dev->d_ipv6addr[0] = HTONS(0xfe80); dev->d_ipv6addr[1] = 0; dev->d_ipv6addr[2] = 0; @@ -199,10 +205,18 @@ static void lo_addr2ip(FAR struct net_driver_s *dev) dev->d_ipv6addr[6] = (uint16_t)g_eaddr[4] << 8 | (uint16_t)g_eaddr[5]; dev->d_ipv6addr[7] = (uint16_t)g_eaddr[6] << 8 | (uint16_t)g_eaddr[6]; dev->d_ipv6addr[4] ^= 0x200; + + memcpy(dev->d_mac.ieee802154, g_eaddr, IEEE802154_EADDRSIZE); } #else static void lo_addr2ip(FAR struct net_driver_s *dev) { + /* Set the MAC address as the saddr */ + + IEEE802154_SADDRCOPY(dev->d_mac.ieee802154.u8, g_saddr); + + /* Set the IP address based on the saddr */ + dev->d_ipv6addr[0] = HTONS(0xfe80); dev->d_ipv6addr[1] = 0; dev->d_ipv6addr[2] = 0; diff --git a/wireless/ieee802154/mac802154_netdev.c b/wireless/ieee802154/mac802154_netdev.c index 6c062e745f..75b777e20b 100644 --- a/wireless/ieee802154/mac802154_netdev.c +++ b/wireless/ieee802154/mac802154_netdev.c @@ -258,11 +258,13 @@ static int macnet_advertise(FAR struct net_driver_s *dev) } else { - /* Set the IP address based on the eaddr */ + /* Set the MAC address as the eaddr */ eaddr = arg.u.getreq.attrval.mac.eaddr; IEEE802154_EADDRCOPY(dev->d_mac.ieee802154.u8, eaddr); + /* Set the IP address based on the eaddr */ + dev->d_ipv6addr[0] = HTONS(0xfe80); dev->d_ipv6addr[1] = 0; dev->d_ipv6addr[2] = 0; @@ -291,6 +293,8 @@ static int macnet_advertise(FAR struct net_driver_s *dev) } else { + /* Set the MAC address as the saddr */ + saddr = arg.u.getreq.attrval.mac.saddr; IEEE802154_SADDRCOPY(dev->d_mac.ieee802154.u8, saddr);