structs.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 INRIA.
3  * Copyright (C) 2015 Cenk Gündoğan <cnkgndgn@gmail.com>
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
23 #ifndef NET_GNRC_RPL_STRUCTS_H
24 #define NET_GNRC_RPL_STRUCTS_H
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #include "net/gnrc/ipv6/netif.h"
31 #include "net/ipv6/addr.h"
32 #include "xtimer.h"
33 #include "trickle.h"
34 
39 #define GNRC_RPL_OPT_DODAG_CONF_LEN (14)
40 #define GNRC_RPL_OPT_PREFIX_INFO_LEN (30)
41 #define GNRC_RPL_OPT_TARGET_LEN (18)
42 #define GNRC_RPL_OPT_TRANSIT_INFO_LEN (4)
43 
49 #define GNRC_RPL_DAO_D_BIT (1 << 6)
50 #define GNRC_RPL_DAO_K_BIT (1 << 7)
51 
57 #define GNRC_RPL_DAO_ACK_D_BIT (1 << 7)
58 
65 #define GNRC_RPL_REQ_DIO_OPT_DODAG_CONF_SHIFT (0)
66 #define GNRC_RPL_REQ_DIO_OPT_DODAG_CONF (1 << GNRC_RPL_REQ_DIO_OPT_DODAG_CONF_SHIFT)
67 #define GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO_SHIFT (1)
68 #define GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO (1 << GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO_SHIFT)
69 
77 typedef struct __attribute__((packed)) {
78  uint8_t type;
79  uint8_t length;
81 
88 typedef struct __attribute__((packed)) {
89  uint8_t instance_id;
90  uint8_t version_number;
92  uint8_t g_mop_prf;
93  uint8_t dtsn;
94  uint8_t flags;
95  uint8_t reserved;
98 
105 typedef struct __attribute__((packed)) {
106  uint8_t type;
107  uint8_t length;
108  uint8_t flags_a_pcs;
109  uint8_t dio_int_doubl;
110  uint8_t dio_int_min;
111  uint8_t dio_redun;
115  uint8_t reserved;
119 
126 typedef struct __attribute__((packed)) {
127  uint8_t flags;
128  uint8_t reserved;
130 
137 typedef struct __attribute__((packed)) {
138  uint8_t instance_id;
139  uint8_t k_d_flags;
140  uint8_t reserved;
141  uint8_t dao_sequence;
143 
150 typedef struct __attribute__((packed)) {
151  uint8_t instance_id;
152  uint8_t d_reserved;
153  uint8_t dao_sequence;
154  uint8_t status;
156 
163 typedef struct __attribute__((packed)) {
164  uint8_t type;
165  uint8_t length;
166  uint8_t flags;
167  uint8_t prefix_length;
170 
177 typedef struct __attribute__((packed)) {
178  uint8_t type;
179  uint8_t length;
180  uint8_t e_flags;
181  uint8_t path_control;
182  uint8_t path_sequence;
183  uint8_t path_lifetime;
185 
192 typedef struct __attribute__((packed)) {
193  uint8_t type;
194  uint8_t length;
195  uint8_t prefix_len;
196  uint8_t LAR_flags;
197  uint32_t valid_lifetime;
198  uint32_t pref_lifetime;
199  uint32_t reserved;
202 
206 typedef struct gnrc_rpl_dodag gnrc_rpl_dodag_t;
207 
211 typedef struct gnrc_rpl_parent gnrc_rpl_parent_t;
212 
216 typedef struct gnrc_rpl_instance gnrc_rpl_instance_t;
217 
220 struct gnrc_rpl_parent {
221  gnrc_rpl_parent_t *next;
222  uint8_t state;
223  ipv6_addr_t addr;
224  uint8_t dtsn;
225  uint16_t rank;
226  gnrc_rpl_dodag_t *dodag;
227  uint32_t lifetime;
228  double link_metric;
229  uint8_t link_metric_type;
230 };
238 typedef struct {
239  uint16_t ocp;
240  uint16_t (*calc_rank)(gnrc_rpl_parent_t *parent, uint16_t base_rank);
241  gnrc_rpl_parent_t *(*which_parent)(gnrc_rpl_parent_t *, gnrc_rpl_parent_t *);
242  gnrc_rpl_dodag_t *(*which_dodag)(gnrc_rpl_dodag_t *, gnrc_rpl_dodag_t *);
243  void (*reset)(gnrc_rpl_dodag_t *);
244  void (*parent_state_callback)(gnrc_rpl_parent_t *, int, int);
245  void (*init)(void);
246  void (*process_dio)(void);
247 } gnrc_rpl_of_t;
248 
252 struct gnrc_rpl_dodag {
253  ipv6_addr_t dodag_id;
254  gnrc_ipv6_netif_addr_t *netif_addr;
255  gnrc_rpl_parent_t *parents;
256  gnrc_rpl_instance_t *instance;
257  uint8_t dtsn;
258  uint8_t prf;
259  uint8_t dio_interval_doubl;
260  uint8_t dio_min;
261  uint8_t dio_redun;
262  uint8_t default_lifetime;
263  uint16_t lifetime_unit;
264  kernel_pid_t iface;
265  uint8_t version;
266  uint8_t grounded;
267  uint16_t my_rank;
268  uint8_t node_status;
269  uint8_t dao_seq;
270  uint8_t dao_counter;
271  bool dao_ack_received;
272  uint8_t dio_opts;
274  uint8_t dao_time;
275  trickle_t trickle;
276 };
277 
278 struct gnrc_rpl_instance {
279  uint8_t id;
280  uint8_t state;
281  gnrc_rpl_dodag_t dodag;
282  uint8_t mop;
283  gnrc_rpl_of_t *of;
284  uint16_t min_hop_rank_inc;
285  uint16_t max_rank_inc;
286  int8_t cleanup;
287 };
292 #ifdef __cplusplus
293 }
294 #endif
295 
296 #endif /* NET_GNRC_RPL_STRUCTS_H */
297 
Trickle timer interface definition.
uint8_t flags
unused
Definition: structs.h:127
uint8_t dao_sequence
sequence must be equal to the sequence from the DAO object
Definition: structs.h:153
uint8_t g_mop_prf
grounded, MOP, preferred flags
Definition: structs.h:92
uint8_t length
option length without the first two bytes
Definition: structs.h:165
uint8_t flags_a_pcs
flags
Definition: structs.h:108
struct gnrc_rpl_parent gnrc_rpl_parent_t
Parent representation.
Definition: structs.h:211
Objective function representation.
Definition: structs.h:238
Target Option.
Definition: structs.h:163
Definitions for IPv6 addresses.
uint8_t path_control
limits the number of DAO parents
Definition: structs.h:181
uint8_t type
option type
Definition: structs.h:164
uint32_t pref_lifetime
preferred lifetime
Definition: structs.h:198
int16_t kernel_pid_t
Unique process identifier.
Definition: kernel_types.h:83
uint8_t dio_int_min
trickle Imin parameter
Definition: structs.h:110
uint8_t length
option length without the first two bytes
Definition: structs.h:194
network_uint16_t max_rank_inc
allowable increase in rank
Definition: structs.h:112
all state variables of a trickle timer
Definition: trickle.h:49
A 16 bit integer in big endian aka network byte order.
Definition: byteorder.h:76
uint8_t path_lifetime
lifetime of routes
Definition: structs.h:183
uint8_t type
Option Type: 0x04.
Definition: structs.h:106
uint8_t reserved
reserved
Definition: structs.h:140
uint8_t dtsn
Destination Advertisement Trigger Sequence Number.
Definition: structs.h:93
Definitions for IPv6 specific information of network interfaces.
DIO Base Object.
Definition: structs.h:88
uint8_t dao_sequence
sequence of the DAO, needs to be used for DAO-ACK
Definition: structs.h:141
network_uint16_t ocp
Objective Code Point.
Definition: structs.h:114
uint8_t length
Option Length, does not include the first two byte.
Definition: structs.h:79
uint8_t LAR_flags
flags and resereved
Definition: structs.h:196
uint8_t prefix_len
prefix length
Definition: structs.h:195
uint8_t reserved
reserved
Definition: structs.h:115
uint32_t valid_lifetime
valid lifetime
Definition: structs.h:197
network_uint16_t min_hop_rank_inc
DAGRank(rank) = floor(rank/MinHopRankIncrease)
Definition: structs.h:113
Transit Option.
Definition: structs.h:177
uint8_t length
length of option, not including first two bytes
Definition: structs.h:107
uint8_t flags
unused
Definition: structs.h:166
uint8_t instance_id
id of the instance
Definition: structs.h:138
struct gnrc_rpl_instance gnrc_rpl_instance_t
Instance representation.
Definition: structs.h:216
uint8_t status
indicates completion
Definition: structs.h:154
uint8_t flags
unused
Definition: structs.h:94
uint8_t dio_redun
trickle k parameter
Definition: structs.h:111
xtimer interface definitions
network_uint16_t rank
rank of the parent emitting the DIO
Definition: structs.h:91
uint8_t type
option type
Definition: structs.h:178
Destination Advertisement Object.
Definition: structs.h:137
RPL-Option Generic Format.
Definition: structs.h:77
uint8_t reserved
reserved
Definition: structs.h:95
uint8_t prefix_length
number of valid leading bits in the IPv6 prefix
Definition: structs.h:167
uint8_t length
option length without the first two bytes
Definition: structs.h:179
Type to represent an IPv6 address registered to an interface.
Definition: ipv6/netif.h:243
uint8_t type
option type
Definition: structs.h:193
uint8_t dio_int_doubl
trickle Imax parameter
Definition: structs.h:109
Prefix Information Option.
Definition: structs.h:192
uint8_t reserved
reserved
Definition: structs.h:128
uint8_t version_number
version number of the DODAG
Definition: structs.h:90
uint8_t e_flags
external flag indicates external routes
Definition: structs.h:180
ipv6_addr_t dodag_id
id of the dodag
Definition: structs.h:96
uint8_t default_lifetime
lifetime of RPL routes (lifetime * lifetime_unit)
Definition: structs.h:116
ipv6_addr_t target
IPv6 prefix, address or multicast group.
Definition: structs.h:168
DODAG Information Solicitation.
Definition: structs.h:126
Data type to represent an IPv6 address.
Definition: ipv6/addr.h:74
uint8_t path_sequence
increased value for route updates
Definition: structs.h:182
uint16_t ocp
objective code point
Definition: structs.h:239
DODAG Configuration Option.
Definition: structs.h:105
uint8_t type
Option Type.
Definition: structs.h:78
ipv6_addr_t prefix
prefix used for Stateless Address Autoconfiguration
Definition: structs.h:200
Destination Advertisement Object Acknowledgement.
Definition: structs.h:150
uint32_t reserved
reserved
Definition: structs.h:199
network_uint16_t lifetime_unit
unit in seconds
Definition: structs.h:117
uint8_t d_reserved
if set, indicates that the DODAG id should be included
Definition: structs.h:152
uint8_t k_d_flags
K and D flags.
Definition: structs.h:139
uint8_t instance_id
id of the instance
Definition: structs.h:151
struct gnrc_rpl_dodag gnrc_rpl_dodag_t
DODAG representation.
Definition: structs.h:206
uint8_t instance_id
id of the instance
Definition: structs.h:89