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 Aggregator.
|
2008-02-14 08:54:51 +01:00
|
|
|
*/
|
|
|
|
|
2012-02-06 16:44:09 +01:00
|
|
|
|
2010-07-12 16:34:25 +02:00
|
|
|
#ifndef _OWLPS_AGGREGATOR_H_
|
|
|
|
#define _OWLPS_AGGREGATOR_H_
|
2008-02-22 16:04:49 +01:00
|
|
|
|
2013-06-04 17:57:59 +02:00
|
|
|
#include <owlps-config.h>
|
|
|
|
|
2011-03-17 14:06:44 +01:00
|
|
|
#include <owlps.h>
|
|
|
|
|
2008-07-17 10:21:41 +02:00
|
|
|
|
2010-07-12 16:34:25 +02:00
|
|
|
/* Arguments & program configuration */
|
2012-01-26 11:28:14 +01:00
|
|
|
#define OPTIONS "Ac:C:Df:hH:i:k:K:l:o:O:p:qt:vV" // getopt string
|
2013-06-04 17:57:59 +02:00
|
|
|
#define DEFAULT_CONFIG_FILE OWL_CONFIG_PREFIX "/owlps-aggregator.conf"
|
2012-02-06 11:32:12 +01:00
|
|
|
#define DEFAULT_AGGREGATE_TIMEOUT 600 // milliseconds
|
2010-07-12 16:34:25 +02:00
|
|
|
#define DEFAULT_KEEP_TIMEOUT 3000 // milliseconds
|
2012-02-06 11:32:12 +01:00
|
|
|
#define DEFAULT_CHECK_INTERVAL 300 // milliseconds
|
|
|
|
#define DEFAULT_AP_KEEP_TIMEOUT 35 // seconds
|
2011-07-24 20:20:32 +02:00
|
|
|
#define DEFAULT_AP_CHECK_INTERVAL 1000 // milliseconds
|
2009-07-02 13:12:51 +02:00
|
|
|
#define POSITIONER_DEFAULT_IP "127.0.0.1"
|
2008-02-22 16:04:49 +01:00
|
|
|
|
2008-02-14 08:54:51 +01:00
|
|
|
|
2011-07-23 22:51:02 +02:00
|
|
|
/* Verbosity levels */
|
|
|
|
#define VERBOSE_QUIET cfg_getint(cfg, "verbose") == 0
|
|
|
|
#define VERBOSE_WARNING cfg_getint(cfg, "verbose") >= 1
|
|
|
|
#define VERBOSE_INFO cfg_getint(cfg, "verbose") >= 2
|
|
|
|
#define VERBOSE_CHATTERBOX cfg_getint(cfg, "verbose") >= 3
|
|
|
|
#define VERBOSE_REQUESTS cfg_getint(cfg, "verbose") >= 4
|
|
|
|
|
|
|
|
|
2011-03-18 16:31:06 +01:00
|
|
|
/* Linked list storing data of each request */
|
|
|
|
typedef struct _request_info_list
|
2008-02-14 08:54:51 +01:00
|
|
|
{
|
2011-10-25 19:28:49 +02:00
|
|
|
// Number of the current packet:
|
|
|
|
uint16_t packet_id ;
|
2011-12-30 17:02:53 +01:00
|
|
|
// MAC address of the transmitter AP (in bytes):
|
2011-03-24 23:42:42 +01:00
|
|
|
uint8_t ap_mac_addr_bytes[ETHER_ADDR_LEN] ;
|
2012-01-26 12:55:03 +01:00
|
|
|
// Timestamp of arrival on the listener:
|
|
|
|
owl_timestamp capture_time ;
|
2010-07-12 16:34:25 +02:00
|
|
|
// Signal strength received by the AP from the mobile:
|
2013-04-24 16:21:54 +02:00
|
|
|
int8_t ss_dbm ;
|
2011-03-18 16:31:06 +01:00
|
|
|
struct _request_info_list *next ;
|
|
|
|
} request_info_list ;
|
2008-02-14 08:54:51 +01:00
|
|
|
|
|
|
|
|
2011-03-18 16:31:06 +01:00
|
|
|
/* Linked list of the requests */
|
|
|
|
typedef struct _request_list
|
2008-02-14 08:54:51 +01:00
|
|
|
{
|
2011-03-25 17:20:18 +01:00
|
|
|
uint8_t type ;
|
|
|
|
|
2011-10-25 19:28:49 +02:00
|
|
|
// Number of packets sent by the mobile for this request:
|
|
|
|
uint16_t nb_packets ;
|
|
|
|
|
2011-03-18 16:31:06 +01:00
|
|
|
/* Request identifier */
|
2012-01-25 16:18:26 +01:00
|
|
|
uint8_t mobile_mac_addr_bytes[ETHER_ADDR_LEN] ; // Mobile MAC address
|
2011-03-18 15:15:39 +01:00
|
|
|
owl_timestamp request_time ; // Request time on the mobile
|
2008-03-14 11:31:04 +01:00
|
|
|
|
2010-07-12 16:34:25 +02:00
|
|
|
/* Calibration data */
|
2008-02-14 08:54:51 +01:00
|
|
|
float x_position ;
|
|
|
|
float y_position ;
|
|
|
|
float z_position ;
|
2011-03-18 15:15:39 +01:00
|
|
|
owl_direction direction ; // Request orientation
|
2010-07-12 16:34:25 +02:00
|
|
|
|
|
|
|
/* Other data */
|
2012-01-25 16:18:26 +01:00
|
|
|
uint8_t mobile_ip_addr_bytes[4] ; // Mobile IP address
|
2011-03-18 16:31:06 +01:00
|
|
|
// Arrival time of the first packet of the request on the aggregator:
|
2011-03-18 15:15:39 +01:00
|
|
|
owl_timestamp start_time ;
|
2011-03-18 16:31:06 +01:00
|
|
|
request_info_list *info ; // Data for this request
|
2008-03-14 11:31:04 +01:00
|
|
|
|
2011-03-18 16:31:06 +01:00
|
|
|
struct _request_list *next ;
|
|
|
|
} request_list ;
|
2008-02-14 08:54:51 +01:00
|
|
|
|
|
|
|
|
2010-08-06 12:29:39 +02:00
|
|
|
/* Linked list of the known APs */
|
|
|
|
typedef struct _ap_list
|
|
|
|
{
|
2011-03-24 23:42:42 +01:00
|
|
|
uint8_t mac_addr_bytes[ETHER_ADDR_LEN] ;
|
2011-03-24 08:40:35 +01:00
|
|
|
char ip_addr[INET_ADDRSTRLEN] ;
|
2010-10-12 15:09:14 +02:00
|
|
|
|
2011-03-18 15:15:39 +01:00
|
|
|
owl_timestamp last_seen ;
|
2010-08-06 12:29:39 +02:00
|
|
|
|
|
|
|
struct _ap_list *previous ;
|
|
|
|
struct _ap_list *next ;
|
|
|
|
} ap_list ;
|
|
|
|
|
|
|
|
|
2010-07-12 16:34:25 +02:00
|
|
|
/* Function headers */
|
2011-08-24 10:47:13 +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 check_configuration(void) ;
|
2010-07-12 12:50:02 +02:00
|
|
|
|
|
|
|
int read_loop(int sockfd) ;
|
2011-03-18 16:31:06 +01:00
|
|
|
void got_request(owl_captured_request request) ;
|
2010-08-06 12:29:39 +02:00
|
|
|
|
2011-03-23 16:36:55 +01:00
|
|
|
void* monitor_requests(void *NULL_value) ;
|
2011-03-18 16:31:06 +01:00
|
|
|
void free_request_list(void) ;
|
2011-07-24 18:58:21 +02:00
|
|
|
#ifndef NDEBUG
|
2011-03-18 16:31:06 +01:00
|
|
|
void print_request_list(void) ;
|
|
|
|
void print_request_info(request_info_list *info) ;
|
2011-07-24 18:58:21 +02:00
|
|
|
#endif // NDEBUG
|
2010-07-12 12:50:02 +02:00
|
|
|
|
2011-03-23 16:36:55 +01:00
|
|
|
void* listen_for_aps(void *NULL_value) ;
|
2011-03-24 23:42:42 +01:00
|
|
|
void update_ap(uint8_t mac_addr_bytes[ETHER_ADDR_LEN],
|
|
|
|
char ip_addr[INET_ADDRSTRLEN]) ;
|
|
|
|
ap_list* find_ap(uint8_t mac_addr_bytes[ETHER_ADDR_LEN]) ;
|
|
|
|
ap_list* add_ap_front(uint8_t mac_addr_bytes[ETHER_ADDR_LEN]) ;
|
2011-03-24 08:40:35 +01:00
|
|
|
void update_ap_ip_addr(ap_list *ap, char ip_addr[INET_ADDRSTRLEN]) ;
|
2010-08-06 12:29:39 +02:00
|
|
|
void update_ap_seen(ap_list *ap) ;
|
|
|
|
void push_ap(ap_list *ap) ;
|
|
|
|
|
2011-03-23 16:36:55 +01:00
|
|
|
void* monitor_aps(void *NULL_value) ;
|
2010-08-06 12:29:39 +02:00
|
|
|
void delete_old_aps(void) ;
|
|
|
|
void delete_ap(ap_list *ap) ;
|
|
|
|
void unlink_ap(ap_list *ap) ;
|
|
|
|
void order_send(ap_list *ap) ;
|
|
|
|
void free_ap_list(void) ;
|
|
|
|
|
2010-07-12 12:50:02 +02:00
|
|
|
void print_usage(void) ;
|
2011-04-12 22:45:18 +02:00
|
|
|
void print_version(void) ;
|
2008-02-22 16:04:49 +01:00
|
|
|
|
2010-07-12 16:34:25 +02:00
|
|
|
#endif // _OWLPS_AGGREGATOR_H_
|