Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
rpl_control.h
00001 /* 00002 * Copyright (c) 2015-2019, 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_CONTROL_H_ 00019 #define RPL_CONTROL_H_ 00020 00021 #ifdef HAVE_RPL 00022 00023 #include "ns_list.h" 00024 #include "ipv6_stack/ipv6_routing_table.h" 00025 00026 struct rpl_instance; 00027 struct rpl_dodag_conf; 00028 struct rpl_dodag; 00029 struct buffer; 00030 struct protocol_interface_info_entry; 00031 struct rpl_dodag_info_t; 00032 struct prefix_entry_t; 00033 00034 typedef enum rpl_event { 00035 RPL_EVENT_DAO_DONE, /* Simplistic trigger for bootstrap advance - a DAO registration completed */ 00036 RPL_EVENT_LOCAL_REPAIR_START, /* RPL start scanning new parent by multicast DIS user can disable beacon request responser here*/ 00037 RPL_EVENT_LOCAL_REPAIR_NO_MORE_DIS, /* RPL not sending DIS anymore user can report bootstrap error */ 00038 RPL_EVENT_DAO_PARENT_ADD, /* RPL indicate that DAO downward Parent has been added */ 00039 } rpl_event_t; 00040 00041 typedef void rpl_domain_callback_t(rpl_event_t event, void *handle); 00042 00043 typedef void rpl_prefix_callback_t(struct prefix_entry_t *prefix, void *handle, uint8_t *parent_link_local); 00044 00045 typedef bool rpl_new_parent_callback_t(uint8_t *ll_parent_address, void *handle); 00046 00047 typedef struct rpl_domain { 00048 NS_LIST_HEAD_INCOMPLETE(struct rpl_instance) instances; 00049 ns_list_link_t link; 00050 /* For non-storing mode, we have to assume a "downstream" interface - 00051 * routing headers contain global addresses that we won't know, and we have 00052 * to assume they're on link on an assumed interface. 00053 */ 00054 int8_t non_storing_downstream_interface; 00055 /* As part of shutdown, we can force entering leaf mode */ 00056 bool force_leaf; 00057 rpl_domain_callback_t *callback; 00058 rpl_prefix_callback_t *prefix_cb; 00059 rpl_new_parent_callback_t *new_parent_add; 00060 void *cb_handle; 00061 } rpl_domain_t; 00062 00063 /* Configuration parameters for a DODAG, obtained through DIO DODAG Configuration options */ 00064 typedef struct rpl_dodag_conf { 00065 bool authentication: 1; 00066 unsigned path_control_size: 3; 00067 uint8_t dio_interval_min; /* log2 milliseconds */ 00068 uint8_t dio_interval_doublings; 00069 uint8_t dio_redundancy_constant; 00070 uint8_t default_lifetime; /* lifetime units */ 00071 uint16_t dag_max_rank_increase; 00072 uint16_t min_hop_rank_increase; 00073 uint16_t objective_code_point; 00074 uint16_t lifetime_unit; /* seconds */ 00075 } rpl_dodag_conf_t; 00076 00077 /* Descriptor for a route from a DIO Route Information option. 00078 * Used to hold the "master copy" in the DODAG structure - the table for the 00079 * current DODAG is used to populate routes in our system routing table, and to 00080 * form our own DIOs. 00081 * Not used directly for next hop determination - this is done via the system 00082 * routing table, which has per-parent information including parent preferences, 00083 * reachability/probing info, etc. 00084 */ 00085 typedef struct rpl_dio_route { 00086 uint32_t lifetime; /* Lifetime in seconds */ 00087 ns_list_link_t link; 00088 bool age; /* Do we age the lifetime? */ 00089 uint8_t hold_count; /* Hold count for relaying 0 lifetime */ 00090 uint8_t flags; /* Flags byte (inc. pref) */ 00091 uint8_t prefix_len_bytes; /* Prefix length (bytes) - padding preserved when relaying */ 00092 uint8_t prefix_len; /* Prefix length (bits) */ 00093 uint8_t prefix[]; /* Variable-length prefix */ 00094 } rpl_dio_route_t; 00095 00096 typedef NS_LIST_HEAD (rpl_dio_route_t, link) rpl_dio_route_list_t; 00097 00098 /******************************* RPL internal API ****************************/ 00099 void *rpl_alloc(uint16_t size); 00100 void *rpl_realloc(void *p, uint16_t old_size, uint16_t new_size); 00101 void rpl_free(void *p, uint16_t size); 00102 void rpl_control_transmit(struct rpl_domain *domain, struct protocol_interface_info_entry *cur, uint8_t code, struct buffer *buf, const uint8_t *dst); 00103 void rpl_control_transmit_multicast_dio(struct rpl_domain *domain, struct rpl_instance *instance, uint8_t instance_id, uint8_t dodag_version, uint16_t rank, uint8_t g_mop_prf, uint8_t dtsn, const uint8_t dodagid[16], const struct rpl_dodag_conf *conf); 00104 void rpl_control_transmit_dio(struct rpl_domain *domain, struct protocol_interface_info_entry *cur, uint8_t instance_id, uint8_t dodag_version, uint16_t rank, uint8_t g_mop_prf, uint8_t dtsn, struct rpl_dodag *dodag, const uint8_t dodagid[16], const struct rpl_dodag_conf *conf, const uint8_t *dst); 00105 bool rpl_control_transmit_dao(struct rpl_domain *domain, struct protocol_interface_info_entry *cur, struct rpl_instance *instance, uint8_t instance_id, uint8_t dao_sequence, const uint8_t dodagid[16], const uint8_t *opts, uint16_t opts_size, const uint8_t *dst); 00106 void rpl_control_disable_ra_routes(struct rpl_domain *domain); 00107 void rpl_control_event(struct rpl_domain *domain, rpl_event_t event); 00108 void rpl_control_process_prefix_option(struct prefix_entry_t *prefix, struct protocol_interface_info_entry *cur); 00109 00110 /*********************** RPL control API to rest of system *******************/ 00111 00112 /* Memory configuration */ 00113 void rpl_control_set_memory_limits(size_t soft_limit, size_t hard_limit); 00114 00115 /* Timer routines */ 00116 void rpl_control_fast_timer(uint16_t ticks); 00117 void rpl_control_slow_timer(uint16_t seconds); 00118 00119 /* Packet handlers, and other data flow callback indications */ 00120 struct buffer *rpl_control_handler(struct buffer *buf); 00121 struct buffer *rpl_control_source_route_error_handler(struct buffer *buf, struct protocol_interface_info_entry *cur); 00122 00123 /* Manually send DIS packets for bootstrap */ 00124 void rpl_control_transmit_dis(struct rpl_domain *domain, struct protocol_interface_info_entry *cur, uint8_t pred, uint8_t instance_id, const uint8_t *dodagid, const uint8_t version, const uint8_t *dst); 00125 bool rpl_control_have_dodag(struct rpl_domain *domain); 00126 00127 /* APIs used to manipulate configuration at the root */ 00128 struct rpl_dodag *rpl_control_create_dodag_root(rpl_domain_t *domain, uint8_t instance_id, const uint8_t *dodagid, const rpl_dodag_conf_t *conf, uint16_t rank, uint8_t g_mop_prf); 00129 void rpl_control_delete_dodag_root(rpl_domain_t *domain, struct rpl_dodag *dodag); 00130 void rpl_control_update_dodag_route(struct rpl_dodag *dodag, const uint8_t *prefix, uint8_t prefix_len, uint8_t flags, uint32_t lifetime, bool age); 00131 void rpl_control_update_dodag_prefix(struct rpl_dodag *dodag, const uint8_t *prefix, uint8_t prefix_len, uint8_t flags, uint32_t lifetime, uint32_t preftime, bool age); 00132 void rpl_control_increment_dodag_version(struct rpl_dodag *dodag); 00133 void rpl_control_update_dodag_config(struct rpl_dodag *dodag, const rpl_dodag_conf_t *conf); 00134 void rpl_control_set_dodag_pref(struct rpl_dodag *dodag, uint8_t pref); 00135 void rpl_control_increment_dtsn(struct rpl_dodag *dodag); 00136 00137 /* Force leaf behaviour on a domain - useful before shutdown, and in conjunction with poison */ 00138 void rpl_control_force_leaf(rpl_domain_t *domain, bool leaf); 00139 00140 /* Manually send poison on all existing instances a few times */ 00141 void rpl_control_poison(rpl_domain_t *domain, uint8_t poison_count); 00142 00143 /* APIs to create domains and map them to interfaces */ 00144 rpl_domain_t *rpl_control_create_domain(void); 00145 void rpl_control_delete_domain(rpl_domain_t *domain); 00146 void rpl_control_set_domain_on_interface(struct protocol_interface_info_entry *cur, rpl_domain_t *domain, bool downstream); 00147 void rpl_control_remove_domain_from_interface(struct protocol_interface_info_entry *cur); 00148 void rpl_control_free_domain_instances_from_interface(struct protocol_interface_info_entry *cur); 00149 void rpl_control_set_callback(rpl_domain_t *domain, rpl_domain_callback_t callback, rpl_prefix_callback_t prefix_learn_cb, rpl_new_parent_callback_t new_parent_add, void *cb_handle); 00150 00151 /* Target publishing */ 00152 void rpl_control_publish_host_address(rpl_domain_t *domain, const uint8_t addr[16], uint32_t lifetime); 00153 void rpl_control_unpublish_address(rpl_domain_t *domain, const uint8_t addr[16]); 00154 bool rpl_control_is_dodag_parent(struct protocol_interface_info_entry *interface, const uint8_t ll_addr[16]); 00155 bool rpl_control_is_dodag_parent_candidate(struct protocol_interface_info_entry *interface, const uint8_t ll_addr[16], uint16_t candidate_cmp_limiter); 00156 uint16_t rpl_control_parent_candidate_list_size(struct protocol_interface_info_entry *interface, bool parent_list); 00157 void rpl_control_neighbor_delete(struct protocol_interface_info_entry *interface, const uint8_t ll_addr[16]); 00158 /* Parent link confirmation API extension */ 00159 void rpl_control_request_parent_link_confirmation(bool requested); 00160 void rpl_control_set_dio_multicast_min_config_advertisment_count(uint8_t min_count); 00161 void rpl_control_set_dao_retry_count(uint8_t count); 00162 void rpl_control_set_initial_dao_ack_wait(uint16_t timeout_in_ms); 00163 void rpl_control_register_address(struct protocol_interface_info_entry *interface, const uint8_t addr[16]); 00164 void rpl_control_address_register_done(struct protocol_interface_info_entry *interface, const uint8_t ll_addr[16], uint8_t status); 00165 00166 /* Configure and return the routing lookup predicate for a specified RPL instance ID */ 00167 ipv6_route_predicate_fn_t *rpl_control_get_route_predicate(rpl_domain_t *domain, uint8_t instance_id, const uint8_t src[16], const uint8_t dst[16]); 00168 00169 /* Diagnostic APIs */ 00170 void rpl_control_print(route_print_fn_t *print_fn); 00171 00172 struct rpl_instance *rpl_control_enumerate_instances(rpl_domain_t *domain, struct rpl_instance *instance); 00173 struct rpl_instance *rpl_control_lookup_instance(rpl_domain_t *domain, uint8_t instance_id, const uint8_t *dodagid); 00174 bool rpl_control_get_instance_dao_target_count(rpl_domain_t *domain, uint8_t instance_id, const uint8_t *dodagid, const uint8_t *prefix, uint16_t *target_count); 00175 bool rpl_control_read_dodag_info(const struct rpl_instance *instance, struct rpl_dodag_info_t *dodag_info); 00176 const rpl_dodag_conf_t *rpl_control_get_dodag_config(const struct rpl_instance *instance); 00177 const uint8_t *rpl_control_preferred_parent_addr(const struct rpl_instance *instance, bool global); 00178 uint16_t rpl_control_current_rank(const struct rpl_instance *instance); 00179 00180 #else /* HAVE_RPL */ 00181 00182 #define rpl_control_fast_timer(ticks) ((void) 0) 00183 #define rpl_control_slow_timer(seconds) ((void) 0) 00184 #define rpl_control_remove_domain_from_interface(cur) ((void) 0) 00185 #define rpl_control_free_domain_instances_from_interface(cur) ((void) 0) 00186 #define rpl_control_register_address(interface, addr) ((void) 0) 00187 #define rpl_control_address_register_done(interface, ll_addr, status) ((void) 0) 00188 00189 #endif /* HAVE_RPL */ 00190 00191 #endif /* RPL_CONTROL_H_ */
Generated on Tue Jul 12 2022 13:54:47 by
