Skip to content

Commit c9e3d8e

Browse files
author
Juha Heiskanen
committed
Interface down update
6lowpan, Thread and wi-sun interface down now call MLME_RESET(true) which disable, reset and free MAC memory before MAC user start clean own data. Change-Id: I4032aca35ce2d21646219853f459118976314b30
1 parent 1f77ad6 commit c9e3d8e

File tree

6 files changed

+27
-10
lines changed

6 files changed

+27
-10
lines changed

source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan_bootstrap.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,6 +1379,8 @@ static int8_t arm_6lowpan_bootstrap_down(protocol_interface_info_entry_t *cur)
13791379
}
13801380
cur->if_lowpan_security_params->mle_security_frame_counter = mle_service_security_get_frame_counter(cur->id);
13811381
mle_service_interface_receiver_handler_update(cur->id, mle_6lowpan_message_handler);
1382+
// Reset MAC for safe upper layer memory free
1383+
protocol_mac_reset(cur);
13821384
return nwk_6lowpan_down(cur);
13831385
}
13841386
#ifdef HAVE_6LOWPAN_ND

source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan_interface.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@
7272
#include "6LoWPAN/Fragmentation/cipv6_fragmenter.h"
7373
#include "libNET/src/net_load_balance_internal.h"
7474

75+
void protocol_mac_reset(protocol_interface_info_entry_t *cur)
76+
{
77+
if (cur->mac_api) {
78+
mlme_reset_t reset;
79+
reset.SetDefaultPIB = true;
80+
cur->mac_api->mlme_req(cur->mac_api, MLME_RESET, &reset);
81+
}
82+
}
83+
7584

7685

7786
static int8_t set_6lowpan_nwk_down(protocol_interface_info_entry_t *cur)
@@ -96,15 +105,11 @@ static int8_t set_6lowpan_nwk_down(protocol_interface_info_entry_t *cur)
96105
}
97106

98107
if (cur->interface_mode == INTERFACE_UP) {
99-
if (cur->mac_api) {
100-
mlme_reset_t reset;
101-
reset.SetDefaultPIB = true;
102-
cur->mac_parameters->pan_id = 0xffff;
103-
cur->mac_parameters->SecurityEnabled = false;
104-
cur->mac_parameters->security_frame_counter = 0;
105-
cur->mac_parameters->mac_security_level = 0;
106-
cur->mac_api->mlme_req(cur->mac_api, MLME_RESET, &reset);
107-
}
108+
cur->mac_parameters->pan_id = 0xffff;
109+
cur->mac_parameters->SecurityEnabled = false;
110+
cur->mac_parameters->security_frame_counter = 0;
111+
cur->mac_parameters->mac_security_level = 0;
112+
protocol_mac_reset(cur);
108113
cur->interface_mode = INTERFACE_IDLE;
109114
net_load_balance_internal_state_activate(cur, false);
110115
}

source/6LoWPAN/Bootstraps/protocol_6lowpan_interface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,7 @@ extern int8_t nwk_6lowpan_up(struct protocol_interface_info_entry *cur);
3131
*/
3232
extern int8_t nwk_6lowpan_down(struct protocol_interface_info_entry *cur);
3333

34+
extern void protocol_mac_reset(struct protocol_interface_info_entry *cur);
35+
3436

3537
#endif /* PROTOCOL_6LOWPAN_INTERFACE_H_ */

source/6LoWPAN/Thread/thread_common.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ int8_t thread_bootstrap_down(protocol_interface_info_entry_t *cur)
240240
tr_debug("SET thread Idle");
241241
//stop polling
242242
mac_data_poll_disable(cur);
243+
// Reset MAC for safe upper layer memory free
244+
protocol_mac_reset(cur);
243245
//Clean mle table
244246
thread_neighbor_list_clean(cur);
245247
// store frame counters

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,8 @@ static int8_t ws_bootstrap_down(protocol_interface_info_entry_t *cur)
808808
}
809809

810810
tr_info("Wi-SUN ifdown");
811-
811+
// Reset MAC for safe upper layer memory free
812+
protocol_mac_reset(cur);
812813
// Reset WS information
813814
// ws_common_reset(cur)
814815
ws_llc_reset(cur);

test/nanostack/unittest/stub/protocol_6lowpan_interface_stub.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,8 @@ int8_t nwk_6lowpan_down(protocol_interface_info_entry_t *cur)
7575
{
7676
return 0;
7777
}
78+
79+
void protocol_mac_reset(struct protocol_interface_info_entry *cur)
80+
{
81+
82+
}

0 commit comments

Comments
 (0)