mesh: move mesh nettwork getter into mesh_network

This commit is contained in:
Matthias Ringwald 2018-11-28 17:27:47 +01:00
parent a0a1ee7ec3
commit c66b1ca7ce
3 changed files with 20 additions and 14 deletions

View File

@ -616,3 +616,17 @@ void mesh_set_iv_index(uint32_t iv_index){
uint32_t mesh_get_iv_index(void){
return global_iv_index;
}
// Network PDU Getter
uint16_t mesh_network_control(mesh_network_pdu_t * network_pdu){
return network_pdu->data[1] & 0x80;
}
uint8_t mesh_network_ttl(mesh_network_pdu_t * network_pdu){
return network_pdu->data[1] & 0x7f;
}
uint16_t mesh_network_src(mesh_network_pdu_t * network_pdu){
return big_endian_read_16(network_pdu->data, 5);
}
int mesh_network_segmented(mesh_network_pdu_t * network_pdu){
return network_pdu->data[9] & 0x80;
}

View File

@ -183,6 +183,12 @@ void mesh_network_setup_pdu(mesh_network_pdu_t * network_pdu, uint16_t netkey_in
*/
int mesh_network_addresses_valid(uint8_t ctl, uint16_t src, uint16_t dst);
// Mesh Network PDU Getter
uint16_t mesh_network_control(mesh_network_pdu_t * network_pdu);
uint8_t mesh_network_ttl(mesh_network_pdu_t * network_pdu);
uint16_t mesh_network_src(mesh_network_pdu_t * network_pdu);
int mesh_network_segmented(mesh_network_pdu_t * network_pdu);
// Testing only
void mesh_network_received_message(const uint8_t * pdu_data, uint8_t pdu_len);

View File

@ -416,20 +416,6 @@ static void transport_segmented_setup_device_nonce(uint8_t * nonce, const mesh_t
mesh_print_hex("DeviceNonce", nonce, 13);
}
// Network PDU Getter
static uint16_t mesh_network_control(mesh_network_pdu_t * network_pdu){
return network_pdu->data[1] & 0x80;
}
static uint8_t mesh_network_ttl(mesh_network_pdu_t * network_pdu){
return network_pdu->data[1] & 0x7f;
}
static uint16_t mesh_network_src(mesh_network_pdu_t * network_pdu){
return big_endian_read_16(network_pdu->data, 5);
}
static int mesh_network_segmented(mesh_network_pdu_t * network_pdu){
return network_pdu->data[9] & 0x80;
}
// Transport PDU Getter
static uint16_t mesh_transport_nid(mesh_transport_pdu_t * transport_pdu){
return transport_pdu->network_header[0] & 0x7f;