diff --git a/os/net/ipv6/uip-ds6-nbr.c b/os/net/ipv6/uip-ds6-nbr.c index c83fa7674..0db8a0f45 100644 --- a/os/net/ipv6/uip-ds6-nbr.c +++ b/os/net/ipv6/uip-ds6-nbr.c @@ -149,6 +149,19 @@ uip_ds6_nbr_add(const uip_ipaddr_t *ipaddr, const uip_lladdr_t *lladdr, } } + if(list_length(nbr_entry->uip_ds6_nbrs) < UIP_DS6_NBR_MAX_6ADDRS_PER_NBR) { + /* it has room to add another IPv6 address */ + } else { + /* + * it's already had the maximum number of IPv6 addresses; cannot + * add another. + */ + LOG_ERR("%s: no room in nbr_entry for ", __func__); + LOG_ERR_LLADDR((const linkaddr_t *)lladdr); + LOG_ERR_("\n"); + return NULL; + } + if((nbr = (uip_ds6_nbr_t *)memb_alloc(&uip_ds6_nbr_memb)) == NULL) { LOG_ERR("%s: cannot allocate a new uip_ds6_nbr\n", __func__); if(list_length(nbr_entry->uip_ds6_nbrs) == 0) { diff --git a/os/net/ipv6/uip-ds6-nbr.h b/os/net/ipv6/uip-ds6-nbr.h index 809f01d2b..6479c972e 100644 --- a/os/net/ipv6/uip-ds6-nbr.h +++ b/os/net/ipv6/uip-ds6-nbr.h @@ -75,6 +75,14 @@ #define UIP_DS6_NBR_MULTI_IPV6_ADDRS 0 #endif /* UIP_DS6_NBR_CONF_MULTI_IPV6_ADDRS */ +/** \brief Set the maximum number of IPv6 addresses per link-layer + * address */ +#ifdef UIP_DS6_NBR_CONF_MAX_6ADDRS_PER_NBR +#define UIP_DS6_NBR_MAX_6ADDRS_PER_NBR UIP_DS6_NBR_CONF_MAX_6ADDRS_PER_NBR +#else +#define UIP_DS6_NBR_MAX_6ADDRS_PER_NBR 2 +#endif /* UIP_DS6_NBR_CONF_MAX_6ADDRS_PER_NBR */ + /** \brief Set the maximum number of neighbor cache entries */ #ifdef UIP_DS6_NBR_CONF_MAX_NEIGHBOR_CACHES #define UIP_DS6_NBR_MAX_NEIGHBOR_CACHES UIP_DS6_NBR_CONF_MAX_NEIGHBOR_CACHES