diff mbox series

[5/7] Bluetooth: LL Privacy Check and Update the Resolving List

Message ID 20200312100754.3445-6-sathish.narasimman@intel.com
State New
Headers show
Series [1/7] Bluetooth: LL Privacy Delete Store Resolving list | expand

Commit Message

Sathish Narasimman March 12, 2020, 10:07 a.m. UTC
This patch is an helper function which will be usefull to check
the Local Resolving list and update the controller Resolving list
during le_create_conn , le_directed_adv.

Signed-off-by: Sathish Narsimman <sathish.narasimman@intel.com>
Signed-off-by: Joy Shermin <shermin.joy@intel.com>
---
 net/bluetooth/hci_request.c | 21 +++++++++++++++++++++
 net/bluetooth/hci_request.h |  2 ++
 2 files changed, 23 insertions(+)
diff mbox series

Patch

diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index e17db3103a3d..6b685cdc7de5 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -1015,6 +1015,27 @@  void hci_req_update_resolving_list_local_irk(struct hci_dev *hdev)
 	hci_req_run(&req, NULL);
 }
 
+void hci_req_check_and_update_resolving_list(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr)
+{
+	struct smp_irk *irk;
+
+	BT_DBG("");
+
+	/* Nothing to be done if LL privacy is not supported */
+	if ( !(hdev->le_features[0] & HCI_LE_LL_PRIVACY) )
+		return;
+
+	if ( !hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION) &&
+	    ( hci_dev_test_flag(hdev, HCI_LE_ADV) ||
+	      hci_dev_test_flag(hdev, HCI_LE_SCAN) ||
+	      hci_lookup_le_connect(hdev) ) )
+		return;
+
+	irk = hci_find_irk_by_addr(hdev, bdaddr, type);
+	if (irk)
+		hci_req_update_resolving_list(hdev, irk->addr_type, &irk->bdaddr, irk->val);
+}
+
 void hci_load_resolving_list (struct hci_dev *hdev)
 {
 	struct smp_irk *irk;
diff --git a/net/bluetooth/hci_request.h b/net/bluetooth/hci_request.h
index 0e81614d235e..92a71f35543b 100644
--- a/net/bluetooth/hci_request.h
+++ b/net/bluetooth/hci_request.h
@@ -90,6 +90,8 @@  void __hci_req_clear_ext_adv_sets(struct hci_request *req);
 int hci_get_random_address(struct hci_dev *hdev, bool require_privacy,
 			   bool use_rpa, struct adv_info *adv_instance,
 			   u8 *own_addr_type, bdaddr_t *rand_addr);
+void hci_req_check_and_update_resolving_list(struct hci_dev *hdev, u8 addr_type,
+					     bdaddr_t *bdaddr);
 
 void __hci_req_update_class(struct hci_request *req);