Skip to content

Commit 6126ffa

Browse files
Vudentzholtmann
authored andcommitted
Bluetooth: Introduce HCI_CONN_FLAG_DEVICE_PRIVACY device flag
This introduces HCI_CONN_FLAG_DEVICE_PRIVACY which can be used by userspace to indicate to the controller to use Device Privacy Mode to a specific device. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
1 parent 800fe5e commit 6126ffa

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

include/net/bluetooth/hci_core.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ struct bdaddr_list_with_irk {
154154

155155
enum hci_conn_flags {
156156
HCI_CONN_FLAG_REMOTE_WAKEUP,
157+
HCI_CONN_FLAG_DEVICE_PRIVACY,
157158

158159
__HCI_CONN_NUM_FLAGS,
159160
};
@@ -1466,6 +1467,9 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
14661467
#define use_ll_privacy(dev) (ll_privacy_capable(dev) && \
14671468
hci_dev_test_flag(dev, HCI_ENABLE_LL_PRIVACY))
14681469

1470+
#define privacy_mode_capable(dev) (use_ll_privacy(dev) && \
1471+
(hdev->commands[39] & 0x04))
1472+
14691473
/* Use enhanced synchronous connection if command is supported */
14701474
#define enhanced_sco_capable(dev) ((dev)->commands[29] & 0x08)
14711475

net/bluetooth/mgmt.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3978,6 +3978,11 @@ static int exp_ll_privacy_feature_changed(bool enabled, struct hci_dev *hdev,
39783978
memcpy(ev.uuid, rpa_resolution_uuid, 16);
39793979
ev.flags = cpu_to_le32((enabled ? BIT(0) : 0) | BIT(1));
39803980

3981+
if (enabled && privacy_mode_capable(hdev))
3982+
set_bit(HCI_CONN_FLAG_DEVICE_PRIVACY, hdev->conn_flags);
3983+
else
3984+
clear_bit(HCI_CONN_FLAG_DEVICE_PRIVACY, hdev->conn_flags);
3985+
39813986
return mgmt_limited_event(MGMT_EV_EXP_FEATURE_CHANGED, hdev,
39823987
&ev, sizeof(ev),
39833988
HCI_MGMT_EXP_FEATURE_EVENTS, skip);
@@ -4461,6 +4466,13 @@ static int set_device_flags(struct sock *sk, struct hci_dev *hdev, void *data,
44614466
if (params) {
44624467
bitmap_from_u64(params->flags, current_flags);
44634468
status = MGMT_STATUS_SUCCESS;
4469+
4470+
/* Update passive scan if HCI_CONN_FLAG_DEVICE_PRIVACY
4471+
* has been set.
4472+
*/
4473+
if (test_bit(HCI_CONN_FLAG_DEVICE_PRIVACY,
4474+
params->flags))
4475+
hci_update_passive_scan(hdev);
44644476
} else {
44654477
bt_dev_warn(hdev, "No such LE device %pMR (0x%x)",
44664478
&cp->addr.bdaddr,

0 commit comments

Comments
 (0)