Bluetooth: Store source address of HCI connections
authorMarcel Holtmann <marcel@holtmann.org>
Sun, 13 Oct 2013 12:23:59 +0000 (05:23 -0700)
committerJohan Hedberg <johan.hedberg@intel.com>
Sun, 13 Oct 2013 14:47:37 +0000 (17:47 +0300)
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: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
include/net/bluetooth/hci_core.h
net/bluetooth/hci_conn.c

index 714da9ea465efbcba4efddc4e8acb9b8c33e12e4..0326b160b89af55532132245a6c03033258a2952 100644 (file)
@@ -300,6 +300,7 @@ struct hci_conn {
 
        bdaddr_t        dst;
        __u8            dst_type;
+       bdaddr_t        src;
        __u8            src_type;
        __u16           handle;
        __u16           state;
index d9f7f93b813e757d1bf878d6cea53bc394d3e939..ff04b051792debd389e9935bae11a653c14e72e4 100644 (file)
@@ -381,6 +381,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
                return NULL;
 
        bacpy(&conn->dst, dst);
+       bacpy(&conn->src, &hdev->bdaddr);
        conn->hdev  = hdev;
        conn->type  = type;
        conn->mode  = HCI_CM_ACTIVE;
@@ -624,10 +625,12 @@ static struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst,
        else
                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;
-       else
+       } else {
+               bacpy(&conn->src, &hdev->static_addr);
                conn->src_type = ADDR_LE_DEV_RANDOM;
+       }
 
        conn->state = BT_CONNECT;
        conn->out = true;