Contiki 3.x
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 uip6
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 "net/ip/uip.h"
50 #include "net/nbr-table.h"
51 #include "sys/stimer.h"
52 #include "net/ipv6/uip-ds6.h"
53 #include "net/nbr-table.h"
54 
55 #if UIP_CONF_IPV6_QUEUE_PKT
56 #include "net/ip/uip-packetqueue.h"
57 #endif /*UIP_CONF_QUEUE_PKT */
58 
59 /*--------------------------------------------------*/
60 /** \brief Possible states for the nbr cache entries */
61 #define NBR_INCOMPLETE 0
62 #define NBR_REACHABLE 1
63 #define NBR_STALE 2
64 #define NBR_DELAY 3
65 #define NBR_PROBE 4
66 
67 NBR_TABLE_DECLARE(ds6_neighbors);
68 
69 /** \brief An entry in the nbr cache */
70 typedef struct uip_ds6_nbr {
71  uip_ipaddr_t ipaddr;
72  uint8_t isrouter;
73  uint8_t state;
74 #if UIP_ND6_SEND_NA || UIP_ND6_SEND_RA
75  struct stimer reachable;
76  struct stimer sendns;
77  uint8_t nscount;
78 #endif /* UIP_ND6_SEND_NA || UIP_ND6_SEND_RA */
79 #if UIP_CONF_IPV6_QUEUE_PKT
80  struct uip_packetqueue_handle packethandle;
81 #define UIP_DS6_NBR_PACKET_LIFETIME CLOCK_SECOND * 4
82 #endif /*UIP_CONF_QUEUE_PKT */
84 
85 void uip_ds6_neighbors_init(void);
86 
87 /** \brief Neighbor Cache basic routines */
88 uip_ds6_nbr_t *uip_ds6_nbr_add(const uip_ipaddr_t *ipaddr,
89  const uip_lladdr_t *lladdr,
90  uint8_t isrouter, uint8_t state,
91  nbr_table_reason_t reason, void *data);
92 int uip_ds6_nbr_rm(uip_ds6_nbr_t *nbr);
93 const uip_lladdr_t *uip_ds6_nbr_get_ll(const uip_ds6_nbr_t *nbr);
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_neighbor_callback(int status, int numtx);
100 void uip_ds6_neighbor_periodic(void);
101 int uip_ds6_nbr_num(void);
102 
103 /**
104  * \brief
105  * This searches inside the neighbor table for the neighbor that is about to
106  * expire the next.
107  *
108  * \return
109  * A reference to the neighbor about to expire the next or NULL if
110  * table is empty.
111  */
113 
114 #endif /* UIP_DS6_NEIGHBOR_H_ */
115 /** @} */
static uip_ipaddr_t ipaddr
Pointer to prefix information option in uip_buf.
Definition: uip-nd6.c:129
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...
Header file for IPv6-related data structures.
An entry in the nbr cache.
Definition: uip-ds6-nbr.h:70
Second timer library header file.
802.3 address
Definition: uip.h:129
static uip_ds6_nbr_t * nbr
Pointer to llao option in uip_buf.
Definition: uip-nd6.c:122
struct uip_ds6_nbr uip_ds6_nbr_t
An entry in the nbr cache.
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:83
Header file for the uIP TCP/IP stack.
A timer.
Definition: stimer.h:81