Bluetooth: BR/EDR: Reuse link key if available
When link key exists in keys database and subsequent connection wants to use it, reassign such link key to corresponding connection object. < HCI Command: Accept Connection Request (0x01|0x0009) plen 7 Address: 68:17:29:CF:5D:86 (Intel Corporate) Role: Slave (0x01) > HCI Event: Command Status (0x0f) plen 4 Accept Connection Request (0x01|0x0009) ncmd 1 Status: Success (0x00) > HCI Event: Connect Complete (0x03) plen 11 Status: Success (0x00) Handle: 72 Address: 68:17:29:CF:5D:86 (Intel Corporate) Link type: ACL (0x01) Encryption: Disabled (0x00) > HCI Event: Link Key Request (0x17) plen 6 Address: 68:17:29:CF:5D:86 (Intel Corporate) < HCI Command: Link Key Request Reply (0x01|0x000b) plen 22 Address: 68:17:29:CF:5D:86 (Intel Corporate) Link key: 62329a517ec1664361c6578e67e71f22 > HCI Event: Command Complete (0x0e) plen 10 Link Key Request Reply (0x01|0x000b) ncmd 1 Status: Success (0x00) Address: 68:17:29:CF:5D:86 (Intel Corporate) > HCI Event: Encryption Change (0x08) plen 4 Status: Success (0x00) Handle: 72 Encryption: Enabled with E0 (0x01) Change-Id: I409904dc739e600d3418f7d3ffb1a2dc9ea3a411 Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
This commit is contained in:
parent
d4edd35d26
commit
3f6fdacdc6
1 changed files with 16 additions and 5 deletions
|
@ -1100,18 +1100,29 @@ static void link_key_reply(const bt_addr_t *bdaddr, const uint8_t *lk)
|
||||||
static void link_key_req(struct net_buf *buf)
|
static void link_key_req(struct net_buf *buf)
|
||||||
{
|
{
|
||||||
struct bt_hci_evt_link_key_req *evt = (void *)buf->data;
|
struct bt_hci_evt_link_key_req *evt = (void *)buf->data;
|
||||||
struct bt_keys *keys;
|
struct bt_conn *conn;
|
||||||
|
|
||||||
BT_DBG("%s", bt_addr_str(&evt->bdaddr));
|
BT_DBG("%s", bt_addr_str(&evt->bdaddr));
|
||||||
|
|
||||||
keys = bt_keys_find_link_key(&evt->bdaddr);
|
conn = bt_conn_lookup_addr_br(&evt->bdaddr);
|
||||||
if (!keys) {
|
if (!conn) {
|
||||||
BT_ERR("Can't find keys for %s", bt_addr_str(&evt->bdaddr));
|
BT_ERR("Can't find conn for %s", bt_addr_str(&evt->bdaddr));
|
||||||
link_key_neg_reply(&evt->bdaddr);
|
link_key_neg_reply(&evt->bdaddr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
link_key_reply(&evt->bdaddr, keys->link_key.val);
|
if (!conn->keys) {
|
||||||
|
conn->keys = bt_keys_find_link_key(&evt->bdaddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!conn->keys) {
|
||||||
|
link_key_neg_reply(&evt->bdaddr);
|
||||||
|
bt_conn_unref(conn);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
link_key_reply(&evt->bdaddr, conn->keys->link_key.val);
|
||||||
|
bt_conn_unref(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void io_capa_resp(struct net_buf *buf)
|
static void io_capa_resp(struct net_buf *buf)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue