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