Contiki-NG
uip-ds6-nbr.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013, Swedish Institute of Computer Science.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the Institute nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  *
30  */
31 
32 /**
33  * \addtogroup uip
34  * @{
35  */
36 
37 /**
38  * \file
39  * IPv6 Neighbor cache (link-layer/IPv6 address mapping)
40  * \author Mathilde Durvy <mdurvy@cisco.com>
41  * \author Julien Abeille <jabeille@cisco.com>
42  * \author Simon Duquennoy <simonduq@sics.se>
43  *
44  */
45 
46 #ifndef UIP_DS6_NEIGHBOR_H_
47 #define UIP_DS6_NEIGHBOR_H_
48 
49 #include "contiki.h"
50 #include "net/ipv6/uip.h"
51 #include "net/ipv6/uip-nd6.h"
52 #include "net/nbr-table.h"
53 #include "sys/stimer.h"
54 #if UIP_CONF_IPV6_QUEUE_PKT
55 #include "net/ipv6/uip-packetqueue.h"
56 #endif /*UIP_CONF_QUEUE_PKT */
57 
58 /*--------------------------------------------------*/
59 /** \brief Possible states for the nbr cache entries */
60 #define NBR_INCOMPLETE 0
61 #define NBR_REACHABLE 1
62 #define NBR_STALE 2
63 #define NBR_DELAY 3
64 #define NBR_PROBE 4
65 
66 NBR_TABLE_DECLARE(ds6_neighbors);
67 
68 /** \brief An entry in the nbr cache */
69 typedef struct uip_ds6_nbr {
70  uip_ipaddr_t ipaddr;
71  uint8_t isrouter;
72  uint8_t state;
73 #if UIP_ND6_SEND_NS || UIP_ND6_SEND_RA
74  struct stimer reachable;
75  struct stimer sendns;
76  uint8_t nscount;
77 #endif /* UIP_ND6_SEND_NS || UIP_ND6_SEND_RA */
78 #if UIP_CONF_IPV6_QUEUE_PKT
79  struct uip_packetqueue_handle packethandle;
80 #define UIP_DS6_NBR_PACKET_LIFETIME CLOCK_SECOND * 4
81 #endif /*UIP_CONF_QUEUE_PKT */
83 
84 void uip_ds6_neighbors_init(void);
85 
86 /** \brief Neighbor Cache basic routines */
87 uip_ds6_nbr_t *uip_ds6_nbr_add(const uip_ipaddr_t *ipaddr,
88  const uip_lladdr_t *lladdr,
89  uint8_t isrouter, uint8_t state,
90  nbr_table_reason_t reason, void *data);
91 int uip_ds6_nbr_rm(uip_ds6_nbr_t *nbr);
92 const uip_lladdr_t *uip_ds6_nbr_get_ll(const uip_ds6_nbr_t *nbr);
93 int uip_ds6_nbr_update_ll(uip_ds6_nbr_t **nbr, const uip_lladdr_t *new_ll_addr);
94 const uip_ipaddr_t *uip_ds6_nbr_get_ipaddr(const uip_ds6_nbr_t *nbr);
95 uip_ds6_nbr_t *uip_ds6_nbr_lookup(const uip_ipaddr_t *ipaddr);
96 uip_ds6_nbr_t *uip_ds6_nbr_ll_lookup(const uip_lladdr_t *lladdr);
97 uip_ipaddr_t *uip_ds6_nbr_ipaddr_from_lladdr(const uip_lladdr_t *lladdr);
98 const uip_lladdr_t *uip_ds6_nbr_lladdr_from_ipaddr(const uip_ipaddr_t *ipaddr);
99 void uip_ds6_link_callback(int status, int numtx);
100 void uip_ds6_neighbor_periodic(void);
101 int uip_ds6_nbr_num(void);
102 uip_ds6_nbr_t *uip_ds6_nbr_head(void);
103 uip_ds6_nbr_t *uip_ds6_nbr_next(uip_ds6_nbr_t *nbr);
104 
105 #if UIP_ND6_SEND_NS
106 /**
107  * \brief Refresh the reachable state of a neighbor. This function
108  * may be called when a node receives an IPv6 message that confirms the
109  * reachability of a neighbor.
110  * \param ipaddr pointer to the IPv6 address whose neighbor reachability state
111  * should be refreshed.
112  */
113 void uip_ds6_nbr_refresh_reachable_state(const uip_ipaddr_t *ipaddr);
114 #endif /* UIP_ND6_SEND_NS */
115 
116 /**
117  * \brief
118  * This searches inside the neighbor table for the neighbor that is about to
119  * expire the next.
120  *
121  * \return
122  * A reference to the neighbor about to expire the next or NULL if
123  * table is empty.
124  */
126 
127 #endif /* UIP_DS6_NEIGHBOR_H_ */
128 /** @} */
static uip_ipaddr_t ipaddr
Pointer to prefix information option in uip_buf.
Definition: uip-nd6.c:125
static uip_ds6_nbr_t * nbr
Pointer to llao option in uip_buf.
Definition: uip-nd6.c:115
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...
A timer.
Definition: stimer.h:81
Second timer library header file.
Header file for the uIP TCP/IP stack.
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.
Definition: uip-ds6-nbr.c:74
Header file for IPv6 Neighbor discovery (RFC 4861)
struct uip_ds6_nbr uip_ds6_nbr_t
An entry in the nbr cache.
An entry in the nbr cache.
Definition: uip-ds6-nbr.h:69