diff options
-rw-r--r-- | clients/net-snk/app/netlib/icmpv6.c | 4 | ||||
-rw-r--r-- | clients/net-snk/app/netlib/ipv6.h | 7 |
2 files changed, 9 insertions, 2 deletions
diff --git a/clients/net-snk/app/netlib/icmpv6.c b/clients/net-snk/app/netlib/icmpv6.c index be6cc11..940b834 100644 --- a/clients/net-snk/app/netlib/icmpv6.c +++ b/clients/net-snk/app/netlib/icmpv6.c @@ -78,8 +78,8 @@ handle_prefixoption (uint8_t *option) prefix_option = (struct option_prefix *) option; memcpy( &(prefix.addr), &(prefix_option->prefix.addr), IPV6_ADDR_LENGTH); - /* Link-local adresses in RAs are nonsense */ - if ( (IPV6_LL_PREFIX & (prefix_option->prefix.part.prefix)) == IPV6_LL_PREFIX ) + /* Link-local adresses in RAs are nonsense */ + if (ip6_is_linklocal(&prefix)) return; if (prefix_option->preferred_lifetime > prefix_option->valid_lifetime) diff --git a/clients/net-snk/app/netlib/ipv6.h b/clients/net-snk/app/netlib/ipv6.h index b496364..963a1b0 100644 --- a/clients/net-snk/app/netlib/ipv6.h +++ b/clients/net-snk/app/netlib/ipv6.h @@ -26,6 +26,7 @@ #define IPV6_ADDR_LENGTH 16 /* Size of IPv6 adress in bytes */ #define IPV6_LL_PREFIX 0xFE80000000000000ULL +#define IPV6_LL_PREFIX_MASK 0xFFC0000000000000ULL #define IPV6_SOLIC_NODE_PREFIX 0xFF02000000000000ULL #define IPV6_SOLIC_NODE_IFACE_ID 0x00000001FF000000ULL @@ -179,6 +180,12 @@ void * ip6_prefix2addr (ip6_addr_t prefix); /* Compare IPv6 adresses */ int8_t ip6_cmp( ip6_addr_t *ip_1, ip6_addr_t *ip_2 ); +/* Check if it is a link-local address */ +static inline int ip6_is_linklocal(ip6_addr_t *ip) +{ + return (ip->part.prefix & IPV6_LL_PREFIX_MASK) == IPV6_LL_PREFIX; +} + /* Check if prefix is already in our list */ int8_t unknown_prefix (ip6_addr_t *ip); |