public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v3] monitor: Add unknown options decoding for Configure Response
@ 2025-12-05 23:32 Andrey Smirnov
  2025-12-06  0:27 ` [BlueZ,v3] " bluez.test.bot
  0 siblings, 1 reply; 3+ messages in thread
From: Andrey Smirnov @ 2025-12-05 23:32 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andrey Smirnov, Luiz Augusto von Dentz

Unknown options respose for Configure Respose packet has a different
layout that that of unaccepted options, so it needs special code to
handle it.

Before:

> ACL Data RX: Handle 12 flags 0x02 dlen 15
      L2CAP: Configure Response (0x05) ident 2 len 7
        Source CID: 64
        Flags: 0x0000
        Result: Failure - unknown options (0x0003)
        04

After:

> ACL Data RX: Handle 12 flags 0x02 dlen 15
      L2CAP: Configure Response (0x05) ident 3 len 7
        Source CID: 65
        Flags: 0x0000
        Result: Failure - unknown options (0x0003)
        Option: Retransmission and Flow Control (0x04)
---

Changes since [v2]:

    - Patched rebased on latest master

Changes since [v1]:

    - Code converted to use l2cap_frame_get_u8() and l2cap_frame_pull()

[v2] https://lore.kernel.org/linux-bluetooth/20190906190717.1325-1-andrew.smirnov@gmail.com
[v1] https://lore.kernel.org/linux-bluetooth/20190522013216.22493-1-andrew.smirnov@gmail.com/
---
 monitor/l2cap.c | 51 +++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 41 insertions(+), 10 deletions(-)

diff --git a/monitor/l2cap.c b/monitor/l2cap.c
index 6380fec7a..f5ae379c6 100644
--- a/monitor/l2cap.c
+++ b/monitor/l2cap.c
@@ -733,6 +733,41 @@ static const struct {
         { }
 };

+static void lookup_option_by_type(uint8_t type, const char **str,
+                                 uint8_t *expect_len)
+{
+       int i;
+
+       for (i = 0; options_table[i].str; i++) {
+               if (options_table[i].type == type) {
+                       *str = options_table[i].str;
+                       if (expect_len)
+                               *expect_len = options_table[i].len;
+                       return;
+               }
+       }
+
+       *str = "Unknown";
+       if (expect_len)
+               *expect_len = 0;
+}
+
+static void print_unknown_options(const struct l2cap_frame *source,
+                                 uint8_t offset)
+{
+       struct l2cap_frame frame;
+       uint8_t type;
+
+       l2cap_frame_pull(&frame, source, offset);
+
+       while (l2cap_frame_get_u8(&frame, &type)) {
+               const char *str;
+
+               lookup_option_by_type(type, &str, NULL);
+               print_field("Option: %s (0x%2.2x)", str, type);
+       }
+}
+
 static void print_config_options(const struct l2cap_frame *frame,
 				uint8_t offset, uint16_t cid, bool response)
 {
@@ -741,20 +776,13 @@ static void print_config_options(const struct l2cap_frame *frame,
 	uint16_t consumed = 0;

 	while (consumed < size - 2) {
-		const char *str = "Unknown";
+		const char *str;
 		uint8_t type = data[consumed] & 0x7f;
 		uint8_t hint = data[consumed] & 0x80;
 		uint8_t len = data[consumed + 1];
 		uint8_t expect_len = 0;
-		int i;

-		for (i = 0; options_table[i].str; i++) {
-			if (options_table[i].type == type) {
-				str = options_table[i].str;
-				expect_len = options_table[i].len;
-				break;
-			}
-		}
+		lookup_option_by_type(type, &str, &expect_len);

 		print_field("Option: %s (0x%2.2x) [%s]", str, type,
 						hint ? "hint" : "mandatory");
@@ -1132,7 +1160,10 @@ static void sig_config_rsp(const struct l2cap_frame *frame)
 	print_cid("Source", pdu->scid);
 	print_config_flags(pdu->flags);
 	print_config_result(pdu->result);
-	print_config_options(frame, 6, le16_to_cpu(pdu->scid), true);
+	if (pdu->result == 0x0003)
+		print_unknown_options(frame, 6);
+	else
+		print_config_options(frame, 6, le16_to_cpu(pdu->scid), true);
 }

 static void sig_disconn_req(const struct l2cap_frame *frame)
--
2.43.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [BlueZ,v3] monitor: Add unknown options decoding for Configure Response
  2025-12-05 23:32 [PATCH BlueZ v3] monitor: Add unknown options decoding for Configure Response Andrey Smirnov
@ 2025-12-06  0:27 ` bluez.test.bot
  2025-12-08 18:47   ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 3+ messages in thread
From: bluez.test.bot @ 2025-12-06  0:27 UTC (permalink / raw)
  To: linux-bluetooth, andrew.smirnov

[-- Attachment #1: Type: text/plain, Size: 1527 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1031008

---Test result---

Test Summary:
CheckPatch                    PENDING   0.37 seconds
GitLint                       PENDING   0.35 seconds
BuildEll                      PASS      20.17 seconds
BluezMake                     PASS      650.69 seconds
MakeCheck                     PASS      21.59 seconds
MakeDistcheck                 PASS      243.11 seconds
CheckValgrind                 PASS      303.27 seconds
CheckSmatch                   WARNING   355.85 seconds
bluezmakeextell               PASS      184.68 seconds
IncrementalBuild              PENDING   0.35 seconds
ScanBuild                     PASS      1053.31 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
monitor/l2cap.c: note: in included file:monitor/display.h:82:26: warning: Variable length array is used.monitor/bt.h:3854:40: warning: array of flexible structures
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [BlueZ,v3] monitor: Add unknown options decoding for Configure Response
  2025-12-06  0:27 ` [BlueZ,v3] " bluez.test.bot
@ 2025-12-08 18:47   ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2025-12-08 18:47 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: andrew.smirnov

Hi Andrew,

On Fri, Dec 5, 2025 at 7:27 PM <bluez.test.bot@gmail.com> wrote:
>
> This is automated email and please do not reply to this email!
>
> Dear submitter,
>
> Thank you for submitting the patches to the linux bluetooth mailing list.
> This is a CI test results with your patch series:
> PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1031008
>
> ---Test result---
>
> Test Summary:
> CheckPatch                    PENDING   0.37 seconds
> GitLint                       PENDING   0.35 seconds
> BuildEll                      PASS      20.17 seconds
> BluezMake                     PASS      650.69 seconds
> MakeCheck                     PASS      21.59 seconds
> MakeDistcheck                 PASS      243.11 seconds
> CheckValgrind                 PASS      303.27 seconds
> CheckSmatch                   WARNING   355.85 seconds
> bluezmakeextell               PASS      184.68 seconds
> IncrementalBuild              PENDING   0.35 seconds
> ScanBuild                     PASS      1053.31 seconds
>
> Details
> ##############################
> Test: CheckPatch - PENDING
> Desc: Run checkpatch.pl script
> Output:
>
> ##############################
> Test: GitLint - PENDING
> Desc: Run gitlint
> Output:
>
> ##############################
> Test: CheckSmatch - WARNING
> Desc: Run smatch tool with source
> Output:
> monitor/l2cap.c: note: in included file:monitor/display.h:82:26: warning: Variable length array is used.monitor/bt.h:3854:40: warning: array of flexible structures
> ##############################
> Test: IncrementalBuild - PENDING
> Desc: Incremental build with the patches in the series
> Output:

ERROR:CODE_INDENT: code indent should use tabs where possible
#10: FILE: monitor/l2cap.c:737:
+                                 uint8_t *expect_len)$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#10: FILE: monitor/l2cap.c:737:
+                                 uint8_t *expect_len)$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#12: FILE: monitor/l2cap.c:739:
+       int i;$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#14: FILE: monitor/l2cap.c:741:
+       for (i = 0; options_table[i].str; i++) {$

ERROR:CODE_INDENT: code indent should use tabs where possible
#15: FILE: monitor/l2cap.c:742:
+               if (options_table[i].type == type) {$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#15: FILE: monitor/l2cap.c:742:
+               if (options_table[i].type == type) {$

ERROR:CODE_INDENT: code indent should use tabs where possible
#16: FILE: monitor/l2cap.c:743:
+                       *str = options_table[i].str;$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#16: FILE: monitor/l2cap.c:743:
+                       *str = options_table[i].str;$

ERROR:CODE_INDENT: code indent should use tabs where possible
#17: FILE: monitor/l2cap.c:744:
+                       if (expect_len)$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#17: FILE: monitor/l2cap.c:744:
+                       if (expect_len)$

ERROR:CODE_INDENT: code indent should use tabs where possible
#18: FILE: monitor/l2cap.c:745:
+                               *expect_len = options_table[i].len;$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#18: FILE: monitor/l2cap.c:745:
+                               *expect_len = options_table[i].len;$

ERROR:CODE_INDENT: code indent should use tabs where possible
#19: FILE: monitor/l2cap.c:746:
+                       return;$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#19: FILE: monitor/l2cap.c:746:
+                       return;$

ERROR:CODE_INDENT: code indent should use tabs where possible
#20: FILE: monitor/l2cap.c:747:
+               }$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#20: FILE: monitor/l2cap.c:747:
+               }$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#21: FILE: monitor/l2cap.c:748:
+       }$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#23: FILE: monitor/l2cap.c:750:
+       *str = "Unknown";$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#24: FILE: monitor/l2cap.c:751:
+       if (expect_len)$

ERROR:CODE_INDENT: code indent should use tabs where possible
#25: FILE: monitor/l2cap.c:752:
+               *expect_len = 0;$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#25: FILE: monitor/l2cap.c:752:
+               *expect_len = 0;$

ERROR:CODE_INDENT: code indent should use tabs where possible
#29: FILE: monitor/l2cap.c:756:
+                                 uint8_t offset)$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#29: FILE: monitor/l2cap.c:756:
+                                 uint8_t offset)$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#31: FILE: monitor/l2cap.c:758:
+       struct l2cap_frame frame;$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#32: FILE: monitor/l2cap.c:759:
+       uint8_t type;$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#34: FILE: monitor/l2cap.c:761:
+       l2cap_frame_pull(&frame, source, offset);$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#36: FILE: monitor/l2cap.c:763:
+       while (l2cap_frame_get_u8(&frame, &type)) {$

ERROR:CODE_INDENT: code indent should use tabs where possible
#37: FILE: monitor/l2cap.c:764:
+               const char *str;$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#37: FILE: monitor/l2cap.c:764:
+               const char *str;$

ERROR:CODE_INDENT: code indent should use tabs where possible
#39: FILE: monitor/l2cap.c:766:
+               lookup_option_by_type(type, &str, NULL);$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#39: FILE: monitor/l2cap.c:766:
+               lookup_option_by_type(type, &str, NULL);$

ERROR:CODE_INDENT: code indent should use tabs where possible
#40: FILE: monitor/l2cap.c:767:
+               print_field("Option: %s (0x%2.2x)", str, type);$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#40: FILE: monitor/l2cap.c:767:
+               print_field("Option: %s (0x%2.2x)", str, type);$

WARNING:LEADING_SPACE: please, no spaces at the start of a line
#41: FILE: monitor/l2cap.c:768:
+       }$

>
>
> ---
> Regards,
> Linux Bluetooth
>


-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-12-08 18:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-05 23:32 [PATCH BlueZ v3] monitor: Add unknown options decoding for Configure Response Andrey Smirnov
2025-12-06  0:27 ` [BlueZ,v3] " bluez.test.bot
2025-12-08 18:47   ` Luiz Augusto von Dentz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox