Skip to content

Commit

Permalink
FHSS and address registration update
Browse files Browse the repository at this point in the history
Fixed Address registration after parent update by RPL

Fixed Unicast random fixed channel bug.

Change-Id: Iae7ac55aab0323155cf8a9d8a66326bbd845189c
  • Loading branch information
Juha Heiskanen committed Sep 28, 2018
1 parent c14343a commit eac63d2
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 4 deletions.
5 changes: 5 additions & 0 deletions source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,16 +526,21 @@ uint16_t protocol_6lowpan_neighbor_second_priority_set(int8_t interface_id, addr
mac_neighbor_table_entry_t * entry = mac_neighbor_table_address_discover(mac_neighbor_info(cur), addr_ptr + PAN_ID_LEN, addr_type);

if (entry) {
bool new_secondary = false;
etx_storage_t *etx_entry = etx_storage_entry_get(interface_id, entry->index);
// If secondary parent has changed clears priority from previous parent
if (entry->link_role != SECONDARY_PARENT_NEIGHBOUR) {
new_secondary = true;
protocol_6lowpan_neighbor_priority_clear_all(interface_id, PRIORITY_2ND);
}
entry->link_role = SECONDARY_PARENT_NEIGHBOUR;

if (etx_entry) {
protocol_stats_update(STATS_ETX_2ND_PARENT, etx_entry->etx >> 4);
}
if (new_secondary) {
ws_secondary_parent_update(cur);
}
return 1;
} else {
return 0;
Expand Down
38 changes: 34 additions & 4 deletions source/6LoWPAN/ws/ws_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,9 @@ static int8_t ws_fhss_set_defaults(protocol_interface_info_entry_t *cur, fhss_ws
fhss_configuration->ws_bc_channel_function = cur->ws_info->fhss_bc_channel_function;
fhss_configuration->fhss_bc_dwell_interval = cur->ws_info->fhss_bc_dwell_interval;
fhss_configuration->fhss_broadcast_interval = cur->ws_info->fhss_bc_interval;
fhss_configuration->unicast_fixed_channel = cur->ws_info->fhss_uc_fixed_channel;
if (cur->ws_info->fhss_uc_fixed_channel != 0xffff) {
fhss_configuration->unicast_fixed_channel = cur->ws_info->fhss_uc_fixed_channel;
}
fhss_configuration->broadcast_fixed_channel = cur->ws_info->fhss_bc_fixed_channel;
ws_generate_channel_list(fhss_configuration->channel_mask, cur->ws_info->hopping_schdule.number_of_channels, cur->ws_info->hopping_schdule.regulatory_domain);

Expand Down Expand Up @@ -490,7 +492,7 @@ static void ws_bootstrap_primary_parent_set(struct protocol_interface_info_entry
fhss_configuration.broadcast_fixed_channel = cur->ws_info->fhss_bc_fixed_channel;

}
fhss_configuration.unicast_fixed_channel = cur->ws_info->fhss_uc_fixed_channel;

ns_fhss_ws_configuration_set(cur->ws_info->fhss_api, &fhss_configuration);

// We have broadcast schedule set up set the broadcast parent schedule
Expand Down Expand Up @@ -1448,6 +1450,14 @@ static void ws_set_fhss_hop(protocol_interface_info_entry_t *cur)
ns_fhss_ws_set_hop_count(cur->ws_info->fhss_api, own_hop);
}

static void ws_address_registration_update(protocol_interface_info_entry_t *interface)
{
if (!interface->ws_info->address_registration_event_active) {
interface->ws_info->address_registration_event_active = true;
tr_info("RPL parent update ... register ARO");
ws_bootsrap_event_trig(WS_ADDRESS_ADDED, interface->bootStrapId, ARM_LIB_LOW_PRIORITY_EVENT, NULL);
}
}

static void ws_bootstrap_rpl_callback(rpl_event_t event, void *handle)
{
Expand All @@ -1472,8 +1482,7 @@ static void ws_bootstrap_rpl_callback(rpl_event_t event, void *handle)
*/

} else if (event == RPL_EVENT_DAO_PARENT_SWITCH) {
tr_info("RPL parent update ... register ARO");
ws_bootsrap_event_trig(WS_ADDRESS_ADDED, cur->bootStrapId, ARM_LIB_LOW_PRIORITY_EVENT, NULL);
ws_address_registration_update(cur);
}
cur->ws_info->rpl_state = event;
tr_info("RPL event %d", event);
Expand Down Expand Up @@ -1861,6 +1870,7 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
ws_bootstrap_state_change(cur, ER_BOOTSRAP_DONE);
break;
case WS_ADDRESS_ADDED:
cur->ws_info->address_registration_event_active = false;
if (!ws_bootstrap_address_registration_ongoing(cur)) {
rpl_control_register_address(cur, (if_address_entry_t *) event->data_ptr);
}
Expand Down Expand Up @@ -2052,6 +2062,26 @@ void ws_primary_parent_update(protocol_interface_info_entry_t *interface, mac_ne
neighbor_info.neighbor = neighbor;
neighbor_info.ws_neighbor = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, neighbor->index);
ws_bootstrap_primary_parent_set(interface, &neighbor_info);

//Clear both address registration
ns_list_foreach(if_address_entry_t, address, &interface->ip_addresses) {
if (!addr_is_ipv6_link_local(address->address)) {
address->addr_reg_done = 0;
ws_address_registration_update(interface);
}
}
}
}

void ws_secondary_parent_update(protocol_interface_info_entry_t *interface)
{
if (interface->ws_info) {
ns_list_foreach(if_address_entry_t, address, &interface->ip_addresses) {
if (!addr_is_ipv6_link_local(address->address)) {
address->addr_reg_done = 0;
ws_address_registration_update(interface);
}
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions source/6LoWPAN/ws/ws_bootstrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ void ws_bootstrap_trickle_timer(protocol_interface_info_entry_t *cur, uint16_t t

void ws_primary_parent_update(protocol_interface_info_entry_t *interface, mac_neighbor_table_entry_t *neighbor);

void ws_secondary_parent_update(protocol_interface_info_entry_t *interface);

void ws_nud_entry_remove_active(protocol_interface_info_entry_t *cur, void *neighbor);

void ws_nud_active_timer(protocol_interface_info_entry_t *cur, uint16_t ticks);
Expand All @@ -66,6 +68,7 @@ void ws_nud_active_timer(protocol_interface_info_entry_t *cur, uint16_t ticks);
#define ws_bootstrap_state_machine(cur)
#define ws_bootstrap_restart(cur)
#define ws_primary_parent_update(interface, neighbor)
#define ws_secondary_parent_update(interface)

#endif //HAVE_WS

Expand Down
1 change: 1 addition & 0 deletions source/6LoWPAN/ws/ws_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ typedef struct ws_info_s {
uint32_t pan_version_timer; /**< border router version udate timeout */
uint32_t pan_version_timeout_timer; /**< routers will fallback to previous state after this */
uint8_t gtkhash[32];
bool address_registration_event_active : 1;
bool configuration_learned:1;
bool trickle_pas_running:1;
bool trickle_pa_running:1;
Expand Down

0 comments on commit eac63d2

Please sign in to comment.