diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2014-03-22 19:28:45 +0200 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2014-03-22 19:34:32 +0200 |
commit | f6a403f084e683fb8ab1601f7cb7cbc1a4f6cd76 (patch) | |
tree | 473598d0f2916084bc8cf1506470dcad4896ec13 /src/device.c | |
parent | 6f3c15162f4c7b58c6df8290a9ba0f1b6bdc7f03 (diff) | |
download | bluez-f6a403f084e683fb8ab1601f7cb7cbc1a4f6cd76.tar.gz |
core: Add function to look up devices also by their type
Diffstat (limited to 'src/device.c')
-rw-r--r-- | src/device.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/device.c b/src/device.c index a69cfa6f0..1a60b96f1 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) { |