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
|
2016-11-03 05:10:34 +01:00
|
|
|
* https://code.lm7.fr/mcy/owlps/src/master/COPYRIGHT.t2t
|
2013-05-29 18:43:35 +02:00
|
|
|
* 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>
|
|
|
|
|
2013-06-12 22:21:03 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2008-07-17 10:21:41 +02:00
|
|
|
|
2010-07-12 16:34:25 +02:00
|
|
|
/* Arguments & program configuration */
|
2013-06-12 21:11:31 +02:00
|
|
|
#define OPTIONS "Ac:C:Df:FGhH: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
|
2013-06-14 19:55:02 +02:00
|
|
|
#define DEFAULT_CP_KEEP_TIMEOUT 35 // seconds
|
2013-06-14 19:43:58 +02:00
|
|
|
#define DEFAULT_AC_ORDER_INTERVAL 1000 // milliseconds
|
2013-09-23 21:32:19 +02:00
|
|
|
#define POSITIONER_DEFAULT_HOST "localhost"
|
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
|
2013-10-04 16:44:40 +02:00
|
|
|
#define MAX_VERBOSE_LEVEL 4
|
2011-07-23 22:51:02 +02:00
|
|
|
|
|
|
|
|
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 ;
|
2013-06-14 19:55:02 +02:00
|
|
|
// MAC address of the transmitter CP (in bytes):
|
|
|
|
uint8_t cp_mac_addr_bytes[ETHER_ADDR_LEN] ;
|
2012-01-26 12:55:03 +01:00
|
|
|
// Timestamp of arrival on the listener:
|
|
|
|
owl_timestamp capture_time ;
|
2013-06-14 19:55:02 +02:00
|
|
|
// Signal strength received by the CP from the mobile:
|
2013-04-24 16:21:54 +02:00
|
|
|
int8_t ss_dbm ;
|
2016-11-23 23:02:21 +01:00
|
|
|
unsigned char __pad0[7]; // 7 bytes alignment
|
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 ;
|
2016-11-23 23:02:21 +01:00
|
|
|
unsigned char __pad0; // 1 byte alignment
|
2011-03-25 17:20:18 +01:00
|
|
|
|
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
|
2016-11-23 23:02:21 +01:00
|
|
|
unsigned char __pad1[2]; // 2 bytes alignment
|
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
|
2016-11-23 23:02:21 +01:00
|
|
|
unsigned char __pad2[3]; // 3 bytes alignment
|
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
|
|
|
|
|
|
|
|
2013-06-14 19:55:02 +02:00
|
|
|
/* Linked list of the known CPs */
|
|
|
|
typedef struct _cp_list
|
2010-08-06 12:29:39 +02:00
|
|
|
{
|
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
|
|
|
|
2016-11-23 23:02:21 +01:00
|
|
|
unsigned char __pad0[2]; // 2 bytes alignment
|
2011-03-18 15:15:39 +01:00
|
|
|
owl_timestamp last_seen ;
|
2010-08-06 12:29:39 +02:00
|
|
|
|
2013-06-14 19:55:02 +02:00
|
|
|
struct _cp_list *previous ;
|
|
|
|
struct _cp_list *next ;
|
|
|
|
} cp_list ;
|
2010-08-06 12:29:39 +02:00
|
|
|
|
|
|
|
|
2010-07-12 16:34:25 +02:00
|
|
|
/* Function headers */
|
2013-10-02 17:28:48 +02:00
|
|
|
int initialise_configuration(const int argc, char *const *argv) ;
|
|
|
|
int parse_config_file(const int argc, char *const *argv) ;
|
|
|
|
int parse_command_line(const int argc, char *const *argv) ;
|
2011-08-24 10:47:13 +02:00
|
|
|
int check_configuration(void) ;
|
2010-07-12 12:50:02 +02:00
|
|
|
|
2013-10-02 17:28:48 +02:00
|
|
|
int read_loop(const int sockfd) ;
|
2013-06-12 23:59:03 +02:00
|
|
|
void print_captured_request(const owl_captured_request *const request) ;
|
2013-06-13 00:07:17 +02:00
|
|
|
void got_request(const owl_captured_request *const request) ;
|
2013-06-13 00:41:44 +02:00
|
|
|
void add_captured_request(const owl_timestamp *const reception_time,
|
|
|
|
const owl_captured_request *const request,
|
|
|
|
request_info_list *const request_info) ;
|
2010-08-06 12:29:39 +02:00
|
|
|
|
2013-10-02 17:28:48 +02:00
|
|
|
void* monitor_requests(void *const NULL_value) ;
|
2013-06-12 23:52:11 +02:00
|
|
|
void scan_request_list(FILE *const stream,
|
|
|
|
const int sockfd,
|
2013-09-20 23:07:46 +02:00
|
|
|
const struct sockaddr *const serv) ;
|
2013-06-12 23:11:49 +02:00
|
|
|
void flush_request_list(FILE *const stream,
|
|
|
|
const int sockfd,
|
2013-09-20 23:07:46 +02:00
|
|
|
const struct sockaddr *const serv) ;
|
2013-06-12 22:21:03 +02:00
|
|
|
void output_request(request_list *const request_ptr,
|
|
|
|
FILE *const stream,
|
|
|
|
const int sockfd,
|
2013-09-20 23:07:46 +02:00
|
|
|
const struct sockaddr *const serv) ;
|
2013-06-12 22:21:03 +02:00
|
|
|
|
2011-07-24 18:58:21 +02:00
|
|
|
#ifndef NDEBUG
|
2011-03-18 16:31:06 +01:00
|
|
|
void print_request_list(void) ;
|
2013-10-02 17:28:48 +02:00
|
|
|
void print_request_info(const request_info_list *const info) ;
|
2011-07-24 18:58:21 +02:00
|
|
|
#endif // NDEBUG
|
2010-07-12 12:50:02 +02:00
|
|
|
|
2013-10-02 17:28:48 +02:00
|
|
|
void* listen_for_cps(void *const NULL_value) ;
|
|
|
|
void update_cp(const uint8_t mac_addr_bytes[ETHER_ADDR_LEN],
|
|
|
|
const char ip_addr[INET_ADDRSTRLEN]) ;
|
|
|
|
cp_list* find_cp(const uint8_t mac_addr_bytes[ETHER_ADDR_LEN]) ;
|
|
|
|
cp_list* add_cp_front(const uint8_t mac_addr_bytes[ETHER_ADDR_LEN]) ;
|
|
|
|
void update_cp_ip_addr(cp_list *const cp,
|
|
|
|
const char ip_addr[INET_ADDRSTRLEN]) ;
|
|
|
|
void update_cp_seen(cp_list *const cp) ;
|
|
|
|
void push_cp(cp_list *const cp) ;
|
|
|
|
|
|
|
|
void* monitor_cps(void *const NULL_value) ;
|
2013-06-14 19:55:02 +02:00
|
|
|
void delete_old_cps(void) ;
|
2013-10-02 17:28:48 +02:00
|
|
|
void delete_cp(cp_list *const cp) ;
|
|
|
|
void unlink_cp(const cp_list *const cp) ;
|
|
|
|
void order_send(const cp_list *const cp) ;
|
2013-06-14 19:55:02 +02:00
|
|
|
void free_cp_list(void) ;
|
2010-08-06 12:29:39 +02:00
|
|
|
|
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_
|