From 10a47246f42840c2526a0eceac179c8d4fadf077 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Thu, 10 Mar 2011 13:16:35 +0100 Subject: [PATCH] [lib] Rename sub_date() -> time_elapsed() --- .../owlps-aggregator/owlps-aggregatord.c | 14 +++++++------- libowlps/libowlps.c | 4 ++-- libowlps/owlps.h | 2 +- mobile-centred/librtapscanmob/librtapscanmob.c | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/infrastructure-centred/owlps-aggregator/owlps-aggregatord.c b/infrastructure-centred/owlps-aggregator/owlps-aggregatord.c index d1e4ed8..48b9f34 100644 --- a/infrastructure-centred/owlps-aggregator/owlps-aggregatord.c +++ b/infrastructure-centred/owlps-aggregator/owlps-aggregatord.c @@ -390,7 +390,7 @@ void* monitor_couples() struct timeval current_time ; FILE *fd = NULL ; char *mac_string ; - unsigned long sub ; // sub_date() result + unsigned long sub ; // time_elapsed() result unsigned long aggregate_timeout = (unsigned long) cfg_getint(cfg, "aggregate_timeout") ; @@ -430,7 +430,7 @@ void* monitor_couples() while (couple_ptr != NULL) // Parsing list { - sub = sub_date(couple_ptr->start_time, current_time) ; + sub = time_elapsed(couple_ptr->start_time, current_time) ; // If the couple was not treated already if (couple_ptr->info != NULL) @@ -604,8 +604,8 @@ void got_couple_info(couple_message message) { // Research criterion: MAC and transmission time if (mac_equals(message.mobile_mac_addr_bytes, tmp_couple->mobile_mac_addr_bytes) == 1 - && sub_date(message.request_time, - tmp_couple->request_time) == 0) + && time_elapsed(message.request_time, + tmp_couple->request_time) == 0) break ; // If the couple exists, we stop on it tmp_couple = tmp_couple->next ; } @@ -618,8 +618,8 @@ void got_couple_info(couple_message message) // TODO : define an option for the maximal difference time. if (mac_equals(message.mobile_mac_addr_bytes, tmp_couple->mobile_mac_addr_bytes) == 1 - && sub_date(message.start_time, - tmp_couple->request_time) <= 10) + && time_elapsed(message.start_time, + tmp_couple->request_time) <= 10) break ; // If the couple exists, we stop on it tmp_couple = tmp_couple->next ; } @@ -888,7 +888,7 @@ void delete_old_aps() gettimeofday(&now, NULL) ; while (token_aps != NULL) - if (sub_date(token_aps->last_seen, now) > + if (time_elapsed(token_aps->last_seen, now) > (unsigned long) cfg_getint(cfg, "ap_keep_timeout") * 1000) delete_ap(token_aps) ; else diff --git a/libowlps/libowlps.c b/libowlps/libowlps.c index dbd001a..b6e4227 100644 --- a/libowlps/libowlps.c +++ b/libowlps/libowlps.c @@ -117,11 +117,11 @@ struct timeval ms_to_timeval(unsigned long long tms) /* * Returns the time (in milliseconds) between two dates. */ -unsigned long sub_date(struct timeval sup, struct timeval inf) +unsigned long time_elapsed(struct timeval sup, struct timeval inf) { unsigned long sub = abs(timeval_to_ms(sup) - timeval_to_ms(inf)) ; #ifdef DEBUG - printf("sub_date() : sub=%lu\n", sub) ; + printf("time_elapsed(): %lu\n", sub) ; #endif return sub ; } diff --git a/libowlps/owlps.h b/libowlps/owlps.h index ad1747f..ce20899 100644 --- a/libowlps/owlps.h +++ b/libowlps/owlps.h @@ -220,7 +220,7 @@ char frequency_to_channel(unsigned short channel) ; // Time unsigned long long timeval_to_ms(struct timeval date) ; -unsigned long sub_date(struct timeval sup, struct timeval inf) ; +unsigned long time_elapsed(struct timeval sup, struct timeval inf) ; // Network int create_udp_sending_socket(char *server_address, int server_port, diff --git a/mobile-centred/librtapscanmob/librtapscanmob.c b/mobile-centred/librtapscanmob/librtapscanmob.c index 50837dd..9a85b2d 100644 --- a/mobile-centred/librtapscanmob/librtapscanmob.c +++ b/mobile-centred/librtapscanmob/librtapscanmob.c @@ -47,7 +47,7 @@ int capture(char *capture_iface, unsigned long capture_time, mac_list **results, pcap_loop(handle, 1, got_packet, NULL) ; // Collecte 1 paquet et appelle la fonction got_packet quand pcaploop a recupéré des paquets gettimeofday(&tcurrent, NULL) ; // Récupère l'heure courante - if(sub_date(tcurrent, tbegin) > capture_time) // Si le temps de capture est écoulé + if (time_elapsed(tcurrent, tbegin) > capture_time) // Si le temps de capture est écoulé break ; // on arrête la collecte. } }