diff --git a/infrastructure-centred/TODO b/infrastructure-centred/TODO index 1980724..8a56a0e 100644 --- a/infrastructure-centred/TODO +++ b/infrastructure-centred/TODO @@ -1,12 +1 @@ * Un peu partout : fixer la taille des données échangées (float = 4 octets, etc.). - -* client : - - Vérifier que la direction est bien une des quatre possibles. - - Éventuellement, permettre l'utilisation d'une chaîne de caractères pour la direction. - - Faire une vraie gestion des arguments, enlever ce argv++ fort laid. - - Régler avec des arguments plutôt qu'en statique le nombre de paquets envoyés et le délai entre chaque envoi. - -* apd : permettre d'utiliser un nom d'hôte putôt qu'une IP pour le serveur d'agrégation. - -* Permettre de choisir soi-même le port des communications, aussi bien sur le mobile (demande de localisation), que sur les AP et le serveur d'agrégation. Pour l'instant, les ports sont gérés grâce aux constantes AGGREGATE_DEFAULT_PORT et LOC_REQUEST_DEFAULT_PORT. -→ Fait pour le port d'agrégation, dans owlps-listener et owlps-aggregator. diff --git a/infrastructure-centred/owlps-aggregator/TODO b/infrastructure-centred/owlps-aggregator/TODO new file mode 100644 index 0000000..1d7fa0e --- /dev/null +++ b/infrastructure-centred/owlps-aggregator/TODO @@ -0,0 +1 @@ +* Choisir les interfaces en fonction des paramètres spécifiés (permettre des paramètres vides). diff --git a/infrastructure-centred/owlps-aggregator/owlps-aggregator.h b/infrastructure-centred/owlps-aggregator/owlps-aggregator.h index 3a918b2..80637aa 100644 --- a/infrastructure-centred/owlps-aggregator/owlps-aggregator.h +++ b/infrastructure-centred/owlps-aggregator/owlps-aggregator.h @@ -14,15 +14,16 @@ /* Arguments & configuration du programme */ -#define OPTIONS "f:l:o:a:k:c:i:u:n:p:h:" // Chaîne pour getopt +#define OPTIONS "a:c:f:H:i:k:l:N:o:p:P:U:" // Chaîne pour getopt #define DEFAULT_CONFIG_FILE "/usr/local/etc/owlps/owlps-aggregator.conf" #define DEFAULT_AGGREGATE_TIMEOUT 1500 // Timeout d'agrégation (en millisecondes) #define DEFAULT_KEEP_TIMEOUT 3000 // Temps que l'on conserve les données dans la liste (en millisecondes) #define DEFAULT_CHECK_INTERVAL 500000 // Temps entre deux vérifications de la liste (en micro-secondes) -#define DEFAULT_HOST_DB "127.0.0.1" -#define DEFAULT_DB_NAME "owlps_db" -#define DEFAULT_USER_DB "owlps" -#define DEFAULT_PASS_DB "owlps" +#define POSITIONER_DEFAULT_IP "127.0.0.1" +#define DEFAULT_DB_HOST "127.0.0.1" +#define DEFAULT_DB_NAME "owlps_db" +#define DEFAULT_DB_USER "owlps" +#define DEFAULT_DB_PASS "owlps" /* Codes d'erreur */ #define ERR_NO_MESSAGE_RECEIVED 1 // Erreur lors de la lecture sur la socket diff --git a/infrastructure-centred/owlps-aggregator/owlps-aggregatord.c b/infrastructure-centred/owlps-aggregator/owlps-aggregatord.c index 2e0a56c..d627c12 100644 --- a/infrastructure-centred/owlps-aggregator/owlps-aggregatord.c +++ b/infrastructure-centred/owlps-aggregator/owlps-aggregatord.c @@ -47,16 +47,16 @@ int main(int argc, char **argv) cfg_opt_t opts[] = { // Options reconnues par confuse dans le fichier de config CFG_INT("listening_port", AGGREGATE_DEFAULT_PORT, CFGF_NONE), // Port d'écoute - CFG_INT("send_port", POSITIONER_DEFAULT_PORT, CFGF_NONE), // Port de sortie - CFG_STR("ip_positioner", "", CFGF_NONE), // Adresse IP du serveur de géolocalisation + CFG_INT("positioner_port", POSITIONER_DEFAULT_PORT, CFGF_NONE), // Port d'envoi sur le serveur de calcul + CFG_STR("positioner_ip", POSITIONER_DEFAULT_IP, CFGF_NONE), // Adresse IP du serveur de géolocalisation CFG_STR("output_file", "", CFGF_NONE), // Fichier de sortie CFG_INT("aggregate_timeout", DEFAULT_AGGREGATE_TIMEOUT, CFGF_NONE), // Timeout d'agrégation (en millisecondes) CFG_INT("keep_timeout", DEFAULT_KEEP_TIMEOUT, CFGF_NONE), // Temps que l'on conserve les données dans la liste (en millisecondes) CFG_INT("check_interval", DEFAULT_CHECK_INTERVAL, CFGF_NONE), // Temps entre deux vérifications de la liste (en micro-secondes) - CFG_STR("host_db", DEFAULT_HOST_DB, CFGF_NONE), + CFG_STR("host_db", DEFAULT_DB_HOST, CFGF_NONE), CFG_STR("db_name", DEFAULT_DB_NAME, CFGF_NONE), - CFG_STR("user_db", DEFAULT_USER_DB, CFGF_NONE), - CFG_STR("pass_db", DEFAULT_PASS_DB, CFGF_NONE), + CFG_STR("user_db", DEFAULT_DB_USER, CFGF_NONE), + CFG_STR("pass_db", DEFAULT_DB_PASS, CFGF_NONE), CFG_END() } ; char *config_file ; // Nom du fichier de configuration int opt ; // Retour de getopt @@ -93,39 +93,42 @@ int main(int argc, char **argv) { switch (opt) { - case 'f' : // Fichier de configuration - // Déjà traité. - break ; - case 'l' : - cfg_setint(cfg, "listening_port", strtol(optarg, NULL, 0)) ; - break ; - case 'o' : - cfg_setstr(cfg, "output_file", optarg) ; - break ; case 'a' : cfg_setint(cfg, "aggregate_timeout", strtol(optarg, NULL, 0)) ; break ; - case 'k' : - cfg_setint(cfg, "keep_timeout", strtol(optarg, NULL, 0)) ; - break ; case 'c' : cfg_setint(cfg, "check_interval", strtol(optarg, NULL, 0)) ; break ; - case 'i' : - cfg_setstr(cfg, "ip_positioner", optarg) ; + case 'f' : // Fichier de configuration + // Déjà traité. break ; - case 'u' : - cfg_setstr(cfg, "user_db", optarg) ; - break ; - case 'n' : - cfg_setstr(cfg, "db_name", optarg) ; - break ; - case 'p' : - cfg_setstr(cfg, "pass_db", optarg) ; - break ; - case 'h' : + case 'H' : cfg_setstr(cfg, "host_db", optarg) ; break ; + case 'i' : + cfg_setstr(cfg, "positioner_ip", optarg) ; + break ; + case 'k' : + cfg_setint(cfg, "keep_timeout", strtol(optarg, NULL, 0)) ; + break ; + case 'l' : + cfg_setint(cfg, "listening_port", strtol(optarg, NULL, 0)) ; + break ; + case 'N' : + cfg_setstr(cfg, "db_name", optarg) ; + break ; + case 'o' : + cfg_setstr(cfg, "output_file", optarg) ; + break ; + case 'p' : + cfg_setint(cfg, "positioner_port", strtol(optarg, NULL, 0)) ; + break ; + case 'P' : + cfg_setstr(cfg, "pass_db", optarg) ; + break ; + case 'U' : + cfg_setstr(cfg, "user_db", optarg) ; + break ; default : print_usage(argv[0]) ; return ERR_BAD_USAGE ; @@ -140,8 +143,8 @@ int main(int argc, char **argv) print_usage(argv[0]) ; return ERR_BAD_USAGE ; } - // ip_positioner // - if (cfg_getstr(cfg, "ip_positioner")[0] == '\0') + // positioner_ip // + if (cfg_getstr(cfg, "positioner_ip")[0] == '\0') { fprintf(stderr, "Erreur ! Vous devez spécifier l'adresse IP du serveur de géolocalisation.\n") ; print_usage(argv[0]) ; @@ -276,7 +279,7 @@ void* monitor_couple_list(couple_list **couples) couple_info info; int sockfd; - sockfd = create_udp_sending_socket(cfg_getstr(cfg, "ip_positioner"), cfg_getint(cfg, "send_port"), &serv, &client); + sockfd = create_udp_sending_socket(cfg_getstr(cfg, "positioner_ip"), cfg_getint(cfg, "positioner_port"), &serv, &client); fd = fopen(cfg_getstr(cfg, "output_file"), "a") ; // Ouverture du fichier de sortie en ajout if (fd == NULL) // Si ouverture échouée, @@ -760,11 +763,33 @@ int DbPacket(couple_message message, PGconn *conn, int id_ap, int id_request, BO void print_usage(char *prog) { printf("Usage :\n\ -\t%s [-f config_file] [-l listening_port] [-a aggregate_timeout] [-k keep_timeout] [-c check_interval] -o output_file -i ip_positionner\n\ -\tOptions BdD: \n\ -\t -h hostaddr\t: Adresse de l'host de la BdD \n\ -\t -n name_db\t: Nom de la BdD \n\ -\t -u user\t: Nom d'utilisateur pour l'acces à la BdD \n\ -\t -p passwd\t: Mot de passe pour l'acces à la BdD \n\ -", prog) ; +\t%s [-f config_file] [-l listening_port] [-i positionner_ip] [-p positioner_port] [-a aggregate_timeout] [-k keep_timeout] [-c check_interval] [-o output_file] [-H db_addr] [-N db_name] [-U db_user] [-P db_passwd]\n\ +Options générales :\n\ +\t-f config_file : spécifie un fichier de configuration à lire à la place du fichier par défaut.\n\ +Options serveur :\n\ +\t-l listening_port : seules les demandes envoyées sur ce port seront retenues (défaut : %d).\n\ +\t-i positionner_ip : adresse IP du serveur de calcul auquel seront transmises les demandes (défaut : %s).\n\ +\t-p positioner_port : les demandes agrégées seront transmises sur ce port du serveur de calcul (défaut : %d).\n\ +Options d'agrégation :\n\ +\t-a aggregate_timeout : temps d'agrégation (défaut : %d millisecondes)\n\ +\t-a keep_timeout : temps de garde des demandes (défaut : %d millisecondes)\n\ +\t-a check_interval : délai entre deux vérifications des demandes en mémoire, et agrégation (défaut : %d micro-secondes)\n\ +Options relatives à la base de données :\n\ +\t-H db_addr : adresse du serveur de BdD (défaut : %s).\n\ +\t-N db_name : nom de la base (défaut : %s).\n\ +\t-U db_user : nom d'utilisateur pour l'accès à la BdD (défaut : %s).\n\ +\t-P db_passwd : mot de passe pour l'accès à la BdD (défaut : %s).\n\ +", + prog, + AGGREGATE_DEFAULT_PORT, + POSITIONER_DEFAULT_IP, + POSITIONER_DEFAULT_PORT, + DEFAULT_AGGREGATE_TIMEOUT, + DEFAULT_KEEP_TIMEOUT, + DEFAULT_CHECK_INTERVAL, + DEFAULT_DB_HOST, + DEFAULT_DB_NAME, + DEFAULT_DB_USER, + DEFAULT_DB_PASS + ) ; } diff --git a/infrastructure-centred/owlps-client/TODO b/infrastructure-centred/owlps-client/TODO new file mode 100644 index 0000000..6d5b14b --- /dev/null +++ b/infrastructure-centred/owlps-client/TODO @@ -0,0 +1,4 @@ +* Vérifier que la direction est bien une des quatre possibles. +* Éventuellement, permettre l'utilisation d'une chaîne de caractères pour la direction. +* Permettre de choisir soi-même le port d'envoi des demandes, au lieu d'utiliser LOC_REQUEST_DEFAULT_PORT. +* Ajout d'une option et/ou d'une option préprocesseur (#ifdef WAIT_FOR_POSITION) permettant d'activer ou non l'attente d'une réponse après l'envoi d'une demande. diff --git a/infrastructure-centred/owlps-listener/TODO b/infrastructure-centred/owlps-listener/TODO index b7d1521..868626d 100644 --- a/infrastructure-centred/owlps-listener/TODO +++ b/infrastructure-centred/owlps-listener/TODO @@ -1,3 +1,4 @@ * Makefile : utiliser des options passées au compilateur (gcc -D USE_PTHREAD) plutôt que des #define dans owlps-listener.h. * Fusionner Makefile et Makefile_atheros. * Éventuellement remplacer les options positives (USE_PTHREAD) par des options négatives (NO_USE_PTHREAD), en fonction des valeurs par défaut. +* Permettre d'utiliser un nom d'hôte putôt qu'une IP pour le serveur d'agrégation. diff --git a/infrastructure-centred/owlps-listener/owlps-listener.h b/infrastructure-centred/owlps-listener/owlps-listener.h index 007443a..7eeb7a5 100644 --- a/infrastructure-centred/owlps-listener/owlps-listener.h +++ b/infrastructure-centred/owlps-listener/owlps-listener.h @@ -36,7 +36,7 @@ /* Arguments & configuration du programme */ -#define OPTIONS "f:d:kp:r:w:" // Chaîne pour getopt +#define OPTIONS "d:f:kl:p:r:w:" // Chaîne pour getopt #define DEFAULT_CONFIG_FILE "/usr/local/etc/owlps/owlps-listener.conf" @@ -64,6 +64,8 @@ void print_usage(char *prog) ; #endif // USE_PTHREAD #define SET_AGGREGATION_PORT(PORT) (cfg_setint(cfg, "aggregation_port", (PORT))) #define GET_AGGREGATION_PORT() (cfg_getint(cfg, "aggregation_port")) +#define SET_LISTENING_PORT(PORT) (cfg_setint(cfg, "listening_port", (PORT))) +#define GET_LISTENING_PORT() (cfg_getint(cfg, "listening_port")) #define SET_RTAP_IFACE(IFACE) (cfg_setstr(cfg, "rtap_iface", (IFACE))) #define GET_RTAP_IFACE() (cfg_getstr(cfg, "rtap_iface")) #define SET_WIFI_IFACE(IFACE) (cfg_setstr(cfg, "wifi_iface", (IFACE))) @@ -79,6 +81,8 @@ void print_usage(char *prog) ; #endif // USE_PTHREAD #define SET_AGGREGATION_PORT(PORT) (options.aggregation_port = (PORT)) #define GET_AGGREGATION_PORT() (options.aggregation_port) +#define SET_LISTENING_PORT(PORT) (options.listening_port = (PORT)) +#define GET_LISTENING_PORT() (options.listening_port) #define SET_RTAP_IFACE(IFACE) (strncpy(options.rtap_iface, (IFACE), IFNAMSIZ+1)) #define GET_RTAP_IFACE() (options.rtap_iface) #define SET_WIFI_IFACE(IFACE) (strncpy(options.wifi_iface, (IFACE), IFNAMSIZ+1)) diff --git a/infrastructure-centred/owlps-listener/owlps-listenerd.c b/infrastructure-centred/owlps-listener/owlps-listenerd.c index a084e73..35a610e 100644 --- a/infrastructure-centred/owlps-listener/owlps-listenerd.c +++ b/infrastructure-centred/owlps-listener/owlps-listenerd.c @@ -9,6 +9,29 @@ unsigned char mac[6] ; // Adresse MAC de l'AP +#ifdef USE_CONFIG_FILE +cfg_t *cfg ; // Structure contenant la configuration + +#else // USE_CONFIG_FILE // Si on n'utilise pas libconfuse, on déclare une +struct { // structure qui servira à stocker les options getopt : + char aggregation_ip[16] ; + long aggregation_port ; + long listening_port ; +#ifdef USE_PTHREAD + BOOL keep_monitor ; +#endif // USE_PTHREAD + char rtap_iface[IFNAMSIZ + 1] ; + char wifi_iface[IFNAMSIZ + 1] ; +} options = { // et on initalise les options par défaut : + "127.0.0.1", + AGGREGATE_DEFAULT_PORT, +#ifdef USE_PTHREAD + FALSE, +#endif // USE_PTHREAD + "", + "" +} ; +#endif // USE_CONFIG_FILE int main(int argc, char *argv[]) @@ -20,35 +43,19 @@ int main(int argc, char *argv[]) pthread_t thread ; // Thread pour le repassage en mode monitor #endif // USE_PTHREAD -#ifdef USE_CONFIG_FILE +#ifdef USE_CONFIG_FILE // Si on utilise libconfuse, on déclare les options : cfg_opt_t opts[] = { // Options reconnues par confuse dans le fichier de config CFG_STR("aggregation_ip", "127.0.0.1", CFGF_NONE), // Adresse IP du serveur d'agrégation (défaut : boucle locale) - CFG_INT("aggregation_port", AGGREGATE_DEFAULT_PORT, CFGF_NONE), // Port sur le serveur d'agrégation + CFG_INT("aggregation_port", AGGREGATE_DEFAULT_PORT, CFGF_NONE), // Port d'envoi sur le serveur d'agrégation + CFG_INT("listening_port", LOC_REQUEST_DEFAULT_PORT, CFGF_NONE), // Port d'écoute des demandes des mobiles #ifdef USE_PTHREAD CFG_BOOL("keep_monitor", cfg_false, CFGF_NONE), // Active le maintien actif du mode monitor #endif // USE_PTHREAD CFG_STR("rtap_iface", "", CFGF_NONE), // Interface radiotap utilisée pour la capture CFG_STR("wifi_iface", "", CFGF_NONE), // Interface physique correspondante (utilisée pour récupérer l'adresse MAC) CFG_END() } ; - cfg_t *cfg ; // Structure contenant la configuration + char *config_file ; // Nom du fichier de configuration -#else // USE_CONFIG_FILE - struct { - char aggregation_ip[16] ; - int aggregation_port ; -#ifdef USE_PTHREAD - BOOL keep_monitor ; -#endif // USE_PTHREAD - char rtap_iface[IFNAMSIZ + 1] ; - char wifi_iface[IFNAMSIZ + 1] ; - } options = {"127.0.0.1", - AGGREGATE_DEFAULT_PORT, -#ifdef USE_PTHREAD - FALSE, -#endif // USE_PTHREAD - "", - "" - } ; #endif // USE_CONFIG_FILE int opt ; // Retour de getopt @@ -92,12 +99,12 @@ int main(int argc, char *argv[]) { switch (opt) { - case 'f' : // Fichier de configuration - // Déjà traité. - break ; case 'd' : SET_AGGREGATION_IP(optarg) ; break ; + case 'f' : // Fichier de configuration + // Déjà traité. + break ; case 'k' : #ifdef USE_PTHREAD SET_KEEP_MONITOR() ; @@ -105,6 +112,9 @@ int main(int argc, char *argv[]) fprintf(stderr, "Attention ! Le programme a été compilé sans le support des threads POSIX, l'option -k (maintien du mode monitor) n'est donc pas disponible et sera ignorée.\n") ; #endif // USE_PTHREAD break ; + case 'l' : + SET_LISTENING_PORT(strtol(optarg, NULL, 0)) ; + break ; case 'p' : SET_AGGREGATION_PORT(strtol(optarg, NULL, 0)) ; break ; @@ -143,12 +153,14 @@ int main(int argc, char *argv[]) #else // USE_CONFIG_FILE fprintf(stderr, "\ aggregation_ip = \"%s\"\n\ -aggregation_port = %d\n\ +aggregation_port = %ld\n\ +listening_port = %ld\n\ rtap_iface = \"%s\"\n\ wifi_iface = \"%s\"\n\ ", GET_AGGREGATION_IP(), GET_AGGREGATION_PORT(), + GET_LISTENING_PORT(), GET_RTAP_IFACE(), GET_WIFI_IFACE() ); @@ -291,7 +303,7 @@ void read_packet(u_char *args, const struct pcap_pkthdr *header, const u_char *p #ifdef DEBUG if (raw_packet_type == RAW_PACKET_TYPE_DATA && data[rtap_bytes + IEEE80211_HEADER_SIZE + LLC_HEADER_SIZE + 9] == RAW_PACKET_PROTO_UDP - && dst_port == LOC_REQUEST_DEFAULT_PORT) + && dst_port == GET_LISTENING_PORT()) { printf("raw_packet_flags : %02x\n", raw_packet_flags) ; if (IS_RETRY(raw_packet_flags)) @@ -498,7 +510,7 @@ void get_mac_addr(char *eth, unsigned char mac_bytes[6]) void print_usage(char *prog) { printf("Usage :\n\ -\t%s [-f config_file] [-d ip_agrégation] [-p port_agrégation] -r rtap_iface [-w wifi_iface] [-k]\n\ +\t%s [-f config_file] [-d ip_agrégation] [-l listening_port] [-p port_agrégation] -r rtap_iface [-w wifi_iface] [-k]\n\ - L'option -f permet de spécifier un fichier de configuration alternatif (le fichier de configuration par défaut ne sera pas lu). Disponible uniquement si le programme a été compilé avec le support de libconfuse.\n\ - ip_agrégation est l'adresse IP du serveur d'agrégation (par défaut : 127.0.0.1), et port_agrégation le port sur lequel il écoute (par défaut : %d).\n\ - rtap_iface est l'interface de capture radiotap.\n\ diff --git a/libowlps/owlps.h b/libowlps/owlps.h index e6be92d..eaa5121 100644 --- a/libowlps/owlps.h +++ b/libowlps/owlps.h @@ -38,7 +38,7 @@ #define LOC_REQUEST_DEFAULT_PORT 9900 // Port sur lequel est envoyée la requête de localisation depuis le mobile #define AGGREGATE_DEFAULT_PORT 9901 // Port d'échange des données entre AP et serveur d'aggrégation -#define POSITIONER_DEFAULT_PORT 9902 // Port d'échange des données entre server d'aggrégation et serveur de localisation +#define POSITIONER_DEFAULT_PORT 9902 // Port d'échange des données entre serveur d'aggrégation et serveur de localisation #define MOBILE_DEFAULT_PORT 9903 // Port d'envoi de la solution vers le mobile /* Type booléen */