1 /* 2 * Copyright (c) 2024 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef ZEPHYR_SUBSYS_BLUETOOTH_MESH_BRG_CFG_H_ 8 #define ZEPHYR_SUBSYS_BLUETOOTH_MESH_BRG_CFG_H_ 9 10 /** These are internal APIs. They do not sanitize input params. */ 11 12 #define BT_MESH_BRG_CFG_KEY_INDEX_MAX 0x0FFF 13 14 #define BT_MESH_BRG_CFG_NKEY_PRHB_FLT_MASK 0x000C 15 16 #define BT_MESH_BRG_CFG_NETIDX_NOMATCH 0xFFFF 17 18 /* One row of the bridging table */ 19 struct bt_mesh_brg_cfg_row { 20 /* Direction of the entry in the bridging table 21 * 0 - no entry, 22 * 1 - bridge messages with src as addr1 and dst as addr2 23 * 2 - bridge messages with src as addr1 and dst as addr2 and vice-versa 24 */ 25 uint32_t direction: 8; 26 uint32_t net_idx1: 12; 27 uint32_t net_idx2: 12; 28 uint16_t addr1; 29 uint16_t addr2; 30 }; 31 32 bool bt_mesh_brg_cfg_enable_get(void); 33 34 int bt_mesh_brg_cfg_enable_set(bool enable); 35 36 void bt_mesh_brg_cfg_pending_store(void); 37 38 int bt_mesh_brg_cfg_tbl_reset(void); 39 40 int bt_mesh_brg_cfg_tbl_get(const struct bt_mesh_brg_cfg_row **rows); 41 42 int bt_mesh_brg_cfg_tbl_add(uint8_t direction, uint16_t net_idx1, uint16_t net_idx2, uint16_t addr1, 43 uint16_t addr2, uint8_t *status); 44 45 int bt_mesh_brg_cfg_tbl_remove(uint16_t net_idx1, uint16_t net_idx2, uint16_t addr1, uint16_t addr2, 46 uint8_t *status); 47 48 typedef void (*bt_mesh_brg_cfg_cb_t)(uint16_t new_netidx, void *user_data); 49 50 /** 51 * @brief Iterate over the bridging table to find a matching entry for the given SRC, DST, and 52 * NetKey Index. 53 * 54 * This function iterates over the bridging table and checks if there is a match for the provided 55 * parameters. If a match is found, the callback function specified by the 'cb' parameter is 56 * invoked with the NetKey Index of each matching entry (there can be several). Relaying operation 57 * can then happen inside this callback. 58 * 59 * @param src The source address to match. 60 * @param dst The destination address to match. 61 * @param net_idx The NetKey Index to match. 62 * @param cb The callback function to be invoked for each matching entry. 63 * @param user_data User data to be passed to the callback function. 64 */ 65 void bt_mesh_brg_cfg_tbl_foreach_subnet(uint16_t src, uint16_t dst, uint16_t net_idx, 66 bt_mesh_brg_cfg_cb_t cb, void *user_data); 67 68 #endif /* ZEPHYR_SUBSYS_BLUETOOTH_MESH_BRG_CFG_H_ */ 69