From 12002d1604d8b8265b8ff509db715980cdb734ee Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 16 Apr 2018 07:34:02 -0600 Subject: [PATCH] net/sixlowpan: When uncompressing link local addresses, the source of the address matters. Apparently address by byte reversed in IP addresses. But if the source of the address is the locally assigned address, bytes are not reversed. --- net/sixlowpan/sixlowpan_hc06.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/net/sixlowpan/sixlowpan_hc06.c b/net/sixlowpan/sixlowpan_hc06.c index 204cf69cbcd..39f0bd72d28 100644 --- a/net/sixlowpan/sixlowpan_hc06.c +++ b/net/sixlowpan/sixlowpan_hc06.c @@ -489,10 +489,21 @@ static void uncompress_addr(FAR const struct netdev_varaddr_s *addr, for (i = destndx; i < endndx; i++) { - /* Big-endian, network order */ +#ifndef CONFIG_BIG_ENDIAN + if (usemac) + { + /* Local address is already network order. Retain host order */ - ipaddr[i] = (uint16_t)srcptr[1] << 8 | (uint16_t)srcptr[0]; - srcptr += 2; + ipaddr[i] = (uint16_t)srcptr[0] << 8 | (uint16_t)srcptr[1]; + } + else +#endif + { + /* Big-endian, network order */ + + ipaddr[i] = (uint16_t)srcptr[1] << 8 | (uint16_t)srcptr[0]; + srcptr += 2; + } } /* Handle any remaining odd byte */