2008-02-14 08:54:51 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the rtap localisation project.
|
|
|
|
*/
|
|
|
|
|
2010-07-12 16:34:25 +02:00
|
|
|
#ifndef _OWLPS_AGGREGATOR_H_
|
|
|
|
#define _OWLPS_AGGREGATOR_H_
|
2008-02-22 16:04:49 +01:00
|
|
|
|
2011-03-17 14:06:44 +01:00
|
|
|
#include <owlps.h>
|
|
|
|
|
2009-04-15 14:15:49 +02:00
|
|
|
#include <confuse.h>
|
2008-02-14 08:54:51 +01:00
|
|
|
|
2009-09-03 11:09:48 +02:00
|
|
|
#define DEBUG
|
2008-02-14 08:54:51 +01:00
|
|
|
|
2010-07-12 16:34:25 +02:00
|
|
|
// Uncomment to output the timestamp on each line of the output file:
|
2011-03-10 14:28:29 +01:00
|
|
|
//#define USE_TIMESTAMP
|
2008-07-17 10:21:41 +02:00
|
|
|
|
|
|
|
|
2010-07-12 16:34:25 +02:00
|
|
|
/* Arguments & program configuration */
|
2010-10-26 17:15:03 +02:00
|
|
|
#define OPTIONS "Aa:c:C:f:hi:k:K:l:o:p:t:v" // getopt string
|
2009-04-15 14:15:49 +02:00
|
|
|
#define DEFAULT_CONFIG_FILE "/usr/local/etc/owlps/owlps-aggregator.conf"
|
2010-07-12 16:34:25 +02:00
|
|
|
#define DEFAULT_AGGREGATE_TIMEOUT 1500 // milliseconds
|
|
|
|
#define DEFAULT_KEEP_TIMEOUT 3000 // milliseconds
|
|
|
|
#define DEFAULT_CHECK_INTERVAL 500000 // microseconds
|
2010-10-14 18:30:41 +02:00
|
|
|
#define DEFAULT_AP_KEEP_TIMEOUT 600 // s
|
|
|
|
#define DEFAULT_AP_CHECK_INTERVAL 1000 // ms
|
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
|
|
|
|
2010-07-12 16:34:25 +02:00
|
|
|
/* Error codes */
|
|
|
|
#define ERR_NO_MESSAGE_RECEIVED 1 // Error when reading the socket
|
|
|
|
#define ERR_CREATING_SOCKET 2 // Erreur when creating listening socket
|
|
|
|
#define ERR_BAD_USAGE 3 // Bad program call
|
|
|
|
#define ERR_PARSING_CONFIG_FILE 4 // Error reading the configuration file
|
2010-10-25 17:03:16 +02:00
|
|
|
#define ERR_SENDING_INFO 5 // Error sending a message on a socket
|
2008-02-14 08:54:51 +01:00
|
|
|
|
2010-07-12 16:34:25 +02:00
|
|
|
|
|
|
|
/* Linked list storing data of couples MAC / sequence number */
|
2008-02-14 08:54:51 +01:00
|
|
|
typedef struct _couple_info_list
|
|
|
|
{
|
2010-07-12 16:34:25 +02:00
|
|
|
// MAC address of the data sender (in bytes):
|
2011-03-10 19:18:43 +01:00
|
|
|
uint8_t ap_mac_addr_bytes[6] ;
|
2010-07-12 16:34:25 +02:00
|
|
|
// Signal strength received by the AP from the mobile:
|
2011-03-10 19:18:43 +01:00
|
|
|
uint8_t antenna_signal_dbm ;
|
2008-02-14 08:54:51 +01:00
|
|
|
struct _couple_info_list *next ;
|
|
|
|
} couple_info_list ;
|
|
|
|
|
|
|
|
|
2010-07-12 16:34:25 +02:00
|
|
|
/* Linked list of the couples MAC / sequence number */
|
2008-02-14 08:54:51 +01:00
|
|
|
typedef struct _couple_list
|
|
|
|
{
|
2008-03-14 11:31:04 +01:00
|
|
|
/* Numéro de séquence de la demande de localisation du mobile */
|
2011-03-10 19:18:43 +01:00
|
|
|
uint8_t mobile_mac_addr_bytes[6] ; // Mobile MAC address (in bytes)
|
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 */
|
|
|
|
// Arrival time of the first packet of the couple on the aggregator:
|
2011-03-18 15:15:39 +01:00
|
|
|
owl_timestamp start_time ;
|
2010-07-12 16:34:25 +02:00
|
|
|
couple_info_list *info ; // Data for this couple
|
2008-03-14 11:31:04 +01:00
|
|
|
|
|
|
|
struct _couple_list *next ;
|
2008-02-14 08:54:51 +01:00
|
|
|
} couple_list ;
|
|
|
|
|
|
|
|
|
2010-08-06 12:29:39 +02:00
|
|
|
/* Linked list of the known APs */
|
|
|
|
typedef struct _ap_list
|
|
|
|
{
|
2011-03-10 19:18:43 +01:00
|
|
|
uint8_t mac_addr_bytes[6] ;
|
2010-10-14 12:05:11 +02:00
|
|
|
char ip_addr[16] ;
|
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 */
|
2010-07-12 12:50:02 +02:00
|
|
|
void initialise_configuration(int argc, char **argv) ;
|
|
|
|
void parse_config_file(int argc, char **argv) ;
|
|
|
|
void parse_command_line(int argc, char **argv) ;
|
|
|
|
void check_configuration(void) ;
|
|
|
|
|
|
|
|
int read_loop(int sockfd) ;
|
2011-03-18 15:15:39 +01:00
|
|
|
void got_couple_info(owl_captured_request request) ;
|
2010-08-06 12:29:39 +02:00
|
|
|
|
|
|
|
void* monitor_couples(void) ;
|
2010-08-06 09:42:22 +02:00
|
|
|
void free_couple_list(void) ;
|
2009-09-03 11:09:48 +02:00
|
|
|
#ifdef DEBUG
|
2010-08-06 09:42:22 +02:00
|
|
|
void print_couple_list(void) ;
|
2008-02-14 08:54:51 +01:00
|
|
|
void print_couple_info(couple_info_list *info) ;
|
2009-09-03 11:09:48 +02:00
|
|
|
#endif // DEBUG
|
2010-07-12 12:50:02 +02:00
|
|
|
|
2010-10-11 09:54:35 +02:00
|
|
|
void listen_for_aps(void) ;
|
2011-03-10 19:18:43 +01:00
|
|
|
void update_ap(uint8_t mac_addr_bytes[6], char ip_addr[16]) ;
|
|
|
|
ap_list* find_ap(uint8_t mac_addr_bytes[6]) ;
|
|
|
|
ap_list* add_ap_front(uint8_t mac_addr_bytes[6]) ;
|
2010-10-14 12:05:11 +02:00
|
|
|
void update_ap_ip_addr(ap_list *ap, char ip_addr[16]) ;
|
2010-08-06 12:29:39 +02:00
|
|
|
void update_ap_seen(ap_list *ap) ;
|
|
|
|
void push_ap(ap_list *ap) ;
|
|
|
|
|
|
|
|
void monitor_aps(void) ;
|
|
|
|
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) ;
|
|
|
|
|
2011-03-10 19:18:43 +01:00
|
|
|
char* ip_bytes_to_string(uint8_t ip_binary[4]) ;
|
2010-07-12 12:50:02 +02:00
|
|
|
void print_usage(void) ;
|
2008-02-22 16:04:49 +01:00
|
|
|
|
2010-07-12 16:34:25 +02:00
|
|
|
#endif // _OWLPS_AGGREGATOR_H_
|