2008-02-14 08:54:51 +01:00
|
|
|
/*
|
2013-05-29 18:43:35 +02:00
|
|
|
* This file is part of the Owl Positioning System (OwlPS) project.
|
|
|
|
* It is subject to the copyright notice and license terms in the
|
|
|
|
* COPYRIGHT.t2t file found in the top-level directory of this
|
|
|
|
* distribution and at
|
|
|
|
* http://code.lm7.fr/p/owlps/source/tree/master/COPYRIGHT.t2t
|
|
|
|
* No part of the OwlPS Project, including this file, may be copied,
|
|
|
|
* modified, propagated, or distributed except according to the terms
|
|
|
|
* contained in the COPYRIGHT.t2t file; the COPYRIGHT.t2t file must be
|
|
|
|
* distributed along with this file, either separately or by replacing
|
|
|
|
* this notice by the COPYRIGHT.t2t file's contents.
|
2012-11-03 14:52:33 +01:00
|
|
|
*
|
|
|
|
***********************************************************************
|
|
|
|
*
|
2012-02-06 16:44:09 +01:00
|
|
|
* This is the header file of OwlPS Listener.
|
2008-02-14 08:54:51 +01:00
|
|
|
*/
|
|
|
|
|
2012-02-06 16:44:09 +01:00
|
|
|
|
2010-07-13 14:39:03 +02:00
|
|
|
#ifndef _OWLPS_LISTENER_H_
|
|
|
|
#define _OWLPS_LISTENER_H_
|
2008-02-22 16:04:49 +01:00
|
|
|
|
2013-05-18 20:28:41 +02:00
|
|
|
#include <owlps-listener-config.h>
|
2009-07-02 09:42:15 +02:00
|
|
|
|
2013-05-18 20:28:41 +02:00
|
|
|
#ifdef OWLPS_LISTENER_KEEPS_MONITOR
|
|
|
|
# ifndef OWLPS_LISTENER_USES_PTHREAD
|
|
|
|
# error "The option OWLPS_LISTENER_KEEPS_MONITOR requires the option OWLPS_LISTENER_USES_PTHREAD"
|
|
|
|
# endif // OWLPS_LISTENER_USES_PTHREAD
|
|
|
|
#endif // OWLPS_LISTENER_KEEPS_MONITOR
|
2008-02-14 08:54:51 +01:00
|
|
|
|
2011-03-17 14:06:44 +01:00
|
|
|
#include <owlps.h>
|
|
|
|
#include <owlps-client.h>
|
2010-08-03 11:19:59 +02:00
|
|
|
|
2008-02-14 08:54:51 +01:00
|
|
|
#include <pcap.h>
|
2009-07-02 09:42:15 +02:00
|
|
|
|
2011-06-24 16:53:46 +02:00
|
|
|
#include <sys/param.h>
|
|
|
|
|
|
|
|
#ifdef __GLIBC__
|
|
|
|
# include <endian.h>
|
2010-11-19 19:23:10 +01:00
|
|
|
/* <endian.h> defines le*toh only in glibc >= 2.9. If we use an older
|
2011-06-24 16:53:46 +02:00
|
|
|
* version of glibc, or another glibc-friendly libc (e.g. uClibc), we
|
|
|
|
* must define them manually.
|
2010-03-16 17:12:19 +01:00
|
|
|
*/
|
2011-06-24 16:53:46 +02:00
|
|
|
# if __BYTE_ORDER == __LITTLE_ENDIAN
|
|
|
|
# ifndef le32toh
|
|
|
|
# define le32toh(x) (x)
|
|
|
|
# endif // le32toh
|
|
|
|
# ifndef le16toh
|
|
|
|
# define le16toh(x) (x)
|
|
|
|
# endif // le16toh
|
|
|
|
# elif __BYTE_ORDER == __BIG_ENDIAN
|
2011-04-07 14:29:53 +02:00
|
|
|
# ifndef le32toh
|
|
|
|
# include <byteswap.h>
|
|
|
|
# define le32toh(x) bswap_32(x)
|
|
|
|
# endif // le32toh
|
|
|
|
# ifndef le16toh
|
|
|
|
# include <byteswap.h>
|
|
|
|
# define le16toh(x) bswap_16(x)
|
|
|
|
# endif // le16toh
|
2011-06-24 16:53:46 +02:00
|
|
|
# else // __BYTE_ORDER
|
|
|
|
# error "This program does not handle strange architectures."
|
|
|
|
# endif // __BYTE_ORDER
|
|
|
|
#else // __GLIBC__
|
|
|
|
# include <sys/endian.h>
|
2011-06-27 10:03:15 +02:00
|
|
|
# ifdef OpenBSD
|
|
|
|
# define le32toh letoh32
|
|
|
|
# define le16toh letoh16
|
|
|
|
# endif // OpenBSD
|
2011-06-24 16:53:46 +02:00
|
|
|
#endif // __GLIBC__
|
2010-11-19 19:23:10 +01:00
|
|
|
|
2008-02-14 08:54:51 +01:00
|
|
|
|
2010-07-13 14:39:03 +02:00
|
|
|
/* Arguments & program configuration */
|
2013-04-23 23:18:41 +02:00
|
|
|
#define OPTIONS "ADf:hH:i:I:Kl:m:n:O:p:P:qr:R:t:T:vVw:" // getopt string
|
2009-04-15 14:15:49 +02:00
|
|
|
#define DEFAULT_CONFIG_FILE "/usr/local/etc/owlps/owlps-listener.conf"
|
2009-08-04 12:02:52 +02:00
|
|
|
enum {MODE_ACTIVE = 'a', MODE_PASSIVE = 'p', MODE_MIXED = 'm'} ;
|
2012-02-06 11:32:12 +01:00
|
|
|
#define DEFAULT_AUTOCALIBRATION_HELLO_DELAY 15 // seconds
|
2011-07-24 20:08:05 +02:00
|
|
|
#define DEFAULT_AUTOCALIBRATION_DELAY 25 // milliseconds
|
2010-10-14 18:30:41 +02:00
|
|
|
#define DEFAULT_AUTOCALIBRATION_NBPKT 20
|
2009-07-02 09:42:15 +02:00
|
|
|
|
2009-09-03 11:09:48 +02:00
|
|
|
|
2011-07-24 18:32:06 +02:00
|
|
|
/* Verbosity levels */
|
|
|
|
#define VERBOSE_QUIET GET_VERBOSE() == 0
|
|
|
|
#define VERBOSE_WARNING GET_VERBOSE() >= 1
|
|
|
|
#define VERBOSE_INFO GET_VERBOSE() >= 2
|
|
|
|
#define VERBOSE_CHATTERBOX GET_VERBOSE() >= 3
|
2011-12-13 17:59:14 +01:00
|
|
|
#define VERBOSE_DISPLAY_CAPTURED GET_VERBOSE() >= 4
|
2011-07-24 18:32:06 +02:00
|
|
|
|
|
|
|
|
2011-08-03 23:13:16 +02:00
|
|
|
/* Packet header sizes (in bytes) */
|
|
|
|
#define IEEE80211_HEADER_SIZE_DATA 24 // Header size for a Data frame
|
|
|
|
#define LLC_HEADER_SIZE 8
|
|
|
|
|
|
|
|
/* IEEE 802.11 frame types */
|
|
|
|
// Beacon (TODO: convert to mask)
|
|
|
|
#define RAW_PACKET_TYPE_BEACON 0x80
|
|
|
|
|
|
|
|
// Data frame
|
|
|
|
#define FRAME_TYPE_DATA_MASK 0x08
|
|
|
|
#define IS_DATA_FRAME(FC1) \
|
|
|
|
(((FC1) & FRAME_TYPE_DATA_MASK) == FRAME_TYPE_DATA_MASK)
|
|
|
|
|
|
|
|
// QoS Data frame
|
|
|
|
#define FRAME_SUBTYPE_QOS_MASK 0x80
|
|
|
|
#define DATA_FRAME_IS_QOS(FC1) \
|
|
|
|
(((FC1) & FRAME_SUBTYPE_QOS_MASK) == FRAME_SUBTYPE_QOS_MASK)
|
|
|
|
|
|
|
|
// To/From DS
|
|
|
|
#define FRAME_FROM_STA_MASK 0x02
|
|
|
|
#define IS_FRAME_FROM_STA(FC2) \
|
|
|
|
(((FC2) & FRAME_FROM_STA_MASK) != FRAME_FROM_STA_MASK)
|
|
|
|
|
2011-08-20 18:56:55 +02:00
|
|
|
/*
|
|
|
|
* Test if a IEEE 802.11 frame is a retry.
|
|
|
|
* Input: IEEE 802.11 header flags.
|
|
|
|
* Returns 0 if the Retry bit is absent, a positive value if present.
|
|
|
|
*/
|
|
|
|
#define IS_RETRY(IEEE80211_FLAGS) ((IEEE80211_FLAGS) & 0x08)
|
|
|
|
|
2011-08-03 23:13:16 +02:00
|
|
|
|
|
|
|
/* Positions of the radiotap header fixed fields (in bytes) */
|
|
|
|
#define RTAP_P_HREVISION 0 // Header revision
|
|
|
|
#define RTAP_P_HPAD 1 // Header pad
|
|
|
|
#define RTAP_P_HLENGTH 2 // Header length
|
|
|
|
#define RTAP_P_PRESENTFLAGS 4 // Present flags
|
|
|
|
|
2013-05-16 17:37:18 +02:00
|
|
|
/* Lengths of the radiotap fixed fields (in bytes) */
|
2011-08-03 23:13:16 +02:00
|
|
|
#define RTAP_L_HREVISION 1 // Header revision
|
|
|
|
#define RTAP_L_HPAD 1 // Header pad
|
|
|
|
#define RTAP_L_HLENGTH 2 // Header length
|
|
|
|
#define RTAP_L_PRESENTFLAGS 4 // Present flags
|
2013-05-16 17:37:18 +02:00
|
|
|
|
|
|
|
/* Bits of the radiotap "Present flags" field */
|
|
|
|
#define RTAP_TSFT 0
|
|
|
|
#define RTAP_FLAGS 1
|
|
|
|
#define RTAP_RATE 2
|
|
|
|
#define RTAP_CHANNEL 3 // Channel frequency and flags
|
|
|
|
#define RTAP_FHSS 4 // FHSS hop set and hop pattern
|
|
|
|
#define RTAP_ANTENNASIGNAL 5
|
|
|
|
// ... (we use only the antenna signal field, so we don't need to handle
|
|
|
|
// the bits greater than RTAP_ANTENNASIGNAL)
|
|
|
|
|
|
|
|
/* Lengths of the radiotap optional fields (in bytes) */
|
2013-05-16 17:09:45 +02:00
|
|
|
#define RTAP_L_TSFT 8 // MAC timestamp (Time Synchronization Function Timer)
|
2013-04-24 00:30:53 +02:00
|
|
|
#define RTAP_L_FLAGS 1 // Flags
|
2011-08-03 23:13:16 +02:00
|
|
|
#define RTAP_L_RATE 1 // Data rate
|
|
|
|
#define RTAP_L_CHANNEL 2 // Channel frequency
|
2013-05-16 17:09:45 +02:00
|
|
|
#define RTAP_L_CHANNELFLAGS 2 // Channel flags (channel type)
|
|
|
|
#define RTAP_L_FHSSHOPSET 1 // FHSS hop set
|
|
|
|
#define RTAP_L_FHSSHOPPATTERN 1 // FHSS hop pattern
|
|
|
|
#define RTAP_L_ANTENNASIGNAL 1 // Signal power at the antenna (dBm)
|
2011-08-03 23:13:16 +02:00
|
|
|
|
2013-05-16 19:52:57 +02:00
|
|
|
/*
|
|
|
|
* Tests if a bit (field) is present in the present flags field.
|
|
|
|
*/
|
|
|
|
#define FIELD_PRESENT(PRESENT_FLAGS, BIT) \
|
|
|
|
(((PRESENT_FLAGS) >> (BIT)) & 1)
|
|
|
|
|
2013-04-24 00:50:41 +02:00
|
|
|
/*
|
|
|
|
* Returns the number of bytes needed to jump after a (radiotap) field of
|
|
|
|
* length 'FIELD_LEN' that should sit at the position 'OFFSET' in the
|
|
|
|
* buffer, taking into account alignment considerations.
|
|
|
|
*/
|
|
|
|
#define SKIP_FIELD(OFFSET, FIELD_LEN) \
|
|
|
|
((FIELD_LEN) + nat_align((OFFSET), (FIELD_LEN)))
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-07-13 14:39:03 +02:00
|
|
|
/* Function headers */
|
2011-08-23 21:48:59 +02:00
|
|
|
int initialise_configuration(int argc, char **argv) ;
|
|
|
|
int parse_config_file(int argc, char **argv) ;
|
|
|
|
int parse_command_line(int argc, char **argv) ;
|
|
|
|
int parse_main_options(int argc, char **argv) ;
|
2013-05-18 20:28:41 +02:00
|
|
|
#ifdef OWLPS_LISTENER_USES_PTHREAD
|
2011-08-23 21:48:59 +02:00
|
|
|
int parse_calibration_data(int argc, char **argv) ;
|
2013-05-18 20:28:41 +02:00
|
|
|
#endif // OWLPS_LISTENER_USES_PTHREAD
|
2011-08-23 21:48:59 +02:00
|
|
|
int check_configuration(void) ;
|
2010-07-13 15:09:07 +02:00
|
|
|
void print_configuration(void) ;
|
|
|
|
|
2013-05-18 20:28:41 +02:00
|
|
|
#ifdef OWLPS_LISTENER_KEEPS_MONITOR
|
2011-03-24 08:30:54 +01:00
|
|
|
void* keep_mode_monitor(void *iface) ;
|
2011-06-23 13:30:57 +02:00
|
|
|
int iface_mode_monitor(const char *const iface) ;
|
2013-05-18 20:28:41 +02:00
|
|
|
#endif // OWLPS_LISTENER_KEEPS_MONITOR
|
2009-08-04 12:02:52 +02:00
|
|
|
int capture(void) ;
|
2013-04-23 17:25:43 +02:00
|
|
|
void read_packet(const struct pcap_pkthdr *pkt_header,
|
|
|
|
const u_char *pkt_data) ;
|
|
|
|
void extract_calibration_data(const u_char *pkt_data,
|
2011-08-03 23:52:25 +02:00
|
|
|
owl_captured_request *request) ;
|
2013-04-23 17:25:43 +02:00
|
|
|
void extract_packet_numbers(const u_char *pkt_data,
|
2011-10-24 15:22:23 +02:00
|
|
|
owl_captured_request *request) ;
|
2013-05-16 19:52:57 +02:00
|
|
|
bool extract_radiotap_ss(const u_char *pkt_data,
|
|
|
|
owl_captured_request *request) ;
|
2013-04-24 00:50:41 +02:00
|
|
|
uint_fast16_t nat_align(uint_fast16_t offset, uint_fast8_t field_len) ;
|
2013-05-16 20:11:06 +02:00
|
|
|
void display_captured_request(owl_captured_request *request,
|
|
|
|
const struct pcap_pkthdr *pkt_header) ;
|
2011-03-24 23:42:42 +01:00
|
|
|
void get_mac_addr(char *eth, uint8_t mac_bytes[ETHER_ADDR_LEN]) ;
|
2010-10-13 17:42:00 +02:00
|
|
|
void get_ip_addr(char *eth, char *ip_bytes) ;
|
2010-10-08 16:57:40 +02:00
|
|
|
|
2013-05-18 20:28:41 +02:00
|
|
|
#ifdef OWLPS_LISTENER_USES_PTHREAD
|
2011-03-24 08:30:54 +01:00
|
|
|
void* autocalibrate(void *NULL_value) ;
|
|
|
|
void* autocalibrate_hello(void *NULL_value) ;
|
2010-10-12 10:13:59 +02:00
|
|
|
void send_autocalibration_request(void) ;
|
2011-03-10 19:18:43 +01:00
|
|
|
uint_fast16_t make_packet(uint8_t **packet) ;
|
2013-05-18 20:28:41 +02:00
|
|
|
#endif // OWLPS_LISTENER_USES_PTHREAD
|
2010-10-08 16:57:40 +02:00
|
|
|
|
2011-03-24 14:57:33 +01:00
|
|
|
void sigint_handler(int num) ;
|
|
|
|
void sigterm_handler(int num) ;
|
|
|
|
|
2010-07-13 15:09:07 +02:00
|
|
|
void print_usage(void) ;
|
2010-10-20 17:55:26 +02:00
|
|
|
void print_version(void) ;
|
2008-02-22 16:04:49 +01:00
|
|
|
|
|
|
|
|
2010-07-13 14:39:03 +02:00
|
|
|
/* Macros to allow switching option handling with the libconfuse
|
|
|
|
* structure and a home-made structure (if program is not compiled
|
|
|
|
* with libconfuse support).
|
2009-07-02 09:42:15 +02:00
|
|
|
*/
|
2010-07-13 14:39:03 +02:00
|
|
|
/* libconfuse macros */
|
2013-05-18 20:28:41 +02:00
|
|
|
#ifdef OWLPS_LISTENER_USES_CONFIG_FILE
|
2011-02-04 17:01:28 +01:00
|
|
|
#define SET_MODE(MODE) \
|
|
|
|
(cfg_setint(cfg, "mode", (MODE)))
|
|
|
|
#define GET_MODE() \
|
|
|
|
(cfg_getint(cfg, "mode"))
|
2012-01-07 16:02:05 +01:00
|
|
|
#define SET_DAEMON() \
|
|
|
|
(cfg_setbool(cfg, "daemon", cfg_true))
|
2013-04-23 23:18:41 +02:00
|
|
|
#define UNSET_DAEMON() \
|
|
|
|
(cfg_setbool(cfg, "daemon", cfg_false))
|
2012-01-07 16:02:05 +01:00
|
|
|
#define GET_DAEMON() \
|
|
|
|
(cfg_getbool(cfg, "daemon"))
|
2011-02-04 17:01:28 +01:00
|
|
|
#define SET_AGGREGATION_IP(IP) \
|
|
|
|
(cfg_setstr(cfg, "aggregation_ip", (IP)))
|
|
|
|
#define GET_AGGREGATION_IP() \
|
|
|
|
(cfg_getstr(cfg, "aggregation_ip"))
|
2013-05-18 20:28:41 +02:00
|
|
|
#ifdef OWLPS_LISTENER_KEEPS_MONITOR
|
2011-02-04 17:01:28 +01:00
|
|
|
#define SET_KEEP_MONITOR() \
|
|
|
|
(cfg_setbool(cfg, "keep_monitor", cfg_true))
|
2013-04-23 23:18:41 +02:00
|
|
|
#define UNSET_KEEP_MONITOR() \
|
|
|
|
(cfg_setbool(cfg, "keep_monitor", cfg_false))
|
2011-02-04 17:01:28 +01:00
|
|
|
#define GET_KEEP_MONITOR() \
|
|
|
|
(cfg_getbool(cfg, "keep_monitor"))
|
2013-05-18 20:28:41 +02:00
|
|
|
#endif // OWLPS_LISTENER_KEEPS_MONITOR
|
2011-02-04 17:01:28 +01:00
|
|
|
#define SET_AGGREGATION_PORT(PORT) \
|
|
|
|
(cfg_setint(cfg, "aggregation_port", (PORT)))
|
|
|
|
#define GET_AGGREGATION_PORT() \
|
|
|
|
(cfg_getint(cfg, "aggregation_port"))
|
|
|
|
#define SET_LISTENING_PORT(PORT) \
|
|
|
|
(cfg_setint(cfg, "listening_port", (PORT)))
|
|
|
|
#define GET_LISTENING_PORT() \
|
|
|
|
(cfg_getint(cfg, "listening_port"))
|
|
|
|
#define SET_RTAP_IFACE(IFACE) \
|
|
|
|
(cfg_setstr(cfg, "rtap_iface", (IFACE)))
|
|
|
|
#define GET_RTAP_IFACE() \
|
|
|
|
(cfg_getstr(cfg, "rtap_iface"))
|
2013-04-23 23:18:41 +02:00
|
|
|
#define SET_PCAP_FILE(PATH) \
|
|
|
|
(cfg_setstr(cfg, "pcap_file", (PATH)))
|
|
|
|
#define GET_PCAP_FILE() \
|
|
|
|
(cfg_getstr(cfg, "pcap_file"))
|
2011-02-04 17:01:28 +01:00
|
|
|
#define SET_WIFI_IFACE(IFACE) \
|
|
|
|
(cfg_setstr(cfg, "wifi_iface", (IFACE)))
|
|
|
|
#define GET_WIFI_IFACE() \
|
|
|
|
(cfg_getstr(cfg, "wifi_iface"))
|
2010-10-08 16:57:40 +02:00
|
|
|
|
2013-05-18 20:28:41 +02:00
|
|
|
#ifdef OWLPS_LISTENER_USES_PTHREAD
|
2011-02-04 17:01:28 +01:00
|
|
|
#define SET_AUTOCALIBRATION() \
|
|
|
|
(cfg_setbool(cfg, "autocalibration", cfg_true))
|
2013-04-23 23:18:41 +02:00
|
|
|
#define UNSET_AUTOCALIBRATION() \
|
|
|
|
(cfg_setbool(cfg, "autocalibration", cfg_false))
|
2011-02-04 17:01:28 +01:00
|
|
|
#define GET_AUTOCALIBRATION() \
|
|
|
|
(cfg_getbool(cfg, "autocalibration"))
|
2011-02-23 18:03:00 +01:00
|
|
|
#define SET_AUTOCALIBRATION_IP(IP) \
|
|
|
|
(cfg_setstr(cfg, "autocalibration_ip", (IP)))
|
|
|
|
#define GET_AUTOCALIBRATION_IP() \
|
|
|
|
(cfg_getstr(cfg, "autocalibration_ip"))
|
2011-02-04 17:54:17 +01:00
|
|
|
#define SET_AUTOCALIBRATION_REQUEST_PORT(PORT) \
|
|
|
|
(cfg_setint(cfg, "autocalibration_request_port", (PORT)))
|
|
|
|
#define GET_AUTOCALIBRATION_REQUEST_PORT() \
|
|
|
|
(cfg_getint(cfg, "autocalibration_request_port"))
|
2012-01-26 11:28:14 +01:00
|
|
|
#define SET_AUTOCALIBRATION_ORDER_PORT(PORT) \
|
|
|
|
(cfg_setint(cfg, "autocalibration_order_port", (PORT)))
|
|
|
|
#define GET_AUTOCALIBRATION_ORDER_PORT() \
|
|
|
|
(cfg_getint(cfg, "autocalibration_order_port"))
|
|
|
|
#define SET_AUTOCALIBRATION_HELLO_PORT(PORT) \
|
|
|
|
(cfg_setint(cfg, "autocalibration_hello_port", (PORT)))
|
|
|
|
#define GET_AUTOCALIBRATION_HELLO_PORT() \
|
|
|
|
(cfg_getint(cfg, "autocalibration_hello_port"))
|
2011-02-04 17:01:28 +01:00
|
|
|
#define SET_AUTOCALIBRATION_HELLO_DELAY(DELAY) \
|
|
|
|
(cfg_setint(cfg, "autocalibration_hello_delay", (DELAY)))
|
|
|
|
#define GET_AUTOCALIBRATION_HELLO_DELAY() \
|
|
|
|
(cfg_getint(cfg, "autocalibration_hello_delay"))
|
|
|
|
#define SET_AUTOCALIBRATION_DELAY(DELAY) \
|
|
|
|
(cfg_setint(cfg, "autocalibration_delay", (DELAY)))
|
|
|
|
#define GET_AUTOCALIBRATION_DELAY() \
|
|
|
|
(cfg_getint(cfg, "autocalibration_delay"))
|
|
|
|
#define SET_AUTOCALIBRATION_NBPKT(NBPKT) \
|
|
|
|
(cfg_setint(cfg, "autocalibration_nb_packets", (NBPKT)))
|
|
|
|
#define GET_AUTOCALIBRATION_NBPKT() \
|
|
|
|
(cfg_getint(cfg, "autocalibration_nb_packets"))
|
2011-04-06 18:11:14 +02:00
|
|
|
#define SET_MY_DIRECTION(DIRECTION) \
|
|
|
|
(cfg_setint(cfg, "my_direction", (DIRECTION)))
|
|
|
|
#define GET_MY_DIRECTION() \
|
|
|
|
(cfg_getint(cfg, "my_direction"))
|
|
|
|
#define SET_MY_POSITION_X(POSITION) \
|
|
|
|
(cfg_setfloat(cfg, "my_position_x", (POSITION)))
|
|
|
|
#define GET_MY_POSITION_X() \
|
|
|
|
(cfg_getfloat(cfg, "my_position_x"))
|
|
|
|
#define SET_MY_POSITION_Y(POSITION) \
|
|
|
|
(cfg_setfloat(cfg, "my_position_y", (POSITION)))
|
|
|
|
#define GET_MY_POSITION_Y() \
|
|
|
|
(cfg_getfloat(cfg, "my_position_y"))
|
|
|
|
#define SET_MY_POSITION_Z(POSITION) \
|
|
|
|
(cfg_setfloat(cfg, "my_position_z", (POSITION)))
|
|
|
|
#define GET_MY_POSITION_Z() \
|
|
|
|
(cfg_getfloat(cfg, "my_position_z"))
|
2013-05-18 20:28:41 +02:00
|
|
|
#endif // OWLPS_LISTENER_USES_PTHREAD
|
2010-10-08 16:57:40 +02:00
|
|
|
|
2011-07-24 17:58:40 +02:00
|
|
|
#define INCREMENT_VERBOSE() \
|
|
|
|
(cfg_setint(cfg, "verbose", cfg_getint(cfg, "verbose") + 1))
|
|
|
|
#define RESET_VERBOSE() \
|
|
|
|
(cfg_setint(cfg, "verbose", 0))
|
2011-02-04 17:01:28 +01:00
|
|
|
#define GET_VERBOSE() \
|
2011-07-24 17:58:40 +02:00
|
|
|
(cfg_getint(cfg, "verbose"))
|
2009-07-02 09:42:15 +02:00
|
|
|
|
2010-07-13 14:39:03 +02:00
|
|
|
/* Home-made structure macros */
|
2013-05-18 20:28:41 +02:00
|
|
|
#else // OWLPS_LISTENER_USES_CONFIG_FILE
|
2012-01-07 16:02:05 +01:00
|
|
|
#define SET_DAEMON() \
|
2013-05-15 21:46:13 +02:00
|
|
|
(options.daemon = true)
|
2013-04-23 23:18:41 +02:00
|
|
|
#define UNSET_DAEMON() \
|
2013-05-15 21:46:13 +02:00
|
|
|
(options.daemon = false)
|
2012-01-07 16:02:05 +01:00
|
|
|
#define GET_DAEMON() \
|
|
|
|
(options.daemon)
|
2011-02-04 17:01:28 +01:00
|
|
|
#define SET_MODE(MODE) \
|
|
|
|
(options.mode = (MODE))
|
|
|
|
#define GET_MODE() \
|
|
|
|
(options.mode)
|
|
|
|
#define SET_AGGREGATION_IP(IP) \
|
2011-03-24 08:40:35 +01:00
|
|
|
(strncpy(options.aggregation_ip, (IP), INET_ADDRSTRLEN))
|
2011-02-04 17:01:28 +01:00
|
|
|
#define GET_AGGREGATION_IP() \
|
|
|
|
(options.aggregation_ip)
|
2013-05-18 20:28:41 +02:00
|
|
|
#ifdef OWLPS_LISTENER_KEEPS_MONITOR
|
2011-02-04 17:01:28 +01:00
|
|
|
#define SET_KEEP_MONITOR() \
|
2013-05-15 21:46:13 +02:00
|
|
|
(options.keep_monitor = true)
|
2013-04-23 23:18:41 +02:00
|
|
|
#define UNSET_KEEP_MONITOR() \
|
2013-05-15 21:46:13 +02:00
|
|
|
(options.keep_monitor = false)
|
2011-02-04 17:01:28 +01:00
|
|
|
#define GET_KEEP_MONITOR() \
|
|
|
|
(options.keep_monitor)
|
2013-05-18 20:28:41 +02:00
|
|
|
#endif // OWLPS_LISTENER_KEEPS_MONITOR
|
2011-02-04 17:01:28 +01:00
|
|
|
#define SET_AGGREGATION_PORT(PORT) \
|
|
|
|
(options.aggregation_port = (PORT))
|
|
|
|
#define GET_AGGREGATION_PORT() \
|
|
|
|
(options.aggregation_port)
|
|
|
|
#define SET_LISTENING_PORT(PORT) \
|
|
|
|
(options.listening_port = (PORT))
|
|
|
|
#define GET_LISTENING_PORT() \
|
|
|
|
(options.listening_port)
|
|
|
|
#define SET_RTAP_IFACE(IFACE) \
|
|
|
|
(strncpy(options.rtap_iface, (IFACE), IFNAMSIZ+1))
|
|
|
|
#define GET_RTAP_IFACE() \
|
|
|
|
(options.rtap_iface)
|
2013-04-23 23:18:41 +02:00
|
|
|
#define SET_PCAP_FILE(PATH) \
|
|
|
|
do { \
|
|
|
|
char *path = (PATH) ; \
|
|
|
|
size_t path_len = strlen(path) ; \
|
|
|
|
free(options.pcap_file) ; \
|
|
|
|
options.pcap_file = malloc(path_len + 1) ; \
|
|
|
|
assert(options.pcap_file) ; \
|
|
|
|
strncpy(options.pcap_file, path, path_len) ; \
|
|
|
|
} while (0)
|
|
|
|
#define GET_PCAP_FILE() \
|
|
|
|
(options.pcap_file)
|
2011-02-04 17:01:28 +01:00
|
|
|
#define SET_WIFI_IFACE(IFACE) \
|
|
|
|
(strncpy(options.wifi_iface, (IFACE), IFNAMSIZ+1))
|
|
|
|
#define GET_WIFI_IFACE() \
|
|
|
|
(options.wifi_iface)
|
2010-10-08 16:57:40 +02:00
|
|
|
|
2013-05-18 20:28:41 +02:00
|
|
|
#ifdef OWLPS_LISTENER_USES_PTHREAD
|
2011-02-04 17:01:28 +01:00
|
|
|
#define SET_AUTOCALIBRATION() \
|
2013-05-15 21:46:13 +02:00
|
|
|
(options.autocalibration = true)
|
2013-04-23 23:18:41 +02:00
|
|
|
#define UNSET_AUTOCALIBRATION() \
|
2013-05-15 21:46:13 +02:00
|
|
|
(options.autocalibration = false)
|
2011-02-04 17:01:28 +01:00
|
|
|
#define GET_AUTOCALIBRATION() \
|
|
|
|
(options.autocalibration)
|
2011-02-23 18:03:00 +01:00
|
|
|
#define SET_AUTOCALIBRATION_IP(IP) \
|
2011-03-24 08:40:35 +01:00
|
|
|
(strncpy(options.autocalibration_ip, (IP), INET_ADDRSTRLEN))
|
2011-02-23 18:03:00 +01:00
|
|
|
#define GET_AUTOCALIBRATION_IP() \
|
|
|
|
(options.autocalibration_ip)
|
2011-02-04 17:54:17 +01:00
|
|
|
#define SET_AUTOCALIBRATION_REQUEST_PORT(PORT) \
|
|
|
|
(options.autocalibration_request_port = (PORT))
|
|
|
|
#define GET_AUTOCALIBRATION_REQUEST_PORT() \
|
|
|
|
(options.autocalibration_request_port)
|
2012-01-26 11:28:14 +01:00
|
|
|
#define SET_AUTOCALIBRATION_ORDER_PORT(PORT) \
|
|
|
|
(options.autocalibration_order_port = (PORT))
|
|
|
|
#define GET_AUTOCALIBRATION_ORDER_PORT() \
|
|
|
|
(options.autocalibration_order_port)
|
|
|
|
#define SET_AUTOCALIBRATION_HELLO_PORT(PORT) \
|
|
|
|
(options.autocalibration_hello_port = (PORT))
|
|
|
|
#define GET_AUTOCALIBRATION_HELLO_PORT() \
|
|
|
|
(options.autocalibration_hello_port)
|
2011-02-04 17:01:28 +01:00
|
|
|
#define SET_AUTOCALIBRATION_HELLO_DELAY(DELAY) \
|
|
|
|
(options.autocalibration_hello_delay = (DELAY))
|
|
|
|
#define GET_AUTOCALIBRATION_HELLO_DELAY() \
|
|
|
|
(options.autocalibration_hello_delay)
|
|
|
|
#define SET_AUTOCALIBRATION_DELAY(DELAY) \
|
|
|
|
(options.autocalibration_delay = (DELAY))
|
|
|
|
#define GET_AUTOCALIBRATION_DELAY() \
|
|
|
|
(options.autocalibration_delay)
|
|
|
|
#define SET_AUTOCALIBRATION_NBPKT(NBPKT) \
|
|
|
|
(options.autocalibration_nb_packets = (NBPKT))
|
|
|
|
#define GET_AUTOCALIBRATION_NBPKT() \
|
|
|
|
(options.autocalibration_nb_packets)
|
2011-04-06 18:11:14 +02:00
|
|
|
#define SET_MY_DIRECTION(DIRECTION) \
|
|
|
|
(options.my_direction = (DIRECTION))
|
|
|
|
#define GET_MY_DIRECTION() \
|
|
|
|
(options.my_direction)
|
|
|
|
#define SET_MY_POSITION_X(POSITION) \
|
|
|
|
(options.my_position_x = (POSITION))
|
|
|
|
#define GET_MY_POSITION_X() \
|
|
|
|
(options.my_position_x)
|
|
|
|
#define SET_MY_POSITION_Y(POSITION) \
|
|
|
|
(options.my_position_y = (POSITION))
|
|
|
|
#define GET_MY_POSITION_Y() \
|
|
|
|
(options.my_position_y)
|
|
|
|
#define SET_MY_POSITION_Z(POSITION) \
|
|
|
|
(options.my_position_z = (POSITION))
|
|
|
|
#define GET_MY_POSITION_Z() \
|
|
|
|
(options.my_position_z)
|
2013-05-18 20:28:41 +02:00
|
|
|
#endif // OWLPS_LISTENER_USES_PTHREAD
|
2010-10-08 16:57:40 +02:00
|
|
|
|
2011-07-24 17:58:40 +02:00
|
|
|
#define INCREMENT_VERBOSE() \
|
|
|
|
(++options.verbose)
|
|
|
|
#define RESET_VERBOSE() \
|
|
|
|
(options.verbose = 0)
|
2011-02-04 17:01:28 +01:00
|
|
|
#define GET_VERBOSE() \
|
|
|
|
(options.verbose)
|
2013-05-18 20:28:41 +02:00
|
|
|
#endif // OWLPS_LISTENER_USES_CONFIG_FILE
|
2009-07-02 09:42:15 +02:00
|
|
|
|
|
|
|
|
2013-04-23 23:18:41 +02:00
|
|
|
/* Returns true if we are capturing packet from a network interface, or
|
|
|
|
* false if we are reading from a pcap file.
|
|
|
|
*/
|
|
|
|
#define LIVE_CAPTURING \
|
2013-04-29 16:51:04 +02:00
|
|
|
(GET_RTAP_IFACE()[0] != '\0')
|
2013-04-23 23:18:41 +02:00
|
|
|
|
|
|
|
|
2010-07-13 14:39:03 +02:00
|
|
|
#endif // _OWLPS_LISTENER_H_
|