Contiki-NG
rpl.h
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  * \ingroup net-layer
32  * \addtogroup rpl-lite
33  RPL-lite is a lightweight implementation of RPL tailored for reliability.
34  Supports only non-storing mode, one instance and one DAG.
35  * @{
36  *
37  * \file
38  * Public API declarations for RPL.
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_H
46 #define RPL_H
47 
48 /********** Includes **********/
49 
50 #include "net/ipv6/uip.h"
60 
61 /********** Public symbols **********/
62 
63 /* The only instance */
64 extern rpl_instance_t curr_instance;
65 /* The RPL multicast address (used for DIS and DIO) */
66 extern uip_ipaddr_t rpl_multicast_addr;
67 
68 /********** Public functions **********/
69 
70 /**
71  * Called by lower layers after every packet transmission
72  *
73  * \param addr The link-layer addrress of the packet destination
74  * \param status The transmission status (see os/net/mac/mac.h)
75  * \param numtx The total number of transmission attempts
76  */
77 void rpl_link_callback(const linkaddr_t *addr, int status, int numtx);
78 
79 /**
80  * Set prefix from an prefix data structure (from DIO)
81  *
82  * \param prefix The prefix
83  * \return 1 if success, 0 otherwise
84  */
85 int rpl_set_prefix(rpl_prefix_t *prefix);
86 /**
87 * Set prefix from an IPv6 address
88 *
89 * \param addr The prefix
90 * \param len The prefix length
91 * \param flags The DIO prefix flags
92 * \return 1 if success, 0 otherwise
93 */
94 
95 int rpl_set_prefix_from_addr(uip_ipaddr_t *addr, unsigned len, uint8_t flags);
96 
97 /**
98  * Removes current prefx
99  *
100  * \param last_prefix The last prefix (which is to be removed)
101  */
102 void rpl_reset_prefix(rpl_prefix_t *last_prefix);
103 
104 /**
105  * Get one of the node's global addresses
106  *
107  * \return A (constant) pointer to the global IPv6 address found.
108  * The pointer directs to the internals of DS6, should only be used
109  * in the current function's local scope
110  */
111 const uip_ipaddr_t *rpl_get_global_address(void);
112 
113 /**
114  * Get the RPL's best guess on if we are reachable via have downward route or not.
115  *
116  * \return 1 if we are reachable, 0 otherwise.
117  */
118 int rpl_is_reachable(void);
119 
120 /**
121  * Greater-than function for a lollipop counter
122  *
123  * \param a The first counter
124  * \param b The second counter
125  * \return 1 is a>b else 0
126  */
127 int rpl_lollipop_greater_than(int a, int b);
128 
129 /**
130  * Triggers a route fresh via DTSN increment
131  *
132  * \param str a textual description of the cause for refresh
133  */
134 void rpl_refresh_routes(const char *str);
135 
136 /**
137  * Changes the value of the rpl_leaf_only flag, which determines if a node acts
138  * only as a leaf in the network
139  *
140  * \param value the value to set: 0-disable, 1-enable
141  */
142 void rpl_set_leaf_only(uint8_t value);
143 
144 /**
145  * Get the value of the rpl_leaf_only flag
146  *
147  * \return The value of the rpl_leaf_only flag
148  */
149 uint8_t rpl_get_leaf_only(void);
150  /** @} */
151 
152 #endif /* RPL_H */
Header file for rpl-dag module.
void rpl_link_callback(const linkaddr_t *addr, int status, int numtx)
Called by lower layers after every packet transmission.
Definition: rpl.c:257
RPL instance structure.
Definition: rpl.h:219
Public configuration and API declarations for ContikiRPL.
static uip_ds6_addr_t * addr
Pointer to a nbr cache entry.
Definition: uip-nd6.c:116
int rpl_lollipop_greater_than(int a, int b)
Greater-than function for a lollipop counter.
Definition: rpl.c:57
void rpl_set_leaf_only(uint8_t value)
Changes the value of the rpl_leaf_only flag, which determines if a node acts only as a leaf in the ne...
Definition: rpl.c:233
uint8_t rpl_get_leaf_only(void)
Get the value of the rpl_leaf_only flag.
Definition: rpl.c:239
Header file for rpl-timers module.
RPL prefix information.
Definition: rpl.h:126
RPL types and macros.
int rpl_set_prefix_from_addr(uip_ipaddr_t *addr, unsigned len, uint8_t flags)
Set prefix from an IPv6 address.
Definition: rpl.c:154
int rpl_set_prefix(rpl_prefix_t *prefix)
Set prefix from an prefix data structure (from DIO)
Definition: rpl.c:182
int rpl_is_reachable(void)
Get the RPL&#39;s best guess on if we are reachable via have downward route or not.
Definition: rpl.c:124
Constants for RPL.
Header file for rpl-ext-header.
const uip_ipaddr_t * rpl_get_global_address(void)
Get one of the node&#39;s global addresses.
Definition: rpl.c:71
Header file for the uIP TCP/IP stack.
DAG root utility functions for RPL.
void rpl_refresh_routes(const char *str)
Triggers a route fresh via DTSN increment.
Definition: rpl-dag.c:189
Header file for rpl-ext-header.
Header file for rpl-neighbor module.
void rpl_reset_prefix(rpl_prefix_t *last_prefix)
Removes current prefx.
Definition: rpl.c:138