From b7c55660cbaf579bcd56e5a1f8701ed9ee2b9a7d Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 5 Apr 2017 13:04:22 -0600 Subject: [PATCH] 6loWPAN: Correct more address manipulations. --- configs/sim/sixlowpan/defconfig | 6 +++--- net/sixlowpan/sixlowpan_utils.c | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/configs/sim/sixlowpan/defconfig b/configs/sim/sixlowpan/defconfig index a71e704bfe..8a5d9f766d 100644 --- a/configs/sim/sixlowpan/defconfig +++ b/configs/sim/sixlowpan/defconfig @@ -892,7 +892,7 @@ CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_4=0x0000 CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_5=0x0000 CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_6=0x00ff CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_7=0xfe00 -CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_8=0x3234 +CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_8=0x1034 CONFIG_EXAMPLES_NSH=y # CONFIG_EXAMPLES_NULL is not set # CONFIG_EXAMPLES_NX is not set @@ -1100,7 +1100,7 @@ CONFIG_NSH_IPv6ADDR_4=0x0000 CONFIG_NSH_IPv6ADDR_5=0x0000 CONFIG_NSH_IPv6ADDR_6=0x00ff CONFIG_NSH_IPv6ADDR_7=0xfe00 -CONFIG_NSH_IPv6ADDR_8=0x8bcd +CONFIG_NSH_IPv6ADDR_8=0xa9cd # # Router IPv6 address @@ -1112,7 +1112,7 @@ CONFIG_NSH_DRIPv6ADDR_4=0x0000 CONFIG_NSH_DRIPv6ADDR_5=0x0000 CONFIG_NSH_DRIPv6ADDR_6=0x00ff CONFIG_NSH_DRIPv6ADDR_7=0xfe00 -CONFIG_NSH_DRIPv6ADDR_8=0x3234 +CONFIG_NSH_DRIPv6ADDR_8=0x1034 # # IPv6 Network mask diff --git a/net/sixlowpan/sixlowpan_utils.c b/net/sixlowpan/sixlowpan_utils.c index c7cf3887a0..fc322ec38e 100644 --- a/net/sixlowpan/sixlowpan_utils.c +++ b/net/sixlowpan/sixlowpan_utils.c @@ -73,8 +73,8 @@ * * 128 112 96 80 64 48 32 16 * ---- ---- ---- ---- ---- ---- ---- ---- - * fe80 0000 0000 0000 0000 00ff fe00 xxxx 2-byte Rime address - * fe80 0000 0000 0000 xxxx xxxx xxxx xxxx 8-byte Rime address + * fe80 0000 0000 0000 0000 00ff fe00 xxxx 2-byte Rime address IEEE 48-bit MAC + * fe80 0000 0000 0000 xxxx xxxx xxxx xxxx 8-byte Rime address IEEE EUI-64 * ****************************************************************************/ @@ -107,8 +107,8 @@ void sixlowpan_ipfromrime(FAR const struct rimeaddr_s *rime, * * 128 112 96 80 64 48 32 16 * ---- ---- ---- ---- ---- ---- ---- ---- - * fe80 0000 0000 0000 0000 00ff fe00 xxxx 2-byte Rime address - * fe80 0000 0000 0000 xxxx xxxx xxxx xxxx 8-byte Rime address + * fe80 0000 0000 0000 0000 00ff fe00 xxxx 2-byte Rime address IEEE 48-bit MAC + * fe80 0000 0000 0000 xxxx xxxx xxxx xxxx 8-byte Rime address IEEE EUI-64 * ****************************************************************************/ @@ -135,8 +135,8 @@ void sixlowpan_rimefromip(const net_ipv6addr_t ipaddr, * * 128 112 96 80 64 48 32 16 * ---- ---- ---- ---- ---- ---- ---- ---- - * fe80 0000 0000 0000 0000 00ff fe00 xxxx 2-byte Rime address - * fe80 0000 0000 0000 xxxx xxxx xxxx xxxx 8-byte Rime address + * fe80 0000 0000 0000 0000 00ff fe00 xxxx 2-byte Rime address IEEE 48-bit MAC + * fe80 0000 0000 0000 xxxx xxxx xxxx xxxx 8-byte Rime address IEEE EUI-64 * ****************************************************************************/ @@ -146,13 +146,13 @@ bool sixlowpan_ismacbased(const net_ipv6addr_t ipaddr, FAR const uint8_t *rimeptr = rime->u8; #if CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 2 - return ((ipaddr[4] == htons((GETINT16(rimeptr, 0) ^ 0x0200))) && - ipaddr[5] == 0 && ipaddr[6] == 0 && ipaddr[7] == 0); + return (ipaddr[5] == HTONS(0x00ff) && ipaddr[6] == HTONS(0xfe00) && + ipaddr[7] == htons((GETINT16(rimeptr, 0) ^ 0x0200))); #else /* CONFIG_NET_6LOWPAN_RIMEADDR_SIZE == 8 */ - return ((ipaddr[4] == htons((GETINT16(rimeptr, 0) ^ 0x0200))) && - ipaddr[5] == GETINT16(rimeptr, 2) && - ipaddr[6] == GETINT16(rimeptr, 4) && - ipaddr[7] == GETINT16(rimeptr, 6)); + return (ipaddr[4] == htons((GETINT16(rimeptr, 0) ^ 0x0200)) && + ipaddr[5] == GETINT16(rimeptr, 2) && + ipaddr[6] == GETINT16(rimeptr, 4) && + ipaddr[7] == GETINT16(rimeptr, 6)); #endif }