Commit a1ff32b6 authored by Mike Hibler's avatar Mike Hibler

Add -N option to add in all ethernet overhead including the 24 invisible

bytes of framing+CRC

Add pcapper.noevents target to Makefile to build without event system
parent 58b19baf
......@@ -19,35 +19,51 @@ PTHREADCFLAGS = -D_THREAD_SAFE -I/usr/local/include/pthread/linuxthreads
PTHREADLIBS = -L/usr/local/lib -llthread -llgcc_r
ELVINFLAGS = `elvin-config --cflags vin4c`
ELVINLIBS = -L/usr/local/lib -lvin4c -lvin4 -lssl -lcrypto -lm
ELVINLIBS = `elvin-config --libs vin4c`
EVENTFLAGS = -DEVENTSYS -I$(TESTBED_SRCDIR)/event/lib $(ELVINFLAGS)
EVENTOBJS = $(OBJDIR)/event/lib/event.o $(OBJDIR)/event/lib/util.o
EVENTLIBS = $(ELVINLIBS)
TBCFLAGS = -I$(TESTBED_SRCDIR)/event/lib -I$(TESTBED_SRCDIR)/lib/libtb
TBLIBS = $(OBJDIR)/event/lib/event.o $(OBJDIR)/event/lib/util.o \
$(OBJDIR)/lib/libtb/libtb.a
TBCFLAGS = $(EVENTFLAGS) -I$(TESTBED_SRCDIR)/lib/libtb
TBLIBS = $(EVENTOBJS) $(OBJDIR)/lib/libtb/libtb.a $(EVENTLIBS)
PCAPLIBS=-lpcap
CFLAGS = -Wall -static $(PTHREADCFLAGS) $(TBCFLAGS) $(ELVINFLAGS) \
-DEVENTSYS -DEMULAB -g -DDROPROOT -DBOSSNODE=\"@BOSSNODE@\"
CFLAGS = -Wall -static $(PTHREADCFLAGS) \
-DEMULAB -g -DDROPROOT -DBOSSNODE=\"@BOSSNODE@\"
LDFLAGS = -static
CFLAGS_FREEBSD = $(CFLAGS)
CLAGS_LINUX = $(CLAGS) -I/usr/include/pcap
LIBS = $(PTHREADLIBS) $(TBLIBS) $(ELVINLIBS) $(PCAPLIBS)
CFLAGS_FBSD = $(CFLAGS) $(TBCFLAGS)
CFLAGS_FBSD_NE = $(CFLAGS)
CFLAGS_LINUX = $(CFLAGS) -I/usr/include/pcap
LIBS_FBSD = $(PTHREADLIBS) $(TBLIBS) $(PCAPLIBS)
LIBS_FBSD_NE = $(PTHREADLIBS) $(PCAPLIBS)
LIBS_LINUX = -L/usr/lib -lpthread -lpcap
clean:
-rm pcapper pcapper.linux
-rm -f pcapper*.o pcapper pcapper.noevents pcapper.linux *.debug
pcapper: GNUmakefile pcapper.o
$(CC) $(LDFLAGS) $(CFLAGS_FREEBSD) pcapper.o $(LIBS) \
-o pcapper
$(CC) $(LDFLAGS) $(CFLAGS_FBSD) pcapper.o $(LIBS_FBSD) -o pcapper
cp pcapper pcapper.debug
strip pcapper
pcapper.o: pcapper.c
$(CC) -c -o pcapper.o $(CFLAGS_FBSD) $<
pcapper.noevents: GNUmakefile pcapper-noevents.o
$(CC) $(LDFLAGS) $(CFLAGS_FBSD_NE) pcapper-noevents.o $(LIBS_FBSD_NE) \
-o pcapper.noevents
cp pcapper.noevents pcapper.noevents.debug
strip pcapper.noevents
pcapper-noevents.o: pcapper.c
$(CC) -c -o pcapper-noevents.o $(CFLAGS_FBSD_NE) $<
#
# Note: Building on Linux with the event system is mighty tricky
#
pcapper.linux: pcapper.c GNUmakefile
$(CC) $(CFLAGS) $(CPPFLAGS_LINUX) -L/usr/lib -lpthread -lpcap \
pcapper.c -o pcapper.linux -lpcap
$(CC) $(CFLAGS_LINUX) $(CPPFLAGS_LINUX) $(LIBS_LINUX) pcapper.c \
-o pcapper.linux
......@@ -72,6 +72,12 @@
*/
#define CONTROL_IFACE "/etc/testbed/control_interface"
/*
* Wire overhead not seen by pcapper:
* interframe gap (12) + preamble (8) + CRC (4)
*/
#define INVISIBLE_ETHSIZE 24
/*
* A struct definitions shamelessly stolen from tcpdump.org
*/
......@@ -179,6 +185,11 @@ int payload_only = 0;
*/
int add_ethernet = 0;
/*
* Nonzero if we're supposed to add ALL ethernet overhead to the packet size
*/
int add_all_ethernet = 0;
/*
* Nonzero if we're supposed to _not_ count zero-sized packets in the
* packet counts (obviously, they're already ignored in the byte counts.
......@@ -247,6 +258,7 @@ void usage(char *progname) {
"(in ms) to report\n"
"-p Count only payload (not header) size\n"
"-n Add in ethernet header size\n"
"-N Add in all ethernet overhead\n"
"-z Don't count zero-length packets\n"
"-o Print output to stdout\n"
#ifdef EVENTSYS
......@@ -309,7 +321,7 @@ int main (int argc, char **argv) {
/*
* Process command-line arguments
*/
while ((ch = getopt(argc, argv, "f:i:e:hpnzs:o")) != -1)
while ((ch = getopt(argc, argv, "f:i:e:hpnNzs:o")) != -1)
switch(ch) {
case 'f':
/* Find the first empty slot */
......@@ -325,6 +337,9 @@ int main (int argc, char **argv) {
case 'n':
add_ethernet = 1;
break;
case 'N':
add_all_ethernet = 1;
break;
case 'z':
no_zero = 1;
break;
......@@ -1010,6 +1025,9 @@ void got_packet(u_char *args, const struct pcap_pkthdr *header,
length = ntohs(ip_pkt->ip_len);
} else {
length = ntohs(ip_pkt->ip_len) + sizeof (struct sniff_ethernet);
if (add_all_ethernet) {
length += INVISIBLE_ETHSIZE;
}
}
type = ip_pkt->ip_p;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment