Merge pull request #291 from simonduq/na-config

Added a flag to optionally disable IPv6 NA/NS at compile time
This commit is contained in:
Nicolas Tsiftes 2013-07-23 09:52:13 -07:00
commit f8edf41411
4 changed files with 39 additions and 19 deletions

View file

@ -602,6 +602,7 @@ tcpip_ipv6_output(void)
} }
#endif /* UIP_CONF_IPV6_RPL */ #endif /* UIP_CONF_IPV6_RPL */
if((nbr = uip_ds6_nbr_lookup(nexthop)) == NULL) { if((nbr = uip_ds6_nbr_lookup(nexthop)) == NULL) {
#if UIP_ND6_SEND_NA
if((nbr = uip_ds6_nbr_add(nexthop, NULL, 0, NBR_INCOMPLETE)) == NULL) { if((nbr = uip_ds6_nbr_add(nexthop, NULL, 0, NBR_INCOMPLETE)) == NULL) {
uip_len = 0; uip_len = 0;
return; return;
@ -628,7 +629,9 @@ tcpip_ipv6_output(void)
stimer_set(&nbr->sendns, uip_ds6_if.retrans_timer / 1000); stimer_set(&nbr->sendns, uip_ds6_if.retrans_timer / 1000);
nbr->nscount = 1; nbr->nscount = 1;
} }
#endif /* UIP_ND6_SEND_NA */
} else { } else {
#if UIP_ND6_SEND_NA
if(nbr->state == NBR_INCOMPLETE) { if(nbr->state == NBR_INCOMPLETE) {
PRINTF("tcpip_ipv6_output: nbr cache entry incomplete\n"); PRINTF("tcpip_ipv6_output: nbr cache entry incomplete\n");
#if UIP_CONF_IPV6_QUEUE_PKT #if UIP_CONF_IPV6_QUEUE_PKT
@ -650,6 +653,7 @@ tcpip_ipv6_output(void)
nbr->nscount = 0; nbr->nscount = 0;
PRINTF("tcpip_ipv6_output: nbr cache entry stale moving to delay\n"); PRINTF("tcpip_ipv6_output: nbr cache entry stale moving to delay\n");
} }
#endif /* UIP_ND6_SEND_NA */
tcpip_output(&nbr->lladdr); tcpip_output(&nbr->lladdr);

View file

@ -204,6 +204,15 @@ uip_ds6_periodic(void)
locnbr++) { locnbr++) {
if(locnbr->isused) { if(locnbr->isused) {
switch(locnbr->state) { switch(locnbr->state) {
case NBR_REACHABLE:
if(stimer_expired(&locnbr->reachable)) {
PRINTF("REACHABLE: moving to STALE (");
PRINT6ADDR(&locnbr->ipaddr);
PRINTF(")\n");
locnbr->state = NBR_STALE;
}
break;
#if UIP_ND6_SEND_NA
case NBR_INCOMPLETE: case NBR_INCOMPLETE:
if(locnbr->nscount >= UIP_ND6_MAX_MULTICAST_SOLICIT) { if(locnbr->nscount >= UIP_ND6_MAX_MULTICAST_SOLICIT) {
uip_ds6_nbr_rm(locnbr); uip_ds6_nbr_rm(locnbr);
@ -214,14 +223,6 @@ uip_ds6_periodic(void)
stimer_set(&locnbr->sendns, uip_ds6_if.retrans_timer / 1000); stimer_set(&locnbr->sendns, uip_ds6_if.retrans_timer / 1000);
} }
break; break;
case NBR_REACHABLE:
if(stimer_expired(&locnbr->reachable)) {
PRINTF("REACHABLE: moving to STALE (");
PRINT6ADDR(&locnbr->ipaddr);
PRINTF(")\n");
locnbr->state = NBR_STALE;
}
break;
case NBR_DELAY: case NBR_DELAY:
if(stimer_expired(&locnbr->reachable)) { if(stimer_expired(&locnbr->reachable)) {
locnbr->state = NBR_PROBE; locnbr->state = NBR_PROBE;
@ -246,6 +247,7 @@ uip_ds6_periodic(void)
stimer_set(&locnbr->sendns, uip_ds6_if.retrans_timer / 1000); stimer_set(&locnbr->sendns, uip_ds6_if.retrans_timer / 1000);
} }
break; break;
#endif /* UIP_ND6_SEND_NA */
default: default:
break; break;
} }

View file

@ -57,17 +57,6 @@
#define UIP_ND6_INFINITE_LIFETIME 0xFFFFFFFF #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 */ /** \name RFC 4861 Host constant */
/** @{ */ /** @{ */
#define UIP_ND6_MAX_RTR_SOLICITATION_DELAY 1 #define UIP_ND6_MAX_RTR_SOLICITATION_DELAY 1
@ -82,6 +71,11 @@
#else #else
#define UIP_ND6_SEND_RA UIP_CONF_ND6_SEND_RA #define UIP_ND6_SEND_RA UIP_CONF_ND6_SEND_RA
#endif #endif
#ifndef UIP_CONF_ND6_SEND_NA
#define UIP_ND6_SEND_NA 1 /* enable/disable NA sending */
#else
#define UIP_ND6_SEND_NA UIP_CONF_ND6_SEND_NA
#endif
#define UIP_ND6_MAX_RA_INTERVAL 600 #define UIP_ND6_MAX_RA_INTERVAL 600
#define UIP_ND6_MIN_RA_INTERVAL (UIP_ND6_MAX_RA_INTERVAL / 3) #define UIP_ND6_MIN_RA_INTERVAL (UIP_ND6_MAX_RA_INTERVAL / 3)
#define UIP_ND6_M_FLAG 0 #define UIP_ND6_M_FLAG 0
@ -95,6 +89,16 @@
#define UIP_ND6_MAX_RA_DELAY_TIME_MS 500 /*milli seconds*/ #define UIP_ND6_MAX_RA_DELAY_TIME_MS 500 /*milli seconds*/
/** @} */ /** @} */
#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 UIP_ND6_SEND_NA
#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 Node constant */ /** \name RFC 4861 Node constant */
#define UIP_ND6_MAX_MULTICAST_SOLICIT 3 #define UIP_ND6_MAX_MULTICAST_SOLICIT 3

View file

@ -1391,10 +1391,20 @@ uip_process(uint8_t flag)
switch(UIP_ICMP_BUF->type) { switch(UIP_ICMP_BUF->type) {
case ICMP6_NS: case ICMP6_NS:
#if UIP_ND6_SEND_NA
uip_nd6_ns_input(); uip_nd6_ns_input();
#else /* UIP_ND6_SEND_NA */
UIP_STAT(++uip_stat.icmp.drop);
uip_len = 0;
#endif /* UIP_ND6_SEND_NA */
break; break;
case ICMP6_NA: case ICMP6_NA:
#if UIP_ND6_SEND_NA
uip_nd6_na_input(); uip_nd6_na_input();
#else /* UIP_ND6_SEND_NA */
UIP_STAT(++uip_stat.icmp.drop);
uip_len = 0;
#endif /* UIP_ND6_SEND_NA */
break; break;
case ICMP6_RS: case ICMP6_RS:
#if UIP_CONF_ROUTER && UIP_ND6_SEND_RA #if UIP_CONF_ROUTER && UIP_ND6_SEND_RA