Contiki-NG
rpl-dag.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-dag 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_DAG_H
46#define RPL_DAG_H
47
48/********** Includes **********/
49
50#include "uip.h"
51
52/********** Public functions **********/
53
54/**
55 * Returns a textual description of the current DAG state
56 *
57 * \param state The DAG state
58 * \return The description string
59*/
60const char *rpl_dag_state_to_str(enum rpl_dag_state state);
61/**
62 * Returns the IPv6 address of the RPL DAG root, if any
63 *
64 * \param ipaddr A pointer where to copy the IP address of the DAG root
65 * \return 1 if the root address was copied, 0 otherwise
66*/
67int rpl_dag_get_root_ipaddr(uip_ipaddr_t *ipaddr);
68/**
69 * Start poisoning and leave the DAG after a delay
70 *
71*/
73/**
74 * Leaves the current DAG
75 *
76*/
77void rpl_dag_leave(void);
78/**
79 * A function called periodically. Used to age the DAG (decrease lifetime
80 * and expire DAG accordingly)
81 *
82 * \param seconds The number of seconds elapsted since last call
83*/
84void rpl_dag_periodic(unsigned seconds);
85
86/**
87 * Triggers a RPL global repair
88 *
89 * \param str A textual description of the cause for triggering a repair
90*/
91void rpl_global_repair(const char *str);
92
93/**
94 * Triggers a RPL local repair
95 *
96 * \param str A textual description of the cause for triggering a repair
97*/
98void rpl_local_repair(const char *str);
99
100/**
101 * Tells whether a given global IPv6 address is in our current DAG
102 *
103 * \param addr The global IPv6 address to be tested
104 * \return 1 if addr is in our current DAG, 0 otherwise
105*/
106int rpl_is_addr_in_our_dag(const uip_ipaddr_t *addr);
107
108/**
109 * Initializes DAG internal structure for a root node
110 *
111 * \param instance_id The instance ID
112 * \param dag_id The DAG ID
113 * \param prefix The prefix
114 * \param prefix_len The prefix length
115 * \param flags The prefix flags (from DIO)
116*/
117void rpl_dag_init_root(uint8_t instance_id, uip_ipaddr_t *dag_id,
118 uip_ipaddr_t *prefix, unsigned prefix_len, uint8_t flags);
119
120/**
121 * Returns pointer to the default instance (for compatibility with legagy RPL code)
122 *
123 * \return A pointer to the only supported instance
124*/
126
127/**
128 * Returns pointer to any DAG (for compatibility with legagy RPL code)
129 *
130 * \return A pointer to the only supported DAG
131*/
133
134/**
135 * Processes Hop-by-Hop (HBH) Extension Header of a packet currently being forwrded.
136 *
137 * \param sender The IPv6 address of the originator
138 * \param sender_rank The rank advertised by the sender in the HBH header
139 * \param loop_detected 1 if we could detect a loop while forwarding, 0 otherwise
140 * \param rank_error_signaled 1 if the HBH header advertises a rank error, 0 otherwise
141 * \return 1 if the packet is to be forwarded, 0 if it is to be dropped
142*/
143int rpl_process_hbh(rpl_nbr_t *sender, uint16_t sender_rank, int loop_detected, int rank_error_signaled);
144
145/**
146 * Processes incoming DIS
147 *
148 * \param from The IPv6 address of the originator
149 * \param is_multicast Set to 1 for multicast DIS, 0 for unicast DIS
150*/
151void rpl_process_dis(uip_ipaddr_t *from, int is_multicast);
152
153/**
154 * Processes incoming DIO
155 *
156 * \param from The IPv6 address of the originator
157 * \param dio A pointer to a parsed DIO
158*/
159void rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio);
160
161/**
162 * Processes incoming DAO
163 *
164 * \param from The IPv6 address of the originator
165 * \param dao A pointer to a parsed DAO
166*/
167void rpl_process_dao(uip_ipaddr_t *from, rpl_dao_t *dao);
168
169/**
170 * Processes incoming DAO-ACK
171 *
172 * \param sequence The DAO-ACK sequence number
173 * \param status The DAO-ACK status (see RPL_DAO_ACK_* defines)
174*/
175void rpl_process_dao_ack(uint8_t sequence, uint8_t status);
176
177/**
178 * Tells whether RPL is ready to advertise the DAG
179 *
180 * \return 1 is ready, 0 otherwise
181*/
183
184/**
185 * Updates RPL internal state: selects preferred parent, updates rank & metreic
186 * container, triggers control traffic accordingly and updates uIP6 internal state.
187*/
188void rpl_dag_update_state(void);
189
190/**
191 * Initializes rpl-dag module
192*/
193void rpl_dag_init(void);
194
195 /** @} */
196
197#endif /* RPL_DAG_H */
int rpl_dag_get_root_ipaddr(uip_ipaddr_t *ipaddr)
Returns the IPv6 address of the RPL DAG root, if any.
Definition: rpl-dag.c:89
void rpl_process_dao_ack(uint8_t sequence, uint8_t status)
Processes incoming DAO-ACK.
void rpl_dag_update_state(void)
Updates RPL internal state: selects preferred parent, updates rank & metreic container,...
Definition: rpl-dag.c:266
void rpl_dag_periodic(unsigned seconds)
A function called periodically.
Definition: rpl-dag.c:138
void rpl_dag_init_root(uint8_t instance_id, uip_ipaddr_t *dag_id, uip_ipaddr_t *prefix, unsigned prefix_len, uint8_t prefix_flags)
Initializes DAG internal structure for a root node.
Definition: rpl-dag.c:713
void rpl_process_dis(uip_ipaddr_t *from, int is_multicast)
Processes incoming DIS.
Definition: rpl-dag.c:619
void rpl_dag_poison_and_leave(void)
Start poisoning and leave the DAG after a delay.
Definition: rpl-dag.c:131
void rpl_process_dao(uip_ipaddr_t *from, rpl_dao_t *dao)
Processes incoming DAO.
Definition: rpl-dag.c:633
void rpl_global_repair(const char *str)
Triggers a RPL global repair.
Definition: rpl-dag.c:204
int rpl_dag_ready_to_advertise(void)
Tells whether RPL is ready to advertise the DAG.
Definition: rpl-dag.c:255
rpl_dag_state
RPL DAG states.
Definition: rpl-types.h:177
int rpl_process_hbh(rpl_nbr_t *sender, uint16_t sender_rank, int loop_detected, int rank_error_signaled)
Processes Hop-by-Hop (HBH) Extension Header of a packet currently being forwrded.
Definition: rpl-dag.c:680
const char * rpl_dag_state_to_str(enum rpl_dag_state state)
Returns a textual description of the current DAG state.
Definition: rpl-dag.c:72
void rpl_dag_leave(void)
Leaves the current DAG.
Definition: rpl-dag.c:99
void rpl_local_repair(const char *str)
Triggers a RPL local repair.
Definition: rpl-dag.c:240
int rpl_is_addr_in_our_dag(const uip_ipaddr_t *addr)
Tells whether a given global IPv6 address is in our current DAG.
Definition: rpl-dag.c:158
rpl_dag_t * rpl_get_any_dag(void)
Returns pointer to any DAG (for compatibility with legagy RPL code)
Definition: rpl-dag.c:1090
void rpl_dag_init(void)
Initializes rpl-dag module.
Definition: rpl-dag.c:140
void rpl_process_dio(uip_ipaddr_t *from, rpl_dio_t *dio)
Processes incoming DIO.
Definition: rpl-dag.c:1491
rpl_instance_t * rpl_get_default_instance(void)
Returns pointer to the default instance (for compatibility with legagy RPL code)
Definition: rpl-dag.c:634
RPL DAG structure.
Definition: rpl.h:138
RPL instance structure.
Definition: rpl.h:222
All information related to a RPL neighbor.
Definition: rpl-types.h:136
static uip_ipaddr_t ipaddr
Pointer to prefix information option in uip_buf.
Definition: uip-nd6.c:116
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.