Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1046801rwi; Fri, 14 Oct 2022 12:03:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7jd8g8nnBZCKttvXxyh3CyTBSOoR6A92GUymvvmgvJgHvxvuO4wB4zSn3O+GMjI1XGT4VQ X-Received: by 2002:a65:44c5:0:b0:439:4697:ead0 with SMTP id g5-20020a6544c5000000b004394697ead0mr5705785pgs.45.1665774211238; Fri, 14 Oct 2022 12:03:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665774211; cv=none; d=google.com; s=arc-20160816; b=vE3r7bemHV3dDWuP7913+jgQzm4Mv/W46mxkxp1YYnaVX2VkD71ulyCdPHJZM4ZeyV cqID714aCQlVffEExulVnEimdfgTtMlNIuxnIqd4KrODPNn95nobG89BpyFlq2d87/OM P7/+Z4FChRgP3j98CfxfqsCPf4GoY2cJDejl2BmjtUNbqmum1MvctBjjDRIgcPIZOwYT LqALeAzR0izKSCAf7nYilHkEFTqPSm/ulhvLbCJFraVzKEjx3Q/wKKK6L3gGrNuVk9r8 Vq/dY8YmzrGwqhHBCCLt9tc5q9e0SDix9fF5pqejp5vJsqXE1wPmwHLgjS7fCjg08Frg zB6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=RX30rg6WmboD9/oaN/9GsKnM75vpU7IW8psSf4cD6g0=; b=bSm2lG1VWAO/SU0MJsWs3xABBW79J4Dva+SANxmuvva+jYrbp8+VRYz/0wSB9x9P47 IkBj9z/p4OaR/n71nQTN1hD3UgD/bY1z8JtBiPwf3oXNLlju0ikKo1ZIR+aEIZ6f5US+ Tiw/0VwyopyIBC6RdCd1fFcwMECuaGibkx3gHxBU5O062h8XFhkBId4TYcOLoTXCPfop 4x04cwaZoyxfmhTCRnyF5JNMAr2WhaTxCygOL814QwoSOONZGPGwemSPDwYV2+1D+Nhu u2ekUmozuLjkXzua/BSjuG0dHJeZ8g9NbM4QH1e0lYcjqA4ndui41wcMOGuvEUy0ejuO cBMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="iRcQg/dK"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i5-20020a170902c94500b001781ab0b3c4si4323657pla.313.2022.10.14.12.03.03; Fri, 14 Oct 2022 12:03:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="iRcQg/dK"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230448AbiJNS5Y (ORCPT + 99 others); Fri, 14 Oct 2022 14:57:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230158AbiJNS5X (ORCPT ); Fri, 14 Oct 2022 14:57:23 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 229291D3748 for ; Fri, 14 Oct 2022 11:57:23 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id g28so5718104pfk.8 for ; Fri, 14 Oct 2022 11:57:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=RX30rg6WmboD9/oaN/9GsKnM75vpU7IW8psSf4cD6g0=; b=iRcQg/dKXDqtd8PoaQuczupOa+QvlOh/sxZREVYHfc+/ZbXEHZD3msz9bwUezOxQrt jrUJdrKRdPcc/gB5yp/rEFjglkZAy/T0eGg24hlVBf6B62caUNUQDuGLSYI1B9XLV9XG flaFzpo9laV/p4VC5yuFbnKmtZe/qvdrbR3jbbZm5BZ0OaV9Y7GkWC45S1YkDg1Qa8KG 0+dIdvl3p801YheyX6arrdSTn/9luxdcFZzSwtqgTBhWjIhneu5Nx1rbhzeddgXTYmZD JGPG3jZzkgfm3/m+B4r+0CvGpxqi8nffLOjasGtS1eXbemP2LH5Q1JCV7EA4ugXL8k2L lrpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=RX30rg6WmboD9/oaN/9GsKnM75vpU7IW8psSf4cD6g0=; b=iAgBuOBVkCaz0e5hZ3G1T22UyM6BORyiaMs8hqD0wy9HPaIFmg+ilsbTxtIxmtYgFh NKwaf9JQhSZAnAYDHb5OXU9KeeGNEn4/Vvmup0zB4SnygZj9pZZ+a2RDSBw0c8dTBOzZ 8L+U48gJBdOAl38CJyI5Wag3dhC/OMNQM/WJ1KYhI4474bvt/uYAb2nh62kaIUX9xmzG A2W45rVc3J08Kho/m8DeDtlh7odmJYkpJHMYeNKlpT96yCJr0ULZ8yzUGP2PzZHMGBxJ 4f2WVplvLIu86WjElGe8xuOjGprXTatxJ9dyTn7sFMZspmbm69cNodtZ+SwTCXV37Jxu FkmA== X-Gm-Message-State: ACrzQf3prosbf/GcteSpYY2hJr8Vr67C/B8mvZM/9Z3WrUn3RRww/I6G pzn3Rbqov4+LDiqbdANvln1C23O20tY= X-Received: by 2002:a65:6bca:0:b0:420:712f:ab98 with SMTP id e10-20020a656bca000000b00420712fab98mr5679580pgw.350.1665773842394; Fri, 14 Oct 2022 11:57:22 -0700 (PDT) Received: from han1-NUC8i7BEH.hsd1.or.comcast.net ([2601:1c0:6a80:cc40:ab40:7d71:fa07:4ac4]) by smtp.gmail.com with ESMTPSA id p4-20020a637f44000000b0043954df3162sm1740730pgn.10.2022.10.14.11.57.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 11:57:21 -0700 (PDT) From: Tedd Ho-Jeong An To: linux-bluetooth@vger.kernel.org Subject: [BlueZ PATCH v2] monitor: Fix incorrect vendor name for vendor cmd and evt Date: Fri, 14 Oct 2022 11:57:20 -0700 Message-Id: <20221014185720.1132417-1-hj.tedd.an@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Tedd Ho-Jeong An This patch fixes the issue that the vendor name for all vendor HCI command and event are display as Microsoft. --- monitor/packet.c | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/monitor/packet.c b/monitor/packet.c index 692012029..c4e5182f0 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -9821,7 +9821,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; @@ -9833,7 +9833,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) { @@ -9877,22 +9878,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: @@ -9904,6 +9899,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; @@ -10084,7 +10100,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), @@ -10176,7 +10192,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), @@ -11618,7 +11634,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), @@ -12020,7 +12036,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.34.1