mesh: store pseudo_dst in dst for access pdu to virtual address

This commit is contained in:
Matthias Ringwald 2019-01-15 16:45:50 +01:00
parent 92a8bb0a3d
commit 8fb1156553
2 changed files with 15 additions and 5 deletions

View File

@ -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);

View File

@ -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));