owlps/owlps-aggregator/owlps-aggregator.h

118 lines
3.2 KiB
C
Raw Normal View History

/*
* This file is part of the rtap localisation project.
*/
#ifndef _OWLPS_AGGREGATOR_H_
#define _OWLPS_AGGREGATOR_H_
#include <owlps.h>
#include <confuse.h>
#define DEBUG
// Uncomment to output the timestamp on each line of the output file:
//#define USE_TIMESTAMP
/* 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
#define DEFAULT_CONFIG_FILE "/usr/local/etc/owlps/owlps-aggregator.conf"
#define DEFAULT_AGGREGATE_TIMEOUT 1500 // milliseconds
#define DEFAULT_KEEP_TIMEOUT 3000 // milliseconds
#define DEFAULT_CHECK_INTERVAL 500000 // microseconds
#define DEFAULT_AP_KEEP_TIMEOUT 600 // s
#define DEFAULT_AP_CHECK_INTERVAL 1000 // ms
#define POSITIONER_DEFAULT_IP "127.0.0.1"
/* 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
#define ERR_SENDING_INFO 5 // Error sending a message on a socket
/* Linked list storing data of couples MAC / sequence number */
typedef struct _couple_info_list
{
// MAC address of the data sender (in bytes):
uint8_t ap_mac_addr_bytes[6] ;
// Signal strength received by the AP from the mobile:
uint8_t antenna_signal_dbm ;
struct _couple_info_list *next ;
} couple_info_list ;
/* Linked list of the couples MAC / sequence number */
typedef struct _couple_list
{
/* Numéro de séquence de la demande de localisation du mobile */
uint8_t mobile_mac_addr_bytes[6] ; // Mobile MAC address (in bytes)
owl_timestamp request_time ; // Request time on the mobile
/* Calibration data */
float x_position ;
float y_position ;
float z_position ;
owl_direction direction ; // Request orientation
/* Other data */
// Arrival time of the first packet of the couple on the aggregator:
owl_timestamp start_time ;
couple_info_list *info ; // Data for this couple
struct _couple_list *next ;
} couple_list ;
2010-08-06 12:29:39 +02:00
/* Linked list of the known APs */
typedef struct _ap_list
{
uint8_t mac_addr_bytes[6] ;
char ip_addr[16] ;
2010-10-12 15:09:14 +02:00
owl_timestamp last_seen ;
2010-08-06 12:29:39 +02:00
struct _ap_list *previous ;
struct _ap_list *next ;
} ap_list ;
/* Function headers */
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) ;
void got_couple_info(owl_captured_request request) ;
2010-08-06 12:29:39 +02:00
void* monitor_couples(void) ;
void free_couple_list(void) ;
#ifdef DEBUG
void print_couple_list(void) ;
void print_couple_info(couple_info_list *info) ;
#endif // DEBUG
void listen_for_aps(void) ;
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]) ;
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) ;
char* ip_bytes_to_string(uint8_t ip_binary[4]) ;
void print_usage(void) ;
#endif // _OWLPS_AGGREGATOR_H_