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 instance_id;
141  uint8_t k_d_flags;
142  uint8_t reserved;
143  uint8_t dao_sequence;
145 
152 typedef struct __attribute__((packed)) {
153  uint8_t instance_id;
154  uint8_t d_reserved;
155  uint8_t dao_sequence;
156  uint8_t status;
158 
165 typedef struct __attribute__((packed)) {
166  uint8_t type;
167  uint8_t length;
168  uint8_t flags;
169  uint8_t prefix_length;
172 
179 typedef struct __attribute__((packed)) {
180  uint8_t type;
181  uint8_t length;
182  uint8_t e_flags;
183  uint8_t path_control;
184  uint8_t path_sequence;
185  uint8_t path_lifetime;
187 
194 typedef struct __attribute__((packed)) {
195  uint8_t type;
196  uint8_t length;
198  uint8_t prefix_len;
199  uint8_t LAR_flags;
202  uint32_t reserved;
206 
210 typedef struct gnrc_rpl_dodag gnrc_rpl_dodag_t;
211 
215 typedef struct gnrc_rpl_parent gnrc_rpl_parent_t;
216 
220 typedef struct gnrc_rpl_instance gnrc_rpl_instance_t;
221 
224 struct gnrc_rpl_parent {
225  gnrc_rpl_parent_t *next;
226  uint8_t state;
227  ipv6_addr_t addr;
228  uint8_t dtsn;
229  uint16_t rank;
230  gnrc_rpl_dodag_t *dodag;
231  double link_metric;
232  uint8_t link_metric_type;
236  evtimer_msg_event_t timeout_event;
237 };
245 typedef struct {
246  uint16_t ocp;
247  uint16_t (*calc_rank)(gnrc_rpl_parent_t *parent, uint16_t base_rank);
248  gnrc_rpl_parent_t *(*which_parent)(gnrc_rpl_parent_t *, gnrc_rpl_parent_t *);
265  int (*parent_cmp)(gnrc_rpl_parent_t *parent1, gnrc_rpl_parent_t *parent2);
266  gnrc_rpl_dodag_t *(*which_dodag)(gnrc_rpl_dodag_t *, gnrc_rpl_dodag_t *);
267  void (*reset)(gnrc_rpl_dodag_t *);
268  void (*parent_state_callback)(gnrc_rpl_parent_t *, int, int);
269  void (*init)(void);
270  void (*process_dio)(void);
271 } gnrc_rpl_of_t;
272 
276 struct gnrc_rpl_dodag {
277  ipv6_addr_t dodag_id;
278  gnrc_rpl_parent_t *parents;
279  gnrc_rpl_instance_t *instance;
280  uint8_t dtsn;
281  uint8_t prf;
282  uint8_t dio_interval_doubl;
283  uint8_t dio_min;
284  uint8_t dio_redun;
285  uint8_t default_lifetime;
286  uint16_t lifetime_unit;
287  kernel_pid_t iface;
288  uint8_t version;
289  uint8_t grounded;
290  uint16_t my_rank;
291  uint8_t node_status;
292  uint8_t dao_seq;
293  uint8_t dao_counter;
294  bool dao_ack_received;
295  uint8_t dio_opts;
297  evtimer_msg_event_t dao_event;
298  trickle_t trickle;
299 };
300 
301 struct gnrc_rpl_instance {
302  uint8_t id;
303  uint8_t state;
304  gnrc_rpl_dodag_t dodag;
305  uint8_t mop;
306  gnrc_rpl_of_t *of;
307  uint16_t min_hop_rank_inc;
308  uint16_t max_rank_inc;
312  evtimer_msg_event_t cleanup_event;
313 };
318 #ifdef __cplusplus
319 }
320 #endif
321 
322 #endif /* NET_GNRC_RPL_STRUCTS_H */
323 
Trickle timer interface definition.
uint8_t flags
unused
Definition: structs.h:129
uint8_t dao_sequence
sequence must be equal to the sequence from the DAO object
Definition: structs.h:155
uint8_t g_mop_prf
grounded, MOP, preferred flags
Definition: structs.h:94
uint8_t length
option length without the first two bytes
Definition: structs.h:167
uint8_t flags_a_pcs
flags
Definition: structs.h:110
struct gnrc_rpl_parent gnrc_rpl_parent_t
Parent representation.
Definition: structs.h:215
Objective function representation.
Definition: structs.h:245
Target Option.
Definition: structs.h:165
Definitions for IPv6 addresses.
uint8_t path_control
limits the number of DAO parents
Definition: structs.h:183
network_uint32_t valid_lifetime
valid lifetime
Definition: structs.h:200
uint8_t type
option type
Definition: structs.h:166
A 32 bit integer in big endian aka network byte order.
Definition: byteorder.h:86
int16_t kernel_pid_t
Unique process identifier.
Definition: kernel_types.h:83
uint8_t dio_int_min
trickle Imin parameter
Definition: structs.h:112
network_uint32_t pref_lifetime
preferred lifetime
Definition: structs.h:201
uint8_t length
option length without the first two bytes
Definition: structs.h:196
network_uint16_t max_rank_inc
allowable increase in rank
Definition: structs.h:114
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:185
uint8_t type
Option Type: 0x04.
Definition: structs.h:108
uint8_t reserved
reserved
Definition: structs.h:142
evtimer API definitions
uint8_t dtsn
Destination Advertisement Trigger Sequence Number.
Definition: structs.h:95
DIO Base Object.
Definition: structs.h:90
uint8_t dao_sequence
sequence of the DAO, needs to be used for DAO-ACK
Definition: structs.h:143
network_uint16_t ocp
Objective Code Point.
Definition: structs.h:116
uint8_t length
Option Length, does not include the first two byte.
Definition: structs.h:81
uint8_t LAR_flags
flags and resereved
Definition: structs.h:199
uint8_t prefix_len
prefix length
Definition: structs.h:198
uint8_t reserved
reserved
Definition: structs.h:117
network_uint16_t min_hop_rank_inc
DAGRank(rank) = floor(rank/MinHopRankIncrease)
Definition: structs.h:115
Transit Option.
Definition: structs.h:179
uint8_t length
length of option, not including first two bytes
Definition: structs.h:109
uint8_t flags
unused
Definition: structs.h:168
uint8_t instance_id
id of the instance
Definition: structs.h:140
struct gnrc_rpl_instance gnrc_rpl_instance_t
Instance representation.
Definition: structs.h:220
uint8_t status
indicates completion
Definition: structs.h:156
IPC-based evtimer definitions.
uint8_t flags
unused
Definition: structs.h:96
uint8_t dio_redun
trickle k parameter
Definition: structs.h:113
network_uint16_t rank
rank of the parent emitting the DIO
Definition: structs.h:93
uint8_t type
option type
Definition: structs.h:180
Destination Advertisement Object.
Definition: structs.h:139
RPL-Option Generic Format.
Definition: structs.h:79
uint8_t reserved
reserved
Definition: structs.h:97
uint8_t prefix_length
number of valid leading bits in the IPv6 prefix
Definition: structs.h:169
uint8_t length
option length without the first two bytes
Definition: structs.h:181
Functions to work with different byte orders.
uint8_t type
option type
Definition: structs.h:195
uint8_t dio_int_doubl
trickle Imax parameter
Definition: structs.h:111
Prefix Information Option.
Definition: structs.h:194
uint8_t reserved
reserved
Definition: structs.h:130
uint8_t version_number
version number of the DODAG
Definition: structs.h:92
uint8_t e_flags
external flag indicates external routes
Definition: structs.h:182
ipv6_addr_t dodag_id
id of the dodag
Definition: structs.h:98
uint8_t default_lifetime
lifetime of RPL routes (lifetime * lifetime_unit)
Definition: structs.h:118
ipv6_addr_t target
IPv6 prefix, address or multicast group.
Definition: structs.h:170
IPC-message event.
Definition: evtimer_msg.h:40
DODAG Information Solicitation.
Definition: structs.h:128
Data type to represent an IPv6 address.
Definition: ipv6/addr.h:74
uint8_t path_sequence
increased value for route updates
Definition: structs.h:184
uint16_t ocp
objective code point
Definition: structs.h:246
DODAG Configuration Option.
Definition: structs.h:107
uint8_t type
Option Type.
Definition: structs.h:80
ipv6_addr_t prefix
prefix used for Stateless Address Autoconfiguration
Definition: structs.h:203
Destination Advertisement Object Acknowledgement.
Definition: structs.h:152
uint32_t reserved
reserved
Definition: structs.h:202
network_uint16_t lifetime_unit
unit in seconds
Definition: structs.h:119
uint8_t d_reserved
if set, indicates that the DODAG id should be included
Definition: structs.h:154
uint8_t k_d_flags
K and D flags.
Definition: structs.h:141
uint8_t instance_id
id of the instance
Definition: structs.h:153
struct gnrc_rpl_dodag gnrc_rpl_dodag_t
DODAG representation.
Definition: structs.h:210
uint8_t instance_id
id of the instance
Definition: structs.h:91