From f8ff9f6794d1e7370c3002a23d51fc6e9868f5be Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Mon, 9 Nov 2009 10:42:23 +0100 Subject: [PATCH] [Listener] Endianess (beginning) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Last (uncommited) changes in the SVN repo (1/2): - Endianess in owlps-listener : use of le32toh(). /!\ *Not* sure it works ! /!\ --- .../owlps-listener/owlps-listener.h | 2 ++ .../owlps-listener/owlps-listenerd.c | 15 ++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/infrastructure-centred/owlps-listener/owlps-listener.h b/infrastructure-centred/owlps-listener/owlps-listener.h index dd920a9..d4e2a85 100644 --- a/infrastructure-centred/owlps-listener/owlps-listener.h +++ b/infrastructure-centred/owlps-listener/owlps-listener.h @@ -24,6 +24,8 @@ #include #endif // USE_PTHREAD +#include + // Pour la fonction get_mac_addr() : #include #include diff --git a/infrastructure-centred/owlps-listener/owlps-listenerd.c b/infrastructure-centred/owlps-listener/owlps-listenerd.c index cab7635..3830403 100644 --- a/infrastructure-centred/owlps-listener/owlps-listenerd.c +++ b/infrastructure-centred/owlps-listener/owlps-listenerd.c @@ -28,6 +28,7 @@ struct { // structure qui servira à stocker les options getopt MODE_ACTIVE, "127.0.0.1", AGGREGATE_DEFAULT_PORT, + LOC_REQUEST_DEFAULT_PORT, #ifdef USE_PTHREAD FALSE, #endif // USE_PTHREAD @@ -442,11 +443,15 @@ void read_packet(u_char *args, const struct pcap_pkthdr *header, const u_char *p /* Traitement de l'en-tête Radiotap */ - // TODO : traiter le boutisme avec ntohs - 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 + memcpy(&rtap_presentflags, &data[RTAP_P_PRESENTFLAGS], RTAP_L_PRESENTFLAGS) ; // Récupère les flags de l'en-tête rtap + // Note : on récupère les flags en big-endian (net-endianess), mais on + // travaille dessus comme si c'était du little-endian. Cela nous permet + // de déclarer un tableau de seulement 15 bits (au lieu de 32) car ce + // sont ces bits (de poids faible) qui nous intéressent. C'est un peu de + // la triche :-) + // Du coup, sur les architectures big-endian, il faut retourner les bits + // en faisant comme si on avait récupéré les flags en little-endian : + rtap_presentflags = le32toh(rtap_presentflags) ; for (i = 0 ; i < 15 ; i++) // Initialisation de la structure des champs présents check[i] = FALSE ;