Diff between 822d27806aa5f2733ee84944b67e489147429b5f and 678b6733ef9b6d4118296670a5f97971434ec6a3

Changed Files

File Additions Deletions Status
emulator/bthost.c +23 -0 modified

Full Patch

diff --git a/emulator/bthost.c b/emulator/bthost.c
index c627f8a..83bfdee 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -70,6 +70,7 @@ struct cid_hook {
 struct btconn {
 	uint16_t handle;
 	uint8_t addr_type;
+	uint8_t encr_mode;
 	uint16_t next_cid;
 	struct l2conn *l2conns;
 	struct cid_hook *cid_hooks;
@@ -655,6 +656,24 @@ static void evt_num_completed_packets(struct bthost *bthost, const void *data,
 		return;
 }
 
+static void evt_encrypt_change(struct bthost *bthost, const void *data,
+								uint8_t len)
+{
+	const struct bt_hci_evt_encrypt_change *ev = data;
+	struct btconn *conn;
+	uint16_t handle;
+
+	if (len < sizeof(*ev))
+		return;
+
+	handle = acl_handle(ev->handle);
+	conn = bthost_find_conn(bthost, handle);
+	if (!conn)
+		return;
+
+	conn->encr_mode = ev->encr_mode;
+}
+
 static void evt_le_conn_complete(struct bthost *bthost, const void *data,
 								uint8_t len)
 {
@@ -731,6 +750,10 @@ static void process_evt(struct bthost *bthost, const void *data, uint16_t len)
 		evt_num_completed_packets(bthost, param, hdr->plen);
 		break;
 
+	case BT_HCI_EVT_ENCRYPT_CHANGE:
+		evt_encrypt_change(bthost, param, hdr->plen);
+		break;
+
 	case BT_HCI_EVT_LE_META_EVENT:
 		evt_le_meta_event(bthost, param, hdr->plen);
 		break;