diff options
author | Johan Hedberg <johan.hedberg@nokia.com> | 2011-01-21 23:10:07 -0500 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-02-07 22:40:07 -0500 |
commit | 980e1a537fed7dfa53e9a4b6e586b43341f8c2d5 (patch) | |
tree | 36d7716d48a71e16f37afb5d8afdb527463826cd /net/bluetooth/hci_event.c | |
parent | a38528f1117590169c0bf61cbf874e9fd2d5c5c9 (diff) |
Bluetooth: Add support for PIN code handling in the management interface
This patch adds the necessary commands and events needed to communicate
PIN code related actions between the kernel and userspace. This includes
a pin_code_request event as well as pin_code_reply and
pin_code_negative_reply commands.
Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Diffstat (limited to 'net/bluetooth/hci_event.c')
-rw-r--r-- | net/bluetooth/hci_event.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 995ae6c17f11..98bcf78f2021 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -743,6 +743,40 @@ static void hci_cc_set_event_flt(struct hci_dev *hdev, struct sk_buff *skb) | |||
743 | hci_req_complete(hdev, HCI_OP_SET_EVENT_FLT, status); | 743 | hci_req_complete(hdev, HCI_OP_SET_EVENT_FLT, status); |
744 | } | 744 | } |
745 | 745 | ||
746 | static void hci_cc_pin_code_reply(struct hci_dev *hdev, struct sk_buff *skb) | ||
747 | { | ||
748 | struct hci_rp_pin_code_reply *rp = (void *) skb->data; | ||
749 | struct hci_cp_pin_code_reply *cp; | ||
750 | struct hci_conn *conn; | ||
751 | |||
752 | BT_DBG("%s status 0x%x", hdev->name, rp->status); | ||
753 | |||
754 | if (test_bit(HCI_MGMT, &hdev->flags)) | ||
755 | mgmt_pin_code_reply_complete(hdev->id, &rp->bdaddr, rp->status); | ||
756 | |||
757 | if (rp->status != 0) | ||
758 | return; | ||
759 | |||
760 | cp = hci_sent_cmd_data(hdev, HCI_OP_PIN_CODE_REPLY); | ||
761 | if (!cp) | ||
762 | return; | ||
763 | |||
764 | conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); | ||
765 | if (conn) | ||
766 | conn->pin_length = cp->pin_len; | ||
767 | } | ||
768 | |||
769 | static void hci_cc_pin_code_neg_reply(struct hci_dev *hdev, struct sk_buff *skb) | ||
770 | { | ||
771 | struct hci_rp_pin_code_neg_reply *rp = (void *) skb->data; | ||
772 | |||
773 | BT_DBG("%s status 0x%x", hdev->name, rp->status); | ||
774 | |||
775 | if (test_bit(HCI_MGMT, &hdev->flags)) | ||
776 | mgmt_pin_code_neg_reply_complete(hdev->id, &rp->bdaddr, | ||
777 | rp->status); | ||
778 | } | ||
779 | |||
746 | static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) | 780 | static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status) |
747 | { | 781 | { |
748 | BT_DBG("%s status 0x%x", hdev->name, status); | 782 | BT_DBG("%s status 0x%x", hdev->name, status); |
@@ -1619,6 +1653,14 @@ static inline void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *sk | |||
1619 | hci_cc_set_event_flt(hdev, skb); | 1653 | hci_cc_set_event_flt(hdev, skb); |
1620 | break; | 1654 | break; |
1621 | 1655 | ||
1656 | case HCI_OP_PIN_CODE_REPLY: | ||
1657 | hci_cc_pin_code_reply(hdev, skb); | ||
1658 | break; | ||
1659 | |||
1660 | case HCI_OP_PIN_CODE_NEG_REPLY: | ||
1661 | hci_cc_pin_code_neg_reply(hdev, skb); | ||
1662 | break; | ||
1663 | |||
1622 | default: | 1664 | default: |
1623 | BT_DBG("%s opcode 0x%x", hdev->name, opcode); | 1665 | BT_DBG("%s opcode 0x%x", hdev->name, opcode); |
1624 | break; | 1666 | break; |
@@ -1821,6 +1863,9 @@ static inline void hci_pin_code_request_evt(struct hci_dev *hdev, struct sk_buff | |||
1821 | hci_send_cmd(hdev, HCI_OP_PIN_CODE_NEG_REPLY, | 1863 | hci_send_cmd(hdev, HCI_OP_PIN_CODE_NEG_REPLY, |
1822 | sizeof(ev->bdaddr), &ev->bdaddr); | 1864 | sizeof(ev->bdaddr), &ev->bdaddr); |
1823 | 1865 | ||
1866 | if (test_bit(HCI_MGMT, &hdev->flags)) | ||
1867 | mgmt_pin_code_request(hdev->id, &ev->bdaddr); | ||
1868 | |||
1824 | hci_dev_unlock(hdev); | 1869 | hci_dev_unlock(hdev); |
1825 | } | 1870 | } |
1826 | 1871 | ||
@@ -1889,6 +1934,7 @@ static inline void hci_link_key_notify_evt(struct hci_dev *hdev, struct sk_buff | |||
1889 | if (conn) { | 1934 | if (conn) { |
1890 | hci_conn_hold(conn); | 1935 | hci_conn_hold(conn); |
1891 | conn->disc_timeout = HCI_DISCONN_TIMEOUT; | 1936 | conn->disc_timeout = HCI_DISCONN_TIMEOUT; |
1937 | pin_len = conn->pin_length; | ||
1892 | hci_conn_put(conn); | 1938 | hci_conn_put(conn); |
1893 | } | 1939 | } |
1894 | 1940 | ||