From 35232d49971ce75eca9df9f678a7098520619d32 Mon Sep 17 00:00:00 2001 From: Anthony Merlino Date: Sun, 16 Dec 2018 21:39:40 +0000 Subject: [PATCH] Merged in antmerlino/nuttx/uncompress-addr-fix (pull request #786) net/sixlowpan: Fixes decompression of ipaddr from MAC address. The logic used to populate the IP from the radio address should match sixlowpan_ipfromsaddr/sixlowpan_ipfromeaddr Approved-by: GregoryN --- net/sixlowpan/sixlowpan_hc06.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/net/sixlowpan/sixlowpan_hc06.c b/net/sixlowpan/sixlowpan_hc06.c index 8a8e87eb4e..aa1fe9468a 100644 --- a/net/sixlowpan/sixlowpan_hc06.c +++ b/net/sixlowpan/sixlowpan_hc06.c @@ -513,15 +513,22 @@ static void uncompress_addr(FAR const struct netdev_varaddr_s *addr, for (i = destndx; i < 8; i++) { + if (usemac) + { + ipaddr[i] = (uint16_t)srcptr[0] << 8 | (uint16_t)srcptr[1]; + } + else + { #ifdef CONFIG_ENDIAN_BIG - /* Preserve big-endian, network order */ + /* Preserve big-endian, network order */ - ipaddr[i] = (uint16_t)srcptr[0] << 8 | (uint16_t)srcptr[1]; + ipaddr[i] = (uint16_t)srcptr[0] << 8 | (uint16_t)srcptr[1]; #else - /* Preserve big-endian, network order */ + /* Preserve big-endian, network order */ - ipaddr[i] = (uint16_t)srcptr[1] << 8 | (uint16_t)srcptr[0]; + ipaddr[i] = (uint16_t)srcptr[1] << 8 | (uint16_t)srcptr[0]; #endif + } srcptr += 2; }