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  * \file
34  * IPv6 Neighbor cache (link-layer/IPv6 address mapping)
35  * \author Mathilde Durvy <mdurvy@cisco.com>
36  * \author Julien Abeille <jabeille@cisco.com>
37  * \author Simon Duquennoy <simonduq@sics.se>
38  *
39  */
40 
41 /**
42  * \addtogroup uip6
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  struct stimer reachable;
73  struct stimer sendns;
74  uint8_t nscount;
75  uint8_t isrouter;
76  uint8_t state;
77 #if UIP_CONF_IPV6_QUEUE_PKT
78  struct uip_packetqueue_handle packethandle;
79 #define UIP_DS6_NBR_PACKET_LIFETIME CLOCK_SECOND * 4
80 #endif /*UIP_CONF_QUEUE_PKT */
82 
83 void uip_ds6_neighbors_init(void);
84 
85 /** \brief Neighbor Cache basic routines */
86 uip_ds6_nbr_t *uip_ds6_nbr_add(const uip_ipaddr_t *ipaddr, const uip_lladdr_t *lladdr,
87  uint8_t isrouter, uint8_t state);
88 void uip_ds6_nbr_rm(uip_ds6_nbr_t *nbr);
89 const uip_lladdr_t *uip_ds6_nbr_get_ll(const uip_ds6_nbr_t *nbr);
90 const uip_ipaddr_t *uip_ds6_nbr_get_ipaddr(const uip_ds6_nbr_t *nbr);
91 uip_ds6_nbr_t *uip_ds6_nbr_lookup(const uip_ipaddr_t *ipaddr);
92 uip_ds6_nbr_t *uip_ds6_nbr_ll_lookup(const uip_lladdr_t *lladdr);
93 uip_ipaddr_t *uip_ds6_nbr_ipaddr_from_lladdr(const uip_lladdr_t *lladdr);
94 const uip_lladdr_t *uip_ds6_nbr_lladdr_from_ipaddr(const uip_ipaddr_t *ipaddr);
95 void uip_ds6_link_neighbor_callback(int status, int numtx);
96 void uip_ds6_neighbor_periodic(void);
97 int uip_ds6_nbr_num(void);
98 
99 /**
100  * \brief
101  * This searches inside the neighbor table for the neighbor that is about to
102  * expire the next.
103  *
104  * \return
105  * A reference to the neighbor about to expire the next or NULL if
106  * table is empty.
107  */
109 
110 #endif /* UIP_DS6_NEIGHBOR_H_ */
111 /** @} */
Second timer library header file.
Header file for the uIP TCP/IP stack.
Network interface and stateless autoconfiguration (RFC 4862)
802.3 address
Definition: uip.h:135
struct uip_ds6_nbr uip_ds6_nbr_t
An entry in the nbr cache.
A timer.
Definition: stimer.h:81
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...
Definition: uip-ds6-nbr.c:281
uip_ds6_nbr_t * uip_ds6_nbr_add(const uip_ipaddr_t *ipaddr, const uip_lladdr_t *lladdr, uint8_t isrouter, uint8_t state)
Neighbor Cache basic routines.
Definition: uip-ds6-nbr.c:81
An entry in the nbr cache.
Definition: uip-ds6-nbr.h:70