diff --git a/core/net/ipv6/uip-ds6-nbr.c b/core/net/ipv6/uip-ds6-nbr.c index 3ccebddd1..36585d23c 100644 --- a/core/net/ipv6/uip-ds6-nbr.c +++ b/core/net/ipv6/uip-ds6-nbr.c @@ -322,6 +322,20 @@ uip_ds6_neighbor_periodic(void) } } /*---------------------------------------------------------------------------*/ +#if UIP_ND6_SEND_NA +void +uip_ds6_nbr_refresh_reachable_state(const uip_ipaddr_t *ipaddr) +{ + uip_ds6_nbr_t *nbr; + nbr = uip_ds6_nbr_lookup(ipaddr); + if(nbr != NULL) { + nbr->state = NBR_REACHABLE; + nbr->nscount = 0; + stimer_set(&nbr->reachable, UIP_ND6_REACHABLE_TIME / 1000); + } +} +#endif /* UIP_ND6_SEND_NA */ +/*---------------------------------------------------------------------------*/ uip_ds6_nbr_t * uip_ds6_get_least_lifetime_neighbor(void) { diff --git a/core/net/ipv6/uip-ds6-nbr.h b/core/net/ipv6/uip-ds6-nbr.h index 40a17d1e2..251e16c36 100644 --- a/core/net/ipv6/uip-ds6-nbr.h +++ b/core/net/ipv6/uip-ds6-nbr.h @@ -100,6 +100,17 @@ void uip_ds6_link_neighbor_callback(int status, int numtx); void uip_ds6_neighbor_periodic(void); int uip_ds6_nbr_num(void); +#if UIP_ND6_SEND_NA +/** + * \brief Refresh the reachable state of a neighbor. This function + * may be called when a node receives an IPv6 message that confirms the + * reachability of a neighbor. + * \param ipaddr pointer to the IPv6 address whose neighbor reachability state + * should be refreshed. + */ +void uip_ds6_nbr_refresh_reachable_state(const uip_ipaddr_t *ipaddr); +#endif /* UIP_ND6_SEND_NA */ + /** * \brief * This searches inside the neighbor table for the neighbor that is about to diff --git a/core/net/ipv6/uip6.c b/core/net/ipv6/uip6.c index a54754371..88df55340 100644 --- a/core/net/ipv6/uip6.c +++ b/core/net/ipv6/uip6.c @@ -84,6 +84,10 @@ #include "rpl/rpl-private.h" #endif +#if UIP_ND6_SEND_NA +#include "net/ipv6/uip-ds6-nbr.h" +#endif /* UIP_ND6_SEND_NA */ + #include /*---------------------------------------------------------------------------*/ @@ -1150,6 +1154,11 @@ uip_process(uint8_t flag) goto drop; } + /* Refresh neighbor state after receiving a unicast message */ +#if UIP_ND6_SEND_NA + uip_ds6_nbr_refresh_reachable_state(&UIP_IP_BUF->srcipaddr); +#endif /* UIP_ND6_SEND_NA */ + #if UIP_CONF_ROUTER /* * Next header field processing. In IPv6, we can have extension headers,