aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2011-04-28 14:28:53 -0400
committerGustavo F. Padovan <padovan@profusion.mobi>2011-04-28 15:02:25 -0400
commit7a828908a026d801c6192fd32cfb35d6843f1539 (patch)
tree8c78e5c259afd46a055a77c276bf3f3518d495ef /net/bluetooth
parenta770bb5aea84ee2509d4775f9959665f96da3b9d (diff)
Bluetooth: Add automated SSP user confirmation responses
This patch adds automated negative and positive (auto-accept) responses for Secure Simple Pairing user confirmation requests. The responses are only sent if the HCI_MGMT flag is set in order not to confuse older user space versions (without management interface support). Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/hci_event.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 577d638600df..514e10e1e0ff 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -2483,14 +2483,47 @@ static inline void hci_user_confirm_request_evt(struct hci_dev *hdev,
2483 struct sk_buff *skb) 2483 struct sk_buff *skb)
2484{ 2484{
2485 struct hci_ev_user_confirm_req *ev = (void *) skb->data; 2485 struct hci_ev_user_confirm_req *ev = (void *) skb->data;
2486 int loc_mitm, rem_mitm;
2487 struct hci_conn *conn;
2486 2488
2487 BT_DBG("%s", hdev->name); 2489 BT_DBG("%s", hdev->name);
2488 2490
2489 hci_dev_lock(hdev); 2491 hci_dev_lock(hdev);
2490 2492
2491 if (test_bit(HCI_MGMT, &hdev->flags)) 2493 if (!test_bit(HCI_MGMT, &hdev->flags))
2492 mgmt_user_confirm_request(hdev->id, &ev->bdaddr, ev->passkey); 2494 goto unlock;
2493 2495
2496 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
2497 if (!conn)
2498 goto unlock;
2499
2500 loc_mitm = (conn->auth_type & 0x01);
2501 rem_mitm = (conn->remote_auth & 0x01);
2502
2503 /* If we require MITM but the remote device can't provide that
2504 * (it has NoInputNoOutput) then reject the confirmation
2505 * request. The only exception is when we're dedicated bonding
2506 * initiators (connect_cfm_cb set) since then we always have the MITM
2507 * bit set. */
2508 if (!conn->connect_cfm_cb && loc_mitm && conn->remote_cap == 0x03) {
2509 BT_DBG("Rejecting request: remote device can't provide MITM");
2510 hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_NEG_REPLY,
2511 sizeof(ev->bdaddr), &ev->bdaddr);
2512 goto unlock;
2513 }
2514
2515 /* If no side requires MITM protection; auto-accept */
2516 if ((!loc_mitm || conn->remote_cap == 0x03) &&
2517 (!rem_mitm || conn->io_capability == 0x03)) {
2518 BT_DBG("Auto-accept of user confirmation");
2519 hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_REPLY,
2520 sizeof(ev->bdaddr), &ev->bdaddr);
2521 goto unlock;
2522 }
2523
2524 mgmt_user_confirm_request(hdev->id, &ev->bdaddr, ev->passkey);
2525
2526unlock:
2494 hci_dev_unlock(hdev); 2527 hci_dev_unlock(hdev);
2495} 2528}
2496 2529