diff --git a/monitor/main.c b/monitor/main.c
index 8a12a6d..ac4dc1f 100644
--- a/monitor/main.c
+++ b/monitor/main.c
#endif
#include <stdio.h>
+#include <ctype.h>
#include <stdlib.h>
+#include <string.h>
#include <getopt.h>
#include "mainloop.h"
"\t-r, --read <file> Read traces in btsnoop format\n"
"\t-w, --write <file> Save traces in btsnoop format\n"
"\t-s, --server <socket> Start monitor server socket\n"
+ "\t-i, --index <num> Show only specified controller\n"
"\t-t, --time Show time instead of time offset\n"
"\t-T, --date Show time and date information\n"
"\t-h, --help Show help options\n");
static const struct option main_options[] = {
{ "read", required_argument, NULL, 'r' },
- { "write", required_argument, NULL, 'b' },
- { "server", required_argument, NULL, 'r' },
+ { "write", required_argument, NULL, 'w' },
+ { "server", required_argument, NULL, 's' },
+ { "index", required_argument, NULL, 'i' },
{ "time", no_argument, NULL, 't' },
{ "date", no_argument, NULL, 'T' },
{ "version", no_argument, NULL, 'v' },
int main(int argc, char *argv[])
{
unsigned long filter_mask = 0;
- const char *reader_path = NULL;
+ const char *str, *reader_path = NULL;
sigset_t mask;
mainloop_init();
for (;;) {
int opt;
- opt = getopt_long(argc, argv, "r:w:s:tTvh",
+ opt = getopt_long(argc, argv, "r:w:s:i:tTvh",
main_options, NULL);
if (opt < 0)
break;
case 's':
control_server(optarg);
break;
+ case 'i':
+ if (strlen(optarg) > 3 && !strncmp(optarg, "hci", 3))
+ str = optarg + 3;
+ else
+ str = optarg;
+ if (!isdigit(*str)) {
+ usage();
+ return EXIT_FAILURE;
+ }
+ packet_select_index(atoi(str));
+ break;
case 't':
filter_mask &= ~PACKET_FILTER_SHOW_TIME_OFFSET;
filter_mask |= PACKET_FILTER_SHOW_TIME;
diff --git a/monitor/packet.c b/monitor/packet.c
index a080ff7..fea13df 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
static time_t time_offset = ((time_t) -1);
static unsigned long filter_mask = 0;
+static bool index_filter = false;
+static uint16_t index_number = 0;
void packet_set_filter(unsigned long filter)
{
void packet_add_filter(unsigned long filter)
{
+ if (index_filter)
+ filter &= ~PACKET_FILTER_SHOW_INDEX;
+
filter_mask |= filter;
}
filter_mask &= ~filter;
}
+void packet_select_index(uint16_t index)
+{
+ filter_mask &= ~PACKET_FILTER_SHOW_INDEX;
+
+ index_filter = true;
+ index_number = index;
+}
+
#define print_space(x) printf("%*c", (x), ' ');
static void print_packet(struct timeval *tv, uint16_t index, char ident,
void packet_control(struct timeval *tv, uint16_t index, uint16_t opcode,
const void *data, uint16_t size)
{
+ if (index_filter && index_number != index)
+ return;
+
control_message(opcode, data, size);
}
const struct monitor_new_index *ni;
char str[18], extra_str[24];
+ if (index_filter && index_number != index)
+ return;
+
if (tv && time_offset == ((time_t) -1))
time_offset = tv->tv_sec;
diff --git a/monitor/packet.h b/monitor/packet.h
index 711e35c..9a12376 100644
--- a/monitor/packet.h
+++ b/monitor/packet.h
void packet_add_filter(unsigned long filter);
void packet_del_filter(unsigned long filter);
+void packet_select_index(uint16_t index);
+
void packet_hexdump(const unsigned char *buf, uint16_t len);
void packet_control(struct timeval *tv, uint16_t index, uint16_t opcode,