Skip to content

Commit

Permalink
Bluetooth: Add support for pairing via mgmt over LE
Browse files Browse the repository at this point in the history
Using the advertising cache we are able to infer the type
of the remote device, and so trigger pairing over the correct
link type.

Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
  • Loading branch information
vcgomes authored and Gustavo F. Padovan committed Sep 21, 2011
1 parent 454d48f commit 7a512d0
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions net/bluetooth/mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,7 @@ static int pair_device(struct sock *sk, u16 index, unsigned char *data, u16 len)
struct hci_dev *hdev;
struct mgmt_cp_pair_device *cp;
struct pending_cmd *cmd;
struct adv_entry *entry;
u8 sec_level, auth_type;
struct hci_conn *conn;
int err;
Expand All @@ -1372,7 +1373,14 @@ static int pair_device(struct sock *sk, u16 index, unsigned char *data, u16 len)
auth_type = HCI_AT_DEDICATED_BONDING_MITM;
}

conn = hci_connect(hdev, ACL_LINK, &cp->bdaddr, sec_level, auth_type);
entry = hci_find_adv_entry(hdev, &cp->bdaddr);
if (entry)
conn = hci_connect(hdev, LE_LINK, &cp->bdaddr, sec_level,
auth_type);
else
conn = hci_connect(hdev, ACL_LINK, &cp->bdaddr, sec_level,
auth_type);

if (IS_ERR(conn)) {
err = PTR_ERR(conn);
goto unlock;
Expand All @@ -1391,7 +1399,10 @@ static int pair_device(struct sock *sk, u16 index, unsigned char *data, u16 len)
goto unlock;
}

conn->connect_cfm_cb = pairing_complete_cb;
/* For LE, just connecting isn't a proof that the pairing finished */
if (!entry)
conn->connect_cfm_cb = pairing_complete_cb;

conn->security_cfm_cb = pairing_complete_cb;
conn->disconn_cfm_cb = pairing_complete_cb;
conn->io_capability = cp->io_cap;
Expand Down

0 comments on commit 7a512d0

Please sign in to comment.