[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) ;
|
||||
void read_packet(u_char *args, const struct pcap_pkthdr *header,
|
||||
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_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 :
|
||||
if (VERBOSE_INFO)
|
||||
printf("\nExplicit calibration packet received.\n") ;
|
||||
request.direction =
|
||||
packet[rtap_bytes + ieee80211_header_size + LLC_HEADER_SIZE
|
||||
+ sizeof(struct iphdr) + sizeof(struct udphdr) + 9];
|
||||
memcpy(&request.x_position,
|
||||
&packet[rtap_bytes + ieee80211_header_size
|
||||
+ LLC_HEADER_SIZE + sizeof(struct iphdr)
|
||||
+ 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)) ;
|
||||
extract_calibration_data(&packet[rtap_bytes +
|
||||
ieee80211_header_size +
|
||||
LLC_HEADER_SIZE
|
||||
+ sizeof(struct iphdr) +
|
||||
sizeof(struct udphdr) + 9],
|
||||
&request) ;
|
||||
break ;
|
||||
|
||||
case OWL_REQUEST_AUTOCALIBRATION :
|
||||
|
@ -934,21 +925,12 @@ void read_packet(u_char *args, const struct pcap_pkthdr *header,
|
|||
printf(".. on the wrong port!") ;
|
||||
putchar('\n') ;
|
||||
}
|
||||
request.direction =
|
||||
packet[rtap_bytes + ieee80211_header_size + LLC_HEADER_SIZE
|
||||
+ sizeof(struct iphdr) + sizeof(struct udphdr) + 9];
|
||||
memcpy(&request.x_position,
|
||||
&packet[rtap_bytes + ieee80211_header_size
|
||||
+ LLC_HEADER_SIZE + sizeof(struct iphdr)
|
||||
+ 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)) ;
|
||||
extract_calibration_data(&packet[rtap_bytes +
|
||||
ieee80211_header_size +
|
||||
LLC_HEADER_SIZE
|
||||
+ sizeof(struct iphdr) +
|
||||
sizeof(struct udphdr) + 9],
|
||||
&request) ;
|
||||
break ;
|
||||
|
||||
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'.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue