From 3ac53e7b76236e58a5fd6fe853324685b9de3a69 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Fri, 24 Jun 2011 15:38:07 +0200 Subject: [PATCH] [Listener] Fix compilation without USE_PTHREAD --- owlps-listener/owlps-listener.h | 2 ++ owlps-listener/owlps-listenerd.c | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/owlps-listener/owlps-listener.h b/owlps-listener/owlps-listener.h index 48ad4a4..38e67a9 100644 --- a/owlps-listener/owlps-listener.h +++ b/owlps-listener/owlps-listener.h @@ -66,7 +66,9 @@ void initialise_configuration(int argc, char **argv) ; void parse_config_file(int argc, char **argv) ; void parse_command_line(int argc, char **argv) ; void parse_main_options(int argc, char **argv) ; +#ifdef USE_PTHREAD void parse_calibration_data(int argc, char **argv) ; +#endif // USE_PTHREAD void check_configuration(void) ; #ifdef DEBUG void print_configuration(void) ; diff --git a/owlps-listener/owlps-listenerd.c b/owlps-listener/owlps-listenerd.c index 602c247..7c77c64 100644 --- a/owlps-listener/owlps-listenerd.c +++ b/owlps-listener/owlps-listenerd.c @@ -176,6 +176,7 @@ int main(int argc, char *argv[]) /* Wait for the threads to terminate */ +#ifdef USE_PTHREAD if (GET_KEEP_MONITOR()) { fprintf(stderr, "Waiting for the keep mode monitor thread... ") ; @@ -219,6 +220,10 @@ int main(int argc, char *argv[]) else fprintf(stderr, "OK.\n") ; } +#else // USE_PTHREAD + // Just to avoid a warning when compiling without threads' support: + goto exit ; +#endif // USE_PTHREAD /* Last cleaning tasks */ exit: @@ -372,7 +377,9 @@ void parse_config_file(int argc, char **argv) void parse_command_line(int argc, char **argv) { parse_main_options(argc, argv) ; +#ifdef USE_PTHREAD parse_calibration_data(argc, argv) ; +#endif // USE_PTHREAD } @@ -410,7 +417,9 @@ void parse_main_options(int argc, char **argv) SET_AGGREGATION_IP(optarg) ; break ; case 'D' : +#ifdef USE_PTHREAD SET_AUTOCALIBRATION_IP(optarg) ; +#endif // USE_PTHREAD break ; case 'f' : // Config file break ; // (already parsed) @@ -481,6 +490,7 @@ void parse_main_options(int argc, char **argv) +#ifdef USE_PTHREAD void parse_calibration_data(int argc, char **argv) { /* Parse remaining arguments (possible calibration data) */ @@ -501,6 +511,7 @@ void parse_calibration_data(int argc, char **argv) } } } +#endif // USE_PTHREAD @@ -837,12 +848,14 @@ void read_packet(u_char *args, const struct pcap_pkthdr *header, LLC_HEADER_SIZE + sizeof(struct iphdr)] ; dest_port = ntohs(packet_udp_header->dest) ; +#ifdef USE_PTHREAD if (GET_AUTOCALIBRATION() && dest_port == (uint_fast16_t) GET_AUTOCALIBRATION_REQUEST_PORT()) uses_autocalibration_request_port = TRUE ; - - else if (dest_port != (uint_fast16_t) GET_LISTENING_PORT()) - goto not_explicit_packet ; + else +#endif // USE_PTHREAD + if (dest_port != (uint_fast16_t) GET_LISTENING_PORT()) + goto not_explicit_packet ; } goto process_packet ;