aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hci_core.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2014-02-23 23:25:54 -0500
committerJohan Hedberg <johan.hedberg@intel.com>2014-02-24 01:45:58 -0500
commit94b1fc92cd7cf550460ffd4bcc08c2707564aa49 (patch)
tree6288fa61c03d3139540e007ccdb2fa6c9d30dbbf /net/bluetooth/hci_core.c
parentac345813c4ac5a0e66261e9812f0fe94729c0eb2 (diff)
Bluetooth: Use unresolvable private address for active scanning
When running active scanning during LE discovery, do not reveal the own identity to the peer devices. In case LE privacy has been enabled, then a resolvable private address is used. If the LE privacy option is off, then use an unresolvable private address. The public address or static random address is never used in active scanning anymore. This ensures that scan request are send using a random address. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net/bluetooth/hci_core.c')
-rw-r--r--net/bluetooth/hci_core.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 80462a126ebd..31e68ade309d 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -3332,7 +3332,8 @@ static void le_scan_disable_work(struct work_struct *work)
3332 BT_ERR("Disable LE scanning request failed: err %d", err); 3332 BT_ERR("Disable LE scanning request failed: err %d", err);
3333} 3333}
3334 3334
3335int hci_update_random_address(struct hci_request *req, u8 *own_addr_type) 3335int hci_update_random_address(struct hci_request *req, bool require_privacy,
3336 u8 *own_addr_type)
3336{ 3337{
3337 struct hci_dev *hdev = req->hdev; 3338 struct hci_dev *hdev = req->hdev;
3338 int err; 3339 int err;
@@ -3365,6 +3366,21 @@ int hci_update_random_address(struct hci_request *req, u8 *own_addr_type)
3365 return 0; 3366 return 0;
3366 } 3367 }
3367 3368
3369 /* In case of required privacy without resolvable private address,
3370 * use an unresolvable private address. This is useful for active
3371 * scanning and non-connectable advertising.
3372 */
3373 if (require_privacy) {
3374 bdaddr_t urpa;
3375
3376 get_random_bytes(&urpa, 6);
3377 urpa.b[5] &= 0x3f; /* Clear two most significant bits */
3378
3379 *own_addr_type = ADDR_LE_DEV_RANDOM;
3380 hci_req_add(req, HCI_OP_LE_SET_RANDOM_ADDR, 6, &urpa);
3381 return 0;
3382 }
3383
3368 /* If forcing static address is in use or there is no public 3384 /* If forcing static address is in use or there is no public
3369 * address use the static address as random address (but skip 3385 * address use the static address as random address (but skip
3370 * the HCI command if the current random address is already the 3386 * the HCI command if the current random address is already the