[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:
Matteo Cypriani 2010-03-16 17:12:19 +01:00
parent b35a0e1e7c
commit bd789cd4a1
3 changed files with 29 additions and 13 deletions

View File

@ -27,25 +27,30 @@ 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_USR)/lib/ -I$(TOOLCHAIN_USR_2)/lib/
IATHEROS=-I$(TOOLCHAIN_USR)/include/ -I$(TOOLCHAIN_USR_2)/include/
LIBS = -lm -lpcap -liw
LOWLPS = -L../../libowlps -lowlps
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 ##
.PHONY : all install uninstall clean purge help
.PHONY : all static semistatic install uninstall clean purge help
all : $(TARGET)
static : $(TARGET).static
semistatic : $(TARGET).semistatic
% : %.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)
$(CC) $(XCFLAGS) $(IATHEROS) -c $<
# Compilation du programme
$(TARGET) : $(TARGET).o $(HEADER)
## Installation / désinstallation ##
@ -63,7 +68,7 @@ clean :
@$(RM) -fv *~ *.o *.d
purge : clean
@$(RM) -fv $(TARGET)
@$(RM) -fv $(TARGET) $(TARGET).static $(TARGET).semistatic
## Aide ##

View File

@ -8,7 +8,6 @@
// 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?
#define DEBUG
@ -17,14 +16,26 @@
#include <pcap.h>
#ifdef USE_CONFIG_FILE
#include <confuse.h>
# include <confuse.h>
#endif // USE_CONFIG_FILE
#ifdef USE_PTHREAD
#include <pthread.h>
# include <pthread.h>
#endif // USE_PTHREAD
#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() :
#include <netinet/if_ether.h>

View File

@ -454,7 +454,7 @@ void read_packet(u_char *args, const struct pcap_pkthdr *header, const u_char *p
check[i] = FALSE ;
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)
{