Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers rpl_structures.h Source File

rpl_structures.h

00001 /*
00002  * Copyright (c) 2015-2018, 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     rpl_dodag_version_t *dodag_version;     // Back pointer to DODAG Version (may be NULL, if not dodag_parent)
00049     uint8_t ll_address[16];                 // Link-local address (source of DIO)
00050     uint8_t global_address[16];             // Global address (from DIO RIO)
00051     bool dodag_parent: 1;                   // This is a DODAG parent (if true, dodag_version may not be NULL)
00052     bool was_dodag_parent: 1;               // Was a DODAG parent (used only during parent selection)
00053     bool have_global_address: 1;            // Global address known
00054     bool considered: 1;                     // Have considered at least once for parent selection
00055     bool confirmed: 1;                      // Confirmed
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     rpl_dodag_t *dodag;                             /* Back pointer to DODAG */
00073     uint8_t number;                                 /* Version Number */
00074     uint16_t lowest_advertised_rank;
00075     uint16_t last_advertised_rank;
00076     uint16_t hard_rank_limit;                       /* Hard rank limit by DAGMaxRankIncrease */
00077     uint16_t greediness_rank_limit;                 /* Rank limit for greediness */
00078     ns_list_link_t link;
00079 };
00080 
00081 /* Descriptor for a DODAG. A DODAG is identified by a (RPLInstanceID, DODAGID) tuple */
00082 struct rpl_dodag {
00083     rpl_instance_t *instance;                       /* Back pointer to instance */
00084     uint32_t timestamp;                             /* How long since we heard a DIO */
00085     uint8_t id[16];                                 /* Root identifier */
00086     uint8_t g_mop_prf;                              /* Grounded, Mode, Preference */
00087     rpl_dodag_conf_t config;                        /* Configuration from DIO */
00088     uint8_t info_version;                           /* Version for g_mop_prf and config */
00089     bool root: 1;                                   /* We are the root of this DODAG */
00090     bool leaf: 1;                                   /* We are a leaf in this DODAG (by policy) */
00091     bool have_config: 1;                            /* We have the config */
00092     bool used: 1;                                   /* We have ever been a member of this DODAG? */
00093     uint8_t new_config_advertisment_count;      /* We have advertiment new config at multicasti DIO */
00094     NS_LIST_HEAD (rpl_dodag_version_t, link) versions; /* List of DODAG versions (newest first) */
00095     prefix_list_t prefixes;                         /* Prefixes advertised in DIO PIOs */
00096     rpl_dio_route_list_t routes;                    /* Routes advertised in DIO RIOs*/
00097     trickle_params_t dio_timer_params;              /* Trickle parameters */
00098     ns_list_link_t link;
00099 };
00100 
00101 typedef struct rpl_dao_target rpl_dao_target_t;
00102 
00103 /* List of transits for a DAO target in a non-storing root */
00104 typedef struct rpl_dao_root_transit {
00105     uint8_t transit[16];
00106     rpl_dao_target_t *parent;           /* Current parent matched by transit. NULL if DODAG root, the original target if no match */
00107     rpl_dao_target_t *target;
00108     uint8_t path_control;
00109     uint16_t cost;
00110     ns_list_link_t parent_link;
00111     ns_list_link_t target_link;
00112 } rpl_dao_root_transit_t;
00113 
00114 typedef NS_LIST_HEAD (rpl_dao_root_transit_t, target_link) rpl_dao_root_transit_list_t;
00115 typedef NS_LIST_HEAD (rpl_dao_root_transit_t, parent_link) rpl_dao_root_transit_children_list_t;
00116 
00117 /* Information held for a DAO target in a non-storing root */
00118 typedef struct rpl_dao_root {
00119     uint32_t cost;                      /* Routing cost - (used as number of incoming graph edges during topo sort) */
00120     rpl_dao_root_transit_children_list_t children;   /* Child list - only valid after routing cost computation */
00121     rpl_dao_root_transit_list_t transits;
00122 } rpl_dao_root_t;
00123 
00124 /* Information held for a DAO target in other nodes */
00125 typedef struct rpl_dao_non_root {
00126     uint8_t path_lifetime;              /* Does this count down? 0 means "not set yet" on published targets - we don't hold "No-Path" entries */
00127     uint8_t pc_assigning;               /* Bitfield of Path Control being assigned by in-flight DAO */
00128     uint8_t pc_assigned;                /* Bitfield of Path Control successfully assigned */
00129     uint8_t pc_to_retry;                /* Bitfield of Path Control assignment to be retried */
00130     uint32_t refresh_timer;             /* Refresh timer (seconds) - 0xFFFFFFFF = infinite, 0 = not yet set */
00131 } rpl_dao_non_root_t;
00132 
00133 
00134 /* Descriptor for a RPL DAO target */
00135 struct rpl_dao_target {
00136     rpl_instance_t *instance;
00137     uint8_t prefix[16];
00138     uint8_t prefix_len;
00139     uint8_t path_sequence;
00140     uint8_t path_control;
00141     uint8_t response_wait_time;
00142     int8_t interface_id;
00143     uint32_t lifetime;                  /* Seconds */
00144     uint32_t descriptor;                /* Target descriptor */
00145     bool external: 1;                   /* RPL 'E' flag */
00146     bool root: 1;                       /* This is a "root" structure - root member of info active */
00147     bool published: 1;                  /* Are we publishing, or did we get it from a DAO? (non-root) */
00148     bool own: 1;                        /* Is this our own address, or are we publishing for an attached host? (non-root) */
00149     bool descriptor_present: 1;         /* Target descriptor specified */
00150     bool need_seq_inc: 1;
00151     bool connected: 1;                  /* We know this target has a path to the root */
00152     bool trig_confirmation_state: 1;         /* Enable confirmation to parent's */
00153     bool active_confirmation_state: 1;
00154     union {
00155 #ifdef HAVE_RPL_ROOT
00156         rpl_dao_root_t root;            /* Info specific to a non-storing root */
00157 #endif
00158         rpl_dao_non_root_t non_root;    /* Info for other nodes (any in storing, non-root in non-storing) */
00159     } info;
00160     ns_list_link_t link;
00161 };
00162 
00163 typedef NS_LIST_HEAD (rpl_dao_target_t, link) rpl_dao_target_list_t;
00164 
00165 /* Descriptor for a RPL Instance. An instance can have multiple DODAGs.
00166  *
00167  * If top bit of instance_id is set then it's a local DODAG, and the dodags
00168  * list must have exactly one member, whose dodag_id disambiguates the
00169  * instance_id.
00170  */
00171 struct rpl_instance {
00172     ns_list_link_t link;
00173     rpl_domain_t *domain;                           /* Back pointer to domain */
00174     uint8_t id;                                     /* RPLInstanceID */
00175     uint8_t dtsn;                                   /* Our DTSN for this instance */
00176     bool neighbours_changed: 1;
00177     bool local_repair: 1;
00178     bool root_topo_sort_valid: 1;
00179     bool root_paths_valid: 1;
00180     bool dio_not_consistent: 1;                     /* Something changed - not consistent this period */
00181     bool dao_in_transit: 1;                         /* If we have a DAO in transit */
00182     bool requested_dao_ack: 1;                      /* If we requested an ACK (so we retry if no ACK, rather than assuming success) */
00183     bool pending_neighbour_confirmation: 1;         /* if we have not finished address registration state to parent */
00184     uint8_t poison_count;
00185     uint8_t repair_dis_count;
00186     uint16_t repair_dis_timer;
00187     uint32_t last_dao_trigger_time;
00188     uint16_t srh_error_count;                       /* SRH errors since last DAO trigger */
00189     NS_LIST_HEAD (rpl_dodag_t, link) dodags;         /* List of DODAGs */
00190     rpl_neighbour_t *wait_response;
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_ */