From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ] monitor: Decode vendor codecs of BT_HCI_CMD_READ_LOCAL_CODECS_V2
Date: Wed, 16 Nov 2022 13:18:36 -0800 [thread overview]
Message-ID: <20221116211836.2671441-1-luiz.dentz@gmail.com> (raw)
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This attempts to decode the vendor codecs includec in the response of
BT_HCI_CMD_READ_LOCAL_CODECS_V2.
---
monitor/bt.h | 6 ++++++
monitor/packet.c | 25 +++++++++++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/monitor/bt.h b/monitor/bt.h
index 7aa016a0e2a8..97501c7dc939 100644
--- a/monitor/bt.h
+++ b/monitor/bt.h
@@ -1787,6 +1787,12 @@ struct bt_hci_rsp_read_local_pairing_options {
#define BT_HCI_LOCAL_CODEC_LE_CIS BIT(2)
#define BT_HCI_LOCAL_CODEC_LE_BIS BIT(3)
+struct bt_hci_vnd_codec_v2 {
+ uint16_t cid;
+ uint16_t vid;
+ uint8_t transport;
+} __attribute__ ((packed));
+
struct bt_hci_vnd_codec {
uint8_t id;
uint16_t cid;
diff --git a/monitor/packet.c b/monitor/packet.c
index dae763e22e61..134cf398a66f 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -6384,6 +6384,20 @@ static void print_list(const void *data, uint8_t size, int num_items,
print_hex_field("", data, size);
}
+static void print_vnd_codecs_v2(const void *data, int i)
+{
+ const struct bt_hci_vnd_codec_v2 *codec = data;
+ uint8_t mask;
+
+ packet_print_company(" Company ID", le16_to_cpu(codec->cid));
+ print_field(" Vendor Codec ID: 0x%4.4x", le16_to_cpu(codec->vid));
+ print_field(" Logical Transport Type: 0x%02x", codec->transport);
+ mask = print_bitfield(4, codec->transport, codec_transport_table);
+ if (mask)
+ print_text(COLOR_UNKNOWN_SERVICE_CLASS,
+ " Unknown transport (0x%2.2x)", mask);
+}
+
static void read_local_codecs_rsp_v2(uint16_t index, const void *data,
uint8_t size)
{
@@ -6417,7 +6431,18 @@ static void read_local_codecs_rsp_v2(uint16_t index, const void *data,
num_vnd_codecs = rsp->codec[rsp->num_codecs].id;
+ size -= 1;
+
print_field("Number of vendor codecs: %d", num_vnd_codecs);
+
+ if (size < num_vnd_codecs * sizeof(*rsp->codec)) {
+ print_field("Invalid number of vendor codecs.");
+ return;
+ }
+
+ print_list(&rsp->codec[rsp->num_codecs] + 1, size, num_vnd_codecs,
+ sizeof(struct bt_hci_vnd_codec_v2),
+ print_vnd_codecs_v2);
}
static void print_path_direction(const char *prefix, uint8_t dir)
--
2.37.3
next reply other threads:[~2022-11-16 21:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-16 21:18 Luiz Augusto von Dentz [this message]
2022-11-16 22:24 ` [BlueZ] monitor: Decode vendor codecs of BT_HCI_CMD_READ_LOCAL_CODECS_V2 bluez.test.bot
2022-11-18 2:32 ` bluez.test.bot
2022-11-18 4:17 ` bluez.test.bot
2022-11-18 5:08 ` bluez.test.bot
2022-11-18 5:09 ` bluez.test.bot
2022-11-18 5:38 ` bluez.test.bot
2022-11-18 6:27 ` bluez.test.bot
2022-11-19 5:42 ` bluez.test.bot
2022-12-02 21:25 ` [PATCH BlueZ] " 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=20221116211836.2671441-1-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox