Fix semantic of UIP_ND6_SEND_NA and add UIP_ND6_SEND_NS
This commit is contained in:
parent
c1f11cfaa9
commit
12c930893c
19 changed files with 75 additions and 61 deletions
|
@ -88,14 +88,14 @@ uip_ds6_nbr_add(const uip_ipaddr_t *ipaddr, const uip_lladdr_t *lladdr,
|
|||
, reason, data);
|
||||
if(nbr) {
|
||||
uip_ipaddr_copy(&nbr->ipaddr, ipaddr);
|
||||
#if UIP_ND6_SEND_NA || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER
|
||||
#if UIP_ND6_SEND_RA || !UIP_CONF_ROUTER
|
||||
nbr->isrouter = isrouter;
|
||||
#endif /* UIP_ND6_SEND_NA || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER */
|
||||
#endif /* UIP_ND6_SEND_RA || !UIP_CONF_ROUTER */
|
||||
nbr->state = state;
|
||||
#if UIP_CONF_IPV6_QUEUE_PKT
|
||||
uip_packetqueue_new(&nbr->packethandle);
|
||||
#endif /* UIP_CONF_IPV6_QUEUE_PKT */
|
||||
#if UIP_ND6_SEND_NA
|
||||
#if UIP_ND6_SEND_NS
|
||||
if(nbr->state == NBR_REACHABLE) {
|
||||
stimer_set(&nbr->reachable, UIP_ND6_REACHABLE_TIME / 1000);
|
||||
} else {
|
||||
|
@ -104,7 +104,7 @@ uip_ds6_nbr_add(const uip_ipaddr_t *ipaddr, const uip_lladdr_t *lladdr,
|
|||
}
|
||||
stimer_set(&nbr->sendns, 0);
|
||||
nbr->nscount = 0;
|
||||
#endif /* UIP_ND6_SEND_NA */
|
||||
#endif /* UIP_ND6_SEND_NS */
|
||||
PRINTF("Adding neighbor with ip addr ");
|
||||
PRINT6ADDR(ipaddr);
|
||||
PRINTF(" link addr ");
|
||||
|
@ -245,7 +245,7 @@ uip_ds6_link_neighbor_callback(int status, int numtx)
|
|||
#endif /* UIP_DS6_LL_NUD */
|
||||
|
||||
}
|
||||
#if UIP_ND6_SEND_NA
|
||||
#if UIP_ND6_SEND_NS
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** Periodic processing on neighbors */
|
||||
void
|
||||
|
@ -326,7 +326,6 @@ uip_ds6_neighbor_periodic(void)
|
|||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#if UIP_ND6_SEND_NA
|
||||
void
|
||||
uip_ds6_nbr_refresh_reachable_state(const uip_ipaddr_t *ipaddr)
|
||||
{
|
||||
|
@ -338,7 +337,6 @@ uip_ds6_nbr_refresh_reachable_state(const uip_ipaddr_t *ipaddr)
|
|||
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)
|
||||
|
@ -358,6 +356,6 @@ uip_ds6_get_least_lifetime_neighbor(void)
|
|||
}
|
||||
return nbr_expiring;
|
||||
}
|
||||
#endif /* UIP_ND6_SEND_NA */
|
||||
#endif /* UIP_ND6_SEND_NS */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @} */
|
||||
|
|
|
@ -69,11 +69,11 @@ typedef struct uip_ds6_nbr {
|
|||
uip_ipaddr_t ipaddr;
|
||||
uint8_t isrouter;
|
||||
uint8_t state;
|
||||
#if UIP_ND6_SEND_NA || UIP_ND6_SEND_RA
|
||||
#if UIP_ND6_SEND_NS || UIP_ND6_SEND_RA
|
||||
struct stimer reachable;
|
||||
struct stimer sendns;
|
||||
uint8_t nscount;
|
||||
#endif /* UIP_ND6_SEND_NA || UIP_ND6_SEND_RA */
|
||||
#endif /* UIP_ND6_SEND_NS || UIP_ND6_SEND_RA */
|
||||
#if UIP_CONF_IPV6_QUEUE_PKT
|
||||
struct uip_packetqueue_handle packethandle;
|
||||
#define UIP_DS6_NBR_PACKET_LIFETIME CLOCK_SECOND * 4
|
||||
|
@ -98,7 +98,7 @@ 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
|
||||
#if UIP_ND6_SEND_NS
|
||||
/**
|
||||
* \brief Refresh the reachable state of a neighbor. This function
|
||||
* may be called when a node receives an IPv6 message that confirms the
|
||||
|
@ -107,7 +107,7 @@ int uip_ds6_nbr_num(void);
|
|||
* should be refreshed.
|
||||
*/
|
||||
void uip_ds6_nbr_refresh_reachable_state(const uip_ipaddr_t *ipaddr);
|
||||
#endif /* UIP_ND6_SEND_NA */
|
||||
#endif /* UIP_ND6_SEND_NS */
|
||||
|
||||
/**
|
||||
* \brief
|
||||
|
|
|
@ -187,9 +187,9 @@ uip_ds6_periodic(void)
|
|||
}
|
||||
#endif /* !UIP_CONF_ROUTER */
|
||||
|
||||
#if UIP_ND6_SEND_NA
|
||||
#if UIP_ND6_SEND_NS
|
||||
uip_ds6_neighbor_periodic();
|
||||
#endif /* UIP_ND6_SEND_RA */
|
||||
#endif /* UIP_ND6_SEND_NS */
|
||||
|
||||
#if UIP_CONF_ROUTER && UIP_ND6_SEND_RA
|
||||
/* Periodic RA sending */
|
||||
|
|
|
@ -116,13 +116,16 @@ void uip_log(char *msg);
|
|||
#define UIP_ND6_OPT_RDNSS_BUF ((uip_nd6_opt_dns *)&uip_buf[uip_l2_l3_icmp_hdr_len + nd6_opt_offset])
|
||||
/** @} */
|
||||
|
||||
#if UIP_ND6_SEND_NA || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER
|
||||
#if UIP_ND6_SEND_NS || UIP_ND6_SEND_NA || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER
|
||||
static uint8_t nd6_opt_offset; /** Offset from the end of the icmpv6 header to the option in uip_buf*/
|
||||
static uint8_t *nd6_opt_llao; /** Pointer to llao option in uip_buf */
|
||||
static uip_ds6_nbr_t *nbr; /** Pointer to a nbr cache entry*/
|
||||
static uip_ds6_defrt_t *defrt; /** Pointer to a router list entry */
|
||||
static uip_ds6_addr_t *addr; /** Pointer to an interface address */
|
||||
#endif /* UIP_ND6_SEND_NA || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER */
|
||||
#endif /* UIP_ND6_SEND_NS || UIP_ND6_SEND_NA || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER */
|
||||
|
||||
#if UIP_ND6_SEND_NS || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER
|
||||
static uip_ds6_defrt_t *defrt; /** Pointer to a router list entry */
|
||||
#endif /* UIP_ND6_SEND_NS || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER */
|
||||
|
||||
#if !UIP_CONF_ROUTER // TBD see if we move it to ra_input
|
||||
static uip_nd6_opt_prefix_info *nd6_opt_prefix_info; /** Pointer to prefix information option in uip_buf */
|
||||
|
@ -366,6 +369,7 @@ discard:
|
|||
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
#if UIP_ND6_SEND_NS
|
||||
void
|
||||
uip_nd6_ns_output(uip_ipaddr_t * src, uip_ipaddr_t * dest, uip_ipaddr_t * tgt)
|
||||
{
|
||||
|
@ -428,7 +432,9 @@ uip_nd6_ns_output(uip_ipaddr_t * src, uip_ipaddr_t * dest, uip_ipaddr_t * tgt)
|
|||
PRINTF("\n");
|
||||
return;
|
||||
}
|
||||
#if UIP_ND6_SEND_NA
|
||||
#endif /* UIP_ND6_SEND_NS */
|
||||
|
||||
#if UIP_ND6_SEND_NS
|
||||
/*------------------------------------------------------------------*/
|
||||
/**
|
||||
* Neighbor Advertisement Processing
|
||||
|
@ -603,7 +609,7 @@ discard:
|
|||
uip_clear_buf();
|
||||
return;
|
||||
}
|
||||
#endif /* UIP_ND6_SEND_NA */
|
||||
#endif /* UIP_ND6_SEND_NS */
|
||||
|
||||
#if UIP_CONF_ROUTER
|
||||
#if UIP_ND6_SEND_RA
|
||||
|
@ -1097,6 +1103,8 @@ discard:
|
|||
#if UIP_ND6_SEND_NA
|
||||
UIP_ICMP6_HANDLER(ns_input_handler, ICMP6_NS, UIP_ICMP6_HANDLER_CODE_ANY,
|
||||
ns_input);
|
||||
#endif
|
||||
#if UIP_ND6_SEND_NS
|
||||
UIP_ICMP6_HANDLER(na_input_handler, ICMP6_NA, UIP_ICMP6_HANDLER_CODE_ANY,
|
||||
na_input);
|
||||
#endif
|
||||
|
@ -1114,19 +1122,16 @@ UIP_ICMP6_HANDLER(ra_input_handler, ICMP6_RA, UIP_ICMP6_HANDLER_CODE_ANY,
|
|||
void
|
||||
uip_nd6_init()
|
||||
{
|
||||
|
||||
#if UIP_ND6_SEND_NA
|
||||
/* Only handle NSs if we are prepared to send out NAs */
|
||||
uip_icmp6_register_input_handler(&ns_input_handler);
|
||||
|
||||
/*
|
||||
* Only handle NAs if we are prepared to send out NAs.
|
||||
* This is perhaps logically incorrect, but this condition was present in
|
||||
* uip_process and we keep it until proven wrong
|
||||
*/
|
||||
uip_icmp6_register_input_handler(&na_input_handler);
|
||||
#endif
|
||||
|
||||
#if UIP_ND6_SEND_NS
|
||||
/*
|
||||
* Only handle NAs if we are prepared to send out NSs. */
|
||||
uip_icmp6_register_input_handler(&na_input_handler);
|
||||
#endif
|
||||
|
||||
#if UIP_CONF_ROUTER && UIP_ND6_SEND_RA
|
||||
/* Only accept RS if we are a router and happy to send out RAs */
|
||||
|
|
|
@ -74,6 +74,11 @@
|
|||
#else
|
||||
#define UIP_ND6_SEND_RA UIP_CONF_ND6_SEND_RA
|
||||
#endif
|
||||
#ifndef UIP_CONF_ND6_SEND_NS
|
||||
#define UIP_ND6_SEND_NS 1 /* enable/disable NS sending */
|
||||
#else
|
||||
#define UIP_ND6_SEND_NS UIP_CONF_ND6_SEND_NS
|
||||
#endif
|
||||
#ifndef UIP_CONF_ND6_SEND_NA
|
||||
#define UIP_ND6_SEND_NA 1 /* enable/disable NA sending */
|
||||
#else
|
||||
|
@ -109,7 +114,7 @@
|
|||
#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
|
||||
#define UIP_ND6_DEF_MAXDADNS UIP_ND6_SEND_NS
|
||||
#endif /* UIP_CONF_LL_802154 */
|
||||
#else /* UIP_CONF_ND6_DEF_MAXDADNS */
|
||||
#define UIP_ND6_DEF_MAXDADNS UIP_CONF_ND6_DEF_MAXDADNS
|
||||
|
|
|
@ -85,9 +85,9 @@
|
|||
#include "rpl/rpl-private.h"
|
||||
#endif
|
||||
|
||||
#if UIP_ND6_SEND_NA
|
||||
#if UIP_ND6_SEND_NS
|
||||
#include "net/ipv6/uip-ds6-nbr.h"
|
||||
#endif /* UIP_ND6_SEND_NA */
|
||||
#endif /* UIP_ND6_SEND_NS */
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
@ -1156,11 +1156,11 @@ uip_process(uint8_t flag)
|
|||
}
|
||||
|
||||
/* Refresh neighbor state after receiving a unicast message */
|
||||
#if UIP_ND6_SEND_NA
|
||||
#if UIP_ND6_SEND_NS
|
||||
if(!uip_is_addr_mcast(&UIP_IP_BUF->destipaddr)) {
|
||||
uip_ds6_nbr_refresh_reachable_state(&UIP_IP_BUF->srcipaddr);
|
||||
}
|
||||
#endif /* UIP_ND6_SEND_NA */
|
||||
#endif /* UIP_ND6_SEND_NS */
|
||||
|
||||
#if UIP_CONF_ROUTER
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue