Skip to content

Commit

Permalink
Corrected PAE controller stop
Browse files Browse the repository at this point in the history
  • Loading branch information
Mika Leppänen committed Feb 27, 2019
1 parent ac2425c commit 5a42e88
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions source/6LoWPAN/ws/ws_pae_controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ static int8_t ws_pae_controller_nw_key_check_and_insert(protocol_interface_info_
static int8_t ws_pae_controller_gak_from_gtk(uint8_t *gak, uint8_t *gtk, char *network_name);
static void ws_pae_controller_nw_key_index_check_and_set(protocol_interface_info_entry_t *interface_ptr, uint8_t index);
static int8_t ws_pae_controller_free_slot_find(nw_key_t *nw_key);
static void ws_pae_controller_data_init(pae_controller_t *controller);

static NS_LIST_DEFINE(pae_controller_list, pae_controller_t, link);

Expand Down Expand Up @@ -447,16 +448,26 @@ int8_t ws_pae_controller_init(protocol_interface_info_entry_t *interface_ptr)
return -1;
}

memset(controller->target_eui_64, 0, 8);
memset(controller->br_eui_64, 0, 8);
memset(controller->gtkhash, 0, 32);
memset(controller->nw_key, 0, sizeof(controller->nw_key));
controller->target_pan_id = 0xffff;
controller->interface_ptr = interface_ptr;
controller->auth_completed = NULL;
controller->nw_key_insert = NULL;
controller->nw_send_key_index_set = NULL;
controller->pan_ver_increment = NULL;

ws_pae_controller_data_init(controller);

ns_list_add_to_end(&pae_controller_list, controller);

return 0;
}

static void ws_pae_controller_data_init(pae_controller_t *controller)
{
memset(controller->target_eui_64, 0, 8);
memset(controller->br_eui_64, 0, 8);
memset(controller->gtkhash, 0, 32);
memset(controller->nw_key, 0, sizeof(controller->nw_key));
controller->target_pan_id = 0xffff;
controller->pae_delete = NULL;
controller->pae_fast_timer = NULL;
controller->pae_slow_timer = NULL;
Expand All @@ -475,10 +486,6 @@ int8_t ws_pae_controller_init(protocol_interface_info_entry_t *interface_ptr)
sec_prot_keys_gtks_init(&controller->next_gtks);
sec_prot_certs_init(&controller->certs);
ws_pae_timers_settings_init(&controller->timer_settings);

ns_list_add_to_end(&pae_controller_list, controller);

return 0;
}

int8_t ws_pae_controller_supp_init(protocol_interface_info_entry_t *interface_ptr)
Expand Down Expand Up @@ -536,6 +543,12 @@ int8_t ws_pae_controller_stop(protocol_interface_info_entry_t *interface_ptr)
controller->pae_delete(interface_ptr);
}

// Free data
sec_prot_certs_delete(&controller->certs);

// Init controller data
ws_pae_controller_data_init(controller);

return 0;
}

Expand All @@ -553,9 +566,6 @@ int8_t ws_pae_controller_delete(protocol_interface_info_entry_t *interface_ptr)
}

ns_list_remove(&pae_controller_list, controller);

sec_prot_certs_delete(&controller->certs);

ns_dyn_mem_free(controller);

return 0;
Expand Down

0 comments on commit 5a42e88

Please sign in to comment.