Bluetooth: Mesh: Fix Proxy Privacy parameter support

According to section 6.7, upon connection Proxy Server shall determine
value of Proxy Privacy parameter (sections 6.5 and 7.2.2.2.6). Depending
on that, it will either send Secure Network Beacon or Private Beacon to
Proxy Client, but never both.

Proxy Privacy parameter is determined by GATT Proxy, Node Identity
states and their private counterparts (section 7.2.2.2.6). Since
non-private and private states are mutually exclusive, it is enough to
only check either Private GATT Proxy state or Private Node Identity
state of any known subnet for which the state is currenty enabled.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This commit is contained in:
Pavel Vasilyev 2023-06-05 11:55:37 +02:00 committed by Anas Nashif
commit dfb8bcaf38
5 changed files with 63 additions and 6 deletions

View file

@ -67,6 +67,9 @@ static struct bt_mesh_proxy_client {
REJECT,
} filter_type;
struct k_work send_beacons;
#if defined(CONFIG_BT_MESH_PRIV_BEACONS)
bool privacy;
#endif
} clients[CONFIG_BT_MAX_CONN] = {
[0 ... (CONFIG_BT_MAX_CONN - 1)] = {
.send_beacons = Z_WORK_INITIALIZER(proxy_send_beacons),
@ -324,7 +327,12 @@ static int beacon_send(struct bt_mesh_proxy_client *client,
NET_BUF_SIMPLE_DEFINE(buf, 28);
net_buf_simple_reserve(&buf, 1);
err = bt_mesh_beacon_create(sub, &buf);
#if defined(CONFIG_BT_MESH_PRIV_BEACONS)
err = bt_mesh_beacon_create(sub, &buf, client->privacy);
#else
err = bt_mesh_beacon_create(sub, &buf, false);
#endif
if (err) {
return err;
}
@ -1044,6 +1052,21 @@ static void gatt_connected(struct bt_conn *conn, uint8_t err)
client->cli = bt_mesh_proxy_role_setup(conn, proxy_send,
proxy_msg_recv);
#if defined(CONFIG_BT_MESH_PRIV_BEACONS)
/* Binding from section 7.2.2.2.6 of MshPRTv1.1. */
enum bt_mesh_subnets_node_id_state cur_node_id = bt_mesh_subnets_node_id_state_get();
if (bt_mesh_gatt_proxy_get() == BT_MESH_FEATURE_ENABLED ||
cur_node_id == BT_MESH_SUBNETS_NODE_ID_STATE_ENABLED) {
client->privacy = false;
} else {
client->privacy = (bt_mesh_priv_gatt_proxy_get() == BT_MESH_FEATURE_ENABLED) ||
(cur_node_id == BT_MESH_SUBNETS_NODE_ID_STATE_ENABLED_PRIVATE);
}
LOG_DBG("privacy: %d", client->privacy);
#endif
/* If connection was formed after Proxy Solicitation we need to stop future
* Private Network ID advertisements
*/