From 88727a38324214813a826afda104fbb5d8a599ac Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 8 Nov 2015 03:48:21 +0100 Subject: [PATCH] monitor: Add support for user logging priority selection --- monitor/main.c | 6 +++++- monitor/packet.c | 9 +++++++++ monitor/packet.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/monitor/main.c b/monitor/main.c index de48db57d..faf629e2b 100644 --- a/monitor/main.c +++ b/monitor/main.c @@ -61,6 +61,7 @@ static void usage(void) "\t-w, --write Save traces in btsnoop format\n" "\t-a, --analyze Analyze traces in btsnoop format\n" "\t-s, --server Start monitor server socket\n" + "\t-p, --priority Show only priority or lower\n" "\t-i, --index Show only specified controller\n" "\t-t, --time Show time instead of time offset\n" "\t-T, --date Show time and date information\n" @@ -104,7 +105,7 @@ int main(int argc, char *argv[]) for (;;) { int opt; - opt = getopt_long(argc, argv, "r:w:a:s:i:tTSE:vh", + opt = getopt_long(argc, argv, "r:w:a:s:p:i:tTSE:vh", main_options, NULL); if (opt < 0) break; @@ -122,6 +123,9 @@ int main(int argc, char *argv[]) case 's': control_server(optarg); break; + case 'p': + packet_set_priority(optarg); + break; case 'i': if (strlen(optarg) > 3 && !strncmp(optarg, "hci", 3)) str = optarg + 3; diff --git a/monitor/packet.c b/monitor/packet.c index 86745420d..1e3fc4c0b 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -88,6 +88,7 @@ #define COLOR_PHY_PACKET COLOR_BLUE static time_t time_offset = ((time_t) -1); +static int priority_level = 6; static unsigned long filter_mask = 0; static bool index_filter = false; static uint16_t index_number = 0; @@ -160,6 +161,11 @@ void packet_del_filter(unsigned long filter) filter_mask &= ~filter; } +void packet_set_priority(const char *priority) +{ + priority_level = atoi(priority); +} + void packet_select_index(uint16_t index) { filter_mask &= ~PACKET_FILTER_SHOW_INDEX; @@ -8717,6 +8723,9 @@ void packet_user_logging(struct timeval *tv, struct ucred *cred, const char *label; const char *color; + if (priority > priority_level) + return; + switch (priority) { case 0x03: color = COLOR_ERROR; diff --git a/monitor/packet.h b/monitor/packet.h index 218a63b9d..322f1019a 100644 --- a/monitor/packet.h +++ b/monitor/packet.h @@ -38,6 +38,7 @@ void packet_set_filter(unsigned long filter); void packet_add_filter(unsigned long filter); void packet_del_filter(unsigned long filter); +void packet_set_priority(const char *priority); void packet_select_index(uint16_t index); void packet_hexdump(const unsigned char *buf, uint16_t len); -- 2.47.3