diff --git a/infrastructure-centred/owlps-listener/owlps-listener.h b/infrastructure-centred/owlps-listener/owlps-listener.h index 658ed81..2663e87 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:cd:f:hH:kl:m:n:p:P:qQr:t:vVw:" // getopt string +#define OPTIONS "Aa:cd:D: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 @@ -142,6 +142,10 @@ void print_version(void) ; (cfg_setbool(cfg, "autocalibration", cfg_true)) #define GET_AUTOCALIBRATION() \ (cfg_getbool(cfg, "autocalibration")) +#define SET_AUTOCALIBRATION_IP(IP) \ + (cfg_setstr(cfg, "autocalibration_ip", (IP))) +#define GET_AUTOCALIBRATION_IP() \ + (cfg_getstr(cfg, "autocalibration_ip")) #define SET_AUTOCALIBRATION_REQUEST_PORT(PORT) \ (cfg_setint(cfg, "autocalibration_request_port", (PORT))) #define GET_AUTOCALIBRATION_REQUEST_PORT() \ @@ -215,6 +219,10 @@ void print_version(void) ; (options.autocalibration = TRUE) #define GET_AUTOCALIBRATION() \ (options.autocalibration) +#define SET_AUTOCALIBRATION_IP(IP) \ + (strncpy(options.autocalibration_ip, (IP), 16)) +#define GET_AUTOCALIBRATION_IP() \ + (options.autocalibration_ip) #define SET_AUTOCALIBRATION_REQUEST_PORT(PORT) \ (options.autocalibration_request_port = (PORT)) #define GET_AUTOCALIBRATION_REQUEST_PORT() \ diff --git a/infrastructure-centred/owlps-listener/owlps-listenerd.c b/infrastructure-centred/owlps-listener/owlps-listenerd.c index 7fd5e39..08d5656 100644 --- a/infrastructure-centred/owlps-listener/owlps-listenerd.c +++ b/infrastructure-centred/owlps-listener/owlps-listenerd.c @@ -35,6 +35,7 @@ struct { char wifi_iface[IFNAMSIZ + 1] ; #ifdef USE_PTHREAD BOOL autocalibration ; + char autocalibration_ip[16] ; long autocalibration_request_port ; long autocalibration_port ; long autocalibration_hello_delay ; @@ -55,6 +56,7 @@ struct { "", #ifdef USE_PTHREAD FALSE, + "", DEFAULT_AUTOCALIBRATION_REQUEST_PORT, DEFAULT_AUTOCALIBRATION_PORT, DEFAULT_AUTOCALIBRATION_HELLO_DELAY, @@ -166,6 +168,9 @@ void parse_config_file(int argc, char **argv) #ifdef USE_PTHREAD // Autocalibration activated? CFG_BOOL("autocalibration", cfg_false, CFGF_NONE), + // Destination IP address of the autocalibration requests (default: + // none, but will be set to aggregation_ip in the config check): + CFG_STR("autocalibration_ip", "", CFGF_NONE), // Port on which autocalibration requests are sent: CFG_INT("autocalibration_request_port", DEFAULT_AUTOCALIBRATION_REQUEST_PORT, CFGF_NONE), @@ -282,6 +287,9 @@ void parse_command_line(int argc, char **argv) case 'd' : SET_AGGREGATION_IP(optarg) ; break ; + case 'D' : + SET_AUTOCALIBRATION_IP(optarg) ; + break ; case 'f' : // Config file break ; // (already parsed) case 'h' : // Usage @@ -382,6 +390,13 @@ void check_configuration() SET_WIFI_IFACE(GET_RTAP_IFACE()) ; } + if (GET_AUTOCALIBRATION() && GET_AUTOCALIBRATION_IP()[0] == '\0') + { + if (GET_VERBOSE()) + fprintf(stderr, "No autocalibration IP specified, we will use" + " the aggregation IP as the destination of" + " autocalibration requests.\n") ; + } } @@ -403,6 +418,7 @@ void print_configuration() #ifdef USE_PTHREAD "keep_monitor = %s\n" "autocalibration = %s\n" + "autocalibration_ip = %s\n" "autocalibration_request_port = %ld\n" "autocalibration_port = %ld\n" "autocalibration_hello_delay = %ld\n" @@ -413,7 +429,7 @@ void print_configuration() "display_captured = %s\n" , GET_MODE(), - GET_AGGREGATION_IP(), + GET_AGGREGATION_IP(), GET_AGGREGATION_PORT(), GET_LISTENING_PORT(), GET_RTAP_IFACE(), @@ -421,6 +437,7 @@ void print_configuration() #ifdef USE_PTHREAD BOOL_TO_STRING(GET_KEEP_MONITOR()), BOOL_TO_STRING(GET_AUTOCALIBRATION()), + GET_AUTOCALIBRATION_IP(), GET_AUTOCALIBRATION_REQUEST_PORT(), GET_AUTOCALIBRATION_PORT(), GET_AUTOCALIBRATION_HELLO_DELAY(), @@ -934,7 +951,7 @@ void autocalibrate() // Socket to send autocalibration positioning requests autocalibration_send_sockfd = - owlps_create_socket_to_aggregator(GET_AGGREGATION_IP(), + owlps_create_socket_to_aggregator(GET_AUTOCALIBRATION_IP(), GET_AUTOCALIBRATION_REQUEST_PORT(), &autocalibration_send_server, GET_WIFI_IFACE()) ; @@ -1031,6 +1048,7 @@ void print_usage() "\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] [-c | -Q] [-A]" + " [-D autocalibration_ip]" " [-P autocalibration_request_port ] [-a autocalibration_port]" " [-H autocalibration_hello_delay] [-t autocalibration_delay]" " [-n autocalibration_nb_packets]\n" @@ -1061,6 +1079,8 @@ void print_usage() "(These options are available only if the program was compiled" " with support of POSIX threads.)\n" "\t-A\t\t\tEnable autocalibration (default: disabled).\n" + "\t-D autocalib_ip\t\tDestination IP of the autocalibration" + "requests (default: aggregation_ip).\n" "\t-P autocalib_req_port\tPort on which autocalibration positioning" " requests are sent (default: %d).\n" "\t-a autocalib_port\tPort on which autocalibration data (hello & orders)"