mesh: use proxy_configuration_message instead of proxy_message

This commit is contained in:
Matthias Ringwald 2019-06-27 14:33:21 +02:00
parent bd9002edc0
commit fd7ffe0047
4 changed files with 16 additions and 14 deletions

View File

@ -322,7 +322,7 @@ static void mesh_network_send_a(mesh_network_pdu_t * network_pdu){
}
// get network nonce
if (network_pdu->flags & MESH_NETWORK_PDU_FLAGS_PROXY_MESSAGE){
if (network_pdu->flags & MESH_NETWORK_PDU_FLAGS_PROXY_CONFIGURATION){
mesh_proxy_create_nonce(network_nonce, network_pdu, global_iv_index);
#ifdef LOG_NETWORK
printf("TX-ProxyNonce: ");
@ -431,7 +431,7 @@ static void process_network_pdu_validate_d(void * arg){
// set netkey_index
network_pdu->netkey_index = current_network_key->netkey_index;
if (network_pdu->flags & MESH_NETWORK_PDU_FLAGS_PROXY_MESSAGE){
if (network_pdu->flags & MESH_NETWORK_PDU_FLAGS_PROXY_CONFIGURATION){
// no additional checks for proxy messages
(*mesh_network_proxy_message_handler)(MESH_NETWORK_PDU_RECEIVED, network_pdu);
@ -504,7 +504,7 @@ static void process_network_pdu_validate_b(void * arg){
uint32_t iv_index = iv_index_for_pdu(network_pdu);
if (network_pdu->flags & MESH_NETWORK_PDU_FLAGS_PROXY_MESSAGE){
if (network_pdu->flags & MESH_NETWORK_PDU_FLAGS_PROXY_CONFIGURATION){
// create network nonce
mesh_proxy_create_nonce(network_nonce, network_pdu, iv_index);
#ifdef LOG_NETWORK
@ -780,7 +780,7 @@ void mesh_network_received_message(const uint8_t * pdu_data, uint8_t pdu_len){
}
void mesh_network_process_proxy_message(const uint8_t * pdu_data, uint8_t pdu_len){
void mesh_network_process_proxy_configuration_message(const uint8_t * pdu_data, uint8_t pdu_len){
// verify len
if (pdu_len > 29) return;
@ -791,7 +791,7 @@ void mesh_network_process_proxy_message(const uint8_t * pdu_data, uint8_t pdu_le
// store data
memcpy(network_pdu->data, pdu_data, pdu_len);
network_pdu->len = pdu_len;
network_pdu->flags = MESH_NETWORK_PDU_FLAGS_PROXY_MESSAGE; // Network PDU
network_pdu->flags = MESH_NETWORK_PDU_FLAGS_PROXY_CONFIGURATION; // Network PDU
// add to list and go
btstack_linked_list_add_tail(&network_pdus_received, (btstack_linked_item_t *) network_pdu);
@ -820,13 +820,13 @@ void mesh_network_send_pdu(mesh_network_pdu_t * network_pdu){
mesh_network_run();
}
void mesh_network_encrypt_proxy_message(mesh_network_pdu_t * network_pdu, void (* callback)(mesh_network_pdu_t * callback)){
void mesh_network_encrypt_proxy_configuration_message(mesh_network_pdu_t * network_pdu, void (* callback)(mesh_network_pdu_t * callback)){
printf("ProxyPDU(unencrypted): ");
printf_hexdump(network_pdu->data, network_pdu->len);
// setup callback
network_pdu->callback = callback;
network_pdu->flags = MESH_NETWORK_PDU_FLAGS_PROXY_MESSAGE;
network_pdu->flags = MESH_NETWORK_PDU_FLAGS_PROXY_CONFIGURATION;
// queue up
btstack_linked_list_add_tail(&network_pdus_queued, (btstack_linked_item_t *) network_pdu);

View File

@ -74,7 +74,9 @@ typedef struct mesh_pdu {
mesh_pdu_type_t pdu_type;
} mesh_pdu_t;
#define MESH_NETWORK_PDU_FLAGS_PROXY_MESSAGE 1
//
#define MESH_NETWORK_PDU_FLAGS_PROXY_CONFIGURATION 1
#define MESH_NETWORK_PDU_FLAGS_GATT_BEARER 2
typedef struct mesh_network_pdu {
mesh_pdu_t pdu_header;
@ -266,8 +268,8 @@ uint32_t mesh_get_iv_index(void);
// Testing only
void mesh_network_received_message(const uint8_t * pdu_data, uint8_t pdu_len);
void mesh_network_process_proxy_message(const uint8_t * pdu_data, uint8_t pdu_len);
void mesh_network_encrypt_proxy_message(mesh_network_pdu_t * network_pdu, void (* callback)(mesh_network_pdu_t * callback));
void mesh_network_process_proxy_configuration_message(const uint8_t * pdu_data, uint8_t pdu_len);
void mesh_network_encrypt_proxy_configuration_message(mesh_network_pdu_t * network_pdu, void (* callback)(mesh_network_pdu_t * callback));
void mesh_network_dump(void);
void mesh_network_reset(void);

View File

@ -846,7 +846,7 @@ static void packet_handler_for_mesh_proxy_configuration(uint8_t packet_type, uin
case MESH_PROXY_DATA_PACKET:
printf("Received proxy configuration\n");
printf_hexdump(packet, size);
mesh_network_process_proxy_message(packet, size);
mesh_network_process_proxy_configuration_message(packet, size);
break;
case HCI_EVENT_PACKET:
switch (hci_event_packet_get_type(packet)){
@ -926,7 +926,7 @@ void proxy_configuration_message_handler(mesh_network_callback_type_t callback_t
big_endian_store_16(data, pos, proxy_configuration_filter_list_len);
mesh_network_setup_pdu(network_pdu, netkey_index, nid, ctl, ttl, seq, src, dest, data, sizeof(data));
mesh_network_encrypt_proxy_message(network_pdu, &request_can_send_now_proxy_configuration_callback_handler);
mesh_network_encrypt_proxy_configuration_message(network_pdu, &request_can_send_now_proxy_configuration_callback_handler);
// received_network_pdu is processed
btstack_memory_mesh_network_pdu_free(received_network_pdu);

View File

@ -1029,7 +1029,7 @@ TEST(MessageTest, ProxyConfigReceive){
char ** network_pdus = proxy_config_pdus;
test_network_pdu_len = strlen(network_pdus[i]) / 2;
btstack_parse_hex(network_pdus[i], test_network_pdu_len, test_network_pdu_data);
mesh_network_process_proxy_message(&test_network_pdu_data[1], test_network_pdu_len-1);
mesh_network_process_proxy_configuration_message(&test_network_pdu_data[1], test_network_pdu_len-1);
while (received_proxy_pdu == NULL) {
mock_process_hci_cmd();
}
@ -1068,7 +1068,7 @@ TEST(MessageTest, ProxyConfigSend){
mesh_network_pdu_t * network_pdu = mesh_network_pdu_get();
uint8_t data[] = { 0 , 0 };
mesh_network_setup_pdu(network_pdu, netkey_index, nid, ctl, ttl, seq, src, dest, data, sizeof(data));
mesh_network_encrypt_proxy_message(network_pdu, &test_proxy_callback_handler);
mesh_network_encrypt_proxy_configuration_message(network_pdu, &test_proxy_callback_handler);
while (received_proxy_pdu == NULL) {
mock_process_hci_cmd();
}