50 #include "net/link-stats.h"
55 #define DEBUG DEBUG_NONE
58 #ifdef UIP_CONF_DS6_NEIGHBOR_STATE_CHANGED
59 #define NEIGHBOR_STATE_CHANGED(n) UIP_CONF_DS6_NEIGHBOR_STATE_CHANGED(n)
62 #define NEIGHBOR_STATE_CHANGED(n)
65 #ifdef UIP_CONF_DS6_LINK_NEIGHBOR_CALLBACK
66 #define LINK_NEIGHBOR_CALLBACK(addr, status, numtx) UIP_CONF_DS6_LINK_NEIGHBOR_CALLBACK(addr, status, numtx)
67 void LINK_NEIGHBOR_CALLBACK(
const linkaddr_t *
addr,
int status,
int numtx);
69 #define LINK_NEIGHBOR_CALLBACK(addr, status, numtx)
76 uip_ds6_neighbors_init(
void)
79 nbr_table_register(ds6_neighbors, (nbr_table_callback *)uip_ds6_nbr_rm);
84 uint8_t isrouter, uint8_t state, nbr_table_reason_t reason,
91 #if UIP_ND6_SEND_NA || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER
92 nbr->isrouter = isrouter;
95 #if UIP_CONF_IPV6_QUEUE_PKT
96 uip_packetqueue_new(&nbr->packethandle);
104 PRINTF(
"Adding neighbor with ip addr ");
106 PRINTF(
" link addr ");
108 PRINTF(
" state %u\n", state);
109 NEIGHBOR_STATE_CHANGED(nbr);
112 PRINTF(
"uip_ds6_nbr_add drop ip addr ");
114 PRINTF(
" link addr (%p) ", lladdr);
116 PRINTF(
" state %u\n", state);
126 #if UIP_CONF_IPV6_QUEUE_PKT
127 uip_packetqueue_free(&nbr->packethandle);
129 NEIGHBOR_STATE_CHANGED(nbr);
130 return nbr_table_remove(ds6_neighbors, nbr);
139 return (nbr !=
NULL) ? &nbr->ipaddr :
NULL;
146 return (
const uip_lladdr_t *)nbr_table_get_lladdr(ds6_neighbors, nbr);
150 uip_ds6_nbr_num(
void)
156 for(nbr = nbr_table_head(ds6_neighbors);
158 nbr = nbr_table_next(ds6_neighbors, nbr)) {
165 uip_ds6_nbr_lookup(
const uip_ipaddr_t *
ipaddr)
170 if(uip_ipaddr_cmp(&nbr->ipaddr, ipaddr)) {
173 nbr = nbr_table_next(ds6_neighbors, nbr);
182 return nbr_table_get_from_lladdr(ds6_neighbors, (linkaddr_t*)lladdr);
187 uip_ds6_nbr_ipaddr_from_lladdr(
const uip_lladdr_t *lladdr)
190 return nbr ? &nbr->ipaddr :
NULL;
195 uip_ds6_nbr_lladdr_from_ipaddr(
const uip_ipaddr_t *ipaddr)
198 return nbr ? uip_ds6_nbr_get_ll(nbr) :
NULL;
202 uip_ds6_link_neighbor_callback(
int status,
int numtx)
204 const linkaddr_t *dest = packetbuf_addr(PACKETBUF_ADDR_RECEIVER);
210 link_stats_packet_sent(dest, status, numtx);
212 LINK_NEIGHBOR_CALLBACK(dest, status, numtx);
234 nbr->state = NBR_REACHABLE;
235 stimer_set(&nbr->reachable, UIP_ND6_REACHABLE_TIME / 1000);
236 PRINTF(
"uip-ds6-neighbor : received a link layer ACK : ");
238 PRINTF(
" is reachable.\n");
248 uip_ds6_neighbor_periodic(
void)
255 #if UIP_CONF_IPV6_RPL
262 if(uip_ds6_defrt_lookup(&nbr->ipaddr) !=
NULL) {
263 PRINTF(
"REACHABLE: defrt moving to DELAY (");
264 PRINT6ADDR(&nbr->ipaddr);
266 nbr->state = NBR_DELAY;
267 stimer_set(&nbr->reachable, UIP_ND6_DELAY_FIRST_PROBE_TIME);
270 PRINTF(
"REACHABLE: moving to STALE (");
271 PRINT6ADDR(&nbr->ipaddr);
273 nbr->state = NBR_STALE;
276 PRINTF(
"REACHABLE: moving to STALE (");
277 PRINT6ADDR(&nbr->ipaddr);
279 nbr->state = NBR_STALE;
284 if(nbr->nscount >= UIP_ND6_MAX_MULTICAST_SOLICIT) {
288 PRINTF(
"NBR_INCOMPLETE: NS %u\n", nbr->nscount);
295 nbr->state = NBR_PROBE;
297 PRINTF(
"DELAY: moving to PROBE\n");
302 if(nbr->nscount >= UIP_ND6_MAX_UNICAST_SOLICIT) {
304 PRINTF(
"PROBE END\n");
305 if((locdefrt = uip_ds6_defrt_lookup(&nbr->ipaddr)) !=
NULL) {
306 if (!locdefrt->isinfinite) {
307 uip_ds6_defrt_rm(locdefrt);
313 PRINTF(
"PROBE: NS %u\n", nbr->nscount);
321 nbr = nbr_table_next(ds6_neighbors, nbr);
331 if(nbr_expiring !=
NULL) {
339 nbr = nbr_table_next(ds6_neighbors, nbr);
uip_len
The length of the packet in the uip_buf buffer.
static uip_ipaddr_t ipaddr
Pointer to prefix information option in uip_buf.
static uip_ds6_addr_t * addr
Pointer to a router list entry.
uip_ds6_nbr_t * uip_ds6_get_least_lifetime_neighbor(void)
This searches inside the neighbor table for the neighbor that is about to expire the next...
int stimer_expired(struct stimer *t)
Check if a timer has expired.
An entry in the default router list.
const linkaddr_t linkaddr_null
The null Rime address.
#define NBR_INCOMPLETE
Possible states for the nbr cache entries.
#define uip_ipaddr_copy(dest, src)
Copy an IP address from one place to another.
An entry in the nbr cache.
IPv6 Neighbor cache (link-layer/IPv6 address mapping)
Header file for the Rime buffer (packetbuf) management
Header file for the Rime address representation
The MAC layer transmission was OK.
#define NULL
The null pointer.
unsigned long stimer_remaining(struct stimer *t)
The time until the timer expires.
static uip_ds6_nbr_t * nbr
Pointer to llao option in uip_buf.
void stimer_set(struct stimer *t, unsigned long interval)
Set a timer.
uip_ds6_nbr_t * uip_ds6_nbr_add(const uip_ipaddr_t *ipaddr, const uip_lladdr_t *lladdr, uint8_t isrouter, uint8_t state, nbr_table_reason_t reason, void *data)
Neighbor Cache basic routines.
Linked list manipulation routines.
void uip_nd6_ns_output(uip_ipaddr_t *src, uip_ipaddr_t *dest, uip_ipaddr_t *tgt)
Send a neighbor solicitation, send a Neighbor Advertisement.
A set of debugging macros for the IP stack
int linkaddr_cmp(const linkaddr_t *addr1, const linkaddr_t *addr2)
Compare two Rime addresses.
uip_ds6_netif_t uip_ds6_if
The single interface.