summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorh.sandeep <h.sandeep@samsung.com>2016-11-15 16:38:58 +0530
committerSeung-Woo Kim <sw0312.kim@samsung.com>2016-12-14 13:53:31 +0900
commitd0e66637e6bb0c6bef60af86389515ec55f0b61d (patch)
treedf1fed154bad300b14aee4df67ca8d48072c0755 /net
parent4905f405a5119a25a7e85be423153b671c86b016 (diff)
Bluetooth: add to support LE privacy 1.2 & MGMT to load device RPA resolution
RPA resolution support of peer device to be checked before starting directed advertising. This patch load the resolution support info of device and check before starting directed advertising. Change-Id: Ia1e7b2ae1ef9d5e12877d96759cb9089b52c20b7 Signed-off-by: paras.kumar <paras.kumar@samsung.com> Signed-off-by: h.sandeep <h.sandeep@samsung.com> [Fix coding style and adjust commit-msg] Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/hci_conn.c28
-rw-r--r--net/bluetooth/hci_core.c15
-rw-r--r--net/bluetooth/mgmt.c41
3 files changed, 84 insertions, 0 deletions
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 1848ff8e93da..359ff4976805 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -724,13 +724,22 @@ static void hci_req_add_le_create_conn(struct hci_request *req,
conn->state = BT_CONNECT;
}
+#ifdef TIZEN_BT
+static void hci_req_directed_advertising(struct hci_request *req,
+ struct hci_conn *conn,
+ u8 rpa_res_support)
+#else
static void hci_req_directed_advertising(struct hci_request *req,
struct hci_conn *conn)
+#endif
{
struct hci_dev *hdev = req->hdev;
struct hci_cp_le_set_adv_param cp;
u8 own_addr_type;
u8 enable;
+#ifdef TIZEN_BT
+ bool require_privacy;
+#endif
/* Clear the HCI_LE_ADV bit temporarily so that the
* hci_update_random_address knows that it's safe to go ahead
@@ -739,11 +748,26 @@ static void hci_req_directed_advertising(struct hci_request *req,
*/
hci_dev_clear_flag(hdev, HCI_LE_ADV);
+#ifdef TIZEN_BT
+ /* Set require_privacy to true if remote device is able to
+ * resolve RPA (As per BT spec 4.2 & Enhanced privacy feature)
+ * otherwise, set require_privacy to false so that the remote
+ * device has a chance of identifying us.
+ */
+ if (rpa_res_support)
+ require_privacy = true;
+ else
+ require_privacy = false;
+
+ if (hci_update_random_address(req, require_privacy, &own_addr_type) < 0)
+ return;
+#else
/* Set require_privacy to false so that the remote device has a
* chance of identifying us.
*/
if (hci_update_random_address(req, false, &own_addr_type) < 0)
return;
+#endif
memset(&cp, 0, sizeof(cp));
cp.type = LE_ADV_DIRECT_IND;
@@ -854,7 +878,11 @@ struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
return ERR_PTR(-EBUSY);
}
+#ifdef TIZEN_BT
+ hci_req_directed_advertising(&req, conn, irk->rpa_res_support);
+#else
hci_req_directed_advertising(&req, conn);
+#endif
goto create_conn;
}
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 39f2026dc477..0d066020e77e 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2545,6 +2545,21 @@ void hci_remove_irk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type)
}
}
+#ifdef TIZEN_BT
+int hci_set_rpa_res_support(struct hci_dev *hdev, bdaddr_t *bdaddr,
+ u8 addr_type, u8 enabled)
+{
+ struct smp_irk *irk;
+
+ irk = hci_find_irk_by_addr(hdev, bdaddr, addr_type);
+ if (!irk)
+ return -ENOENT;
+
+ irk->rpa_res_support = enabled;
+
+ return 0;
+}
+#endif
bool hci_bdaddr_is_paired(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type)
{
struct smp_ltk *k;
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 3fbcfdbe219d..185513200931 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -7834,6 +7834,46 @@ unlocked:
hci_dev_unlock(hdev);
return err;
}
+
+static int set_dev_rpa_res_support(struct sock *sk, struct hci_dev *hdev,
+ void *data, u16 len)
+{
+ struct mgmt_cp_set_dev_rpa_res_support *cp = data;
+ int err;
+
+ BT_DBG("Set resolve RPA as %u for %s", cp->res_support, hdev->name);
+
+ hci_dev_lock(hdev);
+
+ if (!lmp_le_capable(hdev)) {
+ err = mgmt_cmd_status(sk, hdev->id,
+ MGMT_OP_SET_DEV_RPA_RES_SUPPORT,
+ MGMT_STATUS_NOT_SUPPORTED);
+ goto unlocked;
+ }
+
+ if (!hdev_is_powered(hdev)) {
+ err = mgmt_cmd_status(sk, hdev->id,
+ MGMT_OP_SET_DEV_RPA_RES_SUPPORT,
+ MGMT_STATUS_REJECTED);
+ goto unlocked;
+ }
+
+ if (hci_set_rpa_res_support(hdev, &cp->addr.bdaddr, cp->addr.type,
+ cp->res_support)) {
+ err = mgmt_cmd_complete(sk, hdev->id,
+ MGMT_OP_SET_DEV_RPA_RES_SUPPORT,
+ MGMT_STATUS_NOT_PAIRED, NULL, 0);
+ goto unlocked;
+ }
+
+ err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_SET_DEV_RPA_RES_SUPPORT,
+ MGMT_STATUS_SUCCESS, NULL, 0);
+
+unlocked:
+ hci_dev_unlock(hdev);
+ return err;
+}
#endif /* TIZEN_BT */
static bool ltk_is_valid(struct mgmt_ltk_info *key)
@@ -9736,6 +9776,7 @@ static const struct hci_mgmt_handler tizen_mgmt_handlers[] = {
{ set_le_data_length_params,
MGMT_LE_SET_DATA_LENGTH_SIZE },
{ set_irk, MGMT_SET_IRK_SIZE },
+ { set_dev_rpa_res_support, MGMT_OP_SET_DEV_RPA_RES_SUPPORT_SIZE },
};
#endif