monitor: Fix incorrect vendor name for vendor cmd and evt
authorTedd Ho-Jeong An <tedd.an@intel.com>
Fri, 14 Oct 2022 18:57:20 +0000 (11:57 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:55 +0000 (14:55 +0530)
This patch fixes the issue that the vendor name for all vendor HCI
command and event are display as Microsoft.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
monitor/packet.c

index b00d0cc..f579ac0 100755 (executable)
@@ -9815,7 +9815,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;
 
@@ -9827,7 +9827,8 @@ 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) {
@@ -9879,22 +9880,16 @@ static const struct vendor_ocf *current_vendor_ocf(uint16_t ocf)
 static const struct vendor_evt *current_vendor_evt(const void *data,
                                                        int *consumed_size)
 {
-       uint16_t manufacturer, msft_opcode;
+       uint16_t manufacturer;
        uint8_t evt = *((const uint8_t *) data);
 
        /* A regular vendor event consumes 1 byte. */
        *consumed_size = 1;
 
-       if (index_current < MAX_INDEX) {
+       if (index_current < MAX_INDEX)
                manufacturer = index_list[index_current].manufacturer;
-               msft_opcode = index_list[index_current].msft_opcode;
-       } else {
+       else
                manufacturer = fallback_manufacturer;
-               msft_opcode = BT_HCI_CMD_NOP;
-       }
-
-       if (msft_opcode != BT_HCI_CMD_NOP)
-               return NULL;
 
        switch (manufacturer) {
        case 2:
@@ -9910,6 +9905,27 @@ static const struct vendor_evt *current_vendor_evt(const void *data,
        return NULL;
 }
 
+static const char *current_vendor_evt_str(void)
+{
+       uint16_t manufacturer;
+
+       if (index_current < MAX_INDEX)
+               manufacturer = index_list[index_current].manufacturer;
+       else
+               manufacturer = fallback_manufacturer;
+
+       switch (manufacturer) {
+       case 2:
+               return "Intel";
+       case 15:
+               return "Broadcom";
+       case 93:
+               return "Realtek";
+       }
+
+       return NULL;
+}
+
 static void inquiry_complete_evt(uint16_t index, const void *data, uint8_t size)
 {
        const struct bt_hci_evt_inquiry_complete *evt = data;
@@ -10090,7 +10106,7 @@ static void cmd_complete_evt(uint16_t index, 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),
@@ -10182,7 +10198,7 @@ static void cmd_status_evt(uint16_t index, 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),
@@ -11624,7 +11640,7 @@ static void vendor_evt(uint16_t index, const void *data, uint8_t size)
        const struct vendor_evt *vnd = current_vendor_evt(data, &consumed_size);
 
        if (vnd) {
-               const char *str = current_vendor_str();
+               const char *str = current_vendor_evt_str();
 
                if (str) {
                        snprintf(vendor_str, sizeof(vendor_str),
@@ -12026,7 +12042,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),