diff --git a/core/net/uip-ds6.c b/core/net/uip-ds6.c index 7e3cf1882..cea431612 100644 --- a/core/net/uip-ds6.c +++ b/core/net/uip-ds6.c @@ -148,16 +148,19 @@ uip_ds6_init(void) void uip_ds6_periodic(void) { + /* Periodic processing on unicast addresses */ for(locaddr = uip_ds6_if.addr_list; locaddr < uip_ds6_if.addr_list + UIP_DS6_ADDR_NB; locaddr++) { if(locaddr->isused) { if((!locaddr->isinfinite) && (stimer_expired(&locaddr->vlifetime))) { uip_ds6_addr_rm(locaddr); +#if UIP_ND6_DEF_MAXDADNS > 0 } else if((locaddr->state == ADDR_TENTATIVE) && (locaddr->dadnscount <= uip_ds6_if.maxdadns) && (timer_expired(&locaddr->dadtimer))) { uip_ds6_dad(locaddr); +#endif /* UIP_ND6_DEF_MAXDADNS > 0 */ } } } @@ -549,7 +552,6 @@ uip_ds6_addr_add(uip_ipaddr_t *ipaddr, unsigned long vlifetime, uint8_t type) (uip_ds6_element_t **)&locaddr) == FREESPACE) { locaddr->isused = 1; uip_ipaddr_copy(&locaddr->ipaddr, ipaddr); - locaddr->state = ADDR_TENTATIVE; locaddr->type = type; if(vlifetime == 0) { locaddr->isinfinite = 1; @@ -557,10 +559,15 @@ uip_ds6_addr_add(uip_ipaddr_t *ipaddr, unsigned long vlifetime, uint8_t type) locaddr->isinfinite = 0; stimer_set(&(locaddr->vlifetime), vlifetime); } +#if UIP_ND6_DEF_MAXDADNS > 0 + locaddr->state = ADDR_TENTATIVE; timer_set(&locaddr->dadtimer, random_rand() % (UIP_ND6_MAX_RTR_SOLICITATION_DELAY * CLOCK_SECOND)); locaddr->dadnscount = 0; +#else /* UIP_ND6_DEF_MAXDADNS > 0 */ + locaddr->state = ADDR_PREFERRED; +#endif /* UIP_ND6_DEF_MAXDADNS > 0 */ uip_create_solicited_node(ipaddr, &loc_fipaddr); uip_ds6_maddr_add(&loc_fipaddr); return locaddr; @@ -884,6 +891,7 @@ get_match_length(uip_ipaddr_t *src, uip_ipaddr_t *dst) } /*---------------------------------------------------------------------------*/ +#if UIP_ND6_DEF_MAXDADNS > 0 void uip_ds6_dad(uip_ds6_addr_t *addr) { @@ -922,10 +930,11 @@ uip_ds6_dad_failed(uip_ds6_addr_t * addr) uip_ds6_addr_rm(addr); return 1; } +#endif /*UIP_ND6_DEF_MAXDADNS > 0 */ +/*---------------------------------------------------------------------------*/ #if UIP_CONF_ROUTER #if UIP_ND6_SEND_RA -/*---------------------------------------------------------------------------*/ void uip_ds6_send_ra_sollicited(void) { diff --git a/core/net/uip-ds6.h b/core/net/uip-ds6.h index 064587ac2..3b31d8315 100644 --- a/core/net/uip-ds6.h +++ b/core/net/uip-ds6.h @@ -209,8 +209,10 @@ typedef struct uip_ds6_addr { uint8_t type; uint8_t isinfinite; struct stimer vlifetime; +#if UIP_ND6_DEF_MAXDADNS > 0 struct timer dadtimer; uint8_t dadnscount; +#endif /* UIP_ND6_DEF_MAXDADNS > 0 */ } uip_ds6_addr_t; /** \brief Anycast address */ @@ -385,11 +387,13 @@ void uip_ds6_set_addr_iid(uip_ipaddr_t * ipaddr, uip_lladdr_t * lladdr); /** \brief Get the number of matching bits of two addresses */ uint8_t get_match_length(uip_ipaddr_t * src, uip_ipaddr_t * dst); +#if UIP_ND6_DEF_MAXDADNS >0 /** \brief Perform Duplicate Address Selection on one address */ void uip_ds6_dad(uip_ds6_addr_t * ifaddr); /** \brief Callback when DAD failed */ int uip_ds6_dad_failed(uip_ds6_addr_t * ifaddr); +#endif /* UIP_ND6_DEF_MAXDADNS */ /** \brief Source address selection, see RFC 3484 */ void uip_ds6_select_src(uip_ipaddr_t * src, uip_ipaddr_t * dst); diff --git a/core/net/uip-nd6.c b/core/net/uip-nd6.c index 1874cec51..f49fb9ed7 100644 --- a/core/net/uip-nd6.c +++ b/core/net/uip-nd6.c @@ -224,6 +224,7 @@ uip_nd6_ns_input(void) addr = uip_ds6_addr_lookup(&UIP_ND6_NS_BUF->tgtipaddr); if(addr != NULL) { +#if UIP_ND6_DEF_MAXDADNS > 0 if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) { /* DAD CASE */ #if UIP_CONF_IPV6_CHECKS @@ -242,6 +243,11 @@ uip_nd6_ns_input(void) uip_ds6_dad_failed(addr); goto discard; } +#else /* UIP_ND6_DEF_MAXDADNS > 0 */ + if(uip_is_addr_unspecified(&UIP_IP_BUF->srcipaddr)) { + /* DAD CASE */ + goto discard; +#endif /* UIP_ND6_DEF_MAXDADNS > 0 */ } #if UIP_CONF_IPV6_CHECKS if(uip_ds6_is_my_addr(&UIP_IP_BUF->srcipaddr)) { @@ -441,9 +447,11 @@ uip_nd6_na_input(void) addr = uip_ds6_addr_lookup(&UIP_ND6_NA_BUF->tgtipaddr); /* Message processing, including TLLAO if any */ if(addr != NULL) { +#if UIP_ND6_DEF_MAXDADNS > 0 if(addr->state == ADDR_TENTATIVE) { uip_ds6_dad_failed(addr); } +#endif /*UIP_ND6_DEF_MAXDADNS > 0 */ PRINTF("NA received is bad\n"); goto discard; } else { diff --git a/core/net/uip-nd6.h b/core/net/uip-nd6.h index 38bfd0727..c62e0363e 100644 --- a/core/net/uip-nd6.h +++ b/core/net/uip-nd6.h @@ -57,7 +57,16 @@ #define UIP_ND6_INFINITE_LIFETIME 0xFFFFFFFF /** @} */ +#ifndef UIP_CONF_ND6_DEF_MAXDADNS +/** \brief Do not try DAD when using EUI-64 as allowed by draft-ietf-6lowpan-nd-15 section 8.2 */ +#if UIP_CONF_LL_802154 +#define UIP_ND6_DEF_MAXDADNS 0 +#else /* UIP_CONF_LL_802154 */ #define UIP_ND6_DEF_MAXDADNS 1 +#endif /* UIP_CONF_LL_802154 */ +#else /* UIP_CONF_ND6_DEF_MAXDADNS */ +#define UIP_ND6_DEF_MAXDADNS UIP_CONF_ND6_DEF_MAXDADNS +#endif /* UIP_CONF_ND6_DEF_MAXDADNS */ /** \name RFC 4861 Host constant */ /** @{ */