mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-27 06:35:20 +00:00
mesh: rename sequence number functions mesh_sequence_number_x
This commit is contained in:
parent
04875b115d
commit
6e131f4b89
@ -190,7 +190,7 @@ static void mesh_lower_transport_send_ack(uint16_t netkey_index, uint8_t ttl, ui
|
||||
if (!network_pdu) return;
|
||||
|
||||
// setup network_pdu
|
||||
mesh_network_setup_pdu(network_pdu, netkey_index, network_key->nid, 1, ttl, mesh_lower_transport_next_seq(), primary_element_address, dest, ack_msg, sizeof(ack_msg));
|
||||
mesh_network_setup_pdu(network_pdu, netkey_index, network_key->nid, 1, ttl, mesh_sequence_number_next(), primary_element_address, dest, ack_msg, sizeof(ack_msg));
|
||||
|
||||
// send network_pdu
|
||||
mesh_network_send_pdu(network_pdu);
|
||||
@ -473,7 +473,7 @@ static void mesh_lower_transport_setup_segment(mesh_transport_pdu_t *transport_p
|
||||
int ctl = mesh_transport_ctl(transport_pdu);
|
||||
uint16_t max_segment_len = ctl ? 8 : 12; // control 8 bytes (64 bit NetMic), access 12 bytes (32 bit NetMIC)
|
||||
|
||||
uint32_t seq = mesh_lower_transport_next_seq();
|
||||
uint32_t seq = mesh_sequence_number_next();
|
||||
uint16_t seq_zero = mesh_transport_seq(transport_pdu) & 0x01fff;
|
||||
uint8_t seg_n = (transport_pdu->len - 1) / max_segment_len;
|
||||
uint8_t szmic = ((!ctl) && (transport_pdu->transmic_len == 8)) ? 1 : 0; // only 1 for access messages with 64 bit TransMIC
|
||||
|
@ -569,7 +569,7 @@ static uint8_t mesh_upper_transport_setup_unsegmented_control_pdu(mesh_network_p
|
||||
|
||||
mesh_print_hex("LowerTransportPDU", transport_pdu_data, transport_pdu_len);
|
||||
// setup network_pdu
|
||||
mesh_network_setup_pdu(network_pdu, netkey_index, network_key->nid, 1, ttl, mesh_lower_transport_next_seq(), src, dest, transport_pdu_data, transport_pdu_len);
|
||||
mesh_network_setup_pdu(network_pdu, netkey_index, network_key->nid, 1, ttl, mesh_sequence_number_next(), src, dest, transport_pdu_data, transport_pdu_len);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -585,7 +585,7 @@ static uint8_t mesh_upper_transport_setup_segmented_control_pdu(mesh_transport_p
|
||||
const mesh_network_key_t * network_key = mesh_network_key_list_get(netkey_index);
|
||||
if (!network_key) return 1;
|
||||
|
||||
uint32_t seq = mesh_lower_transport_peek_seq();
|
||||
uint32_t seq = mesh_sequence_number_peek();
|
||||
|
||||
memcpy(transport_pdu->data, control_pdu_data, control_pdu_len);
|
||||
transport_pdu->len = control_pdu_len;
|
||||
@ -631,7 +631,7 @@ static uint8_t mesh_upper_transport_setup_unsegmented_access_pdu_header(mesh_net
|
||||
|
||||
network_pdu->data[9] = akf_aid;
|
||||
// setup network_pdu
|
||||
mesh_network_setup_pdu_header(network_pdu, netkey_index, network_key->nid, 0, ttl, mesh_lower_transport_next_seq(), src, dest);
|
||||
mesh_network_setup_pdu_header(network_pdu, netkey_index, network_key->nid, 0, ttl, mesh_sequence_number_next(), src, dest);
|
||||
network_pdu->appkey_index = appkey_index;
|
||||
return 0;
|
||||
}
|
||||
@ -653,7 +653,7 @@ static uint8_t mesh_upper_transport_setup_unsegmented_access_pdu(mesh_network_pd
|
||||
|
||||
static uint8_t mesh_upper_transport_setup_segmented_access_pdu_header(mesh_transport_pdu_t * transport_pdu, uint16_t netkey_index, uint16_t appkey_index, uint8_t ttl, uint16_t src, uint16_t dest,
|
||||
uint8_t szmic){
|
||||
uint32_t seq = mesh_lower_transport_peek_seq();
|
||||
uint32_t seq = mesh_sequence_number_peek();
|
||||
|
||||
printf("[+] Upper transport, setup segmented Access PDU - seq %06x, szmic %u, iv_index %08x\n", seq, szmic,
|
||||
mesh_get_iv_index_for_tx());
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include "btstack_debug.h"
|
||||
#include "mesh_foundation.h"
|
||||
#include "btstack_tlv.h"
|
||||
#include "mesh_iv_index_seq_number.h"
|
||||
|
||||
#define MEST_TRANSACTION_TIMEOUT_MS 6000
|
||||
|
||||
@ -1378,7 +1379,7 @@ void mesh_store_iv_index_and_sequence_number(void){
|
||||
mesh_access_setup_tlv();
|
||||
uint32_t tag = mesh_tag_for_iv_index_and_seq_number();
|
||||
data.iv_index = mesh_get_iv_index();
|
||||
data.seq_number = mesh_lower_transport_peek_seq();
|
||||
data.seq_number = mesh_sequence_number_peek();
|
||||
btstack_tlv_singleton_impl->get_tag(btstack_tlv_singleton_context, tag, (uint8_t *) &data, sizeof(data));
|
||||
}
|
||||
void mesh_load_iv_index_and_sequence_number(void){
|
||||
@ -1387,7 +1388,7 @@ void mesh_load_iv_index_and_sequence_number(void){
|
||||
uint32_t tag = mesh_tag_for_iv_index_and_seq_number();
|
||||
btstack_tlv_singleton_impl->store_tag(btstack_tlv_singleton_context, tag, (uint8_t *) &data, sizeof(data));
|
||||
mesh_set_iv_index(data.iv_index);
|
||||
mesh_lower_transport_set_seq(data.seq_number);
|
||||
mesh_sequence_number_set(data.seq_number);
|
||||
}
|
||||
|
||||
|
||||
@ -1713,7 +1714,7 @@ static void mesh_access_secure_network_beacon_handler(uint8_t packet_type, uint1
|
||||
} else {
|
||||
if (beacon_iv_update_active == 0){
|
||||
// " At the point of transition, the node shall reset the sequence number to 0x000000."
|
||||
mesh_lower_transport_set_seq(0);
|
||||
mesh_sequence_number_set(0);
|
||||
mesh_iv_update_completed();
|
||||
// store updated iv index
|
||||
mesh_store_iv_index_and_sequence_number();
|
||||
|
@ -54,6 +54,7 @@
|
||||
#include "btstack_tlv.h"
|
||||
#include "mesh_proxy.h"
|
||||
#include "mesh/gatt_bearer.h"
|
||||
#include "mesh_iv_index_seq_number.h"
|
||||
|
||||
#define MESH_HEARTBEAT_FEATURES_SUPPORTED_MASK 0x000f
|
||||
|
||||
@ -1838,7 +1839,7 @@ static void config_heartbeat_publication_emit(mesh_heartbeat_publication_t * mes
|
||||
mesh_heartbeat_publication->destination,
|
||||
mesh_heartbeat_publication->count,
|
||||
mesh_heartbeat_publication->period_ms,
|
||||
mesh_lower_transport_peek_seq());
|
||||
mesh_sequence_number_peek());
|
||||
|
||||
// active features
|
||||
mesh_heartbeat_publication->active_features = mesh_foundation_get_features();
|
||||
|
@ -39,17 +39,18 @@
|
||||
|
||||
#include "mesh_iv_index_seq_number.h"
|
||||
|
||||
static uint32_t lower_transport_seq;
|
||||
static uint32_t sequence_number_current;
|
||||
|
||||
uint32_t mesh_lower_transport_next_seq(void){
|
||||
return lower_transport_seq++;
|
||||
void mesh_sequence_number_set(uint32_t seq){
|
||||
sequence_number_current = seq;
|
||||
}
|
||||
|
||||
uint32_t mesh_lower_transport_peek_seq(void){
|
||||
return lower_transport_seq;
|
||||
uint32_t mesh_sequence_number_next(void){
|
||||
return sequence_number_current++;
|
||||
}
|
||||
|
||||
void mesh_lower_transport_set_seq(uint32_t seq){
|
||||
lower_transport_seq = seq;
|
||||
uint32_t mesh_sequence_number_peek(void){
|
||||
return sequence_number_current;
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,9 +47,9 @@ extern "C"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void mesh_lower_transport_set_seq(uint32_t seq);
|
||||
uint32_t mesh_lower_transport_next_seq(void);;
|
||||
uint32_t mesh_lower_transport_peek_seq(void);
|
||||
void mesh_sequence_number_set(uint32_t seq);
|
||||
uint32_t mesh_sequence_number_peek(void);
|
||||
uint32_t mesh_sequence_number_next(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of extern "C" */
|
||||
|
@ -466,7 +466,7 @@ TEST(MessageTest, Message1Send){
|
||||
uint32_t seq = 1;
|
||||
load_network_key_nid_68();
|
||||
mesh_set_iv_index(0x12345678);
|
||||
mesh_lower_transport_set_seq(seq);
|
||||
mesh_sequence_number_set(seq);
|
||||
test_send_control_message(netkey_index, ttl, src, dest, message1_upper_transport_pdu, 1, message1_lower_transport_pdus, message1_network_pdus);
|
||||
}
|
||||
|
||||
@ -491,7 +491,7 @@ TEST(MessageTest, Message2Send){
|
||||
uint32_t seq = 0x014820;
|
||||
load_network_key_nid_68();
|
||||
mesh_set_iv_index(0x12345678);
|
||||
mesh_lower_transport_set_seq(seq);
|
||||
mesh_sequence_number_set(seq);
|
||||
test_send_control_message(netkey_index, ttl, src, dest, message2_upper_transport_pdu, 1, message2_lower_transport_pdus, message2_network_pdus);
|
||||
}
|
||||
|
||||
@ -516,7 +516,7 @@ TEST(MessageTest, Message3Send){
|
||||
uint32_t seq = 0x2b3832;
|
||||
load_network_key_nid_68();
|
||||
mesh_set_iv_index(0x12345678);
|
||||
mesh_lower_transport_set_seq(seq);
|
||||
mesh_sequence_number_set(seq);
|
||||
test_send_control_message(netkey_index, ttl, src, dest, message3_upper_transport_pdu, 1, message3_lower_transport_pdus, message3_network_pdus);
|
||||
}
|
||||
|
||||
@ -541,7 +541,7 @@ TEST(MessageTest, Message4Send){
|
||||
uint32_t seq = 0x000002;
|
||||
load_network_key_nid_5e();
|
||||
mesh_set_iv_index(0x12345678);
|
||||
mesh_lower_transport_set_seq(seq);
|
||||
mesh_sequence_number_set(seq);
|
||||
test_send_control_message(netkey_index, ttl, src, dest, message4_upper_transport_pdu, 1, message4_lower_transport_pdus, message4_network_pdus);
|
||||
}
|
||||
|
||||
@ -566,7 +566,7 @@ TEST(MessageTest, Message5Send){
|
||||
uint32_t seq = 0x014834;
|
||||
load_network_key_nid_5e();
|
||||
mesh_set_iv_index(0x12345678);
|
||||
mesh_lower_transport_set_seq(seq);
|
||||
mesh_sequence_number_set(seq);
|
||||
test_send_control_message(netkey_index, ttl, src, dest, message5_upper_transport_pdu, 1, message5_lower_transport_pdus, message5_network_pdus);
|
||||
}
|
||||
|
||||
@ -596,7 +596,7 @@ TEST(MessageTest, Message6Send){
|
||||
|
||||
load_network_key_nid_68();
|
||||
mesh_set_iv_index(0x12345678);
|
||||
mesh_lower_transport_set_seq(seq);
|
||||
mesh_sequence_number_set(seq);
|
||||
test_send_access_message(netkey_index, appkey_index, ttl, src, dest, szmic, message6_upper_transport_pdu, 2, message6_lower_transport_pdus, message6_network_pdus);
|
||||
}
|
||||
|
||||
@ -617,7 +617,7 @@ TEST(MessageTest, Message7Send){
|
||||
|
||||
load_network_key_nid_68();
|
||||
mesh_set_iv_index(0x12345678);
|
||||
mesh_lower_transport_set_seq(seq);
|
||||
mesh_sequence_number_set(seq);
|
||||
test_send_control_message(netkey_index, ttl, src, dest, message7_upper_transport_pdu, 1, message7_lower_transport_pdus, message7_network_pdus);
|
||||
}
|
||||
// ACK message, handled in mesh_transport - can be checked with test_control_receive_network_pdu
|
||||
@ -664,7 +664,7 @@ TEST(MessageTest, Message10Send){
|
||||
|
||||
load_network_key_nid_5e();
|
||||
mesh_set_iv_index(0x12345678);
|
||||
mesh_lower_transport_set_seq(seq);
|
||||
mesh_sequence_number_set(seq);
|
||||
test_send_control_message(netkey_index, ttl, src, dest, message10_upper_transport_pdu, 1, message10_lower_transport_pdus, message10_network_pdus);
|
||||
}
|
||||
|
||||
@ -693,7 +693,7 @@ TEST(MessageTest, Message12Send){
|
||||
|
||||
load_network_key_nid_5e();
|
||||
mesh_set_iv_index(0x12345678);
|
||||
mesh_lower_transport_set_seq(seq);
|
||||
mesh_sequence_number_set(seq);
|
||||
test_send_control_message(netkey_index, ttl, src, dest, message12_upper_transport_pdu, 1, message12_lower_transport_pdus, message12_network_pdus);
|
||||
}
|
||||
|
||||
@ -723,7 +723,7 @@ TEST(MessageTest, Message14Send){
|
||||
|
||||
load_network_key_nid_5e();
|
||||
mesh_set_iv_index(0x12345678);
|
||||
mesh_lower_transport_set_seq(seq);
|
||||
mesh_sequence_number_set(seq);
|
||||
test_send_control_message(netkey_index, ttl, src, dest, message14_upper_transport_pdu, 1, message14_lower_transport_pdus, message14_network_pdus);
|
||||
}
|
||||
|
||||
@ -768,7 +768,7 @@ TEST(MessageTest, Message16Send){
|
||||
|
||||
load_network_key_nid_68();
|
||||
mesh_set_iv_index(0x12345678);
|
||||
mesh_lower_transport_set_seq(seq);
|
||||
mesh_sequence_number_set(seq);
|
||||
test_send_access_message(netkey_index, appkey_index, ttl, src, dest, szmic, message16_upper_transport_pdu, 1, message16_lower_transport_pdus, message16_network_pdus);
|
||||
}
|
||||
|
||||
@ -798,7 +798,7 @@ TEST(MessageTest, Message18Send){
|
||||
|
||||
load_network_key_nid_68();
|
||||
mesh_set_iv_index(0x12345678);
|
||||
mesh_lower_transport_set_seq(seq);
|
||||
mesh_sequence_number_set(seq);
|
||||
test_send_access_message(netkey_index, appkey_index, ttl, src, dest, szmic, message18_upper_transport_pdu, 1, message18_lower_transport_pdus, message18_network_pdus);
|
||||
}
|
||||
|
||||
@ -829,7 +829,7 @@ TEST(MessageTest, Message19Send){
|
||||
|
||||
load_network_key_nid_68();
|
||||
mesh_set_iv_index(0x12345678);
|
||||
mesh_lower_transport_set_seq(seq);
|
||||
mesh_sequence_number_set(seq);
|
||||
test_send_access_message(netkey_index, appkey_index, ttl, src, dest, szmic, message19_upper_transport_pdu, 1, message19_lower_transport_pdus, message19_network_pdus);
|
||||
}
|
||||
|
||||
@ -857,7 +857,7 @@ TEST(MessageTest, Message20Send){
|
||||
|
||||
load_network_key_nid_68();
|
||||
mesh_set_iv_index(0x12345677);
|
||||
mesh_lower_transport_set_seq(seq);
|
||||
mesh_sequence_number_set(seq);
|
||||
test_send_access_message(netkey_index, appkey_index, ttl, src, dest, szmic, message20_upper_transport_pdu, 1, message20_lower_transport_pdus, message20_network_pdus);
|
||||
}
|
||||
|
||||
@ -886,7 +886,7 @@ TEST(MessageTest, Message21Send){
|
||||
|
||||
load_network_key_nid_68();
|
||||
mesh_set_iv_index(0x12345677);
|
||||
mesh_lower_transport_set_seq(seq);
|
||||
mesh_sequence_number_set(seq);
|
||||
test_send_access_message(netkey_index, appkey_index, ttl, src, dest, szmic, message21_upper_transport_pdu, 1, message21_lower_transport_pdus, message21_network_pdus);
|
||||
}
|
||||
|
||||
@ -919,7 +919,7 @@ TEST(MessageTest, Message22Send){
|
||||
|
||||
load_network_key_nid_68();
|
||||
mesh_set_iv_index(0x12345677);
|
||||
mesh_lower_transport_set_seq(seq);
|
||||
mesh_sequence_number_set(seq);
|
||||
uint8_t label_uuid[16];
|
||||
btstack_parse_hex(message22_label_string, 16, label_uuid);
|
||||
mesh_virtual_address_t * virtual_address = mesh_virtual_address_register(label_uuid, 0xb529);
|
||||
@ -955,7 +955,7 @@ TEST(MessageTest, Message23Send){
|
||||
|
||||
load_network_key_nid_68();
|
||||
mesh_set_iv_index(0x12345677);
|
||||
mesh_lower_transport_set_seq(seq);
|
||||
mesh_sequence_number_set(seq);
|
||||
uint8_t label_uuid[16];
|
||||
btstack_parse_hex(message23_label_string, 16, label_uuid);
|
||||
mesh_virtual_address_t * virtual_address = mesh_virtual_address_register(label_uuid, 0x9736);
|
||||
@ -993,7 +993,7 @@ TEST(MessageTest, Message24Send){
|
||||
|
||||
load_network_key_nid_68();
|
||||
mesh_set_iv_index(0x12345677);
|
||||
mesh_lower_transport_set_seq(seq);
|
||||
mesh_sequence_number_set(seq);
|
||||
uint8_t label_uuid[16];
|
||||
btstack_parse_hex(message24_label_string, 16, label_uuid);
|
||||
mesh_virtual_address_t * virtual_address = mesh_virtual_address_register(label_uuid, 0x9736);
|
||||
|
@ -292,7 +292,7 @@ static void proxy_configuration_message_handler(mesh_network_callback_type_t cal
|
||||
uint8_t ttl = 0;
|
||||
uint16_t src = primary_element_address;
|
||||
uint16_t dest = 0; // unassigned address
|
||||
uint32_t seq = mesh_lower_transport_next_seq();
|
||||
uint32_t seq = mesh_sequence_number_next();
|
||||
uint8_t nid = mesh_network_nid(received_network_pdu);
|
||||
uint16_t netkey_index = received_network_pdu->netkey_index;
|
||||
printf("netkey index 0x%02x\n", netkey_index);
|
||||
|
Loading…
x
Reference in New Issue
Block a user