Commit 662e8820 authored by Marcel Holtmann's avatar Marcel Holtmann Committed by Johan Hedberg

Bluetooth: Store source address of HCI connections

The source addressed was based on the public address of the HCI device,
but with LE connections this not always the case. For example single
mode LE-only controllers would use a static random address. And this
address is configured by userspace.

To not complicate the lookup of what kind of address is in use, store
the correct source address for each HCI connection.
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
parent e7c4096e
...@@ -300,6 +300,7 @@ struct hci_conn { ...@@ -300,6 +300,7 @@ struct hci_conn {
bdaddr_t dst; bdaddr_t dst;
__u8 dst_type; __u8 dst_type;
bdaddr_t src;
__u8 src_type; __u8 src_type;
__u16 handle; __u16 handle;
__u16 state; __u16 state;
......
...@@ -381,6 +381,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst) ...@@ -381,6 +381,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
return NULL; return NULL;
bacpy(&conn->dst, dst); bacpy(&conn->dst, dst);
bacpy(&conn->src, &hdev->bdaddr);
conn->hdev = hdev; conn->hdev = hdev;
conn->type = type; conn->type = type;
conn->mode = HCI_CM_ACTIVE; conn->mode = HCI_CM_ACTIVE;
...@@ -624,10 +625,12 @@ static struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, ...@@ -624,10 +625,12 @@ static struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
else else
conn->dst_type = ADDR_LE_DEV_RANDOM; conn->dst_type = ADDR_LE_DEV_RANDOM;
if (bacmp(&hdev->bdaddr, BDADDR_ANY)) if (bacmp(&conn->src, BDADDR_ANY)) {
conn->src_type = ADDR_LE_DEV_PUBLIC; conn->src_type = ADDR_LE_DEV_PUBLIC;
else } else {
bacpy(&conn->src, &hdev->static_addr);
conn->src_type = ADDR_LE_DEV_RANDOM; conn->src_type = ADDR_LE_DEV_RANDOM;
}
conn->state = BT_CONNECT; conn->state = BT_CONNECT;
conn->out = true; conn->out = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment