@@ -1465,8 +1465,13 @@ static void ws_bootstrap_asynch_ind(struct protocol_interface_info_entry *cur, c
1465
1465
static void ws_bootstrap_asynch_confirm (struct protocol_interface_info_entry * interface , uint8_t asynch_message )
1466
1466
{
1467
1467
ws_stats_update (interface , STATS_WS_ASYNCH_TX , 1 );
1468
- (void )interface ;
1469
- (void )asynch_message ;
1468
+ if (interface -> bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER ) {
1469
+ if (asynch_message == WS_FT_PAN_CONF && interface -> ws_info -> pending_key_index_info .state == PENDING_KEY_INDEX_ACTIVATE ) {
1470
+ interface -> ws_info -> pending_key_index_info .state = NO_PENDING_PROCESS ;
1471
+ tr_info ("Activate new default key %u" , interface -> ws_info -> pending_key_index_info .index + 1 );
1472
+ mac_helper_security_auto_request_key_index_set (interface , interface -> ws_info -> pending_key_index_info .index , interface -> ws_info -> pending_key_index_info .index + 1 );
1473
+ }
1474
+ }
1470
1475
}
1471
1476
1472
1477
uint32_t ws_time_from_last_unicast_traffic (uint32_t current_time_stamp , ws_neighbor_class_entry_t * ws_neighbor )
@@ -2410,7 +2415,16 @@ static void ws_bootstrap_nw_key_clear(protocol_interface_info_entry_t *cur, uint
2410
2415
2411
2416
static void ws_bootstrap_nw_key_index_set (protocol_interface_info_entry_t * cur , uint8_t index )
2412
2417
{
2413
- // Set send key
2418
+
2419
+ if (cur -> bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER ) {
2420
+ if (cur -> mac_parameters -> mac_default_key_index != 0 && cur -> mac_parameters -> mac_default_key_index != index + 1 ) {
2421
+ tr_info ("New Pending key Request %u" , index + 1 );
2422
+ cur -> ws_info -> pending_key_index_info .state = PENDING_KEY_INDEX_ADVERTISMENT ;
2423
+ cur -> ws_info -> pending_key_index_info .index = index ;
2424
+ return ;
2425
+ }
2426
+ }
2427
+
2414
2428
mac_helper_security_auto_request_key_index_set (cur , index , index + 1 );
2415
2429
}
2416
2430
@@ -2660,7 +2674,13 @@ static void ws_bootstrap_pan_config(protocol_interface_info_entry_t *cur)
2660
2674
2661
2675
async_req .security .SecurityLevel = mac_helper_default_security_level_get (cur );
2662
2676
async_req .security .KeyIdMode = mac_helper_default_security_key_id_mode_get (cur );
2663
- async_req .security .KeyIndex = mac_helper_default_key_index_get (cur );
2677
+ if (cur -> bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER && cur -> ws_info -> pending_key_index_info .state == PENDING_KEY_INDEX_ADVERTISMENT ) {
2678
+ async_req .security .KeyIndex = cur -> ws_info -> pending_key_index_info .index + 1 ;
2679
+ cur -> ws_info -> pending_key_index_info .state = PENDING_KEY_INDEX_ACTIVATE ;
2680
+ } else {
2681
+ async_req .security .KeyIndex = mac_helper_default_key_index_get (cur );
2682
+ }
2683
+
2664
2684
ws_llc_asynch_request (cur , & async_req );
2665
2685
}
2666
2686
@@ -2680,6 +2700,11 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
2680
2700
break ;
2681
2701
case WS_DISCOVERY_START :
2682
2702
tr_info ("Discovery start" );
2703
+
2704
+ //Clear Pending Key Index State
2705
+ cur -> ws_info -> pending_key_index_info .state = NO_PENDING_PROCESS ;
2706
+ cur -> mac_parameters -> mac_default_key_index = 0 ;
2707
+
2683
2708
// All trickle timers stopped to allow entry from any state
2684
2709
cur -> ws_info -> trickle_pa_running = false;
2685
2710
cur -> ws_info -> trickle_pc_running = false;
0 commit comments