Added a flag to optionally disable IPv6 NA/NS at compile time

This commit is contained in:
Simon Duquennoy 2013-07-02 13:52:11 +02:00
parent ad34b714cd
commit 1f38348cf9
3 changed files with 29 additions and 11 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

@ -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