summaryrefslogtreecommitdiff
path: root/src/device.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2022-05-11 17:55:15 -0700
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2022-05-12 16:56:18 -0700
commitcd24715bb22656539157a6fb09d70485ec5f5cdd (patch)
tree3ac28de28bb8a828201ac8954308839d15fde1cc /src/device.c
parent4423d63a9634e62cb41d1b1b53cf360edd927f98 (diff)
downloadbluez-cd24715bb22656539157a6fb09d70485ec5f5cdd.tar.gz
service: Add initiator argument to service_accept
This adds initiator argument to service_accept so profiles accepting the connection can use btd_service_is_initiator to determine if the connection was initiated locally (central) or remotely (peripheral).
Diffstat (limited to 'src/device.c')
-rw-r--r--src/device.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/device.c b/src/device.c
index b0309a1e7..a39eb8c64 100644
--- a/src/device.c
+++ b/src/device.c
@@ -158,6 +158,7 @@ struct bearer_state {
bool bonded;
bool connected;
bool svc_resolved;
+ bool initiator;
};
struct csrk_info {
@@ -297,6 +298,16 @@ static struct bearer_state *get_state(struct btd_device *dev,
return &dev->le_state;
}
+static bool get_initiator(struct btd_device *dev)
+{
+ if (dev->le_state.connected)
+ return dev->le_state.initiator;
+ if (dev->bredr_state.connected)
+ return dev->bredr_state.initiator;
+
+ return false;
+}
+
static GSList *find_service_with_profile(GSList *list, struct btd_profile *p)
{
GSList *l;
@@ -3256,6 +3267,7 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type)
return;
state->connected = false;
+ state->initiator = false;
device->general_connect = FALSE;
device_set_svc_refreshed(device, false);
@@ -4169,7 +4181,7 @@ done:
}
/* Notify driver about the new connection */
- service_accept(service);
+ service_accept(service, get_initiator(device));
}
static void device_add_gatt_services(struct btd_device *device)
@@ -4191,7 +4203,7 @@ static void device_accept_gatt_profiles(struct btd_device *device)
GSList *l;
for (l = device->services; l != NULL; l = g_slist_next(l))
- service_accept(l->data);
+ service_accept(l->data, get_initiator(device));
}
static void device_remove_gatt_service(struct btd_device *device,
@@ -5899,6 +5911,8 @@ int device_connect_le(struct btd_device *dev)
/* Keep this, so we can cancel the connection */
dev->att_io = io;
+ /* Set as initiator */
+ dev->le_state.initiator = true;
return 0;
}