From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v1 08/10] monitor/att: Reference the request frame on responses
Date: Wed, 9 Sep 2026 14:28:38 -0400 [thread overview]
Message-ID: <20260909182840.1289776-9-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20260909182840.1289776-1-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
ATT responses use the request opcode plus one, and only one request may be
outstanding on a bearer, so the opcode itself identifies the transaction:
ATT: Read By Group Type Request (0x10) len 6
ATT: Error Response (0x01) len 4 #6 (45.500 msec)
An Error Response names the request it rejects rather than following the
plus one rule, so it is matched on the opcode it carries. A Handle Value
Indication is paired with the confirmation that answers it.
The model wrote the matching, which the author reviewed and verified
against a trace covering ordinary responses, an Error Response, an
indication and a response with no request.
Assisted-by: opencode:claude-opus-5
---
monitor/att.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 68 insertions(+), 1 deletion(-)
diff --git a/monitor/att.c b/monitor/att.c
index 44965a2aaf3b..a35198949e3d 100644
--- a/monitor/att.c
+++ b/monitor/att.c
@@ -5873,6 +5873,64 @@ static const char *att_opcode_to_str(uint8_t opcode)
return "Unknown";
}
+/*
+ * ATT responses use the request opcode plus one, except for an Error
+ * Response which names the request it rejects. Only one request may be
+ * outstanding on a bearer, so the opcode itself identifies the transaction.
+ */
+static void att_req_str(uint16_t handle, uint16_t key, uint8_t opcode,
+ const void *data, uint16_t size, struct timeval *tv,
+ size_t num, char *str, size_t len)
+{
+ str[0] = '\0';
+
+ switch (opcode) {
+ /* Requests, and the indication which is answered by a confirmation */
+ case 0x02:
+ case 0x04:
+ case 0x06:
+ case 0x08:
+ case 0x0a:
+ case 0x0c:
+ case 0x0e:
+ case 0x10:
+ case 0x12:
+ case 0x16:
+ case 0x18:
+ case 0x1d:
+ case 0x20:
+ packet_req_add(handle, key, PACKET_PROTO_ATT, opcode, tv,
+ num);
+ return;
+ case 0x01:
+ /* The rejected request is named in the response */
+ if (size < 1)
+ return;
+ packet_req_str(handle, key, PACKET_PROTO_ATT,
+ *((const uint8_t *) data), tv, str, len);
+ return;
+ case 0x1e:
+ packet_req_str(handle, key, PACKET_PROTO_ATT, 0x1d, tv, str,
+ len);
+ return;
+ case 0x03:
+ case 0x05:
+ case 0x07:
+ case 0x09:
+ case 0x0b:
+ case 0x0d:
+ case 0x0f:
+ case 0x11:
+ case 0x13:
+ case 0x17:
+ case 0x19:
+ case 0x21:
+ packet_req_str(handle, key, PACKET_PROTO_ATT, opcode - 1, tv,
+ str, len);
+ return;
+ }
+}
+
void att_packet(uint16_t index, bool in, uint16_t handle, uint16_t cid,
const void *data, uint16_t size)
{
@@ -5880,6 +5938,9 @@ void att_packet(uint16_t index, bool in, uint16_t handle, uint16_t cid,
uint8_t opcode = *((const uint8_t *) data);
const struct att_opcode_data *opcode_data = NULL;
const char *opcode_color, *opcode_str;
+ char req_str[32];
+ struct timeval tv;
+ size_t num;
int i;
if (size < 1) {
@@ -5909,8 +5970,14 @@ void att_packet(uint16_t index, bool in, uint16_t handle, uint16_t cid,
opcode_str = "Unknown";
}
+ packet_get_context(&tv, &num);
+ att_req_str(handle, l2cap_chan_key(index, in, handle, cid), opcode,
+ data + 1, size - 1, &tv, num, req_str,
+ sizeof(req_str));
+
print_indent(6, opcode_color, "ATT: ", opcode_str, COLOR_OFF,
- " (0x%2.2x) len %d", opcode, size - 1);
+ " (0x%2.2x) len %d%s%s", opcode, size - 1,
+ req_str[0] ? " " : "", req_str);
if (!opcode_data || !opcode_data->func) {
packet_hexdump(data + 1, size - 1);
--
2.55.0
next prev parent reply other threads:[~2026-09-09 18:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 18:28 [PATCH BlueZ v1 00/10] monitor: Reference request frames on responses Luiz Augusto von Dentz
2026-09-09 18:28 ` [PATCH BlueZ v1 01/10] monitor: Reference the request frame on command responses Luiz Augusto von Dentz
2026-09-10 17:43 ` monitor: Reference request frames on responses bluez.test.bot
2026-09-09 18:28 ` [PATCH BlueZ v1 02/10] doc/btmon: Document the request reference on command responses Luiz Augusto von Dentz
2026-09-09 18:28 ` [PATCH BlueZ v1 03/10] monitor: Resolve commands completed by a later event Luiz Augusto von Dentz
2026-09-09 18:28 ` [PATCH BlueZ v1 04/10] doc/btmon: Document the deferred command references Luiz Augusto von Dentz
2026-09-09 18:28 ` [PATCH BlueZ v1 05/10] monitor: Report command latency in analyze mode Luiz Augusto von Dentz
2026-09-09 18:28 ` [PATCH BlueZ v1 06/10] doc/btmon: Document the command latency statistics Luiz Augusto von Dentz
2026-09-09 18:28 ` [PATCH BlueZ v1 07/10] monitor: Add request tracking for the protocols above HCI Luiz Augusto von Dentz
2026-09-09 18:28 ` Luiz Augusto von Dentz [this message]
2026-09-09 18:28 ` [PATCH BlueZ v1 09/10] monitor: Reference the request frame on SDP, AVDTP and AVCTP responses Luiz Augusto von Dentz
2026-09-09 18:28 ` [PATCH BlueZ v1 10/10] doc/btmon: Document the protocol request references Luiz Augusto von Dentz
2026-09-17 17:50 ` [PATCH BlueZ v1 00/10] monitor: Reference request frames on responses patchwork-bot+bluetooth
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=20260909182840.1289776-9-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.