Modifs tx, unification makefiles
M code/loc-mobile/librtapscanmob/librtapscanmob.c : Ajout de la fonction write_mac_list_to_text_file(). M code/loc-mobile/librtapscanmob/rtapscanmob.h Déplacement de tx.c dans un répertoire à part, sous le nom mobile.c : D code/loc-mobile/librtapscanmob/tx.c A code/loc-mobile/mobile A code/loc-mobile/mobile/mobile.c : Ajout de la gestion des données de calibration, utilisation de write_mac_list_to_text_file() au lieu de write_mac_list_to_file(). M code/loc-bts/rtapaggregate/rtapaggregated.c : Format de sortie dans le fichier texte. Unification des Makefiles : M code/loc-mobile/librtapscanmob/Makefile A code/loc-mobile/mobile/Makefile M code/loc-mobile/Makefile M code/loc-bts/Makefile M code/Makefile A code/loc-mobile/client : Erreur, sera supprimé au prochain commit. git-svn-id: https://pif.pu-pm.univ-fcomte.fr/svn/loc@20 785a6c6c-259e-4ff1-8b91-dc31627914f0
This commit is contained in:
parent
dfe60f3de5
commit
ac937d1471
44
Makefile
44
Makefile
|
@ -1,55 +1,55 @@
|
|||
.PHONY : all librtaputil clean purge help install install-librtaputil install-loc-bts install-loc-client uninstall uninstall-librtaputil uninstall-loc-bts uninstall-loc-client
|
||||
.PHONY : all librtaputil clean purge help install install-librtaputil install-loc-bts install-loc-mobile uninstall uninstall-librtaputil uninstall-loc-bts uninstall-loc-mobile
|
||||
|
||||
## Compilation ##
|
||||
|
||||
all : librtaputil loc-bts loc-mobile
|
||||
|
||||
librtaputil :
|
||||
@cd librtaputil && make
|
||||
@make -C librtaputil
|
||||
|
||||
loc-bts : librtaputil
|
||||
@cd loc-bts && make
|
||||
@make -C loc-bts
|
||||
|
||||
loc-mobile : librtaputil
|
||||
@cd loc-mobile && make
|
||||
@make -C loc-mobile
|
||||
|
||||
## Installation ##
|
||||
|
||||
install : install-librtaputil install-loc-bts install-loc-client
|
||||
install : install-librtaputil install-loc-bts install-loc-mobile
|
||||
|
||||
install-librtaputil : librtaputil
|
||||
@cd librtaputil && make install
|
||||
install-librtaputil :
|
||||
@make -C librtaputil install
|
||||
|
||||
install-loc-bts : loc-bts
|
||||
@cd loc-bts && make install
|
||||
install-loc-bts : install-librtaputil
|
||||
@make -C loc-bts install
|
||||
|
||||
install-loc-mobile : loc-mobile
|
||||
@cd loc-mobile && make install
|
||||
install-loc-mobile : install-librtaputil
|
||||
@make -C loc-mobile install
|
||||
|
||||
## Désinstallation ##
|
||||
|
||||
uninstall : uninstall-librtaputil uninstall-loc-bts uninstall-loc-client
|
||||
uninstall : uninstall-librtaputil uninstall-loc-bts uninstall-loc-mobile
|
||||
|
||||
uninstall-librtaputil :
|
||||
@cd librtaputil && make uninstall
|
||||
uninstall-librtaputil : uninstall-loc-bts uninstall-loc-mobile
|
||||
@make -C librtaputil uninstall
|
||||
|
||||
uninstall-loc-bts :
|
||||
@cd loc-bts && make uninstall
|
||||
@make -C loc-bts uninstall
|
||||
|
||||
uninstall-loc-mobile :
|
||||
@cd loc-mobile && make uninstall
|
||||
@make -C loc-mobile uninstall
|
||||
|
||||
## Nettoyage ##
|
||||
|
||||
clean :
|
||||
@cd librtaputil && make clean
|
||||
@cd loc-bts && make clean
|
||||
@cd loc-mobile && make clean
|
||||
@make -C librtaputil clean
|
||||
@make -C loc-bts clean
|
||||
@make -C loc-mobile clean
|
||||
|
||||
purge :
|
||||
@cd librtaputil && make purge
|
||||
@cd loc-bts && make purge
|
||||
@cd loc-mobile && make purge
|
||||
@make -C librtaputil purge
|
||||
@make -C loc-bts purge
|
||||
@make -C loc-mobile purge
|
||||
|
||||
## Aide ##
|
||||
|
||||
|
|
|
@ -5,51 +5,51 @@
|
|||
all : rtapaggregate ap client
|
||||
|
||||
rtapaggregate :
|
||||
@cd rtapaggregate && make
|
||||
@make -C rtapaggregate
|
||||
|
||||
ap :
|
||||
@cd ap && make
|
||||
@make -C ap
|
||||
|
||||
client :
|
||||
@cd client && make
|
||||
@make -C client
|
||||
|
||||
## Installation ##
|
||||
|
||||
install : install-rtapaggregate install-ap install-client
|
||||
|
||||
install-rtapaggregate : rtapaggregate
|
||||
@cd rtapaggregate && make install
|
||||
install-rtapaggregate :
|
||||
@make -C rtapaggregate install
|
||||
|
||||
install-ap : ap
|
||||
@cd ap && make install
|
||||
install-ap :
|
||||
@make -C ap install
|
||||
|
||||
install-client : client
|
||||
@cd client && make install
|
||||
install-client :
|
||||
@make -C client install
|
||||
|
||||
## Désinstallation ##
|
||||
|
||||
uninstall : uninstall-rtapaggregate uninstall-ap uninstall-client
|
||||
|
||||
uninstall-rtapaggregate :
|
||||
@cd rtapaggregate && make uninstall
|
||||
@make -C rtapaggregate uninstall
|
||||
|
||||
uninstall-ap :
|
||||
@cd ap && make uninstall
|
||||
@make -C ap uninstall
|
||||
|
||||
uninstall-client :
|
||||
@cd client && make uninstall
|
||||
@make -C client uninstall
|
||||
|
||||
## Nettoyage ##
|
||||
|
||||
clean :
|
||||
@cd rtapaggregate && make clean
|
||||
@cd ap && make clean
|
||||
@cd client && make clean
|
||||
@make -C rtapaggregate clean
|
||||
@make -C ap clean
|
||||
@make -C client clean
|
||||
|
||||
purge :
|
||||
@cd rtapaggregate && make purge
|
||||
@cd ap && make purge
|
||||
@cd client && make purge
|
||||
@make -C rtapaggregate purge
|
||||
@make -C ap purge
|
||||
@make -C client purge
|
||||
|
||||
## Aide ##
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ void* monitor_couple_list(couple_list **couples)
|
|||
if (sub_date(couple_ptr->start_time, current_time) > AGGREGATE_TIMEOUT) // Si le timeout est atteint,
|
||||
{
|
||||
printf("* Timeout dépassé.\n") ;
|
||||
fprintf(fd, "%f;%f;%f;%hhd", couple_ptr->x_position, couple_ptr->y_position, couple_ptr->z_position, couple_ptr->direction) ; // Inscription des infos du couple dans le fichier
|
||||
fprintf(fd, "%0.2f;%0.2f;%0.2f;%hhd", couple_ptr->x_position, couple_ptr->y_position, couple_ptr->z_position, couple_ptr->direction) ; // Inscription des infos du couple dans le fichier
|
||||
|
||||
couple_info_ptr = couple_ptr->info ;
|
||||
while (couple_info_ptr != NULL) // On vide la liste des infos
|
||||
|
|
|
@ -1,33 +1,44 @@
|
|||
.PHONY : all librtapscanmob clean purge help install install-librtapscanmob uninstall uninstall-librtapscanmob
|
||||
.PHONY : all librtapscanmob mobile clean purge help install install-librtapscanmob install-mobile uninstall uninstall-librtapscanmob uninstall-mobile
|
||||
|
||||
## Compilation ##
|
||||
|
||||
all : librtapscanmob
|
||||
all : librtapscanmob mobile
|
||||
|
||||
librtapscanmob :
|
||||
@cd librtapscanmob && make
|
||||
@make -C librtapscanmob
|
||||
|
||||
mobile :
|
||||
@make -C mobile
|
||||
|
||||
## Installation ##
|
||||
|
||||
install : install-librtapscanmob
|
||||
install : install-librtapscanmob install-mobile
|
||||
|
||||
install-librtapscanmob : librtapscanmob
|
||||
@cd librtapscanmob && make install
|
||||
install-librtapscanmob :
|
||||
@make -C librtapscanmob install
|
||||
|
||||
install-mobile : install-librtapscanmob
|
||||
@make -C mobile install
|
||||
|
||||
## Désinstallation ##
|
||||
|
||||
uninstall : uninstall-librtapscanmob
|
||||
uninstall : uninstall-librtapscanmob uninstall-mobile
|
||||
|
||||
uninstall-librtapscanmob :
|
||||
@cd librtapscanmob && make uninstall
|
||||
uninstall-librtapscanmob : uninstall-mobile
|
||||
@make -C librtapscanmob uninstall
|
||||
|
||||
uninstall-mobile :
|
||||
@make -C mobile uninstall
|
||||
|
||||
## Nettoyage ##
|
||||
|
||||
clean :
|
||||
@cd librtapscanmob && make clean
|
||||
@make -C librtapscanmob clean
|
||||
@make -C mobile clean
|
||||
|
||||
purge :
|
||||
@cd librtapscanmob && make purge
|
||||
purge : clean
|
||||
@make -C librtapscanmob purge
|
||||
@make -C mobile purge
|
||||
|
||||
## Aide ##
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ VERSION=1.0
|
|||
# Cibles à construire
|
||||
STATIC=$(LIB_CIBLE).a
|
||||
DYNAMIC=$(LIB_CIBLE).so.$(VERSION)
|
||||
PROGS=tx
|
||||
HEADER=rtapscanmob.h
|
||||
#HEADERS=
|
||||
|
||||
|
@ -52,9 +51,6 @@ static : $(STATIC)
|
|||
%.so : %.c $(HEADER)
|
||||
$(CC) $(XCFLAGS) $(PICFLAG) -c -o $@ $<
|
||||
|
||||
# Compilation du programme d'exemple
|
||||
tx : tx.o $(DYNAMIC) $(HEADER)
|
||||
|
||||
# Compilation de la bibliothèque dynamique
|
||||
$(DYNAMIC) : $(OBJS:.o=.so)
|
||||
$(CC) -shared -o $@ -Wl,-soname,$@ $(STRIPFLAGS) $(LIBS) -lc $^
|
||||
|
@ -68,7 +64,7 @@ $(STATIC) : $(OBJS:.o=.so)
|
|||
|
||||
## Installation ##
|
||||
|
||||
install : install-tx install-static install-dynamic
|
||||
install : install-static install-dynamic
|
||||
|
||||
install-dynamic : install-header $(DYNAMIC)
|
||||
@$(CP) $(DYNAMIC) $(INSTALL_LIB) &&\
|
||||
|
@ -86,14 +82,10 @@ install-header : $(HEADER)
|
|||
chmod 644 $(INSTALL_INC)/$(HEADER) &&\
|
||||
chown root:root $(INSTALL_INC)/$(HEADER)
|
||||
|
||||
install-tx : $(PROGS)
|
||||
@$(CP) $(PROGS) $(INSTALL_DIR)
|
||||
@cd $(INSTALL_DIR) ; chown root:root $(PROGS) ; chmod 755 $(PROGS)
|
||||
|
||||
|
||||
## Désinstallation ##
|
||||
|
||||
uninstall : uninstall-dynamic uninstall-static uninstall-tx
|
||||
uninstall : uninstall-static uninstall-dynamic
|
||||
|
||||
uninstall-dynamic : uninstall-header
|
||||
@$(RM) $(INSTALL_LIB)/$(DYNAMIC)
|
||||
|
@ -105,9 +97,6 @@ uninstall-static : uninstall-header
|
|||
uninstall-header :
|
||||
@$(RM) $(INSTALL_INC)/$(HEADER)
|
||||
|
||||
uninstall-tx :
|
||||
@cd $(INSTALL_DIR) && $(RM) $(PROGS)
|
||||
|
||||
|
||||
## Nettoyage ##
|
||||
|
||||
|
@ -123,22 +112,20 @@ purge : clean
|
|||
help :
|
||||
@echo -e "Bibliothèques nécessaires à la compilation :\n\
|
||||
libpcap0.8-dev\n\
|
||||
librtaputil1.0 (fournie)\n\
|
||||
\n\
|
||||
Cibles possibles :\n\
|
||||
all (cible par défaut) : Compile la bibliothèque et le programme d'exemple (tx).\n\
|
||||
all (cible par défaut) : Compile la bibliothèque partagée et statique.\n\
|
||||
dynamic : Compile la bibilothèque partagée (.so).\n\
|
||||
static : Compile la bibliothèque statique (.a).\n\
|
||||
tx : Compile le programme d'exemple.\n\
|
||||
\n\
|
||||
install : Installe la bibliothèque partagée, statique, ainsi que le programme d'exemple.\n\
|
||||
install : Installe la bibliothèque partagée et statique.\n\
|
||||
install-dynamic : N'installe que la bibliothèque partagée.\n\
|
||||
install-static : N'installe que la bibliothèque statique.\n\
|
||||
install-tx : N'installe que le programme d'exemple.\n\
|
||||
\n\
|
||||
uninstall : Désinstalle tout ce qu'il est possible de désinstaller.\n\
|
||||
uninstall-dynamic : Désinstalle la bibliothèque partagée.\n\
|
||||
uninstall-static : Désinstalle la bibliothèque statique.\n\
|
||||
uninstall-tx : Désinstalle le programme d'exemple.\n\
|
||||
\n\
|
||||
clean : Supprime les fichiers temporaires.\n\
|
||||
purge : Supprime le résultat de la compilation.\n\
|
||||
|
|
|
@ -413,7 +413,7 @@ void free_mac_list(mac_list **results)
|
|||
|
||||
|
||||
|
||||
/* Enregistre la liste "results" dans le fichier "file" */
|
||||
/* Enregistre la liste "results" dans le fichier nommé "file" */
|
||||
int write_mac_list_to_file(char *file, mac_list *results)
|
||||
{
|
||||
int fd = 0 ; // Descripteur de fichier.
|
||||
|
@ -454,7 +454,10 @@ int write_mac_list_to_file(char *file, mac_list *results)
|
|||
|
||||
/* Fermeture du fichier */
|
||||
if (close(fd) != 0)
|
||||
perror("Erreur lors de la fermeture du fichier de sortie ") ;
|
||||
{
|
||||
perror("Erreur lors de la fermeture du fichier de sortie ") ;
|
||||
return ERR_CLOSING_FILE ;
|
||||
}
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
@ -462,7 +465,7 @@ int write_mac_list_to_file(char *file, mac_list *results)
|
|||
|
||||
|
||||
|
||||
/* Lit le fichier "file" et enregistre la liste lue dans "results" */
|
||||
/* Lit le fichier nommé "file" et enregistre la liste lue dans "results" */
|
||||
int read_mac_list_from_file(char *file, mac_list **results)
|
||||
{
|
||||
int fd = 0 ; // Descripteur de fichier.
|
||||
|
@ -538,3 +541,60 @@ int read_mac_list_from_file(char *file, mac_list **results)
|
|||
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Enregistre la liste "results" dans le fichier nommé "file", au format texte */
|
||||
int write_mac_list_to_text_file(char *file, mac_list *results, char direction, float pos_x, float pos_y, float pos_z)
|
||||
{
|
||||
FILE *fd = NULL ; // Descripteur de fichier.
|
||||
mac_list *ptr ; // Tête de lecture de la liste chaînée.
|
||||
ss_list *ss_ptr ; // Tête de lecture de la sous-liste.
|
||||
|
||||
|
||||
/* Ouverture du fichier */
|
||||
fd = fopen(file, "a") ; // Ouverture du fichier de sortie en ajout
|
||||
if (fd == NULL) // Si ouverture échouée,
|
||||
{
|
||||
perror("Impossible d'ouvrir le fichier de sortie ") ;
|
||||
fprintf(stderr, "Redirection de la sortie sur la sortie standard.") ;
|
||||
fd = stdout ; // on redirige sur stdout
|
||||
}
|
||||
|
||||
/* Écriture des données */
|
||||
ptr = results ; // On commence par la tête de la liste (forcément...).
|
||||
while (ptr != NULL)
|
||||
{
|
||||
char *mac_string ;
|
||||
|
||||
/* Enregistrement des données fixes */
|
||||
fprintf(fd, "%0.2f;%0.2f;%0.2f;%hhd", pos_x, pos_y, pos_z, direction) ;
|
||||
|
||||
/* Enregistrement du maillon de la liste principale */
|
||||
mac_string = mac_bytes_to_string(ptr->mac_addr_bytes) ;
|
||||
fprintf(fd, ";%s", mac_string) ;
|
||||
|
||||
/* Enregistrement de la sous-liste */
|
||||
ss_ptr = ptr->samples_list ;
|
||||
while (ss_ptr != NULL)
|
||||
{
|
||||
fprintf(fd, ";%d", ss_ptr->antenna_signal_dbm - 0x100) ; // Écriture de la puissance du signal
|
||||
ss_ptr = ss_ptr->next ;
|
||||
}
|
||||
|
||||
fprintf(fd, "\n") ;
|
||||
|
||||
free(mac_string) ;
|
||||
ptr = ptr->next ;
|
||||
}
|
||||
|
||||
/* Fermeture du fichier */
|
||||
if (fclose(fd) != 0)
|
||||
{
|
||||
perror("Erreur lors de la fermeture du fichier de sortie ") ;
|
||||
return ERR_CLOSING_FILE ;
|
||||
}
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ typedef struct _mac_list
|
|||
#define ERR_OPENING_FILE 2 // Erreur lors de l'ouverture du fichier d'entrée ou de sortie
|
||||
#define ERR_OPENING_IFACE 3 // Erreur lors de l'ouverture de l'interface de capture
|
||||
#define ERR_CAPTURE_TIME_FORMAT 4 // Format du temps de capture incorrect
|
||||
#define ERR_CLOSING_FILE 5 // Erreur lors de la fermeture du fichier de sortie
|
||||
|
||||
|
||||
/* En-têtes des fonctions */
|
||||
|
@ -66,6 +67,7 @@ void print_ss_list(ss_list *ss) ;
|
|||
void free_mac_list(mac_list **results) ;
|
||||
int write_mac_list_to_file(char *file, mac_list *results) ;
|
||||
int read_mac_list_from_file(char *file, mac_list **results) ;
|
||||
int write_mac_list_to_text_file(char *file, mac_list *results, char direction, float pos_x, float pos_y, float pos_z) ;
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
# Répertoire d'installation
|
||||
PREFIX=/usr/local
|
||||
INSTALL_DIR= $(PREFIX)/sbin
|
||||
INSTALL_LIB= $(PREFIX)/lib
|
||||
INSTALL_INC= $(PREFIX)/include
|
||||
INSTALL_MAN= $(PREFIX)/share/man
|
||||
|
||||
# Compilateur
|
||||
CC = gcc
|
||||
|
||||
# Commandes d'installation et de désinstallation
|
||||
RM=rm -fv
|
||||
CP=cp -v
|
||||
|
||||
# Cible
|
||||
TARGET=mobile
|
||||
HEADER=
|
||||
|
||||
# Flags
|
||||
CFLAGS=-O2 -W -Wall -Wstrict-prototypes -O -I.
|
||||
DEPFLAGS=-MMD
|
||||
XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS)
|
||||
PICFLAG=-fPIC
|
||||
#LIBS=../../librtaputil/librtaputil.so.1.0 ../librtapscanmob/librtapscanmob.so.1.0
|
||||
LIBS=../librtapscanmob/librtapscanmob.so.1.0
|
||||
|
||||
|
||||
## Cibles de compilation standard ##
|
||||
|
||||
.PHONY : all install uninstall clean purge help
|
||||
|
||||
all : $(TARGET)
|
||||
|
||||
% : %.o
|
||||
$(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS)
|
||||
%.o : %.c $(HEADER)
|
||||
$(CC) $(XCFLAGS) -c $<
|
||||
|
||||
# Compilation du programme
|
||||
$(TARGET) : $(TARGET).o $(HEADER)
|
||||
|
||||
|
||||
## Installation / désinstallation ##
|
||||
|
||||
install : $(TARGET)
|
||||
@$(CP) $(TARGET) $(INSTALL_DIR)
|
||||
@cd $(INSTALL_DIR) ; chown root:root $(TARGET) ; chmod 755 $(TARGET)
|
||||
|
||||
uninstall :
|
||||
@$(RM) $(INSTALL_DIR)/$(TARGET)
|
||||
|
||||
|
||||
## Nettoyage ##
|
||||
|
||||
clean :
|
||||
@$(RM) -fv *~ *.o *.d
|
||||
|
||||
purge : clean
|
||||
@$(RM) -fv $(TARGET)
|
||||
|
||||
|
||||
## Aide ##
|
||||
|
||||
help :
|
||||
@echo "Bibliothèques nécessaires à la compilation :\n\
|
||||
librtaputil1.0 (fournie)\n\
|
||||
librtapscanmob1.0 (fournie)\n\
|
||||
\n\
|
||||
Cibles possibles :\n\
|
||||
$(TARGET) (cible par défaut) : Compile le programme $(TARGET).\n\
|
||||
install : Installe le programme $(TARGET).\n\
|
||||
uninstall : Désinstalle le programme $(TARGET).\n\
|
||||
clean : Supprime les fichiers temporaires.\n\
|
||||
purge : Supprime le résultat de la compilation.\n\
|
||||
\n\
|
||||
Note : l'installation se fait dans l'arborescence $(PREFIX). Modifiez la variable PREFIX du Makefile pour changer ce comportement."
|
|
@ -12,10 +12,9 @@
|
|||
#define DEFAULT_IFACE "rtap0" // Interface de capture par défaut.
|
||||
#define DEFAULT_CAPTURE_TIME 5000 // Temps de capture par défaut en milli-secondes.
|
||||
#define MAX_FILENAME_LENGTH 500 // Longueur maximale du nom des fichiers.
|
||||
#define MAX_IFACENAME_LENGTH 50 // Longueur maximale du nom de l'interface de capture.
|
||||
#define MAX_OPT_LENGTH 5 // Longueur maximale des options sur la ligne de commandes.
|
||||
#define NB_OPTIONS 7 // Nombre d'options.
|
||||
enum {NUM_OPT_HELP, NUM_OPT_IFACE, NUM_OPT_CAPTURE_TIME, NUM_OPT_OUTPUT, NUM_OPT_INPUT, NUM_OPT_VERB, NUM_OPT_VERB2} ; // Liste des numéros d'options.
|
||||
#define MAX_OPT_LENGTH 6 // Longueur maximale des options sur la ligne de commandes.
|
||||
#define NB_OPTIONS 11 // Nombre d'options.
|
||||
enum {NUM_OPT_HELP, NUM_OPT_IFACE, NUM_OPT_CAPTURE_TIME, NUM_OPT_OUTPUT, NUM_OPT_INPUT, NUM_OPT_VERB, NUM_OPT_VERB2, NUM_OPT_DIRECTION, NUM_OPT_POSX, NUM_OPT_POSY, NUM_OPT_POSZ} ; // Liste des numéros d'options.
|
||||
#define OPT_HELP "-h" // Option d'affichage de l'aide.
|
||||
#define OPT_OUTPUT "-o" // Option d'enregistrement des résultats dans un fichier.
|
||||
#define OPT_INPUT "-i" // Option de lecture des trames enregistrées avec -o.
|
||||
|
@ -23,8 +22,13 @@ enum {NUM_OPT_HELP, NUM_OPT_IFACE, NUM_OPT_CAPTURE_TIME, NUM_OPT_OUTPUT, NUM_OPT
|
|||
#define OPT_CAPTURE_TIME "-t" // Option de spécification du temps de capture.
|
||||
#define OPT_VERB "-v" // Option de verbosité.
|
||||
#define OPT_VERB2 "-vv" // Option de verbosité maximale.
|
||||
#define OPT_DIRECTION "-dir" // Option de calibration (direction).
|
||||
#define OPT_POSX "-posx" // Option de calibration (position en X).
|
||||
#define OPT_POSY "-posy" // Option de calibration (position en Y).
|
||||
#define OPT_POSZ "-posz" // Option de calibration (position en Z).
|
||||
#define ERR_BAD_OPTION 50 // Code d'erreur en cas de mauvaise option de ligne de commande.
|
||||
#define ERR_OPT_INPUT_OUTPUT 51 // Erreur d'incompatibilité entre les deux options entrée et sortie de/vers fichier.
|
||||
#define ERR_OPT_CALIBRATION 52 // Erreur si toutes les options de calibration ne sont pas présentes.
|
||||
|
||||
|
||||
|
||||
|
@ -34,7 +38,7 @@ void print_usage(char *prog)
|
|||
printf("Usage :\n\
|
||||
\t%s -h\n\
|
||||
\t%s [ -v ] [ -i fichier ]\n\
|
||||
\t%s [ -v | -vv ] [ -d interface ] [ -t temps ] [ -o fichier ]\n\
|
||||
\t%s [ -v | -vv ] [ -d interface ] [ -t temps ] [ -o fichier ] [ -dir direction -posx x -posy y -posz z ]\n\
|
||||
", prog, prog, prog) ;
|
||||
}
|
||||
|
||||
|
@ -66,6 +70,10 @@ Options :\n\
|
|||
\t-o fichier : enregistre les informations capturées dans le fichier « fichier ».\n\
|
||||
\t-d interface : les paquets sont capturés sur l'interface réseau « interface ». Par défaut, « %s » est utilisée.\n\
|
||||
\t-t temps : les paquets sont capturés pendant « temps » millisecondes. Par défaut, « temps » vaut %d.\n\
|
||||
\t-dir direction : dans le cas de la calibration, indique que la mesure est effectuée vers « direction » (entier de 1 à 4).\n\
|
||||
\t-posx x : dans le cas de la calibration, indique que la position en X du mobile est « x » (flottant).\n\
|
||||
\t-posy y : dans le cas de la calibration, indique que la position en Y du mobile est « y » (flottant).\n\
|
||||
\t-posz z : dans le cas de la calibration, indique que la position en Z du mobile est « z » (flottant).\n\
|
||||
\n\
|
||||
Note : votre interface de capture doit être en mode « monitor », et supporter radiotap.\n\
|
||||
", DEFAULT_IFACE, DEFAULT_CAPTURE_TIME) ;
|
||||
|
@ -74,7 +82,7 @@ Note : votre interface de capture doit être en mode « monitor », et supporter
|
|||
|
||||
|
||||
/* Analyse les options de la ligne de commandes */
|
||||
void read_options(int argc, char **argv, BOOL *options, char *capture_iface, int *capture_time, char *file)
|
||||
void read_options(int argc, char **argv, BOOL *options, char *capture_iface, int *capture_time, char *file, char *direction, float *pos_x, float *pos_y, float *pos_z)
|
||||
{
|
||||
int i ; // Compteur.
|
||||
char num_prev_opt = -1 ; // Numéro de la dernière option lue, si elle prend un argument. Ne doit pas être positionné lors de la lecture des options ne prenant pas d'argument ; doit être repositionnée à -1 après le traitement de l'option.
|
||||
|
@ -96,17 +104,27 @@ void read_options(int argc, char **argv, BOOL *options, char *capture_iface, int
|
|||
case NUM_OPT_OUTPUT :
|
||||
case NUM_OPT_INPUT :
|
||||
strncpy(file, argv[i], MAX_FILENAME_LENGTH) ;
|
||||
num_prev_opt = -1 ;
|
||||
break ;
|
||||
case NUM_OPT_IFACE :
|
||||
strncpy(capture_iface, argv[i], MAX_IFACENAME_LENGTH) ;
|
||||
num_prev_opt = -1 ;
|
||||
strncpy(capture_iface, argv[i], IFNAMSIZ) ;
|
||||
break ;
|
||||
case NUM_OPT_CAPTURE_TIME :
|
||||
*capture_time = atoi(argv[i]) ;
|
||||
num_prev_opt = -1 ;
|
||||
break ;
|
||||
case NUM_OPT_DIRECTION :
|
||||
*direction = atoi(argv[i]) ;
|
||||
break ;
|
||||
case NUM_OPT_POSX :
|
||||
*pos_x = atof(argv[i]) ;
|
||||
break ;
|
||||
case NUM_OPT_POSY :
|
||||
*pos_y = atof(argv[i]) ;
|
||||
break ;
|
||||
case NUM_OPT_POSZ :
|
||||
*pos_z = atof(argv[i]) ;
|
||||
break ;
|
||||
}
|
||||
num_prev_opt = -1 ;
|
||||
}
|
||||
|
||||
else if (strncmp(argv[i], OPT_HELP, MAX_OPT_LENGTH) == 0)
|
||||
|
@ -153,6 +171,30 @@ void read_options(int argc, char **argv, BOOL *options, char *capture_iface, int
|
|||
options[NUM_OPT_VERB2] = TRUE ;
|
||||
}
|
||||
|
||||
else if (strncmp(argv[i], OPT_DIRECTION, MAX_OPT_LENGTH) == 0)
|
||||
{
|
||||
options[NUM_OPT_DIRECTION] = TRUE ;
|
||||
num_prev_opt = NUM_OPT_DIRECTION ;
|
||||
}
|
||||
|
||||
else if (strncmp(argv[i], OPT_POSX, MAX_OPT_LENGTH) == 0)
|
||||
{
|
||||
options[NUM_OPT_POSX] = TRUE ;
|
||||
num_prev_opt = NUM_OPT_POSX ;
|
||||
}
|
||||
|
||||
else if (strncmp(argv[i], OPT_POSY, MAX_OPT_LENGTH) == 0)
|
||||
{
|
||||
options[NUM_OPT_POSY] = TRUE ;
|
||||
num_prev_opt = NUM_OPT_POSY ;
|
||||
}
|
||||
|
||||
else if (strncmp(argv[i], OPT_POSZ, MAX_OPT_LENGTH) == 0)
|
||||
{
|
||||
options[NUM_OPT_POSZ] = TRUE ;
|
||||
num_prev_opt = NUM_OPT_POSZ ;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
print_usage_only(argv[0]) ;
|
||||
|
@ -176,6 +218,12 @@ void read_options(int argc, char **argv, BOOL *options, char *capture_iface, int
|
|||
print_usage_only(argv[0]) ;
|
||||
exit(ERR_OPT_INPUT_OUTPUT) ;
|
||||
}
|
||||
if (! (options[NUM_OPT_DIRECTION] && options[NUM_OPT_POSX] && options[NUM_OPT_POSY] && options[NUM_OPT_POSZ]))
|
||||
{
|
||||
fprintf(stderr, "Vous devez spécifier toutes les options de calibration ou aucune !\n") ;
|
||||
print_usage_only(argv[0]) ;
|
||||
exit(ERR_OPT_CALIBRATION) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -183,14 +231,16 @@ void read_options(int argc, char **argv, BOOL *options, char *capture_iface, int
|
|||
int main(int argc, char **argv)
|
||||
{
|
||||
BOOL options[NB_OPTIONS] ; // Tableau des options présentes.
|
||||
char capture_iface[MAX_IFACENAME_LENGTH] = DEFAULT_IFACE ; // Interface d'entrée
|
||||
char capture_iface[IFNAMSIZ] = DEFAULT_IFACE ; // Interface d'entrée
|
||||
int capture_time = DEFAULT_CAPTURE_TIME ; // Temps de capture
|
||||
char file[MAX_FILENAME_LENGTH] = "\0" ; // Nom du fichier à lire ou écrire.
|
||||
char direction = 0 ; // Direction de la calibration.
|
||||
float pos_x = 0, pos_y = 0, pos_z = 0 ; // Positions de la calibration.
|
||||
mac_list *results = NULL ;
|
||||
int ret = 0 ; // Valeur de retour des fonctions appelées.
|
||||
|
||||
/* Lecture des options de la ligne de commande */
|
||||
read_options(argc, argv, options, capture_iface, &capture_time, file) ;
|
||||
read_options(argc, argv, options, capture_iface, &capture_time, file, &direction, &pos_x, &pos_y, &pos_z) ;
|
||||
|
||||
if (options[NUM_OPT_INPUT] == TRUE) // Si l'option INPUT est présente,
|
||||
{
|
||||
|
@ -209,7 +259,8 @@ int main(int argc, char **argv)
|
|||
print_mac_list(results, options[NUM_OPT_VERB2]) ; // Affichage des paquets capturés.
|
||||
|
||||
if (options[NUM_OPT_OUTPUT] == TRUE) // Si l'option OUTPUT est présente,
|
||||
ret = write_mac_list_to_file(file, results) ;
|
||||
// ret = write_mac_list_to_file(file, results) ;
|
||||
ret = write_mac_list_to_text_file(file, results, direction, pos_x, pos_y, pos_z) ;
|
||||
|
||||
free_mac_list(&results) ; // Nettoyage
|
||||
|
Loading…
Reference in New Issue