Bluetooth: Add Passkey Entry and User Confirm hooks for SMP
Subsystems (2)
cover Bluetooth: Add Passkey Entry and User Confirm hooks for SMP
While I actually prefer Johan's method of adding the User Confirm MGMT code, with it's code re-use between user_confirm_reply, and user_confirm_neg_reply, I have broken the user_passkey_reply out from user_passkey_neg_reply, and added an additional patch to hook in the HCI/SSP based usage of passkeys.
This makes sense, I suppose, since the regular and neg replies for passkeys are different sizes.
Passkey's only come into play only if our OI_CAP happens to be KeyboardOnly (for BR/EDR/LER) or DisplayKeyboard (LE only).
So the summary of the changes is:
1. Addition of BR/EDR vs LE breakout in user_confirm_reply
1.1 Adds SMP placeholder
1.2 Keeps Johan's confirm_reply & confirm_neg_reply structure.
1.2.1 Johan can defend or change that himself, but the existing code works.
2. Addition of user_passkey_reply, with both BR/EDR (SSP) and LE (SMP) handling 2.1 Adds approriate SSP HCI opcodes
2.2 Adds appropriate MGMT opcodes
2.3 Adds SMP placeholder
2.4 Seperate paths for passkey_reply & passkey_neg_reply
3. Addition of HCI event handling and forwarding for the appropriate BR/EDR SSP events
Signature · 4 lines
Brian Gix [email protected] Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
PATCH 1/3 Bluetooth: Add SMP support to user_confirm_reply
to enable User Confirmation during LE-SMP pairing.
--- net/bluetooth/mgmt.c | 22 +++++++++++++++++++--- 1 files changed, 19 insertions(+), 3 deletions(-)
net/bluetooth/mgmt.c +19 -3
@@ -1423,6 +1423,7 @@ static int user_confirm_reply(struct sock *sk, u16 index, unsigned char *data,u16 mgmt_op, hci_op;struct pending_cmd *cmd;struct hci_dev *hdev; +struct hci_conn *conn;int err;BT_DBG ("" );
@@ -1446,20 +1447,35 @@ static int user_confirm_reply(struct sock *sk, u16 index, unsigned char *data,if (!test_bit (HCI_UP , &hdev->flags)) { err =cmd_status (sk, index, mgmt_op,ENETDOWN ); - goto failed; + goto done; + } + +/* Route command to HCI (if ACL Link) or SMP (if LE Link) */ + conn =hci_conn_hash_lookup_ba (hdev,ACL_LINK , &cp->bdaddr); +if (!conn) { + conn =hci_conn_hash_lookup_ba (hdev,LE_LINK , &cp->bdaddr); +if (!conn) { + err =cmd_status (sk, index, mgmt_op,ENOTCONN ); + goto done; + } + +/* Forward Confirm response to SMP */ + + err =cmd_status (sk, index, mgmt_op,0 ); + goto done; } cmd =mgmt_pending_add (sk, mgmt_op, hdev, data, len);if (!cmd) { err = -ENOMEM ; - goto failed; + goto done; } err =hci_send_cmd (hdev, hci_op,sizeof (cp->bdaddr), &cp->bdaddr);if (err <0 )mgmt_pending_remove (cmd); -failed: +done:hci_dev_unlock_bh (hdev);hci_dev_put (hdev);
Signature · 7 lines
1.7.7.2 -- Brian Gix [email protected] Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
Re: [PATCH 1/3] Bluetooth: Add SMP support to user_confirm_reply
Quoted 1 line · Brian Gix
to enable User Confirmation during LE-SMP pairing.
Can I get a better commit message here as Marcel suggested? And please use -v2, -v3 and so on to version your patch sets to help us identify them.
Gustavo
PATCH 2/3 Bluetooth: Add MGMT opcode for User Passkey entry
In reply to Brian Gix--- include/net/bluetooth/hci.h | 8 +++ include/net/bluetooth/mgmt.h | 11 +++ net/bluetooth/mgmt.c | 143 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 162 insertions(+), 0 deletions(-)
include/net/bluetooth/hci.h +8 -0
@@ -453,6 +453,14 @@ struct hci_rp_user_confirm_reply {#define HCI_OP_USER_CONFIRM_NEG_REPLY 0x042d +#define HCI_OP_USER_PASSKEY_REPLY 0x042e +struct hci_cp_user_passkey_reply { +bdaddr_t bdaddr; +__u32 passkey; +} __packed; + +#define HCI_OP_USER_PASSKEY_NEG_REPLY 0x042f +#define HCI_OP_REMOTE_OOB_DATA_REPLY 0x0430struct hci_cp_remote_oob_data_reply {bdaddr_t bdaddr;
include/net/bluetooth/mgmt.h +11 -0
@@ -228,6 +228,17 @@ struct mgmt_cp_set_fast_connectable {__u8 enable; } __packed; +#define MGMT_OP_USER_PASSKEY_REPLY 0x0020 +struct mgmt_cp_user_passkey_reply { +bdaddr_t bdaddr; +__le32 passkey; +} __packed; + +#define MGMT_OP_USER_PASSKEY_NEG_REPLY 0x0021 +struct mgmt_cp_user_passkey_neg_reply { +bdaddr_t bdaddr; +} __packed; +#define MGMT_EV_CMD_COMPLETE 0x0001struct mgmt_ev_cmd_complete {__le16 opcode;
net/bluetooth/mgmt.c +143 -0
161 lines not on this page · raw message
Signature · 7 lines
1.7.7.2 -- Brian Gix [email protected] Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
Re: [PATCH 2/3] Bluetooth: Add MGMT opcode for User Passkey entry
Quoted 1 line · Brian Gix
Signed-off-by Brian Gix <[email protected]>
Same here, better commit message please.
Gustavo
PATCH 3/3 Bluetooth: Add User Passkey entry to HCI Events
In reply to Brian Gix--- include/net/bluetooth/hci.h | 5 +++ include/net/bluetooth/hci_core.h | 4 ++ net/bluetooth/hci_event.c | 62 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 0 deletions(-)
include/net/bluetooth/hci.h +5 -0
@@ -1084,6 +1084,11 @@ struct hci_ev_user_confirm_req {__le32 passkey; } __packed; +#define HCI_EV_USER_PASSKEY_REQUEST 0x34 +struct hci_ev_user_passkey_req { +bdaddr_t bdaddr; +} __packed; +#define HCI_EV_REMOTE_OOB_DATA_REQUEST 0x35struct hci_ev_remote_oob_data_request {bdaddr_t bdaddr;
include/net/bluetooth/hci_core.h +4 -0
@@ -931,6 +931,10 @@ int mgmt_user_confirm_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status);int mgmt_user_confirm_neg_reply_complete (struct hci_dev *hdev,bdaddr_t *bdaddr,u8 status); +int mgmt_user_passkey_reply_complete (struct hci_dev *hdev,bdaddr_t *bdaddr, +u8 status); +int mgmt_user_passkey_neg_reply_complete (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_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash,
net/bluetooth/hci_event.c +62 -0
86 lines not on this page · raw message
Signature · 7 lines
1.7.7.2 -- Brian Gix [email protected] Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum