Bluetooth: Update the connections address from IRK

When a connection occurs it may have happened with an RPA. If so,
check if there's a matching IRK available and update the connection
address with the Identity Address (stored together with the IRK).

Change-Id: I3d995a35171b514ec1902fce617e8e7d6770e785
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2015-06-01 00:20:14 +07:00 committed by Anas Nashif
commit a6f18d7cc4

View file

@ -503,6 +503,24 @@ static void hci_num_completed_packets(struct bt_buf *buf)
}
}
static void copy_id_addr(struct bt_conn *conn, const bt_addr_le_t *addr)
{
struct bt_keys *keys;
/* If we have a keys struct we already know the identity */
if (conn->keys) {
return;
}
keys = bt_keys_find_irk(addr);
if (keys) {
bt_addr_le_copy(&conn->dst, &keys->addr);
conn->keys = keys;
} else {
bt_addr_le_copy(&conn->dst, addr);
}
}
static void le_conn_complete(struct bt_buf *buf)
{
struct bt_hci_evt_le_conn_complete *evt = (void *)buf->data;
@ -524,7 +542,7 @@ static void le_conn_complete(struct bt_buf *buf)
conn->src.type = BT_ADDR_LE_PUBLIC;
memcpy(conn->src.val, dev.bdaddr.val, sizeof(dev.bdaddr.val));
bt_addr_le_copy(&conn->dst, &evt->peer_addr);
copy_id_addr(conn, &evt->peer_addr);
conn->le_conn_interval = sys_le16_to_cpu(evt->interval);
bt_l2cap_connected(conn);