mesh: mesh_subnet_get_outgoing_network_key picks outgoing network key

This commit is contained in:
Matthias Ringwald 2019-07-02 18:19:49 +02:00
parent 2b7de14bb0
commit d134d597d2

View File

@ -133,6 +133,7 @@ static int mesh_network_cache_index;
static void mesh_network_run(void);
static void process_network_pdu_validate(mesh_network_pdu_t * network_pdu);
static mesh_network_key_t * mesh_subnet_get_outgoing_network_key(mesh_subnet_t * subnet);
// network caching
static uint32_t mesh_network_cache_hash(mesh_network_pdu_t * network_pdu){
@ -313,9 +314,9 @@ static void mesh_network_send_a(mesh_network_pdu_t * network_pdu){
mesh_crypto_active = 1;
// lookup network by netkey_index
current_network_key = mesh_network_key_list_get(network_pdu->netkey_index);
if (!current_network_key) {
// lookup subnet by netkey_index
mesh_subnet_t * subnet = mesh_subnet_get_by_netkey_index(network_pdu->netkey_index);
if (!subnet) {
mesh_crypto_active = 0;
// notify upper layer
(*mesh_network_higher_layer_handler)(MESH_NETWORK_PDU_SENT, network_pdu);
@ -324,6 +325,9 @@ static void mesh_network_send_a(mesh_network_pdu_t * network_pdu){
return;
}
// get network key to use for sending
current_network_key = mesh_subnet_get_outgoing_network_key(subnet);
// get network nonce
if (network_pdu->flags & MESH_NETWORK_PDU_FLAGS_PROXY_CONFIGURATION){
mesh_proxy_create_nonce(network_nonce, network_pdu, global_iv_index);
@ -1081,6 +1085,11 @@ mesh_subnet_t * mesh_subnet_iterator_get_next(mesh_subnet_iterator_t *it){
return (mesh_subnet_t *) btstack_linked_list_iterator_next(&it->it);
}
static mesh_network_key_t * mesh_subnet_get_outgoing_network_key(mesh_subnet_t * subnet){
// TODO: old vs. new depends on key resfresh
return subnet->old_key;
}
/**
* @brief Update subnet for given netkey index
*/