diff mbox series

[BlueZ,v2,3/5] device: Use btd_device_is_initiator instead of Connect message

Message ID 20250326193133.2718934-3-luiz.dentz@gmail.com
State New
Headers show
Series [BlueZ,v2,1/5] device: Attempt to elevate security on Pair while connected | expand

Commit Message

Luiz Augusto von Dentz March 26, 2025, 7:31 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Device.Connect message is not the only way to initiate a connection as
there is also the likes of Device.Pair which will initiate bonding, so
this incorporate the bonding check into btd_device_is_initiator and
replaces the checks of were Connect message was used to determine if
initiator to use btd_device_is_initiator.
---
 src/device.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/src/device.c b/src/device.c
index 6a6c379fcbbf..034491b59d30 100644
--- a/src/device.c
+++ b/src/device.c
@@ -320,6 +320,8 @@  bool btd_device_is_initiator(struct btd_device *dev)
 		return dev->le_state.initiator;
 	else if (dev->bredr_state.connected)
 		return dev->bredr_state.initiator;
+	else if (dev->bonding)
+		return true;
 
 	return dev->att_io ? true : false;
 }
@@ -5780,11 +5782,12 @@  static void gatt_client_init(struct btd_device *device)
 
 	gatt_client_cleanup(device);
 
-	if (!device->connect && !btd_opts.reverse_discovery) {
+	if (!btd_device_is_initiator(device) && !btd_opts.reverse_discovery) {
 		DBG("Reverse service discovery disabled: skipping GATT client");
 		return;
 	}
-	if (!device->connect && !btd_opts.gatt_client) {
+
+	if (!btd_device_is_initiator(device) && !btd_opts.gatt_client) {
 		DBG("GATT client disabled: skipping GATT client");
 		return;
 	}
@@ -5834,7 +5837,7 @@  static void gatt_client_init(struct btd_device *device)
 	 * it shall be triggered only when ready to avoid possible clashes where
 	 * both sides attempt to connection at same time.
 	 */
-	if (device->connect)
+	if (btd_device_is_initiator(device))
 		btd_gatt_client_eatt_connect(device->client_dbus);
 }