From 4520d31d3d7c664125834ee8b37d54d18c865b4e Mon Sep 17 00:00:00 2001 From: Joakim Gebart Date: Tue, 3 Mar 2015 19:19:42 +0100 Subject: [PATCH 1/3] net-if: Set U/L bit in short address to local. --- sys/net/link_layer/net_if/net_if.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/net/link_layer/net_if/net_if.c b/sys/net/link_layer/net_if/net_if.c index 74776ca1f..a1788f395 100644 --- a/sys/net/link_layer/net_if/net_if.c +++ b/sys/net/link_layer/net_if/net_if.c @@ -429,7 +429,9 @@ int net_if_get_eui64(net_if_eui64_t *eui64, int if_id, int force_generation) } /* RFC 6282 Section 3.2.2 / RFC 2464 Section 4 */ - eui64->uint32[0] = HTONL(0x000000ff); + /* Since this is a short address, which is never globally unique, we set + * the local/universal bit to 1. */ + eui64->uint32[0] = HTONL(0x020000ff); eui64->uint16[2] = HTONS(0xfe00); if (sizeof(hwaddr) == 2) { From 2aa031e7c71b87fc9839340cb83d641eeeb4f8c7 Mon Sep 17 00:00:00 2001 From: Joakim Gebart Date: Tue, 3 Mar 2015 19:51:58 +0100 Subject: [PATCH 2/3] sixlowpan: Set U/L bit in short address to local. --- sys/net/network_layer/sixlowpan/lowpan.c | 4 ++-- sys/net/network_layer/sixlowpan/mac.c | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sys/net/network_layer/sixlowpan/lowpan.c b/sys/net/network_layer/sixlowpan/lowpan.c index c8e4803e3..e1d594d65 100644 --- a/sys/net/network_layer/sixlowpan/lowpan.c +++ b/sys/net/network_layer/sixlowpan/lowpan.c @@ -895,10 +895,10 @@ uint8_t lowpan_iphc_encoding(int if_id, const uint8_t *dest, int dest_len, if (!net_if_get_eui64(&own_iid, if_id, 0)) { return 1; } - - own_iid.uint8[0] ^= 0x02; } + own_iid.uint8[0] ^= 0x02; + ipv6_buf = ipv6_buf_extra; memset(&lowpan_iphc, 0, 2); diff --git a/sys/net/network_layer/sixlowpan/mac.c b/sys/net/network_layer/sixlowpan/mac.c index 995722588..822c3f49f 100644 --- a/sys/net/network_layer/sixlowpan/mac.c +++ b/sys/net/network_layer/sixlowpan/mac.c @@ -54,7 +54,9 @@ static uint8_t macdsn; static inline void mac_frame_short_to_eui64(net_if_eui64_t *eui64, uint8_t *frame_short) { - eui64->uint32[0] = HTONL(0x000000ff); + /* Since this is a short address, which is never globally unique, we set + * the local/universal bit to 1. */ + eui64->uint32[0] = HTONL(0x020000ff); eui64->uint16[2] = HTONS(0xfe00); eui64->uint8[6] = frame_short[1]; eui64->uint8[7] = frame_short[0]; From d6242360daaf5670b9483419ae463e4678de587c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cenk=20G=C3=BCndo=C4=9Fan?= Date: Mon, 2 Mar 2015 18:02:01 +0100 Subject: [PATCH 3/3] net_if: proper u/l-bit inversion for short addresses --- sys/net/link_layer/net_if/net_if.c | 15 +-------------- sys/net/network_layer/sixlowpan/ip.c | 8 -------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/sys/net/link_layer/net_if/net_if.c b/sys/net/link_layer/net_if/net_if.c index a1788f395..1f1cdd820 100644 --- a/sys/net/link_layer/net_if/net_if.c +++ b/sys/net/link_layer/net_if/net_if.c @@ -433,20 +433,7 @@ int net_if_get_eui64(net_if_eui64_t *eui64, int if_id, int force_generation) * the local/universal bit to 1. */ eui64->uint32[0] = HTONL(0x020000ff); eui64->uint16[2] = HTONS(0xfe00); - - if (sizeof(hwaddr) == 2) { - eui64->uint16[3] = HTONS(hwaddr); - } - else if (sizeof(hwaddr) == 1) { - eui64->uint8[6] = 0; - eui64->uint8[7] = (uint8_t)hwaddr; - } - else { - DEBUG("Error on EUI-64 generation: do not know what to do with " - "hardware address of length %d\n", sizeof(hwaddr)); - return 0; - } - + eui64->uint16[3] = HTONS(hwaddr); } return 1; diff --git a/sys/net/network_layer/sixlowpan/ip.c b/sys/net/network_layer/sixlowpan/ip.c index 7372042c3..9cffd8396 100644 --- a/sys/net/network_layer/sixlowpan/ip.c +++ b/sys/net/network_layer/sixlowpan/ip.c @@ -690,15 +690,7 @@ ipv6_addr_t *ipv6_addr_set_by_eui64(ipv6_addr_t *out, int if_id, if (net_if_get_eui64((net_if_eui64_t *) &out->uint8[8], if_id, force_generation)) { -#ifdef MODULE_SIXLOWPAN - - if (!sixlowpan_lowpan_eui64_to_short_addr((net_if_eui64_t *)&out->uint8[8])) { - out->uint8[8] ^= 0x02; - } - -#else out->uint8[8] ^= 0x02; -#endif return out; } else {