提交 6928a924 编写于 作者: J Johan Hedberg 提交者: Marcel Holtmann

Bluetooth: Store address type with OOB data

To be able to support OOB data for LE pairing we need to store the
address type of the remote device. This patch extends the relevant
functions and data types with a bdaddr_type variable.
Signed-off-by: NJohan Hedberg <johan.hedberg@intel.com>
Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
上级 81328d5c
...@@ -140,6 +140,7 @@ struct link_key { ...@@ -140,6 +140,7 @@ struct link_key {
struct oob_data { struct oob_data {
struct list_head list; struct list_head list;
bdaddr_t bdaddr; bdaddr_t bdaddr;
u8 bdaddr_type;
u8 hash192[16]; u8 hash192[16];
u8 rand192[16]; u8 rand192[16];
u8 hash256[16]; u8 hash256[16];
...@@ -942,11 +943,12 @@ void hci_smp_irks_clear(struct hci_dev *hdev); ...@@ -942,11 +943,12 @@ void hci_smp_irks_clear(struct hci_dev *hdev);
void hci_remote_oob_data_clear(struct hci_dev *hdev); void hci_remote_oob_data_clear(struct hci_dev *hdev);
struct oob_data *hci_find_remote_oob_data(struct hci_dev *hdev, struct oob_data *hci_find_remote_oob_data(struct hci_dev *hdev,
bdaddr_t *bdaddr); bdaddr_t *bdaddr, u8 bdaddr_type);
int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr,
u8 *hash192, u8 *rand192, u8 bdaddr_type, u8 *hash192, u8 *rand192,
u8 *hash256, u8 *rand256); u8 *hash256, u8 *rand256);
int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr); int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr,
u8 bdaddr_type);
void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb); void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);
......
...@@ -2160,7 +2160,7 @@ u32 hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, ...@@ -2160,7 +2160,7 @@ u32 hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data,
BT_DBG("cache %p, %pMR", cache, &data->bdaddr); BT_DBG("cache %p, %pMR", cache, &data->bdaddr);
hci_remove_remote_oob_data(hdev, &data->bdaddr); hci_remove_remote_oob_data(hdev, &data->bdaddr, BDADDR_BREDR);
if (!data->ssp_mode) if (!data->ssp_mode)
flags |= MGMT_DEV_FOUND_LEGACY_PAIRING; flags |= MGMT_DEV_FOUND_LEGACY_PAIRING;
...@@ -3479,26 +3479,31 @@ static void hci_cmd_timeout(struct work_struct *work) ...@@ -3479,26 +3479,31 @@ static void hci_cmd_timeout(struct work_struct *work)
} }
struct oob_data *hci_find_remote_oob_data(struct hci_dev *hdev, struct oob_data *hci_find_remote_oob_data(struct hci_dev *hdev,
bdaddr_t *bdaddr) bdaddr_t *bdaddr, u8 bdaddr_type)
{ {
struct oob_data *data; struct oob_data *data;
list_for_each_entry(data, &hdev->remote_oob_data, list) list_for_each_entry(data, &hdev->remote_oob_data, list) {
if (bacmp(bdaddr, &data->bdaddr) == 0) if (bacmp(bdaddr, &data->bdaddr) != 0)
return data; continue;
if (data->bdaddr_type != bdaddr_type)
continue;
return data;
}
return NULL; return NULL;
} }
int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr) int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr,
u8 bdaddr_type)
{ {
struct oob_data *data; struct oob_data *data;
data = hci_find_remote_oob_data(hdev, bdaddr); data = hci_find_remote_oob_data(hdev, bdaddr, bdaddr_type);
if (!data) if (!data)
return -ENOENT; return -ENOENT;
BT_DBG("%s removing %pMR", hdev->name, bdaddr); BT_DBG("%s removing %pMR (%u)", hdev->name, bdaddr, bdaddr_type);
list_del(&data->list); list_del(&data->list);
kfree(data); kfree(data);
...@@ -3517,18 +3522,19 @@ void hci_remote_oob_data_clear(struct hci_dev *hdev) ...@@ -3517,18 +3522,19 @@ void hci_remote_oob_data_clear(struct hci_dev *hdev)
} }
int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr,
u8 *hash192, u8 *rand192, u8 bdaddr_type, u8 *hash192, u8 *rand192,
u8 *hash256, u8 *rand256) u8 *hash256, u8 *rand256)
{ {
struct oob_data *data; struct oob_data *data;
data = hci_find_remote_oob_data(hdev, bdaddr); data = hci_find_remote_oob_data(hdev, bdaddr, bdaddr_type);
if (!data) { if (!data) {
data = kmalloc(sizeof(*data), GFP_KERNEL); data = kmalloc(sizeof(*data), GFP_KERNEL);
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
bacpy(&data->bdaddr, bdaddr); bacpy(&data->bdaddr, bdaddr);
data->bdaddr_type = bdaddr_type;
list_add(&data->list, &hdev->remote_oob_data); list_add(&data->list, &hdev->remote_oob_data);
} }
......
...@@ -3773,7 +3773,7 @@ static void hci_io_capa_request_evt(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -3773,7 +3773,7 @@ static void hci_io_capa_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
cp.authentication = conn->auth_type; cp.authentication = conn->auth_type;
if (hci_find_remote_oob_data(hdev, &conn->dst) && if (hci_find_remote_oob_data(hdev, &conn->dst, BDADDR_BREDR) &&
(conn->out || test_bit(HCI_CONN_REMOTE_OOB, &conn->flags))) (conn->out || test_bit(HCI_CONN_REMOTE_OOB, &conn->flags)))
cp.oob_data = 0x01; cp.oob_data = 0x01;
else else
...@@ -4028,7 +4028,7 @@ static void hci_remote_oob_data_request_evt(struct hci_dev *hdev, ...@@ -4028,7 +4028,7 @@ static void hci_remote_oob_data_request_evt(struct hci_dev *hdev,
if (!test_bit(HCI_MGMT, &hdev->dev_flags)) if (!test_bit(HCI_MGMT, &hdev->dev_flags))
goto unlock; goto unlock;
data = hci_find_remote_oob_data(hdev, &ev->bdaddr); data = hci_find_remote_oob_data(hdev, &ev->bdaddr, BDADDR_BREDR);
if (data) { if (data) {
if (bredr_sc_enabled(hdev)) { if (bredr_sc_enabled(hdev)) {
struct hci_cp_remote_oob_ext_data_reply cp; struct hci_cp_remote_oob_ext_data_reply cp;
......
...@@ -3599,8 +3599,8 @@ static int add_remote_oob_data(struct sock *sk, struct hci_dev *hdev, ...@@ -3599,8 +3599,8 @@ static int add_remote_oob_data(struct sock *sk, struct hci_dev *hdev,
} }
err = hci_add_remote_oob_data(hdev, &cp->addr.bdaddr, err = hci_add_remote_oob_data(hdev, &cp->addr.bdaddr,
cp->hash, cp->rand, cp->addr.type, cp->hash,
NULL, NULL); cp->rand, NULL, NULL);
if (err < 0) if (err < 0)
status = MGMT_STATUS_FAILED; status = MGMT_STATUS_FAILED;
else else
...@@ -3621,8 +3621,9 @@ static int add_remote_oob_data(struct sock *sk, struct hci_dev *hdev, ...@@ -3621,8 +3621,9 @@ static int add_remote_oob_data(struct sock *sk, struct hci_dev *hdev,
} }
err = hci_add_remote_oob_data(hdev, &cp->addr.bdaddr, err = hci_add_remote_oob_data(hdev, &cp->addr.bdaddr,
cp->hash192, cp->rand192, cp->addr.type, cp->hash192,
cp->hash256, cp->rand256); cp->rand192, cp->hash256,
cp->rand256);
if (err < 0) if (err < 0)
status = MGMT_STATUS_FAILED; status = MGMT_STATUS_FAILED;
else else
...@@ -3663,7 +3664,7 @@ static int remove_remote_oob_data(struct sock *sk, struct hci_dev *hdev, ...@@ -3663,7 +3664,7 @@ static int remove_remote_oob_data(struct sock *sk, struct hci_dev *hdev,
goto done; goto done;
} }
err = hci_remove_remote_oob_data(hdev, &cp->addr.bdaddr); err = hci_remove_remote_oob_data(hdev, &cp->addr.bdaddr, cp->addr.type);
if (err < 0) if (err < 0)
status = MGMT_STATUS_INVALID_PARAMS; status = MGMT_STATUS_INVALID_PARAMS;
else else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册