aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/mgmt.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2012-02-09 08:26:12 -0500
committerJohan Hedberg <johan.hedberg@intel.com>2012-02-13 10:01:36 -0500
commit272d90df2d4d065e782cafb08358bd8918bf703a (patch)
treea39907ac765574b8b0bf087a7aa0f37cc580d5a7 /net/bluetooth/mgmt.c
parent88c3df13ca06718e5a8f509ae9cbb1228c10d537 (diff)
Bluetooth: Add address type to user_confirm and user_passkey messages
This patch upadate the user confirm and user passkey mgmt messages to match the latest API specification by adding an address type parameter to them. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/mgmt.c')
-rw-r--r--net/bluetooth/mgmt.c98
1 files changed, 50 insertions, 48 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index f1257ee5afbc..16fc828096f6 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1629,7 +1629,8 @@ unlock:
1629} 1629}
1630 1630
1631static int user_pairing_resp(struct sock *sk, u16 index, bdaddr_t *bdaddr, 1631static int user_pairing_resp(struct sock *sk, u16 index, bdaddr_t *bdaddr,
1632 u16 mgmt_op, u16 hci_op, __le32 passkey) 1632 u8 type, u16 mgmt_op, u16 hci_op,
1633 __le32 passkey)
1633{ 1634{
1634 struct pending_cmd *cmd; 1635 struct pending_cmd *cmd;
1635 struct hci_dev *hdev; 1636 struct hci_dev *hdev;
@@ -1648,24 +1649,18 @@ static int user_pairing_resp(struct sock *sk, u16 index, bdaddr_t *bdaddr,
1648 goto done; 1649 goto done;
1649 } 1650 }
1650 1651
1651 /* 1652 if (type == MGMT_ADDR_BREDR)
1652 * Check for an existing ACL link, if present pair via 1653 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, bdaddr);
1653 * HCI commands. 1654 else
1654 *
1655 * If no ACL link is present, check for an LE link and if
1656 * present, pair via the SMP engine.
1657 *
1658 * If neither ACL nor LE links are present, fail with error.
1659 */
1660 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, bdaddr);
1661 if (!conn) {
1662 conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, bdaddr); 1655 conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, bdaddr);
1663 if (!conn) { 1656
1664 err = cmd_status(sk, index, mgmt_op, 1657 if (!conn) {
1658 err = cmd_status(sk, index, mgmt_op,
1665 MGMT_STATUS_NOT_CONNECTED); 1659 MGMT_STATUS_NOT_CONNECTED);
1666 goto done; 1660 goto done;
1667 } 1661 }
1668 1662
1663 if (type == MGMT_ADDR_LE_PUBLIC || type == MGMT_ADDR_LE_RANDOM) {
1669 /* Continue with pairing via SMP */ 1664 /* Continue with pairing via SMP */
1670 err = smp_user_confirm_reply(conn, mgmt_op, passkey); 1665 err = smp_user_confirm_reply(conn, mgmt_op, passkey);
1671 1666
@@ -1715,9 +1710,9 @@ static int user_confirm_reply(struct sock *sk, u16 index, void *data, u16 len)
1715 return cmd_status(sk, index, MGMT_OP_USER_CONFIRM_REPLY, 1710 return cmd_status(sk, index, MGMT_OP_USER_CONFIRM_REPLY,
1716 MGMT_STATUS_INVALID_PARAMS); 1711 MGMT_STATUS_INVALID_PARAMS);
1717 1712
1718 return user_pairing_resp(sk, index, &cp->bdaddr, 1713 return user_pairing_resp(sk, index, &cp->addr.bdaddr, cp->addr.type,
1719 MGMT_OP_USER_CONFIRM_REPLY, 1714 MGMT_OP_USER_CONFIRM_REPLY,
1720 HCI_OP_USER_CONFIRM_REPLY, 0); 1715 HCI_OP_USER_CONFIRM_REPLY, 0);
1721} 1716}
1722 1717
1723static int user_confirm_neg_reply(struct sock *sk, u16 index, void *data, 1718static int user_confirm_neg_reply(struct sock *sk, u16 index, void *data,
@@ -1731,9 +1726,9 @@ static int user_confirm_neg_reply(struct sock *sk, u16 index, void *data,
1731 return cmd_status(sk, index, MGMT_OP_USER_CONFIRM_NEG_REPLY, 1726 return cmd_status(sk, index, MGMT_OP_USER_CONFIRM_NEG_REPLY,
1732 MGMT_STATUS_INVALID_PARAMS); 1727 MGMT_STATUS_INVALID_PARAMS);
1733 1728
1734 return user_pairing_resp(sk, index, &cp->bdaddr, 1729 return user_pairing_resp(sk, index, &cp->addr.bdaddr, cp->addr.type,
1735 MGMT_OP_USER_CONFIRM_NEG_REPLY, 1730 MGMT_OP_USER_CONFIRM_NEG_REPLY,
1736 HCI_OP_USER_CONFIRM_NEG_REPLY, 0); 1731 HCI_OP_USER_CONFIRM_NEG_REPLY, 0);
1737} 1732}
1738 1733
1739static int user_passkey_reply(struct sock *sk, u16 index, void *data, u16 len) 1734static int user_passkey_reply(struct sock *sk, u16 index, void *data, u16 len)
@@ -1746,9 +1741,10 @@ static int user_passkey_reply(struct sock *sk, u16 index, void *data, u16 len)
1746 return cmd_status(sk, index, MGMT_OP_USER_PASSKEY_REPLY, 1741 return cmd_status(sk, index, MGMT_OP_USER_PASSKEY_REPLY,
1747 EINVAL); 1742 EINVAL);
1748 1743
1749 return user_pairing_resp(sk, index, &cp->bdaddr, 1744 return user_pairing_resp(sk, index, &cp->addr.bdaddr, cp->addr.type,
1750 MGMT_OP_USER_PASSKEY_REPLY, 1745 MGMT_OP_USER_PASSKEY_REPLY,
1751 HCI_OP_USER_PASSKEY_REPLY, cp->passkey); 1746 HCI_OP_USER_PASSKEY_REPLY,
1747 cp->passkey);
1752} 1748}
1753 1749
1754static int user_passkey_neg_reply(struct sock *sk, u16 index, void *data, 1750static int user_passkey_neg_reply(struct sock *sk, u16 index, void *data,
@@ -1762,9 +1758,9 @@ static int user_passkey_neg_reply(struct sock *sk, u16 index, void *data,
1762 return cmd_status(sk, index, MGMT_OP_USER_PASSKEY_NEG_REPLY, 1758 return cmd_status(sk, index, MGMT_OP_USER_PASSKEY_NEG_REPLY,
1763 EINVAL); 1759 EINVAL);
1764 1760
1765 return user_pairing_resp(sk, index, &cp->bdaddr, 1761 return user_pairing_resp(sk, index, &cp->addr.bdaddr, cp->addr.type,
1766 MGMT_OP_USER_PASSKEY_NEG_REPLY, 1762 MGMT_OP_USER_PASSKEY_NEG_REPLY,
1767 HCI_OP_USER_PASSKEY_NEG_REPLY, 0); 1763 HCI_OP_USER_PASSKEY_NEG_REPLY, 0);
1768} 1764}
1769 1765
1770static int set_local_name(struct sock *sk, u16 index, void *data, 1766static int set_local_name(struct sock *sk, u16 index, void *data,
@@ -2765,13 +2761,15 @@ int mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
2765} 2761}
2766 2762
2767int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr, 2763int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr,
2768 __le32 value, u8 confirm_hint) 2764 u8 link_type, u8 addr_type, __le32 value,
2765 u8 confirm_hint)
2769{ 2766{
2770 struct mgmt_ev_user_confirm_request ev; 2767 struct mgmt_ev_user_confirm_request ev;
2771 2768
2772 BT_DBG("%s", hdev->name); 2769 BT_DBG("%s", hdev->name);
2773 2770
2774 bacpy(&ev.bdaddr, bdaddr); 2771 bacpy(&ev.addr.bdaddr, bdaddr);
2772 ev.addr.type = link_to_mgmt(link_type, addr_type);
2775 ev.confirm_hint = confirm_hint; 2773 ev.confirm_hint = confirm_hint;
2776 put_unaligned_le32(value, &ev.value); 2774 put_unaligned_le32(value, &ev.value);
2777 2775
@@ -2779,20 +2777,23 @@ int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr,
2779 NULL); 2777 NULL);
2780} 2778}
2781 2779
2782int mgmt_user_passkey_request(struct hci_dev *hdev, bdaddr_t *bdaddr) 2780int mgmt_user_passkey_request(struct hci_dev *hdev, bdaddr_t *bdaddr,
2781 u8 link_type, u8 addr_type)
2783{ 2782{
2784 struct mgmt_ev_user_passkey_request ev; 2783 struct mgmt_ev_user_passkey_request ev;
2785 2784
2786 BT_DBG("%s", hdev->name); 2785 BT_DBG("%s", hdev->name);
2787 2786
2788 bacpy(&ev.bdaddr, bdaddr); 2787 bacpy(&ev.addr.bdaddr, bdaddr);
2788 ev.addr.type = link_to_mgmt(link_type, addr_type);
2789 2789
2790 return mgmt_event(MGMT_EV_USER_PASSKEY_REQUEST, hdev, &ev, sizeof(ev), 2790 return mgmt_event(MGMT_EV_USER_PASSKEY_REQUEST, hdev, &ev, sizeof(ev),
2791 NULL); 2791 NULL);
2792} 2792}
2793 2793
2794static int user_pairing_resp_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, 2794static int user_pairing_resp_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
2795 u8 status, u8 opcode) 2795 u8 link_type, u8 addr_type, u8 status,
2796 u8 opcode)
2796{ 2797{
2797 struct pending_cmd *cmd; 2798 struct pending_cmd *cmd;
2798 struct mgmt_rp_user_confirm_reply rp; 2799 struct mgmt_rp_user_confirm_reply rp;
@@ -2802,7 +2803,8 @@ static int user_pairing_resp_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
2802 if (!cmd) 2803 if (!cmd)
2803 return -ENOENT; 2804 return -ENOENT;
2804 2805
2805 bacpy(&rp.bdaddr, bdaddr); 2806 bacpy(&rp.addr.bdaddr, bdaddr);
2807 rp.addr.type = link_to_mgmt(link_type, addr_type);
2806 rp.status = mgmt_status(status); 2808 rp.status = mgmt_status(status);
2807 err = cmd_complete(cmd->sk, hdev->id, opcode, &rp, sizeof(rp)); 2809 err = cmd_complete(cmd->sk, hdev->id, opcode, &rp, sizeof(rp));
2808 2810
@@ -2812,31 +2814,31 @@ static int user_pairing_resp_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
2812} 2814}
2813 2815
2814int mgmt_user_confirm_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, 2816int mgmt_user_confirm_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
2815 u8 status) 2817 u8 link_type, u8 addr_type, u8 status)
2816{ 2818{
2817 return user_pairing_resp_complete(hdev, bdaddr, status, 2819 return user_pairing_resp_complete(hdev, bdaddr, link_type, addr_type,
2818 MGMT_OP_USER_CONFIRM_REPLY); 2820 status, MGMT_OP_USER_CONFIRM_REPLY);
2819} 2821}
2820 2822
2821int mgmt_user_confirm_neg_reply_complete(struct hci_dev *hdev, 2823int mgmt_user_confirm_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
2822 bdaddr_t *bdaddr, u8 status) 2824 u8 link_type, u8 addr_type, u8 status)
2823{ 2825{
2824 return user_pairing_resp_complete(hdev, bdaddr, status, 2826 return user_pairing_resp_complete(hdev, bdaddr, link_type, addr_type,
2825 MGMT_OP_USER_CONFIRM_NEG_REPLY); 2827 status, MGMT_OP_USER_CONFIRM_NEG_REPLY);
2826} 2828}
2827 2829
2828int mgmt_user_passkey_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, 2830int mgmt_user_passkey_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
2829 u8 status) 2831 u8 link_type, u8 addr_type, u8 status)
2830{ 2832{
2831 return user_pairing_resp_complete(hdev, bdaddr, status, 2833 return user_pairing_resp_complete(hdev, bdaddr, link_type, addr_type,
2832 MGMT_OP_USER_PASSKEY_REPLY); 2834 status, MGMT_OP_USER_PASSKEY_REPLY);
2833} 2835}
2834 2836
2835int mgmt_user_passkey_neg_reply_complete(struct hci_dev *hdev, 2837int mgmt_user_passkey_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
2836 bdaddr_t *bdaddr, u8 status) 2838 u8 link_type, u8 addr_type, u8 status)
2837{ 2839{
2838 return user_pairing_resp_complete(hdev, bdaddr, status, 2840 return user_pairing_resp_complete(hdev, bdaddr, link_type, addr_type,
2839 MGMT_OP_USER_PASSKEY_NEG_REPLY); 2841 status, MGMT_OP_USER_PASSKEY_NEG_REPLY);
2840} 2842}
2841 2843
2842int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status) 2844int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status)