mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-29 22:20:37 +00:00
mesh: transition norml -> iv update active -> normal via secure network beacons
This commit is contained in:
parent
d075c32206
commit
5d8695d635
@ -994,6 +994,12 @@ void mesh_trigger_iv_update(void){
|
||||
global_iv_index++;
|
||||
}
|
||||
|
||||
void mesh_iv_update_completed(void){
|
||||
if (!global_iv_update_active) return;
|
||||
// set Normal mode
|
||||
global_iv_update_active = 0;
|
||||
}
|
||||
|
||||
// Network PDU Getter
|
||||
uint8_t mesh_network_nid(mesh_network_pdu_t * network_pdu){
|
||||
return network_pdu->data[0] & 0x7f;
|
||||
|
@ -379,6 +379,7 @@ uint32_t mesh_get_iv_index_for_tx(void);
|
||||
|
||||
int mesh_iv_update_active(void);
|
||||
void mesh_trigger_iv_update(void);
|
||||
void mesh_iv_update_completed(void);
|
||||
|
||||
// Testing only
|
||||
void mesh_network_received_message(const uint8_t * pdu_data, uint8_t pdu_len, uint8_t flags);
|
||||
|
@ -1404,10 +1404,12 @@ static void mesh_access_secure_network_beacon_handler(uint8_t packet_type, uint1
|
||||
}
|
||||
if (subnet == NULL) return;
|
||||
|
||||
uint8_t flags = packet[1];
|
||||
|
||||
// Key refresh via secure network beacons that are authenticated with new netkey
|
||||
if (new_key){
|
||||
// either first or second phase (in phase 0, new key is not set)
|
||||
int key_refresh_flag = packet[1] & 1;
|
||||
int key_refresh_flag = flags & 1;
|
||||
if (key_refresh_flag){
|
||||
// transition to phase 3 from either phase 1 or 2
|
||||
switch (subnet->key_refresh){
|
||||
@ -1432,5 +1434,19 @@ static void mesh_access_secure_network_beacon_handler(uint8_t packet_type, uint1
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: IV Update
|
||||
// IV Update
|
||||
|
||||
// TODO: validate IV index w.r.t. local index
|
||||
|
||||
int iv_update_active_flag = flags & 2;
|
||||
|
||||
if (mesh_iv_update_active()){
|
||||
if (iv_update_active_flag){
|
||||
mesh_trigger_iv_update();
|
||||
}
|
||||
} else {
|
||||
if (iv_update_active_flag == 0){
|
||||
mesh_iv_update_completed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user