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 
11 #pragma once
12 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #include "byteorder.h"
31 #include "net/ipv6/addr.h"
32 #include "evtimer.h"
33 #include "evtimer_msg.h"
34 #include "trickle.h"
35 
40 #define GNRC_RPL_OPT_DODAG_CONF_LEN (14)
41 #define GNRC_RPL_OPT_PREFIX_INFO_LEN (30)
42 #define GNRC_RPL_OPT_TARGET_LEN (18)
43 #define GNRC_RPL_OPT_TRANSIT_INFO_LEN (4)
50 #define GNRC_RPL_DAO_D_BIT (1 << 6)
51 #define GNRC_RPL_DAO_K_BIT (1 << 7)
58 #define GNRC_RPL_DAO_ACK_D_BIT (1 << 7)
66 #define GNRC_RPL_REQ_DIO_OPT_DODAG_CONF_SHIFT (0)
67 #define GNRC_RPL_REQ_DIO_OPT_DODAG_CONF (1 << GNRC_RPL_REQ_DIO_OPT_DODAG_CONF_SHIFT)
68 #define GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO_SHIFT (1)
69 #define GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO (1 << GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO_SHIFT)
78 typedef struct __attribute__((packed)) {
79  uint8_t type;
80  uint8_t length;
82 
89 typedef struct __attribute__((packed)) {
90  uint8_t instance_id;
91  uint8_t version_number;
93  uint8_t g_mop_prf;
94  uint8_t dtsn;
95  uint8_t flags;
96  uint8_t reserved;
99 
106 typedef struct __attribute__((packed)) {
107  uint8_t type;
108  uint8_t length;
109  uint8_t flags_a_pcs;
110  uint8_t dio_int_doubl;
111  uint8_t dio_int_min;
112  uint8_t dio_redun;
116  uint8_t reserved;
120 
127 typedef struct __attribute__((packed)) {
128  uint8_t flags;
129  uint8_t reserved;
131 
138 typedef struct __attribute__((packed)) {
139  uint8_t type;
140  uint8_t length;
141  uint8_t instance_id;
142  uint8_t VID_flags;
144  uint8_t version_number;
146 
153 typedef struct __attribute__((packed)) {
154  uint8_t instance_id;
155  uint8_t k_d_flags;
156  uint8_t reserved;
157  uint8_t dao_sequence;
159 
166 typedef struct __attribute__((packed)) {
167  uint8_t instance_id;
168  uint8_t d_reserved;
169  uint8_t dao_sequence;
170  uint8_t status;
172 
179 typedef struct __attribute__((packed)) {
180  uint8_t type;
181  uint8_t length;
182  uint8_t flags;
183  uint8_t prefix_length;
186 
193 typedef struct __attribute__((packed)) {
194  uint8_t type;
195  uint8_t length;
196  uint8_t e_flags;
197  uint8_t path_control;
198  uint8_t path_sequence;
199  uint8_t path_lifetime;
201 
208 typedef struct __attribute__((packed)) {
209  uint8_t type;
210  uint8_t length;
212  uint8_t prefix_len;
213  uint8_t LAR_flags;
216  uint32_t reserved;
220 
224 typedef struct gnrc_rpl_dodag gnrc_rpl_dodag_t;
225 
229 typedef struct gnrc_rpl_parent gnrc_rpl_parent_t;
230 
234 typedef struct gnrc_rpl_instance gnrc_rpl_instance_t;
235 
238 struct gnrc_rpl_parent {
239  gnrc_rpl_parent_t *next;
240  uint8_t state;
241  ipv6_addr_t addr;
242  uint8_t dtsn;
243  uint16_t rank;
244  gnrc_rpl_dodag_t *dodag;
245  double link_metric;
246  uint8_t link_metric_type;
250  evtimer_msg_event_t timeout_event;
251 };
259 typedef struct {
260  uint16_t ocp;
271  uint16_t (*calc_rank)(gnrc_rpl_dodag_t *dodag, uint16_t base_rank);
272 
288  int (*parent_cmp)(gnrc_rpl_parent_t *parent1, gnrc_rpl_parent_t *parent2);
296  void (*reset)(gnrc_rpl_dodag_t *dodag);
297  void (*parent_state_callback)(gnrc_rpl_parent_t *, int, int);
304  void (*init)(gnrc_rpl_dodag_t *dodag);
305  void (*process_dio)(void);
306 } gnrc_rpl_of_t;
307 
311 struct gnrc_rpl_dodag {
312  ipv6_addr_t dodag_id;
313  gnrc_rpl_parent_t *parents;
314  gnrc_rpl_instance_t *instance;
315  uint8_t dtsn;
316  uint8_t prf;
317  uint8_t dio_interval_doubl;
318  uint8_t dio_min;
319  uint8_t dio_redun;
320  uint8_t default_lifetime;
321  uint16_t lifetime_unit;
322  kernel_pid_t iface;
323  uint8_t version;
324  uint8_t grounded;
325  uint16_t my_rank;
326  uint8_t node_status;
327  uint8_t dao_seq;
328  uint8_t dao_counter;
329  bool dao_ack_received;
330  uint8_t dio_opts;
332  evtimer_msg_event_t dao_event;
333  trickle_t trickle;
334 };
335 
336 struct gnrc_rpl_instance {
337  uint8_t id;
338  uint8_t state;
339  gnrc_rpl_dodag_t dodag;
340  uint8_t mop;
341  gnrc_rpl_of_t *of;
342  uint16_t min_hop_rank_inc;
343  uint16_t max_rank_inc;
347  evtimer_msg_event_t cleanup_event;
348 };
356 typedef struct {
357  uint8_t type;
358  uint8_t length;
360 
364 typedef struct {
365  uint8_t type;
366  uint8_t length;
367  uint8_t instance_id;
368  uint8_t VID_flags;
370  uint8_t version_number;
372 
373 #ifdef __cplusplus
374 }
375 #endif
376 
Functions to work with different byte orders.
evtimer API definitions
IPC-based evtimer definitions.
int16_t kernel_pid_t
Unique process identifier.
Definition: sched.h:138
Definitions for IPv6 addresses.
IPC-message event.
Definition: evtimer_msg.h:40
Destination Advertisement Object Acknowledgement.
Definition: structs.h:166
uint8_t dao_sequence
sequence must be equal to the sequence from the DAO object
Definition: structs.h:169
uint8_t d_reserved
if set, indicates that the DODAG id should be included
Definition: structs.h:168
uint8_t instance_id
id of the instance
Definition: structs.h:167
uint8_t status
indicates completion
Definition: structs.h:170
Destination Advertisement Object.
Definition: structs.h:153
uint8_t instance_id
id of the instance
Definition: structs.h:154
uint8_t reserved
reserved
Definition: structs.h:156
uint8_t k_d_flags
K and D flags.
Definition: structs.h:155
uint8_t dao_sequence
sequence of the DAO, needs to be used for DAO-ACK
Definition: structs.h:157
DIO Base Object.
Definition: structs.h:89
uint8_t version_number
version number of the DODAG
Definition: structs.h:91
uint8_t dtsn
Destination Advertisement Trigger Sequence Number.
Definition: structs.h:94
uint8_t g_mop_prf
grounded, MOP, preferred flags
Definition: structs.h:93
uint8_t flags
unused
Definition: structs.h:95
uint8_t reserved
reserved
Definition: structs.h:96
network_uint16_t rank
rank of the parent emitting the DIO
Definition: structs.h:92
ipv6_addr_t dodag_id
id of the dodag
Definition: structs.h:97
uint8_t instance_id
id of the instance
Definition: structs.h:90
DODAG Information Solicitation.
Definition: structs.h:127
uint8_t flags
unused
Definition: structs.h:128
uint8_t reserved
reserved
Definition: structs.h:129
internal unpacked struct type for DIS solicited option insertion
Definition: structs.h:364
uint8_t type
Option Type: 0x07.
Definition: structs.h:365
uint8_t version_number
version number of the DODAG
Definition: structs.h:370
ipv6_addr_t dodag_id
DODAG ID predicate.
Definition: structs.h:369
uint8_t VID_flags
V|I|D predicate options followed by 5 bit unused flags.
Definition: structs.h:368
uint8_t length
Option Length: 19 bytes.
Definition: structs.h:366
uint8_t instance_id
id of the instance
Definition: structs.h:367
internal unpacked struct type for option insertion
Definition: structs.h:356
uint8_t length
Option Length, does not include the first two byte.
Definition: structs.h:358
uint8_t type
Option Type.
Definition: structs.h:357
Objective function representation.
Definition: structs.h:259
uint16_t ocp
objective code point
Definition: structs.h:260
DIS Solicited Information option.
Definition: structs.h:138
uint8_t VID_flags
V|I|D predicate options followed by 5 bit unused flags.
Definition: structs.h:142
uint8_t type
Option Type: 0x07.
Definition: structs.h:139
uint8_t length
Option Length: 19 bytes.
Definition: structs.h:140
uint8_t version_number
version number of the DODAG
Definition: structs.h:144
ipv6_addr_t dodag_id
DODAG ID predicate.
Definition: structs.h:143
uint8_t instance_id
id of the instance
Definition: structs.h:141
DODAG Configuration Option.
Definition: structs.h:106
uint8_t length
length of option, not including first two bytes
Definition: structs.h:108
uint8_t dio_int_min
trickle Imin parameter
Definition: structs.h:111
uint8_t type
Option Type: 0x04.
Definition: structs.h:107
network_uint16_t lifetime_unit
unit in seconds
Definition: structs.h:118
uint8_t reserved
reserved
Definition: structs.h:116
uint8_t dio_redun
trickle k parameter
Definition: structs.h:112
network_uint16_t ocp
Objective Code Point.
Definition: structs.h:115
uint8_t default_lifetime
lifetime of RPL routes (lifetime * lifetime_unit)
Definition: structs.h:117
network_uint16_t max_rank_inc
allowable increase in rank
Definition: structs.h:113
network_uint16_t min_hop_rank_inc
DAGRank(rank) = floor(rank/MinHopRankIncrease)
Definition: structs.h:114
uint8_t dio_int_doubl
trickle Imax parameter
Definition: structs.h:110
uint8_t flags_a_pcs
flags
Definition: structs.h:109
Prefix Information Option.
Definition: structs.h:208
uint8_t length
option length without the first two bytes
Definition: structs.h:210
ipv6_addr_t prefix
prefix used for Stateless Address Autoconfiguration
Definition: structs.h:217
uint8_t type
option type
Definition: structs.h:209
uint32_t reserved
reserved
Definition: structs.h:216
network_uint32_t valid_lifetime
valid lifetime
Definition: structs.h:214
uint8_t LAR_flags
flags and resereved
Definition: structs.h:213
uint8_t prefix_len
prefix length
Definition: structs.h:212
network_uint32_t pref_lifetime
preferred lifetime
Definition: structs.h:215
RPL-Option Generic Format.
Definition: structs.h:78
uint8_t type
Option Type.
Definition: structs.h:79
uint8_t length
Option Length, does not include the first two byte.
Definition: structs.h:80
Target Option.
Definition: structs.h:179
ipv6_addr_t target
IPv6 prefix, address or multicast group.
Definition: structs.h:184
uint8_t type
option type
Definition: structs.h:180
uint8_t prefix_length
number of valid leading bits in the IPv6 prefix
Definition: structs.h:183
uint8_t flags
unused
Definition: structs.h:182
uint8_t length
option length without the first two bytes
Definition: structs.h:181
Transit Option.
Definition: structs.h:193
uint8_t length
option length without the first two bytes
Definition: structs.h:195
uint8_t path_control
limits the number of DAO parents
Definition: structs.h:197
uint8_t path_lifetime
lifetime of routes
Definition: structs.h:199
uint8_t path_sequence
increased value for route updates
Definition: structs.h:198
uint8_t type
option type
Definition: structs.h:194
uint8_t e_flags
external flag indicates external routes
Definition: structs.h:196
struct gnrc_rpl_instance gnrc_rpl_instance_t
Instance representation.
Definition: structs.h:234
struct gnrc_rpl_parent gnrc_rpl_parent_t
Parent representation.
Definition: structs.h:229
struct gnrc_rpl_dodag gnrc_rpl_dodag_t
DODAG representation.
Definition: structs.h:224
all state variables of a trickle timer
Definition: trickle.h:48
Trickle timer interface definition.
A 16 bit integer in big endian aka network byte order.
Definition: byteorder.h:73
A 32 bit integer in big endian aka network byte order.
Definition: byteorder.h:83
Data type to represent an IPv6 address.
Definition: addr.h:67