/* * This file is part of the Owl Positioning System (OwlPS). * OwlPS is a project of the University of Franche-Comte * (Université de Franche-Comté), France. * * Copyright © Université de Franche-Comté 2007-2012. * * Corresponding author: Matteo Cypriani * *********************************************************************** * * This software is governed by the CeCILL license under French law and * abiding by the rules of distribution of free software. You can use, * modify and/or redistribute the software under the terms of the CeCILL * license as circulated by CEA, CNRS and INRIA at the following URL: * http://www.cecill.info * * As a counterpart to the access to the source code and rights to copy, * modify and redistribute granted by the license, users are provided * only with a limited warranty and the software's authors, the holder * of the economic rights, and the successive licensors have only * limited liability. * * In this respect, the user's attention is drawn to the risks * associated with loading, using, modifying and/or developing or * reproducing the software by the user in light of its specific status * of free software, that may mean that it is complicated to manipulate, * and that also therefore means that it is reserved for developers and * experienced professionals having in-depth computer knowledge. Users * are therefore encouraged to load and test the software's suitability * as regards their requirements in conditions enabling the security of * their systems and/or data to be ensured and, more generally, to use * and operate it in the same conditions as regards security. * * The fact that you are presently reading this means that you have had * knowledge of the CeCILL license and that you accept its terms. * *********************************************************************** * * This is the header file of OwlPS Aggregator. */ #ifndef _OWLPS_AGGREGATOR_H_ #define _OWLPS_AGGREGATOR_H_ #include /* Arguments & program configuration */ #define OPTIONS "Ac:C:Df:hH:i:k:K:l:o:O:p:qt:vV" // getopt string #define DEFAULT_CONFIG_FILE "/usr/local/etc/owlps/owlps-aggregator.conf" #define DEFAULT_AGGREGATE_TIMEOUT 600 // milliseconds #define DEFAULT_KEEP_TIMEOUT 3000 // milliseconds #define DEFAULT_CHECK_INTERVAL 300 // milliseconds #define DEFAULT_AP_KEEP_TIMEOUT 35 // seconds #define DEFAULT_AP_CHECK_INTERVAL 1000 // milliseconds #define POSITIONER_DEFAULT_IP "127.0.0.1" /* 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 /* Linked list storing data of each request */ typedef struct _request_info_list { // Number of the current packet: uint16_t packet_id ; // MAC address of the transmitter AP (in bytes): uint8_t ap_mac_addr_bytes[ETHER_ADDR_LEN] ; // Timestamp of arrival on the listener: owl_timestamp capture_time ; // Signal strength received by the AP from the mobile: uint8_t ss_dbm ; struct _request_info_list *next ; } request_info_list ; /* Linked list of the requests */ typedef struct _request_list { uint8_t type ; // Number of packets sent by the mobile for this request: uint16_t nb_packets ; /* Request identifier */ uint8_t mobile_mac_addr_bytes[ETHER_ADDR_LEN] ; // Mobile MAC address 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 */ uint8_t mobile_ip_addr_bytes[4] ; // Mobile IP address // Arrival time of the first packet of the request on the aggregator: owl_timestamp start_time ; request_info_list *info ; // Data for this request struct _request_list *next ; } request_list ; /* Linked list of the known APs */ typedef struct _ap_list { uint8_t mac_addr_bytes[ETHER_ADDR_LEN] ; char ip_addr[INET_ADDRSTRLEN] ; owl_timestamp last_seen ; struct _ap_list *previous ; struct _ap_list *next ; } ap_list ; /* Function headers */ 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) ; int read_loop(int sockfd) ; void got_request(owl_captured_request request) ; void* monitor_requests(void *NULL_value) ; void free_request_list(void) ; #ifndef NDEBUG void print_request_list(void) ; void print_request_info(request_info_list *info) ; #endif // NDEBUG void* listen_for_aps(void *NULL_value) ; 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]) ; void update_ap_ip_addr(ap_list *ap, char ip_addr[INET_ADDRSTRLEN]) ; void update_ap_seen(ap_list *ap) ; void push_ap(ap_list *ap) ; void* monitor_aps(void *NULL_value) ; 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) ; void print_usage(void) ; void print_version(void) ; #endif // _OWLPS_AGGREGATOR_H_