Commit 272d90df authored by Johan Hedberg's avatar Johan Hedberg

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: default avatarJohan Hedberg <johan.hedberg@intel.com>
Acked-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 88c3df13
...@@ -968,16 +968,18 @@ int mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, ...@@ -968,16 +968,18 @@ int mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
int mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, int mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
u8 status); u8 status);
int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr, int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr,
__le32 value, u8 confirm_hint); u8 link_type, u8 addr_type, __le32 value,
u8 confirm_hint);
int mgmt_user_confirm_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, int mgmt_user_confirm_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
u8 status); u8 link_type, u8 addr_type, u8 status);
int mgmt_user_confirm_neg_reply_complete(struct hci_dev *hdev, int mgmt_user_confirm_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
bdaddr_t *bdaddr, u8 status); u8 link_type, u8 addr_type, u8 status);
int mgmt_user_passkey_request(struct hci_dev *hdev, bdaddr_t *bdaddr); int mgmt_user_passkey_request(struct hci_dev *hdev, bdaddr_t *bdaddr,
u8 link_type, u8 addr_type);
int mgmt_user_passkey_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, int mgmt_user_passkey_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
u8 status); u8 link_type, u8 addr_type, u8 status);
int mgmt_user_passkey_neg_reply_complete(struct hci_dev *hdev, int mgmt_user_passkey_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
bdaddr_t *bdaddr, u8 status); u8 link_type, u8 addr_type, u8 status);
int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status); int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status);
int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status); int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status);
int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash,
......
...@@ -235,31 +235,31 @@ struct mgmt_rp_unpair_device { ...@@ -235,31 +235,31 @@ struct mgmt_rp_unpair_device {
#define MGMT_OP_USER_CONFIRM_REPLY 0x001C #define MGMT_OP_USER_CONFIRM_REPLY 0x001C
struct mgmt_cp_user_confirm_reply { struct mgmt_cp_user_confirm_reply {
bdaddr_t bdaddr; struct mgmt_addr_info addr;
} __packed; } __packed;
struct mgmt_rp_user_confirm_reply { struct mgmt_rp_user_confirm_reply {
bdaddr_t bdaddr; struct mgmt_addr_info addr;
__u8 status; __u8 status;
} __packed; } __packed;
#define MGMT_OP_USER_CONFIRM_NEG_REPLY 0x001D #define MGMT_OP_USER_CONFIRM_NEG_REPLY 0x001D
struct mgmt_cp_user_confirm_neg_reply { struct mgmt_cp_user_confirm_neg_reply {
bdaddr_t bdaddr; struct mgmt_addr_info addr;
} __packed; } __packed;
#define MGMT_OP_USER_PASSKEY_REPLY 0x001E #define MGMT_OP_USER_PASSKEY_REPLY 0x001E
struct mgmt_cp_user_passkey_reply { struct mgmt_cp_user_passkey_reply {
bdaddr_t bdaddr; struct mgmt_addr_info addr;
__le32 passkey; __le32 passkey;
} __packed; } __packed;
struct mgmt_rp_user_passkey_reply { struct mgmt_rp_user_passkey_reply {
bdaddr_t bdaddr; struct mgmt_addr_info addr;
__u8 status; __u8 status;
} __packed; } __packed;
#define MGMT_OP_USER_PASSKEY_NEG_REPLY 0x001F #define MGMT_OP_USER_PASSKEY_NEG_REPLY 0x001F
struct mgmt_cp_user_passkey_neg_reply { struct mgmt_cp_user_passkey_neg_reply {
bdaddr_t bdaddr; struct mgmt_addr_info addr;
} __packed; } __packed;
#define MGMT_OP_READ_LOCAL_OOB_DATA 0x0020 #define MGMT_OP_READ_LOCAL_OOB_DATA 0x0020
...@@ -376,14 +376,14 @@ struct mgmt_ev_pin_code_request { ...@@ -376,14 +376,14 @@ struct mgmt_ev_pin_code_request {
#define MGMT_EV_USER_CONFIRM_REQUEST 0x000F #define MGMT_EV_USER_CONFIRM_REQUEST 0x000F
struct mgmt_ev_user_confirm_request { struct mgmt_ev_user_confirm_request {
bdaddr_t bdaddr; struct mgmt_addr_info addr;
__u8 confirm_hint; __u8 confirm_hint;
__le32 value; __le32 value;
} __packed; } __packed;
#define MGMT_EV_USER_PASSKEY_REQUEST 0x0010 #define MGMT_EV_USER_PASSKEY_REQUEST 0x0010
struct mgmt_ev_user_passkey_request { struct mgmt_ev_user_passkey_request {
bdaddr_t bdaddr; struct mgmt_addr_info addr;
} __packed; } __packed;
#define MGMT_EV_AUTH_FAILED 0x0011 #define MGMT_EV_AUTH_FAILED 0x0011
......
...@@ -960,8 +960,8 @@ static void hci_cc_user_confirm_reply(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -960,8 +960,8 @@ static void hci_cc_user_confirm_reply(struct hci_dev *hdev, struct sk_buff *skb)
hci_dev_lock(hdev); hci_dev_lock(hdev);
if (test_bit(HCI_MGMT, &hdev->dev_flags)) if (test_bit(HCI_MGMT, &hdev->dev_flags))
mgmt_user_confirm_reply_complete(hdev, &rp->bdaddr, mgmt_user_confirm_reply_complete(hdev, &rp->bdaddr, ACL_LINK,
rp->status); 0, rp->status);
hci_dev_unlock(hdev); hci_dev_unlock(hdev);
} }
...@@ -977,6 +977,7 @@ static void hci_cc_user_confirm_neg_reply(struct hci_dev *hdev, ...@@ -977,6 +977,7 @@ static void hci_cc_user_confirm_neg_reply(struct hci_dev *hdev,
if (test_bit(HCI_MGMT, &hdev->dev_flags)) if (test_bit(HCI_MGMT, &hdev->dev_flags))
mgmt_user_confirm_neg_reply_complete(hdev, &rp->bdaddr, mgmt_user_confirm_neg_reply_complete(hdev, &rp->bdaddr,
ACL_LINK, 0,
rp->status); rp->status);
hci_dev_unlock(hdev); hci_dev_unlock(hdev);
...@@ -991,8 +992,8 @@ static void hci_cc_user_passkey_reply(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -991,8 +992,8 @@ static void hci_cc_user_passkey_reply(struct hci_dev *hdev, struct sk_buff *skb)
hci_dev_lock(hdev); hci_dev_lock(hdev);
if (test_bit(HCI_MGMT, &hdev->dev_flags)) if (test_bit(HCI_MGMT, &hdev->dev_flags))
mgmt_user_passkey_reply_complete(hdev, &rp->bdaddr, mgmt_user_passkey_reply_complete(hdev, &rp->bdaddr, ACL_LINK,
rp->status); 0, rp->status);
hci_dev_unlock(hdev); hci_dev_unlock(hdev);
} }
...@@ -1008,6 +1009,7 @@ static void hci_cc_user_passkey_neg_reply(struct hci_dev *hdev, ...@@ -1008,6 +1009,7 @@ static void hci_cc_user_passkey_neg_reply(struct hci_dev *hdev,
if (test_bit(HCI_MGMT, &hdev->dev_flags)) if (test_bit(HCI_MGMT, &hdev->dev_flags))
mgmt_user_passkey_neg_reply_complete(hdev, &rp->bdaddr, mgmt_user_passkey_neg_reply_complete(hdev, &rp->bdaddr,
ACL_LINK, 0,
rp->status); rp->status);
hci_dev_unlock(hdev); hci_dev_unlock(hdev);
...@@ -3123,7 +3125,7 @@ static inline void hci_user_confirm_request_evt(struct hci_dev *hdev, ...@@ -3123,7 +3125,7 @@ static inline void hci_user_confirm_request_evt(struct hci_dev *hdev,
} }
confirm: confirm:
mgmt_user_confirm_request(hdev, &ev->bdaddr, ev->passkey, mgmt_user_confirm_request(hdev, &ev->bdaddr, ACL_LINK, 0, ev->passkey,
confirm_hint); confirm_hint);
unlock: unlock:
...@@ -3140,7 +3142,7 @@ static inline void hci_user_passkey_request_evt(struct hci_dev *hdev, ...@@ -3140,7 +3142,7 @@ static inline void hci_user_passkey_request_evt(struct hci_dev *hdev,
hci_dev_lock(hdev); hci_dev_lock(hdev);
if (test_bit(HCI_MGMT, &hdev->dev_flags)) if (test_bit(HCI_MGMT, &hdev->dev_flags))
mgmt_user_passkey_request(hdev, &ev->bdaddr); mgmt_user_passkey_request(hdev, &ev->bdaddr, ACL_LINK, 0);
hci_dev_unlock(hdev); hci_dev_unlock(hdev);
} }
......
...@@ -1629,7 +1629,8 @@ static int cancel_pair_device(struct sock *sk, u16 index, ...@@ -1629,7 +1629,8 @@ static int cancel_pair_device(struct sock *sk, u16 index,
} }
static int user_pairing_resp(struct sock *sk, u16 index, bdaddr_t *bdaddr, static int user_pairing_resp(struct sock *sk, u16 index, bdaddr_t *bdaddr,
u16 mgmt_op, u16 hci_op, __le32 passkey) u8 type, u16 mgmt_op, u16 hci_op,
__le32 passkey)
{ {
struct pending_cmd *cmd; struct pending_cmd *cmd;
struct hci_dev *hdev; struct hci_dev *hdev;
...@@ -1648,24 +1649,18 @@ static int user_pairing_resp(struct sock *sk, u16 index, bdaddr_t *bdaddr, ...@@ -1648,24 +1649,18 @@ static int user_pairing_resp(struct sock *sk, u16 index, bdaddr_t *bdaddr,
goto done; goto done;
} }
/* if (type == MGMT_ADDR_BREDR)
* Check for an existing ACL link, if present pair via conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, bdaddr);
* HCI commands. else
*
* If no ACL link is present, check for an LE link and if
* present, pair via the SMP engine.
*
* If neither ACL nor LE links are present, fail with error.
*/
conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, bdaddr);
if (!conn) {
conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, bdaddr); conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, bdaddr);
if (!conn) {
err = cmd_status(sk, index, mgmt_op, if (!conn) {
err = cmd_status(sk, index, mgmt_op,
MGMT_STATUS_NOT_CONNECTED); MGMT_STATUS_NOT_CONNECTED);
goto done; goto done;
} }
if (type == MGMT_ADDR_LE_PUBLIC || type == MGMT_ADDR_LE_RANDOM) {
/* Continue with pairing via SMP */ /* Continue with pairing via SMP */
err = smp_user_confirm_reply(conn, mgmt_op, passkey); err = smp_user_confirm_reply(conn, mgmt_op, passkey);
...@@ -1715,9 +1710,9 @@ static int user_confirm_reply(struct sock *sk, u16 index, void *data, u16 len) ...@@ -1715,9 +1710,9 @@ static int user_confirm_reply(struct sock *sk, u16 index, void *data, u16 len)
return cmd_status(sk, index, MGMT_OP_USER_CONFIRM_REPLY, return cmd_status(sk, index, MGMT_OP_USER_CONFIRM_REPLY,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
return user_pairing_resp(sk, index, &cp->bdaddr, return user_pairing_resp(sk, index, &cp->addr.bdaddr, cp->addr.type,
MGMT_OP_USER_CONFIRM_REPLY, MGMT_OP_USER_CONFIRM_REPLY,
HCI_OP_USER_CONFIRM_REPLY, 0); HCI_OP_USER_CONFIRM_REPLY, 0);
} }
static int user_confirm_neg_reply(struct sock *sk, u16 index, void *data, static 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,9 +1726,9 @@ static int user_confirm_neg_reply(struct sock *sk, u16 index, void *data,
return cmd_status(sk, index, MGMT_OP_USER_CONFIRM_NEG_REPLY, return cmd_status(sk, index, MGMT_OP_USER_CONFIRM_NEG_REPLY,
MGMT_STATUS_INVALID_PARAMS); MGMT_STATUS_INVALID_PARAMS);
return user_pairing_resp(sk, index, &cp->bdaddr, return user_pairing_resp(sk, index, &cp->addr.bdaddr, cp->addr.type,
MGMT_OP_USER_CONFIRM_NEG_REPLY, MGMT_OP_USER_CONFIRM_NEG_REPLY,
HCI_OP_USER_CONFIRM_NEG_REPLY, 0); HCI_OP_USER_CONFIRM_NEG_REPLY, 0);
} }
static int user_passkey_reply(struct sock *sk, u16 index, void *data, u16 len) static 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,9 +1741,10 @@ static int user_passkey_reply(struct sock *sk, u16 index, void *data, u16 len)
return cmd_status(sk, index, MGMT_OP_USER_PASSKEY_REPLY, return cmd_status(sk, index, MGMT_OP_USER_PASSKEY_REPLY,
EINVAL); EINVAL);
return user_pairing_resp(sk, index, &cp->bdaddr, return user_pairing_resp(sk, index, &cp->addr.bdaddr, cp->addr.type,
MGMT_OP_USER_PASSKEY_REPLY, MGMT_OP_USER_PASSKEY_REPLY,
HCI_OP_USER_PASSKEY_REPLY, cp->passkey); HCI_OP_USER_PASSKEY_REPLY,
cp->passkey);
} }
static int user_passkey_neg_reply(struct sock *sk, u16 index, void *data, static 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,9 +1758,9 @@ static int user_passkey_neg_reply(struct sock *sk, u16 index, void *data,
return cmd_status(sk, index, MGMT_OP_USER_PASSKEY_NEG_REPLY, return cmd_status(sk, index, MGMT_OP_USER_PASSKEY_NEG_REPLY,
EINVAL); EINVAL);
return user_pairing_resp(sk, index, &cp->bdaddr, return user_pairing_resp(sk, index, &cp->addr.bdaddr, cp->addr.type,
MGMT_OP_USER_PASSKEY_NEG_REPLY, MGMT_OP_USER_PASSKEY_NEG_REPLY,
HCI_OP_USER_PASSKEY_NEG_REPLY, 0); HCI_OP_USER_PASSKEY_NEG_REPLY, 0);
} }
static int set_local_name(struct sock *sk, u16 index, void *data, static 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,13 +2761,15 @@ int mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
} }
int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr, int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr,
__le32 value, u8 confirm_hint) u8 link_type, u8 addr_type, __le32 value,
u8 confirm_hint)
{ {
struct mgmt_ev_user_confirm_request ev; struct mgmt_ev_user_confirm_request ev;
BT_DBG("%s", hdev->name); BT_DBG("%s", hdev->name);
bacpy(&ev.bdaddr, bdaddr); bacpy(&ev.addr.bdaddr, bdaddr);
ev.addr.type = link_to_mgmt(link_type, addr_type);
ev.confirm_hint = confirm_hint; ev.confirm_hint = confirm_hint;
put_unaligned_le32(value, &ev.value); put_unaligned_le32(value, &ev.value);
...@@ -2779,20 +2777,23 @@ int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr, ...@@ -2779,20 +2777,23 @@ int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr,
NULL); NULL);
} }
int mgmt_user_passkey_request(struct hci_dev *hdev, bdaddr_t *bdaddr) int mgmt_user_passkey_request(struct hci_dev *hdev, bdaddr_t *bdaddr,
u8 link_type, u8 addr_type)
{ {
struct mgmt_ev_user_passkey_request ev; struct mgmt_ev_user_passkey_request ev;
BT_DBG("%s", hdev->name); BT_DBG("%s", hdev->name);
bacpy(&ev.bdaddr, bdaddr); bacpy(&ev.addr.bdaddr, bdaddr);
ev.addr.type = link_to_mgmt(link_type, addr_type);
return mgmt_event(MGMT_EV_USER_PASSKEY_REQUEST, hdev, &ev, sizeof(ev), return mgmt_event(MGMT_EV_USER_PASSKEY_REQUEST, hdev, &ev, sizeof(ev),
NULL); NULL);
} }
static int user_pairing_resp_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, static int user_pairing_resp_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
u8 status, u8 opcode) u8 link_type, u8 addr_type, u8 status,
u8 opcode)
{ {
struct pending_cmd *cmd; struct pending_cmd *cmd;
struct mgmt_rp_user_confirm_reply rp; 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,7 +2803,8 @@ static int user_pairing_resp_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
if (!cmd) if (!cmd)
return -ENOENT; return -ENOENT;
bacpy(&rp.bdaddr, bdaddr); bacpy(&rp.addr.bdaddr, bdaddr);
rp.addr.type = link_to_mgmt(link_type, addr_type);
rp.status = mgmt_status(status); rp.status = mgmt_status(status);
err = cmd_complete(cmd->sk, hdev->id, opcode, &rp, sizeof(rp)); err = cmd_complete(cmd->sk, hdev->id, opcode, &rp, sizeof(rp));
...@@ -2812,31 +2814,31 @@ static int user_pairing_resp_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, ...@@ -2812,31 +2814,31 @@ static int user_pairing_resp_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
} }
int mgmt_user_confirm_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, int mgmt_user_confirm_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
u8 status) u8 link_type, u8 addr_type, u8 status)
{ {
return user_pairing_resp_complete(hdev, bdaddr, status, return user_pairing_resp_complete(hdev, bdaddr, link_type, addr_type,
MGMT_OP_USER_CONFIRM_REPLY); status, MGMT_OP_USER_CONFIRM_REPLY);
} }
int mgmt_user_confirm_neg_reply_complete(struct hci_dev *hdev, int mgmt_user_confirm_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
bdaddr_t *bdaddr, u8 status) u8 link_type, u8 addr_type, u8 status)
{ {
return user_pairing_resp_complete(hdev, bdaddr, status, return user_pairing_resp_complete(hdev, bdaddr, link_type, addr_type,
MGMT_OP_USER_CONFIRM_NEG_REPLY); status, MGMT_OP_USER_CONFIRM_NEG_REPLY);
} }
int mgmt_user_passkey_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, int mgmt_user_passkey_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
u8 status) u8 link_type, u8 addr_type, u8 status)
{ {
return user_pairing_resp_complete(hdev, bdaddr, status, return user_pairing_resp_complete(hdev, bdaddr, link_type, addr_type,
MGMT_OP_USER_PASSKEY_REPLY); status, MGMT_OP_USER_PASSKEY_REPLY);
} }
int mgmt_user_passkey_neg_reply_complete(struct hci_dev *hdev, int mgmt_user_passkey_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
bdaddr_t *bdaddr, u8 status) u8 link_type, u8 addr_type, u8 status)
{ {
return user_pairing_resp_complete(hdev, bdaddr, status, return user_pairing_resp_complete(hdev, bdaddr, link_type, addr_type,
MGMT_OP_USER_PASSKEY_NEG_REPLY); status, MGMT_OP_USER_PASSKEY_NEG_REPLY);
} }
int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status) int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status)
......
...@@ -349,9 +349,11 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth, ...@@ -349,9 +349,11 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,
hci_dev_lock(hcon->hdev); hci_dev_lock(hcon->hdev);
if (method == REQ_PASSKEY) if (method == REQ_PASSKEY)
ret = mgmt_user_passkey_request(hcon->hdev, conn->dst); ret = mgmt_user_passkey_request(hcon->hdev, conn->dst,
hcon->type, hcon->dst_type);
else else
ret = mgmt_user_confirm_request(hcon->hdev, conn->dst, ret = mgmt_user_confirm_request(hcon->hdev, conn->dst,
hcon->type, hcon->dst_type,
cpu_to_le32(passkey), 0); cpu_to_le32(passkey), 0);
hci_dev_unlock(hcon->hdev); hci_dev_unlock(hcon->hdev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment