2021-04-15 01:50:09

by Tedd Ho-Jeong An

[permalink] [raw]
Subject: [RFC BlueZ v2] monitor: Fix the incorrect vendor name

From: Tedd Ho-Jeong An <[email protected]>

This patch fixes the vendor name is alwasy shown as "Microsoft".

< HCI Command: Microsoft Secure Send (0x3f|0x0009) plen 249
Type: Data fragment (0x01)
> HCI Event: Command Complete (0x0e) plen 4
Microsoft Secure Send (0x3f|0x0009) ncmd 31
Status: Success (0x00)
---
monitor/packet.c | 56 +++++++++++++++++++++++++++++++++++++-----------
1 file changed, 44 insertions(+), 12 deletions(-)

diff --git a/monitor/packet.c b/monitor/packet.c
index d729a01cc..30ed9944c 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -266,6 +266,7 @@ struct index_data {
uint8_t bdaddr[6];
uint16_t manufacturer;
uint16_t msft_opcode;
+ uint8_t msft_evt_code;
size_t frame;
};

@@ -3940,6 +3941,7 @@ void packet_monitor(struct timeval *tv, struct ucred *cred,
memcpy(index_list[index].bdaddr, ni->bdaddr, 6);
index_list[index].manufacturer = fallback_manufacturer;
index_list[index].msft_opcode = BT_HCI_CMD_NOP;
+ index_list[index].msft_evt_code = 0x00;
}

addr2str(ni->bdaddr, str);
@@ -4006,9 +4008,11 @@ void packet_monitor(struct timeval *tv, struct ucred *cred,
/*
* Intel controllers that support the
* Microsoft vendor extension are using
- * 0xFC1E for VsMsftOpCode.
+ * 0xFC1E for VsMsftOpCode and 0x50 for event
+ * code.
*/
index_list[index].msft_opcode = 0xFC1E;
+ index_list[index].msft_evt_code = 0x50;
break;
case 93:
/*
@@ -9323,7 +9327,7 @@ static const char *get_supported_command(int bit)
return NULL;
}

-static const char *current_vendor_str(void)
+static const char *current_vendor_str(uint16_t ocf)
{
uint16_t manufacturer, msft_opcode;

@@ -9335,7 +9339,35 @@ static const char *current_vendor_str(void)
msft_opcode = BT_HCI_CMD_NOP;
}

- if (msft_opcode != BT_HCI_CMD_NOP)
+ if (msft_opcode != BT_HCI_CMD_NOP &&
+ cmd_opcode_ocf(msft_opcode) == ocf)
+ return "Microsoft";
+
+ switch (manufacturer) {
+ case 2:
+ return "Intel";
+ case 15:
+ return "Broadcom";
+ case 93:
+ return "Realtek";
+ }
+
+ return NULL;
+}
+
+static const char *current_vendor_evt_str(uint8_t evt)
+{
+ uint16_t manufacturer, msft_evt_code;
+
+ if (index_current < MAX_INDEX) {
+ manufacturer = index_list[index_current].manufacturer;
+ msft_evt_code = index_list[index_current].msft_evt_code;
+ } else {
+ manufacturer = fallback_manufacturer;
+ msft_evt_code = 0x00;
+ }
+
+ if (msft_evt_code == evt)
return "Microsoft";

switch (manufacturer) {
@@ -9378,18 +9410,18 @@ static const struct vendor_ocf *current_vendor_ocf(uint16_t ocf)

static const struct vendor_evt *current_vendor_evt(uint8_t evt)
{
- uint16_t manufacturer, msft_opcode;
+ uint16_t manufacturer, msft_evt_code;

if (index_current < MAX_INDEX) {
manufacturer = index_list[index_current].manufacturer;
- msft_opcode = index_list[index_current].msft_opcode;
+ msft_evt_code = index_list[index_current].msft_evt_code;
} else {
manufacturer = fallback_manufacturer;
- msft_opcode = BT_HCI_CMD_NOP;
+ msft_evt_code = 0x00;
}

- if (msft_opcode != BT_HCI_CMD_NOP)
- return NULL;
+ if (msft_evt_code == evt)
+ return msft_vendor_evt();

switch (manufacturer) {
case 2:
@@ -9573,7 +9605,7 @@ static void cmd_complete_evt(const void *data, uint8_t size)
const struct vendor_ocf *vnd = current_vendor_ocf(ocf);

if (vnd) {
- const char *str = current_vendor_str();
+ const char *str = current_vendor_str(ocf);

if (str) {
snprintf(vendor_str, sizeof(vendor_str),
@@ -9665,7 +9697,7 @@ static void cmd_status_evt(const void *data, uint8_t size)
const struct vendor_ocf *vnd = current_vendor_ocf(ocf);

if (vnd) {
- const char *str = current_vendor_str();
+ const char *str = current_vendor_str(ocf);

if (str) {
snprintf(vendor_str, sizeof(vendor_str),
@@ -11018,7 +11050,7 @@ static void vendor_evt(const void *data, uint8_t size)
const struct vendor_evt *vnd = current_vendor_evt(subevent);

if (vnd) {
- const char *str = current_vendor_str();
+ const char *str = current_vendor_evt_str(subevent);

if (str) {
snprintf(vendor_str, sizeof(vendor_str),
@@ -11419,7 +11451,7 @@ void packet_hci_command(struct timeval *tv, struct ucred *cred, uint16_t index,
const struct vendor_ocf *vnd = current_vendor_ocf(ocf);

if (vnd) {
- const char *str = current_vendor_str();
+ const char *str = current_vendor_str(ocf);

if (str) {
snprintf(vendor_str, sizeof(vendor_str),
--
2.25.1


2021-04-15 02:38:15

by bluez.test.bot

[permalink] [raw]
Subject: RE: [RFC,BlueZ,v2] monitor: Fix the incorrect vendor name

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=467397

---Test result---

Test Summary:
CheckPatch PASS 0.36 seconds
GitLint PASS 0.12 seconds
Prep - Setup ELL PASS 48.80 seconds
Build - Prep PASS 0.12 seconds
Build - Configure PASS 8.55 seconds
Build - Make PASS 204.79 seconds
Make Check PASS 9.22 seconds
Make Dist PASS 12.94 seconds
Make Dist - Configure PASS 5.25 seconds
Make Dist - Make PASS 84.41 seconds
Build w/ext ELL - Configure PASS 8.55 seconds
Build w/ext ELL - Make PASS 196.08 seconds

Details
##############################
Test: CheckPatch - PASS
Desc: Run checkpatch.pl script with rule in .checkpatch.conf

##############################
Test: GitLint - PASS
Desc: Run gitlint with rule in .gitlint

##############################
Test: Prep - Setup ELL - PASS
Desc: Clone, build, and install ELL

##############################
Test: Build - Prep - PASS
Desc: Prepare environment for build

##############################
Test: Build - Configure - PASS
Desc: Configure the BlueZ source tree

##############################
Test: Build - Make - PASS
Desc: Build the BlueZ source tree

##############################
Test: Make Check - PASS
Desc: Run 'make check'

##############################
Test: Make Dist - PASS
Desc: Run 'make dist' and build the distribution tarball

##############################
Test: Make Dist - Configure - PASS
Desc: Configure the source from distribution tarball

##############################
Test: Make Dist - Make - PASS
Desc: Build the source from distribution tarball

##############################
Test: Build w/ext ELL - Configure - PASS
Desc: Configure BlueZ source with '--enable-external-ell' configuration

##############################
Test: Build w/ext ELL - Make - PASS
Desc: Build BlueZ source with '--enable-external-ell' configuration



---
Regards,
Linux Bluetooth