aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2015-03-06 13:11:21 -0500
committerJohan Hedberg <johan.hedberg@intel.com>2015-03-06 13:43:07 -0500
commit93690c227acf08a2a19cbaf9acbcd2210fbb8ded (patch)
treead2744a305b0e5c907a694cdb64984d4143d79cf
parent82f8b651a94d5c7090563fe55cfdb286c461a16c (diff)
Bluetooth: Introduce controller setting information for static address
Currently it is not possible to determine if the static address is used by the controller. It is also not possible to determine if using a static on a dual-mode controller with disabled BR/EDR is possible or not. To address this issue, introduce a new setting called static-address. If support for this setting is signaled that means that the kernel supports using static addresses. And if used on dual-mode controllers with BR/EDR disabled it means that a configured static address can be used. In addition utilize the same setting for the list of current active settings that indicates if a static address is configured and if that address will be actually used. With this in mind the existing Set Static Address management command has been extended to return the current settings. That way the caller of that command can easily determine if the programmed address will be used or if extra steps are required. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
-rw-r--r--include/net/bluetooth/mgmt.h1
-rw-r--r--net/bluetooth/mgmt.c28
2 files changed, 27 insertions, 2 deletions
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index fe8eef00e9ca..0c737e4b8f57 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -98,6 +98,7 @@ struct mgmt_rp_read_index_list {
98#define MGMT_SETTING_DEBUG_KEYS 0x00001000 98#define MGMT_SETTING_DEBUG_KEYS 0x00001000
99#define MGMT_SETTING_PRIVACY 0x00002000 99#define MGMT_SETTING_PRIVACY 0x00002000
100#define MGMT_SETTING_CONFIGURATION 0x00004000 100#define MGMT_SETTING_CONFIGURATION 0x00004000
101#define MGMT_SETTING_STATIC_ADDRESS 0x00008000
101 102
102#define MGMT_OP_READ_INFO 0x0004 103#define MGMT_OP_READ_INFO 0x0004
103#define MGMT_READ_INFO_SIZE 0 104#define MGMT_READ_INFO_SIZE 0
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 967f07fdbbbe..d185a9800983 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -583,6 +583,7 @@ static u32 get_supported_settings(struct hci_dev *hdev)
583 settings |= MGMT_SETTING_ADVERTISING; 583 settings |= MGMT_SETTING_ADVERTISING;
584 settings |= MGMT_SETTING_SECURE_CONN; 584 settings |= MGMT_SETTING_SECURE_CONN;
585 settings |= MGMT_SETTING_PRIVACY; 585 settings |= MGMT_SETTING_PRIVACY;
586 settings |= MGMT_SETTING_STATIC_ADDRESS;
586 } 587 }
587 588
588 if (test_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks) || 589 if (test_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks) ||
@@ -638,6 +639,25 @@ static u32 get_current_settings(struct hci_dev *hdev)
638 if (test_bit(HCI_PRIVACY, &hdev->dev_flags)) 639 if (test_bit(HCI_PRIVACY, &hdev->dev_flags))
639 settings |= MGMT_SETTING_PRIVACY; 640 settings |= MGMT_SETTING_PRIVACY;
640 641
642 /* The current setting for static address has two purposes. The
643 * first is to indicate if the static address will be used and
644 * the second is to indicate if it is actually set.
645 *
646 * This means if the static address is not configured, this flag
647 * will never bet set. If the address is configured, then if the
648 * address is actually used decides if the flag is set or not.
649 *
650 * For single mode LE only controllers and dual-mode controllers
651 * with BR/EDR disabled, the existence of the static address will
652 * be evaluated.
653 */
654 if (test_bit(HCI_FORCE_STATIC_ADDR, &hdev->dbg_flags) ||
655 !test_bit(HCI_BREDR_ENABLED, &hdev->dev_flags) ||
656 !bacmp(&hdev->bdaddr, BDADDR_ANY)) {
657 if (bacmp(&hdev->static_addr, BDADDR_ANY))
658 settings |= MGMT_SETTING_STATIC_ADDRESS;
659 }
660
641 return settings; 661 return settings;
642} 662}
643 663
@@ -4498,10 +4518,14 @@ static int set_static_address(struct sock *sk, struct hci_dev *hdev,
4498 4518
4499 bacpy(&hdev->static_addr, &cp->bdaddr); 4519 bacpy(&hdev->static_addr, &cp->bdaddr);
4500 4520
4501 err = cmd_complete(sk, hdev->id, MGMT_OP_SET_STATIC_ADDRESS, 0, NULL, 0); 4521 err = send_settings_rsp(sk, MGMT_OP_SET_STATIC_ADDRESS, hdev);
4522 if (err < 0)
4523 goto unlock;
4502 4524
4503 hci_dev_unlock(hdev); 4525 err = new_settings(hdev, sk);
4504 4526
4527unlock:
4528 hci_dev_unlock(hdev);
4505 return err; 4529 return err;
4506} 4530}
4507 4531