[PATCH BlueZ v3 2/4] monitor: s/vendor_(evt|event)/\1_vendor/

From: Zijun Hu

Date: Thu Sep 03 2026 - 11:04:53 EST


Kernel include/net/bluetooth/hci.h defines:

#define HCI_EVENT_PKT 0x04
#define HCI_VENDOR_PKT 0xff
#define HCI_EV_VENDOR 0xff

HCI_VENDOR_PKT and HCI_EV_VENDOR share the same value, but are very
different, as the table below shows:

+------------+-----------------------+---------------------------+
| | HCI_VENDOR_PKT | HCI_EV_VENDOR |
+------------+-----------------------+---------------------------+
| Defined by | Vendor | BT SIG |
+------------+-----------------------+---------------------------+
| Hierarchy | Parallel to | Nested inside |
| | HCI_EVENT_PKT | HCI_EVENT_PKT |
+------------+-----------------------+---------------------------+
| Direction | RX and TX | RX only |
+------------+-----------------------+---------------------------+
| kernel <-> | HCI_VENDOR_PKT, ... | 0x04, HCI_EV_VENDOR, ... |
| userspace | | |
+------------+-----------------------+---------------------------+
| kernel <-> | RX: 23, vendor packet | RX: 3, HCI_EV_VENDOR, ... |
| monitor | TX: 22, vendor packet | |
+------------+-----------------------+---------------------------+

monitor is about to gain HCI_VENDOR_PKT support. To avoid confusing the
two, rename what deals with HCI_EV_VENDOR to follow its pattern:

s/vendor_(evt|event)/\1_vendor/
---
monitor/broadcom.c | 10 +++++-----
monitor/broadcom.h | 4 ++--
monitor/intel.c | 16 ++++++++--------
monitor/intel.h | 4 ++--
monitor/msft.c | 6 +++---
monitor/msft.h | 4 ++--
monitor/packet.c | 20 ++++++++++----------
monitor/vendor.c | 2 +-
monitor/vendor.h | 4 ++--
9 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/monitor/broadcom.c b/monitor/broadcom.c
index 80c95e91db0a..0dbc5eb39bb8 100644
--- a/monitor/broadcom.c
+++ b/monitor/broadcom.c
@@ -707,24 +707,24 @@ void broadcom_lm_diag(const void *data, uint8_t size)
}

static void lm_diag_evt(struct timeval *tv, uint16_t index,
const void *data, uint8_t size)
{
broadcom_lm_diag(data, 63);
}

-static const struct vendor_evt vendor_evt_table[] = {
+static const struct evt_vendor evt_vendor_table[] = {
{ 0xb4, "LM Diag", lm_diag_evt, 64, true },
{ }
};

-const struct vendor_evt *broadcom_vendor_evt(uint8_t evt)
+const struct evt_vendor *broadcom_evt_vendor(uint8_t evt)
{
int i;

- for (i = 0; vendor_evt_table[i].str; i++) {
- if (vendor_evt_table[i].evt == evt)
- return &vendor_evt_table[i];
+ for (i = 0; evt_vendor_table[i].str; i++) {
+ if (evt_vendor_table[i].evt == evt)
+ return &evt_vendor_table[i];
}

return NULL;
}
diff --git a/monitor/broadcom.h b/monitor/broadcom.h
index 5cb51d81dbb8..36492a4071a7 100644
--- a/monitor/broadcom.h
+++ b/monitor/broadcom.h
@@ -7,13 +7,13 @@
* Copyright (C) 2002-2010 Marcel Holtmann <marcel@xxxxxxxxxxxx>
*
*
*/

#include <stdint.h>

struct vendor_ocf;
-struct vendor_evt;
+struct evt_vendor;

const struct vendor_ocf *broadcom_vendor_ocf(uint16_t ocf);
-const struct vendor_evt *broadcom_vendor_evt(uint8_t evt);
+const struct evt_vendor *broadcom_evt_vendor(uint8_t evt);
void broadcom_lm_diag(const void *data, uint8_t size);
diff --git a/monitor/intel.c b/monitor/intel.c
index 782fda675422..d52b2dc80e4c 100644
--- a/monitor/intel.c
+++ b/monitor/intel.c
@@ -1286,17 +1286,17 @@ static void system_exception_evt(struct timeval *tv, uint16_t index,
break;
}

print_field("Type: %s (0x%2.2x)", str, type);

packet_hexdump(data + 1, size - 1);
}

-static const struct vendor_evt vendor_evt_table[] = {
+static const struct evt_vendor evt_vendor_table[] = {
{ 0x00, "Startup",
startup_evt, 0, true },
{ 0x01, "Fatal Exception",
fatal_exception_evt, 4, true },
{ 0x02, "Bootup",
bootup_evt, 6, true },
{ 0x05, "Default BD Data",
default_bd_data_evt, 1, true },
@@ -1861,17 +1861,17 @@ static void intel_vendor_ext_evt(struct timeval *tv, uint16_t index,
tlv = process_ext_subevent(tlv, last_tlv);

/* If an error occurs in decoding the subevents, hexdump the packet. */
if (!tlv)
packet_hexdump(data, size);
}

/* Vendor extended events with a vendor prefix. */
-static const struct vendor_evt vendor_prefix_evt_table[] = {
+static const struct evt_vendor vendor_prefix_evt_table[] = {
{ 0x03, "Extended Telemetry", intel_vendor_ext_evt },
{ }
};

static const uint8_t intel_vendor_prefix[] = {0x87, 0x80};
#define INTEL_VENDOR_PREFIX_SIZE sizeof(intel_vendor_prefix)

/*
@@ -1883,17 +1883,17 @@ static const uint8_t intel_vendor_prefix[] = {0x87, 0x80};
* When <subopcode> == 0x03, it is a telemetry event; and
* <data> is a number of tlv data.
*/
struct vendor_prefix_evt {
uint8_t prefix_data[INTEL_VENDOR_PREFIX_SIZE];
uint8_t subopcode;
};

-static const struct vendor_evt *intel_vendor_prefix_evt(const void *data,
+static const struct evt_vendor *intel_vendor_prefix_evt(const void *data,
int *consumed_size)
{
unsigned int i;
const struct vendor_prefix_evt *vnd = data;
char prefix_string[INTEL_VENDOR_PREFIX_SIZE * 2 + 1] = { 0 };

/* Check if the vendor prefix matches. */
for (i = 0; i < INTEL_VENDOR_PREFIX_SIZE; i++) {
@@ -1914,29 +1914,29 @@ static const struct vendor_evt *intel_vendor_prefix_evt(const void *data,
*consumed_size = sizeof(struct vendor_prefix_evt);
return &vendor_prefix_evt_table[i];
}
}

return NULL;
}

-const struct vendor_evt *intel_vendor_evt(const void *data, int *consumed_size)
+const struct evt_vendor *intel_evt_vendor(const void *data, int *consumed_size)
{
uint8_t evt = *((const uint8_t *) data);
int i;

/*
* Handle the vendor event without a vendor prefix.
* 0xff <length> <evt> <data>
- * This loop checks whether the <evt> exists in the vendor_evt_table.
+ * This loop checks whether the <evt> exists in the evt_vendor_table.
*/
- for (i = 0; vendor_evt_table[i].str; i++) {
- if (vendor_evt_table[i].evt == evt)
- return &vendor_evt_table[i];
+ for (i = 0; evt_vendor_table[i].str; i++) {
+ if (evt_vendor_table[i].evt == evt)
+ return &evt_vendor_table[i];
}

/*
* It is not a regular event. Check whether it is a vendor extended
* event that comes with a vendor prefix followed by a subopcode.
*/
return intel_vendor_prefix_evt(data, consumed_size);
}
diff --git a/monitor/intel.h b/monitor/intel.h
index bfb04540c058..e218745a8712 100644
--- a/monitor/intel.h
+++ b/monitor/intel.h
@@ -7,12 +7,12 @@
* Copyright (C) 2002-2010 Marcel Holtmann <marcel@xxxxxxxxxxxx>
*
*
*/

#include <stdint.h>

struct vendor_ocf;
-struct vendor_evt;
+struct evt_vendor;

const struct vendor_ocf *intel_vendor_ocf(uint16_t ocf);
-const struct vendor_evt *intel_vendor_evt(const void *data, int *consumed_size);
+const struct evt_vendor *intel_evt_vendor(const void *data, int *consumed_size);
diff --git a/monitor/msft.c b/monitor/msft.c
index d41f10d68a96..1fd13cf88ea0 100644
--- a/monitor/msft.c
+++ b/monitor/msft.c
@@ -364,23 +364,23 @@ static void msft_evt(struct timeval *tv, uint16_t index,
" (0x%2.2x)", code);

if (code_func)
code_func(data, size);
else
packet_hexdump(data + 1, size - 1);
}

-static const struct vendor_evt vendor_evt_entry = {
+static const struct evt_vendor evt_vendor_entry = {
0x00, "Extension", msft_evt, 1, false
};

-const struct vendor_evt *msft_vendor_evt(void)
+const struct evt_vendor *msft_evt_vendor(void)
{
- return &vendor_evt_entry;
+ return &evt_vendor_entry;
}

bool msft_event_code_valid(uint8_t code)
{
int i;

for (i = 0; evt_table[i].str; i++) {
if (evt_table[i].code == code)
diff --git a/monitor/msft.h b/monitor/msft.h
index ff6c28011018..8ecc925add80 100644
--- a/monitor/msft.h
+++ b/monitor/msft.h
@@ -178,13 +178,13 @@ struct msft_evt_monitor_device {
uint8_t subevt;
uint8_t addr_type;
uint8_t addr[6];
uint8_t handle;
uint8_t state;
} __attribute__((packed));

struct vendor_ocf;
-struct vendor_evt;
+struct evt_vendor;

const struct vendor_ocf *msft_vendor_ocf(void);
-const struct vendor_evt *msft_vendor_evt(void);
+const struct evt_vendor *msft_evt_vendor(void);
bool msft_event_code_valid(uint8_t code);
diff --git a/monitor/packet.c b/monitor/packet.c
index 0d3b23cc3fb7..08051f434ba2 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -11131,46 +11131,46 @@ static const struct vendor_ocf *current_vendor_ocf(uint16_t ocf)
return intel_vendor_ocf(ocf);
case COMPANY_ID_BROADCOM:
return broadcom_vendor_ocf(ocf);
}

return NULL;
}

-static const struct vendor_evt *current_vendor_evt(const void *data,
+static const struct evt_vendor *current_evt_vendor(const void *data,
uint8_t size, int *consumed_size)
{
uint16_t manufacturer;
uint8_t evt = *((const uint8_t *) data);

if (msft_event_prefix_match(data, size)) {
*consumed_size = index_list[index_current].msft_evt_len;
- return msft_vendor_evt();
+ return msft_evt_vendor();
}

/* A regular vendor event consumes 1 byte. */
*consumed_size = 1;

if (index_current < MAX_INDEX)
manufacturer = index_list[index_current].manufacturer;
else
manufacturer = fallback_manufacturer;

switch (manufacturer) {
case COMPANY_ID_INTEL:
- return intel_vendor_evt(data, consumed_size);
+ return intel_evt_vendor(data, consumed_size);
case COMPANY_ID_BROADCOM:
- return broadcom_vendor_evt(evt);
+ return broadcom_evt_vendor(evt);
}

return NULL;
}

-static const char *current_vendor_evt_str(const void *data, uint8_t size)
+static const char *current_evt_vendor_str(const void *data, uint8_t size)
{
uint16_t manufacturer;

if (msft_event_prefix_match(data, size))
return "Microsoft";

if (index_current < MAX_INDEX)
manufacturer = index_list[index_current].manufacturer;
@@ -13791,27 +13791,27 @@ static void le_meta_event_evt(struct timeval *tv, uint16_t index,
subevent_data = &le_meta_event_table[i];
break;
}
}

print_subevent(tv, index, subevent_data, data + 1, size - 1);
}

-static void vendor_evt(struct timeval *tv, uint16_t index,
+static void evt_vendor(struct timeval *tv, uint16_t index,
const void *data, uint8_t size)
{
struct subevent_data vendor_data;
char vendor_str[150];
int consumed_size;
- const struct vendor_evt *vnd = current_vendor_evt(data, size,
+ const struct evt_vendor *vnd = current_evt_vendor(data, size,
&consumed_size);

if (vnd) {
- const char *str = current_vendor_evt_str(data, size);
+ const char *str = current_evt_vendor_str(data, size);

if (str) {
snprintf(vendor_str, sizeof(vendor_str),
"%s %s", str, vnd->str);
vendor_data.str = vendor_str;
} else {
vendor_data.str = vnd->str;
}
@@ -13826,17 +13826,17 @@ static void vendor_evt(struct timeval *tv, uint16_t index,
} else {
uint16_t manufacturer;

if (index_current < MAX_INDEX)
manufacturer = index_list[index_current].manufacturer;
else
manufacturer = fallback_manufacturer;

- vendor_event(manufacturer, data, size);
+ event_vendor(manufacturer, data, size);
}
}

struct event_data {
uint8_t event;
const char *str;
void (*func) (struct timeval *tv, uint16_t index, const void *data,
uint8_t size);
@@ -13993,17 +13993,17 @@ static const struct event_data event_table[] = {
{ 0x56, "Inquiry Response Notification",
inquiry_response_notify_evt, 4, true },
{ 0x57, "Authenticated Payload Timeout Expired",
auth_payload_timeout_expired_evt, 2, true },
{ 0x58, "SAM Status Change" },
{ 0x59, "Encryption Change v2",
encrypt_change_evt_v2, 5, true },
{ 0xfe, "Testing" },
- { 0xff, "Vendor", vendor_evt, 0, false },
+ { 0xff, "Vendor", evt_vendor, 0, false },
{ }
};

void packet_new_index(struct timeval *tv, uint16_t index, const char *label,
uint8_t type, uint8_t bus, const char *name)
{
char details[48];

diff --git a/monitor/vendor.c b/monitor/vendor.c
index ecbfcf2eb817..9942e3d735d8 100644
--- a/monitor/vendor.c
+++ b/monitor/vendor.c
@@ -12,12 +12,12 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#define _GNU_SOURCE
#include "packet.h"
#include "vendor.h"

-void vendor_event(uint16_t manufacturer, const void *data, uint8_t size)
+void event_vendor(uint16_t manufacturer, const void *data, uint8_t size)
{
packet_hexdump(data, size);
}
diff --git a/monitor/vendor.h b/monitor/vendor.h
index 996ed44cb18e..1ce42a645096 100644
--- a/monitor/vendor.h
+++ b/monitor/vendor.h
@@ -17,18 +17,18 @@ struct vendor_ocf {
void (*cmd_func) (uint16_t index, const void *data, uint8_t size);
uint8_t cmd_size;
bool cmd_fixed;
void (*rsp_func) (uint16_t index, const void *data, uint8_t size);
uint8_t rsp_size;
bool rsp_fixed;
};

-struct vendor_evt {
+struct evt_vendor {
uint8_t evt;
const char *str;
void (*evt_func) (struct timeval *tv, uint16_t index,
const void *data, uint8_t size);
uint8_t evt_size;
bool evt_fixed;
};

-void vendor_event(uint16_t manufacturer, const void *data, uint8_t size);
+void event_vendor(uint16_t manufacturer, const void *data, uint8_t size);

--
2.34.1