2013-06-22 05:11:53 +02:00
|
|
|
/**
|
2013-08-08 13:39:00 +02:00
|
|
|
* RPL data structs
|
2013-06-22 05:11:53 +02:00
|
|
|
*
|
|
|
|
* Copyright (C) 2013 INRIA.
|
|
|
|
*
|
2013-11-22 20:47:05 +01:00
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser General
|
2013-06-22 05:11:53 +02:00
|
|
|
* Public License. See the file LICENSE in the top level directory for more
|
|
|
|
* details.
|
|
|
|
*
|
2013-08-08 13:39:00 +02:00
|
|
|
* @ingroup rpl
|
2013-06-22 05:11:53 +02:00
|
|
|
* @{
|
|
|
|
* @file rpl_structs.h
|
|
|
|
* @brief RPL data structs
|
|
|
|
* @author Eric Engel <eric.engel@fu-berlin.de>
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
2013-08-05 16:10:54 +02:00
|
|
|
#include "ipv6.h"
|
2012-01-19 17:35:50 +01:00
|
|
|
|
2012-01-26 20:26:55 +01:00
|
|
|
#ifndef RPL_STRUCTS_H_INCLUDED
|
|
|
|
#define RPL_STRUCTS_H_INCLUDED
|
2013-06-22 05:11:53 +02:00
|
|
|
/* Modes of Operation */
|
2012-01-19 17:35:50 +01:00
|
|
|
|
2013-06-28 17:53:21 +02:00
|
|
|
/* DIO Base Object (RFC 6550 Fig. 14) */
|
2013-06-22 05:11:53 +02:00
|
|
|
struct __attribute__((packed)) rpl_dio_t {
|
2012-01-19 17:35:50 +01:00
|
|
|
uint8_t rpl_instanceid;
|
|
|
|
uint8_t version_number;
|
|
|
|
uint16_t rank;
|
|
|
|
uint8_t g_mop_prf;
|
|
|
|
uint8_t dtsn;
|
2013-06-22 05:11:53 +02:00
|
|
|
uint8_t flags;
|
2012-01-19 17:35:50 +01:00
|
|
|
uint8_t reserved;
|
|
|
|
ipv6_addr_t dodagid;
|
|
|
|
};
|
|
|
|
|
2013-06-22 05:11:53 +02:00
|
|
|
struct __attribute__((packed)) rpl_dis_t {
|
2012-01-19 17:35:50 +01:00
|
|
|
uint8_t flags;
|
|
|
|
uint8_t reserved;
|
|
|
|
};
|
|
|
|
|
2013-06-28 17:53:21 +02:00
|
|
|
/* DAO Base Object (RFC 6550 Fig. 16) */
|
2013-06-22 05:11:53 +02:00
|
|
|
struct __attribute__((packed)) rpl_dao_t {
|
2012-01-19 17:35:50 +01:00
|
|
|
uint8_t rpl_instanceid;
|
|
|
|
uint8_t k_d_flags;
|
|
|
|
uint8_t reserved;
|
|
|
|
uint8_t dao_sequence;
|
|
|
|
};
|
|
|
|
|
2013-06-28 17:53:21 +02:00
|
|
|
/* DAO ACK Base Object (RFC 6550 Fig. 17.) */
|
2013-06-22 05:11:53 +02:00
|
|
|
struct __attribute__((packed)) rpl_dao_ack_t {
|
2012-01-19 17:35:50 +01:00
|
|
|
uint8_t rpl_instanceid;
|
|
|
|
uint8_t d_reserved;
|
|
|
|
uint8_t dao_sequence;
|
|
|
|
uint8_t status;
|
|
|
|
};
|
|
|
|
|
2013-06-28 17:53:21 +02:00
|
|
|
/* DODAG ID Struct */
|
2013-06-22 05:11:53 +02:00
|
|
|
/* may be present in dao or dao_ack packets */
|
|
|
|
struct __attribute__((packed)) dodag_id_t {
|
2012-01-19 17:35:50 +01:00
|
|
|
ipv6_addr_t dodagid;
|
|
|
|
};
|
2013-06-22 05:11:53 +02:00
|
|
|
|
2013-06-28 17:53:21 +02:00
|
|
|
/* RPL-Option Generic Format (RFC 6550 Fig. 19) */
|
2014-03-31 14:23:11 +02:00
|
|
|
typedef struct __attribute__((packed)) {
|
2012-01-19 17:35:50 +01:00
|
|
|
uint8_t type;
|
|
|
|
uint8_t length;
|
2014-03-31 14:23:11 +02:00
|
|
|
} rpl_opt_t;
|
2012-01-19 17:35:50 +01:00
|
|
|
|
2013-06-28 17:53:21 +02:00
|
|
|
/* DODAG Configuration-Option (RFC 6550 Fig. 24) */
|
2014-03-31 14:23:11 +02:00
|
|
|
typedef struct __attribute__((packed)) {
|
2012-01-19 17:35:50 +01:00
|
|
|
uint8_t type;
|
|
|
|
uint8_t length;
|
|
|
|
uint8_t flags_a_pcs;
|
|
|
|
uint8_t DIOIntDoubl;
|
|
|
|
uint8_t DIOIntMin;
|
|
|
|
uint8_t DIORedun;
|
|
|
|
uint16_t MaxRankIncrease;
|
|
|
|
uint16_t MinHopRankIncrease;
|
|
|
|
uint16_t ocp;
|
|
|
|
uint8_t reserved;
|
|
|
|
uint8_t default_lifetime;
|
|
|
|
uint16_t lifetime_unit;
|
2014-03-31 14:23:11 +02:00
|
|
|
} rpl_opt_dodag_conf_t;
|
2012-01-19 17:35:50 +01:00
|
|
|
|
2013-06-28 17:53:21 +02:00
|
|
|
/* RPL Solicited Information Option (RFC 6550 Fig. 28) */
|
2014-03-31 14:23:11 +02:00
|
|
|
typedef struct __attribute__((packed)) {
|
2013-06-22 05:11:53 +02:00
|
|
|
uint8_t type;
|
|
|
|
uint8_t length;
|
|
|
|
uint8_t rplinstanceid;
|
|
|
|
uint8_t VID_Flags;
|
|
|
|
ipv6_addr_t dodagid;
|
|
|
|
uint8_t version;
|
2014-03-31 14:23:11 +02:00
|
|
|
} rpl_opt_solicited_t;
|
2012-02-16 23:23:15 +01:00
|
|
|
|
2013-06-28 17:53:21 +02:00
|
|
|
/* RPL Target-Option (RFC 6550 Fig. 25) */
|
|
|
|
/* TODO: ipv6_addr_t target may be replaced by a target prefix of variable length */
|
2014-03-31 14:23:11 +02:00
|
|
|
typedef struct __attribute__((packed)) {
|
2013-06-22 05:11:53 +02:00
|
|
|
uint8_t type;
|
|
|
|
uint8_t length;
|
|
|
|
uint8_t flags;
|
|
|
|
uint8_t prefix_length;
|
|
|
|
ipv6_addr_t target;
|
2014-03-31 14:23:11 +02:00
|
|
|
} rpl_opt_target_t;
|
2012-02-16 23:23:15 +01:00
|
|
|
|
2013-06-28 17:53:21 +02:00
|
|
|
/* RPL Transit-Option (RFC 6550 Fig. 26) */
|
2014-03-31 14:23:11 +02:00
|
|
|
typedef struct __attribute__((packed)) {
|
2013-06-22 05:11:53 +02:00
|
|
|
uint8_t type;
|
|
|
|
uint8_t length;
|
|
|
|
uint8_t e_flags;
|
|
|
|
uint8_t path_control;
|
|
|
|
uint8_t path_sequence;
|
|
|
|
uint8_t path_lifetime;
|
2014-03-31 14:23:11 +02:00
|
|
|
} rpl_opt_transit_t;
|
2012-02-26 19:30:48 +01:00
|
|
|
|
2012-01-19 17:35:50 +01:00
|
|
|
struct rpl_dodag_t;
|
|
|
|
|
2013-06-22 05:11:53 +02:00
|
|
|
typedef struct {
|
2013-03-15 17:48:13 +01:00
|
|
|
ipv6_addr_t addr;
|
|
|
|
uint16_t rank;
|
2013-08-08 13:39:00 +02:00
|
|
|
uint8_t dtsn;
|
2012-01-19 17:35:50 +01:00
|
|
|
struct rpl_dodag_t *dodag;
|
2013-08-08 13:39:00 +02:00
|
|
|
uint16_t lifetime;
|
|
|
|
double link_metric;
|
|
|
|
uint8_t link_metric_type;
|
|
|
|
uint8_t used;
|
2012-01-19 17:35:50 +01:00
|
|
|
} rpl_parent_t;
|
|
|
|
|
|
|
|
struct rpl_of_t;
|
|
|
|
|
2013-06-22 05:11:53 +02:00
|
|
|
typedef struct {
|
2012-01-19 17:35:50 +01:00
|
|
|
uint8_t id;
|
|
|
|
uint8_t used;
|
2013-06-22 05:11:53 +02:00
|
|
|
uint8_t joined;
|
2012-01-19 17:35:50 +01:00
|
|
|
|
|
|
|
} rpl_instance_t;
|
|
|
|
|
2013-03-15 17:48:13 +01:00
|
|
|
//Node-internal representation of a DODAG, with nodespecific information
|
2013-06-24 14:09:33 +02:00
|
|
|
typedef struct rpl_dodag_t {
|
2012-01-19 17:35:50 +01:00
|
|
|
rpl_instance_t *instance;
|
|
|
|
ipv6_addr_t dodag_id;
|
|
|
|
uint8_t used;
|
|
|
|
uint8_t mop;
|
|
|
|
uint8_t dtsn;
|
2013-06-22 05:11:53 +02:00
|
|
|
uint8_t prf;
|
2012-01-19 17:35:50 +01:00
|
|
|
uint8_t dio_interval_doubling;
|
|
|
|
uint8_t dio_min;
|
|
|
|
uint8_t dio_redundancy;
|
|
|
|
uint16_t maxrankincrease;
|
2012-01-26 20:26:55 +01:00
|
|
|
uint16_t minhoprankincrease;
|
2012-01-19 17:35:50 +01:00
|
|
|
uint8_t default_lifetime;
|
2013-06-22 05:11:53 +02:00
|
|
|
uint16_t lifetime_unit;
|
2012-01-19 17:35:50 +01:00
|
|
|
uint8_t version;
|
|
|
|
uint8_t grounded;
|
|
|
|
uint16_t my_rank;
|
2013-03-15 17:48:13 +01:00
|
|
|
uint8_t node_status;
|
2013-06-22 05:11:53 +02:00
|
|
|
uint8_t dao_seq;
|
|
|
|
uint16_t min_rank;
|
2012-01-19 17:35:50 +01:00
|
|
|
uint8_t joined;
|
|
|
|
rpl_parent_t *my_preferred_parent;
|
2013-06-22 05:11:53 +02:00
|
|
|
struct rpl_of_t *of;
|
2012-01-19 17:35:50 +01:00
|
|
|
} rpl_dodag_t;
|
|
|
|
|
2013-06-24 14:09:33 +02:00
|
|
|
typedef struct rpl_of_t {
|
2012-01-19 17:35:50 +01:00
|
|
|
uint16_t ocp;
|
2013-08-08 13:39:00 +02:00
|
|
|
uint16_t (*calc_rank)(rpl_parent_t *parent, uint16_t base_rank);
|
2012-01-19 17:35:50 +01:00
|
|
|
rpl_parent_t *(*which_parent)(rpl_parent_t *, rpl_parent_t *);
|
|
|
|
rpl_dodag_t *(*which_dodag)(rpl_dodag_t *, rpl_dodag_t *);
|
2013-06-24 14:09:33 +02:00
|
|
|
void (*reset)(rpl_dodag_t *);
|
2012-01-19 17:35:50 +01:00
|
|
|
void (*parent_state_callback)(rpl_parent_t *, int, int);
|
2013-08-08 13:39:00 +02:00
|
|
|
void (*init)(void); //OF specific init function
|
2013-09-17 19:46:50 +02:00
|
|
|
void (*process_dio)(void); //DIO processing callback (acc. to OF0 spec, chpt 5)
|
2012-01-19 17:35:50 +01:00
|
|
|
} rpl_of_t;
|
|
|
|
|
2013-06-22 05:11:53 +02:00
|
|
|
typedef struct {
|
|
|
|
ipv6_addr_t address;
|
|
|
|
ipv6_addr_t next_hop;
|
|
|
|
uint16_t lifetime;
|
2014-03-07 15:34:09 +01:00
|
|
|
uint8_t used;
|
2012-02-14 22:22:01 +01:00
|
|
|
} rpl_routing_entry_t;
|
|
|
|
|
2012-01-26 20:26:55 +01:00
|
|
|
#endif
|