[Listener] Add option -G (dump configuration)
This new option is just like Aggregator's -G option.
This commit is contained in:
parent
94e5c5cbab
commit
a29a43a6fa
|
@ -31,6 +31,7 @@
|
|||
#include <owlps.h>
|
||||
#include <owlps-client.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <pcap.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -70,7 +71,7 @@
|
|||
|
||||
|
||||
/* Arguments & program configuration */
|
||||
#define OPTIONS "ADf:hH:i:I:Kl:m:n:O:p:P:qr:R:t:T:vVw:" // getopt string
|
||||
#define OPTIONS "ADf:GhH:i:I:Kl:m:n:O:p:P:qr:R:t:T:vVw:" // getopt string
|
||||
#define DEFAULT_CONFIG_FILE OWL_CONFIG_PREFIX "/owlps-listener.conf"
|
||||
enum {MODE_ACTIVE = 'a', MODE_PASSIVE = 'p', MODE_MIXED = 'm'} ;
|
||||
#define DEFAULT_AUTOCALIBRATION_HELLO_DELAY 15 // seconds
|
||||
|
@ -174,7 +175,7 @@ int parse_main_options(int argc, char **argv) ;
|
|||
int parse_calibration_data(int argc, char **argv) ;
|
||||
#endif // OWLPS_LISTENER_USES_PTHREAD
|
||||
int check_configuration(void) ;
|
||||
void print_configuration(void) ;
|
||||
void print_configuration(FILE *stream) ;
|
||||
|
||||
#ifdef OWLPS_LISTENER_KEEPS_MONITOR
|
||||
void* keep_mode_monitor(void *iface) ;
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
#include "owlps-listener.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <inttypes.h>
|
||||
|
@ -56,6 +55,13 @@ char *program_name = NULL ;
|
|||
uint8_t my_mac_bytes[ETHER_ADDR_LEN] ; // AP MAC address
|
||||
char my_ip[INET_ADDRSTRLEN] ; // AP IP address
|
||||
|
||||
/* Will we dump the configuration?
|
||||
* Note that we declare this option as a global variable because
|
||||
* it must not appear in Confuse's options (to avoid dumping the
|
||||
* dump_configuration option itself).
|
||||
*/
|
||||
bool dump_configuration = false ;
|
||||
|
||||
pcap_t *capture_handler = NULL ; // Packet capture descriptor
|
||||
int aggregation_sockfd ;
|
||||
struct sockaddr_in aggregation_server ;
|
||||
|
@ -316,8 +322,20 @@ int initialise_configuration(int argc, char **argv)
|
|||
if (! owl_run)
|
||||
return ret ;
|
||||
|
||||
/* Configuration dumping */
|
||||
if (dump_configuration)
|
||||
{
|
||||
print_configuration(stdout) ;
|
||||
owl_run = false ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
/* Configuration printing */
|
||||
if (VERBOSE_INFO)
|
||||
print_configuration() ;
|
||||
{
|
||||
fprintf(stderr, "Configuration:\n") ;
|
||||
print_configuration(stderr) ;
|
||||
}
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
@ -515,6 +533,11 @@ int parse_main_options(int argc, char **argv)
|
|||
break ;
|
||||
case 'f' : // Config file
|
||||
break ; // (already parsed)
|
||||
case 'G' :
|
||||
dump_configuration = true ;
|
||||
/* We must not turn owl_run false here, to avoid the default
|
||||
* check on its value in initialise_configuration(). */
|
||||
break ;
|
||||
case 'H' :
|
||||
#ifdef OWLPS_LISTENER_USES_PTHREAD
|
||||
SET_AUTOCALIBRATION_HELLO_PORT(strtol(optarg, NULL, 0)) ;
|
||||
|
@ -770,13 +793,12 @@ int check_configuration()
|
|||
|
||||
|
||||
|
||||
void print_configuration()
|
||||
void print_configuration(FILE *stream)
|
||||
{
|
||||
fprintf(stderr, "Configuration:\n") ;
|
||||
#ifdef OWLPS_LISTENER_USES_CONFIG_FILE
|
||||
cfg_print(cfg, stderr) ;
|
||||
cfg_print(cfg, stream) ;
|
||||
#else // OWLPS_LISTENER_USES_CONFIG_FILE
|
||||
fprintf(stderr,
|
||||
fprintf(stream,
|
||||
"mode = %c\n"
|
||||
"aggregation_ip = \"%s\"\n"
|
||||
"aggregation_port = %"PRIuFAST16"\n"
|
||||
|
@ -1617,6 +1639,7 @@ void print_usage()
|
|||
printf("Usage :\n"
|
||||
"\t%s"
|
||||
" [-f config_file]"
|
||||
" [-G]"
|
||||
" [-D]"
|
||||
" [-v[v[v[v]]] | -q]"
|
||||
"\n\t"
|
||||
|
@ -1644,11 +1667,14 @@ void print_usage()
|
|||
"\t%s -V\n"
|
||||
|
||||
"Main options:\n"
|
||||
"\t-h\t\tPrint this help.\n"
|
||||
"\t-V\t\tShow version information.\n"
|
||||
"\t-h\t\tPrint this help message and exit.\n"
|
||||
"\t-V\t\tShow version information and exit.\n"
|
||||
"\t-f config_file\tUse 'config_file' instead of the default"
|
||||
" configuration\n\t\t\tfile (%s).\n\t\t\tAvailable only if the"
|
||||
" program was linked against\n\t\t\tlibconfuse.\n"
|
||||
"\t-G\t\tDump the configuration on the standard output and exit"
|
||||
"\n\t\t\t(useful to generate a configuration file from the"
|
||||
"\n\t\t\tcurrent set of options).\n"
|
||||
"\t-D\t\tDaemon mode.\n"
|
||||
"\t-v\t\tBe verbose. You can use this option up to 4 times to"
|
||||
"\n\t\t\tincrease the level of verbosity (1 = warnings,"
|
||||
|
@ -1699,7 +1725,7 @@ void print_usage()
|
|||
"\t-K\tKeep the monitor mode up on wifi_iface. Use it with"
|
||||
" buggy\n\t\tdrivers that disable monitor mode periodically."
|
||||
" Available only\n\t\tif the program was compiled with the"
|
||||
" option OWLPS_LISTENER_KEEPS_MONITOR.\n"
|
||||
" option\n\t\tOWLPS_LISTENER_KEEPS_MONITOR.\n"
|
||||
,
|
||||
program_name,
|
||||
program_name,
|
||||
|
|
Loading…
Reference in New Issue