From e5883d99d5c767a6d3545e8ddbe0a602ce5c42d6 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Mon, 23 Sep 2013 15:32:19 -0400 Subject: [PATCH] Finish supporting getaddrinfo() - For static buffers, use a size suited for host names and not only IP addresses. - Change variable names. - Adapt usage messages and documentation. --- TODO.t2t | 8 +--- doc/owlps-aggregatord.t2t | 7 ++-- doc/owlps-client.t2t | 20 +++++----- doc/owlps-listenerd.t2t | 15 +++---- libowlps-client/libowlps-client.c | 6 +-- libowlps-client/owlps-client.h | 2 +- owlps-aggregator/owlps-aggregator.h | 2 +- owlps-aggregator/owlps-aggregatord.c | 24 ++++++------ owlps-client/owlps-client.c | 33 ++++++++-------- owlps-listener/owlps-listener.h | 34 ++++++++-------- owlps-listener/owlps-listenerd.c | 58 ++++++++++++++-------------- owlps-positioner/userinterface.cc | 7 ++-- 12 files changed, 110 insertions(+), 106 deletions(-) diff --git a/TODO.t2t b/TODO.t2t index 2de0bb8..aa932c6 100644 --- a/TODO.t2t +++ b/TODO.t2t @@ -52,12 +52,6 @@ Work to do in OwlPS checked), but not constantly in C modules. //Done in lib*.// -- Allow to use hostnames instead of IP addresses in all modules - - getaddrinfo(3) (or gethostbyname(3)) should be used when opening - sockets in libowlps, then string buffer size have to be adapted in all - modules to be able to contain a long hostname. - - Use struct ether_addr to store MAC addresses? We could use the struct ether_addr to store binary MAC addresses, and @@ -71,7 +65,7 @@ Work to do in OwlPS = Aggregator = -- An empty positioner_ip should turn off communication with the +- An empty positioner_host should turn off communication with the positioning server. - Option to overwrite the output file (ask for a confirmation!). diff --git a/doc/owlps-aggregatord.t2t b/doc/owlps-aggregatord.t2t index c45e738..00adad3 100644 --- a/doc/owlps-aggregatord.t2t +++ b/doc/owlps-aggregatord.t2t @@ -24,7 +24,7 @@ June 2013 **owlps-aggregatord** [ **-f** //config_file// ] [ **-G** ] [ **-D** ] [ **-v**[**v**[**v**[**v**]] ] | **-q** ] [ **-o** //out_file// ] [ **-F** ] - [ **-i** //positioner_ip// ] + [ **-i** //positioner_host// ] [ **-p** //positioner_port// ] [ **-l** //listening_port// ] [ **-t** //aggregate_timeout// ] @@ -125,8 +125,9 @@ the **-K** option). "-", i.e. the standard output). : **-F** Do not flush the output file. -: **-i** //positionner_ip// - IP address of the positioning server (default: 127.0.0.1). +: **-i** //positionner_host// + Host name or IP address of the positioning server (default: + localhost). : **-p** //positioner_port// Aggregated requests are transmitted to the positioning server on this port (default: 9902). diff --git a/doc/owlps-client.t2t b/doc/owlps-client.t2t index 2e23b32..8c43d66 100644 --- a/doc/owlps-client.t2t +++ b/doc/owlps-client.t2t @@ -21,11 +21,11 @@ June 2013 = Synopsis = -**owlps-client** [ **-v** | **-q** ] **-i** //dest_ip// [ **-p** //dest_port// ] [ **-I** //iface// ] +**owlps-client** [ **-v** | **-q** ] **-i** //dest_host// [ **-p** //dest_port// ] [ **-I** //iface// ] [ **-t** //delay// ] [ **-n** //nb_packets// ] [ **-s** //packet_size// ] [ **-F** [ //[+]delay// ] [ **-N** //nb_requests// ] [ **-D** ] ] [ **-l** [ //port// ] ] -**owlps-client** [ **-v** | **-q** ] **-i** dest_ip [ **-p** //dest_port// ] [ **-I** //iface// ] +**owlps-client** [ **-v** | **-q** ] **-i** dest_host [ **-p** //dest_port// ] [ **-I** //iface// ] [ **-t** //delay// ] [ **-n** //nb_packets// ] [ **-s** //packet_size// ] [ **-F** [ //delay// ] [ **-N** //nb_requests// ] [ **-D** ] ] //direction x y z// @@ -35,8 +35,8 @@ June 2013 = Description = **OwlPS Client** is the reference client for OwlPS, i.e. the program run -by the mobile terminals to send positioning requests. With the second -invocation form, that is when the user provides the direction +by the mobile terminals to send one or more positioning requests. With +the second invocation form, that is when the user provides the direction (orientation) and the coordinates of the mobile terminal, //owlps-client// will send calibration requests instead of positioning requests, which can be registered (using OwlPS Aggregator, see @@ -56,8 +56,9 @@ owlps-aggregatord.t2t) to create a manual calibration database. : **-q** Do not print informational messages and some (less important) warnings. -: **-i** //dest_ip// - Destination IP address of the localisation request. +: **-i** //dest_host// + Name or IP address of the destination host of the localisation + request. : **-p** //dest_port// Destination port of the localisation request (default: 9900). : **-t** //delay// @@ -86,10 +87,11 @@ owlps-aggregatord.t2t) to create a manual calibration database. //delay// is the time between the start of the transmissions of both requests. : **-N** //nb_requests// - With -F, stop after //nb_requests// requests transmitted instead of - looping indefinitely. + With **-F**, stop after //nb_requests// requests transmitted instead + of looping indefinitely. : **-D** - Daemon mode (fork to the background). Useful only in flood mode. + Daemon mode (fork to the background). Useful only in flood mode (cf. + **-F** option). : **-l** [ //port// ] Wait for the computed position and display it. The optional argument //port// allows to specify the listening port (default: 9910). diff --git a/doc/owlps-listenerd.t2t b/doc/owlps-listenerd.t2t index b5f1fef..9feff44 100644 --- a/doc/owlps-listenerd.t2t +++ b/doc/owlps-listenerd.t2t @@ -26,10 +26,10 @@ June 2013 < **-r** //rtap_iface// [ **-w** //wifi_iface// ] | **-R** //pcap_file// > [ **-K** ] [ **-m** //mode// ] [ **-l** //listening_port// ] - [ **-i** //aggregation_ip// ] + [ **-i** //aggregation_host// ] [ **-p** //aggregation_port// ] [ **-A** ] - [ **-I** //autocalibration_ip// ] + [ **-I** //autocalibration_host// ] [ **-P** //autocalibration_request_port// ] [ **-O** //autocalibration_order_port// ] [ **-H** //hello_port// ] @@ -124,8 +124,9 @@ debugging and to replay scenarios. : **-l** //listening_port// Port to which explicit positioning requests are sent by the mobiles (default: 9900). -: **-i** //aggregation_ip// - IP address of the aggregation server (default: 127.0.0.1). +: **-i** //aggregation_host// + Host name or IP address of the aggregation server (default: + localhost). : **-p** //aggregation_port// Port to which the captured requests are transmitted to the aggregation server (default: 9901). @@ -145,9 +146,9 @@ support of the POSIX threads. : **-A** Enable autocalibration (default: disabled). -: **-I** //autocalibration_ip// - Destination IP of the autocalibration requests (default: - //aggregation_ip//). +: **-I** //autocalibration_host// + Host name or IP address of the destination of the autocalibration + requests (default: //aggregation_host//). : **-P** //autocalibration_request_port// Port to which autocalibration requests are sent (default: //listening_port//). diff --git a/libowlps-client/libowlps-client.c b/libowlps-client/libowlps-client.c index c06d217..d08e76e 100644 --- a/libowlps-client/libowlps-client.c +++ b/libowlps-client/libowlps-client.c @@ -32,7 +32,7 @@ * This function uses owl_create_udp_trx_socket() (from libowlps) * as a backend, and allows to select a particular network interface. * - * @param[in] dest_ip IP address of the remote server. + * @param[in] dest_host host name or IP address of the remote server. * @param[in] dest_port Port on which the remote server listens. * @param[out] server Structure in which the server information will * be saved. @@ -40,12 +40,12 @@ * If this parameter is `NULL` or an empty string, the interface will * be selected automatically. */ -int owl_create_trx_socket(const char *const dest_ip, +int owl_create_trx_socket(const char *const dest_host, const uint_fast16_t dest_port, struct sockaddr *const server, const char *const iface) { - int sockfd = owl_create_udp_trx_socket(dest_ip, dest_port, server) ; + int sockfd = owl_create_udp_trx_socket(dest_host, dest_port, server) ; if (sockfd < 0) { perror("Error! Cannot create UDP sending socket to the aggregation" diff --git a/libowlps-client/owlps-client.h b/libowlps-client/owlps-client.h index ae976df..0460199 100644 --- a/libowlps-client/owlps-client.h +++ b/libowlps-client/owlps-client.h @@ -28,7 +28,7 @@ /* Function headers */ /// Opens a transmission socket -int owl_create_trx_socket(const char *const dest_ip, +int owl_create_trx_socket(const char *const dest_host, const uint_fast16_t dest_port, struct sockaddr *const server, const char *const iface) ; diff --git a/owlps-aggregator/owlps-aggregator.h b/owlps-aggregator/owlps-aggregator.h index ab5d8c9..796d617 100644 --- a/owlps-aggregator/owlps-aggregator.h +++ b/owlps-aggregator/owlps-aggregator.h @@ -34,7 +34,7 @@ #define DEFAULT_CHECK_INTERVAL 300 // milliseconds #define DEFAULT_CP_KEEP_TIMEOUT 35 // seconds #define DEFAULT_AC_ORDER_INTERVAL 1000 // milliseconds -#define POSITIONER_DEFAULT_IP "127.0.0.1" +#define POSITIONER_DEFAULT_HOST "localhost" /* Verbosity levels */ diff --git a/owlps-aggregator/owlps-aggregatord.c b/owlps-aggregator/owlps-aggregatord.c index f395e62..eb48551 100644 --- a/owlps-aggregator/owlps-aggregatord.c +++ b/owlps-aggregator/owlps-aggregatord.c @@ -248,9 +248,9 @@ int parse_config_file(int argc, char **argv) // Aggregation listening port CFG_INT("listening_port", OWL_DEFAULT_LISTENER_PORT, CFGF_NONE), - // Port and IP address of the localisation server: + // Port and host of the localisation server: CFG_INT("positioner_port", OWL_DEFAULT_AGGREGATION_PORT, CFGF_NONE), - CFG_STR("positioner_ip", POSITIONER_DEFAULT_IP, CFGF_NONE), + CFG_STR("positioner_host", POSITIONER_DEFAULT_HOST, CFGF_NONE), // Output file (default is the standard output) CFG_STR("output_file", "-", CFGF_NONE), @@ -397,7 +397,7 @@ int parse_command_line(int argc, char **argv) strtol(optarg, NULL, 0)) ; break ; case 'i' : - cfg_setstr(cfg, "positioner_ip", optarg) ; + cfg_setstr(cfg, "positioner_host", optarg) ; break ; case 'k' : cfg_setint(cfg, "keep_timeout", strtol(optarg, NULL, 0)) ; @@ -473,11 +473,11 @@ int check_configuration() cfg_setint(cfg, "positioner_port", OWL_DEFAULT_AGGREGATION_PORT) ; } - // positioner_ip // - if (cfg_getstr(cfg, "positioner_ip")[0] == '\0') + // positioner_host // + if (cfg_getstr(cfg, "positioner_host")[0] == '\0') { - fprintf(stderr, "Error! You must specify the IP address of the" - " localisation server.\n") ; + fprintf(stderr, "Error! You must specify the host name or IP" + " address of the localisation server.\n") ; print_usage() ; owl_run = false ; return OWL_ERR_BAD_USAGE ; @@ -832,7 +832,7 @@ void* monitor_requests(void *NULL_value) fprintf(stderr, "Monitor requests thread launched.\n") ; sockfd = - owl_create_udp_trx_socket(cfg_getstr(cfg, "positioner_ip"), + owl_create_udp_trx_socket(cfg_getstr(cfg, "positioner_host"), cfg_getint(cfg, "positioner_port"), &serv) ; pthread_cleanup_push(&owl_close_fd, &sockfd) ; @@ -1519,7 +1519,7 @@ void print_usage() "\n\t" " [-o out_file]" " [-F]" - " [-i positionner_ip]" + " [-i positionner_host]" " [-p positioner_port]" "\n\t" " [-l listening_port]" @@ -1559,8 +1559,8 @@ void print_usage() " output).\n" "\t-F\t\t\tDo not flush the output file after each analyse" "\n\t\t\t\tof the requests' list.\n" - "\t-i positionner_ip\tIP address of the positioning server" - " (default:\n\t\t\t\t%s).\n" + "\t-i positionner_host\tHost name or IP address of the" + " positioning\n\t\t\t\tserver (default: %s).\n" "\t-p positioner_port\tAggregated requests are transmitted to" " the\n\t\t\t\tpositioning server on this port (default:" "\n\t\t\t\t%d).\n" @@ -1593,7 +1593,7 @@ void print_usage() program_name, program_name, DEFAULT_CONFIG_FILE, - POSITIONER_DEFAULT_IP, + POSITIONER_DEFAULT_HOST, OWL_DEFAULT_AGGREGATION_PORT, OWL_DEFAULT_LISTENER_PORT, DEFAULT_AGGREGATE_TIMEOUT, diff --git a/owlps-client/owlps-client.c b/owlps-client/owlps-client.c index c7f3741..945576f 100644 --- a/owlps-client/owlps-client.c +++ b/owlps-client/owlps-client.c @@ -33,6 +33,7 @@ #include #include +#include // for MAXHOSTNAMELEN /* Number of packets to send */ @@ -56,7 +57,7 @@ /* Function headers */ void parse_command_line(int argc, char **argv) ; void parse_main_options(int argc, char **argv) ; -void check_destination_ip(void) ; +void check_destination_host(void) ; void parse_calibration_data(int argc, char **argv) ; void check_configuration(void) ; void print_configuration(void) ; @@ -77,7 +78,7 @@ void print_version(void) ; struct { bool daemon ; bool verbose ; - char dest_ip[INET_ADDRSTRLEN] ; // Destination IP of the packets + char dest_host[MAXHOSTNAMELEN] ; // Destination host of the packets uint_fast16_t dest_port ; char iface[IFNAMSIZ + 1] ; // Source network interface int_fast32_t delay ; // Time between two packet transmissions @@ -95,7 +96,7 @@ struct { } options = { false, // daemon true, // verbose - "", // dest_ip + "", // dest_host OWL_DEFAULT_REQUEST_PORT, // dest_port "", // iface -1, // delay @@ -211,7 +212,7 @@ int main(int argc, char *argv[]) void parse_command_line(int argc, char **argv) { parse_main_options(argc, argv) ; - check_destination_ip() ; + check_destination_host() ; parse_calibration_data(argc, argv) ; check_configuration() ; @@ -266,7 +267,7 @@ void parse_main_options(int argc, char **argv) strncpy(options.iface, optarg, IFNAMSIZ + 1) ; break ; case 'i' : - strncpy(options.dest_ip, optarg, INET_ADDRSTRLEN) ; + strncpy(options.dest_host, optarg, MAXHOSTNAMELEN) ; break ; case 'l' : #ifdef OWLPS_CLIENT_RECEIVES_POSITION @@ -329,12 +330,12 @@ void parse_main_options(int argc, char **argv) -void check_destination_ip() +void check_destination_host() { - /* Check if we got a destination IP address */ - if (options.dest_ip[0] == '\0') + /* Check if we got a destination host */ + if (options.dest_host[0] == '\0') { - fprintf(stderr, "Error! You must specify a destination IP address" + fprintf(stderr, "Error! You must specify a destination host" " (-i) .\n") ; print_usage() ; exit(OWL_ERR_BAD_USAGE) ; @@ -469,7 +470,7 @@ void print_configuration() printf("Options:\n" "\tDaemon: %s\n" "\tVerbose: %s\n" - "\tDestination IP: %s\n" + "\tDestination host: %s\n" "\tDestination port: %"PRIuFAST16"\n" "\tInterface: %s\n" "\tDelay (ms): %"PRIdFAST32"\n" @@ -486,7 +487,7 @@ void print_configuration() , OWL_BOOL_TO_STRING(options.daemon), OWL_BOOL_TO_STRING(options.verbose), - options.dest_ip, + options.dest_host, options.dest_port, options.iface, options.delay, @@ -508,7 +509,7 @@ void print_configuration() void create_socket() { sockfd = - owl_create_trx_socket(options.dest_ip, options.dest_port, + owl_create_trx_socket(options.dest_host, options.dest_port, &server, options.iface) ; } @@ -709,7 +710,7 @@ void print_usage() "Localisation request:\n" "\t%s" " [-v | -q]" - " -i dest_ip" + " -i dest_host" " [-p dest_port]" " [-I iface]" " [-t delay]" @@ -722,7 +723,7 @@ void print_usage() "Calibration request:\n" "\t%s" " [-v | -q]" - " -i dest_ip" + " -i dest_host" " [-p dest_port]" " [-I iface]" " [-t delay]" @@ -739,8 +740,8 @@ void print_usage() "\t-v\t\tTurn on verbose mode (default).\n" "\t-q\t\tDo not print informational messages and some (less\n" "\t\t\timportant) warnings.\n" - "\t-i dest_ip\tDestination IP address of the localisation" - " request.\n" + "\t-i dest_host\tName or IP address of the destination host of" + " the\n\t\t\tlocalisation request.\n" "\t-p dest_port\tDestination port of the localisation request" " (default:\n\t\t\t%d).\n" "\t-t delay\tTime between each packet transmission in" diff --git a/owlps-listener/owlps-listener.h b/owlps-listener/owlps-listener.h index 2ee020f..eae4ea2 100644 --- a/owlps-listener/owlps-listener.h +++ b/owlps-listener/owlps-listener.h @@ -35,6 +35,7 @@ #include #include +#include // for MAXHOSTNAMELEN #ifdef __GLIBC__ # include @@ -77,6 +78,7 @@ enum {MODE_ACTIVE = 'a', MODE_PASSIVE = 'p', MODE_MIXED = 'm'} ; #define DEFAULT_AUTOCALIBRATION_HELLO_DELAY 15 // seconds #define DEFAULT_AUTOCALIBRATION_DELAY 25 // milliseconds #define DEFAULT_AUTOCALIBRATION_NBPKT 20 +#define DEFAULT_AGGREGATION_HOST "localhost" /* Verbosity levels */ @@ -227,10 +229,10 @@ void print_version(void) ; (cfg_setbool(cfg, "daemon", cfg_false)) #define GET_DAEMON() \ (cfg_getbool(cfg, "daemon")) -#define SET_AGGREGATION_IP(IP) \ - (cfg_setstr(cfg, "aggregation_ip", (IP))) -#define GET_AGGREGATION_IP() \ - (cfg_getstr(cfg, "aggregation_ip")) +#define SET_AGGREGATION_HOST(HOST) \ + (cfg_setstr(cfg, "aggregation_host", (HOST))) +#define GET_AGGREGATION_HOST() \ + (cfg_getstr(cfg, "aggregation_host")) #ifdef OWLPS_LISTENER_KEEPS_MONITOR #define SET_KEEP_MONITOR() \ (cfg_setbool(cfg, "keep_monitor", cfg_true)) @@ -267,10 +269,10 @@ void print_version(void) ; (cfg_setbool(cfg, "autocalibration", cfg_false)) #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_HOST(HOST) \ + (cfg_setstr(cfg, "autocalibration_host", (HOST))) +#define GET_AUTOCALIBRATION_HOST() \ + (cfg_getstr(cfg, "autocalibration_host")) #define SET_AUTOCALIBRATION_REQUEST_PORT(PORT) \ (cfg_setint(cfg, "autocalibration_request_port", (PORT))) #define GET_AUTOCALIBRATION_REQUEST_PORT() \ @@ -332,10 +334,10 @@ void print_version(void) ; (options.mode = (MODE)) #define GET_MODE() \ (options.mode) -#define SET_AGGREGATION_IP(IP) \ - (strncpy(options.aggregation_ip, (IP), INET_ADDRSTRLEN)) -#define GET_AGGREGATION_IP() \ - (options.aggregation_ip) +#define SET_AGGREGATION_HOST(HOST) \ + (strncpy(options.aggregation_host, (HOST), MAXHOSTNAMELEN)) +#define GET_AGGREGATION_HOST() \ + (options.aggregation_host) #ifdef OWLPS_LISTENER_KEEPS_MONITOR #define SET_KEEP_MONITOR() \ (options.keep_monitor = true) @@ -379,10 +381,10 @@ void print_version(void) ; (options.autocalibration = false) #define GET_AUTOCALIBRATION() \ (options.autocalibration) -#define SET_AUTOCALIBRATION_IP(IP) \ - (strncpy(options.autocalibration_ip, (IP), INET_ADDRSTRLEN)) -#define GET_AUTOCALIBRATION_IP() \ - (options.autocalibration_ip) +#define SET_AUTOCALIBRATION_HOST(HOST) \ + (strncpy(options.autocalibration_host, (HOST), MAXHOSTNAMELEN)) +#define GET_AUTOCALIBRATION_HOST() \ + (options.autocalibration_host) #define SET_AUTOCALIBRATION_REQUEST_PORT(PORT) \ (options.autocalibration_request_port = (PORT)) #define GET_AUTOCALIBRATION_REQUEST_PORT() \ diff --git a/owlps-listener/owlps-listenerd.c b/owlps-listener/owlps-listenerd.c index a1ae1ba..80c0953 100644 --- a/owlps-listener/owlps-listenerd.c +++ b/owlps-listener/owlps-listenerd.c @@ -90,7 +90,7 @@ cfg_t *cfg = NULL ; // Configuration structure struct { bool daemon ; char mode ; - char aggregation_ip[INET_ADDRSTRLEN] ; + char aggregation_host[MAXHOSTNAMELEN] ; uint_fast16_t aggregation_port ; uint_fast16_t listening_port ; #ifdef OWLPS_LISTENER_KEEPS_MONITOR @@ -101,7 +101,7 @@ struct { char wifi_iface[IFNAMSIZ + 1] ; #ifdef OWLPS_LISTENER_USES_PTHREAD bool autocalibration ; - char autocalibration_ip[INET_ADDRSTRLEN] ; + char autocalibration_host[MAXHOSTNAMELEN] ; uint_fast16_t autocalibration_request_port ; uint_fast16_t autocalibration_order_port ; uint_fast16_t autocalibration_hello_port ; @@ -117,7 +117,7 @@ struct { } options = { // Initalise default options: false, // daemon MODE_ACTIVE, // mode - "127.0.0.1", // aggregation_ip + DEFAULT_AGGREGATION_HOST, // aggregation_host OWL_DEFAULT_LISTENER_PORT, // aggregation_port OWL_DEFAULT_REQUEST_PORT, // listening_port #ifdef OWLPS_LISTENER_KEEPS_MONITOR @@ -128,7 +128,7 @@ struct { "", // wifi_iface #ifdef OWLPS_LISTENER_USES_PTHREAD false, // autocalibration - "", // autocalibration_ip + "", // autocalibration_host 0, // autocalibration_request_port OWL_DEFAULT_AUTOCALIBRATION_ORDER_PORT, // autocalibration_order_port OWL_DEFAULT_AUTOCALIBRATION_HELLO_PORT, // autocalibration_hello_port @@ -361,8 +361,8 @@ int parse_config_file(int argc, char **argv) // Listening mode: a for active, p for passive, m for mixed // (default: a): CFG_INT("mode", MODE_ACTIVE, CFGF_NONE), - // IP address of the aggregator (default: loopback): - CFG_STR("aggregation_ip", "127.0.0.1", CFGF_NONE), + // Aggregation server host (default: loopback): + CFG_STR("aggregation_host", DEFAULT_AGGREGATION_HOST, CFGF_NONE), // Port on which the aggregator listens: CFG_INT("aggregation_port", OWL_DEFAULT_LISTENER_PORT, CFGF_NONE), // Port to which mobiles send active requests: @@ -382,9 +382,9 @@ int parse_config_file(int argc, char **argv) #ifdef OWLPS_LISTENER_USES_PTHREAD // Autocalibration activated? CFG_BOOL("autocalibration", cfg_false, CFGF_NONE), - // Destination IP address of the autocalibration requests (default: + // Destination host of the autocalibration requests (default: // none, but will be set to aggregation_ip in the config check): - CFG_STR("autocalibration_ip", "", CFGF_NONE), + CFG_STR("autocalibration_host", "", CFGF_NONE), // Port to which autocalibration requests are sent (default: 0, // but will be set to listening_port in the config check): CFG_INT("autocalibration_request_port", 0, CFGF_NONE), @@ -563,11 +563,11 @@ int parse_main_options(int argc, char **argv) #endif // OWLPS_LISTENER_USES_PTHREAD break ; case 'i' : - SET_AGGREGATION_IP(optarg) ; + SET_AGGREGATION_HOST(optarg) ; break ; case 'I' : #ifdef OWLPS_LISTENER_USES_PTHREAD - SET_AUTOCALIBRATION_IP(optarg) ; + SET_AUTOCALIBRATION_HOST(optarg) ; #endif // OWLPS_LISTENER_USES_PTHREAD break ; case 'K' : @@ -762,13 +762,13 @@ int check_configuration() #ifdef OWLPS_LISTENER_USES_PTHREAD if (GET_AUTOCALIBRATION()) { - if (GET_AUTOCALIBRATION_IP()[0] == '\0') + if (GET_AUTOCALIBRATION_HOST()[0] == '\0') { if (VERBOSE_WARNING) - fprintf(stderr, "No autocalibration IP specified, we will" - " use the aggregation IP as the destination of" - " autocalibration requests.\n") ; - SET_AUTOCALIBRATION_IP(GET_AGGREGATION_IP()) ; + fprintf(stderr, "No autocalibration host specified, the" + " aggregation host will be used as the destination" + " of autocalibration requests.\n") ; + SET_AUTOCALIBRATION_HOST(GET_AGGREGATION_HOST()) ; } if (GET_AUTOCALIBRATION_NBPKT() < 1) @@ -819,7 +819,7 @@ void print_configuration(FILE *stream) #else // OWLPS_LISTENER_USES_CONFIG_FILE fprintf(stream, "mode = %c\n" - "aggregation_ip = \"%s\"\n" + "aggregation_host = \"%s\"\n" "aggregation_port = %"PRIuFAST16"\n" "listening_port = %"PRIuFAST16"\n" "rtap_iface = \"%s\"\n" @@ -829,7 +829,7 @@ void print_configuration(FILE *stream) #endif // OWLPS_LISTENER_KEEPS_MONITOR #ifdef OWLPS_LISTENER_USES_PTHREAD "autocalibration = %s\n" - "autocalibration_ip = \"%s\"\n" + "autocalibration_host = \"%s\"\n" "autocalibration_request_port = %"PRIuFAST16"\n" "autocalibration_order_port = %"PRIuFAST16"\n" "autocalibration_hello_port = %"PRIuFAST16"\n" @@ -844,7 +844,7 @@ void print_configuration(FILE *stream) "verbose = %"PRIuFAST8"\n" , GET_MODE(), - GET_AGGREGATION_IP(), + GET_AGGREGATION_HOST(), GET_AGGREGATION_PORT(), GET_LISTENING_PORT(), GET_RTAP_IFACE(), @@ -854,7 +854,7 @@ void print_configuration(FILE *stream) #endif // OWLPS_LISTENER_KEEPS_MONITOR #ifdef OWLPS_LISTENER_USES_PTHREAD OWL_BOOL_TO_STRING(GET_AUTOCALIBRATION()), - GET_AUTOCALIBRATION_IP(), + GET_AUTOCALIBRATION_HOST(), GET_AUTOCALIBRATION_REQUEST_PORT(), GET_AUTOCALIBRATION_ORDER_PORT(), GET_AUTOCALIBRATION_HELLO_PORT(), @@ -970,7 +970,7 @@ int capture() /* Open UDP socket to the aggregator */ aggregation_sockfd = - owl_create_trx_socket(GET_AGGREGATION_IP(), GET_AGGREGATION_PORT(), + owl_create_trx_socket(GET_AGGREGATION_HOST(), GET_AGGREGATION_PORT(), &aggregation_server, NULL) ; while (owl_run) @@ -1545,7 +1545,7 @@ void* autocalibrate_hello(void *NULL_value) fprintf(stderr, "Autocalibration Hello thread launched.\n") ; send_sockfd = - owl_create_trx_socket(GET_AGGREGATION_IP(), + owl_create_trx_socket(GET_AGGREGATION_HOST(), GET_AUTOCALIBRATION_HELLO_PORT(), &serv, NULL) ; pthread_cleanup_push(&owl_close_fd, &send_sockfd) ; @@ -1578,7 +1578,7 @@ void* autocalibrate(void *NULL_value) // Socket to send autocalibration positioning requests autocalibration_send_sockfd = - owl_create_trx_socket(GET_AUTOCALIBRATION_IP(), + owl_create_trx_socket(GET_AUTOCALIBRATION_HOST(), GET_AUTOCALIBRATION_REQUEST_PORT(), &autocalibration_send_server, GET_WIFI_IFACE()) ; @@ -1747,11 +1747,11 @@ void print_usage() " [-m mode]" "\n\t" " [-l listening_port]" - " [-i aggregation_ip]" + " [-i aggregation_host]" " [-p aggregation_port]" "\n\t" " [-A]" - " [-I autocalibration_ip]" + " [-I autocalibration_host]" " [-P autocalibration_request_port]" "\n\t" " [-O autocalibration_order_port]" @@ -1786,8 +1786,8 @@ void print_usage() "\n\t\t\t\t(default: a).\n" "\t-l listening_port\tPort to which explicit positioning" " requests are\n\t\t\t\tsent by the mobiles (default: %d).\n" - "\t-i aggregation_ip\tIP address of the aggregation server" - " (default:\n\t\t\t\t127.0.0.1).\n" + "\t-i aggregation_host\tHost name or IP address of the" + " aggregation\n\t\t\t\tserver (default: %s).\n" "\t-p aggregation_port\tRequests are transmitted to the" " aggregation\n\t\t\t\tserver on this port (default: %d).\n" "\t-r rtap_iface\t\tRadiotap-enabled capture interface.\n" @@ -1800,8 +1800,9 @@ void print_usage() " with support of\nthe POSIX threads and the adequate" " compilation-time option.)\n" "\t-A\t\t\tEnable autocalibration (default: disabled).\n" - "\t-I ac_ip\t\tDestination IP of the autocalibration" - " requests\n\t\t\t\t(default: aggregation_ip).\n" + "\t-I ac_host\t\tHost name or IP address of the destination" + " of\n\t\t\t\tthe autocalibration requests" + " (default:\n\t\t\t\taggregation_host).\n" "\t-P ac_request_port\tPort to which autocalibration" " requests are sent\n\t\t\t\t(default: listening_port).\n" "\t-O ac_order_port\tPort on which autocalibration orders are" @@ -1830,6 +1831,7 @@ void print_usage() program_name, DEFAULT_CONFIG_FILE, OWL_DEFAULT_REQUEST_PORT, + DEFAULT_AGGREGATION_HOST, OWL_DEFAULT_LISTENER_PORT, OWL_DEFAULT_AUTOCALIBRATION_ORDER_PORT, OWL_DEFAULT_AUTOCALIBRATION_HELLO_PORT, diff --git a/owlps-positioner/userinterface.cc b/owlps-positioner/userinterface.cc index 915835e..6203d53 100644 --- a/owlps-positioner/userinterface.cc +++ b/owlps-positioner/userinterface.cc @@ -359,7 +359,8 @@ void UserInterface::fill_output_options() "Port on which the UDP data is sent (when output.medium = UDP).") ("output.tcpevaal-host", po::value()->default_value(DEFAULT_TCPEVAAL_HOST), - "Host to which the TCP data is sent (when output.medium = TCPEvAAL).") + "IP address of the host to which the TCP data is sent (when" + " output.medium = TCPEvAAL).") ("output.tcpevaal-port", po::value()->default_value(DEFAULT_TCPEVAAL_PORT), "Port on which the TCP data is sent (when output.medium = TCPEvAAL).") @@ -380,8 +381,8 @@ void UserInterface::fill_misc_options() ("replay", po::value()->default_value(false), "\"Replay\" mode. With this option enabled, the current time is the" - " emission timestamp of the most recent request; you will want to" - " enable this when reading inputs (requests) off-line to replay" + " transmission timestamp of the most recent request; you will want" + " to enable this when reading inputs (requests) offline to replay" " scenarios, if time-related options are enabled (e.g." " \"positioning.calibration-requests-timeout\"). To be useful, this" " option requires the listeners' clocks to be synchronised.")