Skip to contentSkip to conversation

client/btpclient: Add BTP_EV_GAP_SEC_LEVEL_CHANGED support

PATCH In review Frédéric Danis 3 participants 3 messages May 7 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 client/btpclient: Add BTP_EV_GAP_SEC_LEVEL_CHANGED support

This allows reduces connection time for the BAP tests.

---
 client/btpclient/gap.c | 22 ++++++++++++++++++++++
 src/shared/btp.h       | 11 +++++++++++
 2 files changed, 33 insertions(+)
client/btpclient/gap.c +22 -0
index 68e029dcc..1a6c2c2f0 100644
@@ -2538,6 +2538,21 @@ static void btp_gap_device_connection_ev(struct l_dbus_proxy *proxy,
 	}
 }
 
+static void btp_security_changed_ev(struct l_dbus_proxy *proxy, bool paired)
+{
+	struct btp_device *dev = find_device_by_proxy(proxy);
+	struct btp_adapter *adapter = find_adapter_by_device(dev);
+	struct btp_gap_sec_level_changed_ev ev;
+
+	/* TODO: get real security level */
+	memcpy(&ev.address, &dev->address, sizeof(ev.address));
+	ev.address_type = dev->address_type;
+	ev.sec_level = BTP_GAP_SEC_LEVEL_AUTH_ENC;
+
+	btp_send(btp, BTP_GAP_SERVICE, BTP_EV_GAP_SEC_LEVEL_CHANGED,
+					adapter->index, sizeof(ev), &ev);
+}
+
 static void btp_identity_resolved_ev(struct l_dbus_proxy *proxy)
 {
 	struct btp_device *dev = find_device_by_proxy(proxy);
@@ -2709,6 +2724,13 @@ void gap_property_changed(struct l_dbus_proxy *proxy, const char *name,
 			 */
 			if (!prop)
 				btp_gap_device_connection_ev(proxy, prop);
+		} else if (!strcmp(name, "Paired")) {
+			bool prop;
+
+			if (!l_dbus_message_get_arguments(msg, "b", &prop))
+				return;
+
+			btp_security_changed_ev(proxy, prop);
 		} else if (!strcmp(name, "AddressType")) {
 			/* Address property change came first along with address
 			 * type.
src/shared/btp.h +11 -0
index b99ad3a28..4d3c4ec6f 100644
@@ -286,6 +286,17 @@ struct btp_gap_identity_resolved_ev {
 	bdaddr_t identity_address;
 } __packed;
 
+#define BTP_GAP_SEC_LEVEL_UNAUTH_ENC		0x01
+#define BTP_GAP_SEC_LEVEL_AUTH_ENC		0x02
+#define BTP_GAP_SEC_LEVEL_AUTH_SC		0x03
+
+#define BTP_EV_GAP_SEC_LEVEL_CHANGED		0x89
+struct btp_gap_sec_level_changed_ev {
+	uint8_t address_type;
+	bdaddr_t address;
+	uint8_t sec_level;
+} __packed;
+
 struct btp_gatt_service {
 	uint16_t start_handle;
 	uint16_t end_handle;
Signature · 1 line
2.43.0
#1 lore raw

Hi Frédéric,

Quoted 12 lines · Frédéric Danis

This allows reduces connection time for the BAP tests.

---
 client/btpclient/gap.c | 22 ++++++++++++++++++++++
 src/shared/btp.h       | 11 +++++++++++
 2 files changed, 33 insertions(+)
client/btpclient/gap.c +0 -0
index 68e029dcc..1a6c2c2f0 100644

client/btpclient/gap.c static void btp_gap_device_connection_ev(struct l_dbus_proxy *proxy, · line 2547

Quoted 10 lines
client/btpclient/gap.c +7 -0
@@ -2538,6 +2538,21 @@ static void btp_gap_device_connection_ev(struct l_dbus_proxy *proxy,
        }
 }
 
+static void btp_security_changed_ev(struct l_dbus_proxy *proxy, bool paired)
+{
+       struct btp_device *dev = find_device_by_proxy(proxy);
+       struct btp_adapter *adapter = find_adapter_by_device(dev);
+       struct btp_gap_sec_level_changed_ev ev;
+
+       /* TODO: get real security level */

I guess it wouldn't hurt to expose the security level somehow, not the key itself just the level.

Quoted 51 lines
client/btpclient/gap.c +15 -0
+       memcpy(&ev.address, &dev->address, sizeof(ev.address));
+       ev.address_type = dev->address_type;
+       ev.sec_level = BTP_GAP_SEC_LEVEL_AUTH_ENC;
+
+       btp_send(btp, BTP_GAP_SERVICE, BTP_EV_GAP_SEC_LEVEL_CHANGED,
+                                       adapter->index, sizeof(ev), &ev);
+}
+
 static void btp_identity_resolved_ev(struct l_dbus_proxy *proxy)
 {
        struct btp_device *dev = find_device_by_proxy(proxy);
@@ -2709,6 +2724,13 @@ void gap_property_changed(struct l_dbus_proxy *proxy, const char *name,
                         */
                        if (!prop)
                                btp_gap_device_connection_ev(proxy, prop);
+               } else if (!strcmp(name, "Paired")) {
+                       bool prop;
+
+                       if (!l_dbus_message_get_arguments(msg, "b", &prop))
+                               return;
+
+                       btp_security_changed_ev(proxy, prop);
                } else if (!strcmp(name, "AddressType")) {
                        /* Address property change came first along with address
                         * type.
src/shared/btp.h +11 -1
index b99ad3a28..4d3c4ec6f 100644
@@ -286,6 +286,17 @@ struct btp_gap_identity_resolved_ev {
        bdaddr_t identity_address;
 } __packed;
 
+#define BTP_GAP_SEC_LEVEL_UNAUTH_ENC           0x01
+#define BTP_GAP_SEC_LEVEL_AUTH_ENC             0x02
+#define BTP_GAP_SEC_LEVEL_AUTH_SC              0x03
+
+#define BTP_EV_GAP_SEC_LEVEL_CHANGED           0x89
+struct btp_gap_sec_level_changed_ev {
+       uint8_t address_type;
+       bdaddr_t address;
+       uint8_t sec_level;
+} __packed;
+
 struct btp_gatt_service {
        uint16_t start_handle;
        uint16_t end_handle;
--

2.43.0

Signature · 1 line
Luiz Augusto von Dentz
#2 lore raw
In reply to Frédéric Danis

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1091167

---Test result---

Test Summary:

CheckPatch                    PASS      0.44 seconds
GitLint                       PASS      0.29 seconds
BuildEll                      PASS      20.26 seconds
BluezMake                     PASS      652.26 seconds
CheckSmatch                   PASS      351.90 seconds
bluezmakeextell               PASS      183.13 seconds
IncrementalBuild              PASS      657.53 seconds
ScanBuild                     PASS      1021.35 seconds

https://github.com/bluez/bluez/pull/2106

---
Regards,
Linux Bluetooth