mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-02 07:20:16 +00:00
mesh: dd mesh_subnet_iterator, add mesh_subnet_for_netkey_index
This commit is contained in:
parent
01122b73ee
commit
de7d11c030
@ -94,6 +94,9 @@ static const mesh_network_key_t * current_network_key;
|
|||||||
static uint8_t encryption_block[16];
|
static uint8_t encryption_block[16];
|
||||||
static uint8_t obfuscation_block[16];
|
static uint8_t obfuscation_block[16];
|
||||||
|
|
||||||
|
// Subnets
|
||||||
|
static btstack_linked_list_t subnets;
|
||||||
|
|
||||||
// Network Nonce
|
// Network Nonce
|
||||||
static uint8_t network_nonce[13];
|
static uint8_t network_nonce[13];
|
||||||
|
|
||||||
@ -1040,3 +1043,40 @@ mesh_network_pdu_t * mesh_network_pdu_get(void){
|
|||||||
void mesh_network_pdu_free(mesh_network_pdu_t * network_pdu){
|
void mesh_network_pdu_free(mesh_network_pdu_t * network_pdu){
|
||||||
btstack_memory_mesh_network_pdu_free(network_pdu);
|
btstack_memory_mesh_network_pdu_free(network_pdu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mesh Subnet Management
|
||||||
|
|
||||||
|
void mesh_subnet_add(mesh_subnet_t * subnet){
|
||||||
|
btstack_linked_list_add_tail(&subnets, (btstack_linked_item_t *) subnet);
|
||||||
|
}
|
||||||
|
|
||||||
|
void mesh_subnet_remove(mesh_subnet_t * subnet){
|
||||||
|
btstack_linked_list_remove(&subnets, (btstack_linked_item_t *) subnet);
|
||||||
|
}
|
||||||
|
|
||||||
|
mesh_subnet_t * mesh_subnet_list_get(uint16_t netkey_index){
|
||||||
|
btstack_linked_list_iterator_t it;
|
||||||
|
btstack_linked_list_iterator_init(&it, &subnets);
|
||||||
|
while (btstack_linked_list_iterator_has_next(&it)){
|
||||||
|
mesh_subnet_t * item = (mesh_subnet_t *) btstack_linked_list_iterator_next(&it);
|
||||||
|
if (item->netkey_index == netkey_index) return item;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mesh_subnet_list_count(void){
|
||||||
|
return btstack_linked_list_count(&subnets);
|
||||||
|
}
|
||||||
|
|
||||||
|
// mesh network key iterator over all keys
|
||||||
|
void mesh_subnet_iterator_init(mesh_subnet_iterator_t *it){
|
||||||
|
btstack_linked_list_iterator_init(&it->it, &subnets);
|
||||||
|
}
|
||||||
|
|
||||||
|
int mesh_subnet_iterator_has_more(mesh_subnet_iterator_t *it){
|
||||||
|
return btstack_linked_list_iterator_has_next(&it->it);
|
||||||
|
}
|
||||||
|
|
||||||
|
mesh_subnet_t * mesh_subnet_iterator_get_next(mesh_subnet_iterator_t *it){
|
||||||
|
return (mesh_subnet_t *) btstack_linked_list_iterator_next(&it->it);
|
||||||
|
}
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
#include "btstack_linked_list.h"
|
#include "btstack_linked_list.h"
|
||||||
#include "provisioning.h"
|
#include "provisioning.h"
|
||||||
#include "btstack_run_loop.h"
|
#include "btstack_run_loop.h"
|
||||||
|
#include "mesh_keys.h"
|
||||||
|
|
||||||
#if defined __cplusplus
|
#if defined __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -133,6 +134,9 @@ typedef struct {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
btstack_linked_item_t item;
|
btstack_linked_item_t item;
|
||||||
|
|
||||||
|
// netkey index
|
||||||
|
uint16_t netkey_index;
|
||||||
|
|
||||||
// current / old key
|
// current / old key
|
||||||
mesh_network_key_t * old_key;
|
mesh_network_key_t * old_key;
|
||||||
|
|
||||||
@ -156,6 +160,10 @@ typedef struct {
|
|||||||
|
|
||||||
} mesh_subnet_t;
|
} mesh_subnet_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
btstack_linked_list_iterator_t it;
|
||||||
|
} mesh_subnet_iterator_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Init Mesh Network Layer
|
* @brief Init Mesh Network Layer
|
||||||
*/
|
*/
|
||||||
@ -275,6 +283,54 @@ int mesh_network_address_all_relays(uint16_t addr);
|
|||||||
*/
|
*/
|
||||||
int mesh_network_address_virtual(uint16_t addr);
|
int mesh_network_address_virtual(uint16_t addr);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Add subnet to list
|
||||||
|
* @param subnet
|
||||||
|
*/
|
||||||
|
void mesh_subnet_add(mesh_subnet_t * subnet);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Remove subnet from list
|
||||||
|
* @param subnet
|
||||||
|
*/
|
||||||
|
void mesh_subnet_remove(mesh_subnet_t * subnet);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get subnet for netkey_index
|
||||||
|
* @param netkey_index
|
||||||
|
* @returns mesh_subnet_t or NULL
|
||||||
|
*/
|
||||||
|
mesh_subnet_t * mesh_subnet_get_by_netkey_index(uint16_t netkey_index);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get number of stored subnets
|
||||||
|
* @returns count
|
||||||
|
*/
|
||||||
|
int mesh_subnet_list_count(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Iterate over all subnets
|
||||||
|
* @param it
|
||||||
|
*/
|
||||||
|
void mesh_subnet_iterator_init(mesh_subnet_iterator_t *it);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if another subnet is available
|
||||||
|
* @param it
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int mesh_subnet_iterator_has_more(mesh_subnet_iterator_t *it);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get next subnet
|
||||||
|
* @param it
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
mesh_subnet_t * mesh_subnet_iterator_get_next(mesh_subnet_iterator_t *it);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// buffer pool
|
// buffer pool
|
||||||
mesh_network_pdu_t * mesh_network_pdu_get(void);
|
mesh_network_pdu_t * mesh_network_pdu_get(void);
|
||||||
void mesh_network_pdu_free(mesh_network_pdu_t * network_pdu);
|
void mesh_network_pdu_free(mesh_network_pdu_t * network_pdu);
|
||||||
|
@ -47,7 +47,6 @@ extern "C"
|
|||||||
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "mesh/mesh_network.h"
|
|
||||||
#include "mesh/adv_bearer.h"
|
#include "mesh/adv_bearer.h"
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user