From 5a42e88ed3840ac0643e09210703f17822c2bd3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=20Lepp=C3=A4nen?= Date: Wed, 27 Feb 2019 09:10:52 +0200 Subject: [PATCH] Corrected PAE controller stop --- source/6LoWPAN/ws/ws_pae_controller.c | 34 +++++++++++++++++---------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/source/6LoWPAN/ws/ws_pae_controller.c b/source/6LoWPAN/ws/ws_pae_controller.c index 886c343f15a..72e5aa8d5b1 100644 --- a/source/6LoWPAN/ws/ws_pae_controller.c +++ b/source/6LoWPAN/ws/ws_pae_controller.c @@ -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); @@ -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; @@ -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) @@ -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; } @@ -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;