From 929ade555d43d80642aafbed70e7d2fd7147aa2d Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 6 Jan 2014 11:50:58 -0800 Subject: [PATCH] monitor: Move new index opcode structure into btsnoop header --- monitor/btsnoop.h | 7 +++++++ monitor/packet.c | 19 +++++-------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/monitor/btsnoop.h b/monitor/btsnoop.h index cdefb8cc5..5067f4546 100644 --- a/monitor/btsnoop.h +++ b/monitor/btsnoop.h @@ -42,6 +42,13 @@ #define BTSNOOP_OPCODE_SCO_TX_PKT 6 #define BTSNOOP_OPCODE_SCO_RX_PKT 7 +struct btsnoop_opcode_new_index { + uint8_t type; + uint8_t bus; + uint8_t bdaddr[6]; + char name[8]; +} __attribute__((packed)); + void btsnoop_create(const char *path, uint32_t type); void btsnoop_write(struct timeval *tv, uint32_t flags, const void *data, uint16_t size); diff --git a/monitor/packet.c b/monitor/packet.c index 8b298d3e2..03d0d5de5 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -3088,17 +3088,6 @@ void packet_control(struct timeval *tv, uint16_t index, uint16_t opcode, control_message(opcode, data, size); } -struct monitor_new_index { - uint8_t type; - uint8_t bus; - bdaddr_t bdaddr; - char name[8]; -} __attribute__((packed)); - -#define MONITOR_NEW_INDEX_SIZE 16 - -#define MONITOR_DEL_INDEX_SIZE 0 - #define MAX_INDEX 16 struct index_data { @@ -3111,8 +3100,9 @@ static struct index_data index_list[MAX_INDEX]; void packet_monitor(struct timeval *tv, uint16_t index, uint16_t opcode, const void *data, uint16_t size) { - const struct monitor_new_index *ni; + const struct btsnoop_opcode_new_index *ni; char str[18], extra_str[24]; + bdaddr_t bdaddr; if (index_filter && index_number != index) return; @@ -3125,13 +3115,14 @@ void packet_monitor(struct timeval *tv, uint16_t index, uint16_t opcode, switch (opcode) { case BTSNOOP_OPCODE_NEW_INDEX: ni = data; + memcpy(&bdaddr, ni->bdaddr, 6); if (index < MAX_INDEX) { index_list[index].type = ni->type; - bacpy(&index_list[index].bdaddr, &ni->bdaddr); + memcpy(&index_list[index].bdaddr, &bdaddr, 6); } - ba2str(&ni->bdaddr, str); + ba2str(&bdaddr, str); packet_new_index(tv, index, str, ni->type, ni->bus, ni->name); break; case BTSNOOP_OPCODE_DEL_INDEX: -- 2.47.3