Browse Source

Import upstream version 3.0.1

Aaron Turner 17 years ago
parent
commit
d3840888d1
66 changed files with 2662 additions and 2323 deletions
  1. 1 0
      Makefile.in
  2. 2305 2053
      configure
  3. 106 60
      configure.in
  4. 18 1
      docs/CHANGELOG
  5. 1 0
      docs/Makefile.in
  6. 1 0
      lib/Makefile.in
  7. 1 0
      libopts/Makefile.in
  8. 1 0
      scripts/Makefile.in
  9. BIN
      src/._defines.h.in
  10. BIN
      src/._send_packets.c
  11. BIN
      src/._tcpprep.c
  12. BIN
      src/._tcpreplay.c
  13. BIN
      src/._tcpreplay.h
  14. 1 0
      src/Makefile.in
  15. BIN
      src/common/._cidr.c
  16. BIN
      src/common/._cidr.h
  17. BIN
      src/common/._timer.h
  18. BIN
      src/common/._xX.c
  19. 1 0
      src/common/Makefile.in
  20. 16 15
      src/common/cidr.c
  21. 3 3
      src/common/cidr.h
  22. 13 13
      src/common/err.c
  23. 13 22
      src/common/err.h
  24. 2 2
      src/common/get.c
  25. 14 11
      src/common/interface.c
  26. 1 1
      src/common/svn_version.c
  27. 6 14
      src/common/timer.c
  28. 42 35
      src/common/timer.h
  29. 13 13
      src/common/xX.c
  30. 3 3
      src/config.h.in
  31. 4 4
      src/defines.h
  32. 1 1
      src/defines.h.in
  33. BIN
      src/flow/._flownode.c
  34. 1 0
      src/flow/Makefile.in
  35. 2 2
      src/flowreplay.1
  36. 1 1
      src/flowreplay_opts.c
  37. 1 1
      src/flowreplay_opts.h
  38. 21 9
      src/send_packets.c
  39. 2 2
      src/tcpbridge.1
  40. 5 2
      src/tcpbridge.c
  41. 1 1
      src/tcpbridge_opts.c
  42. 1 1
      src/tcpbridge_opts.h
  43. BIN
      src/tcpedit/._edit_packet.c
  44. 1 0
      src/tcpedit/Makefile.in
  45. BIN
      src/tcpedit/plugins/dlt_en10mb/._en10mb.c
  46. BIN
      src/tcpedit/plugins/dlt_en10mb/._en10mb.h
  47. 5 5
      src/tcpedit/plugins/dlt_en10mb/en10mb.c
  48. 3 4
      src/tcpedit/plugins/dlt_hdlc/hdlc.c
  49. 2 2
      src/tcpedit/tcpedit.c
  50. 1 1
      src/tcpedit/tcpedit_stub.h
  51. 2 2
      src/tcpprep.1
  52. 2 7
      src/tcpprep.c
  53. 1 1
      src/tcpprep_opts.c
  54. 1 1
      src/tcpprep_opts.h
  55. 2 2
      src/tcpreplay.1
  56. 6 9
      src/tcpreplay.c
  57. 24 8
      src/tcpreplay_opts.c
  58. 1 0
      src/tcpreplay_opts.def
  59. 3 1
      src/tcpreplay_opts.h
  60. 2 2
      src/tcprewrite.1
  61. 1 6
      src/tcprewrite.c
  62. 1 1
      src/tcprewrite_opts.c
  63. 1 1
      src/tcprewrite_opts.h
  64. 1 0
      test/Makefile.in
  65. BIN
      test/test2.rewrite_config
  66. BIN
      test/test2.rewrite_pnat

+ 1 - 0
Makefile.in

@@ -135,6 +135,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@
 PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@
 PRINTF = @PRINTF@
 PRINTF = @PRINTF@
 RANLIB = @RANLIB@
 RANLIB = @RANLIB@
+SED = @SED@
 SET_MAKE = @SET_MAKE@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SHELL = @SHELL@
 STRIP = @STRIP@
 STRIP = @STRIP@

File diff suppressed because it is too large
+ 2305 - 2053
configure


+ 106 - 60
configure.in

@@ -1,5 +1,5 @@
 
 
-dnl $Id: configure.in 1808 2007-04-15 01:46:13Z aturner $
+dnl $Id: configure.in 1857 2007-05-02 05:07:52Z aturner $
 
 
 AC_INIT(tcpreplay)
 AC_INIT(tcpreplay)
 AC_CONFIG_SRCDIR(src/tcpreplay.c)
 AC_CONFIG_SRCDIR(src/tcpreplay.c)
@@ -7,12 +7,11 @@ AM_CONFIG_HEADER(src/config.h)
 AC_CONFIG_AUX_DIR(config)
 AC_CONFIG_AUX_DIR(config)
 AM_MAINTAINER_MODE
 AM_MAINTAINER_MODE
 AM_WITH_DMALLOC
 AM_WITH_DMALLOC
-AC_PROG_LIBTOOL
 
 
 dnl Set version info here!
 dnl Set version info here!
 MAJOR_VERSION=3
 MAJOR_VERSION=3
 MINOR_VERSION=0
 MINOR_VERSION=0
-MICRO_VERSION=RC1
+MICRO_VERSION=1
 TCPREPLAY_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
 TCPREPLAY_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
 
 
 dnl Release is only used for the RPM spec file
 dnl Release is only used for the RPM spec file
@@ -23,7 +22,8 @@ AC_DEFINE_UNQUOTED(VERSION, "$TCPREPLAY_VERSION", [What is our version?])
 AC_SUBST(TCPREPLAY_VERSION)
 AC_SUBST(TCPREPLAY_VERSION)
 AC_SUBST(TCPREPLAY_RELEASE)
 AC_SUBST(TCPREPLAY_RELEASE)
 
 
-CFLAGS="$CFLAGS -Wall -O2 -funroll-loops -std=gnu99"
+USER_CFLAGS=$CFLAGS
+CFLAGS="${CFLAGS} -Wall -O3 -std=gnu99"
 
 
 dnl Determine OS
 dnl Determine OS
 AC_CANONICAL_BUILD
 AC_CANONICAL_BUILD
@@ -54,11 +54,28 @@ AC_PROG_CPP
 AC_PROG_LN_S
 AC_PROG_LN_S
 AC_PROG_RANLIB
 AC_PROG_RANLIB
 AC_PROG_AWK
 AC_PROG_AWK
+AC_PROG_SED
 AC_PROG_MAKE_SET
 AC_PROG_MAKE_SET
 AC_EXEEXT
 AC_EXEEXT
 AC_PATH_PROG(PRINTF, printf)
 AC_PATH_PROG(PRINTF, printf)
 AC_PATH_PROG(AUTOGEN, autogen)
 AC_PATH_PROG(AUTOGEN, autogen)
 
 
+dnl check autogen version
+if test -n "${AUTOGEN}" ; then
+	AC_MSG_CHECKING(for autogen version >= 5.9)
+	AUTOGEN_VERSION=`${AUTOGEN} -v | ${SED} 's|.*\([[0-9\.]]\{3,\}\)$|\1|'`
+	AUTOGEN_MAJOR=`echo ${AUTOGEN_VERSION} | ${SED} 's|^\([[0-9]]\)\.[[0-9]]|\1|'`
+	AUTOGEN_MINOR=`echo ${AUTOGEN_VERSION} | ${SED} 's|^\([[0-9]]\)\.\([[0-9]]\)|\2|'`
+	if test ${AUTOGEN_MAJOR} -le 5 && test ${AUTOGEN_MINOR} -lt 9 || test ${AUTOGEN_MAJOR} -lt 5 ; then
+		AC_MSG_RESULT(no)
+		AC_MSG_WARN([${AUTOGEN} is too old (${AUTOGEN_VERSION}) for building from SVN.  Please upgrade to 5.9)])
+	else
+		AC_MSG_RESULT(yes)
+	fi
+else
+	AC_MSG_WARN([Please install autogen >= 5.9 if you are building from SVN])
+fi
+
 AC_HEADER_STDC
 AC_HEADER_STDC
 AC_HEADER_MAJOR
 AC_HEADER_MAJOR
 
 
@@ -158,7 +175,7 @@ AC_ARG_ENABLE(debug,
     AC_HELP_STRING([--enable-debug], [Enable debugging code and support for the -d option]),
     AC_HELP_STRING([--enable-debug], [Enable debugging code and support for the -d option]),
     [ if test x$enableval = xyes; then
     [ if test x$enableval = xyes; then
         debug=yes
         debug=yes
-	CFLAGS="-ggdb -std=gnu99 -Wall $wextra $wfatal_errors $wno_variadic_macros"
+	CFLAGS="${USER_CFLAGS} -ggdb -std=gnu99 -Wall $wextra $wfatal_errors $wno_variadic_macros"
 # We may also want to add:
 # We may also want to add:
 #         -Wformat-security -Wswitch-default -Wunused-paramter -Wpadded"
 #         -Wformat-security -Wswitch-default -Wunused-paramter -Wpadded"
          AC_SUBST(debug_flag)
          AC_SUBST(debug_flag)
@@ -288,41 +305,68 @@ AC_ARG_ENABLE(flowreplay,
 AM_CONDITIONAL([ENABLE_FLOWREPLAY], [test x$flowreplay = xyes])
 AM_CONDITIONAL([ENABLE_FLOWREPLAY], [test x$flowreplay = xyes])
 
 
 dnl ##################################################
 dnl ##################################################
-dnl Checks for libnet (shamelessly horked from dsniff)
+dnl Checks for libnet IFF you specify --enable-libnet.
+dnl We no longer by default use libnet unless you tell me to.
 dnl ##################################################
 dnl ##################################################
 foundnet=no
 foundnet=no
-trynetdir=/usr/local
-AC_MSG_CHECKING(for libnet)
+trynetdir=no
+have_libnet=no
+use_libnet=no
+
+AC_ARG_ENABLE(libnet,
+	AC_HELP_STRING([--enable-libnet], [Enable using the libnet 1.1.x library (deprecated)]),
+	[ if test x$enableval = xyes; then
+		use_libnet=yes
+		AC_MSG_WARN([Due to bugs in libnet, it is no longer officially supported])
+	  fi]
+)
+
 AC_ARG_WITH(libnet,
 AC_ARG_WITH(libnet,
     AC_HELP_STRING([--with-libnet=DIR], [Use libnet in DIR]),
     AC_HELP_STRING([--with-libnet=DIR], [Use libnet in DIR]),
     [trynetdir=$withval])
     [trynetdir=$withval])
 
 
-for testdir in $trynetdir /usr/local /opt/local /usr ; do
-    if test -f "${testdir}/include/libnet.h" -a $foundnet = no ; then
-     LNETINC="${testdir}/include/libnet.h"
-     LNETINCDIR="$testdir/include"
-     if test $dynamic_link = yes; then
-         LNETLIB="-L${testdir}/lib -lnet"
-     elif test -f "${testdir}/lib64/libnet.a" ; then
-         LNETLIB="${testdir}/lib64/libnet.a"
-     else
-         LNETLIB="${testdir}/lib/libnet.a"
-     fi
-     foundnet=$testdir
-    fi
-done
+if test x$use_libnet = xyes ; then
+	AC_MSG_CHECKING(for libnet)
+
+	for testdir in $trynetdir /usr/local /opt/local /usr ; do 
+    	if test -f "${testdir}/include/libnet.h" -a $foundnet = no ; then
+        	LNETINC="${testdir}/include/libnet.h"
+	        LNETINCDIR="${testdir}/include"
+	        if test $dynamic_link = yes; then
+				if test -f "${testdir}/lib64/libnet.a" ; then
+		            LNETLIB="-L${testdir}/lib64 -lnet"
+				elif test -f "${testdir}/lib/libnet.a" ; then
+					LNETLIB="-L${testdir}/lib -lnet"
+				else
+					AC_ERROR([Unable to find libnet in ${testdir}])
+				fi
+	        elif test -f "${testdir}/lib64/libnet.a" ; then
+	            LNETLIB="${testdir}/lib64/libnet.a"
+	        elif test -f "${testdir}/lib/libnet.a" ; then
+	            LNETLIB="${testdir}/lib/libnet.a"
+		 	else
+				AC_ERROR([Unable to find matching library for header file in ${testdir}])
+			fi
+        	foundnet=$testdir
+     	fi
+	done
+	
+
+	if test x$foundnet = xno ; then
+	    AC_MSG_RESULT(no)
+	else
+	    AC_MSG_RESULT($foundnet)
+		have_libnet=yes
+		AC_DEFINE([HAVE_LIBNET], [1], [Enable libnet support])
+	fi
 
 
-if test $foundnet = no ; then
-    AC_MSG_RESULT(no)
-else 
-    AC_MSG_RESULT($foundnet) 
-	AC_DEFINE([HAVE_LIBNET], [1], [Enable libnet support])
 fi
 fi
 
 
+
 AC_SUBST(LNETINC)
 AC_SUBST(LNETINC)
 AC_SUBST(LNETLIB)
 AC_SUBST(LNETLIB)
 
 
-if test $foundnet = yes ; then
+if test $foundnet != no ; then
 	OLDLIBS="$LIBS"
 	OLDLIBS="$LIBS"
 	OLDCFLAGS="$CFLAGS"
 	OLDCFLAGS="$CFLAGS"
 	LIBS="$LNETLIB"
 	LIBS="$LNETLIB"
@@ -414,10 +458,10 @@ AC_ARG_WITH(libpcap,
         	LPCAPINC="${testdir}/include/pcap.h"
         	LPCAPINC="${testdir}/include/pcap.h"
 	        LPCAPINCDIR="${testdir}/include"
 	        LPCAPINCDIR="${testdir}/include"
 	        if test $dynamic_link = yes; then
 	        if test $dynamic_link = yes; then
-				if test -f "${testdir}/lib/libpcap.a" ; then
-		            LPCAPLIB="-L${testdir}/lib -lpcap"
-				elif test -f "${testdir}/lib64/libpcap.a" ; then
-					LPCAPLIB="-L${testdir}/lib64 -lpcap"
+				if test -f "${testdir}/lib64/libpcap.a" ; then
+		            LPCAPLIB="-L${testdir}/lib64 -lpcap"
+				elif test -f "${testdir}/lib/libpcap.a" ; then
+					LPCAPLIB="-L${testdir}/lib -lpcap"
 				else
 				else
 					AC_ERROR([Unable to find libpcap in ${testdir}])
 					AC_ERROR([Unable to find libpcap in ${testdir}])
 				fi
 				fi
@@ -452,7 +496,6 @@ LIBS="$LPCAPLIB"
 CFLAGS="$CFLAGS -I$LPCAPINCDIR"
 CFLAGS="$CFLAGS -I$LPCAPINCDIR"
 
 
 
 
-have_libnet=no
 dnl Check to see what version of libpcap
 dnl Check to see what version of libpcap
 dnl this code has been reduced a lot, but probably still could be
 dnl this code has been reduced a lot, but probably still could be
 dnl reduced quite a bit more if we chose too
 dnl reduced quite a bit more if we chose too
@@ -568,31 +611,6 @@ else
 	AC_MSG_NOTICE([--verbose mode requires libpcap >= 0.9.0])
 	AC_MSG_NOTICE([--verbose mode requires libpcap >= 0.9.0])
 fi
 fi
 
 
-dnl Check to see if we've got pcap_snapshot_override()
-AC_MSG_CHECKING(for pcap_snapshot_override)
-AC_LINK_IFELSE(AC_LANG_PROGRAM([[
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "$LPCAPINC"
-]],[[
-	pcap_t *pcap;
-	pcap_snapshot_override(pcap, 1);
-	exit(0);
-]]),[
-    have_pcap_snapshot_override=yes
-    AC_MSG_RESULT(yes)
-], [
-    have_pcap_snapshot_override=no
-    AC_MSG_RESULT(no)
-])
-
-if test $have_pcap_snapshot_override = yes ; then
-    AC_DEFINE([HAVE_PCAP_SNAPSHOT_OVERRIDE], [1], 
-              [Does libpcap have pcap_snapshot_override()?])
-fi
-
-
 have_pcap_inject=no
 have_pcap_inject=no
 dnl Check to see if we've got pcap_inject()
 dnl Check to see if we've got pcap_inject()
 AC_MSG_CHECKING(for pcap_inject sending support)
 AC_MSG_CHECKING(for pcap_inject sending support)
@@ -710,13 +728,15 @@ main(int argc, char *argv[]) {
               [Do we have BPF device support?])
               [Do we have BPF device support?])
 	AC_MSG_RESULT(yes)
 	AC_MSG_RESULT(yes)
 	have_bpf=yes
 	have_bpf=yes
+	],[
+	AC_MSG_RESULT(no)
 	])
 	])
 
 
 
 
 dnl Make sure we have a valid packet injection mechanisim
 dnl Make sure we have a valid packet injection mechanisim
 if test $have_bpf = no -a $have_pcap_inject = no -a $have_pcap_sendpacket = no \
 if test $have_bpf = no -a $have_pcap_inject = no -a $have_pcap_sendpacket = no \
 	-a $have_libnet = no -a $have_pf = no ; then
 	-a $have_libnet = no -a $have_pf = no ; then
-	AC_MSG_ERROR([Unable to find a supported method to send packets])
+	AC_MSG_ERROR([Unable to find a supported method to send packets.  Please upgrade your libpcap or enable libnet])
 fi
 fi
 
 
 dnl Libpcap support doesn't give us a method to get the hardware address of the
 dnl Libpcap support doesn't give us a method to get the hardware address of the
@@ -962,7 +982,7 @@ fi
 
 
 dnl No 'make test' when cross compile
 dnl No 'make test' when cross compile
 
 
-AC_MSG_CHECKING( for 'make test' profile)
+AC_MSG_CHECKING(for 'make test' profile)
 if test "$host" != "$build" ; then
 if test "$host" != "$build" ; then
 	AC_MSG_WARN(Unable to do tests when cross-compiling)
 	AC_MSG_WARN(Unable to do tests when cross-compiling)
 fi
 fi
@@ -974,6 +994,12 @@ AC_ARG_WITH(testnic,
       nic2=$withval
       nic2=$withval
       AC_MSG_RESULT([Using --with-testnic=$withval])],
       AC_MSG_RESULT([Using --with-testnic=$withval])],
     [
     [
+
+dnl There's a bug in OS X which causes pcap_findalldevs() to make the wifi NIC to disassociate
+dnl so under OSX we disable the interface list feature
+disable_pcap_findalldevs=no
+
+
 dnl these need to be dynamic based on OS
 dnl these need to be dynamic based on OS
 case $host in
 case $host in
 	*-*-linux*)
 	*-*-linux*)
@@ -997,6 +1023,7 @@ case $host in
 	*-apple-darwin*)
 	*-apple-darwin*)
 	nic1=en0
 	nic1=en0
 	nic2=en0
 	nic2=en0
+	disable_pcap_findalldevs=yes
 	AC_MSG_RESULT(Apple OS X)
 	AC_MSG_RESULT(Apple OS X)
 	;;
 	;;
 
 
@@ -1029,6 +1056,15 @@ AC_MSG_NOTICE([Using $nic2 for 2nd test network interface card])
 AC_SUBST(nic1)
 AC_SUBST(nic1)
 AC_SUBST(nic2)
 AC_SUBST(nic2)
 
 
+
+AC_MSG_CHECKING([if it's ok to use pcap_findalldevs()])
+if test x$disable_pcap_findalldevs = xno ; then
+	AC_DEFINE([ENABLE_PCAP_FINDALLDEVS], [1], [Enable use of pcap_findalldevs()])
+	AC_MSG_RESULT(yes)
+else
+	AC_MSG_RESULT(no)
+fi
+
 LIBOPTS_CHECK
 LIBOPTS_CHECK
 
 
 AC_OUTPUT([Makefile
 AC_OUTPUT([Makefile
@@ -1044,3 +1080,13 @@ AC_OUTPUT([Makefile
            test/config
            test/config
            scripts/Makefile
            scripts/Makefile
            tcpreplay.spec])
            tcpreplay.spec])
+
+case $host in
+	*-apple-darwin*)
+	AC_MSG_WARN([OS X <= 10.4.9 has a serious problem.  Please see: http://tcpreplay.synfin.net/trac/ticket/142])
+	;;
+	
+	*-*-cygwin)
+	AC_MSG_WARN([Windows/Cygwin support is still somewhat experimental.  Please report any bugs!])
+	;;
+esac

+ 18 - 1
docs/CHANGELOG

@@ -1,4 +1,21 @@
-$Id: CHANGELOG 1807 2007-04-15 01:32:22Z aturner $
+$Id: CHANGELOG 1860 2007-05-02 05:18:08Z aturner $
+
+05/01/2007: Version 3.0.1
+	- Stop tcpreplay causing OS X WiFi from disassociating (#167)
+	- --pnat incorrectly matched all IP addresses (#170)
+	- Fix serious memory leak in core common library (#175)
+	- Fix tcprewrite --enet-vlan on little endian systems (#174)
+	- Bad pcap timestamps were causing excessive delays (#169)
+	- Code cleanup (#173)
+
+04/20/2007: Version 3.0
+	- By default, no longer try to use libnet.  You must now specify --enable-libnet (#148)
+	- Improve documentation (#30)
+	- General code cleanup (#47)
+	- Warn when GNU Autogen version < 5.9 (#153)
+	- Remove support for pcap_snapshot_override which was never added to libpcap (#140)
+	- Fix support for C99/GCC 4.3 "inline".  Rely on -O3 for better performance. (#149)
+	- Prioritize 64 bit libraries over 32 bit counterparts (#150)
 
 
 04/14/2007: Version 3.0.RC1
 04/14/2007: Version 3.0.RC1
     - Fix tcpbridge and make it compile by default (#15)
     - Fix tcpbridge and make it compile by default (#15)

+ 1 - 0
docs/Makefile.in

@@ -107,6 +107,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@
 PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@
 PRINTF = @PRINTF@
 PRINTF = @PRINTF@
 RANLIB = @RANLIB@
 RANLIB = @RANLIB@
+SED = @SED@
 SET_MAKE = @SET_MAKE@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SHELL = @SHELL@
 STRIP = @STRIP@
 STRIP = @STRIP@

+ 1 - 0
lib/Makefile.in

@@ -131,6 +131,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@
 PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@
 PRINTF = @PRINTF@
 PRINTF = @PRINTF@
 RANLIB = @RANLIB@
 RANLIB = @RANLIB@
+SED = @SED@
 SET_MAKE = @SET_MAKE@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SHELL = @SHELL@
 STRIP = @STRIP@
 STRIP = @STRIP@

+ 1 - 0
libopts/Makefile.in

@@ -139,6 +139,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@
 PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@
 PRINTF = @PRINTF@
 PRINTF = @PRINTF@
 RANLIB = @RANLIB@
 RANLIB = @RANLIB@
+SED = @SED@
 SET_MAKE = @SET_MAKE@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SHELL = @SHELL@
 STRIP = @STRIP@
 STRIP = @STRIP@

+ 1 - 0
scripts/Makefile.in

@@ -127,6 +127,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@
 PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@
 PRINTF = @PRINTF@
 PRINTF = @PRINTF@
 RANLIB = @RANLIB@
 RANLIB = @RANLIB@
+SED = @SED@
 SET_MAKE = @SET_MAKE@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SHELL = @SHELL@
 STRIP = @STRIP@
 STRIP = @STRIP@

BIN
src/._defines.h.in


BIN
src/._send_packets.c


BIN
src/._tcpprep.c


BIN
src/._tcpreplay.c


BIN
src/._tcpreplay.h


+ 1 - 0
src/Makefile.in

@@ -195,6 +195,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@
 PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@
 PRINTF = @PRINTF@
 PRINTF = @PRINTF@
 RANLIB = @RANLIB@
 RANLIB = @RANLIB@
+SED = @SED@
 SET_MAKE = @SET_MAKE@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SHELL = @SHELL@
 STRIP = @STRIP@
 STRIP = @STRIP@

BIN
src/common/._cidr.c


BIN
src/common/._cidr.h


BIN
src/common/._timer.h


BIN
src/common/._xX.c


+ 1 - 0
src/common/Makefile.in

@@ -143,6 +143,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@
 PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@
 PRINTF = @PRINTF@
 PRINTF = @PRINTF@
 RANLIB = @RANLIB@
 RANLIB = @RANLIB@
+SED = @SED@
 SET_MAKE = @SET_MAKE@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SHELL = @SHELL@
 STRIP = @STRIP@
 STRIP = @STRIP@

+ 16 - 15
src/common/cidr.c

@@ -1,4 +1,4 @@
-/* $Id: cidr.c 1757 2007-03-22 05:38:56Z aturner $ */
+/* $Id: cidr.c 1844 2007-04-27 02:42:36Z aturner $ */
 
 
 /*
 /*
  * Copyright (c) 2001-2004 Aaron Turner.
  * Copyright (c) 2001-2004 Aaron Turner.
@@ -374,20 +374,19 @@ parse_cidr_map(tcpr_cidrmap_t **cidrmap, const char *optarg)
     return 1; /* success */
     return 1; /* success */
 }
 }
 
 
-/*
+/* 
  * checks to see if the ip address is in the cidr
  * checks to see if the ip address is in the cidr
- * returns TCPR_DIR_C2S for true, TCPR_DIR_S2C for false
+ * returns 1 for true, 0 for false
  */
  */
-
-tcpr_dir_t
+int
 ip_in_cidr(const tcpr_cidr_t * mycidr, const unsigned long ip)
 ip_in_cidr(const tcpr_cidr_t * mycidr, const unsigned long ip)
 {
 {
     unsigned long ipaddr = 0, network = 0, mask = 0;
     unsigned long ipaddr = 0, network = 0, mask = 0;
-    int ret;
+    int ret = 0;
     
     
     /* always return 1 if 0.0.0.0/0 */
     /* always return 1 if 0.0.0.0/0 */
     if (mycidr->masklen == 0 && mycidr->network == 0)
     if (mycidr->masklen == 0 && mycidr->network == 0)
-        return TCPR_DIR_C2S;
+        return 1;
 
 
     mask = ~0;                  /* turn on all the bits */
     mask = ~0;                  /* turn on all the bits */
 
 
@@ -406,7 +405,7 @@ ip_in_cidr(const tcpr_cidr_t * mycidr, const unsigned long ip)
             get_addr2name4(ip, RESOLVE),
             get_addr2name4(ip, RESOLVE),
             get_addr2name4(htonl(network), RESOLVE), mycidr->masklen);
             get_addr2name4(htonl(network), RESOLVE), mycidr->masklen);
 
 
-        ret = TCPR_DIR_C2S;
+        ret = 1;
     }
     }
     else {
     else {
 
 
@@ -414,17 +413,19 @@ ip_in_cidr(const tcpr_cidr_t * mycidr, const unsigned long ip)
             get_addr2name4(ip, RESOLVE),
             get_addr2name4(ip, RESOLVE),
             get_addr2name4(htonl(network), RESOLVE), mycidr->masklen);
             get_addr2name4(htonl(network), RESOLVE), mycidr->masklen);
 
 
-        ret = TCPR_DIR_S2C;
+        ret = 0;
     }
     }
     return ret;
     return ret;
+
 }
 }
 
 
+
 /*
 /*
  * iterates over cidrdata to find if a given ip matches
  * iterates over cidrdata to find if a given ip matches
- * returns TCPR_DIR_C2S for true, TCPR_DIR_S2C for false
+ * returns 1 for true, 0 for false
  */
  */
 
 
-tcpr_dir_t
+int
 check_ip_cidr(tcpr_cidr_t * cidrdata, const unsigned long ip)
 check_ip_cidr(tcpr_cidr_t * cidrdata, const unsigned long ip)
 {
 {
     tcpr_cidr_t *mycidr;
     tcpr_cidr_t *mycidr;
@@ -433,7 +434,7 @@ check_ip_cidr(tcpr_cidr_t * cidrdata, const unsigned long ip)
      * this actually should happen occasionally, so don't put an assert here
      * this actually should happen occasionally, so don't put an assert here
      */
      */
     if (cidrdata == NULL) {
     if (cidrdata == NULL) {
-        return TCPR_DIR_S2C;
+        return 1;
     }
     }
 
 
     mycidr = cidrdata;
     mycidr = cidrdata;
@@ -442,9 +443,9 @@ check_ip_cidr(tcpr_cidr_t * cidrdata, const unsigned long ip)
     while (1) {
     while (1) {
 
 
         /* if match, return 1 */
         /* if match, return 1 */
-        if (ip_in_cidr(mycidr, ip) == TCPR_DIR_C2S) {
+        if (ip_in_cidr(mycidr, ip)) {
             dbgx(3, "Found %s in cidr", get_addr2name4(ip, RESOLVE));
             dbgx(3, "Found %s in cidr", get_addr2name4(ip, RESOLVE));
-            return TCPR_DIR_C2S;
+            return 1;
         }
         }
         /* check for next record */
         /* check for next record */
         if (mycidr->next != NULL) {
         if (mycidr->next != NULL) {
@@ -457,7 +458,7 @@ check_ip_cidr(tcpr_cidr_t * cidrdata, const unsigned long ip)
 
 
     /* if we get here, no match */
     /* if we get here, no match */
     dbgx(3, "Didn't find %s in cidr", get_addr2name4(ip, RESOLVE));
     dbgx(3, "Didn't find %s in cidr", get_addr2name4(ip, RESOLVE));
-    return TCPR_DIR_S2C;
+    return 0;
 }
 }
 
 
 
 

+ 3 - 3
src/common/cidr.h

@@ -1,4 +1,4 @@
-/* $Id: cidr.h 1757 2007-03-22 05:38:56Z aturner $ */
+/* $Id: cidr.h 1844 2007-04-27 02:42:36Z aturner $ */
 
 
 /*
 /*
  * Copyright (c) 2001-2004 Aaron Turner.
  * Copyright (c) 2001-2004 Aaron Turner.
@@ -50,8 +50,8 @@ struct tcpr_cidrmap_s {
 };
 };
 typedef struct tcpr_cidrmap_s tcpr_cidrmap_t;
 typedef struct tcpr_cidrmap_s tcpr_cidrmap_t;
 
 
-tcpr_dir_t ip_in_cidr(const tcpr_cidr_t *, const unsigned long);
-tcpr_dir_t check_ip_cidr(tcpr_cidr_t *, const unsigned long);
+int ip_in_cidr(const tcpr_cidr_t *, const unsigned long);
+int check_ip_cidr(tcpr_cidr_t *, const unsigned long);
 int parse_cidr(tcpr_cidr_t **, char *, char *delim);
 int parse_cidr(tcpr_cidr_t **, char *, char *delim);
 int parse_cidr_map(tcpr_cidrmap_t **, const char *);
 int parse_cidr_map(tcpr_cidrmap_t **, const char *);
 int parse_endpoints(tcpr_cidrmap_t **, tcpr_cidrmap_t **, const char *);
 int parse_endpoints(tcpr_cidrmap_t **, tcpr_cidrmap_t **, const char *);

+ 13 - 13
src/common/err.c

@@ -1,11 +1,11 @@
-/* $Id: err.c 1776 2007-04-01 02:10:03Z aturner $ */
+/* $Id: err.c 1814 2007-04-16 19:31:50Z aturner $ */
 
 
 /*
 /*
  * err.c
  * err.c
  *
  *
  * Adapted from OpenBSD libc *err* *warn* code.
  * Adapted from OpenBSD libc *err* *warn* code.
  *
  *
- * Copyright (c) 2001-2005 Aaron Turner.
+ * Copyright (c) 2001-2007 Aaron Turner.
  *
  *
  * Copyright (c) 2000 Dug Song <dugsong@monkey.org>
  * Copyright (c) 2000 Dug Song <dugsong@monkey.org>
  *
  *
@@ -55,7 +55,7 @@
 extern int debug;
 extern int debug;
 #endif
 #endif
 
 
-inline void
+void
 notice(const char *fmt, ...)
 notice(const char *fmt, ...)
 {
 {
     va_list ap;
     va_list ap;
@@ -68,7 +68,7 @@ notice(const char *fmt, ...)
     fflush(NULL);
     fflush(NULL);
 }
 }
 
 
-inline void
+void
 _our_verbose_dbgx(int dbg_level, const char *fmt, const char *function, 
 _our_verbose_dbgx(int dbg_level, const char *fmt, const char *function, 
         const int line, const char *file, ...)
         const int line, const char *file, ...)
 {
 {
@@ -93,7 +93,7 @@ _our_verbose_dbgx(int dbg_level, const char *fmt, const char *function,
 #endif
 #endif
 }
 }
 
 
-inline void
+void
 _our_verbose_dbg(int dbg_level, const char *string, const char *function, const int line, const char *file)
 _our_verbose_dbg(int dbg_level, const char *string, const char *function, const int line, const char *file)
 {
 {
 #ifdef DEBUG
 #ifdef DEBUG
@@ -110,10 +110,10 @@ _our_verbose_dbg(int dbg_level, const char *string, const char *function, const
 
 
 
 
 #ifdef DEBUG
 #ifdef DEBUG
-inline void
+void
 _our_verbose_err(int eval, const char *string, const char *function, const int line, const char *file) {
 _our_verbose_err(int eval, const char *string, const char *function, const int line, const char *file) {
 #else
 #else
-inline void
+void
 _our_verbose_err(int eval, const char *string) {
 _our_verbose_err(int eval, const char *string) {
 #endif
 #endif
 
 
@@ -126,10 +126,10 @@ _our_verbose_err(int eval, const char *string) {
 }
 }
 
 
 #ifdef DEBUG
 #ifdef DEBUG
-inline void
+void
 _our_verbose_warn(const char *string, const char *function, const int line, const char *file) {
 _our_verbose_warn(const char *string, const char *function, const int line, const char *file) {
 #else
 #else
-inline void
+void
 _our_verbose_warn(const char *string) {
 _our_verbose_warn(const char *string) {
 #endif
 #endif
 
 
@@ -140,10 +140,10 @@ _our_verbose_warn(const char *string) {
 }
 }
 
 
 #ifdef DEBUG
 #ifdef DEBUG
-inline void
+void
 _our_verbose_errx(int eval, const char *fmt, const char *function, const int line, const char *file, ...) {
 _our_verbose_errx(int eval, const char *fmt, const char *function, const int line, const char *file, ...) {
 #else
 #else
-inline void
+void
 _our_verbose_errx(int eval, const char *fmt, ...) {
 _our_verbose_errx(int eval, const char *fmt, ...) {
 #endif
 #endif
 
 
@@ -165,10 +165,10 @@ _our_verbose_errx(int eval, const char *fmt, ...) {
 }
 }
 
 
 #ifdef DEBUG
 #ifdef DEBUG
-inline void
+void
 _our_verbose_warnx(const char *fmt, const char *function, const int line, const char *file, ...) {
 _our_verbose_warnx(const char *fmt, const char *function, const int line, const char *file, ...) {
 #else
 #else
-inline void 
+void 
 _our_verbose_warnx(const char *fmt, ...) {
 _our_verbose_warnx(const char *fmt, ...) {
 #endif
 #endif
 
 

+ 13 - 22
src/common/err.h

@@ -1,11 +1,11 @@
-/* $Id: err.h 1776 2007-04-01 02:10:03Z aturner $ */
+/* $Id: err.h 1817 2007-04-17 06:50:44Z aturner $ */
 
 
 /*
 /*
  * err.h
  * err.h
  *
  *
  * Adapted from OpenBSD libc *err* *warn* code.
  * Adapted from OpenBSD libc *err* *warn* code.
  *
  *
- * Copyright (c) 2001-2005 Aaron Turner.
+ * Copyright (c) 2001-2007 Aaron Turner.
  *
  *
  * Copyright (c) 2000 Dug Song <dugsong@monkey.org>
  * Copyright (c) 2000 Dug Song <dugsong@monkey.org>
  *
  *
@@ -60,54 +60,45 @@
 
 
 
 
 #define dbg(x, y) _our_verbose_dbg(x, y, __FUNCTION__, __LINE__, __FILE__)
 #define dbg(x, y) _our_verbose_dbg(x, y, __FUNCTION__, __LINE__, __FILE__)
-inline void _our_verbose_dbg(int dbg_level, const char *string, const char *, 
+void _our_verbose_dbg(int dbg_level, const char *string, const char *, 
         const int, const char *);
         const int, const char *);
 
 
 #define dbgx(x, y, ...) _our_verbose_dbgx(x, y, __FUNCTION__, __LINE__, __FILE__, __VA_ARGS__)
 #define dbgx(x, y, ...) _our_verbose_dbgx(x, y, __FUNCTION__, __LINE__, __FILE__, __VA_ARGS__)
-inline void _our_verbose_dbgx(int dbg_level, const char *fmt, const char *, 
+void _our_verbose_dbgx(int dbg_level, const char *fmt, const char *, 
         const int, const char *, ...);
         const int, const char *, ...);
 
 
-inline void notice(const char *fmt, ...);
+void notice(const char *fmt, ...);
 
 
 
 
 #ifdef DEBUG /* then err, errx, warn, warnx print file, func, line */
 #ifdef DEBUG /* then err, errx, warn, warnx print file, func, line */
 
 
 #define err(x, y) _our_verbose_err(x, y, __FUNCTION__, __LINE__, __FILE__)
 #define err(x, y) _our_verbose_err(x, y, __FUNCTION__, __LINE__, __FILE__)
-inline void _our_verbose_err(int eval, const char *string, const char *, const int, const char *);
+void _our_verbose_err(int eval, const char *string, const char *, const int, const char *);
 
 
 #define warn(x) _our_verbose_warn(x, __FUNCTION__, __LINE__, __FILE__)
 #define warn(x) _our_verbose_warn(x, __FUNCTION__, __LINE__, __FILE__)
-inline void _our_verbose_warn(const char *fmt, const char *, const int, const char *);
+void _our_verbose_warn(const char *fmt, const char *, const int, const char *);
 
 
 #define errx(x, y, ...) _our_verbose_errx(x, y, __FUNCTION__, __LINE__, __FILE__, __VA_ARGS__)
 #define errx(x, y, ...) _our_verbose_errx(x, y, __FUNCTION__, __LINE__, __FILE__, __VA_ARGS__)
-inline void _our_verbose_errx(int eval, const char *fmt, const char *, const int, const char *, ...);
+void _our_verbose_errx(int eval, const char *fmt, const char *, const int, const char *, ...);
 
 
 #define warnx(x, ...) _our_verbose_warnx(x, __FUNCTION__, __LINE__, __FILE__, __VA_ARGS__)
 #define warnx(x, ...) _our_verbose_warnx(x, __FUNCTION__, __LINE__, __FILE__, __VA_ARGS__)
-inline void _our_verbose_warnx(const char *fmt, const char *, const int, const char *, ...);
+void _our_verbose_warnx(const char *fmt, const char *, const int, const char *, ...);
 
 
 #else /* no detailed DEBUG info */
 #else /* no detailed DEBUG info */
 
 
 #define err(x, y) _our_verbose_err(x, y)
 #define err(x, y) _our_verbose_err(x, y)
-inline void _our_verbose_err(int eval, const char *string);
+void _our_verbose_err(int eval, const char *string);
 
 
 #define errx(x, y, ...) _our_verbose_errx(x, y, __VA_ARGS__)
 #define errx(x, y, ...) _our_verbose_errx(x, y, __VA_ARGS__)
-inline void _our_verbose_errx(int eval, const char *fmt, ...);
+void _our_verbose_errx(int eval, const char *fmt, ...);
 
 
 #define warn(x) _our_verbose_warn(x)
 #define warn(x) _our_verbose_warn(x)
-inline void _our_verbose_warn(const char *fmt);
+void _our_verbose_warn(const char *fmt);
 
 
 #define warnx(x, ...) _our_verbose_warnx(x, __VA_ARGS__)
 #define warnx(x, ...) _our_verbose_warnx(x, __VA_ARGS__)
-inline void _our_verbose_warnx(const char *fmt, ...);
+void _our_verbose_warnx(const char *fmt, ...);
 
 
 #endif /* DEBUG */
 #endif /* DEBUG */
 
 
 
 
 #endif /* !_ERR_H_ */
 #endif /* !_ERR_H_ */
-
-/*
- Local Variables:
- mode:c
- indent-tabs-mode:nil
- c-basic-offset:4
- End:
-*/
-

+ 2 - 2
src/common/get.c

@@ -1,4 +1,4 @@
-/* $Id: get.c 1757 2007-03-22 05:38:56Z aturner $ */
+/* $Id: get.c 1847 2007-04-30 20:55:46Z aturner $ */
 
 
 /*
 /*
  * Copyright (c) 2001-2005 Aaron Turner.
  * Copyright (c) 2001-2005 Aaron Turner.
@@ -340,7 +340,7 @@ const char *
 get_addr2name4(const u_int32_t ip, u_int8_t dnslookup)
 get_addr2name4(const u_int32_t ip, u_int8_t dnslookup)
 {
 {
     struct in_addr addr;
     struct in_addr addr;
-    char *new_string = NULL;
+    static char *new_string = NULL;
 
 
     if (new_string == NULL)
     if (new_string == NULL)
         new_string = (char *)safe_malloc(255);
         new_string = (char *)safe_malloc(255);

+ 14 - 11
src/common/interface.c

@@ -1,4 +1,4 @@
-/* $Id: interface.c 1766 2007-03-29 03:51:25Z aturner $ */
+/* $Id: interface.c 1845 2007-04-27 02:48:10Z aturner $ */
 
 
 /*
 /*
  * Copyright (c) 2007 Aaron Turner.
  * Copyright (c) 2007 Aaron Turner.
@@ -54,20 +54,23 @@ get_interface(interface_list_t *list, const char *alias)
     interface_list_t *ptr;
     interface_list_t *ptr;
     
     
     assert(alias);
     assert(alias);
-    assert(list);
     
     
-    ptr = list;
+    if (list != NULL) {        
+        ptr = list;
     
     
-    do {
-        /* check both the alias & name fields */
-        if (strcmp(alias, ptr->alias) == 0)
-            return(ptr->name);
+        do {
+            /* check both the alias & name fields */
+            if (strcmp(alias, ptr->alias) == 0)
+                return(ptr->name);
         
         
-        if (strcmp(alias, ptr->name) == 0)
-            return(ptr->name);
+            if (strcmp(alias, ptr->name) == 0)
+                return(ptr->name);
             
             
-        ptr = ptr->next;
-    } while (ptr != NULL);
+            ptr = ptr->next;
+        } while (ptr != NULL);
+    } else {
+        return(alias);
+    }
     
     
     return(NULL);
     return(NULL);
 }
 }

+ 1 - 1
src/common/svn_version.c

@@ -1,4 +1,4 @@
-const char SVN_Version[] = "1811";
+const char SVN_Version[] = "1861";
 const char *svn_version(void) {
 const char *svn_version(void) {
 	return SVN_Version;
 	return SVN_Version;
 }
 }

+ 6 - 14
src/common/timer.c

@@ -1,7 +1,7 @@
-/* $Id: timer.c 1757 2007-03-22 05:38:56Z aturner $ */
+/* $Id: timer.c 1814 2007-04-16 19:31:50Z aturner $ */
 
 
 /*
 /*
- * Copyright (c) 2001-2004 Aaron Turner.
+ * Copyright (c) 2001-2007 Aaron Turner.
  * All rights reserved.
  * All rights reserved.
  *
  *
  * Redistribution and use in source and binary forms, with or without
  * Redistribution and use in source and binary forms, with or without
@@ -41,7 +41,7 @@
 /* Miscellaneous timeval routines */
 /* Miscellaneous timeval routines */
 
 
 /* Divide tvp by div, storing the result in tvp */
 /* Divide tvp by div, storing the result in tvp */
-inline void
+void
 timerdiv(struct timeval *tvp, float div)
 timerdiv(struct timeval *tvp, float div)
 {
 {
     double interval;
     double interval;
@@ -56,8 +56,8 @@ timerdiv(struct timeval *tvp, float div)
 
 
 /*
 /*
  * converts a float to a timeval structure
  * converts a float to a timeval structure
- */
-inline void
+ * converted to a #define
+void
 float2timer(float time, struct timeval *tvp)
 float2timer(float time, struct timeval *tvp)
 {
 {
     float n;
     float n;
@@ -70,12 +70,4 @@ float2timer(float time, struct timeval *tvp)
     tvp->tv_usec = n * 100000;
     tvp->tv_usec = n * 100000;
 
 
 }
 }
-
-/*
- Local Variables:
- mode:c
- indent-tabs-mode:nil
- c-basic-offset:4
- End:
-*/
-
+ */

+ 42 - 35
src/common/timer.h

@@ -1,7 +1,7 @@
-/* $Id: timer.h 1757 2007-03-22 05:38:56Z aturner $ */
+/* $Id: timer.h 1853 2007-05-02 04:40:39Z aturner $ */
 
 
 /*
 /*
- * Copyright (c) 2001-2004 Aaron Turner.
+ * Copyright (c) 2001-2007 Aaron Turner.
  * All rights reserved.
  * All rights reserved.
  *
  *
  * Redistribution and use in source and binary forms, with or without
  * Redistribution and use in source and binary forms, with or without
@@ -42,12 +42,27 @@
 #include <sys/time.h>
 #include <sys/time.h>
 #include <math.h>
 #include <math.h>
 
 
-inline void timerdiv(struct timeval *tvp, float div);
-inline void float2timer(float time, struct timeval *tvp);
+/*
+ * 1 sec = 1,000,000 microsec
+ * 1 microsec = 1,000 nanosec
+ * 1 sec = 1,000,000,000 nanosec
+ */
+
+void timerdiv(struct timeval *tvp, float div);
+
+/* convert float time to struct timeval *tvp */
+#ifndef float2timer
+#define float2timer(time, tvp)                  \
+    do {                                        \
+        tvp->tv_sec = time;                     \
+        tvp->tv_usec = (time - tvp->tv_sec) * 100000; \
+    } while (0);
+#endif
+
 
 
 #ifndef TIMEVAL_TO_TIMESPEC
 #ifndef TIMEVAL_TO_TIMESPEC
-#define TIMEVAL_TO_TIMESPEC(tv, ts) { \
-            (ts)->tv_sec = (tv)->tv_sec; \
+#define TIMEVAL_TO_TIMESPEC(tv, ts) {           \
+            (ts)->tv_sec = (tv)->tv_sec;        \
             (ts)->tv_nsec = (tv)->tv_usec * 1000; }
             (ts)->tv_nsec = (tv)->tv_usec * 1000; }
 #endif
 #endif
 
 
@@ -63,64 +78,56 @@ inline void float2timer(float time, struct timeval *tvp);
 
 
 /* add tvp and uvp and store in vvp */
 /* add tvp and uvp and store in vvp */
 #ifndef timeradd
 #ifndef timeradd
-#define timeradd(tvp, uvp, vvp)                     \
-	do {                                \
+#define timeradd(tvp, uvp, vvp)                 \
+	do {                                        \
 		(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec;      \
 		(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec;      \
 		(vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec;   \
 		(vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec;   \
-		if ((vvp)->tv_usec >= 1000000) {            \
-			(vvp)->tv_sec++;                \
+		if ((vvp)->tv_usec >= 1000000) {        \
+			(vvp)->tv_sec++;                    \
 			(vvp)->tv_usec -= 1000000;          \
 			(vvp)->tv_usec -= 1000000;          \
-		}                           \
+		}                                       \
 	} while (0)
 	} while (0)
 #endif
 #endif
 
 
 /* subtract uvp from tvp and store in vvp */
 /* subtract uvp from tvp and store in vvp */
 #ifndef timersub
 #ifndef timersub
-#define	timersub(tvp, uvp, vvp)						\
-	do {								\
+#define	timersub(tvp, uvp, vvp)					\
+	do {								        \
 		(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;		\
 		(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;		\
 		(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;	\
 		(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;	\
 		if ((vvp)->tv_usec < 0) {				\
 		if ((vvp)->tv_usec < 0) {				\
-			(vvp)->tv_sec--;				\
+			(vvp)->tv_sec--;				    \
 			(vvp)->tv_usec += 1000000;			\
 			(vvp)->tv_usec += 1000000;			\
-		}							\
+		}							            \
 	} while (0)
 	} while (0)
 #endif
 #endif
 
 
 /* compare tvp and uvp using cmp */
 /* compare tvp and uvp using cmp */
 #ifndef timercmp
 #ifndef timercmp
-#define timercmp(tvp, uvp, cmp)				\
-	(((tvp)->tv_sec == (uvp)->tv_sec) ?		\
+#define timercmp(tvp, uvp, cmp)				    \
+	(((tvp)->tv_sec == (uvp)->tv_sec) ?		    \
 	((tvp)->tv_usec cmp (uvp)->tv_usec) :		\
 	((tvp)->tv_usec cmp (uvp)->tv_usec) :		\
 	((tvp)->tv_sec cmp (uvp)->tv_sec))
 	((tvp)->tv_sec cmp (uvp)->tv_sec))
 #endif
 #endif
 
 
 /* multiply tvp by x and store in uvp */
 /* multiply tvp by x and store in uvp */
-#define timermul(tvp, uvp, x)						\
-	do {								\
-		(uvp)->tv_sec = (tvp)->tv_sec * x;			\
-		(uvp)->tv_usec = (tvp)->tv_usec * x;			\
-		while((uvp)->tv_usec > 1000000) {			\
-			(uvp)->tv_sec++;				\
+#define timermul(tvp, uvp, x)					\
+	do {								        \
+		(uvp)->tv_sec = (tvp)->tv_sec * x;		\
+		(uvp)->tv_usec = (tvp)->tv_usec * x;	\
+		while((uvp)->tv_usec > 1000000) {		\
+			(uvp)->tv_sec++;				    \
 			(uvp)->tv_usec -= 1000000;			\
 			(uvp)->tv_usec -= 1000000;			\
-		}							\
+		}							            \
 	} while(0)
 	} while(0)
 
 
 
 
 /* device tvp by x.  store in tvp */
 /* device tvp by x.  store in tvp */
 #define timerdiv2(tvp, x)						\
 #define timerdiv2(tvp, x)						\
-	do {								\
-		(tvp)->tv_sec = (tvp)->tv_sec / x;			\
-		(tvp)->tv_usec = (tvp)->tv_usec / x;			\
+	do {								        \
+		(tvp)->tv_sec = (tvp)->tv_sec / x;		\
+		(tvp)->tv_usec = (tvp)->tv_usec / x;	\
 	} while(0)
 	} while(0)
 
 
 #endif
 #endif
 
 
-/*
- Local Variables:
- mode:c
- indent-tabs-mode:nil
- c-basic-offset:4
- End:
-*/
-

+ 13 - 13
src/common/xX.c

@@ -1,4 +1,4 @@
-/* $Id: xX.c 1757 2007-03-22 05:38:56Z aturner $ */
+/* $Id: xX.c 1844 2007-04-27 02:42:36Z aturner $ */
 
 
 /*
 /*
  * Copyright (c) 2001-2004 Aaron Turner.
  * Copyright (c) 2001-2004 Aaron Turner.
@@ -133,17 +133,17 @@ process_xX_by_cidr(int mode, tcpr_cidr_t * cidr, ipv4_hdr_t * ip_hdr)
             /* note: check_ip_cidr() returns TCPR_DIR_C2S for true, TCPR_DIR_S2C for false 
             /* note: check_ip_cidr() returns TCPR_DIR_C2S for true, TCPR_DIR_S2C for false 
              * and NOT true/false or 1/0, etc!
              * and NOT true/false or 1/0, etc!
              */
              */
-            return check_ip_cidr(cidr, ip_hdr->ip_src.s_addr) == TCPR_DIR_C2S ? DONT_SEND : SEND;
+            return check_ip_cidr(cidr, ip_hdr->ip_src.s_addr) ? DONT_SEND : SEND;
             break;
             break;
         case xXDest:
         case xXDest:
-            return check_ip_cidr(cidr, ip_hdr->ip_dst.s_addr) == TCPR_DIR_C2S ? DONT_SEND : SEND;
+            return check_ip_cidr(cidr, ip_hdr->ip_dst.s_addr)  ? DONT_SEND : SEND;
         case xXBoth:
         case xXBoth:
-            return (check_ip_cidr(cidr, ip_hdr->ip_dst.s_addr) == TCPR_DIR_C2S &&
-                    check_ip_cidr(cidr, ip_hdr->ip_src.s_addr) == TCPR_DIR_C2S) ? DONT_SEND : SEND;
+            return (check_ip_cidr(cidr, ip_hdr->ip_dst.s_addr)  &&
+                    check_ip_cidr(cidr, ip_hdr->ip_src.s_addr) ) ? DONT_SEND : SEND;
             break;
             break;
         case xXEither:
         case xXEither:
-            return (check_ip_cidr(cidr, ip_hdr->ip_dst.s_addr) == TCPR_DIR_C2S ||
-                    check_ip_cidr(cidr, ip_hdr->ip_src.s_addr) == TCPR_DIR_C2S) ? DONT_SEND : SEND;
+            return (check_ip_cidr(cidr, ip_hdr->ip_dst.s_addr)  ||
+                    check_ip_cidr(cidr, ip_hdr->ip_src.s_addr) ) ? DONT_SEND : SEND;
             break;
             break;
         }
         }
     }
     }
@@ -151,18 +151,18 @@ process_xX_by_cidr(int mode, tcpr_cidr_t * cidr, ipv4_hdr_t * ip_hdr)
         /* Include Mode */
         /* Include Mode */
         switch (mode) {
         switch (mode) {
         case xXSource:
         case xXSource:
-            return check_ip_cidr(cidr, ip_hdr->ip_src.s_addr) == TCPR_DIR_C2S ? SEND : DONT_SEND;
+            return check_ip_cidr(cidr, ip_hdr->ip_src.s_addr)  ? SEND : DONT_SEND;
             break;
             break;
         case xXDest:
         case xXDest:
-            return check_ip_cidr(cidr, ip_hdr->ip_dst.s_addr) == TCPR_DIR_C2S ? SEND : DONT_SEND;
+            return check_ip_cidr(cidr, ip_hdr->ip_dst.s_addr)  ? SEND : DONT_SEND;
             break;
             break;
         case xXBoth:
         case xXBoth:
-            return (check_ip_cidr(cidr, ip_hdr->ip_dst.s_addr) == TCPR_DIR_C2S &&
-                    check_ip_cidr(cidr, ip_hdr->ip_src.s_addr) == TCPR_DIR_C2S) ? SEND : DONT_SEND;
+            return (check_ip_cidr(cidr, ip_hdr->ip_dst.s_addr)  &&
+                    check_ip_cidr(cidr, ip_hdr->ip_src.s_addr) ) ? SEND : DONT_SEND;
             break;
             break;
         case xXEither:
         case xXEither:
-            return (check_ip_cidr(cidr, ip_hdr->ip_dst.s_addr) == TCPR_DIR_C2S ||
-                    check_ip_cidr(cidr, ip_hdr->ip_src.s_addr) == TCPR_DIR_C2S) ? SEND : DONT_SEND;
+            return (check_ip_cidr(cidr, ip_hdr->ip_dst.s_addr)  ||
+                    check_ip_cidr(cidr, ip_hdr->ip_src.s_addr) ) ? SEND : DONT_SEND;
             break;
             break;
         }
         }
     }
     }

+ 3 - 3
src/config.h.in

@@ -15,6 +15,9 @@
 /* Enable building flowreplay (alpha) */
 /* Enable building flowreplay (alpha) */
 #undef ENABLE_FLOWREPLAY
 #undef ENABLE_FLOWREPLAY
 
 
+/* Enable use of pcap_findalldevs() */
+#undef ENABLE_PCAP_FINDALLDEVS
+
 /* Do we have tcpdump and pcap_dump_fopen()? */
 /* Do we have tcpdump and pcap_dump_fopen()? */
 #undef ENABLE_VERBOSE
 #undef ENABLE_VERBOSE
 
 
@@ -179,9 +182,6 @@
 /* Does libpcap have pcap_sendpacket? */
 /* Does libpcap have pcap_sendpacket? */
 #undef HAVE_PCAP_SENDPACKET
 #undef HAVE_PCAP_SENDPACKET
 
 
-/* Does libpcap have pcap_snapshot_override()? */
-#undef HAVE_PCAP_SNAPSHOT_OVERRIDE
-
 /* Does libpcap have pcap_version[] */
 /* Does libpcap have pcap_version[] */
 #undef HAVE_PCAP_VERSION
 #undef HAVE_PCAP_VERSION
 
 

+ 4 - 4
src/defines.h

@@ -20,11 +20,11 @@
 #endif
 #endif
 
 
 #if defined INCLUDE_PCAP_BPF_H_FILE && !defined PCAP_DONT_INCLUDE_PCAP_BPF_H
 #if defined INCLUDE_PCAP_BPF_H_FILE && !defined PCAP_DONT_INCLUDE_PCAP_BPF_H
-#include "/opt/local/include/pcap-bpf.h"
+#include "/usr/local/include/pcap-bpf.h"
 #define PCAP_DONT_INCLUDE_PCAP_BPF_H 1 /* don't re-include it in pcap.h */
 #define PCAP_DONT_INCLUDE_PCAP_BPF_H 1 /* don't re-include it in pcap.h */
 #endif
 #endif
 
 
-#include "/opt/local/include/pcap.h"
+#include "/usr/local/include/pcap.h"
 
 
 #include "lib/strlcpy.h"
 #include "lib/strlcpy.h"
 #include "common/list.h"
 #include "common/list.h"
@@ -41,7 +41,7 @@
 
 
 
 
 #ifdef HAVE_LIBNET
 #ifdef HAVE_LIBNET
-#include "/opt/local/include/libnet.h"
+#include ""
 #endif
 #endif
 
 
 typedef struct tcpr_ipv4_hdr ipv4_hdr_t;
 typedef struct tcpr_ipv4_hdr ipv4_hdr_t;
@@ -160,7 +160,7 @@ enum tcpprep_mode {
 #define MAC_STR(x) x[0], x[1], x[2], x[3], x[4], x[5]
 #define MAC_STR(x) x[0], x[1], x[2], x[3], x[4], x[5]
 
 
 /* struct timeval print structs */
 /* struct timeval print structs */
-#define TIMEVAL_FORMAT "%lu.%08lu"
+#define TIMEVAL_FORMAT "%lu.%06lu"
 
 
 /* force a word or half-word swap on both Big and Little endian systems */
 /* force a word or half-word swap on both Big and Little endian systems */
 #ifndef SWAPLONG
 #ifndef SWAPLONG

+ 1 - 1
src/defines.h.in

@@ -160,7 +160,7 @@ enum tcpprep_mode {
 #define MAC_STR(x) x[0], x[1], x[2], x[3], x[4], x[5]
 #define MAC_STR(x) x[0], x[1], x[2], x[3], x[4], x[5]
 
 
 /* struct timeval print structs */
 /* struct timeval print structs */
-#define TIMEVAL_FORMAT "%lu.%08lu"
+#define TIMEVAL_FORMAT "%lu.%06lu"
 
 
 /* force a word or half-word swap on both Big and Little endian systems */
 /* force a word or half-word swap on both Big and Little endian systems */
 #ifndef SWAPLONG
 #ifndef SWAPLONG

BIN
src/flow/._flownode.c


+ 1 - 0
src/flow/Makefile.in

@@ -132,6 +132,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@
 PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@
 PRINTF = @PRINTF@
 PRINTF = @PRINTF@
 RANLIB = @RANLIB@
 RANLIB = @RANLIB@
+SED = @SED@
 SET_MAKE = @SET_MAKE@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SHELL = @SHELL@
 STRIP = @STRIP@
 STRIP = @STRIP@

+ 2 - 2
src/flowreplay.1

@@ -1,7 +1,7 @@
-.TH FLOWREPLAY 1 2007-04-14 "(flowreplay )" "Programmer's Manual"
+.TH FLOWREPLAY 1 2007-04-21 "(flowreplay )" "Programmer's Manual"
 .\"  DO NOT EDIT THIS FILE   (flowreplay.1)
 .\"  DO NOT EDIT THIS FILE   (flowreplay.1)
 .\"  
 .\"  
-.\"  It has been AutoGen-ed  Saturday April 14, 2007 at 08:10:43 PM PDT
+.\"  It has been AutoGen-ed  Saturday April 21, 2007 at 10:41:06 AM PDT
 .\"  From the definitions    flowreplay_opts.def
 .\"  From the definitions    flowreplay_opts.def
 .\"  and the template file   agman1.tpl
 .\"  and the template file   agman1.tpl
 .\"
 .\"

+ 1 - 1
src/flowreplay_opts.c

@@ -2,7 +2,7 @@
  *  
  *  
  *  DO NOT EDIT THIS FILE   (flowreplay_opts.c)
  *  DO NOT EDIT THIS FILE   (flowreplay_opts.c)
  *  
  *  
- *  It has been AutoGen-ed  Saturday April 14, 2007 at 08:10:43 PM PDT
+ *  It has been AutoGen-ed  Saturday April 21, 2007 at 06:52:24 PM PDT
  *  From the definitions    flowreplay_opts.def
  *  From the definitions    flowreplay_opts.def
  *  and the template file   options
  *  and the template file   options
  *
  *

+ 1 - 1
src/flowreplay_opts.h

@@ -2,7 +2,7 @@
  *  
  *  
  *  DO NOT EDIT THIS FILE   (flowreplay_opts.h)
  *  DO NOT EDIT THIS FILE   (flowreplay_opts.h)
  *  
  *  
- *  It has been AutoGen-ed  Saturday April 14, 2007 at 08:10:42 PM PDT
+ *  It has been AutoGen-ed  Saturday April 21, 2007 at 06:52:24 PM PDT
  *  From the definitions    flowreplay_opts.def
  *  From the definitions    flowreplay_opts.def
  *  and the template file   options
  *  and the template file   options
  *
  *

+ 21 - 9
src/send_packets.c

@@ -1,4 +1,4 @@
-/* $Id: send_packets.c 1795 2007-04-11 04:51:58Z aturner $ */
+/* $Id: send_packets.c 1853 2007-05-02 04:40:39Z aturner $ */
 
 
 /*
 /*
  * Copyright (c) 2001-2007 Aaron Turner.
  * Copyright (c) 2001-2007 Aaron Turner.
@@ -94,14 +94,13 @@ send_packets(pcap_t *pcap, int cache_file_idx)
 
 
     /* register signals */
     /* register signals */
     didsig = 0;
     didsig = 0;
-    if (!options.speed.mode == SPEED_ONEATATIME) {
+    if (options.speed.mode != SPEED_ONEATATIME) {
         (void)signal(SIGINT, catcher);
         (void)signal(SIGINT, catcher);
-    }
-    else {
+    } else {
         (void)signal(SIGINT, break_now);
         (void)signal(SIGINT, break_now);
     }
     }
 
 
-	if( options.enable_file_cache ) {
+	if (options.enable_file_cache) {
 		prev_packet = &cached_packet;
 		prev_packet = &cached_packet;
 	} else {
 	} else {
 		prev_packet = NULL;
 		prev_packet = NULL;
@@ -170,9 +169,13 @@ send_packets(pcap_t *pcap, int cache_file_idx)
 		
 		
         /* 
         /* 
          * track the time of the "last packet sent".  Again, because of OpenBSD
          * track the time of the "last packet sent".  Again, because of OpenBSD
-         * we have to do a mempcy rather then assignment
+         * we have to do a mempcy rather then assignment. 
+         * 
+         * A number of 3rd party tools generate bad timestamps which go backwards
+         * in time.  Hence, don't update the "last" unless pkthdr.ts > last
          */
          */
-        memcpy(&last, &pkthdr.ts, sizeof(struct timeval));
+        if (timercmp(&last, &pkthdr.ts, <))
+            memcpy(&last, &pkthdr.ts, sizeof(struct timeval));
         pkts_sent ++;
         pkts_sent ++;
         bytes_sent += pktlen;
         bytes_sent += pktlen;
     } /* while */
     } /* while */
@@ -312,6 +315,9 @@ do_sleep(struct timeval *time, struct timeval *last, int len, int accurate, send
 {
 {
     static struct timeval didsleep = { 0, 0 };
     static struct timeval didsleep = { 0, 0 };
     static struct timeval start = { 0, 0 };
     static struct timeval start = { 0, 0 };
+#ifdef DEBUG
+    static struct timeval totalsleep = { 0, 0 };
+#endif
     struct timeval nap, now, delta;
     struct timeval nap, now, delta;
     struct timespec ignore, sleep;
     struct timespec ignore, sleep;
     float n;
     float n;
@@ -449,8 +455,11 @@ do_sleep(struct timeval *time, struct timeval *last, int len, int accurate, send
             timersub(&didsleep, &delta, &nap);
             timersub(&didsleep, &delta, &nap);
 
 
             sleep.tv_sec = nap.tv_sec;
             sleep.tv_sec = nap.tv_sec;
-            sleep.tv_nsec = nap.tv_usec * 1000; /* convert ms to ns */
-
+            sleep.tv_nsec = nap.tv_usec * 1000; /* convert microsec to ns */
+            dbgx(4, "Sleeping " TIMEVAL_FORMAT, nap.tv_sec, nap.tv_usec);
+#ifdef DEBUG
+            timeradd(&totalsleep, &nap, &totalsleep);
+#endif
             if (nanosleep(&sleep, &ignore) == -1) {
             if (nanosleep(&sleep, &ignore) == -1) {
                 warnx("nanosleep error: %s", strerror(errno));
                 warnx("nanosleep error: %s", strerror(errno));
             }
             }
@@ -460,6 +469,9 @@ do_sleep(struct timeval *time, struct timeval *last, int len, int accurate, send
         loop = sleep_loop(delta);
         loop = sleep_loop(delta);
         dbgx(3, "sleep_loop looped %u times", loop);
         dbgx(3, "sleep_loop looped %u times", loop);
     }
     }
+#ifdef DEBUG
+    dbgx(4, "Total sleep time: " TIMEVAL_FORMAT, totalsleep.tv_sec, totalsleep.tv_usec);
+#endif
 }
 }
 
 
 /*
 /*

+ 2 - 2
src/tcpbridge.1

@@ -1,7 +1,7 @@
-.TH TCPBRIDGE 1 2007-04-14 "(tcpbridge )" "Programmer's Manual"
+.TH TCPBRIDGE 1 2007-04-21 "(tcpbridge )" "Programmer's Manual"
 .\"  DO NOT EDIT THIS FILE   (tcpbridge.1)
 .\"  DO NOT EDIT THIS FILE   (tcpbridge.1)
 .\"  
 .\"  
-.\"  It has been AutoGen-ed  Saturday April 14, 2007 at 08:10:43 PM PDT
+.\"  It has been AutoGen-ed  Saturday April 21, 2007 at 10:41:06 AM PDT
 .\"  From the definitions    tcpbridge_opts.def
 .\"  From the definitions    tcpbridge_opts.def
 .\"  and the template file   agman1.tpl
 .\"  and the template file   agman1.tpl
 .\"
 .\"

+ 5 - 2
src/tcpbridge.c

@@ -1,4 +1,4 @@
-/* $Id: tcpbridge.c 1803 2007-04-14 22:47:18Z aturner $ */
+/* $Id: tcpbridge.c 1845 2007-04-27 02:48:10Z aturner $ */
 
 
 /*
 /*
  * Copyright (c) 2004-2005 Aaron Turner.
  * Copyright (c) 2004-2005 Aaron Turner.
@@ -158,8 +158,11 @@ post_args(__attribute__((unused)) int argc, __attribute__((unused)) char *argv[]
 {
 {
     char ebuf[SENDPACKET_ERRBUF_SIZE];
     char ebuf[SENDPACKET_ERRBUF_SIZE];
     char *intname;
     char *intname;
+#ifdef ENABLE_PCAP_FINDALLDEVS
     interface_list_t *intlist = get_interface_list();
     interface_list_t *intlist = get_interface_list();
-
+#else
+    interface_list_t *intlist = NULL;
+#endif
     
     
 #ifdef DEBUG
 #ifdef DEBUG
     if (HAVE_OPT(DBUG))
     if (HAVE_OPT(DBUG))

+ 1 - 1
src/tcpbridge_opts.c

@@ -2,7 +2,7 @@
  *  
  *  
  *  DO NOT EDIT THIS FILE   (tcpbridge_opts.c)
  *  DO NOT EDIT THIS FILE   (tcpbridge_opts.c)
  *  
  *  
- *  It has been AutoGen-ed  Saturday April 14, 2007 at 08:10:43 PM PDT
+ *  It has been AutoGen-ed  Saturday April 21, 2007 at 06:52:23 PM PDT
  *  From the definitions    tcpbridge_opts.def
  *  From the definitions    tcpbridge_opts.def
  *  and the template file   options
  *  and the template file   options
  *
  *

+ 1 - 1
src/tcpbridge_opts.h

@@ -2,7 +2,7 @@
  *  
  *  
  *  DO NOT EDIT THIS FILE   (tcpbridge_opts.h)
  *  DO NOT EDIT THIS FILE   (tcpbridge_opts.h)
  *  
  *  
- *  It has been AutoGen-ed  Saturday April 14, 2007 at 08:10:43 PM PDT
+ *  It has been AutoGen-ed  Saturday April 21, 2007 at 06:52:23 PM PDT
  *  From the definitions    tcpbridge_opts.def
  *  From the definitions    tcpbridge_opts.def
  *  and the template file   options
  *  and the template file   options
  *
  *

BIN
src/tcpedit/._edit_packet.c


+ 1 - 0
src/tcpedit/Makefile.in

@@ -204,6 +204,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@
 PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@
 PRINTF = @PRINTF@
 PRINTF = @PRINTF@
 RANLIB = @RANLIB@
 RANLIB = @RANLIB@
+SED = @SED@
 SET_MAKE = @SET_MAKE@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SHELL = @SHELL@
 STRIP = @STRIP@
 STRIP = @STRIP@

BIN
src/tcpedit/plugins/dlt_en10mb/._en10mb.c


BIN
src/tcpedit/plugins/dlt_en10mb/._en10mb.h


+ 5 - 5
src/tcpedit/plugins/dlt_en10mb/en10mb.c

@@ -1,4 +1,4 @@
-/* $Id:$ */
+/* $Id$ */
 
 
 /*
 /*
  * Copyright (c) 2006-2007 Aaron Turner.
  * Copyright (c) 2006-2007 Aaron Turner.
@@ -340,7 +340,7 @@ dlt_en10mb_encode(tcpeditdlt_t *ctx, u_char **packet_ex, int pktlen, tcpr_dir_t
     en10mb_config_t *config = NULL;
     en10mb_config_t *config = NULL;
     en10mb_extra_t *extra = NULL;
     en10mb_extra_t *extra = NULL;
     
     
-    int newl2len;
+    int newl2len = 0;
     u_char tmpbuff[MAXPACKET];
     u_char tmpbuff[MAXPACKET];
 
 
     assert(ctx);
     assert(ctx);
@@ -467,7 +467,7 @@ dlt_en10mb_encode(tcpeditdlt_t *ctx, u_char **packet_ex, int pktlen, tcpr_dir_t
         /* VLAN tags need a bit more */
         /* VLAN tags need a bit more */
         vlan = (struct tcpr_802_1q_hdr *)packet;
         vlan = (struct tcpr_802_1q_hdr *)packet;
         vlan->vlan_len = ctx->proto;
         vlan->vlan_len = ctx->proto;
-        vlan->vlan_tpi = ETHERTYPE_VLAN;
+        vlan->vlan_tpi = htons(ETHERTYPE_VLAN);
         
         
         /* are we changing VLAN info? */
         /* are we changing VLAN info? */
         if (config->vlan_tag < 65535) {
         if (config->vlan_tag < 65535) {
@@ -481,7 +481,7 @@ dlt_en10mb_encode(tcpeditdlt_t *ctx, u_char **packet_ex, int pktlen, tcpr_dir_t
         }
         }
         
         
         if (config->vlan_pri < 255) {
         if (config->vlan_pri < 255) {
-            vlan->vlan_priority_c_vid += htons((u_int16_t)config->vlan_pri) << 13;
+            vlan->vlan_priority_c_vid += htons((u_int16_t)config->vlan_pri << 13);
         } else if (extra->vlan) {
         } else if (extra->vlan) {
             vlan->vlan_priority_c_vid += extra->vlan_pri;
             vlan->vlan_priority_c_vid += extra->vlan_pri;
         } else {
         } else {
@@ -490,7 +490,7 @@ dlt_en10mb_encode(tcpeditdlt_t *ctx, u_char **packet_ex, int pktlen, tcpr_dir_t
         }
         }
             
             
         if (config->vlan_cfi < 255) {
         if (config->vlan_cfi < 255) {
-            vlan->vlan_priority_c_vid += htons((u_int16_t)config->vlan_cfi) << 12;
+            vlan->vlan_priority_c_vid += htons((u_int16_t)config->vlan_cfi << 12);
         } else if (extra->vlan) {
         } else if (extra->vlan) {
             vlan->vlan_priority_c_vid += extra->vlan_cfi;
             vlan->vlan_priority_c_vid += extra->vlan_cfi;
         } else {
         } else {

+ 3 - 4
src/tcpedit/plugins/dlt_hdlc/hdlc.c

@@ -227,7 +227,6 @@ dlt_hdlc_encode(tcpeditdlt_t *ctx, u_char **packet_ex, int pktlen, __attribute__
     hdlc_extra_t *extra = NULL;
     hdlc_extra_t *extra = NULL;
     tcpeditdlt_plugin_t *plugin = NULL;
     tcpeditdlt_plugin_t *plugin = NULL;
     u_char *packet;
     u_char *packet;
-    int l2len;
     u_char tmpbuff[MAXPACKET];
     u_char tmpbuff[MAXPACKET];
 
 
     assert(ctx);
     assert(ctx);
@@ -237,10 +236,10 @@ dlt_hdlc_encode(tcpeditdlt_t *ctx, u_char **packet_ex, int pktlen, __attribute__
     packet = *packet_ex;
     packet = *packet_ex;
     assert(packet);
     assert(packet);
 
 
-    /* Make room for our new l2 header if l2len != 4 */
-    if (l2len > 4) {
+    /* Make room for our new l2 header if old l2len != 4 */
+    if (ctx->l2len > 4) {
         memmove(packet + 4, packet + ctx->l2len, pktlen - ctx->l2len);
         memmove(packet + 4, packet + ctx->l2len, pktlen - ctx->l2len);
-    } else if (l2len < 4) {
+    } else if (ctx->l2len < 4) {
         memcpy(tmpbuff, packet, pktlen);
         memcpy(tmpbuff, packet, pktlen);
         memcpy(packet + 4, (tmpbuff + ctx->l2len), pktlen - ctx->l2len);
         memcpy(packet + 4, (tmpbuff + ctx->l2len), pktlen - ctx->l2len);
     }
     }

+ 2 - 2
src/tcpedit/tcpedit.c

@@ -1,4 +1,4 @@
-/* $Id: tcpedit.c 1802 2007-04-14 22:30:11Z aturner $ */
+/* $Id: tcpedit.c 1855 2007-05-02 04:54:38Z aturner $ */
 
 
 /*
 /*
  * Copyright (c) 2001-2007 Aaron Turner.
  * Copyright (c) 2001-2007 Aaron Turner.
@@ -69,7 +69,7 @@ tcpedit_packet(tcpedit_t *tcpedit, struct pcap_pkthdr **pkthdr,
 {
 {
     ipv4_hdr_t *ip_hdr = NULL;
     ipv4_hdr_t *ip_hdr = NULL;
     arp_hdr_t *arp_hdr = NULL;
     arp_hdr_t *arp_hdr = NULL;
-    int l2len = 0, l2proto, retval, dlt, pktlen, lendiff;
+    int l2len = 0, l2proto, retval = 0, dlt, pktlen, lendiff;
     int needtorecalc = 0;           /* did the packet change? if so, checksum */
     int needtorecalc = 0;           /* did the packet change? if so, checksum */
     static u_char *packet = NULL;   /* static buffer to hold packet data when padding out */
     static u_char *packet = NULL;   /* static buffer to hold packet data when padding out */
     
     

+ 1 - 1
src/tcpedit/tcpedit_stub.h

@@ -2,7 +2,7 @@
  *  
  *  
  *  DO NOT EDIT THIS FILE   (tcpedit_stub.h)
  *  DO NOT EDIT THIS FILE   (tcpedit_stub.h)
  *  
  *  
- *  It has been AutoGen-ed  Saturday April 14, 2007 at 08:10:44 PM PDT
+ *  It has been AutoGen-ed  Saturday April 21, 2007 at 06:52:15 PM PDT
  *  From the definitions    tcpedit_stub.def
  *  From the definitions    tcpedit_stub.def
  *  and the template file   options
  *  and the template file   options
  *
  *

+ 2 - 2
src/tcpprep.1

@@ -1,7 +1,7 @@
-.TH TCPPREP 1 2007-04-14 "(tcpprep )" "Programmer's Manual"
+.TH TCPPREP 1 2007-04-21 "(tcpprep )" "Programmer's Manual"
 .\"  DO NOT EDIT THIS FILE   (tcpprep.1)
 .\"  DO NOT EDIT THIS FILE   (tcpprep.1)
 .\"  
 .\"  
-.\"  It has been AutoGen-ed  Saturday April 14, 2007 at 08:10:43 PM PDT
+.\"  It has been AutoGen-ed  Saturday April 21, 2007 at 10:41:05 AM PDT
 .\"  From the definitions    tcpprep_opts.def
 .\"  From the definitions    tcpprep_opts.def
 .\"  and the template file   agman1.tpl
 .\"  and the template file   agman1.tpl
 .\"
 .\"

+ 2 - 7
src/tcpprep.c

@@ -1,4 +1,4 @@
-/* $Id: tcpprep.c 1801 2007-04-14 22:08:33Z aturner $ */
+/* $Id: tcpprep.c 1844 2007-04-27 02:42:36Z aturner $ */
 
 
 /*
 /*
  * Copyright (c) 2001-2007 Aaron Turner.
  * Copyright (c) 2001-2007 Aaron Turner.
@@ -121,11 +121,6 @@ main(int argc, char *argv[])
     if ((options.pcap = pcap_open_offline(OPT_ARG(PCAP), errbuf)) == NULL)
     if ((options.pcap = pcap_open_offline(OPT_ARG(PCAP), errbuf)) == NULL)
         errx(1, "Error opening file: %s", errbuf);
         errx(1, "Error opening file: %s", errbuf);
 
 
-#ifdef HAVE_PCAP_SNAPSHOT_OVERRIDE
-    /* libpcap >= 0.9.6 have this which handles broken RedHat libpcap files */
-    pcap_snapshot_override(options.pcap, 65535);
-#endif
-
     /* make sure we support the DLT type */
     /* make sure we support the DLT type */
     switch(pcap_datalink(options.pcap)) {
     switch(pcap_datalink(options.pcap)) {
         case DLT_EN10MB:
         case DLT_EN10MB:
@@ -369,7 +364,7 @@ process_raw_packets(pcap_t * pcap)
         case CIDR_MODE:
         case CIDR_MODE:
             dbg(2, "processing cidr mode...");
             dbg(2, "processing cidr mode...");
             cache_result = add_cache(&options.cachedata, SEND,
             cache_result = add_cache(&options.cachedata, SEND,
-                      check_ip_cidr(options.cidrdata, ip_hdr->ip_src.s_addr));
+                      check_ip_cidr(options.cidrdata, ip_hdr->ip_src.s_addr) ? TCPR_DIR_C2S : TCPR_DIR_S2C );
             break;
             break;
         case MAC_MODE:
         case MAC_MODE:
             dbg(2, "processing mac mode...");
             dbg(2, "processing mac mode...");

+ 1 - 1
src/tcpprep_opts.c

@@ -2,7 +2,7 @@
  *  
  *  
  *  DO NOT EDIT THIS FILE   (tcpprep_opts.c)
  *  DO NOT EDIT THIS FILE   (tcpprep_opts.c)
  *  
  *  
- *  It has been AutoGen-ed  Saturday April 14, 2007 at 08:10:42 PM PDT
+ *  It has been AutoGen-ed  Saturday April 21, 2007 at 06:52:20 PM PDT
  *  From the definitions    tcpprep_opts.def
  *  From the definitions    tcpprep_opts.def
  *  and the template file   options
  *  and the template file   options
  *
  *

+ 1 - 1
src/tcpprep_opts.h

@@ -2,7 +2,7 @@
  *  
  *  
  *  DO NOT EDIT THIS FILE   (tcpprep_opts.h)
  *  DO NOT EDIT THIS FILE   (tcpprep_opts.h)
  *  
  *  
- *  It has been AutoGen-ed  Saturday April 14, 2007 at 08:10:42 PM PDT
+ *  It has been AutoGen-ed  Saturday April 21, 2007 at 06:52:20 PM PDT
  *  From the definitions    tcpprep_opts.def
  *  From the definitions    tcpprep_opts.def
  *  and the template file   options
  *  and the template file   options
  *
  *

+ 2 - 2
src/tcpreplay.1

@@ -1,7 +1,7 @@
-.TH TCPREPLAY 1 2007-04-14 "(tcpreplay )" "Programmer's Manual"
+.TH TCPREPLAY 1 2007-04-30 "(tcpreplay )" "Programmer's Manual"
 .\"  DO NOT EDIT THIS FILE   (tcpreplay.1)
 .\"  DO NOT EDIT THIS FILE   (tcpreplay.1)
 .\"  
 .\"  
-.\"  It has been AutoGen-ed  Saturday April 14, 2007 at 08:10:43 PM PDT
+.\"  It has been AutoGen-ed  Monday April 30, 2007 at 01:31:13 PM PDT
 .\"  From the definitions    tcpreplay_opts.def
 .\"  From the definitions    tcpreplay_opts.def
 .\"  and the template file   agman1.tpl
 .\"  and the template file   agman1.tpl
 .\"
 .\"

+ 6 - 9
src/tcpreplay.c

@@ -1,4 +1,4 @@
-/* $Id: tcpreplay.c 1795 2007-04-11 04:51:58Z aturner $ */
+/* $Id: tcpreplay.c 1845 2007-04-27 02:48:10Z aturner $ */
 
 
 /*
 /*
  * Copyright (c) 2001-2007 Aaron Turner.
  * Copyright (c) 2001-2007 Aaron Turner.
@@ -198,13 +198,6 @@ replay_file(int file_idx)
 
 
     }
     }
     
     
-#ifdef HAVE_PCAP_SNAPSHOT_OVERRIDE
-    /* libpcap >= 0.9.6 have this which handles broken RedHat libpcap files */
-    if (pcap != NULL)
-        pcap_snapshot_override(pcap, 65535);
-#endif
-
-
 #ifdef ENABLE_VERBOSE
 #ifdef ENABLE_VERBOSE
     if (options.verbose) {
     if (options.verbose) {
         
         
@@ -278,8 +271,12 @@ post_args(void)
     char *temp, *intname;
     char *temp, *intname;
     char ebuf[SENDPACKET_ERRBUF_SIZE];
     char ebuf[SENDPACKET_ERRBUF_SIZE];
     int int1dlt, int2dlt;
     int int1dlt, int2dlt;
+    
+#ifdef ENABLE_PCAP_FINDALLDEVS
     interface_list_t *intlist = get_interface_list();
     interface_list_t *intlist = get_interface_list();
-
+#else
+    interface_list_t *intlist = NULL;
+#endif
 
 
 #ifdef DEBUG
 #ifdef DEBUG
     if (HAVE_OPT(DBUG))
     if (HAVE_OPT(DBUG))

+ 24 - 8
src/tcpreplay_opts.c

@@ -2,7 +2,7 @@
  *  
  *  
  *  DO NOT EDIT THIS FILE   (tcpreplay_opts.c)
  *  DO NOT EDIT THIS FILE   (tcpreplay_opts.c)
  *  
  *  
- *  It has been AutoGen-ed  Saturday April 14, 2007 at 08:10:42 PM PDT
+ *  It has been AutoGen-ed  Monday April 30, 2007 at 01:31:09 PM PDT
  *  From the definitions    tcpreplay_opts.def
  *  From the definitions    tcpreplay_opts.def
  *  and the template file   options
  *  and the template file   options
  *
  *
@@ -235,12 +235,21 @@ static const int
 /*
 /*
  *  Listnics option description:
  *  Listnics option description:
  */
  */
+#ifdef ENABLE_PCAP_FINDALLDEVS
 tSCC    zListnicsText[] =
 tSCC    zListnicsText[] =
         "List available network interfaces and exit";
         "List available network interfaces and exit";
 tSCC    zListnics_NAME[]           = "LISTNICS";
 tSCC    zListnics_NAME[]           = "LISTNICS";
 tSCC    zListnics_Name[]           = "listnics";
 tSCC    zListnics_Name[]           = "listnics";
 #define LISTNICS_FLAGS       (OPTST_DISABLED | OPTST_IMM)
 #define LISTNICS_FLAGS       (OPTST_DISABLED | OPTST_IMM)
 
 
+#else   /* disable Listnics */
+#define VALUE_OPT_LISTNICS NO_EQUIVALENT
+#define LISTNICS_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zListnicsText       NULL
+#define zListnics_NAME      NULL
+#define zListnics_Name      NULL
+#endif  /* ENABLE_PCAP_FINDALLDEVS */
+
 /*
 /*
  *  Loop option description:
  *  Loop option description:
  */
  */
@@ -411,11 +420,16 @@ tSCC zNotLoad_Opts_Pfx[]  = "no";
 #else /* not DEBUG */
 #else /* not DEBUG */
 # define doOptDbug NULL
 # define doOptDbug NULL
 #endif /* def/not DEBUG */
 #endif /* def/not DEBUG */
+#ifdef ENABLE_PCAP_FINDALLDEVS
+  static tOptProc doOptListnics;
+#else /* not ENABLE_PCAP_FINDALLDEVS */
+# define doOptListnics NULL
+#endif /* def/not ENABLE_PCAP_FINDALLDEVS */
 extern tOptProc
 extern tOptProc
     optionNumericVal, optionPagedUsage;
     optionNumericVal, optionPagedUsage;
 static tOptProc
 static tOptProc
-    doOptLess_Help, doOptLimit,     doOptListnics,  doOptLoop,
-    doOptPid,       doOptVersion,   doUsageOpt;
+    doOptLess_Help, doOptLimit,     doOptLoop,      doOptPid,
+    doOptVersion,   doUsageOpt;
 
 
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  *
  *
@@ -859,14 +873,15 @@ doOptDbug(
 
 
 /* * * * * * *
 /* * * * * * *
  *
  *
- *   For the listnics option.
+ *   For the listnics option, when ENABLE_PCAP_FINDALLDEVS is #define-d.
  */
  */
+#ifdef ENABLE_PCAP_FINDALLDEVS
 static void
 static void
 doOptListnics(
 doOptListnics(
     tOptions*   pOptions,
     tOptions*   pOptions,
     tOptDesc*   pOptDesc )
     tOptDesc*   pOptDesc )
 {
 {
-    /* extracted from tcpreplay_opts.def, line 208 */
+    /* extracted from tcpreplay_opts.def, line 209 */
 
 
 interface_list_t *list = get_interface_list();
 interface_list_t *list = get_interface_list();
 list_interfaces(list);
 list_interfaces(list);
@@ -874,6 +889,7 @@ free(list);
     exit(0);
     exit(0);
 
 
 }
 }
+#endif /* defined ENABLE_PCAP_FINDALLDEVS */
 
 
 /* * * * * * *
 /* * * * * * *
  *
  *
@@ -986,7 +1002,7 @@ doOptPid(
     tOptions*   pOptions,
     tOptions*   pOptions,
     tOptDesc*   pOptDesc )
     tOptDesc*   pOptDesc )
 {
 {
-    /* extracted from tcpreplay_opts.def, line 344 */
+    /* extracted from tcpreplay_opts.def, line 345 */
     
     
     fprintf(stderr, "PID: %hu\n", getpid());
     fprintf(stderr, "PID: %hu\n", getpid());
     
     
@@ -1001,7 +1017,7 @@ doOptVersion(
     tOptions*   pOptions,
     tOptions*   pOptions,
     tOptDesc*   pOptDesc )
     tOptDesc*   pOptDesc )
 {
 {
-    /* extracted from tcpreplay_opts.def, line 356 */
+    /* extracted from tcpreplay_opts.def, line 357 */
     
     
     fprintf(stderr, "tcpreplay version: %s (build %s)", VERSION, svn_version());
     fprintf(stderr, "tcpreplay version: %s (build %s)", VERSION, svn_version());
 #ifdef DEBUG
 #ifdef DEBUG
@@ -1043,7 +1059,7 @@ doOptLess_Help(
     tOptions*   pOptions,
     tOptions*   pOptions,
     tOptDesc*   pOptDesc )
     tOptDesc*   pOptDesc )
 {
 {
-    /* extracted from tcpreplay_opts.def, line 396 */
+    /* extracted from tcpreplay_opts.def, line 397 */
   
   
     USAGE(EXIT_FAILURE);
     USAGE(EXIT_FAILURE);
 
 

+ 1 - 0
src/tcpreplay_opts.def

@@ -199,6 +199,7 @@ flag = {
 };
 };
 
 
 flag = {
 flag = {
+	ifdef		= ENABLE_PCAP_FINDALLDEVS;
 	name		= listnics;
 	name		= listnics;
 	value		= N;
 	value		= N;
 	descrip		= "List available network interfaces and exit";
 	descrip		= "List available network interfaces and exit";

+ 3 - 1
src/tcpreplay_opts.h

@@ -2,7 +2,7 @@
  *  
  *  
  *  DO NOT EDIT THIS FILE   (tcpreplay_opts.h)
  *  DO NOT EDIT THIS FILE   (tcpreplay_opts.h)
  *  
  *  
- *  It has been AutoGen-ed  Saturday April 14, 2007 at 08:10:42 PM PDT
+ *  It has been AutoGen-ed  Monday April 30, 2007 at 01:31:09 PM PDT
  *  From the definitions    tcpreplay_opts.def
  *  From the definitions    tcpreplay_opts.def
  *  and the template file   options
  *  and the template file   options
  *
  *
@@ -151,7 +151,9 @@ typedef enum {
 #define VALUE_OPT_CACHEFILE      'c'
 #define VALUE_OPT_CACHEFILE      'c'
 #define VALUE_OPT_INTF1          'i'
 #define VALUE_OPT_INTF1          'i'
 #define VALUE_OPT_INTF2          'I'
 #define VALUE_OPT_INTF2          'I'
+#ifdef ENABLE_PCAP_FINDALLDEVS
 #define VALUE_OPT_LISTNICS       'N'
 #define VALUE_OPT_LISTNICS       'N'
+#endif /* ENABLE_PCAP_FINDALLDEVS */
 #define VALUE_OPT_LOOP           'l'
 #define VALUE_OPT_LOOP           'l'
 #define OPT_VALUE_LOOP           (DESC(LOOP).optArg.argInt)
 #define OPT_VALUE_LOOP           (DESC(LOOP).optArg.argInt)
 #define VALUE_OPT_PKTLEN         'S'
 #define VALUE_OPT_PKTLEN         'S'

+ 2 - 2
src/tcprewrite.1

@@ -1,7 +1,7 @@
-.TH TCPREWRITE 1 2007-04-14 "(tcprewrite )" "Programmer's Manual"
+.TH TCPREWRITE 1 2007-04-21 "(tcprewrite )" "Programmer's Manual"
 .\"  DO NOT EDIT THIS FILE   (tcprewrite.1)
 .\"  DO NOT EDIT THIS FILE   (tcprewrite.1)
 .\"  
 .\"  
-.\"  It has been AutoGen-ed  Saturday April 14, 2007 at 08:10:43 PM PDT
+.\"  It has been AutoGen-ed  Saturday April 21, 2007 at 10:41:05 AM PDT
 .\"  From the definitions    tcprewrite_opts.def
 .\"  From the definitions    tcprewrite_opts.def
 .\"  and the template file   agman1.tpl
 .\"  and the template file   agman1.tpl
 .\"
 .\"

+ 1 - 6
src/tcprewrite.c

@@ -1,4 +1,4 @@
-/* $Id: tcprewrite.c 1795 2007-04-11 04:51:58Z aturner $ */
+/* $Id: tcprewrite.c 1820 2007-04-19 06:31:03Z aturner $ */
 
 
 /*
 /*
  * Copyright (c) 2004-2007 Aaron Turner.
  * Copyright (c) 2004-2007 Aaron Turner.
@@ -197,11 +197,6 @@ rewrite_packets(tcpedit_t *tcpedit, pcap_t *pin, pcap_dumper_t *pout)
 
 
     pkthdr_ptr = &pkthdr;
     pkthdr_ptr = &pkthdr;
 
 
-#ifdef HAVE_PCAP_SNAPSHOT_OVERRIDE
-    /* libpcap >= 0.9.6 have this which handles broken RedHat libpcap files */
-    pcap_snapshot_override(pin, 65535);
-#endif
-
     /* MAIN LOOP 
     /* MAIN LOOP 
      * Keep sending while we have packets or until
      * Keep sending while we have packets or until
      * we've sent enough packets
      * we've sent enough packets

+ 1 - 1
src/tcprewrite_opts.c

@@ -2,7 +2,7 @@
  *  
  *  
  *  DO NOT EDIT THIS FILE   (tcprewrite_opts.c)
  *  DO NOT EDIT THIS FILE   (tcprewrite_opts.c)
  *  
  *  
- *  It has been AutoGen-ed  Saturday April 14, 2007 at 08:10:42 PM PDT
+ *  It has been AutoGen-ed  Saturday April 21, 2007 at 06:52:22 PM PDT
  *  From the definitions    tcprewrite_opts.def
  *  From the definitions    tcprewrite_opts.def
  *  and the template file   options
  *  and the template file   options
  *
  *

+ 1 - 1
src/tcprewrite_opts.h

@@ -2,7 +2,7 @@
  *  
  *  
  *  DO NOT EDIT THIS FILE   (tcprewrite_opts.h)
  *  DO NOT EDIT THIS FILE   (tcprewrite_opts.h)
  *  
  *  
- *  It has been AutoGen-ed  Saturday April 14, 2007 at 08:10:42 PM PDT
+ *  It has been AutoGen-ed  Saturday April 21, 2007 at 06:52:22 PM PDT
  *  From the definitions    tcprewrite_opts.def
  *  From the definitions    tcprewrite_opts.def
  *  and the template file   options
  *  and the template file   options
  *
  *

+ 1 - 0
test/Makefile.in

@@ -108,6 +108,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
 PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@
 PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@
 PRINTF = @PRINTF@
 PRINTF = @PRINTF@
 RANLIB = @RANLIB@
 RANLIB = @RANLIB@
+SED = @SED@
 SET_MAKE = @SET_MAKE@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 SHELL = @SHELL@
 STRIP = @STRIP@
 STRIP = @STRIP@

BIN
test/test2.rewrite_config


BIN
test/test2.rewrite_pnat