Skip to contentSkip to conversation

Bluetooth: Add management command for setting static address

PATCH Applied Marcel Holtmann 2 participants 2 messages Oct 2, 2013

Subsystems (2)
lore
Share & tools
lore

Marcel Holtmann

author maintainer
#0 lore raw

PATCH v2 1/1 Bluetooth: Add management command for setting static address

On dual-mode BR/EDR/LE and LE only controllers it is possible to configure a random address. There are two types or random addresses, one is static and the other private. Since the random private addresses require special privacy feature to be supported, the configuration of these two are kept separate.

This command allows for setting the static random address. It is only supported on controllers with LE support. The static random address is suppose to be valid for the lifetime of the controller or at least until the next power cycle. To ensure such behavior, setting of the address is limited to when the controller is powered off.

The special BDADDR_ANY address (00:00:00:00:00:00) can be used to disable the static address. This is also the default value.

---
 include/net/bluetooth/hci.h      |  2 ++
 include/net/bluetooth/hci_core.h |  1 +
 include/net/bluetooth/mgmt.h     |  6 +++++
 net/bluetooth/mgmt.c             | 49 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 58 insertions(+)
include/net/bluetooth/hci.h +2 -0
index 4fa08d7..d7fd825 100644
@@ -978,6 +978,8 @@ struct hci_rp_le_read_local_features {
 	__u8     features[8];
 } __packed;
 
+#define HCI_OP_LE_SET_RANDOM_ADDR	0x2005
+
 #define HCI_OP_LE_READ_ADV_TX_POWER	0x2007
 struct hci_rp_le_read_adv_tx_power {
 	__u8	status;
include/net/bluetooth/hci_core.h +1 -0
index 26cc9f7..e09c305 100644
@@ -140,6 +140,7 @@ struct hci_dev {
 	__u8		bus;
 	__u8		dev_type;
 	bdaddr_t	bdaddr;
+	bdaddr_t	static_addr;
 	__u8		dev_name[HCI_MAX_NAME_LENGTH];
 	__u8		short_name[HCI_MAX_SHORT_NAME_LENGTH];
 	__u8		eir[HCI_MAX_EIR_LENGTH];
include/net/bluetooth/mgmt.h +6 -0
index 7347df8..2ad433bb 100644
@@ -356,6 +356,12 @@ struct mgmt_cp_set_device_id {
 
 #define MGMT_OP_SET_BREDR		0x002A
 
+#define MGMT_OP_SET_STATIC_ADDRESS	0x002B
+struct mgmt_cp_set_static_address {
+	bdaddr_t bdaddr;
+} __packed;
+#define MGMT_SET_STATIC_ADDRESS_SIZE	6
+
 #define MGMT_EV_CMD_COMPLETE		0x0001
 struct mgmt_ev_cmd_complete {
 	__le16	opcode;
net/bluetooth/mgmt.c +49 -0

73 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#1 lore raw

Hi Marcel,

Quoted 16 lines · Marcel Holtmann

On dual-mode BR/EDR/LE and LE only controllers it is possible to configure a random address. There are two types or random addresses, one is static and the other private. Since the random private addresses require special privacy feature to be supported, the configuration of these two are kept separate.

This command allows for setting the static random address. It is only supported on controllers with LE support. The static random address is suppose to be valid for the lifetime of the controller or at least until the next power cycle. To ensure such behavior, setting of the address is limited to when the controller is powered off.

The special BDADDR_ANY address (00:00:00:00:00:00) can be used to disable the static address. This is also the default value.

Quoted 7 lines
---
 include/net/bluetooth/hci.h      |  2 ++
 include/net/bluetooth/hci_core.h |  1 +
 include/net/bluetooth/mgmt.h     |  6 +++++
 net/bluetooth/mgmt.c             | 49 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 58 insertions(+)

Applied to bluetooth-next. Thanks.

Johan