Contiki-NG
rpl-const.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  * Constants 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_CONST_H
46 #define RPL_CONST_H
47 
48 /********** Constants **********/
49 
50 /* Special value indicating infinite lifetime. */
51 #define RPL_INFINITE_LIFETIME 0xFF
52 #define RPL_ROUTE_INFINITE_LIFETIME 0xFFFFFFFF
53 #define RPL_INFINITE_RANK 0xFFFF
54 
55 /*---------------------------------------------------------------------------*/
56 /* IANA Routing Metric/Constraint Type as defined in RFC6551 */
57 #define RPL_DAG_MC_NONE 0 /* Local identifier for empty MC */
58 #define RPL_DAG_MC_NSA 1 /* Node State and Attributes */
59 #define RPL_DAG_MC_ENERGY 2 /* Node Energy */
60 #define RPL_DAG_MC_HOPCOUNT 3 /* Hop Count */
61 #define RPL_DAG_MC_THROUGHPUT 4 /* Throughput */
62 #define RPL_DAG_MC_LATENCY 5 /* Latency */
63 #define RPL_DAG_MC_LQL 6 /* Link Quality Level */
64 #define RPL_DAG_MC_ETX 7 /* Expected Transmission Count */
65 #define RPL_DAG_MC_LC 8 /* Link Color */
66 
67 /* IANA Routing Metric/Constraint Common Header Flag field as defined in RFC6551 (bit indexes) */
68 #define RPL_DAG_MC_FLAG_P 5
69 #define RPL_DAG_MC_FLAG_C 6
70 #define RPL_DAG_MC_FLAG_O 7
71 #define RPL_DAG_MC_FLAG_R 8
72 
73 /* IANA Routing Metric/Constraint Common Header A Field as defined in RFC6551 */
74 #define RPL_DAG_MC_AGGR_ADDITIVE 0
75 #define RPL_DAG_MC_AGGR_MAXIMUM 1
76 #define RPL_DAG_MC_AGGR_MINIMUM 2
77 #define RPL_DAG_MC_AGGR_MULTIPLICATIVE 3
78 
79 /* The bit index within the flags field of the rpl_metric_object_energy structure. */
80 #define RPL_DAG_MC_ENERGY_INCLUDED 3
81 #define RPL_DAG_MC_ENERGY_TYPE 1
82 #define RPL_DAG_MC_ENERGY_ESTIMATION 0
83 
84 /* IANA Node Type Field as defined in RFC6551 */
85 #define RPL_DAG_MC_ENERGY_TYPE_MAINS 0
86 #define RPL_DAG_MC_ENERGY_TYPE_BATTERY 1
87 #define RPL_DAG_MC_ENERGY_TYPE_SCAVENGING 2
88 
89 /* IANA Objective Code Point as defined in RFC6550 */
90 #define RPL_OCP_OF0 0
91 #define RPL_OCP_MRHOF 1
92 
93 /*---------------------------------------------------------------------------*/
94 /* RPL message types */
95 #define RPL_CODE_DIS 0x00 /* DAG Information Solicitation */
96 #define RPL_CODE_DIO 0x01 /* DAG Information Option */
97 #define RPL_CODE_DAO 0x02 /* Destination Advertisement Option */
98 #define RPL_CODE_DAO_ACK 0x03 /* DAO acknowledgment */
99 #define RPL_CODE_SEC_DIS 0x80 /* Secure DIS */
100 #define RPL_CODE_SEC_DIO 0x81 /* Secure DIO */
101 #define RPL_CODE_SEC_DAO 0x82 /* Secure DAO */
102 #define RPL_CODE_SEC_DAO_ACK 0x83 /* Secure DAO-ACK */
103 
104 /* RPL control message options. */
105 #define RPL_OPTION_PAD1 0
106 #define RPL_OPTION_PADN 1
107 #define RPL_OPTION_DAG_METRIC_CONTAINER 2
108 #define RPL_OPTION_ROUTE_INFO 3
109 #define RPL_OPTION_DAG_CONF 4
110 #define RPL_OPTION_TARGET 5
111 #define RPL_OPTION_TRANSIT 6
112 #define RPL_OPTION_SOLICITED_INFO 7
113 #define RPL_OPTION_PREFIX_INFO 8
114 #define RPL_OPTION_TARGET_DESC 9
115 
116 #define RPL_DAO_K_FLAG 0x80 /* DAO-ACK requested */
117 #define RPL_DAO_D_FLAG 0x40 /* DODAG ID present */
118 
119 #define RPL_DAO_ACK_UNCONDITIONAL_ACCEPT 0
120 #define RPL_DAO_ACK_ACCEPT 1 /* 1 - 127 is OK but not good */
121 #define RPL_DAO_ACK_UNABLE_TO_ACCEPT 128 /* >127 is fail */
122 #define RPL_DAO_ACK_UNABLE_TO_ADD_ROUTE_AT_ROOT 255 /* root can not accept */
123 #define RPL_DAO_ACK_TIMEOUT -1
124 
125 /*---------------------------------------------------------------------------*/
126 /* RPL IPv6 extension header option. */
127 #define RPL_HDR_OPT_LEN 4
128 #define RPL_HOP_BY_HOP_LEN (RPL_HDR_OPT_LEN + 2 + 2)
129 #define RPL_RH_LEN 4
130 #define RPL_SRH_LEN 4
131 #define RPL_RH_TYPE_SRH 3
132 #define RPL_HDR_OPT_DOWN 0x80
133 #define RPL_HDR_OPT_DOWN_SHIFT 7
134 #define RPL_HDR_OPT_RANK_ERR 0x40
135 #define RPL_HDR_OPT_RANK_ERR_SHIFT 6
136 #define RPL_HDR_OPT_FWD_ERR 0x20
137 #define RPL_HDR_OPT_FWD_ERR_SHIFT 5
138 
139 /*---------------------------------------------------------------------------*/
140 #define RPL_INSTANCE_LOCAL_FLAG 0x80
141 #define RPL_INSTANCE_D_FLAG 0x40
142 
143 /* Values that tell where a route came from. */
144 #define RPL_ROUTE_FROM_INTERNAL 0
145 #define RPL_ROUTE_FROM_UNICAST_DAO 1
146 #define RPL_ROUTE_FROM_MULTICAST_DAO 2
147 #define RPL_ROUTE_FROM_DIO 3
148 
149 /* DAG Mode of Operation */
150 #define RPL_MOP_NO_DOWNWARD_ROUTES 0
151 #define RPL_MOP_NON_STORING 1
152 #define RPL_MOP_STORING_NO_MULTICAST 2
153 #define RPL_MOP_STORING_MULTICAST 3
154 
155  /** @} */
156 
157 #endif /* RPL_CONST_H */