Diff between a1ecdb0df1aa88281947d3f8c120abfc9923f00a and 18f0cdaac11b07ad3a209bd6ba03ced11e99b714

Changed Files

File Additions Deletions Status
emulator/btdev.c +32 -0 modified

Full Patch

diff --git a/emulator/btdev.c b/emulator/btdev.c
index c127c0b..6a3b163 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -1561,6 +1561,32 @@ static void le_encrypt_complete(struct btdev *btdev)
 	send_event(remote, BT_HCI_EVT_ENCRYPT_CHANGE, &ev, sizeof(ev));
 }
 
+static void ltk_neg_reply_complete(struct btdev *btdev)
+{
+	struct bt_hci_rsp_le_ltk_req_neg_reply rp;
+	struct bt_hci_evt_encrypt_change ev;
+	struct btdev *remote = btdev->conn;
+
+	memset(&rp, 0, sizeof(rp));
+	rp.handle = cpu_to_le16(42);
+
+	if (!remote) {
+		rp.status = BT_HCI_ERR_UNKNOWN_CONN_ID;
+		cmd_complete(btdev, BT_HCI_CMD_LE_LTK_REQ_NEG_REPLY, &rp,
+							sizeof(rp));
+		return;
+	}
+
+	rp.status = BT_HCI_ERR_SUCCESS;
+	cmd_complete(btdev, BT_HCI_CMD_LE_LTK_REQ_NEG_REPLY, &rp, sizeof(rp));
+
+	memset(&ev, 0, sizeof(ev));
+	ev.status = BT_HCI_ERR_PIN_OR_KEY_MISSING;
+	ev.handle = cpu_to_le16(42);
+
+	send_event(remote, BT_HCI_EVT_ENCRYPT_CHANGE, &ev, sizeof(ev));
+}
+
 static void default_cmd(struct btdev *btdev, uint16_t opcode,
 						const void *data, uint8_t len)
 {
@@ -2526,6 +2552,12 @@ static void default_cmd(struct btdev *btdev, uint16_t opcode,
 		le_encrypt_complete(btdev);
 		break;
 
+	case BT_HCI_CMD_LE_LTK_REQ_NEG_REPLY:
+		if (btdev->type == BTDEV_TYPE_BREDR)
+			goto unsupported;
+		ltk_neg_reply_complete(btdev);
+		break;
+
 	case BT_HCI_CMD_SETUP_SYNC_CONN:
 		if (btdev->type == BTDEV_TYPE_LE)
 			goto unsupported;