Diff between 6f3c15162f4c7b58c6df8290a9ba0f1b6bdc7f03 and f6a403f084e683fb8ab1601f7cb7cbc1a4f6cd76

Changed Files

File Additions Deletions Status
src/device.c +21 -0 modified
src/device.h +8 -0 modified

Full Patch

diff --git a/src/device.c b/src/device.c
index a69cfa6..1a60b96 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2662,6 +2662,27 @@ int device_bdaddr_cmp(gconstpointer a, gconstpointer b)
 	return bacmp(&device->bdaddr, bdaddr);
 }
 
+int device_addr_type_cmp(gconstpointer a, gconstpointer b)
+{
+	const struct btd_device *dev = a;
+	const struct device_addr_type *addr = b;
+
+	if (addr->bdaddr_type == BDADDR_BREDR) {
+		if (!dev->bredr)
+			return -1;
+
+		return bacmp(&dev->bdaddr, &addr->bdaddr);
+	}
+
+	if (!dev->le)
+	       return -1;
+
+	if (addr->bdaddr_type != dev->bdaddr_type)
+		return -1;
+
+	return bacmp(&dev->bdaddr, &addr->bdaddr);
+}
+
 static gboolean record_has_uuid(const sdp_record_t *rec,
 				const char *profile_uuid)
 {
diff --git a/src/device.h b/src/device.h
index 66b257d..30e2d5d 100644
--- a/src/device.h
+++ b/src/device.h
@@ -51,6 +51,14 @@ uint16_t btd_device_get_version(struct btd_device *device);
 void device_remove(struct btd_device *device, gboolean remove_stored);
 int device_address_cmp(gconstpointer a, gconstpointer b);
 int device_bdaddr_cmp(gconstpointer a, gconstpointer b);
+
+/* Struct used by device_addr_type_cmp() */
+struct device_addr_type {
+	bdaddr_t bdaddr;
+	uint8_t bdaddr_type;
+};
+
+int device_addr_type_cmp(gconstpointer a, gconstpointer b);
 GSList *btd_device_get_uuids(struct btd_device *device);
 void device_probe_profiles(struct btd_device *device, GSList *profiles);
 const sdp_record_t *btd_device_get_record(struct btd_device *device,