structs.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2017 HAW Hamburg
3  * SPDX-FileCopyrightText: 2015–2018 Cenk Gündoğan <cenk.guendogan@haw-hamburg.de>
4  * SPDX-FileCopyrightText: 2013 INRIA
5  * SPDX-License-Identifier: LGPL-2.1-only
6  */
7 
8 #pragma once
9 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #include "byteorder.h"
28 #include "net/ipv6/addr.h"
29 #include "evtimer.h"
30 #include "evtimer_msg.h"
31 #include "trickle.h"
32 
37 #define GNRC_RPL_OPT_DODAG_CONF_LEN (14)
38 #define GNRC_RPL_OPT_PREFIX_INFO_LEN (30)
39 #define GNRC_RPL_OPT_TARGET_LEN (18)
40 #define GNRC_RPL_OPT_TRANSIT_INFO_LEN (4)
47 #define GNRC_RPL_DAO_D_BIT (1 << 6)
48 #define GNRC_RPL_DAO_K_BIT (1 << 7)
55 #define GNRC_RPL_DAO_ACK_D_BIT (1 << 7)
63 #define GNRC_RPL_REQ_DIO_OPT_DODAG_CONF_SHIFT (0)
64 #define GNRC_RPL_REQ_DIO_OPT_DODAG_CONF (1 << GNRC_RPL_REQ_DIO_OPT_DODAG_CONF_SHIFT)
65 #define GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO_SHIFT (1)
66 #define GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO (1 << GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO_SHIFT)
75 typedef struct __attribute__((packed)) {
76  uint8_t type;
77  uint8_t length;
79 
86 typedef struct __attribute__((packed)) {
87  uint8_t instance_id;
88  uint8_t version_number;
90  uint8_t g_mop_prf;
91  uint8_t dtsn;
92  uint8_t flags;
93  uint8_t reserved;
96 
103 typedef struct __attribute__((packed)) {
104  uint8_t type;
105  uint8_t length;
106  uint8_t flags_a_pcs;
107  uint8_t dio_int_doubl;
108  uint8_t dio_int_min;
109  uint8_t dio_redun;
113  uint8_t reserved;
117 
124 typedef struct __attribute__((packed)) {
125  uint8_t flags;
126  uint8_t reserved;
128 
135 typedef struct __attribute__((packed)) {
136  uint8_t type;
137  uint8_t length;
138  uint8_t instance_id;
139  uint8_t VID_flags;
141  uint8_t version_number;
143 
150 typedef struct __attribute__((packed)) {
151  uint8_t instance_id;
152  uint8_t k_d_flags;
153  uint8_t reserved;
154  uint8_t dao_sequence;
156 
163 typedef struct __attribute__((packed)) {
164  uint8_t instance_id;
165  uint8_t d_reserved;
166  uint8_t dao_sequence;
167  uint8_t status;
169 
176 typedef struct __attribute__((packed)) {
177  uint8_t type;
178  uint8_t length;
179  uint8_t flags;
180  uint8_t prefix_length;
183 
190 typedef struct __attribute__((packed)) {
191  uint8_t type;
192  uint8_t length;
193  uint8_t e_flags;
194  uint8_t path_control;
195  uint8_t path_sequence;
196  uint8_t path_lifetime;
198 
205 typedef struct __attribute__((packed)) {
206  uint8_t type;
207  uint8_t length;
209  uint8_t prefix_len;
210  uint8_t LAR_flags;
213  uint32_t reserved;
217 
221 typedef struct gnrc_rpl_dodag gnrc_rpl_dodag_t;
222 
226 typedef struct gnrc_rpl_parent gnrc_rpl_parent_t;
227 
231 typedef struct gnrc_rpl_instance gnrc_rpl_instance_t;
232 
235 struct gnrc_rpl_parent {
236  gnrc_rpl_parent_t *next;
237  uint8_t state;
238  ipv6_addr_t addr;
239  uint8_t dtsn;
240  uint16_t rank;
241  gnrc_rpl_dodag_t *dodag;
242  double link_metric;
243  uint8_t link_metric_type;
247  evtimer_msg_event_t timeout_event;
248 };
256 typedef struct {
257  uint16_t ocp;
268  uint16_t (*calc_rank)(gnrc_rpl_dodag_t *dodag, uint16_t base_rank);
269 
285  int (*parent_cmp)(gnrc_rpl_parent_t *parent1, gnrc_rpl_parent_t *parent2);
286  int (*which_dodag)(gnrc_rpl_dodag_t *, gnrc_rpl_dio_t *);
293  void (*reset)(gnrc_rpl_dodag_t *dodag);
294  void (*parent_state_callback)(gnrc_rpl_parent_t *, int, int);
301  void (*init)(gnrc_rpl_dodag_t *dodag);
302  void (*process_dio)(void);
303 } gnrc_rpl_of_t;
304 
308 struct gnrc_rpl_dodag {
309  ipv6_addr_t dodag_id;
310  gnrc_rpl_parent_t *parents;
311  gnrc_rpl_instance_t *instance;
312  uint8_t dtsn;
313  uint8_t prf;
314  uint8_t dio_interval_doubl;
315  uint8_t dio_min;
316  uint8_t dio_redun;
317  uint8_t default_lifetime;
318  uint16_t lifetime_unit;
319  kernel_pid_t iface;
320  uint8_t version;
321  uint8_t grounded;
322  uint16_t my_rank;
323  uint8_t node_status;
324  uint8_t dao_seq;
325  uint8_t dao_counter;
326  bool dao_ack_received;
327  uint8_t dio_opts;
329  evtimer_msg_event_t dao_event;
330  trickle_t trickle;
331 };
332 
333 struct gnrc_rpl_instance {
334  uint8_t id;
335  uint8_t state;
336  gnrc_rpl_dodag_t dodag;
337  uint8_t mop;
338  gnrc_rpl_of_t *of;
339  uint16_t min_hop_rank_inc;
340  uint16_t max_rank_inc;
344  evtimer_msg_event_t cleanup_event;
345 };
353 typedef struct {
354  uint8_t type;
355  uint8_t length;
357 
361 typedef struct {
362  uint8_t type;
363  uint8_t length;
364  uint8_t instance_id;
365  uint8_t VID_flags;
367  uint8_t version_number;
369 
370 #ifdef __cplusplus
371 }
372 #endif
373 
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:135
Definitions for IPv6 addresses.
IPC-message event.
Definition: evtimer_msg.h:37
Destination Advertisement Object Acknowledgement.
Definition: structs.h:163
uint8_t dao_sequence
sequence must be equal to the sequence from the DAO object
Definition: structs.h:166
uint8_t d_reserved
if set, indicates that the DODAG id should be included
Definition: structs.h:165
uint8_t instance_id
id of the instance
Definition: structs.h:164
uint8_t status
indicates completion
Definition: structs.h:167
Destination Advertisement Object.
Definition: structs.h:150
uint8_t instance_id
id of the instance
Definition: structs.h:151
uint8_t reserved
reserved
Definition: structs.h:153
uint8_t k_d_flags
K and D flags.
Definition: structs.h:152
uint8_t dao_sequence
sequence of the DAO, needs to be used for DAO-ACK
Definition: structs.h:154
DIO Base Object.
Definition: structs.h:86
uint8_t version_number
version number of the DODAG
Definition: structs.h:88
uint8_t dtsn
Destination Advertisement Trigger Sequence Number.
Definition: structs.h:91
uint8_t g_mop_prf
grounded, MOP, preferred flags
Definition: structs.h:90
uint8_t flags
unused
Definition: structs.h:92
uint8_t reserved
reserved
Definition: structs.h:93
network_uint16_t rank
rank of the parent emitting the DIO
Definition: structs.h:89
ipv6_addr_t dodag_id
id of the dodag
Definition: structs.h:94
uint8_t instance_id
id of the instance
Definition: structs.h:87
DODAG Information Solicitation.
Definition: structs.h:124
uint8_t flags
unused
Definition: structs.h:125
uint8_t reserved
reserved
Definition: structs.h:126
internal unpacked struct type for DIS solicited option insertion
Definition: structs.h:361
uint8_t type
Option Type: 0x07.
Definition: structs.h:362
uint8_t version_number
version number of the DODAG
Definition: structs.h:367
ipv6_addr_t dodag_id
DODAG ID predicate.
Definition: structs.h:366
uint8_t VID_flags
V|I|D predicate options followed by 5 bit unused flags.
Definition: structs.h:365
uint8_t length
Option Length: 19 bytes.
Definition: structs.h:363
uint8_t instance_id
id of the instance
Definition: structs.h:364
internal unpacked struct type for option insertion
Definition: structs.h:353
uint8_t length
Option Length, does not include the first two byte.
Definition: structs.h:355
uint8_t type
Option Type.
Definition: structs.h:354
Objective function representation.
Definition: structs.h:256
uint16_t ocp
objective code point
Definition: structs.h:257
DIS Solicited Information option.
Definition: structs.h:135
uint8_t VID_flags
V|I|D predicate options followed by 5 bit unused flags.
Definition: structs.h:139
uint8_t type
Option Type: 0x07.
Definition: structs.h:136
uint8_t length
Option Length: 19 bytes.
Definition: structs.h:137
uint8_t version_number
version number of the DODAG
Definition: structs.h:141
ipv6_addr_t dodag_id
DODAG ID predicate.
Definition: structs.h:140
uint8_t instance_id
id of the instance
Definition: structs.h:138
DODAG Configuration Option.
Definition: structs.h:103
uint8_t length
length of option, not including first two bytes
Definition: structs.h:105
uint8_t dio_int_min
trickle Imin parameter
Definition: structs.h:108
uint8_t type
Option Type: 0x04.
Definition: structs.h:104
network_uint16_t lifetime_unit
unit in seconds
Definition: structs.h:115
uint8_t reserved
reserved
Definition: structs.h:113
uint8_t dio_redun
trickle k parameter
Definition: structs.h:109
network_uint16_t ocp
Objective Code Point.
Definition: structs.h:112
uint8_t default_lifetime
lifetime of RPL routes (lifetime * lifetime_unit)
Definition: structs.h:114
network_uint16_t max_rank_inc
allowable increase in rank
Definition: structs.h:110
network_uint16_t min_hop_rank_inc
DAGRank(rank) = floor(rank/MinHopRankIncrease)
Definition: structs.h:111
uint8_t dio_int_doubl
trickle Imax parameter
Definition: structs.h:107
uint8_t flags_a_pcs
flags
Definition: structs.h:106
Prefix Information Option.
Definition: structs.h:205
uint8_t length
option length without the first two bytes
Definition: structs.h:207
ipv6_addr_t prefix
prefix used for Stateless Address Autoconfiguration
Definition: structs.h:214
uint8_t type
option type
Definition: structs.h:206
uint32_t reserved
reserved
Definition: structs.h:213
network_uint32_t valid_lifetime
valid lifetime
Definition: structs.h:211
uint8_t LAR_flags
flags and resereved
Definition: structs.h:210
uint8_t prefix_len
prefix length
Definition: structs.h:209
network_uint32_t pref_lifetime
preferred lifetime
Definition: structs.h:212
RPL-Option Generic Format.
Definition: structs.h:75
uint8_t type
Option Type.
Definition: structs.h:76
uint8_t length
Option Length, does not include the first two byte.
Definition: structs.h:77
Target Option.
Definition: structs.h:176
ipv6_addr_t target
IPv6 prefix, address or multicast group.
Definition: structs.h:181
uint8_t type
option type
Definition: structs.h:177
uint8_t prefix_length
number of valid leading bits in the IPv6 prefix
Definition: structs.h:180
uint8_t flags
unused
Definition: structs.h:179
uint8_t length
option length without the first two bytes
Definition: structs.h:178
Transit Option.
Definition: structs.h:190
uint8_t length
option length without the first two bytes
Definition: structs.h:192
uint8_t path_control
limits the number of DAO parents
Definition: structs.h:194
uint8_t path_lifetime
lifetime of routes
Definition: structs.h:196
uint8_t path_sequence
increased value for route updates
Definition: structs.h:195
uint8_t type
option type
Definition: structs.h:191
uint8_t e_flags
external flag indicates external routes
Definition: structs.h:193
struct gnrc_rpl_instance gnrc_rpl_instance_t
Instance representation.
Definition: structs.h:231
struct gnrc_rpl_parent gnrc_rpl_parent_t
Parent representation.
Definition: structs.h:226
struct gnrc_rpl_dodag gnrc_rpl_dodag_t
DODAG representation.
Definition: structs.h:221
all state variables of a trickle timer
Definition: trickle.h:43
Trickle timer interface definition.
A 16 bit integer in big endian aka network byte order.
Definition: byteorder.h:70
A 32 bit integer in big endian aka network byte order.
Definition: byteorder.h:80
Data type to represent an IPv6 address.
Definition: addr.h:64