2013-12-23 15:33:19

by Andrei Emeltchenko

[permalink] [raw]
Subject: [RFC] btdev: Send Link Key Request on Authentication Requested

From: Andrei Emeltchenko <[email protected]>

The Link Key Request event shall be generated when Simple Pairing Mode
is enabled.
---
emulator/btdev.c | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/emulator/btdev.c b/emulator/btdev.c
index b1e804b..c0cfdef 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -2005,6 +2005,19 @@ static void default_cmd_completion(struct btdev *btdev, uint16_t opcode,
conn_complete(btdev, rcr->bdaddr, BT_HCI_ERR_UNKNOWN_CONN_ID);
break;

+ case BT_HCI_CMD_AUTH_REQUESTED:
+ if (btdev->type == BTDEV_TYPE_LE)
+ return;
+
+ if (btdev->simple_pairing_mode) {
+ struct bt_hci_evt_link_key_request lkr;
+
+ memcpy(lkr.bdaddr, btdev->conn->bdaddr, 6);
+ send_event(btdev, BT_HCI_EVT_LINK_KEY_REQUEST, &lkr,
+ sizeof(lkr));
+ }
+ break;
+
case BT_HCI_CMD_REMOTE_NAME_REQUEST:
if (btdev->type == BTDEV_TYPE_LE)
return;
--
1.8.3.2



2013-12-23 15:41:04

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [RFC] btdev: Send Link Key Request on Authentication Requested

Hi Andrei,

> From: Andrei Emeltchenko <[email protected]>
>
> The Link Key Request event shall be generated when Simple Pairing Mode
> is enabled.
> ---
> emulator/btdev.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/emulator/btdev.c b/emulator/btdev.c
> index b1e804b..c0cfdef 100644
> --- a/emulator/btdev.c
> +++ b/emulator/btdev.c
> @@ -2005,6 +2005,19 @@ static void default_cmd_completion(struct btdev *btdev, uint16_t opcode,
> conn_complete(btdev, rcr->bdaddr, BT_HCI_ERR_UNKNOWN_CONN_ID);
> break;
>
> + case BT_HCI_CMD_AUTH_REQUESTED:
> + if (btdev->type == BTDEV_TYPE_LE)
> + return;

please make sure that you send correct command status event first. The Core specification is pretty detailed on what needs to be send when here.

> +
> + if (btdev->simple_pairing_mode) {
> + struct bt_hci_evt_link_key_request lkr;
> +
> + memcpy(lkr.bdaddr, btdev->conn->bdaddr, 6);
> + send_event(btdev, BT_HCI_EVT_LINK_KEY_REQUEST, &lkr,
> + sizeof(lkr));
> + }
> + break;
> +
> case BT_HCI_CMD_REMOTE_NAME_REQUEST:
> if (btdev->type == BTDEV_TYPE_LE)
> return;

Regards

Marcel