1 /*
2  * Copyright (c) 2024 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_BRG_CFG_H__
8 #define ZEPHYR_INCLUDE_BLUETOOTH_MESH_BRG_CFG_H__
9 
10 #include <stdint.h>
11 #include <stdbool.h>
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 /**
18  * @defgroup bt_mesh_brg_cfg Bridge Configuration common header
19  * @ingroup bt_mesh
20  * @{
21  */
22 
23 /** Subnet Bridge states */
24 enum bt_mesh_brg_cfg_state {
25 	/** Subnet bridge functionality is disabled. */
26 	BT_MESH_BRG_CFG_DISABLED,
27 	/** Subnet bridge state functionality is enabled. */
28 	BT_MESH_BRG_CFG_ENABLED,
29 };
30 
31 /* Bridging from Addr1 to Addr2. */
32 #define BT_MESH_BRG_CFG_DIR_ONEWAY 1
33 /* Bidirectional bridging between Addr1 and Addr2. */
34 #define BT_MESH_BRG_CFG_DIR_TWOWAY 2
35 
36 /** Bridging Table state entry corresponding to a entry in the Bridging Table. */
37 struct bt_mesh_brg_cfg_table_entry {
38 	/** Allowed directions for the bridged traffic (or bridged traffic not allowed) */
39 	uint8_t directions;
40 	/** NetKey Index of the first subnet */
41 	uint16_t net_idx1;
42 	/** NetKey Index of the second subnet */
43 	uint16_t net_idx2;
44 	/** Address of the node in the first subnet */
45 	uint16_t addr1;
46 	/** Address of the node in the second subnet */
47 	uint16_t addr2;
48 };
49 
50 /** Bridging Table Status response */
51 struct bt_mesh_brg_cfg_table_status {
52 	/** Status Code of the requesting message */
53 	uint8_t status;
54 	/** Requested Bridging Table entry */
55 	struct bt_mesh_brg_cfg_table_entry entry;
56 };
57 
58 /** Used to filter set of pairs of NetKey Indexes from the Bridging Table */
59 struct bt_mesh_brg_cfg_filter_netkey {
60 	uint16_t filter: 2,    /* Filter applied to the set of pairs of NetKey Indexes */
61 		prohibited: 2, /* Prohibited */
62 		net_idx: 12;   /* NetKey Index used for filtering or ignored */
63 };
64 
65 /** Bridged Subnets List response */
66 struct bt_mesh_brg_cfg_subnets_list {
67 	/** Filter applied NetKey Indexes, and NetKey Index used for filtering. */
68 	struct bt_mesh_brg_cfg_filter_netkey net_idx_filter;
69 	/** Start offset in units of bridges */
70 	uint8_t start_idx;
71 	/** Pointer to allocated buffer for storing filtered of NetKey Indexes */
72 	struct net_buf_simple *list;
73 };
74 
75 /** Bridging Table List response */
76 struct bt_mesh_brg_cfg_table_list {
77 	/** Status Code of the requesting message */
78 	uint8_t status;
79 	/** NetKey Index of the first subnet */
80 	uint16_t net_idx1;
81 	/** NetKey Index of the second subnet */
82 	uint16_t net_idx2;
83 	/** Start offset in units of bridging table state entries */
84 	uint16_t start_idx;
85 	/** Pointer to allocated buffer for storing list of bridged addresses and directions */
86 	struct net_buf_simple *list;
87 };
88 
89 /**
90  * @}
91  */
92 
93 #ifdef __cplusplus
94 }
95 #endif
96 
97 #endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_BRG_CFG_H__ */
98