From 984ced2d10b8c02e64e8404891466eb1cf5785cc Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Wed, 23 Feb 2011 17:18:17 +0100 Subject: [PATCH] [Listener] Add option display_captured (-c/-Q) The packet captured are no longer displayed when in verbose mode. The new option 'display_captured' (or command-line -c) activates this behaviour. One can use -Q to deactivate. --- .../owlps-listener/owlps-listener.h | 14 +++++++++- .../owlps-listener/owlps-listenerd.c | 26 +++++++++++++++---- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/infrastructure-centred/owlps-listener/owlps-listener.h b/infrastructure-centred/owlps-listener/owlps-listener.h index 29716ed..658ed81 100644 --- a/infrastructure-centred/owlps-listener/owlps-listener.h +++ b/infrastructure-centred/owlps-listener/owlps-listener.h @@ -57,7 +57,7 @@ /* Arguments & program configuration */ -#define OPTIONS "Aa:d:f:hH:kl:m:n:p:P:qr:t:vVw:" // getopt string +#define OPTIONS "Aa:cd:f:hH:kl:m:n:p:P:qQr:t:vVw:" // getopt string #define DEFAULT_CONFIG_FILE "/usr/local/etc/owlps/owlps-listener.conf" enum {MODE_ACTIVE = 'a', MODE_PASSIVE = 'p', MODE_MIXED = 'm'} ; #define DEFAULT_AUTOCALIBRATION_HELLO_DELAY 120 // seconds @@ -170,6 +170,12 @@ void print_version(void) ; (cfg_setbool(cfg, "verbose", cfg_false)) #define GET_VERBOSE() \ (cfg_getbool(cfg, "verbose")) +#define SET_DISPLAY_CAPTURED() \ + (cfg_setbool(cfg, "display_captured", cfg_true)) +#define UNSET_DISPLAY_CAPTURED() \ + (cfg_setbool(cfg, "display_captured", cfg_false)) +#define GET_DISPLAY_CAPTURED() \ + (cfg_getbool(cfg, "display_captured")) /* Home-made structure macros */ #else // USE_CONFIG_FILE @@ -237,6 +243,12 @@ void print_version(void) ; (options.verbose = FALSE) #define GET_VERBOSE() \ (options.verbose) +#define SET_DISPLAY_CAPTURED() \ + (options.display_captured = TRUE) +#define UNSET_DISPLAY_CAPTURED() \ + (options.display_captured = FALSE) +#define GET_DISPLAY_CAPTURED() \ + (options.display_captured) #endif // USE_CONFIG_FILE diff --git a/infrastructure-centred/owlps-listener/owlps-listenerd.c b/infrastructure-centred/owlps-listener/owlps-listenerd.c index 34ab079..8f4fd76 100644 --- a/infrastructure-centred/owlps-listener/owlps-listenerd.c +++ b/infrastructure-centred/owlps-listener/owlps-listenerd.c @@ -42,6 +42,7 @@ struct { int autocalibration_nb_packets ; #endif // USE_PTHREAD BOOL verbose ; + BOOL display_captured ; } options = { // Initalise default options: MODE_ACTIVE, "127.0.0.1", @@ -60,6 +61,7 @@ struct { DEFAULT_AUTOCALIBRATION_DELAY, DEFAULT_AUTOCALIBRATION_NBPKT, #endif // USE_PTHREAD + FALSE, FALSE } ; #endif // USE_CONFIG_FILE @@ -181,8 +183,10 @@ void parse_config_file(int argc, char **argv) CFG_INT("autocalibration_nb_packets", DEFAULT_AUTOCALIBRATION_NBPKT, CFGF_NONE), #endif // USE_PTHREAD - // Display capture packets, or not: + // Be verbose, or not: CFG_BOOL("verbose", cfg_false, CFGF_NONE), + // Display captured packets, or not: + CFG_BOOL("display_captured", cfg_false, CFGF_NONE), CFG_END() } ; @@ -272,6 +276,9 @@ void parse_command_line(int argc, char **argv) SET_AUTOCALIBRATION_PORT(strtol(optarg, NULL, 0)) ; #endif // USE_PTHREAD break ; + case 'c' : + SET_DISPLAY_CAPTURED() ; + break ; case 'd' : SET_AGGREGATION_IP(optarg) ; break ; @@ -316,6 +323,9 @@ void parse_command_line(int argc, char **argv) case 'q' : UNSET_VERBOSE() ; break ; + case 'Q' : + UNSET_DISPLAY_CAPTURED() ; + break ; case 'r' : SET_RTAP_IFACE(optarg) ; break ; @@ -400,6 +410,7 @@ void print_configuration() "autocalibration_nb_packets = %d\n" #endif // USE_PTHREAD "verbose = %s\n" + "display_captured = %s\n" , GET_MODE(), GET_AGGREGATION_IP(), @@ -416,7 +427,8 @@ void print_configuration() GET_AUTOCALIBRATION_DELAY(), GET_AUTOCALIBRATION_NBPKT(), #endif // USE_PTHREAD - BOOL_TO_STRING(GET_VERBOSE()) + BOOL_TO_STRING(GET_VERBOSE()), + BOOL_TO_STRING(GET_DISPLAY_CAPTURED()) ) ; #endif // USE_CONFIG_FILE } @@ -776,7 +788,8 @@ void read_packet(u_char *args, const struct pcap_pkthdr *header, rtap_presentflags /= 2 ; } - if (GET_VERBOSE()) + /* Display the packet details */ + if (GET_DISPLAY_CAPTURED()) { char *ap_mac_string = mac_bytes_to_string(couple.ap_mac_addr_bytes) ; @@ -1017,7 +1030,8 @@ void print_usage() printf("Usage :\n" "\t%s [-f config_file] [-m mode] [-d aggregation_ip]" " [-l listening_port] [-p aggregation_port] -r rtap_iface" - " [-w wifi_iface] [-k] [-v | -q] [-A] [-a autocalibration_port]" + " [-w wifi_iface] [-k] [-v | -q] [-c | -Q] [-A]" + " [-a autocalibration_port]" " [-H autocalibration_hello_delay] [-t autocalibration_delay]" " [-n autocalibration_nb_packets]\n" "\t%s -h\n" @@ -1063,8 +1077,10 @@ void print_usage() " drivers that disable monitor mode periodically. Available" " only if the program was compiled with support of POSIX" " threads.\n" - "\t-v\tVerbose mode (display captured packets).\n" + "\t-v\tVerbose mode (display what we do).\n" "\t-q\tQuiet mode (default).\n" + "\t-c\tDisplay captured packets.\n" + "\t-Q\tDo not display captured packets (default).\n" , program_name, program_name,