[Listener] Fix compilation on Atheros
Makefile_atheros: - Add target 'static' to compile fully statically. (Note: does not work in the OpenWRT 8.09 cross-compilation suite, since it does not provide libiw.a) - Add target 'semistatic', that compiles with static libowlps and dynamic libiw and libpcap. Fix (mostly) endianess issues: - le32toh() is defined only in glibc >= 2.9, so owlps-listener did not compile with older glibc or other libc (such as uClibc that we use to cross-compile to OpenWRT). We now define le32toh() manually, if needed. - Additionally, the PLATFORM_ATHEROS define is removed. We should now test the value of __BYTE_ORDER if needed.
This commit is contained in:
parent
b35a0e1e7c
commit
bd789cd4a1
|
@ -27,25 +27,30 @@ CFLAGS=-O2 -W -Wall -Wstrict-prototypes -O -I.
|
||||||
DEPFLAGS=-MMD
|
DEPFLAGS=-MMD
|
||||||
XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS)
|
XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS)
|
||||||
PICFLAG=-fPIC
|
PICFLAG=-fPIC
|
||||||
LIBS=-lm -lpcap -liw ../../libowlps/libowlps.so.1.0
|
LIBS = -lm -lpcap -liw
|
||||||
LATHEROS=-L$(TOOLCHAIN_USR)/lib/ -I$(TOOLCHAIN_USR_2)/lib/
|
LOWLPS = -L../../libowlps -lowlps
|
||||||
IATHEROS=-I$(TOOLCHAIN_USR)/include/ -I$(TOOLCHAIN_USR_2)/include/
|
LOWLPSA = ../../libowlps/libowlps.a
|
||||||
|
LATHEROS = -L$(TOOLCHAIN_USR)/lib -L$(TOOLCHAIN_USR_2)/lib
|
||||||
|
IATHEROS = -I$(TOOLCHAIN_USR)/include -I$(TOOLCHAIN_USR_2)/include
|
||||||
|
|
||||||
|
|
||||||
## Cibles de compilation standard ##
|
## Cibles de compilation standard ##
|
||||||
|
|
||||||
.PHONY : all install uninstall clean purge help
|
.PHONY : all static semistatic install uninstall clean purge help
|
||||||
|
|
||||||
all : $(TARGET)
|
all : $(TARGET)
|
||||||
|
static : $(TARGET).static
|
||||||
|
semistatic : $(TARGET).semistatic
|
||||||
|
|
||||||
% : %.o
|
% : %.o
|
||||||
$(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS) $(IATHEROS) $(LATHEROS)
|
$(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS) $(LOWLPS) $(IATHEROS) $(LATHEROS)
|
||||||
|
%.static : %.o
|
||||||
|
$(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS) $(LOWLPS) $(IATHEROS) $(LATHEROS) -static
|
||||||
|
%.semistatic : %.o
|
||||||
|
$(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS) $(LOWLPSA) $(IATHEROS) $(LATHEROS)
|
||||||
%.o : %.c $(HEADER)
|
%.o : %.c $(HEADER)
|
||||||
$(CC) $(XCFLAGS) $(IATHEROS) -c $<
|
$(CC) $(XCFLAGS) $(IATHEROS) -c $<
|
||||||
|
|
||||||
# Compilation du programme
|
|
||||||
$(TARGET) : $(TARGET).o $(HEADER)
|
|
||||||
|
|
||||||
|
|
||||||
## Installation / désinstallation ##
|
## Installation / désinstallation ##
|
||||||
|
|
||||||
|
@ -63,7 +68,7 @@ clean :
|
||||||
@$(RM) -fv *~ *.o *.d
|
@$(RM) -fv *~ *.o *.d
|
||||||
|
|
||||||
purge : clean
|
purge : clean
|
||||||
@$(RM) -fv $(TARGET)
|
@$(RM) -fv $(TARGET) $(TARGET).static $(TARGET).semistatic
|
||||||
|
|
||||||
|
|
||||||
## Aide ##
|
## Aide ##
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
// Compilation-time options (comment-out to unactivate)
|
// Compilation-time options (comment-out to unactivate)
|
||||||
#define USE_CONFIG_FILE // Use libconfuse to read a config file
|
#define USE_CONFIG_FILE // Use libconfuse to read a config file
|
||||||
#define USE_PTHREAD // POSIX threads available?
|
#define USE_PTHREAD // POSIX threads available?
|
||||||
//#define PLATFORM_ATHEROS // Will we compile to an Atheros platform?
|
|
||||||
|
|
||||||
#define DEBUG
|
#define DEBUG
|
||||||
|
|
||||||
|
@ -17,14 +16,26 @@
|
||||||
#include <pcap.h>
|
#include <pcap.h>
|
||||||
|
|
||||||
#ifdef USE_CONFIG_FILE
|
#ifdef USE_CONFIG_FILE
|
||||||
#include <confuse.h>
|
# include <confuse.h>
|
||||||
#endif // USE_CONFIG_FILE
|
#endif // USE_CONFIG_FILE
|
||||||
|
|
||||||
#ifdef USE_PTHREAD
|
#ifdef USE_PTHREAD
|
||||||
#include <pthread.h>
|
# include <pthread.h>
|
||||||
#endif // USE_PTHREAD
|
#endif // USE_PTHREAD
|
||||||
|
|
||||||
#include <endian.h>
|
#include <endian.h>
|
||||||
|
/* <endian.h> defines le32toh only in glibc >= 2.9. If we use an older
|
||||||
|
* version of glibc, or another libc (e.g. uClibc), we must define it
|
||||||
|
* manually.
|
||||||
|
*/
|
||||||
|
#ifndef le32toh
|
||||||
|
# if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||||
|
# define le32toh(x) (x)
|
||||||
|
# else // __BYTE_ORDER == __LITTLE_ENDIAN
|
||||||
|
# include <byteswap.h>
|
||||||
|
# define le32toh(x) bswap_32(x)
|
||||||
|
# endif // __BYTE_ORDER == __LITTLE_ENDIAN
|
||||||
|
#endif // le32toh
|
||||||
|
|
||||||
// Pour la fonction get_mac_addr() :
|
// Pour la fonction get_mac_addr() :
|
||||||
#include <netinet/if_ether.h>
|
#include <netinet/if_ether.h>
|
||||||
|
|
|
@ -454,7 +454,7 @@ void read_packet(u_char *args, const struct pcap_pkthdr *header, const u_char *p
|
||||||
check[i] = FALSE ;
|
check[i] = FALSE ;
|
||||||
rtap_position = 8 ; // Début des champs déterminés par le present flag
|
rtap_position = 8 ; // Début des champs déterminés par le present flag
|
||||||
|
|
||||||
for(i=0 ; i < 15 ; i++) // on teste les 15 premiers bits du champ flag afin de valider la présence et de les copier
|
for (i=0 ; i < 15 ; i++) // on teste les 15 premiers bits du champ flag afin de valider la présence et de les copier
|
||||||
{
|
{
|
||||||
if ((rtap_presentflags % 2) == 1)
|
if ((rtap_presentflags % 2) == 1)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue