diff --git a/owlps-aggregator/owlps-aggregator.h b/owlps-aggregator/owlps-aggregator.h index 0e68653..8b1d8dc 100644 --- a/owlps-aggregator/owlps-aggregator.h +++ b/owlps-aggregator/owlps-aggregator.h @@ -109,7 +109,7 @@ int check_configuration(void) ; int read_loop(int sockfd) ; void print_captured_request(const owl_captured_request *const request) ; -void got_request(owl_captured_request request) ; +void got_request(const owl_captured_request *const request) ; void* monitor_requests(void *NULL_value) ; void scan_request_list(FILE *const stream, diff --git a/owlps-aggregator/owlps-aggregatord.c b/owlps-aggregator/owlps-aggregatord.c index 24deca6..6731c36 100644 --- a/owlps-aggregator/owlps-aggregatord.c +++ b/owlps-aggregator/owlps-aggregatord.c @@ -563,7 +563,7 @@ int read_loop(int sockfd) fprintf(stderr, "Request received from AP \"%s\".\n", owl_mac_bytes_to_string(request.ap_mac_addr_bytes)) ; - got_request(request) ; + got_request(&request) ; } return ret ; @@ -629,12 +629,14 @@ void print_captured_request(const owl_captured_request *const request) /* * Treats a received packet. */ -void got_request(owl_captured_request request) +void got_request(const owl_captured_request *const request) { request_list *tmp_request = NULL ; request_info_list *tmp_info = NULL ; owl_timestamp start_time ; // Reception time on the aggregator + assert(request) ; + owl_timestamp_now(&start_time) ; /* Create a new request */ @@ -646,11 +648,11 @@ void got_request(owl_captured_request request) return ; } - tmp_info->packet_id = request.packet_id ; - memcpy(tmp_info->ap_mac_addr_bytes, request.ap_mac_addr_bytes, + tmp_info->packet_id = request->packet_id ; + memcpy(tmp_info->ap_mac_addr_bytes, request->ap_mac_addr_bytes, ETHER_ADDR_LEN) ; - tmp_info->capture_time = request.capture_time ; - tmp_info->ss_dbm = request.ss_dbm ; + tmp_info->capture_time = request->capture_time ; + tmp_info->ss_dbm = request->ss_dbm ; tmp_info->next = NULL ; /* Add it in the list */ @@ -668,7 +670,7 @@ void got_request(owl_captured_request request) { if (VERBOSE_INFO) fprintf(stderr, "Creating request list with AP \"%s\".\n", - owl_mac_bytes_to_string(request.ap_mac_addr_bytes)) ; + owl_mac_bytes_to_string(request->ap_mac_addr_bytes)) ; tmp_request = malloc(sizeof(request_list)) ; // create it. if (! tmp_request) { @@ -676,27 +678,27 @@ void got_request(owl_captured_request request) owl_run = false ; goto end ; } - tmp_request->type = request.type ; - tmp_request->nb_packets = request.nb_packets ; + tmp_request->type = request->type ; + tmp_request->nb_packets = request->nb_packets ; memcpy(tmp_request->mobile_mac_addr_bytes, - request.mobile_mac_addr_bytes, ETHER_ADDR_LEN) ; + request->mobile_mac_addr_bytes, ETHER_ADDR_LEN) ; memcpy(tmp_request->mobile_ip_addr_bytes, - request.mobile_ip_addr_bytes, 4) ; + request->mobile_ip_addr_bytes, 4) ; // Explicit packet: - if (request.type != OWL_REQUEST_IMPLICIT) + if (request->type != OWL_REQUEST_IMPLICIT) // Transmission time on the mobile: - tmp_request->request_time = request.request_time ; + tmp_request->request_time = request->request_time ; // Implicit packet: else // Reception time on the AP: - tmp_request->request_time = request.capture_time ; + tmp_request->request_time = request->capture_time ; // Save locale time on the aggregator (not the reception time // on the AP): tmp_request->start_time = start_time ; - tmp_request->x_position = request.x_position ; - tmp_request->y_position = request.y_position ; - tmp_request->z_position = request.z_position ; - tmp_request->direction = request.direction ; + tmp_request->x_position = request->x_position ; + tmp_request->y_position = request->y_position ; + tmp_request->z_position = request->z_position ; + tmp_request->direction = request->direction ; tmp_request->next = NULL ; tmp_request->info = tmp_info ; requests = tmp_request ; @@ -705,13 +707,13 @@ void got_request(owl_captured_request request) else // If the request list exists already { // we search the list for the request // Explicit packet: - if (request.type != OWL_REQUEST_IMPLICIT) + if (request->type != OWL_REQUEST_IMPLICIT) { while (tmp_request != NULL) { // Research criterion: MAC and transmission time - if (owl_mac_equals(request.mobile_mac_addr_bytes, + if (owl_mac_equals(request->mobile_mac_addr_bytes, tmp_request->mobile_mac_addr_bytes) - && owl_timestamp_equals(&request.request_time, + && owl_timestamp_equals(&request->request_time, &tmp_request->request_time)) break ; // If the request exists, we stop on it tmp_request = tmp_request->next ; @@ -724,9 +726,9 @@ void got_request(owl_captured_request request) { // Research criterion: MAC addresses equals and reception // times on the APs less than 10 ms // TODO : define an option for the maximal difference time. - if (owl_mac_equals(request.mobile_mac_addr_bytes, + if (owl_mac_equals(request->mobile_mac_addr_bytes, tmp_request->mobile_mac_addr_bytes) && - owl_time_elapsed_ms(&request.capture_time, + owl_time_elapsed_ms(&request->capture_time, &tmp_request->request_time) <= 10) break ; // If the request exists, we stop on it tmp_request = tmp_request->next ; @@ -737,7 +739,7 @@ void got_request(owl_captured_request request) { if (VERBOSE_INFO) fprintf(stderr, "Create new request from AP \"%s\".\n", - owl_mac_bytes_to_string(request.ap_mac_addr_bytes)) ; + owl_mac_bytes_to_string(request->ap_mac_addr_bytes)) ; tmp_request = malloc(sizeof(request_list)) ; // create it if (! tmp_request) { @@ -745,27 +747,27 @@ void got_request(owl_captured_request request) owl_run = false ; goto end ; } - tmp_request->type = request.type ; - tmp_request->nb_packets = request.nb_packets ; + tmp_request->type = request->type ; + tmp_request->nb_packets = request->nb_packets ; memcpy(tmp_request->mobile_mac_addr_bytes, - request.mobile_mac_addr_bytes, ETHER_ADDR_LEN) ; + request->mobile_mac_addr_bytes, ETHER_ADDR_LEN) ; memcpy(tmp_request->mobile_ip_addr_bytes, - request.mobile_ip_addr_bytes, 4) ; + request->mobile_ip_addr_bytes, 4) ; // Explicit packet: - if (request.type != OWL_REQUEST_IMPLICIT) + if (request->type != OWL_REQUEST_IMPLICIT) // Transmission time on the mobile: - tmp_request->request_time = request.request_time ; + tmp_request->request_time = request->request_time ; // Implicit packet: else // Reception time on the AP: - tmp_request->request_time = request.capture_time ; + tmp_request->request_time = request->capture_time ; // Save the local time on the aggregator (not the reception // time on the AP): tmp_request->start_time = start_time ; - tmp_request->x_position = request.x_position ; - tmp_request->y_position = request.y_position ; - tmp_request->z_position = request.z_position ; - tmp_request->direction = request.direction ; + tmp_request->x_position = request->x_position ; + tmp_request->y_position = request->y_position ; + tmp_request->z_position = request->z_position ; + tmp_request->direction = request->direction ; tmp_request->next = requests ; tmp_request->info = tmp_info ; requests = tmp_request ;