Bluetooth: Add convenience function for fetching IRKs
authorJohan Hedberg <johan.hedberg@intel.com>
Tue, 18 Feb 2014 15:14:36 +0000 (17:14 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 18 Feb 2014 16:58:21 +0000 (08:58 -0800)
There are many situations where we need to check if an LE address is an
RPA and if so try to look up the IRK for it. To simplify such cases this
patch adds a convenience function for the job.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
include/net/bluetooth/hci_core.h

index ac468de11cb727c59c5217437db7322df9104db5..4461c00512289cfca25f0174cff46529f6766659 100644 (file)
@@ -1083,6 +1083,15 @@ static inline bool hci_bdaddr_is_rpa(bdaddr_t *bdaddr, u8 addr_type)
        return false;
 }
 
+static inline struct smp_irk *hci_get_irk(struct hci_dev *hdev,
+                                         bdaddr_t *bdaddr, u8 addr_type)
+{
+       if (!hci_bdaddr_is_rpa(bdaddr, addr_type))
+               return NULL;
+
+       return hci_find_irk_by_rpa(hdev, bdaddr);
+}
+
 int hci_register_cb(struct hci_cb *hcb);
 int hci_unregister_cb(struct hci_cb *hcb);