From: "Frédéric Danis" <frederic.danis@collabora.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v2 3/6] monitor: Add support for Mgmt Security Level changed event
Date: Thu, 20 Aug 2026 14:58:03 +0200 [thread overview]
Message-ID: <20260820125806.1253547-4-frederic.danis@collabora.com> (raw)
In-Reply-To: <20260820125806.1253547-1-frederic.danis@collabora.com>
@ MGMT Event: Security Level Changed (0x0034) plen 16
BR/EDR Address: 00:AA:01:01:00:00 (Intel Corporation)
Count: 2
Security Level: No security (0x00000000)
Encryption Type: No encryption (0x00000000)
---
monitor/packet.c | 117 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 117 insertions(+)
diff --git a/monitor/packet.c b/monitor/packet.c
index 0d3b23cc3..217fcdad1 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -17680,6 +17680,121 @@ static void mgmt_conn_subrate_evt(const void *data, uint16_t size)
print_field("Supervision timeout: %u", supv_timeout);
}
+static void mgmt_print_security_level(const char *desc, uint32_t value)
+{
+ const char *level;
+
+ switch (value) {
+ case BT_SECURITY_SDP:
+ level = "No security";
+ break;
+ case BT_SECURITY_LOW:
+ level = "Unauthenticated pairing with encryption not required";
+ break;
+ case BT_SECURITY_MEDIUM:
+ level = "Unauthenticated pairing with encryption desired";
+ break;
+ case BT_SECURITY_HIGH:
+ level = "Authenticated pairing with encryption";
+ break;
+ case BT_SECURITY_FIPS:
+ level = "FIPS authenticated pairing with encryption";
+ break;
+ default:
+ level = "Reserved";
+ break;
+ }
+
+ print_field("%s: %s (0x%8.8x)", desc, level, value);
+}
+
+static void mgmt_print_encryption_type(const char *desc, uint32_t value)
+{
+ const char *type;
+
+ switch (value) {
+ case MGMT_CONN_SEC_ENCRYPT_NONE:
+ type = "No encryption";
+ break;
+ case MGMT_CONN_SEC_ENCRYPT_E0:
+ type = "E0";
+ break;
+ case MGMT_CONN_SEC_ENCRYPT_AES_CCM:
+ type = "AES-CCM";
+ break;
+ default:
+ type = "Reserved";
+ break;
+ }
+
+ print_field("%s: %s (0x%8.8x)", desc, type, value);
+}
+
+static void mgmt_print_sec_level_tlv(void *data, void *user_data)
+{
+ const struct mgmt_tlv *entry = data;
+ uint16_t type = get_le16(&entry->type);
+ const char *desc = default_system_config(type);
+ uint32_t value;
+ char buf[8];
+
+ switch (type) {
+ case MGMT_SEC_LEVEL_CHANGED_PARAM_LEVEL:
+ desc = "Security Level";
+ break;
+ case MGMT_SEC_LEVEL_CHANGED_PARAM_ENC_TYPE:
+ desc = "Encryption Type";
+ break;
+ default:
+ snprintf(buf, sizeof(buf), "0x%4.4x", entry->type);
+ desc = buf;
+ break;
+ }
+
+ if (entry->length == 1 || entry->length == 2 || entry->length == 4) {
+ if (entry->length == 1)
+ value = get_u8(entry->value);
+ else if (entry->length == 2)
+ value = get_le16(entry->value);
+ else
+ value = get_le32(entry->value);
+
+ switch (type) {
+ case MGMT_SEC_LEVEL_CHANGED_PARAM_LEVEL:
+ mgmt_print_security_level(desc, value);
+ break;
+ case MGMT_SEC_LEVEL_CHANGED_PARAM_ENC_TYPE:
+ mgmt_print_encryption_type(desc, value);
+ break;
+ default:
+ print_field("%s: %u", desc, value);
+ break;
+ }
+ } else {
+ print_hex_field(desc, entry->value, entry->length);
+ }
+}
+
+static void mgmt_security_level_changed_evt(const void *data, uint16_t size)
+{
+ const uint8_t *addr = data;
+ uint8_t addr_type = get_u8(data + 6);
+ uint8_t count = get_u8(data + 7);
+ struct mgmt_tlv_list *tlv_list;
+
+ mgmt_print_address(addr, addr_type);
+ print_field("Count: %d", count);
+
+ tlv_list = mgmt_tlv_list_load_from_buf(data + 8, size - 8);
+ if (!tlv_list) {
+ print_text(COLOR_ERROR, " Unable to parse security level "
+ "changed event");
+ return;
+ }
+ mgmt_tlv_list_foreach(tlv_list, mgmt_print_sec_level_tlv, NULL);
+ mgmt_tlv_list_free(tlv_list);
+}
+
static const struct mgmt_data mgmt_event_table[] = {
{ 0x0001, "Command Complete",
mgmt_command_complete_evt, 3, false },
@@ -17779,6 +17894,8 @@ static const struct mgmt_data mgmt_event_table[] = {
mgmt_mesh_packet_cmplt_evt, 1, true },
{ 0x0033, "Connection Subrate",
mgmt_conn_subrate_evt, 18, true },
+ { 0x0034, "Security Level Changed",
+ mgmt_security_level_changed_evt, 8, false },
{ }
};
--
2.43.0
next prev parent reply other threads:[~2026-08-20 12:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-20 12:58 [PATCH BlueZ v2 0/6] mgmt/device: report link security level to D-Bus clients Frédéric Danis
2026-08-20 12:58 ` [PATCH BlueZ v2 1/6] mgmt: Add Security Level Changed event Frédéric Danis
2026-08-20 14:07 ` mgmt/device: report link security level to D-Bus clients bluez.test.bot
2026-08-20 12:58 ` [PATCH BlueZ v2 2/6] mgmt-tester: Add Security Level Changed event tests Frédéric Danis
2026-08-20 12:58 ` Frédéric Danis [this message]
2026-08-20 12:58 ` [PATCH BlueZ v2 4/6] device: Add SecurityLevel properties to org.bluez.Device1 Frédéric Danis
2026-08-20 12:58 ` [PATCH BlueZ v2 5/6] org.bluez.Device: Add Security Level related properties Frédéric Danis
2026-08-20 12:58 ` [PATCH BlueZ v2 6/6] client: Display SecurityLevel in device info Frédéric Danis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260820125806.1253547-4-frederic.danis@collabora.com \
--to=frederic.danis@collabora.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox