Contiki-NG
rpl-neighbor.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010, 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 * This file is part of the Contiki operating system.
30 *
31 */
32
33 /**
34 * \addtogroup rpl-lite
35 * @{
36 *
37 * \file
38 * Header file for rpl-neighbor module
39 * \author
40 * Joakim Eriksson <joakime@sics.se>, Nicolas Tsiftes <nvt@sics.se>,
41 * Simon DUquennoy <simon.duquennoy@inria.fr>
42 *
43 */
44
45#ifndef RPL_NEIGHBOR_H
46#define RPL_NEIGHBOR_H
47
48/********** Includes **********/
49
50#include "net/routing/rpl-lite/rpl.h"
51#include "lib/list.h"
52#include "net/ipv6/uip.h"
53#include "net/ipv6/uip-ds6.h"
54#include "sys/ctimer.h"
55
56/********** Public symbols **********/
57
58/* Per-neighbor RPL information. According to RFC 6550, there exist three
59 * types of neighbors:
60 * - Candidate neighbor set: any neighbor, selected in an implementation
61 * and OF-specific way. The nodes in rpl_neighbors constitute the candidate neighbor set.
62 * - Parent set: the subset of the candidate neighbor set with rank below our rank
63 * - Preferred parent: one node of the parent set
64 */
65NBR_TABLE_DECLARE(rpl_neighbors);
66
67/********** Public functions **********/
68
69/**
70 * Initialize rpl-dag-neighbor module
71*/
72void rpl_neighbor_init(void);
73
74/**
75 * Tells whether a neighbor is in the parent set.
76 *
77 * \param nbr The neighbor to be tested
78 * \return 1 if nbr is in the parent set, 0 otherwise
79 */
81
82/**
83 * Set current RPL preferred parent and update DS6 default route accordingly
84 *
85 * \param nbr The new preferred parent
86*/
88
89/**
90 * Tells wether we have fresh link information towards a given neighbor
91 *
92 * \param nbr The neighbor
93 * \return 1 if we have fresh link information, 0 otherwise
94*/
96
97/**
98 * Tells whether a nbr is acceptable as per the OF's definition
99 *
100 * \param nbr The neighbor
101 * \return 1 if acceptable, 0 otherwise
102*/
104
105/**
106 * Returns a neighbor's link metric
107 *
108 * \param nbr The neighbor
109 * \return The link metric if any, 0xffff otherwise
110*/
112
113/**
114 * Returns our rank if selecting a given parent as preferred parent
115 *
116 * \param nbr The neighbor
117 * \return The resulting rank if any, RPL_INFINITE_RANK otherwise
118*/
120
121/**
122 * Returns a neighbors's link-layer address
123 *
124 * \param nbr The neighbor
125 * \return The link-layer address if any, NULL otherwise
126*/
127const linkaddr_t *rpl_neighbor_get_lladdr(rpl_nbr_t *nbr);
128
129/**
130 * Returns a neighbor's link statistics
131 *
132 * \param nbr The neighbor
133 * \return The link_stats structure address if any, NULL otherwise
134*/
135const struct link_stats *rpl_neighbor_get_link_stats(rpl_nbr_t *nbr);
136
137/**
138 * Returns a neighbor's (link-local) IPv6 address
139 *
140 * \param nbr The neighbor
141 * \return The link-local IPv6 address if any, NULL otherwise
142*/
144
145/**
146 * Returns a neighbor from its link-layer address
147 *
148 * \param addr The link-layer address
149 * \return The neighbor if found, NULL otherwise
150*/
152
153/**
154 * Returns a neighbor from its link-local IPv6 address
155 *
156 * \param addr The link-local IPv6 address
157 * \return The neighbor if found, NULL otherwise
158*/
160
161/**
162 * Returns the number of nodes in the RPL neighbor table
163 *
164 * \return the neighbor count
165*/
166int rpl_neighbor_count(void);
167
168/**
169 * Prints a summary of all RPL neighbors and their properties
170 *
171 * \param str A descriptive text on the caller
172*/
173void rpl_neighbor_print_list(const char *str);
174
175/**
176 * Empty the RPL neighbor table
177*/
178void rpl_neighbor_remove_all(void);
179
180/**
181 * Returns the best candidate for preferred parent
182 *
183 * \return The best candidate, NULL if no usable parent is found
184*/
186
187/**
188* Print a textual description of RPL neighbor into a string
189*
190* \param buf The buffer where to write content
191* \param buflen The buffer len
192* \param nbr A pointer to a RPL neighbor that will be written to the buffer
193* \return Identical to snprintf: number of bytes written excluding ending null
194* byte. A value >= buflen if the buffer was too small.
195*/
196int rpl_neighbor_snprint(char *buf, int buflen, rpl_nbr_t *nbr);
197
198typedef rpl_nbr_t rpl_parent_t;
199#define rpl_parent_get_from_ipaddr(addr) rpl_neighbor_get_from_ipaddr(addr)
200#define rpl_parent_get_ipaddr(nbr) rpl_neighbor_get_ipaddr(nbr)
201 /** @} */
202
203#endif /* RPL_NEIGHBOR_H */
Header file for the callback timer.
void rpl_neighbor_init(void)
Initialize rpl-dag-neighbor module.
Definition: rpl-neighbor.c:442
rpl_nbr_t * rpl_neighbor_get_from_lladdr(uip_lladdr_t *addr)
Returns a neighbor from its link-layer address.
Definition: rpl-neighbor.c:213
rpl_rank_t rpl_neighbor_rank_via_nbr(rpl_nbr_t *nbr)
Returns our rank if selecting a given parent as preferred parent.
Definition: rpl-neighbor.c:237
uint16_t rpl_neighbor_get_link_metric(rpl_nbr_t *nbr)
Returns a neighbor's link metric.
Definition: rpl-neighbor.c:228
void rpl_neighbor_remove_all(void)
Empty the RPL neighbor table.
Definition: rpl-neighbor.c:309
const linkaddr_t * rpl_neighbor_get_lladdr(rpl_nbr_t *nbr)
Returns a neighbors's link-layer address.
Definition: rpl-neighbor.c:246
int rpl_neighbor_is_fresh(rpl_nbr_t *nbr)
Tells wether we have fresh link information towards a given neighbor.
Definition: rpl-neighbor.c:266
int rpl_neighbor_is_parent(rpl_nbr_t *nbr)
Tells whether a neighbor is in the parent set.
Definition: rpl-neighbor.c:273
int rpl_neighbor_snprint(char *buf, int buflen, rpl_nbr_t *nbr)
Print a textual description of RPL neighbor into a string.
Definition: rpl-neighbor.c:90
const struct link_stats * rpl_neighbor_get_link_stats(rpl_nbr_t *nbr)
Returns a neighbor's link statistics.
Definition: rpl-neighbor.c:259
rpl_nbr_t * rpl_neighbor_get_from_ipaddr(uip_ipaddr_t *addr)
Returns a neighbor from its link-local IPv6 address.
Definition: rpl-neighbor.c:332
void rpl_neighbor_set_preferred_parent(rpl_nbr_t *nbr)
Set current RPL preferred parent and update DS6 default route accordingly.
Definition: rpl-neighbor.c:279
uip_ipaddr_t * rpl_neighbor_get_ipaddr(rpl_nbr_t *nbr)
Returns a neighbor's (link-local) IPv6 address.
Definition: rpl-neighbor.c:252
void rpl_neighbor_print_list(const char *str)
Prints a summary of all RPL neighbors and their properties.
Definition: rpl-neighbor.c:143
rpl_nbr_t * rpl_neighbor_select_best(void)
Returns the best candidate for preferred parent.
Definition: rpl-neighbor.c:378
int rpl_neighbor_is_acceptable_parent(rpl_nbr_t *nbr)
Tells whether a nbr is acceptable as per the OF's definition.
Definition: rpl-neighbor.c:219
int rpl_neighbor_count(void)
Returns the number of nodes in the RPL neighbor table.
Definition: rpl-neighbor.c:168
Linked list manipulation routines.
All information related to a RPL neighbor.
Definition: rpl-types.h:136
Header file for IPv6-related data structures.
static uip_ds6_nbr_t * nbr
Pointer to llao option in uip_buf.
Definition: uip-nd6.c:106
static uip_ds6_addr_t * addr
Pointer to a nbr cache entry.
Definition: uip-nd6.c:107
Header file for the uIP TCP/IP stack.