[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.
This commit is contained in:
Matteo Cypriani 2011-02-23 17:18:17 +01:00
parent ac8438a33b
commit 984ced2d10
2 changed files with 34 additions and 6 deletions

View File

@ -57,7 +57,7 @@
/* Arguments & program configuration */ /* 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" #define DEFAULT_CONFIG_FILE "/usr/local/etc/owlps/owlps-listener.conf"
enum {MODE_ACTIVE = 'a', MODE_PASSIVE = 'p', MODE_MIXED = 'm'} ; enum {MODE_ACTIVE = 'a', MODE_PASSIVE = 'p', MODE_MIXED = 'm'} ;
#define DEFAULT_AUTOCALIBRATION_HELLO_DELAY 120 // seconds #define DEFAULT_AUTOCALIBRATION_HELLO_DELAY 120 // seconds
@ -170,6 +170,12 @@ void print_version(void) ;
(cfg_setbool(cfg, "verbose", cfg_false)) (cfg_setbool(cfg, "verbose", cfg_false))
#define GET_VERBOSE() \ #define GET_VERBOSE() \
(cfg_getbool(cfg, "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 */ /* Home-made structure macros */
#else // USE_CONFIG_FILE #else // USE_CONFIG_FILE
@ -237,6 +243,12 @@ void print_version(void) ;
(options.verbose = FALSE) (options.verbose = FALSE)
#define GET_VERBOSE() \ #define GET_VERBOSE() \
(options.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 #endif // USE_CONFIG_FILE

View File

@ -42,6 +42,7 @@ struct {
int autocalibration_nb_packets ; int autocalibration_nb_packets ;
#endif // USE_PTHREAD #endif // USE_PTHREAD
BOOL verbose ; BOOL verbose ;
BOOL display_captured ;
} options = { // Initalise default options: } options = { // Initalise default options:
MODE_ACTIVE, MODE_ACTIVE,
"127.0.0.1", "127.0.0.1",
@ -60,6 +61,7 @@ struct {
DEFAULT_AUTOCALIBRATION_DELAY, DEFAULT_AUTOCALIBRATION_DELAY,
DEFAULT_AUTOCALIBRATION_NBPKT, DEFAULT_AUTOCALIBRATION_NBPKT,
#endif // USE_PTHREAD #endif // USE_PTHREAD
FALSE,
FALSE FALSE
} ; } ;
#endif // USE_CONFIG_FILE #endif // USE_CONFIG_FILE
@ -181,8 +183,10 @@ void parse_config_file(int argc, char **argv)
CFG_INT("autocalibration_nb_packets", CFG_INT("autocalibration_nb_packets",
DEFAULT_AUTOCALIBRATION_NBPKT, CFGF_NONE), DEFAULT_AUTOCALIBRATION_NBPKT, CFGF_NONE),
#endif // USE_PTHREAD #endif // USE_PTHREAD
// Display capture packets, or not: // Be verbose, or not:
CFG_BOOL("verbose", cfg_false, CFGF_NONE), CFG_BOOL("verbose", cfg_false, CFGF_NONE),
// Display captured packets, or not:
CFG_BOOL("display_captured", cfg_false, CFGF_NONE),
CFG_END() CFG_END()
} ; } ;
@ -272,6 +276,9 @@ void parse_command_line(int argc, char **argv)
SET_AUTOCALIBRATION_PORT(strtol(optarg, NULL, 0)) ; SET_AUTOCALIBRATION_PORT(strtol(optarg, NULL, 0)) ;
#endif // USE_PTHREAD #endif // USE_PTHREAD
break ; break ;
case 'c' :
SET_DISPLAY_CAPTURED() ;
break ;
case 'd' : case 'd' :
SET_AGGREGATION_IP(optarg) ; SET_AGGREGATION_IP(optarg) ;
break ; break ;
@ -316,6 +323,9 @@ void parse_command_line(int argc, char **argv)
case 'q' : case 'q' :
UNSET_VERBOSE() ; UNSET_VERBOSE() ;
break ; break ;
case 'Q' :
UNSET_DISPLAY_CAPTURED() ;
break ;
case 'r' : case 'r' :
SET_RTAP_IFACE(optarg) ; SET_RTAP_IFACE(optarg) ;
break ; break ;
@ -400,6 +410,7 @@ void print_configuration()
"autocalibration_nb_packets = %d\n" "autocalibration_nb_packets = %d\n"
#endif // USE_PTHREAD #endif // USE_PTHREAD
"verbose = %s\n" "verbose = %s\n"
"display_captured = %s\n"
, ,
GET_MODE(), GET_MODE(),
GET_AGGREGATION_IP(), GET_AGGREGATION_IP(),
@ -416,7 +427,8 @@ void print_configuration()
GET_AUTOCALIBRATION_DELAY(), GET_AUTOCALIBRATION_DELAY(),
GET_AUTOCALIBRATION_NBPKT(), GET_AUTOCALIBRATION_NBPKT(),
#endif // USE_PTHREAD #endif // USE_PTHREAD
BOOL_TO_STRING(GET_VERBOSE()) BOOL_TO_STRING(GET_VERBOSE()),
BOOL_TO_STRING(GET_DISPLAY_CAPTURED())
) ; ) ;
#endif // USE_CONFIG_FILE #endif // USE_CONFIG_FILE
} }
@ -776,7 +788,8 @@ void read_packet(u_char *args, const struct pcap_pkthdr *header,
rtap_presentflags /= 2 ; rtap_presentflags /= 2 ;
} }
if (GET_VERBOSE()) /* Display the packet details */
if (GET_DISPLAY_CAPTURED())
{ {
char *ap_mac_string = char *ap_mac_string =
mac_bytes_to_string(couple.ap_mac_addr_bytes) ; mac_bytes_to_string(couple.ap_mac_addr_bytes) ;
@ -1017,7 +1030,8 @@ void print_usage()
printf("Usage :\n" printf("Usage :\n"
"\t%s [-f config_file] [-m mode] [-d aggregation_ip]" "\t%s [-f config_file] [-m mode] [-d aggregation_ip]"
" [-l listening_port] [-p aggregation_port] -r rtap_iface" " [-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]" " [-H autocalibration_hello_delay] [-t autocalibration_delay]"
" [-n autocalibration_nb_packets]\n" " [-n autocalibration_nb_packets]\n"
"\t%s -h\n" "\t%s -h\n"
@ -1063,8 +1077,10 @@ void print_usage()
" drivers that disable monitor mode periodically. Available" " drivers that disable monitor mode periodically. Available"
" only if the program was compiled with support of POSIX" " only if the program was compiled with support of POSIX"
" threads.\n" " 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-q\tQuiet mode (default).\n"
"\t-c\tDisplay captured packets.\n"
"\t-Q\tDo not display captured packets (default).\n"
, ,
program_name, program_name,
program_name, program_name,