@@ -85,8 +85,11 @@ static uint16_t ws_bootstrap_routing_cost_calculate(protocol_interface_info_entr
85
85
static uint16_t ws_bootstrap_rank_get (protocol_interface_info_entry_t * cur );
86
86
static uint16_t ws_bootstrap_min_rank_inc_get (protocol_interface_info_entry_t * cur );
87
87
88
- static void ws_bootstrap_nw_key_insert (protocol_interface_info_entry_t * cur , uint8_t operation , uint8_t index , uint8_t * key );
88
+ static void ws_bootstrap_mac_security_enable (protocol_interface_info_entry_t * cur );
89
+ static void ws_bootstrap_nw_key_set (protocol_interface_info_entry_t * cur , uint8_t operation , uint8_t index , uint8_t * key );
90
+ static void ws_bootstrap_nw_key_clear (protocol_interface_info_entry_t * cur , uint8_t slot );
89
91
static void ws_bootstrap_nw_key_index_set (protocol_interface_info_entry_t * cur , uint8_t index );
92
+ static void ws_bootstrap_nw_frame_counter_set (protocol_interface_info_entry_t * cur , uint32_t counter );
90
93
static void ws_bootstrap_authentication_completed (protocol_interface_info_entry_t * cur , bool success );
91
94
static void ws_bootstrap_pan_version_increment (protocol_interface_info_entry_t * cur );
92
95
static ws_nud_table_entry_t * ws_nud_entry_discover (protocol_interface_info_entry_t * cur , void * neighbor );
@@ -1547,7 +1550,7 @@ int ws_bootstrap_init(int8_t interface_id, net_6lowpan_mode_e bootstrap_mode)
1547
1550
ret_val = -4 ;
1548
1551
goto init_fail ;
1549
1552
}
1550
- if (ws_pae_controller_cb_register (cur , & ws_bootstrap_authentication_completed , & ws_bootstrap_nw_key_insert , & ws_bootstrap_nw_key_index_set , & ws_bootstrap_pan_version_increment ) < 0 ) {
1553
+ if (ws_pae_controller_cb_register (cur , & ws_bootstrap_authentication_completed , & ws_bootstrap_nw_key_set , & ws_bootstrap_nw_key_clear , & ws_bootstrap_nw_key_index_set , & ws_bootstrap_nw_frame_counter_set , & ws_bootstrap_pan_version_increment ) < 0 ) {
1551
1554
ret_val = -4 ;
1552
1555
goto init_fail ;
1553
1556
}
@@ -1692,6 +1695,7 @@ static void ws_bootstrap_fhss_activate(protocol_interface_info_entry_t *cur)
1692
1695
tr_debug ("MAC init" );
1693
1696
mac_helper_pib_boolean_set (cur , macRxOnWhenIdle , true);
1694
1697
cur -> lowpan_info &= ~INTERFACE_NWK_CONF_MAC_RX_OFF_IDLE ;
1698
+ ws_bootstrap_mac_security_enable (cur );
1695
1699
ws_bootstrap_mac_activate (cur , cur -> ws_info -> fhss_uc_fixed_channel , cur -> ws_info -> network_pan_id , true);
1696
1700
return ;
1697
1701
}
@@ -1987,33 +1991,34 @@ static void ws_bootstrap_start_authentication(protocol_interface_info_entry_t *c
1987
1991
ws_pae_controller_authenticate (cur );
1988
1992
}
1989
1993
1990
- static void ws_bootstrap_nw_key_insert (protocol_interface_info_entry_t * cur , uint8_t operation , uint8_t index , uint8_t * key )
1994
+ static void ws_bootstrap_mac_security_enable (protocol_interface_info_entry_t * cur )
1991
1995
{
1992
- switch (operation ) {
1993
- case 0 :
1994
- mac_helper_security_key_clean (cur );
1995
- mac_helper_default_security_level_set (cur , AES_SECURITY_LEVEL_ENC_MIC64 );
1996
- mac_helper_default_security_key_id_mode_set (cur , MAC_KEY_ID_MODE_IDX );
1997
- break ;
1998
- case 1 :
1999
- mac_helper_security_default_recv_key_set (cur , key , index + 1 , MAC_KEY_ID_MODE_IDX );
2000
- break ;
2001
- case 2 :
2002
- mac_helper_security_prev_key_set (cur , key , index + 1 , MAC_KEY_ID_MODE_IDX );
2003
- break ;
2004
- case 3 :
2005
- mac_helper_security_next_key_set (cur , key , index + 1 , MAC_KEY_ID_MODE_IDX );
2006
- break ;
2007
- default :
2008
- break ;
2009
- }
1996
+ mac_helper_default_security_level_set (cur , AES_SECURITY_LEVEL_ENC_MIC64 );
1997
+ mac_helper_default_security_key_id_mode_set (cur , MAC_KEY_ID_MODE_IDX );
1998
+ }
1999
+
2000
+ static void ws_bootstrap_nw_key_set (protocol_interface_info_entry_t * cur , uint8_t slot , uint8_t index , uint8_t * key )
2001
+ {
2002
+ mac_helper_security_key_to_descriptor_set (cur , key , index + 1 , slot );
2003
+ }
2004
+
2005
+ static void ws_bootstrap_nw_key_clear (protocol_interface_info_entry_t * cur , uint8_t slot )
2006
+ {
2007
+ mac_helper_security_key_descriptor_clear (cur , slot );
2010
2008
}
2011
2009
2012
2010
static void ws_bootstrap_nw_key_index_set (protocol_interface_info_entry_t * cur , uint8_t index )
2013
2011
{
2012
+ // Set send key
2014
2013
mac_helper_security_auto_request_key_index_set (cur , index + 1 );
2015
2014
}
2016
2015
2016
+ static void ws_bootstrap_nw_frame_counter_set (protocol_interface_info_entry_t * cur , uint32_t counter )
2017
+ {
2018
+ // Set frame counter
2019
+ mac_helper_link_frame_counter_set (cur -> id , counter );
2020
+ }
2021
+
2017
2022
static void ws_bootstrap_authentication_completed (protocol_interface_info_entry_t * cur , bool success )
2018
2023
{
2019
2024
if (success ) {
0 commit comments