Skip to contentSkip to conversation

Bluetooth: mgmt: Add command for getting device IO capabilities.

PATCH In review Vibhav Pant 2 participants 3 messages Feb 10, 2024 – Feb 11, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Bluetooth: mgmt: Add command for getting device IO capabilities.

The following patch adds a new command to the bluetooth management interface, GET_DEVICE_IO_CAPABILITY. The command allows userspace to get the IO capability, and the authentication methods supported by a connected device. The command is necessary in order to implement parts of the Win32 Bluetooth API in the Wine, specifically the following two structs:

* BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS, which provides IO and auth capabilities info for an incoming authentication request from a device.

* BTH_DEVICE_INFO, which contains flags indicating whether the device supports Simple Secure Pairing and MITM protection. The former is supported through BlueZ's "LegacyPairing" property.

Because the Wine API are implemented on top of BlueZ, I'll also be providing a corresponding patch that uses the newly added management command to expose the capabilities through new properties in the org.bluez.Device1 interface.

Thanks,
Vibhav

Vibhav Pant (1):
Bluetooth: mgmt: Add command for getting device IO capabilities.

 include/net/bluetooth/mgmt.h | 19 ++++++++
 net/bluetooth/mgmt.c         | 89 ++++++++++++++++++++++++++++++++++++
 2 files changed, 108 insertions(+)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/1 Bluetooth: mgmt: Add command for getting device IO capabilities.

get_device_io_capability allows to get a connected device's IO capabilities, including the authentication method (and MITM support) requested, stored in the hci_conn for the device.

---
 include/net/bluetooth/mgmt.h | 19 ++++++++
 net/bluetooth/mgmt.c         | 89 ++++++++++++++++++++++++++++++++++++
 2 files changed, 108 insertions(+)
include/net/bluetooth/mgmt.h +19 -0
index d382679efd2b..dba431baaef8 100644
@@ -878,6 +878,25 @@ struct mgmt_cp_mesh_send_cancel {
 } __packed;
 #define MGMT_MESH_SEND_CANCEL_SIZE	1
 
+#define MGMT_OP_GET_DEVICE_IO_CAPABILITY         0x005B
+struct mgmt_cp_get_device_io_capability {
+	struct mgmt_addr_info addr;
+} __packed;
+#define MGMT_GET_DEVICE_IO_CAPABILITY_SIZE       MGMT_ADDR_INFO_SIZE
+struct mgmt_rp_get_device_io_capability {
+	struct mgmt_addr_info addr;
+	__u8 flags;
+} __packed;
+
+#define MGMT_DEVICE_IO_CAP_FLAG_IO_DISPLAY_ONLY       BIT(0)
+#define MGMT_DEVICE_IO_CAP_FLAG_IO_DISPLAY_YESNO      BIT(1)
+#define MGMT_DEVICE_IO_CAP_FLAG_IO_KEYBOARD_ONLY      BIT(2)
+#define MGMT_DEVICE_IO_CAP_FLAG_IO_NO_INPUT_OUTPUT    BIT(3)
+#define MGMT_DEVICE_IO_CAP_FLAG_AT_NO_BONDING         BIT(4)
+#define MGMT_DEVICE_IO_CAP_FLAG_AT_DEDICATED_BONDING  BIT(5)
+#define MGMT_DEVICE_IO_CAP_FLAG_AT_GENERAL_BONDING    BIT(6)
+#define MGMT_DEVICE_IO_CAP_FLAG_AT_MITM               BIT(7)
+
 #define MGMT_EV_CMD_COMPLETE		0x0001
 struct mgmt_ev_cmd_complete {
 	__le16	opcode;
net/bluetooth/mgmt.c +89 -0

113 lines not on this page · raw message

Signature · 1 line
2.43.0
#2 lore raw
In reply to Vibhav Pant

Hi Vibhav,

Quoted 10 lines · Vibhav Pant

The following patch adds a new command to the bluetooth management interface, GET_DEVICE_IO_CAPABILITY. The command allows userspace to get the IO capability, and the authentication methods supported by a connected device. The command is necessary in order to implement parts of the Win32 Bluetooth API in the Wine, specifically the following two structs:

* BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS, which provides IO and auth capabilities info for an incoming authentication request from a device.

Quoted 7 lines

* BTH_DEVICE_INFO, which contains flags indicating whether the device supports Simple Secure Pairing and MITM protection. The former is supported through BlueZ's "LegacyPairing" property.

Because the Wine API are implemented on top of BlueZ, I'll also be providing a corresponding patch that uses the newly added management command to expose the capabilities through new properties in the org.bluez.Device1 interface.

Interesting, but the IO capability matching logic lives under the kernel so I wonder how useful this information is if you can't really do much about the authentication method used? And in case you are thinking of changing the pairing procedure to just leave it up to the upper layer to figure it out, I don't think that is a good idea because that is subject to qualification that would effectively be a new implementation.

Quoted 14 lines

Thanks,
Vibhav

Vibhav Pant (1):
Bluetooth: mgmt: Add command for getting device IO capabilities.

 include/net/bluetooth/mgmt.h | 19 ++++++++
 net/bluetooth/mgmt.c         | 89 ++++++++++++++++++++++++++++++++++++
 2 files changed, 108 insertions(+)

--
2.43.0

Signature · 1 line
Luiz Augusto von Dentz