From da5211fd185093e75d7c0fd3b04c5c9068c12155 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sat, 10 Nov 2012 17:57:00 +0100 Subject: [PATCH] monitor: Use hcidump fallback only if monitor channel is not present --- monitor/control.c | 13 +++++++++++-- monitor/main.c | 7 ++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/monitor/control.c b/monitor/control.c index 92dc93ab0..3447b7a51 100644 --- a/monitor/control.c +++ b/monitor/control.c @@ -43,8 +43,11 @@ #include "display.h" #include "packet.h" #include "btsnoop.h" +#include "hcidump.h" #include "control.h" +static bool hcidump_fallback = false; + #define MAX_PACKET_SIZE (1486 + 4) struct control_data { @@ -616,6 +619,7 @@ static int open_socket(uint16_t channel) if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) { if (errno == EINVAL) { /* Fallback to hcidump support */ + hcidump_fallback = true; close(fd); return -1; } @@ -801,8 +805,13 @@ int control_tracing(void) if (server_fd >= 0) return 0; - if (open_channel(HCI_CHANNEL_MONITOR) < 0) - return -1; + if (open_channel(HCI_CHANNEL_MONITOR) < 0) { + if (!hcidump_fallback) + return -1; + if (hcidump_tracing() < 0) + return -1; + return 0; + } open_channel(HCI_CHANNEL_CONTROL); diff --git a/monitor/main.c b/monitor/main.c index ac4dc1f64..27a572225 100644 --- a/monitor/main.c +++ b/monitor/main.c @@ -35,7 +35,6 @@ #include "mainloop.h" #include "packet.h" #include "control.h" -#include "hcidump.h" #include "btsnoop.h" static void signal_callback(int signum, void *user_data) @@ -149,10 +148,8 @@ int main(int argc, char *argv[]) return EXIT_SUCCESS; } - if (control_tracing() < 0) { - if (hcidump_tracing() < 0) - return EXIT_FAILURE; - } + if (control_tracing() < 0) + return EXIT_FAILURE; return mainloop_run(); } -- 2.47.3