[Listener] Add display_captured_request()
Create the display_captured_request() function from read_packet() code.
This commit is contained in:
parent
75b6539757
commit
559c884499
|
@ -221,6 +221,8 @@ void extract_packet_numbers(const u_char *pkt_data,
|
|||
bool extract_radiotap_ss(const u_char *pkt_data,
|
||||
owl_captured_request *request) ;
|
||||
uint_fast16_t nat_align(uint_fast16_t offset, uint_fast8_t field_len) ;
|
||||
void display_captured_request(owl_captured_request *request,
|
||||
const struct pcap_pkthdr *pkt_header) ;
|
||||
void get_mac_addr(char *eth, uint8_t mac_bytes[ETHER_ADDR_LEN]) ;
|
||||
void get_ip_addr(char *eth, char *ip_bytes) ;
|
||||
|
||||
|
|
|
@ -1173,59 +1173,7 @@ void read_packet(const struct pcap_pkthdr *pkt_header,
|
|||
|
||||
/* Display the packet details */
|
||||
if (VERBOSE_DISPLAY_CAPTURED)
|
||||
{
|
||||
owl_timestamp tmp_time ;
|
||||
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] ;
|
||||
|
||||
tmp_time = request.request_time ;
|
||||
owl_ntoh_timestamp(&tmp_time) ;
|
||||
owl_timestamp_to_string(&tmp_time, request_time_str) ;
|
||||
tmp_time = request.capture_time ;
|
||||
owl_ntoh_timestamp(&tmp_time) ;
|
||||
owl_timestamp_to_string(&tmp_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) ;
|
||||
|
||||
printf("*** Request to send ***\n"
|
||||
"\tType: %"PRIu8"\n"
|
||||
"\tMAC AP: %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: %hhd\n"
|
||||
"\tPacket number: %"PRIu16"/%"PRIu16"\n"
|
||||
"\tPacket size: %"PRIu32"\n"
|
||||
,
|
||||
request.type,
|
||||
ap_mac_addr_str,
|
||||
mobile_mac_addr_str,
|
||||
mobile_ip_str,
|
||||
request_time_str,
|
||||
capture_time_str,
|
||||
request.ss_dbm,
|
||||
owl_ntohf(request.x_position),
|
||||
owl_ntohf(request.y_position),
|
||||
owl_ntohf(request.z_position),
|
||||
request.direction,
|
||||
ntohs(request.packet_id),
|
||||
ntohs(request.nb_packets),
|
||||
pkt_header->len
|
||||
) ;
|
||||
}
|
||||
display_captured_request(&request, pkt_header) ;
|
||||
|
||||
/* Send the request to the aggregator */
|
||||
nsent =
|
||||
|
@ -1363,6 +1311,64 @@ uint_fast16_t nat_align(uint_fast16_t offset, uint_fast8_t field_len)
|
|||
|
||||
|
||||
|
||||
void display_captured_request(owl_captured_request *request,
|
||||
const struct pcap_pkthdr *pkt_header)
|
||||
{
|
||||
owl_timestamp tmp_time ;
|
||||
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] ;
|
||||
|
||||
tmp_time = request->request_time ;
|
||||
owl_ntoh_timestamp(&tmp_time) ;
|
||||
owl_timestamp_to_string(&tmp_time, request_time_str) ;
|
||||
tmp_time = request->capture_time ;
|
||||
owl_ntoh_timestamp(&tmp_time) ;
|
||||
owl_timestamp_to_string(&tmp_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) ;
|
||||
|
||||
printf("*** Request to send ***\n"
|
||||
"\tType: %"PRIu8"\n"
|
||||
"\tMAC AP: %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: %hhd\n"
|
||||
"\tPacket number: %"PRIu16"/%"PRIu16"\n"
|
||||
"\tPacket size: %"PRIu32"\n"
|
||||
,
|
||||
request->type,
|
||||
ap_mac_addr_str,
|
||||
mobile_mac_addr_str,
|
||||
mobile_ip_str,
|
||||
request_time_str,
|
||||
capture_time_str,
|
||||
request->ss_dbm,
|
||||
owl_ntohf(request->x_position),
|
||||
owl_ntohf(request->y_position),
|
||||
owl_ntohf(request->z_position),
|
||||
request->direction,
|
||||
ntohs(request->packet_id),
|
||||
ntohs(request->nb_packets),
|
||||
pkt_header->len
|
||||
) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Get our own MAC address and copy it to 'mac_bytes'.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue