Gleb Klochkov / Mbed OS Climatcontroll_Main

Dependencies:   esp8266-driver

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers rpl_structures.h Source File

rpl_structures.h

00001 /*
00002  * Copyright (c) 2015-2017, Arm Limited and affiliates.
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef RPL_STRUCTURES_H_
00019 #define RPL_STRUCTURES_H_
00020 
00021 /* RPLstructures are public only for the core processing (rpl_upward,
00022  * rpl_downward, and objective function implementations). This file should
00023  * not be included by rpl_control, rpl_objective or rpl_policy, or any
00024  * external user.
00025  */
00026 
00027 #include <stdint.h>
00028 #include <stdbool.h>
00029 
00030 #include "Service_Libs/Trickle/trickle.h"
00031 
00032 struct rpl_objective;
00033 
00034 /* Descriptor for a RPL neighbour within a DODAG
00035  *
00036  * The neighbour is normally associated with a DODAG Version, but may not be,
00037  * if the version has been retired, and we haven't since heard from that
00038  * neighbour. In that case dodag_version is NULL.
00039  *
00040  * Note that global address is only needed with downward routes, but I don't
00041  * think it's worth optimising for an "upward-only" build. (Unless to be a RPL
00042  * leaf?)
00043  *
00044  * DODAG parents are identified by the dodag_parent flag, and they are sorted
00045  * first in the instance candidate_neighbour list, in order of preference.
00046  */
00047 struct rpl_neighbour
00048 {
00049     rpl_dodag_version_t *dodag_version;     // Back pointer to DODAG Version (may be NULL, if not dodag_parent)
00050     uint8_t ll_address[16];                 // Link-local address (source of DIO)
00051     uint8_t global_address[16];             // Global address (from DIO RIO)
00052     bool dodag_parent:1;                    // This is a DODAG parent (if true, dodag_version may not be NULL)
00053     bool was_dodag_parent:1;                // Was a DODAG parent (used only during parent selection)
00054     bool have_global_address:1;             // Global address known
00055     bool considered:1;                      // Have considered at least once for parent selection
00056     unsigned dodag_pref:4;                  // Preference indication for DODAG parents (0=best)
00057     uint8_t dao_path_control;               // Path control bit assignments for DAO parent
00058     uint8_t old_dao_path_control;
00059     int8_t interface_id;
00060     uint8_t g_mop_prf;
00061     uint8_t dtsn;
00062     uint16_t rank;
00063     uint32_t dio_timestamp;                 // Timestamp of last received DIO message
00064     /* Need link quality indication */
00065     ns_list_link_t candidate_neighbour_link;
00066 };
00067 
00068 typedef NS_LIST_HEAD (rpl_neighbour_t, candidate_neighbour_link) rpl_neighbour_list_t;
00069 
00070 /* Descriptor for a DODAG Version, identified by (RPLInstanceID, DODAGID, DODAGVersionNumber) */
00071 struct rpl_dodag_version
00072 {
00073     rpl_dodag_t *dodag;                             /* Back pointer to DODAG */
00074     uint8_t number;                                 /* Version Number */
00075     uint16_t lowest_advertised_rank;
00076     uint16_t last_advertised_rank;
00077     uint16_t hard_rank_limit;                       /* Hard rank limit by DAGMaxRankIncrease */
00078     uint16_t greediness_rank_limit;                 /* Rank limit for greediness */
00079     ns_list_link_t link;
00080 };
00081 
00082 /* Descriptor for a DODAG. A DODAG is identified by a (RPLInstanceID, DODAGID) tuple */
00083 struct rpl_dodag
00084 {
00085     rpl_instance_t *instance;                       /* Back pointer to instance */
00086     uint32_t timestamp;                             /* How long since we heard a DIO */
00087     uint8_t id[16];                                 /* Root identifier */
00088     uint8_t g_mop_prf;                              /* Grounded, Mode, Preference */
00089     rpl_dodag_conf_t config;                        /* Configuration from DIO */
00090     uint8_t info_version;                           /* Version for g_mop_prf and config */
00091     bool root:1;                                    /* We are the root of this DODAG */
00092     bool leaf:1;                                    /* We are a leaf in this DODAG (by policy) */
00093     bool have_config:1;                             /* We have the config */
00094     bool used:1;                                    /* We have ever been a member of this DODAG? */
00095     NS_LIST_HEAD (rpl_dodag_version_t, link) versions; /* List of DODAG versions (newest first) */
00096     prefix_list_t prefixes;                         /* Prefixes advertised in DIO PIOs */
00097     rpl_dio_route_list_t routes;                    /* Routes advertised in DIO RIOs*/
00098     trickle_params_t dio_timer_params;              /* Trickle parameters */
00099     ns_list_link_t link;
00100 };
00101 
00102 typedef struct rpl_dao_target rpl_dao_target_t;
00103 
00104 /* List of transits for a DAO target in a non-storing root */
00105 typedef struct rpl_dao_root_transit
00106 {
00107     uint8_t transit[16];
00108     rpl_dao_target_t *parent;           /* Current parent matched by transit. NULL if DODAG root, the original target if no match */
00109     rpl_dao_target_t *target;
00110     uint8_t path_control;
00111     uint16_t cost;
00112     ns_list_link_t parent_link;
00113     ns_list_link_t target_link;
00114 } rpl_dao_root_transit_t;
00115 
00116 typedef NS_LIST_HEAD (rpl_dao_root_transit_t, target_link) rpl_dao_root_transit_list_t;
00117 typedef NS_LIST_HEAD (rpl_dao_root_transit_t, parent_link) rpl_dao_root_transit_children_list_t;
00118 
00119 /* Information held for a DAO target in a non-storing root */
00120 typedef struct rpl_dao_root
00121 {
00122     uint32_t cost;                      /* Routing cost - (used as number of incoming graph edges during topo sort) */
00123     rpl_dao_root_transit_children_list_t children;   /* Child list - only valid after routing cost computation */
00124     rpl_dao_root_transit_list_t transits;
00125 } rpl_dao_root_t;
00126 
00127 /* Information held for a DAO target in other nodes */
00128 typedef struct rpl_dao_non_root
00129 {
00130     uint8_t path_lifetime;              /* Does this count down? 0 means "not set yet" on published targets - we don't hold "No-Path" entries */
00131     uint8_t pc_assigning;               /* Bitfield of Path Control being assigned by in-flight DAO */
00132     uint8_t pc_assigned;                /* Bitfield of Path Control successfully assigned */
00133     uint8_t pc_to_retry;                /* Bitfield of Path Control assignment to be retried */
00134     uint32_t refresh_timer;             /* Refresh timer (seconds) - 0xFFFFFFFF = infinite, 0 = not yet set */
00135 } rpl_dao_non_root_t;
00136 
00137 /* Descriptor for a RPL DAO target */
00138 struct rpl_dao_target
00139 {
00140     rpl_instance_t *instance;
00141     uint8_t prefix[16];
00142     uint8_t prefix_len;
00143     uint8_t path_sequence;
00144     uint8_t path_control;
00145     int8_t interface_id;
00146     uint32_t lifetime;                  /* Seconds */
00147     uint32_t descriptor;                /* Target descriptor */
00148     bool external:1;                    /* RPL 'E' flag */
00149     bool root:1;                        /* This is a "root" structure - root member of info active */
00150     bool published:1;                   /* Are we publishing, or did we get it from a DAO? (non-root) */
00151     bool own:1;                         /* Is this our own address, or are we publishing for an attached host? (non-root) */
00152     bool descriptor_present:1;          /* Target descriptor specified */
00153     bool need_seq_inc:1;
00154     bool connected:1;                   /* We know this target has a path to the root */
00155     union {
00156 #ifdef HAVE_RPL_ROOT
00157         rpl_dao_root_t root;            /* Info specific to a non-storing root */
00158 #endif
00159         rpl_dao_non_root_t non_root;    /* Info for other nodes (any in storing, non-root in non-storing) */
00160     } info;
00161     ns_list_link_t link;
00162 };
00163 
00164 typedef NS_LIST_HEAD (rpl_dao_target_t, link) rpl_dao_target_list_t;
00165 
00166 /* Descriptor for a RPL Instance. An instance can have multiple DODAGs.
00167  *
00168  * If top bit of instance_id is set then it's a local DODAG, and the dodags
00169  * list must have exactly one member, whose dodag_id disambiguates the
00170  * instance_id.
00171  */
00172 struct rpl_instance
00173 {
00174     ns_list_link_t link;
00175     rpl_domain_t *domain;                           /* Back pointer to domain */
00176     uint8_t id;                                     /* RPLInstanceID */
00177     uint8_t dtsn;                                   /* Our DTSN for this instance */
00178     bool neighbours_changed:1;
00179     bool local_repair:1;
00180     bool root_topo_sort_valid:1;
00181     bool root_paths_valid:1;
00182     bool dio_not_consistent:1;                      /* Something changed - not consistent this period */
00183     bool dao_in_transit:1;                          /* If we have a DAO in transit */
00184     bool requested_dao_ack:1;                       /* If we requested an ACK (so we retry if no ACK, rather than assuming success) */
00185     uint8_t poison_count;
00186     uint8_t repair_dis_count;
00187     uint16_t repair_dis_timer;
00188     uint32_t last_dao_trigger_time;
00189     uint16_t srh_error_count;                       /* SRH errors since last DAO trigger */
00190     NS_LIST_HEAD (rpl_dodag_t, link) dodags;         /* List of DODAGs */
00191     rpl_neighbour_list_t candidate_neighbours;      /* Candidate neighbour set */
00192    // rpl_neighbour_list_t old_neighbours;            /* Old neighbours (without a live DODAG version) */
00193     rpl_dodag_version_t *current_dodag_version;     /* Pointer to DODAG version we are a member of (if any) */
00194     uint16_t current_rank;                          /* Current rank in current DODAG Version */
00195     uint16_t parent_selection_timer;
00196     rpl_dodag_version_t *last_advertised_dodag_version; /* Pointer to last DODAG version we advertised */
00197     trickle_t dio_timer;                            /* Trickle timer for DIO transmission */
00198     rpl_dao_root_transit_children_list_t root_children;
00199     rpl_dao_target_list_t dao_targets;              /* List of DAO targets */
00200     uint8_t dao_sequence;                           /* Next DAO sequence to use */
00201     uint8_t dao_sequence_in_transit;                /* DAO sequence in transit (if dao_in_transit) */
00202     uint16_t delay_dao_timer;
00203     uint16_t dao_retry_timer;
00204     uint8_t dao_attempt;
00205     struct rpl_objective *of;                       /* Objective function pointer */
00206 };
00207 
00208 /* rpl_control.h uses NS_LIST_HEAD_INCOMPLETE */
00209 NS_STATIC_ASSERT(offsetof(struct rpl_instance, link) == 0, "Link must be first in struct rpl_instance")
00210 
00211 
00212 
00213 #endif /* RPL_STRUCTURES_H_ */