From 7d3650fb5d20b6e0fb0518d6c4fcc1a52319a050 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Fri, 14 Jun 2013 18:01:19 -0400 Subject: [PATCH] [Listener] Improve BSD friendliness --- owlps-listener/owlps-listenerd.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/owlps-listener/owlps-listenerd.c b/owlps-listener/owlps-listenerd.c index 99376ff..ea3632a 100644 --- a/owlps-listener/owlps-listenerd.c +++ b/owlps-listener/owlps-listenerd.c @@ -27,10 +27,6 @@ #include #include -#include -#include -#include - #ifdef OWLPS_LISTENER_USES_CONFIG_FILE # include #endif // OWLPS_LISTENER_USES_CONFIG_FILE @@ -43,8 +39,14 @@ # include #endif // OWLPS_LISTENER_KEEPS_MONITOR -// Used by get_mac_addr(): +#include +#include +#include + +#define __FAVOR_BSD #include + +#include // for n_time on BSD (used in ip.h) #include #include @@ -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) ;