[Listener] Add extract_calibration_data()
A first step in the long way of read_packet() refactoring.
This commit is contained in:
parent
ac3c7b4352
commit
4bae0c9b4e
|
@ -176,6 +176,8 @@ int iface_mode_monitor(const char *const iface) ;
|
||||||
int capture(void) ;
|
int capture(void) ;
|
||||||
void read_packet(u_char *args, const struct pcap_pkthdr *header,
|
void read_packet(u_char *args, const struct pcap_pkthdr *header,
|
||||||
const u_char *packet) ;
|
const u_char *packet) ;
|
||||||
|
void extract_calibration_data(const u_char *packet,
|
||||||
|
owl_captured_request *request) ;
|
||||||
void get_mac_addr(char *eth, uint8_t mac_bytes[ETHER_ADDR_LEN]) ;
|
void get_mac_addr(char *eth, uint8_t mac_bytes[ETHER_ADDR_LEN]) ;
|
||||||
void get_ip_addr(char *eth, char *ip_bytes) ;
|
void get_ip_addr(char *eth, char *ip_bytes) ;
|
||||||
|
|
||||||
|
|
|
@ -909,21 +909,12 @@ void read_packet(u_char *args, const struct pcap_pkthdr *header,
|
||||||
case OWL_REQUEST_CALIBRATION :
|
case OWL_REQUEST_CALIBRATION :
|
||||||
if (VERBOSE_INFO)
|
if (VERBOSE_INFO)
|
||||||
printf("\nExplicit calibration packet received.\n") ;
|
printf("\nExplicit calibration packet received.\n") ;
|
||||||
request.direction =
|
extract_calibration_data(&packet[rtap_bytes +
|
||||||
packet[rtap_bytes + ieee80211_header_size + LLC_HEADER_SIZE
|
ieee80211_header_size +
|
||||||
+ sizeof(struct iphdr) + sizeof(struct udphdr) + 9];
|
LLC_HEADER_SIZE
|
||||||
memcpy(&request.x_position,
|
+ sizeof(struct iphdr) +
|
||||||
&packet[rtap_bytes + ieee80211_header_size
|
sizeof(struct udphdr) + 9],
|
||||||
+ LLC_HEADER_SIZE + sizeof(struct iphdr)
|
&request) ;
|
||||||
+ sizeof(struct udphdr) + 10], sizeof(float)) ;
|
|
||||||
memcpy(&request.y_position,
|
|
||||||
&packet[rtap_bytes + ieee80211_header_size
|
|
||||||
+ LLC_HEADER_SIZE + sizeof(struct iphdr)
|
|
||||||
+ sizeof(struct udphdr) + 14], sizeof(float)) ;
|
|
||||||
memcpy(&request.z_position,
|
|
||||||
&packet[rtap_bytes + ieee80211_header_size
|
|
||||||
+ LLC_HEADER_SIZE + sizeof(struct iphdr)
|
|
||||||
+ sizeof(struct udphdr) + 18], sizeof(float)) ;
|
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
case OWL_REQUEST_AUTOCALIBRATION :
|
case OWL_REQUEST_AUTOCALIBRATION :
|
||||||
|
@ -934,21 +925,12 @@ void read_packet(u_char *args, const struct pcap_pkthdr *header,
|
||||||
printf(".. on the wrong port!") ;
|
printf(".. on the wrong port!") ;
|
||||||
putchar('\n') ;
|
putchar('\n') ;
|
||||||
}
|
}
|
||||||
request.direction =
|
extract_calibration_data(&packet[rtap_bytes +
|
||||||
packet[rtap_bytes + ieee80211_header_size + LLC_HEADER_SIZE
|
ieee80211_header_size +
|
||||||
+ sizeof(struct iphdr) + sizeof(struct udphdr) + 9];
|
LLC_HEADER_SIZE
|
||||||
memcpy(&request.x_position,
|
+ sizeof(struct iphdr) +
|
||||||
&packet[rtap_bytes + ieee80211_header_size
|
sizeof(struct udphdr) + 9],
|
||||||
+ LLC_HEADER_SIZE + sizeof(struct iphdr)
|
&request) ;
|
||||||
+ sizeof(struct udphdr) + 10], sizeof(float)) ;
|
|
||||||
memcpy(&request.y_position,
|
|
||||||
&packet[rtap_bytes + ieee80211_header_size
|
|
||||||
+ LLC_HEADER_SIZE + sizeof(struct iphdr)
|
|
||||||
+ sizeof(struct udphdr) + 14], sizeof(float)) ;
|
|
||||||
memcpy(&request.z_position,
|
|
||||||
&packet[rtap_bytes + ieee80211_header_size
|
|
||||||
+ LLC_HEADER_SIZE + sizeof(struct iphdr)
|
|
||||||
+ sizeof(struct udphdr) + 18], sizeof(float)) ;
|
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
default :
|
default :
|
||||||
|
@ -1132,6 +1114,22 @@ void read_packet(u_char *args, const struct pcap_pkthdr *header,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fills 'request' with the calibration data extracted from 'packet'.
|
||||||
|
* Note: 'packet' is read from its first byte, therefore you must not
|
||||||
|
* pass the whole received packet to this function.
|
||||||
|
*/
|
||||||
|
void extract_calibration_data(const u_char *packet,
|
||||||
|
owl_captured_request *request)
|
||||||
|
{
|
||||||
|
request->direction = packet[0] ;
|
||||||
|
memcpy(&request->x_position, &packet[1], sizeof(float)) ;
|
||||||
|
memcpy(&request->y_position, &packet[4], sizeof(float)) ;
|
||||||
|
memcpy(&request->z_position, &packet[8], sizeof(float)) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get our own MAC address and copy it to 'mac_bytes'.
|
* Get our own MAC address and copy it to 'mac_bytes'.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue