aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAndre Guedes <andre.guedes@openbossa.org>2012-04-24 20:02:54 -0400
committerGustavo Padovan <gustavo@padovan.org>2012-05-09 00:40:45 -0400
commitb12f62cfd9f46ac70013ce661640174b489efd39 (patch)
tree5ad852475d40051fa86fe613d2b9990cd816656b /net
parent31f7956c6648fbae9c9550e91d1c348d28276309 (diff)
Bluetooth: Add dst_type parameter to hci_connect
This patch adds the dst_type parameter to hci_connect function. Instead of searching the address type in advertising cache, we use the dst_type parameter to establish LE connections. The dst_type is ignored for BR/EDR connection establishment. Signed-off-by: Andre Guedes <andre.guedes@openbossa.org> Acked-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/hci_conn.c11
-rw-r--r--net/bluetooth/l2cap_core.c8
-rw-r--r--net/bluetooth/mgmt.c8
-rw-r--r--net/bluetooth/sco.c3
4 files changed, 13 insertions, 17 deletions
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 8f352cd1745a..a3ee1a929a6c 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -513,7 +513,8 @@ EXPORT_SYMBOL(hci_get_route);
513 513
514/* Create SCO, ACL or LE connection. 514/* Create SCO, ACL or LE connection.
515 * Device _must_ be locked */ 515 * Device _must_ be locked */
516struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 sec_level, __u8 auth_type) 516struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
517 __u8 dst_type, __u8 sec_level, __u8 auth_type)
517{ 518{
518 struct hci_conn *acl; 519 struct hci_conn *acl;
519 struct hci_conn *sco; 520 struct hci_conn *sco;
@@ -522,19 +523,13 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8
522 BT_DBG("%s dst %s", hdev->name, batostr(dst)); 523 BT_DBG("%s dst %s", hdev->name, batostr(dst));
523 524
524 if (type == LE_LINK) { 525 if (type == LE_LINK) {
525 struct adv_entry *entry = NULL;
526
527 le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst); 526 le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst);
528 if (!le) { 527 if (!le) {
529 entry = hci_find_adv_entry(hdev, dst);
530 if (!entry)
531 return ERR_PTR(-EHOSTUNREACH);
532
533 le = hci_conn_add(hdev, LE_LINK, dst); 528 le = hci_conn_add(hdev, LE_LINK, dst);
534 if (!le) 529 if (!le)
535 return ERR_PTR(-ENOMEM); 530 return ERR_PTR(-ENOMEM);
536 531
537 le->dst_type = entry->bdaddr_type; 532 le->dst_type = bdaddr_to_le(dst_type);
538 hci_le_connect(le); 533 hci_le_connect(le);
539 } 534 }
540 535
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 97af2b4f6238..61af06d35335 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1479,11 +1479,11 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, bdaddr_t *d
1479 auth_type = l2cap_get_auth_type(chan); 1479 auth_type = l2cap_get_auth_type(chan);
1480 1480
1481 if (chan->dcid == L2CAP_CID_LE_DATA) 1481 if (chan->dcid == L2CAP_CID_LE_DATA)
1482 hcon = hci_connect(hdev, LE_LINK, dst, 1482 hcon = hci_connect(hdev, LE_LINK, dst, BDADDR_LE_RANDOM,
1483 chan->sec_level, auth_type); 1483 chan->sec_level, auth_type);
1484 else 1484 else
1485 hcon = hci_connect(hdev, ACL_LINK, dst, 1485 hcon = hci_connect(hdev, ACL_LINK, dst, BDADDR_BREDR,
1486 chan->sec_level, auth_type); 1486 chan->sec_level, auth_type);
1487 1487
1488 if (IS_ERR(hcon)) { 1488 if (IS_ERR(hcon)) {
1489 err = PTR_ERR(hcon); 1489 err = PTR_ERR(hcon);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 4e26c2585817..9038118d37a3 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1903,11 +1903,11 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data,
1903 auth_type = HCI_AT_DEDICATED_BONDING_MITM; 1903 auth_type = HCI_AT_DEDICATED_BONDING_MITM;
1904 1904
1905 if (cp->addr.type == BDADDR_BREDR) 1905 if (cp->addr.type == BDADDR_BREDR)
1906 conn = hci_connect(hdev, ACL_LINK, &cp->addr.bdaddr, sec_level, 1906 conn = hci_connect(hdev, ACL_LINK, &cp->addr.bdaddr,
1907 auth_type); 1907 cp->addr.type, sec_level, auth_type);
1908 else 1908 else
1909 conn = hci_connect(hdev, LE_LINK, &cp->addr.bdaddr, sec_level, 1909 conn = hci_connect(hdev, LE_LINK, &cp->addr.bdaddr,
1910 auth_type); 1910 cp->addr.type, sec_level, auth_type);
1911 1911
1912 memset(&rp, 0, sizeof(rp)); 1912 memset(&rp, 0, sizeof(rp));
1913 bacpy(&rp.addr.bdaddr, &cp->addr.bdaddr); 1913 bacpy(&rp.addr.bdaddr, &cp->addr.bdaddr);
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index bf1af0b1497e..cbdd313659a7 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -193,7 +193,8 @@ static int sco_connect(struct sock *sk)
193 else 193 else
194 type = SCO_LINK; 194 type = SCO_LINK;
195 195
196 hcon = hci_connect(hdev, type, dst, BT_SECURITY_LOW, HCI_AT_NO_BONDING); 196 hcon = hci_connect(hdev, type, dst, BDADDR_BREDR, BT_SECURITY_LOW,
197 HCI_AT_NO_BONDING);
197 if (IS_ERR(hcon)) { 198 if (IS_ERR(hcon)) {
198 err = PTR_ERR(hcon); 199 err = PTR_ERR(hcon);
199 goto done; 200 goto done;