Bluetooth: Add MGMT interface for setting IRK 08/97908/8
authorh.sandeep <h.sandeep@samsung.com>
Tue, 15 Nov 2016 09:12:18 +0000 (14:42 +0530)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Tue, 22 Nov 2016 05:43:35 +0000 (14:43 +0900)
It is required to set IRK from BlueZ if privacy feature is disabled,
so this patch adds setting IRK interface to MGMT.

Change-Id: I2343ce34c894ad24557218ed41b61151caa8a1a5
Signed-off-by: h.sandeep <h.sandeep@samsung.com>
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
include/net/bluetooth/mgmt_tizen.h
net/bluetooth/mgmt.c

index 4afb984..322c2a7 100644 (file)
@@ -227,6 +227,12 @@ struct mgmt_cp_set_dev_rpa_res_support {
 } __packed;
 #define MGMT_OP_SET_DEV_RPA_RES_SUPPORT_SIZE   8
 
+#define MGMT_OP_SET_IRK                                (TIZEN_OP_CODE_BASE + 0x1A)
+struct mgmt_cp_set_irk {
+       uint8_t irk[16];
+} __packed;
+#define MGMT_SET_IRK_SIZE                      16
+
 /* BEGIN TIZEN_Bluetooth :: name update changes */
 #define MGMT_EV_DEVICE_NAME_UPDATE             (TIZEN_EV_BASE + 0x01)
 struct mgmt_ev_device_name_update {
index e6c8ff3..f4f556a 100644 (file)
@@ -5266,6 +5266,31 @@ unlocked:
        hci_dev_unlock(hdev);
        return err;
 }
+
+static int set_irk(struct sock *sk, struct hci_dev *hdev, void *cp_data,
+                  u16 len)
+{
+       struct mgmt_cp_set_irk *cp = cp_data;
+       int err;
+
+       BT_DBG("request for %s", hdev->name);
+
+       hci_dev_lock(hdev);
+
+       if (!lmp_le_capable(hdev)) {
+               err = cmd_status(sk, hdev->id, MGMT_OP_SET_IRK,
+                                MGMT_STATUS_NOT_SUPPORTED);
+               goto unlocked;
+       }
+
+       memcpy(hdev->irk, cp->irk, sizeof(hdev->irk));
+
+       err = cmd_complete(sk, hdev->id, MGMT_OP_SET_IRK, 0, NULL, 0);
+
+unlocked:
+       hci_dev_unlock(hdev);
+       return err;
+}
 /* END TIZEN_Bluetooth */
 #endif
 
@@ -8478,6 +8503,7 @@ static const struct mgmt_handler tizen_mgmt_handlers[] = {
        { set_le_data_length_params, false,
                                   MGMT_LE_SET_DATA_LENGTH_SIZE },
        { set_dev_rpa_res_support, false, MGMT_OP_SET_DEV_RPA_RES_SUPPORT_SIZE },
+       { set_irk,                 false, MGMT_SET_IRK_SIZE },
 };
 #endif