[Aggregator] Refactor read_loop()
Create print_captured_request() out of read_loop().
This commit is contained in:
parent
0e913a2938
commit
ef154b6d91
|
@ -108,6 +108,7 @@ int parse_command_line(int argc, char **argv) ;
|
|||
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* monitor_requests(void *NULL_value) ;
|
||||
|
|
|
@ -558,56 +558,7 @@ int read_loop(int sockfd)
|
|||
request.nb_packets = ntohs(request.nb_packets) ;
|
||||
|
||||
if (VERBOSE_REQUESTS)
|
||||
{
|
||||
char
|
||||
request_time_str[OWL_TIMESTAMP_STRLEN],
|
||||
capture_time_str[OWL_TIMESTAMP_STRLEN],
|
||||
ap_mac_addr_str[OWL_ETHER_ADDR_STRLEN],
|
||||
mobile_mac_addr_str[OWL_ETHER_ADDR_STRLEN],
|
||||
mobile_ip_str[INET_ADDRSTRLEN] ;
|
||||
|
||||
owl_timestamp_to_string(&request.request_time,
|
||||
request_time_str) ;
|
||||
owl_timestamp_to_string(&request.capture_time,
|
||||
capture_time_str) ;
|
||||
owl_mac_bytes_to_string_r(request.ap_mac_addr_bytes,
|
||||
ap_mac_addr_str) ;
|
||||
owl_mac_bytes_to_string_r(request.mobile_mac_addr_bytes,
|
||||
mobile_mac_addr_str) ;
|
||||
inet_ntop(AF_INET, &request.mobile_ip_addr_bytes,
|
||||
mobile_ip_str, INET_ADDRSTRLEN) ;
|
||||
|
||||
fprintf(stderr,
|
||||
"\n"
|
||||
"*** Request received from AP ***\n"
|
||||
"\tType: %"PRIu8"\n"
|
||||
"\tAP MAC: %s\n"
|
||||
"\tMobile MAC: %s\n"
|
||||
"\tMobile IP: %s\n"
|
||||
"\tRequest timestamp: %s\n"
|
||||
"\tRequest arrival time on the AP: %s\n"
|
||||
"\tSignal: %"PRId8" dBm\n"
|
||||
"\tPosition X: %f\n"
|
||||
"\tPosition Y: %f\n"
|
||||
"\tPosition Z: %f\n"
|
||||
"\tDirection: %"PRIu8"\n"
|
||||
"\tPacket number: %"PRIu16"/%"PRIu16"\n"
|
||||
,
|
||||
request.type,
|
||||
ap_mac_addr_str,
|
||||
mobile_mac_addr_str,
|
||||
mobile_ip_str,
|
||||
request_time_str,
|
||||
capture_time_str,
|
||||
request.ss_dbm,
|
||||
request.x_position,
|
||||
request.y_position,
|
||||
request.z_position,
|
||||
request.direction,
|
||||
request.packet_id,
|
||||
request.nb_packets
|
||||
) ;
|
||||
}
|
||||
print_captured_request(&request) ;
|
||||
else if (VERBOSE_CHATTERBOX)
|
||||
fprintf(stderr, "Request received from AP \"%s\".\n",
|
||||
owl_mac_bytes_to_string(request.ap_mac_addr_bytes)) ;
|
||||
|
@ -619,6 +570,62 @@ int read_loop(int sockfd)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Prints an owl_captured_request on the standard error.
|
||||
*/
|
||||
void print_captured_request(const owl_captured_request *const request)
|
||||
{
|
||||
char
|
||||
request_time_str[OWL_TIMESTAMP_STRLEN],
|
||||
capture_time_str[OWL_TIMESTAMP_STRLEN],
|
||||
ap_mac_addr_str[OWL_ETHER_ADDR_STRLEN],
|
||||
mobile_mac_addr_str[OWL_ETHER_ADDR_STRLEN],
|
||||
mobile_ip_str[INET_ADDRSTRLEN] ;
|
||||
|
||||
assert(request) ;
|
||||
|
||||
owl_timestamp_to_string(&request->request_time, request_time_str) ;
|
||||
owl_timestamp_to_string(&request->capture_time, capture_time_str) ;
|
||||
owl_mac_bytes_to_string_r(request->ap_mac_addr_bytes,
|
||||
ap_mac_addr_str) ;
|
||||
owl_mac_bytes_to_string_r(request->mobile_mac_addr_bytes,
|
||||
mobile_mac_addr_str) ;
|
||||
inet_ntop(AF_INET, &request->mobile_ip_addr_bytes,
|
||||
mobile_ip_str, INET_ADDRSTRLEN) ;
|
||||
|
||||
fprintf(stderr,
|
||||
"\n"
|
||||
"*** Request received from AP ***\n"
|
||||
"\tType: %"PRIu8"\n"
|
||||
"\tAP MAC: %s\n"
|
||||
"\tMobile MAC: %s\n"
|
||||
"\tMobile IP: %s\n"
|
||||
"\tRequest timestamp: %s\n"
|
||||
"\tRequest arrival time on the AP: %s\n"
|
||||
"\tSignal: %"PRId8" dBm\n"
|
||||
"\tPosition X: %f\n"
|
||||
"\tPosition Y: %f\n"
|
||||
"\tPosition Z: %f\n"
|
||||
"\tDirection: %"PRIu8"\n"
|
||||
"\tPacket number: %"PRIu16"/%"PRIu16"\n"
|
||||
,
|
||||
request->type,
|
||||
ap_mac_addr_str,
|
||||
mobile_mac_addr_str,
|
||||
mobile_ip_str,
|
||||
request_time_str,
|
||||
capture_time_str,
|
||||
request->ss_dbm,
|
||||
request->x_position,
|
||||
request->y_position,
|
||||
request->z_position,
|
||||
request->direction,
|
||||
request->packet_id,
|
||||
request->nb_packets
|
||||
) ;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Treats a received packet.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue