Skip to content

Commit

Permalink
EAPOL FHSS temp entry discover
Browse files Browse the repository at this point in the history
Extented Wi-SUN FHSS neighbour data discovery with EAPOL temp entry discovery.

Remoived Temp MAC neighbour usage for EAPOL temp neighbour.
  • Loading branch information
Juha Heiskanen committed May 14, 2021
1 parent 5200b66 commit 3f7eae6
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 93 deletions.
66 changes: 10 additions & 56 deletions source/6LoWPAN/ws/ws_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,56 +199,10 @@ static void ws_bootstrap_neighbor_delete(struct protocol_interface_info_entry *i
ws_neighbor_class_entry_remove(&interface->ws_info->neighbor_storage, entry_ptr->index);
}

static void ws_bootstap_eapol_neigh_entry_allocate(struct protocol_interface_info_entry *interface)
{
uint8_t mac_64[8];
memset(mac_64, 0, sizeof(mac_64));
mac_neighbor_table_entry_t *mac_entry = ws_bootstrap_mac_neighbor_allocate(interface, mac_64);

if (!mac_entry) {
return;
}
mac_entry->lifetime = 0xffffffff;
mac_entry->link_lifetime = 0xffffffff;
ws_neighbor_class_entry_t *ws_neigh = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, mac_entry->index);
if (!ws_neigh) {
return;
}

interface->ws_info->eapol_tx_index = mac_entry->index;
}

ws_neighbor_class_entry_t *ws_bootstrap_eapol_tx_temporary_set(struct protocol_interface_info_entry *interface, const uint8_t *src64)
{
mlme_device_descriptor_t device_desc;
mac_neighbor_table_entry_t *mac_entry = mac_neighbor_table_attribute_discover(mac_neighbor_info(interface), interface->ws_info->eapol_tx_index);
if (!mac_entry) {
return NULL;
}

memcpy(mac_entry->mac64, src64, 8);
mac_helper_device_description_write(interface, &device_desc, src64, 0xffff, 0, false);
mac_helper_devicetable_direct_set(interface->mac_api, &device_desc, mac_entry->index);
return ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, mac_entry->index);
}

void ws_bootstrap_eapol_tx_temporary_clear(struct protocol_interface_info_entry *interface)
{
mac_neighbor_table_entry_t *mac_entry = mac_neighbor_table_attribute_discover(mac_neighbor_info(interface), interface->ws_info->eapol_tx_index);
if (!mac_entry) {
return;
}

memset(mac_entry->mac64, 0xff, 8);
mac_helper_devicetable_remove(interface->mac_api, interface->ws_info->eapol_tx_index, NULL);
}

static void ws_bootstrap_neighbor_list_clean(struct protocol_interface_info_entry *interface)
{

mac_neighbor_table_neighbor_list_clean(mac_neighbor_info(interface));
//Allocate EAPOL TX temporary neigh entries
ws_bootstap_eapol_neigh_entry_allocate(interface);
}

static void ws_address_reregister_trig(struct protocol_interface_info_entry *interface)
Expand Down Expand Up @@ -560,14 +514,19 @@ static fhss_ws_neighbor_timing_info_t *ws_get_neighbor_info(const fhss_api_t *ap
return NULL;
}
mac_neighbor_table_entry_t *mac_neighbor = mac_neighbor_table_address_discover(mac_neighbor_info(cur), eui64, MAC_ADDR_MODE_64_BIT);
if (!mac_neighbor) {
return NULL;
if (mac_neighbor) {
ws_neighbor_class_entry_t *ws_neighbor = ws_neighbor_class_entry_get(&cur->ws_info->neighbor_storage, mac_neighbor->index);
if (!ws_neighbor) {
return NULL;
}
return &ws_neighbor->fhss_data;
}
ws_neighbor_class_entry_t *ws_neighbor = ws_neighbor_class_entry_get(&cur->ws_info->neighbor_storage, mac_neighbor->index);
if (!ws_neighbor) {
//Discover temporary entry
ws_neighbor_temp_class_t *temp_entry = ws_llc_get_eapol_temp_entry(cur, eui64);
if (!temp_entry) {
return NULL;
}
return &ws_neighbor->fhss_data;
return &temp_entry->neigh_info_list.fhss_data;
}
static void ws_bootstrap_llc_hopping_update(struct protocol_interface_info_entry *cur, const fhss_ws_configuration_t *fhss_configuration)
{
Expand Down Expand Up @@ -2082,11 +2041,6 @@ static void ws_bootstrap_neighbor_table_clean(struct protocol_interface_info_ent
ns_list_foreach_safe(mac_neighbor_table_entry_t, cur, &mac_neighbor_info(interface)->neighbour_list) {
ws_neighbor_class_entry_t *ws_neighbor = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, cur->index);

if (cur->index == interface->ws_info->eapol_tx_index) {
//Skip EAPOL temp entries
continue;
}

if (cur->link_role == PRIORITY_PARENT_NEIGHBOUR) {
//This is our primary parent we cannot delete
continue;
Expand Down
4 changes: 0 additions & 4 deletions source/6LoWPAN/ws/ws_bootstrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ bool ws_bootstrap_validate_channel_plan(struct ws_us_ie *ws_us, struct protocol_

bool ws_bootstrap_validate_channel_function(struct ws_us_ie *ws_us, struct ws_bs_ie *ws_bs);

struct ws_neighbor_class_entry *ws_bootstrap_eapol_tx_temporary_set(struct protocol_interface_info_entry *interface, const uint8_t *src64);

void ws_bootstrap_eapol_tx_temporary_clear(struct protocol_interface_info_entry *interface);

void ws_bootstrap_neighbor_set_stable(struct protocol_interface_info_entry *interface, const uint8_t *src64);

int ws_bootstrap_stack_info_get(protocol_interface_info_entry_t *cur, struct ws_stack_info *info_ptr);
Expand Down
1 change: 0 additions & 1 deletion source/6LoWPAN/ws/ws_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ typedef struct ws_info_s {
trickle_params_t trickle_params_pan_discovery;
uint8_t rpl_state; // state from rpl_event_t
uint8_t pas_requests; // Amount of PAN solicits sent
uint8_t eapol_tx_index;
uint8_t device_min_sens; // Device min sensitivity set by the application
int8_t weakest_received_rssi; // Weakest received signal (dBm)
parent_info_t parent_info[WS_PARENT_LIST_SIZE];
Expand Down
4 changes: 4 additions & 0 deletions source/6LoWPAN/ws/ws_llc.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ bool ws_llc_eapol_relay_forward_filter(struct protocol_interface_info_entry *int

ws_neighbor_temp_class_t *ws_llc_get_multicast_temp_entry(struct protocol_interface_info_entry *interface, const uint8_t *mac64);

ws_neighbor_temp_class_t *ws_llc_get_eapol_temp_entry(struct protocol_interface_info_entry *interface, const uint8_t *mac64);



void ws_llc_free_multicast_temp_entry(struct protocol_interface_info_entry *interface, ws_neighbor_temp_class_t *neighbor);

#endif /* WS_LLC_H_ */
36 changes: 14 additions & 22 deletions source/6LoWPAN/ws/ws_llc_data_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,17 +463,12 @@ static llc_data_base_t *ws_llc_base_allocate(void)
return base;
}

static void ws_llc_mac_eapol_clear(llc_data_base_t *base, llc_message_t *message)
static void ws_llc_mac_eapol_clear(llc_data_base_t *base)
{
//Clear active EAPOL Session Count
//Clear active EAPOL Session
if (base->temp_entries->active_eapol_session) {
base->temp_entries->active_eapol_session = false;
}

if (message->eapol_temporary) {
//Clear
ws_bootstrap_eapol_tx_temporary_clear(base->interface_ptr);
}
}


Expand All @@ -495,8 +490,6 @@ static void ws_llc_mac_confirm_cb(const mac_api_t *api, const mcps_data_conf_t *
uint8_t messsage_type = message->messsage_type;
uint8_t mpx_user_handle = message->mpx_user_handle;
if (message->eapol_temporary) {
//Clear
ws_bootstrap_eapol_tx_temporary_clear(interface);

if (data->status == MLME_SUCCESS || data->status == MLME_NO_DATA) {
//Update timeout
Expand Down Expand Up @@ -1182,17 +1175,6 @@ static void ws_llc_mpx_eapol_send(llc_data_base_t *base, llc_message_t *message)
ws_neighbor_temp_class_t *temp_neigh = ws_llc_discover_temp_entry(&base->temp_entries->active_eapol_temp_neigh, message->dst_address);

if (temp_neigh) {
//Discover Free MAC &Wi-sun tx entry
ws_neighbor_class_entry_t *entry = ws_bootstrap_eapol_tx_temporary_set(base->interface_ptr, message->dst_address);
if (!entry) {
//No temp entry add to pending list
//Move to pending list
ns_list_add_to_end(&base->temp_entries->llc_eap_pending_list, message);
base->temp_entries->llc_eap_pending_list_size++;
random_early_detetction_aq_calc(base->interface_ptr->llc_eapol_random_early_detection, base->temp_entries->llc_eap_pending_list_size);
return;
}
*entry = temp_neigh->neigh_info_list;
message->eapol_temporary = true;
} else {
message->eapol_temporary = false;
Expand Down Expand Up @@ -1386,7 +1368,7 @@ static uint8_t ws_llc_mpx_data_purge_request(const mpx_api_t *api, struct mcps_p
purge_status = base->interface_ptr->mac_api->mcps_purge_req(base->interface_ptr->mac_api, &purge_req);
if (purge_status == 0) {
if (message->messsage_type == WS_FT_EAPOL) {
ws_llc_mac_eapol_clear(base, message);
ws_llc_mac_eapol_clear(base);
}
llc_message_free(message, base);
}
Expand Down Expand Up @@ -1423,7 +1405,7 @@ static void ws_llc_clean(llc_data_base_t *base)
ns_list_foreach_safe(llc_message_t, message, &base->llc_message_list) {
purge_req.msduHandle = message->msg_handle;
if (message->messsage_type == WS_FT_EAPOL) {
ws_llc_mac_eapol_clear(base, message);
ws_llc_mac_eapol_clear(base);
}
llc_message_free(message, base);
base->interface_ptr->mac_api->mcps_purge_req(base->interface_ptr->mac_api, &purge_req);
Expand Down Expand Up @@ -1500,6 +1482,16 @@ ws_neighbor_temp_class_t *ws_llc_get_multicast_temp_entry(protocol_interface_inf
return ws_llc_discover_temp_entry(&base->temp_entries->active_multicast_temp_neigh, mac64);
}

ws_neighbor_temp_class_t *ws_llc_get_eapol_temp_entry(struct protocol_interface_info_entry *interface, const uint8_t *mac64)
{
llc_data_base_t *base = ws_llc_discover_by_interface(interface);
if (!base) {
return NULL;
}

return ws_llc_discover_temp_entry(&base->temp_entries->active_eapol_temp_neigh, mac64);
}


static void ws_init_temporary_neigh_data(ws_neighbor_temp_class_t *entry, const uint8_t *mac64)
{
Expand Down
10 changes: 0 additions & 10 deletions test/nanostack/unittest/stub/ws_bootstrap_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,6 @@ bool ws_bootstrap_validate_channel_function(ws_us_ie_t *ws_us, ws_bs_ie_t *ws_bs
return true;
}

struct ws_neighbor_class_entry *ws_bootstrap_eapol_tx_temporary_set(struct protocol_interface_info_entry *interface, const uint8_t *src64)
{
return NULL;
}

void ws_bootstrap_eapol_tx_temporary_clear(struct protocol_interface_info_entry *interface)
{

}

int ws_bootstrap_stack_info_get(protocol_interface_info_entry_t *cur, struct ws_stack_info *info_ptr)
{
return 0;
Expand Down

0 comments on commit 3f7eae6

Please sign in to comment.