From 35a54d7a1eeca6b0153e60ba6b2b6deb0a1814df Mon Sep 17 00:00:00 2001 From: Anthony Merlino Date: Mon, 20 Nov 2017 14:36:21 -0600 Subject: [PATCH] net/sixlowpan: The logic that extracts interface identifier from the IP address needs to be generalized to handle cases where the address is not a link local address. --- net/sixlowpan/sixlowpan_utils.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/net/sixlowpan/sixlowpan_utils.c b/net/sixlowpan/sixlowpan_utils.c index f4c27dc530d..a020e5c9ca6 100644 --- a/net/sixlowpan/sixlowpan_utils.c +++ b/net/sixlowpan/sixlowpan_utils.c @@ -250,14 +250,15 @@ int sixlowpan_destaddrfromip(FAR struct radio_driver_s *radio, return OK; } - /* Otherwise, the destination MAC address is encoded in the IP address */ + /* Otherwise, the destination MAC address is encoded in the IP address */ - /* Check for compressible link-local address. - * REVISIT: This should not restrict us to link-local addresses. - */ + /* If the address is link-local, or matches the prefix of the local address, + * the interface identifier can be extracted from the lower bits of the address. + */ - if (ipaddr[0] != HTONS(0xfe80) || ipaddr[1] != 0 || - ipaddr[2] != 0 || ipaddr[3] != 0) + if (!sixlowpan_islinklocal(ipaddr) && + !net_ipv6addr_maskcmp(radio->r_dev.d_ipv6addr, ipaddr, + radio->r_dev.d_ipv6netmask)) { return -EADDRNOTAVAIL; }