From 8fb115655314433aa1b4389f4d2242d3b504d5b5 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Tue, 15 Jan 2019 16:45:50 +0100 Subject: [PATCH] mesh: store pseudo_dst in dst for access pdu to virtual address --- test/mesh/mesh_transport.c | 18 +++++++++++++++--- test/mesh/mesh_transport.h | 2 -- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/test/mesh/mesh_transport.c b/test/mesh/mesh_transport.c index 774ac52db..2c72feb44 100644 --- a/test/mesh/mesh_transport.c +++ b/test/mesh/mesh_transport.c @@ -59,6 +59,7 @@ static void mesh_print_hex(const char * name, const uint8_t * data, uint16_t len typedef struct { uint8_t label_uuid[16]; + uint16_t pseudo_dst; uint16_t dst; uint8_t akf; uint8_t aid; @@ -139,9 +140,9 @@ static const mesh_transport_key_t * mesh_transport_key_get(uint16_t appkey_index // mesh network key iterator static void mesh_transport_key_iterator_init(mesh_transport_key_iterator_t * it, uint16_t dst, uint8_t akf, uint8_t aid){ it->dst = dst; - it->aid = aid; - it->akf = akf; - it->first = 1; + it->aid = aid; + it->akf = akf; + it->first = 1; } static int mesh_transport_key_iterator_has_more(mesh_transport_key_iterator_t * it){ @@ -158,6 +159,7 @@ static const mesh_transport_key_t * mesh_transport_key_iterator_get_next(mesh_tr it->first = 0; if (mesh_network_address_virtual(it->dst)){ memcpy(it->label_uuid, test_virtual_address.label_uuid, 16); + it->pseudo_dst = test_virtual_address.pseudo_dst; } if (it->akf){ return &test_application_key; @@ -401,6 +403,11 @@ static void mesh_upper_transport_validate_unsegmented_message_ccm(void * arg){ // remove TransMIC from payload network_pdu->len -= trans_mic_len; + // if virtual address, update dst to pseudo_dst + if (mesh_network_address_virtual(mesh_network_dst(network_pdu))){ + big_endian_store_16(network_pdu->data, 7, mesh_transport_key_it.pseudo_dst); + } + // pass to upper layer if (mesh_access_unsegmented_handler){ mesh_access_unsegmented_handler(network_pdu); @@ -444,6 +451,11 @@ static void mesh_upper_transport_validate_segmented_message_ccm(void * arg){ // remove TransMIC from payload transport_pdu->len -= transport_pdu->transmic_len; + // if virtual address, update dst to pseudo_dst + if (mesh_network_address_virtual(mesh_transport_dst(transport_pdu))){ + big_endian_store_16(transport_pdu->network_header, 7, mesh_transport_key_it.pseudo_dst); + } + // pass to upper layer if (mesh_access_segmented_handler){ mesh_access_segmented_handler(transport_pdu); diff --git a/test/mesh/mesh_transport.h b/test/mesh/mesh_transport.h index 368511379..e4390242c 100644 --- a/test/mesh/mesh_transport.h +++ b/test/mesh/mesh_transport.h @@ -61,8 +61,6 @@ void mesh_transport_set_device_key(const uint8_t * device_key); void mesh_application_key_set(uint16_t appkey_index, uint8_t aid, const uint8_t * application_key); -void mesh_virtual_address_set(uint16_t hash, const uint8_t * label_uuid); - void mesh_upper_transport_register_unsegemented_message_handler(void (*callback)(mesh_network_pdu_t * network_pdu)); void mesh_upper_transport_register_segemented_message_handler(void (*callback)(mesh_transport_pdu_t * transport_pdu));