structs.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 HAW Hamburg
3  * Copyright (C) 2015–2018 Cenk Gündoğan <cenk.guendogan@haw-hamburg.de>
4  * Copyright (C) 2013 INRIA.
5  *
6  * This file is subject to the terms and conditions of the GNU Lesser
7  * General Public License v2.1. See the file LICENSE in the top level
8  * directory for more details.
9  */
10 
24 #ifndef NET_GNRC_RPL_STRUCTS_H
25 #define NET_GNRC_RPL_STRUCTS_H
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #include "byteorder.h"
32 #include "net/ipv6/addr.h"
33 #include "evtimer.h"
34 #include "evtimer_msg.h"
35 #include "trickle.h"
36 
41 #define GNRC_RPL_OPT_DODAG_CONF_LEN (14)
42 #define GNRC_RPL_OPT_PREFIX_INFO_LEN (30)
43 #define GNRC_RPL_OPT_TARGET_LEN (18)
44 #define GNRC_RPL_OPT_TRANSIT_INFO_LEN (4)
45 
51 #define GNRC_RPL_DAO_D_BIT (1 << 6)
52 #define GNRC_RPL_DAO_K_BIT (1 << 7)
53 
59 #define GNRC_RPL_DAO_ACK_D_BIT (1 << 7)
60 
67 #define GNRC_RPL_REQ_DIO_OPT_DODAG_CONF_SHIFT (0)
68 #define GNRC_RPL_REQ_DIO_OPT_DODAG_CONF (1 << GNRC_RPL_REQ_DIO_OPT_DODAG_CONF_SHIFT)
69 #define GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO_SHIFT (1)
70 #define GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO (1 << GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO_SHIFT)
71 
79 typedef struct __attribute__((packed)) {
80  uint8_t type;
81  uint8_t length;
83 
90 typedef struct __attribute__((packed)) {
91  uint8_t instance_id;
92  uint8_t version_number;
94  uint8_t g_mop_prf;
95  uint8_t dtsn;
96  uint8_t flags;
97  uint8_t reserved;
100 
107 typedef struct __attribute__((packed)) {
108  uint8_t type;
109  uint8_t length;
110  uint8_t flags_a_pcs;
111  uint8_t dio_int_doubl;
112  uint8_t dio_int_min;
113  uint8_t dio_redun;
117  uint8_t reserved;
121 
128 typedef struct __attribute__((packed)) {
129  uint8_t flags;
130  uint8_t reserved;
132 
139 typedef struct __attribute__((packed)) {
140  uint8_t type;
141  uint8_t length;
142  uint8_t instance_id;
143  uint8_t VID_flags;
145  uint8_t version_number;
147 
154 typedef struct __attribute__((packed)) {
155  uint8_t instance_id;
156  uint8_t k_d_flags;
157  uint8_t reserved;
158  uint8_t dao_sequence;
160 
167 typedef struct __attribute__((packed)) {
168  uint8_t instance_id;
169  uint8_t d_reserved;
170  uint8_t dao_sequence;
171  uint8_t status;
173 
180 typedef struct __attribute__((packed)) {
181  uint8_t type;
182  uint8_t length;
183  uint8_t flags;
184  uint8_t prefix_length;
187 
194 typedef struct __attribute__((packed)) {
195  uint8_t type;
196  uint8_t length;
197  uint8_t e_flags;
198  uint8_t path_control;
199  uint8_t path_sequence;
200  uint8_t path_lifetime;
202 
209 typedef struct __attribute__((packed)) {
210  uint8_t type;
211  uint8_t length;
213  uint8_t prefix_len;
214  uint8_t LAR_flags;
217  uint32_t reserved;
221 
225 typedef struct gnrc_rpl_dodag gnrc_rpl_dodag_t;
226 
230 typedef struct gnrc_rpl_parent gnrc_rpl_parent_t;
231 
235 typedef struct gnrc_rpl_instance gnrc_rpl_instance_t;
236 
239 struct gnrc_rpl_parent {
240  gnrc_rpl_parent_t *next;
241  uint8_t state;
242  ipv6_addr_t addr;
243  uint8_t dtsn;
244  uint16_t rank;
245  gnrc_rpl_dodag_t *dodag;
246  double link_metric;
247  uint8_t link_metric_type;
251  evtimer_msg_event_t timeout_event;
252 };
260 typedef struct {
261  uint16_t ocp;
272  uint16_t (*calc_rank)(gnrc_rpl_dodag_t *dodag, uint16_t base_rank);
273 
289  int (*parent_cmp)(gnrc_rpl_parent_t *parent1, gnrc_rpl_parent_t *parent2);
297  void (*reset)(gnrc_rpl_dodag_t *dodag);
298  void (*parent_state_callback)(gnrc_rpl_parent_t *, int, int);
305  void (*init)(gnrc_rpl_dodag_t *dodag);
306  void (*process_dio)(void);
307 } gnrc_rpl_of_t;
308 
312 struct gnrc_rpl_dodag {
313  ipv6_addr_t dodag_id;
314  gnrc_rpl_parent_t *parents;
315  gnrc_rpl_instance_t *instance;
316  uint8_t dtsn;
317  uint8_t prf;
318  uint8_t dio_interval_doubl;
319  uint8_t dio_min;
320  uint8_t dio_redun;
321  uint8_t default_lifetime;
322  uint16_t lifetime_unit;
323  kernel_pid_t iface;
324  uint8_t version;
325  uint8_t grounded;
326  uint16_t my_rank;
327  uint8_t node_status;
328  uint8_t dao_seq;
329  uint8_t dao_counter;
330  bool dao_ack_received;
331  uint8_t dio_opts;
333  evtimer_msg_event_t dao_event;
334  trickle_t trickle;
335 };
336 
337 struct gnrc_rpl_instance {
338  uint8_t id;
339  uint8_t state;
340  gnrc_rpl_dodag_t dodag;
341  uint8_t mop;
342  gnrc_rpl_of_t *of;
343  uint16_t min_hop_rank_inc;
344  uint16_t max_rank_inc;
348  evtimer_msg_event_t cleanup_event;
349 };
357 typedef struct {
358  uint8_t type;
359  uint8_t length;
361 
365 typedef struct {
366  uint8_t type;
367  uint8_t length;
368  uint8_t instance_id;
369  uint8_t VID_flags;
371  uint8_t version_number;
373 
374 #ifdef __cplusplus
375 }
376 #endif
377 
378 #endif /* NET_GNRC_RPL_STRUCTS_H */
379 
gnrc_rpl_dis_t
DODAG Information Solicitation.
Definition: structs.h:128
gnrc_rpl_opt_target_t
Target Option.
Definition: structs.h:180
gnrc_rpl_opt_transit_t::path_lifetime
uint8_t path_lifetime
lifetime of routes
Definition: structs.h:200
gnrc_rpl_opt_transit_t::type
uint8_t type
option type
Definition: structs.h:195
kernel_pid_t
int16_t kernel_pid_t
Unique process identifier.
Definition: sched.h:125
gnrc_rpl_opt_prefix_info_t::length
uint8_t length
option length without the first two bytes
Definition: structs.h:211
gnrc_rpl_dio_t::flags
uint8_t flags
unused
Definition: structs.h:96
gnrc_rpl_opt_dis_solicited_t::dodag_id
ipv6_addr_t dodag_id
DODAG ID predicate.
Definition: structs.h:144
gnrc_rpl_opt_dis_solicited_t::length
uint8_t length
Option Length: 19 bytes.
Definition: structs.h:141
gnrc_rpl_dao_ack_t::dao_sequence
uint8_t dao_sequence
sequence must be equal to the sequence from the DAO object
Definition: structs.h:170
gnrc_rpl_dao_t::k_d_flags
uint8_t k_d_flags
K and D flags.
Definition: structs.h:156
be_uint32_t
A 32 bit integer in big endian aka network byte order.
Definition: byteorder.h:87
gnrc_rpl_internal_opt_dis_solicited_t::version_number
uint8_t version_number
version number of the DODAG
Definition: structs.h:371
gnrc_rpl_of_t
Objective function representation.
Definition: structs.h:260
gnrc_rpl_opt_transit_t::path_sequence
uint8_t path_sequence
increased value for route updates
Definition: structs.h:199
gnrc_rpl_opt_target_t::length
uint8_t length
option length without the first two bytes
Definition: structs.h:182
gnrc_rpl_dao_ack_t::d_reserved
uint8_t d_reserved
if set, indicates that the DODAG id should be included
Definition: structs.h:169
gnrc_rpl_opt_dodag_conf_t::ocp
network_uint16_t ocp
Objective Code Point.
Definition: structs.h:116
gnrc_rpl_dao_ack_t::instance_id
uint8_t instance_id
id of the instance
Definition: structs.h:168
byteorder.h
Functions to work with different byte orders.
gnrc_rpl_opt_dodag_conf_t::max_rank_inc
network_uint16_t max_rank_inc
allowable increase in rank
Definition: structs.h:114
be_uint16_t
A 16 bit integer in big endian aka network byte order.
Definition: byteorder.h:77
ipv6_addr_t
Data type to represent an IPv6 address.
Definition: addr.h:74
gnrc_rpl_opt_dodag_conf_t::dio_redun
uint8_t dio_redun
trickle k parameter
Definition: structs.h:113
gnrc_rpl_dio_t::dtsn
uint8_t dtsn
Destination Advertisement Trigger Sequence Number.
Definition: structs.h:95
addr.h
Definitions for IPv6 addresses.
gnrc_rpl_opt_dis_solicited_t::type
uint8_t type
Option Type: 0x07.
Definition: structs.h:140
gnrc_rpl_opt_dis_solicited_t::instance_id
uint8_t instance_id
id of the instance
Definition: structs.h:142
trickle.h
Trickle timer interface definition.
gnrc_rpl_internal_opt_dis_solicited_t::instance_id
uint8_t instance_id
id of the instance
Definition: structs.h:368
gnrc_rpl_internal_opt_dis_solicited_t::type
uint8_t type
Option Type: 0x07.
Definition: structs.h:366
gnrc_rpl_opt_transit_t
Transit Option.
Definition: structs.h:194
gnrc_rpl_instance_t
struct gnrc_rpl_instance gnrc_rpl_instance_t
Instance representation.
Definition: structs.h:235
gnrc_rpl_opt_prefix_info_t
Prefix Information Option.
Definition: structs.h:209
gnrc_rpl_dio_t::dodag_id
ipv6_addr_t dodag_id
id of the dodag
Definition: structs.h:98
gnrc_rpl_opt_prefix_info_t::LAR_flags
uint8_t LAR_flags
flags and resereved
Definition: structs.h:214
gnrc_rpl_internal_opt_dis_solicited_t
internal unpacked struct type for DIS solicited option insertion
Definition: structs.h:365
gnrc_rpl_opt_prefix_info_t::type
uint8_t type
option type
Definition: structs.h:210
gnrc_rpl_dio_t::g_mop_prf
uint8_t g_mop_prf
grounded, MOP, preferred flags
Definition: structs.h:94
gnrc_rpl_opt_dodag_conf_t::reserved
uint8_t reserved
reserved
Definition: structs.h:117
gnrc_rpl_opt_dodag_conf_t
DODAG Configuration Option.
Definition: structs.h:107
gnrc_rpl_opt_dodag_conf_t::flags_a_pcs
uint8_t flags_a_pcs
flags
Definition: structs.h:110
evtimer_msg.h
IPC-based evtimer definitions.
gnrc_rpl_opt_prefix_info_t::prefix_len
uint8_t prefix_len
prefix length
Definition: structs.h:213
gnrc_rpl_opt_dodag_conf_t::lifetime_unit
network_uint16_t lifetime_unit
unit in seconds
Definition: structs.h:119
gnrc_rpl_internal_opt_dis_solicited_t::length
uint8_t length
Option Length: 19 bytes.
Definition: structs.h:367
gnrc_rpl_opt_transit_t::path_control
uint8_t path_control
limits the number of DAO parents
Definition: structs.h:198
gnrc_rpl_internal_opt_dis_solicited_t::VID_flags
uint8_t VID_flags
V|I|D predicate options followed by 5 bit unused flags.
Definition: structs.h:369
gnrc_rpl_dio_t::rank
network_uint16_t rank
rank of the parent emitting the DIO
Definition: structs.h:93
gnrc_rpl_dis_t::flags
uint8_t flags
unused
Definition: structs.h:129
gnrc_rpl_opt_transit_t::e_flags
uint8_t e_flags
external flag indicates external routes
Definition: structs.h:197
evtimer.h
evtimer API definitions
gnrc_rpl_internal_opt_t::type
uint8_t type
Option Type.
Definition: structs.h:358
trickle_t
all state variables of a trickle timer
Definition: trickle.h:49
gnrc_rpl_opt_t
RPL-Option Generic Format.
Definition: structs.h:79
gnrc_rpl_opt_prefix_info_t::prefix
ipv6_addr_t prefix
prefix used for Stateless Address Autoconfiguration
Definition: structs.h:218
gnrc_rpl_dao_ack_t
Destination Advertisement Object Acknowledgement.
Definition: structs.h:167
gnrc_rpl_dio_t::reserved
uint8_t reserved
reserved
Definition: structs.h:97
gnrc_rpl_dao_ack_t::status
uint8_t status
indicates completion
Definition: structs.h:171
gnrc_rpl_opt_target_t::type
uint8_t type
option type
Definition: structs.h:181
gnrc_rpl_opt_dodag_conf_t::dio_int_doubl
uint8_t dio_int_doubl
trickle Imax parameter
Definition: structs.h:111
gnrc_rpl_dao_t::dao_sequence
uint8_t dao_sequence
sequence of the DAO, needs to be used for DAO-ACK
Definition: structs.h:158
gnrc_rpl_opt_dodag_conf_t::min_hop_rank_inc
network_uint16_t min_hop_rank_inc
DAGRank(rank) = floor(rank/MinHopRankIncrease)
Definition: structs.h:115
gnrc_rpl_opt_dodag_conf_t::length
uint8_t length
length of option, not including first two bytes
Definition: structs.h:109
gnrc_rpl_of_t::ocp
uint16_t ocp
objective code point
Definition: structs.h:261
gnrc_rpl_internal_opt_dis_solicited_t::dodag_id
ipv6_addr_t dodag_id
DODAG ID predicate.
Definition: structs.h:370
gnrc_rpl_opt_target_t::prefix_length
uint8_t prefix_length
number of valid leading bits in the IPv6 prefix
Definition: structs.h:184
gnrc_rpl_opt_prefix_info_t::valid_lifetime
network_uint32_t valid_lifetime
valid lifetime
Definition: structs.h:215
gnrc_rpl_dio_t
DIO Base Object.
Definition: structs.h:90
gnrc_rpl_dao_t::instance_id
uint8_t instance_id
id of the instance
Definition: structs.h:155
gnrc_rpl_internal_opt_t
internal unpacked struct type for option insertion
Definition: structs.h:357
gnrc_rpl_opt_dodag_conf_t::default_lifetime
uint8_t default_lifetime
lifetime of RPL routes (lifetime * lifetime_unit)
Definition: structs.h:118
gnrc_rpl_internal_opt_t::length
uint8_t length
Option Length, does not include the first two byte.
Definition: structs.h:359
gnrc_rpl_opt_target_t::flags
uint8_t flags
unused
Definition: structs.h:183
gnrc_rpl_opt_t::length
uint8_t length
Option Length, does not include the first two byte.
Definition: structs.h:81
gnrc_rpl_opt_prefix_info_t::pref_lifetime
network_uint32_t pref_lifetime
preferred lifetime
Definition: structs.h:216
gnrc_rpl_dis_t::reserved
uint8_t reserved
reserved
Definition: structs.h:130
gnrc_rpl_opt_dis_solicited_t
DIS Solicited Information option.
Definition: structs.h:139
gnrc_rpl_opt_target_t::target
ipv6_addr_t target
IPv6 prefix, address or multicast group.
Definition: structs.h:185
gnrc_rpl_dao_t::reserved
uint8_t reserved
reserved
Definition: structs.h:157
gnrc_rpl_opt_dodag_conf_t::dio_int_min
uint8_t dio_int_min
trickle Imin parameter
Definition: structs.h:112
gnrc_rpl_opt_prefix_info_t::reserved
uint32_t reserved
reserved
Definition: structs.h:217
gnrc_rpl_parent_t
struct gnrc_rpl_parent gnrc_rpl_parent_t
Parent representation.
Definition: structs.h:230
gnrc_rpl_opt_dodag_conf_t::type
uint8_t type
Option Type: 0x04.
Definition: structs.h:108
evtimer_msg_event_t
IPC-message event.
Definition: evtimer_msg.h:40
gnrc_rpl_dio_t::instance_id
uint8_t instance_id
id of the instance
Definition: structs.h:91
gnrc_rpl_opt_transit_t::length
uint8_t length
option length without the first two bytes
Definition: structs.h:196
gnrc_rpl_opt_dis_solicited_t::version_number
uint8_t version_number
version number of the DODAG
Definition: structs.h:145
gnrc_rpl_dodag_t
struct gnrc_rpl_dodag gnrc_rpl_dodag_t
DODAG representation.
Definition: structs.h:225
gnrc_rpl_opt_dis_solicited_t::VID_flags
uint8_t VID_flags
V|I|D predicate options followed by 5 bit unused flags.
Definition: structs.h:143
gnrc_rpl_dio_t::version_number
uint8_t version_number
version number of the DODAG
Definition: structs.h:92
gnrc_rpl_opt_t::type
uint8_t type
Option Type.
Definition: structs.h:80
gnrc_rpl_dao_t
Destination Advertisement Object.
Definition: structs.h:154