[Listener] Improve BSD friendliness
This commit is contained in:
parent
14e9a4122a
commit
7d3650fb5d
|
@ -27,10 +27,6 @@
|
|||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/if.h>
|
||||
#include <net/ethernet.h>
|
||||
|
||||
#ifdef OWLPS_LISTENER_USES_CONFIG_FILE
|
||||
# include <confuse.h>
|
||||
#endif // OWLPS_LISTENER_USES_CONFIG_FILE
|
||||
|
@ -43,8 +39,14 @@
|
|||
# include <iwlib.h>
|
||||
#endif // OWLPS_LISTENER_KEEPS_MONITOR
|
||||
|
||||
// Used by get_mac_addr():
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/if.h>
|
||||
#include <netinet/if_ether.h>
|
||||
|
||||
#define __FAVOR_BSD
|
||||
#include <netinet/udp.h>
|
||||
|
||||
#include <netinet/in_systm.h> // for n_time on BSD (used in ip.h)
|
||||
#include <netinet/ip.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
|
@ -989,7 +991,7 @@ void read_packet(const struct pcap_pkthdr *pkt_header,
|
|||
uint_fast8_t ieee80211_header_size = IEEE80211_HEADER_SIZE_DATA ;
|
||||
uint16_t llc_packet_type = 0 ;
|
||||
// Pointer to the (possible) IP header of the packet:
|
||||
struct iphdr *packet_ip_header = NULL ;
|
||||
struct ip *packet_ip_header = NULL ;
|
||||
// Pointer to the (possible) UDP header of the packet:
|
||||
struct udphdr *packet_udp_header = NULL ;
|
||||
// Localisation request type (request, calibration, autocalibration):
|
||||
|
@ -1047,24 +1049,24 @@ void read_packet(const struct pcap_pkthdr *pkt_header,
|
|||
goto not_explicit_packet ;
|
||||
|
||||
offset = rtap_bytes + ieee80211_header_size + LLC_HEADER_SIZE ;
|
||||
packet_ip_header = (struct iphdr *) &pkt_data[offset] ;
|
||||
packet_ip_header = (struct ip *) &pkt_data[offset] ;
|
||||
// Get the source IP:
|
||||
memcpy(request.mobile_ip_addr_bytes, &packet_ip_header->saddr, 4) ;
|
||||
memcpy(request.mobile_ip_addr_bytes, &packet_ip_header->ip_src, 4) ;
|
||||
|
||||
if (GET_MODE() != MODE_PASSIVE) // If mode is active or mixed
|
||||
{
|
||||
uint_fast16_t dest_port ;
|
||||
|
||||
// Protocol for an explicit request is UDP
|
||||
if (packet_ip_header->protocol != IPPROTO_UDP)
|
||||
if (packet_ip_header->ip_p != IPPROTO_UDP)
|
||||
goto not_explicit_packet ;
|
||||
|
||||
// Check destination port:
|
||||
offset =
|
||||
rtap_bytes + ieee80211_header_size +
|
||||
LLC_HEADER_SIZE + sizeof(struct iphdr) ;
|
||||
LLC_HEADER_SIZE + sizeof(struct ip) ;
|
||||
packet_udp_header = (struct udphdr *) &pkt_data[offset] ;
|
||||
dest_port = ntohs(packet_udp_header->dest) ;
|
||||
dest_port = ntohs(packet_udp_header->uh_dport) ;
|
||||
|
||||
#ifdef OWLPS_LISTENER_USES_PTHREAD
|
||||
if (GET_AUTOCALIBRATION() && dest_port ==
|
||||
|
@ -1111,7 +1113,7 @@ void read_packet(const struct pcap_pkthdr *pkt_header,
|
|||
{
|
||||
offset =
|
||||
rtap_bytes + ieee80211_header_size + LLC_HEADER_SIZE +
|
||||
sizeof(struct iphdr) + sizeof(struct udphdr) ;
|
||||
sizeof(struct ip) + sizeof(struct udphdr) ;
|
||||
request.type = pkt_data[offset] ;
|
||||
extract_packet_numbers(&pkt_data[++offset], &request) ;
|
||||
offset += 2 * sizeof(uint16_t) ;
|
||||
|
|
Loading…
Reference in New Issue