From 6f3f43d9304e2a9b9b62e1df32496c7609089fe1 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 5 Feb 2015 05:43:57 -0600 Subject: [PATCH] IPv6: Add a netmaks for the local link address --- include/nuttx/net/ip.h | 9 +++++---- net/devif/devif_initialize.c | 9 +++++++-- net/icmpv6/icmpv6_autoconfig.c | 6 +++++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/include/nuttx/net/ip.h b/include/nuttx/net/ip.h index 06aa7c9888..c46c7f00a0 100644 --- a/include/nuttx/net/ip.h +++ b/include/nuttx/net/ip.h @@ -220,16 +220,17 @@ extern "C" /* Well-known IP addresses */ #ifdef CONFIG_NET_IPv4 -EXTERN const in_addr_t g_ipv4_alloneaddr; -EXTERN const in_addr_t g_ipv4_allzeroaddr; +EXTERN const in_addr_t g_ipv4_alloneaddr; /* An address of all ones */ +EXTERN const in_addr_t g_ipv4_allzeroaddr; /* An address of all zeroes */ #endif #ifdef CONFIG_NET_IPv6 -EXTERN const net_ipv6addr_t g_ipv6_alloneaddr; -EXTERN const net_ipv6addr_t g_ipv6_allzeroaddr; +EXTERN const net_ipv6addr_t g_ipv6_alloneaddr; /* An address of all ones */ +EXTERN const net_ipv6addr_t g_ipv6_allzeroaddr; /* An address of all zeroes */ #ifdef CONFIG_NET_ICMPv6_AUTOCONF EXTERN const net_ipv6addr_t g_ipv6_allnodes; /* All link local nodes */ EXTERN const net_ipv6addr_t g_ipv6_allrouters; /* All link local routers */ +EXTERN const net_ipv6addr_t g_ipv6_llnetmask; /* Netmask for local link address */ #endif #endif diff --git a/net/devif/devif_initialize.c b/net/devif/devif_initialize.c index 1f32e67f3a..ee332b2cfa 100644 --- a/net/devif/devif_initialize.c +++ b/net/devif/devif_initialize.c @@ -85,12 +85,12 @@ uint8_t g_reassembly_timer; #ifdef CONFIG_NET_IPv6 -const net_ipv6addr_t g_ipv6_alloneaddr = +const net_ipv6addr_t g_ipv6_alloneaddr = /* An address of all ones */ { 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff }; -const net_ipv6addr_t g_ipv6_allzeroaddr = +const net_ipv6addr_t g_ipv6_allzeroaddr = /* An address of all zeroes */ { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 }; @@ -112,6 +112,11 @@ const net_ipv6addr_t g_ipv6_allrouters = /* All link local routers */ HTONS(0x0002) }; +const net_ipv6addr_t g_ipv6_llnetmask = /* Netmask for local link address */ +{ + 0xffff, 0xffff, 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000 +}; + #ifdef CONFIG_NET_ETHERNET /* IPv6 Multi-cast Ethernet addresses. Formed from the 16-bit prefix: diff --git a/net/icmpv6/icmpv6_autoconfig.c b/net/icmpv6/icmpv6_autoconfig.c index 06d795bbe0..4854c094bb 100644 --- a/net/icmpv6/icmpv6_autoconfig.c +++ b/net/icmpv6/icmpv6_autoconfig.c @@ -515,8 +515,12 @@ int icmpv6_autoconfig(FAR struct net_driver_s *dev) netdev_ifdown(dev); } + /* Set a netmask for the local link address */ + + net_ipv6addr_copy(dev->d_ipv6netmask, g_ipv6_llnetmask); + /* Leave the network up and return success (even though things did not - * work out quite the way we wanted. + * work out quite the way we wanted). */ net_unlock(save);