diff --git a/infrastructure-centred/owlps-listener/Makefile_atheros b/infrastructure-centred/owlps-listener/Makefile_atheros new file mode 100644 index 0000000..c1f58d4 --- /dev/null +++ b/infrastructure-centred/owlps-listener/Makefile_atheros @@ -0,0 +1,80 @@ +# Emplacement de la suite de cross-compilation +TOOLCHAIN = /home/banc/atheros/8.09/staging_dir + +# 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 = $(TOOLCHAIN)/toolchain-mips_gcc4.1.2/bin/mips-linux-gcc + +# Commandes d'installation et de désinstallation +RM=rm -fv +CP=cp -v + +# Cible +TARGET=owlps-listenerd +HEADER=owlps-listener.h + +# Flags +CFLAGS=-O2 -W -Wall -Wstrict-prototypes -O -I. +DEPFLAGS=-MMD +XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) +PICFLAG=-fPIC +LIBS=-lm -lpcap -liw ../../libowlps/libowlps.so.1.0 +LATHEROS=-L$(TOOLCHAIN)/mips/usr/lib/ +IATHEROS=-I$(TOOLCHAIN)/mips/usr/include/ + + +## Cibles de compilation standard ## + +.PHONY : all install uninstall clean purge help + +all : $(TARGET) + +% : %.o + $(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS) $(IATHEROS) $(LATHEROS) +%.o : %.c $(HEADER) + $(CC) $(XCFLAGS) $(IATHEROS) -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 -e "Bibliothèques nécessaires à la compilation :\n\ + libpcap0.8-dev\n\ + libowlps1.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." diff --git a/infrastructure-centred/owlps-listener/TODO b/infrastructure-centred/owlps-listener/TODO new file mode 100644 index 0000000..b7d1521 --- /dev/null +++ b/infrastructure-centred/owlps-listener/TODO @@ -0,0 +1,3 @@ +* 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. diff --git a/infrastructure-centred/owlps-listener/owlps-listener.h b/infrastructure-centred/owlps-listener/owlps-listener.h index 66751a0..007443a 100644 --- a/infrastructure-centred/owlps-listener/owlps-listener.h +++ b/infrastructure-centred/owlps-listener/owlps-listener.h @@ -8,6 +8,7 @@ // Compilation-time options (comment-out to unactivate) #define USE_CONFIG_FILE // Use libconfuse to read a config file #define USE_PTHREAD // POSIX threads available? +//#define PLATFORM_ATHEROS // Will we compile to an Atheros platform? #include "../../libowlps/owlps.h" diff --git a/infrastructure-centred/owlps-listener/owlps-listenerd.c b/infrastructure-centred/owlps-listener/owlps-listenerd.c index fbbe1eb..a084e73 100644 --- a/infrastructure-centred/owlps-listener/owlps-listenerd.c +++ b/infrastructure-centred/owlps-listener/owlps-listenerd.c @@ -273,9 +273,19 @@ void read_packet(u_char *args, const struct pcap_pkthdr *header, const u_char *p int i ; // Compteur memcpy(&rtap_bytes, &data[2], sizeof(unsigned short)) ; // Recopie les deux octets à partir du troisième octet de donnée qui est la taille de l'en-tête rtap (change avec des flags) +#ifdef PLATFORM_ATHEROS + rtap_bytes = ((rtap_bytes & 0xff00) >> 8) + ((rtap_bytes & 0xff) << 8) ; +#endif // PLATFORM_ATHEROS + raw_packet_type = data[rtap_bytes] ; // Au bout de l'en-tête rtap il y a celle du 802.11 dont le premier determine le type (beacon ou pas) + +#ifdef PLATFORM_ATHEROS + memcpy((unsigned char*) &dst_port, &data[rtap_bytes + IEEE80211_HEADER_SIZE + LLC_HEADER_SIZE + IP_HEADER_SIZE + 2], 2) ; // On récupère le port de destination +#else // PLATFORM_ATHEROS memcpy((unsigned char*) &dst_port, &data[rtap_bytes + IEEE80211_HEADER_SIZE + LLC_HEADER_SIZE + IP_HEADER_SIZE + 3], 1) ; // On récupère le port de destination (mais il faut retourner les deux octets) memcpy(&((unsigned char*) &dst_port)[1], &data[rtap_bytes + IEEE80211_HEADER_SIZE + LLC_HEADER_SIZE + IP_HEADER_SIZE + 2], 1) ; // Port de destination = troisième et quatrième octets suivant l'en-tête IP. +#endif // PLATFORM_ATHEROS + raw_packet_flags = data[rtap_bytes+1] ; // On récupère les flags 802.11, qui sont dans l'en-tête 802.11. #ifdef DEBUG @@ -333,6 +343,9 @@ void read_packet(u_char *args, const struct pcap_pkthdr *header, const u_char *p memcpy(&rtap_presentflags, &data[RTAP_P_PRESENTFLAGS], RTAP_L_PRESENTFLAGS); // Récupère les flags de l'en-tête rtap +#ifdef PLATFORM_ATHEROS + rtap_presentflags = ((rtap_presentflags & 0xff000000) >> 24) + ((rtap_presentflags & 0xff0000) >> 8) + ((rtap_presentflags & 0xff00) << 8) + ((rtap_presentflags & 0xff) << 24) ; +#endif // PLATFORM_ATHEROS for (i = 0 ; i < 15 ; i++) // Initialisation de la structure des champs présents check[i] = FALSE ;