[Aggregator] got_request(): pointer parameter
For performance's sake, the request passed in parameter of got_request() is now a const pointer instead of a struct.
This commit is contained in:
parent
ef154b6d91
commit
068553ee49
|
@ -109,7 +109,7 @@ int check_configuration(void) ;
|
||||||
|
|
||||||
int read_loop(int sockfd) ;
|
int read_loop(int sockfd) ;
|
||||||
void print_captured_request(const owl_captured_request *const request) ;
|
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* monitor_requests(void *NULL_value) ;
|
||||||
void scan_request_list(FILE *const stream,
|
void scan_request_list(FILE *const stream,
|
||||||
|
|
|
@ -563,7 +563,7 @@ int read_loop(int sockfd)
|
||||||
fprintf(stderr, "Request received from AP \"%s\".\n",
|
fprintf(stderr, "Request received from AP \"%s\".\n",
|
||||||
owl_mac_bytes_to_string(request.ap_mac_addr_bytes)) ;
|
owl_mac_bytes_to_string(request.ap_mac_addr_bytes)) ;
|
||||||
|
|
||||||
got_request(request) ;
|
got_request(&request) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret ;
|
return ret ;
|
||||||
|
@ -629,12 +629,14 @@ void print_captured_request(const owl_captured_request *const request)
|
||||||
/*
|
/*
|
||||||
* Treats a received packet.
|
* 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_list *tmp_request = NULL ;
|
||||||
request_info_list *tmp_info = NULL ;
|
request_info_list *tmp_info = NULL ;
|
||||||
owl_timestamp start_time ; // Reception time on the aggregator
|
owl_timestamp start_time ; // Reception time on the aggregator
|
||||||
|
|
||||||
|
assert(request) ;
|
||||||
|
|
||||||
owl_timestamp_now(&start_time) ;
|
owl_timestamp_now(&start_time) ;
|
||||||
|
|
||||||
/* Create a new request */
|
/* Create a new request */
|
||||||
|
@ -646,11 +648,11 @@ void got_request(owl_captured_request request)
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp_info->packet_id = request.packet_id ;
|
tmp_info->packet_id = request->packet_id ;
|
||||||
memcpy(tmp_info->ap_mac_addr_bytes, request.ap_mac_addr_bytes,
|
memcpy(tmp_info->ap_mac_addr_bytes, request->ap_mac_addr_bytes,
|
||||||
ETHER_ADDR_LEN) ;
|
ETHER_ADDR_LEN) ;
|
||||||
tmp_info->capture_time = request.capture_time ;
|
tmp_info->capture_time = request->capture_time ;
|
||||||
tmp_info->ss_dbm = request.ss_dbm ;
|
tmp_info->ss_dbm = request->ss_dbm ;
|
||||||
tmp_info->next = NULL ;
|
tmp_info->next = NULL ;
|
||||||
|
|
||||||
/* Add it in the list */
|
/* Add it in the list */
|
||||||
|
@ -668,7 +670,7 @@ void got_request(owl_captured_request request)
|
||||||
{
|
{
|
||||||
if (VERBOSE_INFO)
|
if (VERBOSE_INFO)
|
||||||
fprintf(stderr, "Creating request list with AP \"%s\".\n",
|
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.
|
tmp_request = malloc(sizeof(request_list)) ; // create it.
|
||||||
if (! tmp_request)
|
if (! tmp_request)
|
||||||
{
|
{
|
||||||
|
@ -676,27 +678,27 @@ void got_request(owl_captured_request request)
|
||||||
owl_run = false ;
|
owl_run = false ;
|
||||||
goto end ;
|
goto end ;
|
||||||
}
|
}
|
||||||
tmp_request->type = request.type ;
|
tmp_request->type = request->type ;
|
||||||
tmp_request->nb_packets = request.nb_packets ;
|
tmp_request->nb_packets = request->nb_packets ;
|
||||||
memcpy(tmp_request->mobile_mac_addr_bytes,
|
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,
|
memcpy(tmp_request->mobile_ip_addr_bytes,
|
||||||
request.mobile_ip_addr_bytes, 4) ;
|
request->mobile_ip_addr_bytes, 4) ;
|
||||||
// Explicit packet:
|
// Explicit packet:
|
||||||
if (request.type != OWL_REQUEST_IMPLICIT)
|
if (request->type != OWL_REQUEST_IMPLICIT)
|
||||||
// Transmission time on the mobile:
|
// Transmission time on the mobile:
|
||||||
tmp_request->request_time = request.request_time ;
|
tmp_request->request_time = request->request_time ;
|
||||||
// Implicit packet:
|
// Implicit packet:
|
||||||
else
|
else
|
||||||
// Reception time on the AP:
|
// 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
|
// Save locale time on the aggregator (not the reception time
|
||||||
// on the AP):
|
// on the AP):
|
||||||
tmp_request->start_time = start_time ;
|
tmp_request->start_time = start_time ;
|
||||||
tmp_request->x_position = request.x_position ;
|
tmp_request->x_position = request->x_position ;
|
||||||
tmp_request->y_position = request.y_position ;
|
tmp_request->y_position = request->y_position ;
|
||||||
tmp_request->z_position = request.z_position ;
|
tmp_request->z_position = request->z_position ;
|
||||||
tmp_request->direction = request.direction ;
|
tmp_request->direction = request->direction ;
|
||||||
tmp_request->next = NULL ;
|
tmp_request->next = NULL ;
|
||||||
tmp_request->info = tmp_info ;
|
tmp_request->info = tmp_info ;
|
||||||
requests = tmp_request ;
|
requests = tmp_request ;
|
||||||
|
@ -705,13 +707,13 @@ void got_request(owl_captured_request request)
|
||||||
else // If the request list exists already
|
else // If the request list exists already
|
||||||
{ // we search the list for the request
|
{ // we search the list for the request
|
||||||
// Explicit packet:
|
// Explicit packet:
|
||||||
if (request.type != OWL_REQUEST_IMPLICIT)
|
if (request->type != OWL_REQUEST_IMPLICIT)
|
||||||
{
|
{
|
||||||
while (tmp_request != NULL)
|
while (tmp_request != NULL)
|
||||||
{ // Research criterion: MAC and transmission time
|
{ // 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)
|
tmp_request->mobile_mac_addr_bytes)
|
||||||
&& owl_timestamp_equals(&request.request_time,
|
&& owl_timestamp_equals(&request->request_time,
|
||||||
&tmp_request->request_time))
|
&tmp_request->request_time))
|
||||||
break ; // If the request exists, we stop on it
|
break ; // If the request exists, we stop on it
|
||||||
tmp_request = tmp_request->next ;
|
tmp_request = tmp_request->next ;
|
||||||
|
@ -724,9 +726,9 @@ void got_request(owl_captured_request request)
|
||||||
{ // Research criterion: MAC addresses equals and reception
|
{ // Research criterion: MAC addresses equals and reception
|
||||||
// times on the APs less than 10 ms
|
// times on the APs less than 10 ms
|
||||||
// TODO : define an option for the maximal difference time.
|
// 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) &&
|
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)
|
&tmp_request->request_time) <= 10)
|
||||||
break ; // If the request exists, we stop on it
|
break ; // If the request exists, we stop on it
|
||||||
tmp_request = tmp_request->next ;
|
tmp_request = tmp_request->next ;
|
||||||
|
@ -737,7 +739,7 @@ void got_request(owl_captured_request request)
|
||||||
{
|
{
|
||||||
if (VERBOSE_INFO)
|
if (VERBOSE_INFO)
|
||||||
fprintf(stderr, "Create new request from AP \"%s\".\n",
|
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
|
tmp_request = malloc(sizeof(request_list)) ; // create it
|
||||||
if (! tmp_request)
|
if (! tmp_request)
|
||||||
{
|
{
|
||||||
|
@ -745,27 +747,27 @@ void got_request(owl_captured_request request)
|
||||||
owl_run = false ;
|
owl_run = false ;
|
||||||
goto end ;
|
goto end ;
|
||||||
}
|
}
|
||||||
tmp_request->type = request.type ;
|
tmp_request->type = request->type ;
|
||||||
tmp_request->nb_packets = request.nb_packets ;
|
tmp_request->nb_packets = request->nb_packets ;
|
||||||
memcpy(tmp_request->mobile_mac_addr_bytes,
|
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,
|
memcpy(tmp_request->mobile_ip_addr_bytes,
|
||||||
request.mobile_ip_addr_bytes, 4) ;
|
request->mobile_ip_addr_bytes, 4) ;
|
||||||
// Explicit packet:
|
// Explicit packet:
|
||||||
if (request.type != OWL_REQUEST_IMPLICIT)
|
if (request->type != OWL_REQUEST_IMPLICIT)
|
||||||
// Transmission time on the mobile:
|
// Transmission time on the mobile:
|
||||||
tmp_request->request_time = request.request_time ;
|
tmp_request->request_time = request->request_time ;
|
||||||
// Implicit packet:
|
// Implicit packet:
|
||||||
else
|
else
|
||||||
// Reception time on the AP:
|
// 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
|
// Save the local time on the aggregator (not the reception
|
||||||
// time on the AP):
|
// time on the AP):
|
||||||
tmp_request->start_time = start_time ;
|
tmp_request->start_time = start_time ;
|
||||||
tmp_request->x_position = request.x_position ;
|
tmp_request->x_position = request->x_position ;
|
||||||
tmp_request->y_position = request.y_position ;
|
tmp_request->y_position = request->y_position ;
|
||||||
tmp_request->z_position = request.z_position ;
|
tmp_request->z_position = request->z_position ;
|
||||||
tmp_request->direction = request.direction ;
|
tmp_request->direction = request->direction ;
|
||||||
tmp_request->next = requests ;
|
tmp_request->next = requests ;
|
||||||
tmp_request->info = tmp_info ;
|
tmp_request->info = tmp_info ;
|
||||||
requests = tmp_request ;
|
requests = tmp_request ;
|
||||||
|
|
Loading…
Reference in New Issue