/* * This file is part of the rtap localisation project. */ #ifndef _OWLPS_AGGREGATOR_H_ #define _OWLPS_AGGREGATOR_H_ #include "../../libowlps/owlps.h" #include #define DEBUG // Uncomment to output the timestamp on each line of the output file: //#define TIMESTAMP /* Arguments & program configuration */ #define OPTIONS "Aa:c:f:hi:k:l:o:p:t:" // 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 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 /* Linked list storing data of couples MAC / sequence number */ typedef struct _couple_info_list { // MAC address of the data sender (in bytes): unsigned char ap_mac_addr_bytes[6] ; // Signal strength received by the AP from the mobile: unsigned char 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 */ unsigned char mobile_mac_addr_bytes[6] ; // Mobile MAC address (in bytes) struct timeval request_time ; // Request time on the mobile /* Calibration data */ float x_position ; float y_position ; float z_position ; DIRECTION direction ; // Request orientation /* Other data */ // Arrival time of the first packet of the couple on the aggregator: struct timeval start_time ; couple_info_list *info ; // Data for this couple struct _couple_list *next ; } couple_list ; /* Linked list of the known APs */ typedef struct _ap_list { unsigned char mac_address_bytes[6] ; struct timeval last_seen ; 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(couple_message message) ; 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(unsigned char mac_address_bytes[6]) ; ap_list* find_ap(unsigned char mac_address_bytes[6]) ; void add_ap_front(unsigned char mac_address_bytes[6]) ; 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 move_ap_front(ap_list *ap) ; void free_ap_list(void) ; char* ip_bytes_to_string(unsigned char *ip_binary) ; void print_usage(void) ; #endif // _OWLPS_AGGREGATOR_H_