diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2013-10-13 06:57:39 -0400 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2013-10-13 10:46:31 -0400 |
commit | e7c4096e16f0e362c6cf902baab0de37ebfc1266 (patch) | |
tree | dc3c132857160d10be00f96eb6e2667a9682ba0c | |
parent | 79d95a19a445f5758571b3342064f2c1e40b6c5f (diff) |
Bluetooth: Store the source address type of LE connections
When establishing LE connections, it is possible to use a public
address (if available) or a random address. The type of address
is only known when creating connections, so make sure it is
stored in hci_conn structure.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
-rw-r--r-- | include/net/bluetooth/hci_core.h | 1 | ||||
-rw-r--r-- | net/bluetooth/hci_conn.c | 11 |
2 files changed, 8 insertions, 4 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 7889495da843..714da9ea465e 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
@@ -300,6 +300,7 @@ struct hci_conn { | |||
300 | 300 | ||
301 | bdaddr_t dst; | 301 | bdaddr_t dst; |
302 | __u8 dst_type; | 302 | __u8 dst_type; |
303 | __u8 src_type; | ||
303 | __u16 handle; | 304 | __u16 handle; |
304 | __u16 state; | 305 | __u16 state; |
305 | __u8 mode; | 306 | __u8 mode; |
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index bb32f48b88f9..d9f7f93b813e 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c | |||
@@ -566,10 +566,7 @@ static int hci_create_le_conn(struct hci_conn *conn) | |||
566 | cp.scan_window = cpu_to_le16(hdev->le_scan_window); | 566 | cp.scan_window = cpu_to_le16(hdev->le_scan_window); |
567 | bacpy(&cp.peer_addr, &conn->dst); | 567 | bacpy(&cp.peer_addr, &conn->dst); |
568 | cp.peer_addr_type = conn->dst_type; | 568 | cp.peer_addr_type = conn->dst_type; |
569 | if (bacmp(&hdev->bdaddr, BDADDR_ANY)) | 569 | cp.own_address_type = conn->src_type; |
570 | cp.own_address_type = ADDR_LE_DEV_PUBLIC; | ||
571 | else | ||
572 | cp.own_address_type = ADDR_LE_DEV_RANDOM; | ||
573 | cp.conn_interval_min = __constant_cpu_to_le16(0x0028); | 570 | cp.conn_interval_min = __constant_cpu_to_le16(0x0028); |
574 | cp.conn_interval_max = __constant_cpu_to_le16(0x0038); | 571 | cp.conn_interval_max = __constant_cpu_to_le16(0x0038); |
575 | cp.supervision_timeout = __constant_cpu_to_le16(0x002a); | 572 | cp.supervision_timeout = __constant_cpu_to_le16(0x002a); |
@@ -626,6 +623,12 @@ static struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, | |||
626 | conn->dst_type = ADDR_LE_DEV_PUBLIC; | 623 | conn->dst_type = ADDR_LE_DEV_PUBLIC; |
627 | else | 624 | else |
628 | conn->dst_type = ADDR_LE_DEV_RANDOM; | 625 | conn->dst_type = ADDR_LE_DEV_RANDOM; |
626 | |||
627 | if (bacmp(&hdev->bdaddr, BDADDR_ANY)) | ||
628 | conn->src_type = ADDR_LE_DEV_PUBLIC; | ||
629 | else | ||
630 | conn->src_type = ADDR_LE_DEV_RANDOM; | ||
631 | |||
629 | conn->state = BT_CONNECT; | 632 | conn->state = BT_CONNECT; |
630 | conn->out = true; | 633 | conn->out = true; |
631 | conn->link_mode |= HCI_LM_MASTER; | 634 | conn->link_mode |= HCI_LM_MASTER; |