diff options
author | Johan Hedberg <johan.hedberg@nokia.com> | 2011-02-19 10:06:00 -0500 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-02-21 15:22:44 -0500 |
commit | 2a61169209c72317d4933f8d22f749a6a61a3d36 (patch) | |
tree | d95e0016c704382f2f520ea6f3ac97d5a3b07ae4 | |
parent | ac56fb13c0508181b4227b8ada6d47aaaf72794c (diff) |
Bluetooth: Add mgmt_auth_failed event
To properly track bonding completion an event to indicate authentication
failure is needed. This event will be sent whenever an authentication
complete HCI event with a non-zero status comes. It will also be sent
when we're acting in acceptor role for SSP authentication in which case
the controller will send a Simple Pairing Complete event.
Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
-rw-r--r-- | include/net/bluetooth/hci_core.h | 1 | ||||
-rw-r--r-- | include/net/bluetooth/mgmt.h | 7 | ||||
-rw-r--r-- | net/bluetooth/hci_event.c | 19 | ||||
-rw-r--r-- | net/bluetooth/mgmt.c | 11 |
4 files changed, 35 insertions, 3 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 05f4706e6c34..441dadbf6a89 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
@@ -766,6 +766,7 @@ int mgmt_user_confirm_request(u16 index, bdaddr_t *bdaddr, __le32 value); | |||
766 | int mgmt_user_confirm_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); | 766 | int mgmt_user_confirm_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); |
767 | int mgmt_user_confirm_neg_reply_complete(u16 index, bdaddr_t *bdaddr, | 767 | int mgmt_user_confirm_neg_reply_complete(u16 index, bdaddr_t *bdaddr, |
768 | u8 status); | 768 | u8 status); |
769 | int mgmt_auth_failed(u16 index, bdaddr_t *bdaddr, u8 status); | ||
769 | 770 | ||
770 | /* HCI info for socket */ | 771 | /* HCI info for socket */ |
771 | #define hci_pi(sk) ((struct hci_pinfo *) sk) | 772 | #define hci_pi(sk) ((struct hci_pinfo *) sk) |
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 5aee200e5e36..1e63c3141a78 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h | |||
@@ -264,3 +264,10 @@ struct mgmt_ev_user_confirm_request { | |||
264 | bdaddr_t bdaddr; | 264 | bdaddr_t bdaddr; |
265 | __le32 value; | 265 | __le32 value; |
266 | } __packed; | 266 | } __packed; |
267 | |||
268 | #define MGMT_EV_AUTH_FAILED 0x0010 | ||
269 | struct mgmt_ev_auth_failed { | ||
270 | __le16 index; | ||
271 | bdaddr_t bdaddr; | ||
272 | __u8 status; | ||
273 | } __packed; | ||
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 604c7b5fee97..3fbfa50c2bff 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -1424,8 +1424,10 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s | |||
1424 | if (!ev->status) { | 1424 | if (!ev->status) { |
1425 | conn->link_mode |= HCI_LM_AUTH; | 1425 | conn->link_mode |= HCI_LM_AUTH; |
1426 | conn->sec_level = conn->pending_sec_level; | 1426 | conn->sec_level = conn->pending_sec_level; |
1427 | } else | 1427 | } else { |
1428 | mgmt_auth_failed(hdev->id, &conn->dst, ev->status); | ||
1428 | conn->sec_level = BT_SECURITY_LOW; | 1429 | conn->sec_level = BT_SECURITY_LOW; |
1430 | } | ||
1429 | 1431 | ||
1430 | clear_bit(HCI_CONN_AUTH_PEND, &conn->pend); | 1432 | clear_bit(HCI_CONN_AUTH_PEND, &conn->pend); |
1431 | 1433 | ||
@@ -2418,9 +2420,20 @@ static inline void hci_simple_pair_complete_evt(struct hci_dev *hdev, struct sk_ | |||
2418 | hci_dev_lock(hdev); | 2420 | hci_dev_lock(hdev); |
2419 | 2421 | ||
2420 | conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); | 2422 | conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); |
2421 | if (conn) | 2423 | if (!conn) |
2422 | hci_conn_put(conn); | 2424 | goto unlock; |
2425 | |||
2426 | /* To avoid duplicate auth_failed events to user space we check | ||
2427 | * the HCI_CONN_AUTH_PEND flag which will be set if we | ||
2428 | * initiated the authentication. A traditional auth_complete | ||
2429 | * event gets always produced as initiator and is also mapped to | ||
2430 | * the mgmt_auth_failed event */ | ||
2431 | if (!test_bit(HCI_CONN_AUTH_PEND, &conn->pend) && ev->status != 0) | ||
2432 | mgmt_auth_failed(hdev->id, &conn->dst, ev->status); | ||
2423 | 2433 | ||
2434 | hci_conn_put(conn); | ||
2435 | |||
2436 | unlock: | ||
2424 | hci_dev_unlock(hdev); | 2437 | hci_dev_unlock(hdev); |
2425 | } | 2438 | } |
2426 | 2439 | ||
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 0d3d613baac2..46e2c39c8956 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -1647,3 +1647,14 @@ int mgmt_user_confirm_neg_reply_complete(u16 index, bdaddr_t *bdaddr, | |||
1647 | return confirm_reply_complete(index, bdaddr, status, | 1647 | return confirm_reply_complete(index, bdaddr, status, |
1648 | MGMT_OP_USER_CONFIRM_NEG_REPLY); | 1648 | MGMT_OP_USER_CONFIRM_NEG_REPLY); |
1649 | } | 1649 | } |
1650 | |||
1651 | int mgmt_auth_failed(u16 index, bdaddr_t *bdaddr, u8 status) | ||
1652 | { | ||
1653 | struct mgmt_ev_auth_failed ev; | ||
1654 | |||
1655 | put_unaligned_le16(index, &ev.index); | ||
1656 | bacpy(&ev.bdaddr, bdaddr); | ||
1657 | ev.status = status; | ||
1658 | |||
1659 | return mgmt_event(MGMT_EV_AUTH_FAILED, &ev, sizeof(ev), NULL); | ||
1660 | } | ||