From 5069c5d68c16b0ecd7b6f9adccdf8e84db6f94a4 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Thu, 4 Apr 2024 16:14:02 -0400 Subject: [PATCH] monitor: Fix not decoding MGMT_OP_SET_BLOCKED_KEYS @ MGMT Command: Set Blocked Keys (0x0046) plen 36 Keys: 2 type: Long Term Key (0x01) Link key[16]: bf01fb9d4ef3bc36d874f5394138684c type: Identity Resolving Key (0x02) Link key[16]: a599bae4e17ca618228e0756b4e85f01 @ MGMT Event: Command Complete (0x0001) plen 3 Load Blocked Keys (0x0046) plen 0 Status: Success (0x00) --- monitor/packet.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/monitor/packet.c b/monitor/packet.c index abc557542..48fff2ba6 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -13338,6 +13338,50 @@ static void mgmt_set_low_energy_cmd(const void *data, uint16_t size) print_enable("Low Energy", enable); } +static void mgmt_set_blocked_keys_cmd(const void *data, uint16_t size) +{ + struct iovec frame = { (void *)data, size }; + uint16_t num_keys; + int i; + + if (!util_iov_pull_le16(&frame, &num_keys)) { + print_field("Keys: invalid size"); + return; + } + + print_field("Keys: %u", num_keys); + + for (i = 0; i < num_keys; i++) { + uint8_t type; + uint8_t *key; + + if (!util_iov_pull_u8(&frame, &type)) { + print_field("Key type[%u]: invalid size", i); + return; + } + + switch (type) { + case 0x00: + print_field("type: Link Key (0x00)"); + break; + case 0x01: + print_field("type: Long Term Key (0x01)"); + break; + case 0x02: + print_field("type: Identity Resolving Key (0x02)"); + break; + } + + key = util_iov_pull_mem(&frame, 16); + if (!key) { + print_field("Key[%u]: invalid size", i); + return; + } + + print_link_key(key); + } +} + static void mgmt_set_wbs_cmd(const void *data, uint16_t size) { uint8_t enable = get_u8(data); @@ -14800,7 +14844,9 @@ static const struct mgmt_data mgmt_command_table[] = { { 0x0045, "Set PHY Configuration", mgmt_set_phy_cmd, 4, true, mgmt_null_rsp, 0, true }, - { 0x0046, "Load Blocked Keys" }, + { 0x0046, "Set Blocked Keys", + mgmt_set_blocked_keys_cmd, 2, false, + mgmt_null_rsp, 0, true }, { 0x0047, "Set Wideband Speech", mgmt_set_wbs_cmd, 1, true, mgmt_new_settings_rsp, 4, true }, -- 2.47.3