Skip to content

Commit

Permalink
Added new Callback to RPL indicate Multicast DIS received from RPL Pa…
Browse files Browse the repository at this point in the history
…rent

Wi-SUN enable new callback and trigger ARO registration faster if possible.
  • Loading branch information
Juha Heiskanen committed Feb 9, 2021
1 parent 85b949e commit 5e9ac4e
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2184,7 +2184,7 @@ void nwk_6lowpan_nd_address_registartion_ready(protocol_interface_info_entry_t *
// arm_nwk_6lowpan_rpl_dodag_poison from a previous connection may have left force_leaf set
rpl_control_force_leaf(protocol_6lowpan_rpl_domain, false);
rpl_control_set_domain_on_interface(cur, protocol_6lowpan_rpl_domain, true);
rpl_control_set_callback(protocol_6lowpan_rpl_domain, protocol_6lowpan_bootstrap_rpl_callback, NULL, NULL, cur);
rpl_control_set_callback(protocol_6lowpan_rpl_domain, protocol_6lowpan_bootstrap_rpl_callback, NULL, NULL, NULL, cur);
}
// Send unicast DIS to coordinator
nwk_bootstrap_icmp_rpl_dis_coord_msg_tx(cur);
Expand Down
30 changes: 29 additions & 1 deletion source/6LoWPAN/ws/ws_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -2880,6 +2880,34 @@ static bool ws_rpl_new_parent_callback(uint8_t *ll_parent_address, void *handle,
return create_ok;
}

static void ws_rpl_parent_dis_callback(const uint8_t *ll_parent_address, void *handle, struct rpl_instance *instance)
{
(void) ll_parent_address;
protocol_interface_info_entry_t *cur = handle;
if (!cur->rpl_domain || cur->interface_mode != INTERFACE_UP) {
return;
}
//Multicast DIS from parent indicate that Parent is not valid in short time window possible
//Here we could trigger ARO registration by Triggle Imin
//Trigger ARO by Imin * 2
const rpl_dodag_conf_t *config = rpl_control_get_dodag_config(instance);
if (!config) {
//dio imin Period caluclate in seconds
uint32_t Imin_ms = config->dio_interval_min < 32 ? (1ul << config->dio_interval_min) : 0xfffffffful;
//Covert to seconds and multiple by 2 so we give time to recovery so divide by 500 do that opeartion
uint32_t Imin_secs = (Imin_ms + 499) / 500;

if (Imin_secs > 0xffff) {
Imin_secs = 0xffff;
}

if (cur->ws_info->aro_registration_timer > Imin_secs) {
cur->ws_info->aro_registration_timer = Imin_secs;
}
}

}

static void ws_bootstrap_rpl_activate(protocol_interface_info_entry_t *cur)
{
tr_debug("RPL Activate");
Expand All @@ -2888,7 +2916,7 @@ static void ws_bootstrap_rpl_activate(protocol_interface_info_entry_t *cur)

addr_add_router_groups(cur);
rpl_control_set_domain_on_interface(cur, protocol_6lowpan_rpl_domain, downstream);
rpl_control_set_callback(protocol_6lowpan_rpl_domain, ws_bootstrap_rpl_callback, ws_rpl_prefix_callback, ws_rpl_new_parent_callback, cur);
rpl_control_set_callback(protocol_6lowpan_rpl_domain, ws_bootstrap_rpl_callback, ws_rpl_prefix_callback, ws_rpl_new_parent_callback, ws_rpl_parent_dis_callback, cur);
// If i am router I Do this
rpl_control_force_leaf(protocol_6lowpan_rpl_domain, leaf);
rpl_control_process_routes(protocol_6lowpan_rpl_domain, false); // Wi-SUN assumes that no default route needed
Expand Down
28 changes: 22 additions & 6 deletions source/RPL/rpl_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,9 @@ rpl_domain_t *rpl_control_create_domain(void)
ns_list_init(&domain->instances);
domain->non_storing_downstream_interface = -1;
domain->callback = NULL;
domain->new_parent_add = NULL;
domain->parent_dis = NULL;
domain->prefix_cb = NULL;
domain->cb_handle = NULL;
domain->force_leaf = false;
domain->process_routes = true;
Expand Down Expand Up @@ -528,12 +531,13 @@ void rpl_control_free_domain_instances_from_interface(protocol_interface_info_en
}
}

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)
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, rpl_parent_dis_callback_t parent_dis, void *cb_handle)
{
domain->callback = callback;
domain->prefix_cb = prefix_learn_cb;
domain->cb_handle = cb_handle;
domain->new_parent_add = new_parent_add;
domain->parent_dis = parent_dis;
}

/* To do - this should live somewhere nicer. Basically a bootstrap
Expand Down Expand Up @@ -562,6 +566,11 @@ bool rpl_control_have_dodag(rpl_domain_t *domain)

typedef void rpl_control_predicate_loop_fn_t(rpl_instance_t *instance, rpl_dodag_version_t *version, void *arg);

typedef struct rpl_loopfn_trigger_unicast_dio_arg {
struct protocol_interface_info_entry *interface;
const uint8_t *dst;
} rpl_loopfn_trigger_unicast_dio_arg_t;

/* Callbacks for rpl_control_predicate_loop */

static void rpl_loopfn_reset_dio_timer(rpl_instance_t *instance, rpl_dodag_version_t *dodag_version, void *handle)
Expand All @@ -570,12 +579,19 @@ static void rpl_loopfn_reset_dio_timer(rpl_instance_t *instance, rpl_dodag_versi
(void)handle;

rpl_instance_inconsistency(instance);
}
//Check was Multicast DIS from parent
rpl_loopfn_trigger_unicast_dio_arg_t *arg = handle;
rpl_domain_t *domain = arg->interface->rpl_domain;
if (domain && domain->parent_dis) {

typedef struct rpl_loopfn_trigger_unicast_dio_arg {
struct protocol_interface_info_entry *interface;
const uint8_t *dst;
} rpl_loopfn_trigger_unicast_dio_arg_t;
if (rpl_instance_address_is_parent(instance, arg->dst)) {
// Call Multicast DIS parent Callback
domain->parent_dis(arg->dst, arg->interface, instance);
}
}


}

static void rpl_loopfn_trigger_unicast_dio(rpl_instance_t *instance, rpl_dodag_version_t *dodag_version, void *handle)
{
Expand Down
5 changes: 4 additions & 1 deletion source/RPL/rpl_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ typedef void rpl_prefix_callback_t(struct prefix_entry_t *prefix, void *handle,

typedef bool rpl_new_parent_callback_t(uint8_t *ll_parent_address, void *handle, struct rpl_instance *instance, uint16_t candidate_rank);

typedef void rpl_parent_dis_callback_t(const uint8_t *ll_parent_address, void *handle, struct rpl_instance *instance);

typedef struct rpl_route_info {
uint8_t node[8]; /* IID of parent in parent child relation table */
uint8_t parent[8]; /* IID of child in parent child relation table */
Expand All @@ -65,6 +67,7 @@ typedef struct rpl_domain {
rpl_domain_callback_t *callback;
rpl_prefix_callback_t *prefix_cb;
rpl_new_parent_callback_t *new_parent_add;
rpl_parent_dis_callback_t *parent_dis;
void *cb_handle;
} rpl_domain_t;

Expand Down Expand Up @@ -159,7 +162,7 @@ void rpl_control_delete_domain(rpl_domain_t *domain);
void rpl_control_set_domain_on_interface(struct protocol_interface_info_entry *cur, rpl_domain_t *domain, bool downstream);
void rpl_control_remove_domain_from_interface(struct protocol_interface_info_entry *cur);
void rpl_control_free_domain_instances_from_interface(struct protocol_interface_info_entry *cur);
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);
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, rpl_parent_dis_callback_t parent_dis, void *cb_handle);

/* Target publishing */
void rpl_control_publish_host_address(rpl_domain_t *domain, const uint8_t addr[16], uint32_t lifetime);
Expand Down
2 changes: 1 addition & 1 deletion test/nanostack/unittest/stub/rpl_control_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void rpl_control_free_domain_instances_from_interface(protocol_interface_info_en

}

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)
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, rpl_parent_dis_callback_t parent_dis, void *cb_handle)
{

}
Expand Down

0 comments on commit 5e9ac4e

Please sign in to comment.