Browse Source

Import upstream version 2.99+3.0.beta11

Aaron Turner 18 years ago
parent
commit
7fba252a4b
100 changed files with 3013 additions and 947 deletions
  1. BIN
      ._Makefile.am
  2. 4 4
      Makefile.in
  3. 6 2
      README
  4. 600 235
      configure
  5. 324 177
      configure.in
  6. 35 11
      docs/CHANGELOG
  7. BIN
      docs/FAQ.pdf
  8. 4 1
      docs/INSTALL
  9. 4 4
      docs/LICENSE
  10. 4 4
      docs/Makefile.in
  11. BIN
      docs/flowreplay.pdf
  12. 206 203
      docs/manual.pdf
  13. 1 1
      docs/web/FAQ/FAQ.html
  14. 1 1
      docs/web/FAQ/index.html
  15. 1 1
      docs/web/FAQ/node1.html
  16. 1 1
      docs/web/FAQ/node2.html
  17. 1 1
      docs/web/FAQ/node3.html
  18. 1 1
      docs/web/FAQ/node4.html
  19. 1 1
      docs/web/FAQ/node5.html
  20. 1 1
      docs/web/FAQ/node6.html
  21. 1 1
      docs/web/FAQ/node7.html
  22. 1 1
      docs/web/FAQ/node8.html
  23. 1 1
      docs/web/FAQ/node9.html
  24. 1 1
      docs/web/flowreplay/flowreplay.html
  25. 1 1
      docs/web/flowreplay/images.log
  26. BIN
      docs/web/flowreplay/img1.old
  27. 1 1
      docs/web/flowreplay/index.html
  28. 1 1
      docs/web/flowreplay/node1.html
  29. 1 1
      docs/web/flowreplay/node2.html
  30. 1 1
      docs/web/flowreplay/node3.html
  31. 1 1
      docs/web/flowreplay/node4.html
  32. 1 1
      docs/web/flowreplay/node5.html
  33. 1 1
      docs/web/flowreplay/node6.html
  34. 18 9
      docs/web/man/tcpprep.html
  35. 7 0
      docs/web/man/tcpreplay.html
  36. 53 8
      docs/web/man/tcprewrite.html
  37. 10 12
      docs/web/manual/images.log
  38. 3 3
      docs/web/manual/images.pl
  39. 1 1
      docs/web/manual/images.tex
  40. BIN
      docs/web/manual/img1.old
  41. BIN
      docs/web/manual/img1.png
  42. 2 5
      docs/web/manual/index.html
  43. 2 5
      docs/web/manual/manual.html
  44. 1 1
      docs/web/manual/node1.html
  45. BIN
      docs/web/manual/router-mode3.png
  46. 8 114
      doxygen.cfg.in
  47. 4 4
      lib/Makefile.in
  48. BIN
      libopts/._README
  49. 4 4
      libopts/Makefile.in
  50. 4 4
      scripts/Makefile.in
  51. 105 28
      scripts/dlt2name.pl
  52. BIN
      src/._common.h
  53. BIN
      src/._defines.h.in
  54. BIN
      src/._dlt_names.h
  55. BIN
      src/._flowreplay.c
  56. BIN
      src/._flowreplay_opts.def
  57. BIN
      src/._mac.c
  58. BIN
      src/._send_packets.c
  59. BIN
      src/._signal_handler.c
  60. BIN
      src/._tcpbridge_opts.def
  61. BIN
      src/._tcpprep.c
  62. BIN
      src/._tcpprep.h
  63. BIN
      src/._tcpprep_opts.def
  64. BIN
      src/._tcprewrite.c
  65. BIN
      src/._tcprewrite.h
  66. BIN
      src/._tcprewrite_opts.def
  67. BIN
      src/._tree.c
  68. BIN
      src/._tree.h
  69. 18 14
      src/Makefile.am
  70. 21 20
      src/Makefile.in
  71. 15 22
      src/bridge.c
  72. 2 2
      src/bridge.h
  73. 1 0
      src/common.h
  74. BIN
      src/common/._cache.c
  75. BIN
      src/common/._cache.h
  76. BIN
      src/common/._cidr.c
  77. BIN
      src/common/._cidr.h
  78. BIN
      src/common/._fakepcapnav.h
  79. BIN
      src/common/._get.c
  80. BIN
      src/common/._get.h
  81. BIN
      src/common/._list.c
  82. BIN
      src/common/._services.c
  83. BIN
      src/common/._tcpdump.h
  84. BIN
      src/common/._xX.c
  85. BIN
      src/common/._xX.h
  86. 5 3
      src/common/Makefile.am
  87. 13 8
      src/common/Makefile.in
  88. 4 1
      src/common/abort.c
  89. 2 1
      src/common/cache.c
  90. 2 2
      src/common/cidr.c
  91. 248 0
      src/common/dlt_names.c
  92. 457 0
      src/common/dlt_names.h
  93. 1 3
      src/common/fakepcap.c
  94. 16 8
      src/common/get.c
  95. 3 2
      src/common/get.h
  96. 693 0
      src/common/sendpacket.c
  97. 78 0
      src/common/sendpacket.h
  98. 4 1
      src/common/services.c
  99. 1 1
      src/common/svn_version.c
  100. 0 0
      src/common/tcpdump.c

BIN
._Makefile.am


+ 4 - 4
Makefile.in

@@ -102,14 +102,16 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ENABLE_FLOWREPLAY_FALSE = @ENABLE_FLOWREPLAY_FALSE@
+ENABLE_FLOWREPLAY_TRUE = @ENABLE_FLOWREPLAY_TRUE@
+ENABLE_TCPBRIDGE_FALSE = @ENABLE_TCPBRIDGE_FALSE@
+ENABLE_TCPBRIDGE_TRUE = @ENABLE_TCPBRIDGE_TRUE@
 EXEEXT = @EXEEXT@
 F77 = @F77@
 FFLAGS = @FFLAGS@
 FIG2DEV = @FIG2DEV@
 HAVE_DOCTOOLS_FALSE = @HAVE_DOCTOOLS_FALSE@
 HAVE_DOCTOOLS_TRUE = @HAVE_DOCTOOLS_TRUE@
-HAVE_LIBNIDS_FALSE = @HAVE_LIBNIDS_FALSE@
-HAVE_LIBNIDS_TRUE = @HAVE_LIBNIDS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
@@ -126,8 +128,6 @@ LNAVLIB = @LNAVLIB@
 LNAV_CFLAGS = @LNAV_CFLAGS@
 LNETINC = @LNETINC@
 LNETLIB = @LNETLIB@
-LNIDSINC = @LNIDSINC@
-LNIDSLIB = @LNIDSLIB@
 LN_S = @LN_S@
 LPCAPINC = @LPCAPINC@
 LPCAPLIB = @LPCAPLIB@

+ 6 - 2
README

@@ -1,4 +1,4 @@
-$Id: README 1476 2006-07-07 04:53:44Z aturner $
+$Id: README 1544 2006-07-29 06:21:36Z aturner $
 [Please note that licensing, compiling, usage and other documentation can be 
 found in the docs subdirectory.]
 
@@ -19,7 +19,7 @@ If your problem has to do with RUNNING tcpreplay or one of the sub-tools:
 - Version information (output of -V)
 - Command line used (options and arguments)
 - Platform (Red Hat Linux 9 on Intel, Solaris 7 on SPARC, etc)
-- Make & model of the network card(s) and driver(s)
+- Make & model of the network card(s) and driver(s) version
 - Error message (if available) and/or description of problem
 - If possible, attach the pcap file used (compressed with bzip2 or gzip
     preferred)
@@ -42,3 +42,7 @@ showing up in the list archives.
 
 Thanks,
 Aaron (tcpreplay author)
+
+PS:
+This product includes software developed by the University of
+California, Berkeley and its contributors.

File diff suppressed because it is too large
+ 600 - 235
configure


+ 324 - 177
configure.in

@@ -1,5 +1,5 @@
 
-dnl $Id: configure.in 1519 2006-07-18 02:51:09Z aturner $
+dnl $Id: configure.in 1578 2006-08-08 04:02:14Z aturner $
 
 AC_INIT(tcpreplay)
 AC_CONFIG_SRCDIR(src/tcpreplay.c)
@@ -12,7 +12,7 @@ AC_PROG_LIBTOOL
 dnl Set version info here!
 MAJOR_VERSION=3
 MINOR_VERSION=0
-MICRO_VERSION=beta9
+MICRO_VERSION=beta11
 TCPREPLAY_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
 
 dnl Release is only used for the RPM spec file
@@ -119,7 +119,7 @@ AC_FUNC_MALLOC
 AC_FUNC_MEMCMP
 AC_TYPE_SIGNAL
 AC_FUNC_VPRINTF
-AC_CHECK_FUNCS([gettimeofday ctime memset regcomp strdup strerror strtol strncpy strtoull poll ntohll mmap])
+AC_CHECK_FUNCS([gettimeofday ctime memset regcomp strdup strerror strtol strncpy strtoull poll ntohll mmap snprintf vsnprintf])
 
 dnl Look for strlcpy since some BSD's have it
 AC_CHECK_FUNCS([strlcpy],have_strlcpy=true,have_strlcpy=false)
@@ -142,10 +142,16 @@ AC_ARG_ENABLE(debug,
     AC_HELP_STRING([--enable-debug], [Enable debugging code and support for the -d option]),
     [ if test x$enableval = xyes; then
          debug=yes
-         CFLAGS="-ggdb -std=gnu99 -Wall -Wextra -Wfatal-errors -Wno-variadic-macros"
+		# check for gcc 4.0 flags -Wfatal-errors & -Wno-variadic-macros support
+		CFLAGS="-ggdb -std=gnu99 -Wall -Wextra -Wfatal-errors -Wno-variadic-macros"
+		 AC_COMPILE_IFELSE([#include <stdlib.h>
+			int main(int argc, char *argv[]) { return(0); }], 
+			[CFLAGS="-ggdb -std=gnu99 -Wall -Wextra -Wfatal-errors -Wno-variadic-macros"],
+			[CFLAGS="-ggdb -std=gnu99 -Wall -Wextra"])
+# We may also want to add:
 #         -Wformat-security -Wswitch-default -Wunused-paramter -Wpadded"
          AC_SUBST(debug_flag)
-         AC_DEFINE([DEBUG], [], [Enable debuggin code and support for the -d option]) 
+         AC_DEFINE([DEBUG], [1], [Enable debuging code and support for the -d option]) 
       fi])
 
 AC_ARG_ENABLE(pedantic,
@@ -159,7 +165,7 @@ AC_ARG_ENABLE(efence,
     AC_HELP_STRING([--enable-efence], [Enable Electric Fence memory debugger]),
     [ if test x$enableval = xyes; then
           CFLAGS="$CFLAGS -lefence"
-          AC_DEFINE([EFENCE], [], [Enable Electric Fence memory debugger])
+          AC_DEFINE([EFENCE], [1], [Enable Electric Fence memory debugger])
       fi])
 
 dnl Enable Gprof
@@ -172,41 +178,74 @@ AC_ARG_ENABLE(gprof,
               # GPROF requires gdb
               CFLAGS="$CFLAGS -ggdb -pg -fprofile-arcs"
           fi
-          AC_DEFINE([GPROF], [], [Enable GNU Profiler])
+          AC_DEFINE([GPROF], [1], [Enable GNU Profiler])
       fi])
 
 dnl Use 64bits for packet counters
 AC_ARG_ENABLE(64bits,
     AC_HELP_STRING([--enable-64bits], [Use 64bit packet counters]),
     [ if test x$enableval = xyes; then
-         AC_DEFINE([ENABLE_64BITS], [], [Use 64bit packet counters])
+         AC_DEFINE([ENABLE_64BITS], [1], [Use 64bit packet counters])
          AC_MSG_NOTICE([Using u_int64_t for packet counters])
       else
          AC_MSG_NOTICE([Using u_int32_t for packet counters])
       fi
     ])
 
+disable_bpf=no
+dnl Turn off *BSD's BPF
+AC_ARG_ENABLE(bpf,
+	AC_HELP_STRING([--disable-bpf], [Disable BPF for sending packets]),
+	[ disable_bpf=yes ])
+	
+disable_pf=no
+dnl Turn off Linux's PF_PACKET
+AC_ARG_ENABLE(pf,
+	AC_HELP_STRING([--disable-pf], [Disable Linux PF_PACKET for sending packets]),
+	[ if test x$enableval = xno ; then
+		disable_pf=yes
+	  fi
+	])
+	
+disable_libnet=no
+dnl Turn of Libnet
+AC_ARG_ENABLE(libnet,
+	AC_HELP_STRING([--disable-libnet], [Disable Libnet for sending packets]),
+	[ if test x$enableval = xno ; then
+		disable_libnet=yes
+	  fi
+	])
+	
+disable_pcap=no
+dnl Turn off pcap for sending
+AC_ARG_ENABLE(pcap,
+	AC_HELP_STRING([--disable-pcap], [Disable Libpcap for sending packets]),
+	[ if test x$enableval = xno ; then
+		disable_pcap=yes
+	  fi
+	])
+
 dnl Dynamic link libraries
 dynamic_link=no
 AC_ARG_ENABLE(dynamic-link,
     AC_HELP_STRING([--enable-dynamic-link], [Dynamically link libraries]),
     [ if test x$enableval = xyes; then
-        AC_DEFINE([ENABLE_DYNAMIC_LINK], [], [Enable dynamically linking libs])
+        AC_DEFINE([ENABLE_DYNAMIC_LINK], [1], [Enable dynamically linking libs])
         dynamic_link=yes
       fi
     ])
 
 dnl Check for inet_aton and inet_pton
 AC_CHECK_FUNC(inet_aton, 
-    AC_DEFINE([HAVE_INET_ATON], [], [Do we have inet_aton?]) 
+    AC_DEFINE([HAVE_INET_ATON], [1], [Do we have inet_aton?]) 
     inet_aton=yes, 
     inet_aton=no)
 AC_CHECK_FUNC(inet_pton, 
-    AC_DEFINE([HAVE_INET_PTON], [], [Do we have inet_pton?]) 
+    AC_DEFINE([HAVE_INET_PTON], [1], [Do we have inet_pton?]) 
     inet_pton=yes, 
     inet_pton=no)
 AC_CHECK_FUNC(inet_ntop, 
-    AC_DEFINE([HAVE_INET_NTOP], [], [Do we have inet_ntop?]) 
+    AC_DEFINE([HAVE_INET_NTOP], [1], [Do we have inet_ntop?]) 
     inet_ntop=yes, 
     inet_ntop=no)
 
@@ -219,7 +258,7 @@ if test "$inet_aton" = "no" ; then
 fi
 
 AC_CHECK_FUNC(inet_addr, 
-    AC_DEFINE([HAVE_INET_ADDR], [], [Do we have inet_addr?]) 
+    AC_DEFINE([HAVE_INET_ADDR], [1], [Do we have inet_addr?]) 
     inet_addr=yes, 
     inet_addr=no)
 
@@ -227,142 +266,133 @@ if test x$inet_addr = no ; then
     AC_MSG_ERROR([We need inet_addr.  See bug 26])
 fi
 
+dnl Enable flowreplay
+flowreplay=no
+AC_ARG_ENABLE(flowreplay,
+    AC_HELP_STRING([--enable-flowreplay], [Enable building flowreplay (alpha)]),
+    [ if test x$enableval = xyes; then
+         flowreplay=yes
+         AC_DEFINE([ENABLE_FLOWREPLAY], [1], [Enable building flowreplay (alpha)]) 
+      fi])
 
+AM_CONDITIONAL(ENABLE_FLOWREPLAY, [test x$flowreplay = xyes])
 
 dnl ##################################################
 dnl Checks for libnet (shamelessly horked from dsniff)
 dnl ##################################################
 foundnet=no
-trynetdir=/usr/local
-AC_MSG_CHECKING(for libnet)
-AC_ARG_WITH(libnet,
-    AC_HELP_STRING([--with-libnet=DIR], [Use libnet in DIR]),
-    [trynetdir=$withval])
-
-for testdir in $trynetdir /usr/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 $disable_libnet = no ; then 
+
+	trynetdir=/usr/local
+	AC_MSG_CHECKING(for libnet)
+	AC_ARG_WITH(libnet,
+	    AC_HELP_STRING([--with-libnet=DIR], [Use libnet in DIR]),
+	    [trynetdir=$withval])
+
+	for testdir in $trynetdir /usr/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 $foundnet = no ; then
+	    AC_MSG_RESULT(no)
+	else 
+	    AC_MSG_RESULT($foundnet) 
+		AC_DEFINE([HAVE_LIBNET], [1], [Enable libnet support])
+	fi
 
-if test $foundnet = no ; then
-     AC_MSG_RESULT(no)
-     AC_ERROR(libnet not found)
-else 
-     AC_MSG_RESULT($foundnet) 
+	AC_SUBST(LNETINC)
+	AC_SUBST(LNETLIB)
 fi
 
-AC_SUBST(LNETINC)
-AC_SUBST(LNETLIB)
+dnl END OF if $disable_libnet = no ; then
 
-OLDLIBS="$LIBS"
-OLDCFLAGS="$CFLAGS"
-LIBS="$LNETLIB"
-CFLAGS="$CFLAGS -I$LNETINCDIR"
+if test $foundnet = yes ; then
+	OLDLIBS="$LIBS"
+	OLDCFLAGS="$CFLAGS"
+	LIBS="$LNETLIB"
+	CFLAGS="$CFLAGS -I$LNETINCDIR"
 
-dnl Check to see what version of libnet
-dnl this code has been reduced a lot, but probably still could be
-dnl reduced quite a bit more if we chose too
-AC_MSG_CHECKING(for libnet version)
 
-AC_TRY_RUN([
+	dnl Check to see what version of libnet
+	dnl this code has been reduced a lot, but probably still could be
+	dnl reduced quite a bit more if we chose too
+	AC_MSG_CHECKING(for libnet version)
+
+	AC_TRY_RUN([
 #include <string.h>
 #define LIBNET_LIL_ENDIAN 1
 #include "$LNETINC"
 #define LIB_TEST "1.0"
-/* 
- * simple proggy to test the version of libnet
- * returns zero if it's 1.0.x 
- * or one otherwise
- */
-int
-main (int argc, char *argv[])
-{
-        if (strncmp(LIB_TEST, LIBNET_VERSION, 3) == 0)
-                exit(0);
-        exit(1);
-}],
-        libnet_ver_10=yes
-        AC_MSG_RESULT(1.0.x), 
-        libnet_ver_10=no,
-        libnet_ver_10=no
-        )
-
-AC_TRY_RUN([
+	/* 
+	 * simple proggy to test the version of libnet
+	 * returns zero if it's 1.0.x 
+	 * or one otherwise
+	 */
+	int
+	main (int argc, char *argv[])
+	{
+	        if (strncmp(LIB_TEST, LIBNET_VERSION, 3) == 0)
+	                exit(0);
+	        exit(1);
+	}],
+	        libnet_ver_10=yes
+	        AC_MSG_RESULT(1.0.x), 
+	        libnet_ver_10=no,
+	        libnet_ver_10=no
+	        )
+
+	AC_TRY_RUN([
 #include <string.h>
 #include "$LNETINC"
 #define LIB_TEST "1.1"
-/* 
- * simple proggy to test the version of libnet
- * returns zero if it's 1.0.x 
- * or one otherwise
- */
-int
-main (int argc, char *argv[])
-{
-        if (strncmp(LIB_TEST, LIBNET_VERSION, 3) == 0)
-                exit(0);
-        exit(1);
-}],
-        libnet_ver_11=yes
-        AC_MSG_RESULT(1.1.x), 
-        libnet_ver_11=no,
-        libnet_ver_11=no
-        )
+	/* 
+	 * simple proggy to test the version of libnet
+	 * returns zero if it's 1.0.x 
+	 * or one otherwise
+	 */
+	int
+	main (int argc, char *argv[])
+	{
+	        if (strncmp(LIB_TEST, LIBNET_VERSION, 3) == 0)
+	                exit(0);
+	        exit(1);
+	}],
+	        libnet_ver_11=yes
+	        AC_MSG_RESULT(1.1.x), 
+	        libnet_ver_11=no,
+	        libnet_ver_11=no
+	        )
+
+
+	if test $libnet_ver_10 = no -a $libnet_ver_11 = no ; then
+	        AC_MSG_RESULT(unknown)
+	        AC_MSG_ERROR(Unable to determine version of libnet)
+	fi
 
+	if test $libnet_ver_10 = yes ; then
+	          AC_MSG_ERROR(Libnet version 1.0.x is no longer supported.
+	                Please upgrade to 1.1.0 or better)
+	fi
 
-if test $libnet_ver_10 = no -a $libnet_ver_11 = no ; then
-        AC_MSG_RESULT(unknown)
-        AC_MSG_ERROR(Unable to determine version of libnet)
-fi
 
-if test $libnet_ver_10 = yes ; then
-          AC_MSG_ERROR(Libnet version 1.0.x is no longer supported.
-                Please upgrade to 1.1.0 or better)
-fi
+	dnl restore LIBS & CFLAGS
+	LIBS="$OLDLIBS"
+	CFLAGS="$OLDCFLAGS"
 
-AC_MSG_CHECKING([for working libnet_checksum()])
-AC_TRY_RUN([
-#include <string.h>
-#include "$LNETINC"
-#define LIB_TEST "1.1.3"
-/* 
- * simple proggy to test the version of libnet
- * returns zero if it's < 1.1.3 which has the checksum fix
- * or one otherwise
- */
-int
-main (int argc, char *argv[])
-{
-        if (strncmp(LIB_TEST, LIBNET_VERSION, 5) <= 0)
-                exit(0);
-        exit(1);
-}],
-        libnet_ver_113=yes,
-        libnet_ver_113=no,
-        libnet_ver_113=no
-        )
+fi 
 
-if test $libnet_ver_113 = no ; then
-    AC_MSG_RESULT(no)
-    AC_MSG_WARN([You should upgrade to libnet 1.1.3 or better if you
-    want to modify packets])
-else
-    AC_MSG_RESULT(yes)
-fi
-
-dnl restore LIBS & CFLAGS
-LIBS="$OLDLIBS"
-CFLAGS="$OLDCFLAGS"
+dnl END OF if test $foundnet = yes
 
 dnl #####################################################
 dnl Checks for libpcap
@@ -406,6 +436,8 @@ OLDCFLAGS="$CFLAGS"
 LIBS="$LPCAPLIB"
 CFLAGS="$CFLAGS -I$LPCAPINCDIR"
 
+
+have_libnet=no
 dnl Check to see what version of libpcap
 dnl this code has been reduced a lot, but probably still could be
 dnl reduced quite a bit more if we chose too
@@ -435,6 +467,7 @@ main (int argc, char *argv[])
         libpcap_ver=no
         AC_MSG_RESULT(< 0.5),
         libpcap_ver=no
+		AC_MSG_RESULT(< 0.5)
         )
 
 
@@ -450,42 +483,189 @@ AC_TRY_RUN([
 #include <stdlib.h>
 #include <string.h>
 #include "$LPCAPINC"
+
 int 
 main(int argc, char *argv[]) {
     pcap_datalink_val_to_description(1);
     exit(0);
-} 
-],
+}],
     have_dlt_to_desc=yes 
     AC_MSG_RESULT(yes), 
     have_dlt_to_desc=no
     AC_MSG_RESULT(no),
     have_dlt_to_desc=no
+	AC_MSG_RESULT(no)
     )
 
 if test $have_dlt_to_desc = yes ; then
-    AC_DEFINE([HAVE_DLT_VAL_TO_DESC], [], 
+    AC_DEFINE([HAVE_DLT_VAL_TO_DESC], [1], 
               [Does libpcap have dlt_val_to_desc?])
 fi
 
+dnl This message is placed here for continuity purposes
+dnl but things are really set above in the libnet section
+AC_MSG_CHECKING(for libnet packet sending support)
+if test $disable_libnet = no -a $foundnet != no ; then
+	AC_MSG_RESULT(yes)
+	AC_DEFINE([HAVE_LIBNET], [1], [Do we support libnet for sending packets?])
+	have_libnet=yes
+else 
+	AC_MSG_RESULT(no)
+fi
+
+have_pcap_inject=no
+dnl Check to see if we've got pcap_inject()
+AC_MSG_CHECKING(for pcap_inject sending support)
+AC_TRY_COMPILE([
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "$LPCAPINC"
+],[
+	pcap_t *pcap;
+	char *buf;
+    pcap_inject(pcap, (void *)buf, 0);
+],[
+	if test $disable_pcap = no ; then
+		AC_DEFINE([HAVE_PCAP_INJECT], [1], 
+	              [Does libpcap have pcap_inject?])
+		AC_MSG_RESULT(yes)
+		have_pcap_inject=yes
+	else
+		AC_MSG_RESULT(no)
+	fi
+],[
+	AC_MSG_RESULT(no)
+])
+
+have_pcap_sendpacket=no
+dnl Check to see if we've got pcap_sendpacket()
+AC_MSG_CHECKING(for pcap_sendpacket sending support)
+AC_TRY_COMPILE([
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "$LPCAPINC"
+],[
+	pcap_t *pcap;
+	u_char *buf;
+    pcap_sendpacket(pcap, buf, 0);
+],[
+	if test $disable_pcap = no ; then
+		AC_DEFINE([HAVE_PCAP_SENDPACKET], [1], 
+	              [Does libpcap have pcap_sendpacket?])
+		AC_MSG_RESULT(yes)
+		have_pcap_sendpacket=yes
+	else 
+		AC_MSG_RESULT(no)
+	fi
+],[
+	AC_MSG_RESULT(no)
+])
+
+have_pf=no
+dnl Check for linux PF_PACKET support
+AC_MSG_CHECKING(for PF_PACKET socket sending support)
+AC_TRY_COMPILE([
+#include <sys/socket.h>
+#include <netpacket/packet.h>
+#include <net/ethernet.h>     /* the L2 protocols */
+#include <netinet/in.h>       /* htons */
+],[
+	int pf_socket;
+	pf_socket = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
+],[
+    if test $disable_pf = no ; then
+		AC_DEFINE([HAVE_PF_PACKET], [1],
+			[Do we have Linux PF_PACKET socket support?])
+		AC_MSG_RESULT(yes)
+		have_pf=yes
+	else
+		AC_MSG_RESULT(no)
+	fi
+],[
+	AC_MSG_RESULT(no)
+])
+
+have_bpf=no
+dnl Check for BSD's BPF
+AC_MSG_CHECKING(for BPF device sending support)
+AC_TRY_RUN([
+#include <stdio.h>
+#include <stdlib.h>
+#include <net/bpf.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <fcntl.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+#include <net/bpf.h>
+#include <errno.h>
+
+int 
+main(int argc, char *argv[]) {
+	int fd;
+	
+	fd = open("/dev/bpf0", O_RDONLY, 0);
+	
+	/* if we opened it, we're good */
+	if (fd > 1)
+		exit(0);
+		
+	/* if we got EBUSY or permission denied it exists, so we're good */
+	if (fd < 0 && (errno == EBUSY || errno == 13))
+		exit(0);
+		
+	/* else suck, no good */
+    exit(-1);
+}],
+	[
+	if test $disable_bpf = no ; then
+	    AC_DEFINE([HAVE_BPF], [1], 
+	              [Do we have BPF device support?])
+		AC_MSG_RESULT(yes)
+		have_bpf=yes
+	else
+		AC_MSG_RESULT(no)
+	fi
+	])
+
+
+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 \
+	-a $have_libnet = no -a $have_pf = no ; then
+	AC_MSG_ERROR([Unable to find a supported method to send packets])
+fi
+
+dnl Libpcap support doesn't give us a method to get the hardware address of the
+dnl interfaces which prevents us from doing proper filtering to prevent bridging loops
+enable_tcpbridge=yes
+if test $have_bpf = no -a $have_libnet = no -a $have_pf = no ; then
+	AC_MSG_NOTICE([tcpbridge support disabled without BPF, Libnet or Linux PF_PACKET])
+	enable_tcpbridge=no
+fi
+
+AM_CONDITIONAL(ENABLE_TCPBRIDGE, [test $enable_tcpbridge = yes])
+
 dnl Older versions of libpcap are missing some DLT types
 dnl If doesn't exist, we'll define them in src/common/fakepcap.h
 AC_MSG_CHECKING(for DLT_LINUX_SLL in libpcap)
 AC_TRY_COMPILE([#include "$LPCAPINC"], 
                [ int foo;
                  foo = DLT_LINUX_SLL ],
-                [ AC_DEFINE([HAVE_DLT_LINUX_SLL],
-                    [], [Does pcap.h include a header with DLT_LINUX_SLL?])
+                [ AC_DEFINE([HAVE_DLT_LINUX_SLL], [1], 
+					[Does pcap.h include a header with DLT_LINUX_SLL?])
                   AC_MSG_RESULT(yes)
                 ], 
                 AC_MSG_RESULT(no)
                )
+
 AC_MSG_CHECKING(for DLT_C_HDLC in libpcap)
 AC_TRY_COMPILE([#include "$LPCAPINC"],
                [ int foo;
                  foo = DLT_C_HDLC ],
-                [ AC_DEFINE([HAVE_DLT_C_HDLC],
-                    [], [Does pcap.h include a header with DLT_C_HDLC?])
+                [ AC_DEFINE([HAVE_DLT_C_HDLC], [1], 
+					[Does pcap.h include a header with DLT_C_HDLC?])
                   AC_MSG_RESULT(yes)
                 ],
                 AC_MSG_RESULT(no)   
@@ -498,7 +678,7 @@ AC_TRY_COMPILE([#include <sys/types.h>
                 #include "$PCAP_BPF_H_FILE"],
                [ int foo;
                  foo = BPF_MAJOR_VERSION; ],
-               [ AC_DEFINE([INCLUDE_PCAP_BPF_HEADER], [],
+               [ AC_DEFINE([INCLUDE_PCAP_BPF_HEADER], [1],
                            [What is the path (if any) to the pcap-bpf.h
                             header?])
                  AC_MSG_RESULT(yes)
@@ -523,7 +703,9 @@ AC_ARG_WITH(pcapnav-config,
     if test -x $withval ; then
 	pcncfg=$withval
 	AC_MSG_RESULT($pcncfg)
-    else
+    elif test x$withval = xno ; then
+	AC_MSG_RESULT(no)
+	else
 	AC_MSG_RESULT([Can't find pcapnav-config: disabling offset jump feature])
     fi ],
     [ AC_PATH_PROG(pcncfg,[pcapnav-config], [no] ) ]
@@ -571,47 +753,12 @@ if test x$libpcapnav_ver = xno ; then
     Please upgrade to version 0.4 or better.
     Disabling offset jump feature.])
 else
-    AC_DEFINE([HAVE_PCAPNAV], [], [Do we have libpcapnav?])
+    AC_DEFINE([HAVE_PCAPNAV], [1], [Do we have libpcapnav?])
 fi
 
 fi # checking pcapnav version
 
 
-dnl #####################################################
-dnl Checks for libnids
-dnl #####################################################
-foundnids=no
-trynidsdir=/usr/local
-AC_MSG_CHECKING(for libnids)
-AC_ARG_WITH(libnids,
-    AC_HELP_STRING([--with-libnids=DIR], [Use libnids in DIR]),
-    [trynidsdir=$withval])
-
-    for testdir in $trynidsdir /usr/local /usr ; do 
- 
-     if test -f "${testdir}/include/nids.h" -a $foundnids = no ; then
-         LNIDSINC="${testdir}/include/nids.h"
-         LNIDSINCDIR="${testdir}/include"
-dnl Libnids by default doesn't build a dynamic library and due to a 
-dnl bug, won't build one for OS X, so we link to the static
-dnl         LNIDSLIB="${testdir}/lib -lnids"
-         LNIDSLIB="${testdir}/lib/libnids.a"
-        foundnids=$testdir
-     fi
-   done
-
-   if test $foundnids = no ; then
-     AC_MSG_RESULT(no)
-     AC_MSG_WARN(libnids not found.  We won't build flowreplay.)
-   else
-     AC_MSG_RESULT($foundnids)
-     AC_DEFINE([HAVE_LIBNIDS], [], [Do we have libnids?])
-   fi
-
-AC_SUBST(LNIDSINC)
-AC_SUBST(LNIDSLIB)
-AM_CONDITIONAL([HAVE_LIBNIDS], [ test ${foundnids} != no ])
-
 dnl (shamelessly ripped off from libpcap)
 dnl Checks to see if unaligned memory accesses fail
 dnl
@@ -671,7 +818,7 @@ EOF
         esac])
     AC_MSG_RESULT($unaligned_fail)
     if test $unaligned_fail = yes ; then
-            AC_DEFINE([FORCE_ALIGN],1,[Are we strictly aligned?])
+            AC_DEFINE([FORCE_ALIGN],[1],[Are we strictly aligned?])
     fi
 
 dnl ##################################################
@@ -694,7 +841,7 @@ if test "$td" = "no"; then
     AC_MSG_WARN([Unable to find tcpdump.  Please specify --with-tcpdump.
                  Disabling verbose reporting.])
 else
-    AC_DEFINE([HAVE_TCPDUMP], [], [Do we have tcpdump?])
+    AC_DEFINE([HAVE_TCPDUMP], [1], [Do we have tcpdump?])
     AC_DEFINE_UNQUOTED(TCPDUMP_BINARY, "$td", [The tcpdump binary initially used])
 fi
 
@@ -738,11 +885,11 @@ case $host in
 	AC_MSG_RESULT(Apple OS X)
 	;;
 
-        *-*-openbsd*)
-        nic1=xl0
-        nic2=xl0
-        AC_MSG_RESULT(OpenBSD)
-        ;;
+    *-*-openbsd*)
+    nic1=xl0
+    nic2=xl0
+    AC_MSG_RESULT(OpenBSD)
+    ;;
 
 	*)
 	AC_MSG_RESULT([$host is unknown!  

+ 35 - 11
docs/CHANGELOG

@@ -1,24 +1,48 @@
-$Id: CHANGELOG 1519 2006-07-18 02:51:09Z aturner $
+$Id: CHANGELOG 1585 2006-08-08 04:51:30Z aturner $
+
+08/07/2006: Version 3.0.beta11
+    - Fix distribution to ship missing src/tcpr.h (#73)
+    - Add support to tcprewrite to alter output file DLT (#74)
+    - Fix errors in 'make test' (little endian still broken) (#77)
+    - Tweak Autogen .def files documentation (#78)
+
+08/05/2006: Version 3.0.beta10
+    - tcpprep & tcprewrite no longer require root access (#3)
+    - Develop wrapper API for libnet, libpcap, BPF and PF_PACKET (#4, #24)
+    - Enhance do_sleep() to support looping for better accuracy (#6)
+    - Prefer inet_pton over older, deprecated routines (#26)
+    - Remove libnet as a requirement (#29)
+    - Optionally don't rewrite broadcast/multicast IP/MAC addresses (#38)
+    - Remove libnids dependancy for flowreplay  (#55)
+    - Fix build issues when libpcapnav is installed (#56)
+    - Fix truncate feature not putting correct packet length in IP header (#59)
+    - Internal error reporting fixes in libtcpedit (#60)
+    - Support --enable-debug when building under gcc 3.x (#62)
+    - tcpedit_stub.h wasn't being generated automatically from SVN (#63)
+    - Fix 'make doxygen' (#67)
+    - Fix some Makefile issues (#68)
+    - tcprewrite --endpoints should require a cache file (#70)
+    - Improve IP randomizer code to be more random (#71)
 
 07/17/2006: Version 3.0.beta9
-    - Fix compile issue for users not having AutoOpts installed #54
+    - Fix compile issue for users not having AutoOpts installed (#54)
     - Fix compile issue for users w/ AutoOpts 5.8.4 (upgrade to 5.8.4)
 
 07/16/2006: Version 3.0.beta8
     - Fix -M running in MBps rather then Mbps
     - Fix tcpbridge segfault/bus error reported by Steven Z. (Gerry)
     - Improve tcpbridge man page
-    - Massive tcprewrite fixes & cleanup #50
+    - Massive tcprewrite fixes & cleanup (#50)
     - Much improved README document
     - Reorganize packet editing code into a standalone module (tcpedit) 
-          which has been librarized. #5
-    - Strict code cleanup #27
-    - Fix tcpprep from generating bad cache files #48
-    - Add MAC split mode for tcpprep #1
-    - Improve dbg() to list file/line #32
-    - Add tcpprep statistical reports #2
-    - Reorganize flowreplay code #46
-    - Fix conflicting speed_t for Debian #33
+          which has been librarized. (#5)
+    - Strict code cleanup (#27)
+    - Fix tcpprep from generating bad cache files (#48)
+    - Add MAC split mode for tcpprep (#1)
+    - Improve dbg() to list file/line (#32)
+    - Add tcpprep statistical reports (#2)
+    - Reorganize flowreplay code (#46)
+    - Fix conflicting speed_t for Debian (#33)
     - Too many other things to document
 
 08/07/2005: Version 3.0.beta7

BIN
docs/FAQ.pdf


+ 4 - 1
docs/INSTALL

@@ -1,4 +1,7 @@
-$Id: INSTALL 1464 2006-04-13 05:27:17Z aturner $
+$Id: INSTALL 1575 2006-08-05 21:26:48Z aturner $
+
+NOTE: This information is out of date.  Please see the tcpreplay wiki
+for updated information: http://tcpreplay.synfin.net/trac/wiki/manual
 
 You'll need:
 

+ 4 - 4
docs/LICENSE

@@ -1,4 +1,5 @@
-Copyright (c) 2001-2006 Aaron Turner.  All rights reserved.
+Copyright (c) 2001-2006 Aaron Turner.  aturner at synfin dot net
+All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions
@@ -25,6 +26,5 @@ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-This product includes software developed by the University of California,
-Berkeley and its contributors. 
-
+This product includes software developed by the University of California, 
+Berkeley, Lawrence Berkeley Laboratory and its contributors. 

+ 4 - 4
docs/Makefile.in

@@ -77,14 +77,16 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ENABLE_FLOWREPLAY_FALSE = @ENABLE_FLOWREPLAY_FALSE@
+ENABLE_FLOWREPLAY_TRUE = @ENABLE_FLOWREPLAY_TRUE@
+ENABLE_TCPBRIDGE_FALSE = @ENABLE_TCPBRIDGE_FALSE@
+ENABLE_TCPBRIDGE_TRUE = @ENABLE_TCPBRIDGE_TRUE@
 EXEEXT = @EXEEXT@
 F77 = @F77@
 FFLAGS = @FFLAGS@
 FIG2DEV = @FIG2DEV@
 HAVE_DOCTOOLS_FALSE = @HAVE_DOCTOOLS_FALSE@
 HAVE_DOCTOOLS_TRUE = @HAVE_DOCTOOLS_TRUE@
-HAVE_LIBNIDS_FALSE = @HAVE_LIBNIDS_FALSE@
-HAVE_LIBNIDS_TRUE = @HAVE_LIBNIDS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
@@ -101,8 +103,6 @@ LNAVLIB = @LNAVLIB@
 LNAV_CFLAGS = @LNAV_CFLAGS@
 LNETINC = @LNETINC@
 LNETLIB = @LNETLIB@
-LNIDSINC = @LNIDSINC@
-LNIDSLIB = @LNIDSLIB@
 LN_S = @LN_S@
 LPCAPINC = @LPCAPINC@
 LPCAPLIB = @LPCAPLIB@

BIN
docs/flowreplay.pdf


File diff suppressed because it is too large
+ 206 - 203
docs/manual.pdf


+ 1 - 1
docs/web/FAQ/FAQ.html

@@ -184,7 +184,7 @@ original version by:  Nikos Drakos, CBLU, University of Leeds
 <BR><HR>
 <ADDRESS>
 Aaron Turner
-2006-07-17
+2006-08-07
 </ADDRESS>
 </BODY>
 </HTML>

+ 1 - 1
docs/web/FAQ/index.html

@@ -184,7 +184,7 @@ original version by:  Nikos Drakos, CBLU, University of Leeds
 <BR><HR>
 <ADDRESS>
 Aaron Turner
-2006-07-17
+2006-08-07
 </ADDRESS>
 </BODY>
 </HTML>

+ 1 - 1
docs/web/FAQ/node1.html

@@ -181,7 +181,7 @@ Contents</A>
 <BR><HR>
 <ADDRESS>
 Aaron Turner
-2006-07-17
+2006-08-07
 </ADDRESS>
 </BODY>
 </HTML>

+ 1 - 1
docs/web/FAQ/node2.html

@@ -358,7 +358,7 @@ multiple connections.
 <!--End of Navigation Panel-->
 <ADDRESS>
 Aaron Turner
-2006-07-17
+2006-08-07
 </ADDRESS>
 </BODY>
 </HTML>

+ 1 - 1
docs/web/FAQ/node3.html

@@ -209,7 +209,7 @@ some or all of your submission to maintain a consistent coding style.
 <!--End of Navigation Panel-->
 <ADDRESS>
 Aaron Turner
-2006-07-17
+2006-08-07
 </ADDRESS>
 </BODY>
 </HTML>

+ 1 - 1
docs/web/FAQ/node4.html

@@ -207,7 +207,7 @@ was only 150K.
 <!--End of Navigation Panel-->
 <ADDRESS>
 Aaron Turner
-2006-07-17
+2006-08-07
 </ADDRESS>
 </BODY>
 </HTML>

+ 1 - 1
docs/web/FAQ/node5.html

@@ -216,7 +216,7 @@ which have much larger MTU's then ethernet.
 <!--End of Navigation Panel-->
 <ADDRESS>
 Aaron Turner
-2006-07-17
+2006-08-07
 </ADDRESS>
 </BODY>
 </HTML>

+ 1 - 1
docs/web/FAQ/node6.html

@@ -227,7 +227,7 @@ those errors. Garbage in, garbage out.
 <!--End of Navigation Panel-->
 <ADDRESS>
 Aaron Turner
-2006-07-17
+2006-08-07
 </ADDRESS>
 </BODY>
 </HTML>

+ 1 - 1
docs/web/FAQ/node7.html

@@ -180,7 +180,7 @@ for testing so you must create your own
 <!--End of Navigation Panel-->
 <ADDRESS>
 Aaron Turner
-2006-07-17
+2006-08-07
 </ADDRESS>
 </BODY>
 </HTML>

+ 1 - 1
docs/web/FAQ/node8.html

@@ -171,7 +171,7 @@ become disabled.
 <!--End of Navigation Panel-->
 <ADDRESS>
 Aaron Turner
-2006-07-17
+2006-08-07
 </ADDRESS>
 </BODY>
 </HTML>

+ 1 - 1
docs/web/FAQ/node9.html

@@ -163,7 +163,7 @@ http://www.circlemud.org/&nbsp;jelson/software/tcpflow/
 <BR><HR>
 <ADDRESS>
 Aaron Turner
-2006-07-17
+2006-08-07
 </ADDRESS>
 </BODY>
 </HTML>

+ 1 - 1
docs/web/flowreplay/flowreplay.html

@@ -109,7 +109,7 @@ original version by:  Nikos Drakos, CBLU, University of Leeds
 <BR><HR>
 <ADDRESS>
 Aaron Turner
-2006-07-17
+2006-08-07
 </ADDRESS>
 </BODY>
 </HTML>

+ 1 - 1
docs/web/flowreplay/images.log

@@ -1,4 +1,4 @@
-This is pdfeTeX, Version 3.141592-1.21a-2.2 (Web2C 7.5.4) (format=latex 2006.6.8)  17 JUL 2006 20:36
+This is pdfeTeX, Version 3.141592-1.21a-2.2 (Web2C 7.5.4) (format=latex 2006.6.8)  7 AUG 2006 21:30
 entering extended mode
 **./images.tex
 (./images.tex

BIN
docs/web/flowreplay/img1.old


+ 1 - 1
docs/web/flowreplay/index.html

@@ -109,7 +109,7 @@ original version by:  Nikos Drakos, CBLU, University of Leeds
 <BR><HR>
 <ADDRESS>
 Aaron Turner
-2006-07-17
+2006-08-07
 </ADDRESS>
 </BODY>
 </HTML>

+ 1 - 1
docs/web/flowreplay/node1.html

@@ -81,7 +81,7 @@ then passive devices. </SPAN>
 <BR><HR>
 <ADDRESS>
 Aaron Turner
-2006-07-17
+2006-08-07
 </ADDRESS>
 </BODY>
 </HTML>

+ 1 - 1
docs/web/flowreplay/node2.html

@@ -152,7 +152,7 @@ of RAM.</SPAN>
 <!--End of Navigation Panel-->
 <ADDRESS>
 Aaron Turner
-2006-07-17
+2006-08-07
 </ADDRESS>
 </BODY>
 </HTML>

+ 1 - 1
docs/web/flowreplay/node3.html

@@ -190,7 +190,7 @@ from Open/Net/FreeBSD or writing our own custom stack from scratch.</SPAN>
 <!--End of Navigation Panel-->
 <ADDRESS>
 Aaron Turner
-2006-07-17
+2006-08-07
 </ADDRESS>
 </BODY>
 </HTML>

+ 1 - 1
docs/web/flowreplay/node4.html

@@ -276,7 +276,7 @@ of eof, connect fails. You must poll for both.</SPAN>
 <!--End of Navigation Panel-->
 <ADDRESS>
 Aaron Turner
-2006-07-17
+2006-08-07
 </ADDRESS>
 </BODY>
 </HTML>

+ 1 - 1
docs/web/flowreplay/node5.html

@@ -126,7 +126,7 @@ response or message.</SPAN>
 <!--End of Navigation Panel-->
 <ADDRESS>
 Aaron Turner
-2006-07-17
+2006-08-07
 </ADDRESS>
 </BODY>
 </HTML>

+ 1 - 1
docs/web/flowreplay/node6.html

@@ -213,7 +213,7 @@ and neither the socket was ready or the node timed out </SPAN>
 <!--End of Navigation Panel-->
 <ADDRESS>
 Aaron Turner
-2006-07-17
+2006-08-07
 </ADDRESS>
 </BODY>
 </HTML>

+ 18 - 9
docs/web/man/tcpprep.html

@@ -141,8 +141,8 @@ This option must not appear in combination with any of the following options:
 exclude.
 </dl>
 <p>
-Override default of sending all packets stored in the capture file and only
-send packets which match the provided rule.  Rules can be one of:
+Override default of processing all packets stored in the capture file and only
+send/edit packets which match the provided rule.  Rules can be one of:
 
 <p>
 <p>
@@ -168,7 +168,7 @@ corresponds to the packet number in the capture file.
 <pre>
     -x P:1-5,9,15,72-
 <br></pre>
-would send packets 1 thru 5, the 9th and 15th packet, and packets 72 until the
+would process packets 1 thru 5, the 9th and 15th packet, and packets 72 until the
 end of the file
 
 <p>
@@ -182,8 +182,8 @@ This option must not appear in combination with any of the following options:
 include.
 </dl>
 <p>
-Override default of sending all packets stored in the capture file and only
-send packets which do not match the provided rule.  Rules can be one of:
+Override default of processing all packets stored in the capture file and only
+send/edit packets which do NOT match the provided rule.  Rules can be one of:
 
 <p>
 <p>
@@ -209,7 +209,7 @@ corresponds to the packet number in the capture file.
 <pre>
     -x P:1-5,9,15,72-
 <br></pre>
-would drop packets 1 thru 5, the 9th and 15th packet, and packets 72 until the
+would skip packets 1 thru 5, the 9th and 15th packet, and packets 72 until the
 end of the file
 <br>
 <p><dl compact><dt><b>-o</b> <i>string</i>, <b>--cachefile</b>=<b><i>string</i></b>
@@ -256,7 +256,10 @@ will reclassify non-IP traffic as "server".
 This option may appear up to 1 times.
 This option must appear in combination with the following options:
 auto.
-</dl>
+The default <i>string</i> for this option is:
+</dl><br>
+ 2.0
+
 <p>
 Since a given host may have both client and server traffic being sent
 to/from it, tcpprep uses a ratio to weigh these packets.  If you would
@@ -272,7 +275,10 @@ The value of <i>number</i> is constrained to being:
 <pre>
 in the range  0 through 32
 <br></pre>
-</dl>
+The default <i>number</i> for this option is:
+</dl><br>
+ 30
+
 <p>
 By default, auto modes use a minimum network mask length of 30 bits
 to build networks containing clients and servers.  This allows you
@@ -288,7 +294,10 @@ The value of <i>number</i> is constrained to being:
 <pre>
 in the range  0 through 32
 <br></pre>
-</dl>
+The default <i>number</i> for this option is:
+</dl><br>
+ 8
+
 <p>
 By default, auto modes use a maximum network mask length of 8 bits
 to build networks containing clients and servers.  This allows you

+ 7 - 0
docs/web/man/tcpreplay.html

@@ -28,6 +28,13 @@ firewalls, NIDS and other network devices.
 
 </ul><H2>OPTIONS </H2><ul>
 
+<p><dl compact><dt><b>-a</b>, <b>--accurate</b>
+<dd>Enable more accurate packet timing.
+This option may appear up to 1 times.
+</dl>
+<p>
+Enables more accurate timing between packets at the cost of higher
+CPU utilization.
 <p><dl compact><dt><b>-d</b> <i>number</i>, <b>--dbug</b>=<b><i>number</i></b>
 <dd>Enable debugging output.
 This option may appear up to 1 times.

+ 53 - 8
docs/web/man/tcprewrite.html

@@ -44,7 +44,7 @@ traffic.
 
 <p>Example:
 <pre>
-    --dmac 00:12:13:14:15:16,00:22:33:44:55:66
+    --dmac=00:12:13:14:15:16,00:22:33:44:55:66
 <br></pre>
 <p><dl compact><dt><b>-S</b> <i>string</i>, <b>--smac</b>=<b><i>string</i></b>
 <dd>Rewrite source MAC addresses.
@@ -58,7 +58,7 @@ and the optional second MAC address will be used for the client traffic.
 
 <p>Example:
 <pre>
-    --smac 00:12:13:14:15:16,00:22:33:44:55:66
+    --smac=00:12:13:14:15:16,00:22:33:44:55:66
 <br></pre>
 <p><dl compact><dt><b>-P</b> <i>number</i>, <b>--proto</b>=<b><i>number</i></b>
 <dd>Override L2 protocol type for DLT_RAW.
@@ -128,6 +128,8 @@ mask against the high order bits.
 <p><dl compact><dt><b>-e</b> <i>string</i>, <b>--endpoints</b>=<b><i>string</i></b>
 <dd>Rewrite IP addresses to be between two endpoints.
 This option may appear up to 1 times.
+This option must appear in combination with the following options:
+cachefile.
 </dl>
 <p>
 Takes a pair of colon delimited IP addresses which will be used to rewrite
@@ -137,6 +139,13 @@ all traffic to appear to be between the two IP's.
 <pre>
     --endpoints=172.16.0.1:172.16.0.2
 <br></pre>
+<p><dl compact><dt><b>-b</b>, <b>--skipbroadcast</b>
+<dd>Skip rewriting broadcast/multicast IP's.
+</dl>
+<p>
+By default, --dmac, --smac, --seed, --pnat and --endpoints will rewrite 
+broadcast and multicast IP and MAC addresses.	Setting this flag
+will keep broadcast/multicast IP and MAC addresses from being rewritten.
 <p><dl compact><dt><b>-C</b>, <b>--fixcsum</b>
 <dd>Force recalculation of IP/TCP/UDP checksums.
 </dl>
@@ -155,12 +164,7 @@ in the range  1 through MAXPACKET
 </dl>
 <p>
 Override the default 1500 byte MTU size for determining the maximum padding length.
-<p><dl compact><dt><b>-E</b>, <b>--efcs</b>
-<dd>Remove Ethernet checksums (FCS) from end of frames.
-</dl>
-<p>
-
-<p><p><dl compact><dt><b>-F</b> <i>string</i>, <b>--fixlen</b>=<b><i>string</i></b>
+<p><dl compact><dt><b>-F</b> <i>string</i>, <b>--fixlen</b>=<b><i>string</i></b>
 <dd>Pad or truncate packet data to match header length.
 This option may appear up to 1 times.
 </dl>
@@ -237,6 +241,47 @@ in the range  0 through 7
 </dl>
 <p>
 
+<p><p><dl compact><dt><b>-L</b> <i>number</i>, <b>--dlt</b>=<b><i>number</i></b>
+<dd>Change DLT type for output pcap file.
+This option may appear up to 1 times.
+This option takes an integer number as its argument.
+The value of <i>number</i> is constrained to being:
+<pre>
+in the range  0 through 65535
+<br></pre>
+</dl>
+<p>
+By default, tcprewrite uses the same DLT (data link type) for the 
+output pcap as the input pcap.  However, if you are changing the 
+Layer 2 data with --dlink, then you probably also want to change the
+DLT type stored in the pcap.  Common DLT types are:
+
+<p>
+<b>0</b>
+No Layer 2 header (DLT_NULL)
+
+<p>
+<b>1</b>
+Ethernet (DLT_EN10MB)
+
+<p>
+<b>10</b>
+FDDI (DLT_FDDI)
+
+<p>
+<b>12</b>
+BSD Raw header (DLT_RAW)
+
+<p>
+<b>104</b>
+Cisco HDLC (DLT_C_HDLC)
+
+<p>
+<b>113</b>
+Linux SLL pseudo-header (DLT_LINUX_SLL)
+
+<p>For a full list of DLT types, see: src/common/dlt_names.h
+
 <p><p><dl compact><dt><b>-d</b> <i>number</i>, <b>--dbug</b>=<b><i>number</i></b>
 <dd>Enable debugging output.
 This option may appear up to 1 times.

+ 10 - 12
docs/web/manual/images.log

@@ -1,4 +1,4 @@
-This is pdfeTeX, Version 3.141592-1.21a-2.2 (Web2C 7.5.4) (format=latex 2006.6.8)  17 JUL 2006 20:34
+This is pdfeTeX, Version 3.141592-1.21a-2.2 (Web2C 7.5.4) (format=latex 2006.6.8)  7 AUG 2006 21:31
 entering extended mode
 **./images.tex
 (./images.tex
@@ -181,23 +181,21 @@ latex2htmlLength oddsidemargin=-43.81725pt
 
 latex2htmlLength evensidemargin=-43.81725pt
 
-LaTeX Font Info:    Try loading font information for T1+pcr on input line 172.
-(/opt/local/share/texmf-dist/tex/latex/psnfss/t1pcr.fd
-File: t1pcr.fd 2001/06/04 font definitions for T1/pcr.
-)
-l2hSize :tex2html_wrap2280:60.2256pt::0.0pt::349.0pt.
+File: router-mode3.eps Graphic file (type eps)
+<router-mode3.eps>
+l2hSize :tex2html_wrap2280:261.37915pt::0.0pt::349.0pt.
 [1
 
 
 
 ] (./images.aux) ) 
 Here is how much of TeX's memory you used:
- 1771 strings out of 94501
- 22372 string characters out of 1174997
+ 1744 strings out of 94501
+ 21990 string characters out of 1174997
  71589 words of memory out of 1000000
- 4955 multiletter control sequences out of 10000+50000
- 6369 words of font info for 17 fonts, out of 500000 for 2000
+ 4930 multiletter control sequences out of 10000+50000
+ 6047 words of font info for 16 fonts, out of 500000 for 2000
  580 hyphenation exceptions out of 1000
- 25i,5n,19p,225b,210s stack positions out of 1500i,500n,5000p,200000b,5000s
+ 25i,5n,19p,225b,208s stack positions out of 1500i,500n,5000p,200000b,5000s
 
-Output written on images.dvi (1 page, 392 bytes).
+Output written on images.dvi (1 page, 332 bytes).

+ 3 - 3
docs/web/manual/images.pl

@@ -2,11 +2,11 @@
 # Associate images original text with physical files.
 
 
-$key = q/includegraphics[scale=0.6,bb=00200100,draft,type=eps]{router-mode3.eps};AAT/;
+$key = q/includegraphics[scale=0.6]{router-mode3};AAT/;
 $cached_env_img{$key} = q|<IMG
- WIDTH="192" HEIGHT="96" ALIGN="BOTTOM" BORDER="0"
+ WIDTH="363" HEIGHT="415" ALIGN="BOTTOM" BORDER="0"
  SRC="|."$dir".q|img1.png"
- ALT="\includegraphics[scale=0.6,bb = 0 0 200 100, draft, type=eps]{router-mode3.eps}">|; 
+ ALT="\includegraphics[scale=0.6]{router-mode3}">|; 
 
 1;
 

+ 1 - 1
docs/web/manual/images.tex

@@ -169,7 +169,7 @@
 \setcounter{secnumdepth}{4}
 {\newpage\clearpage
 \lthtmlpictureA{tex2html_wrap2280}%
-\includegraphics[scale=0.6,bb = 0 0 200 100, draft, type=eps]{router-mode3.eps}%
+\includegraphics[scale=0.6]{router-mode3}%
 \lthtmlpictureZ
 \lthtmlcheckvsize\clearpage}
 

BIN
docs/web/manual/img1.old


BIN
docs/web/manual/img1.png


+ 2 - 5
docs/web/manual/index.html

@@ -531,10 +531,7 @@ S<SMALL>TEP 1:</SMALL> Categorize Clients, Servers and Unknowns</TD>
 <DIV ALIGN="CENTER">
 <TABLE CELLPADDING=3>
 <TR><TD ALIGN="CENTER">S<SMALL>TEP 3:</SMALL> Unknowns Now Marked as Clients and Servers
-<BR><IMG
-  WIDTH="254" HEIGHT="290" ALIGN="BOTTOM" BORDER="0"
- SRC="./router-mode3.png"
- ALT="Image router-mode3">
+<BR></SMALL>
 <BR></TD>
 </TR>
 </TABLE></DIV>
@@ -2063,7 +2060,7 @@ client
 <!--End of Navigation Panel-->
 <ADDRESS>
 Aaron Turner
-2006-07-17
+2006-08-07
 </ADDRESS>
 </BODY>
 </HTML>

+ 2 - 5
docs/web/manual/manual.html

@@ -531,10 +531,7 @@ S<SMALL>TEP 1:</SMALL> Categorize Clients, Servers and Unknowns</TD>
 <DIV ALIGN="CENTER">
 <TABLE CELLPADDING=3>
 <TR><TD ALIGN="CENTER">S<SMALL>TEP 3:</SMALL> Unknowns Now Marked as Clients and Servers
-<BR><IMG
-  WIDTH="254" HEIGHT="290" ALIGN="BOTTOM" BORDER="0"
- SRC="./router-mode3.png"
- ALT="Image router-mode3">
+<BR></SMALL>
 <BR></TD>
 </TR>
 </TABLE></DIV>
@@ -2063,7 +2060,7 @@ client
 <!--End of Navigation Panel-->
 <ADDRESS>
 Aaron Turner
-2006-07-17
+2006-08-07
 </ADDRESS>
 </BODY>
 </HTML>

+ 1 - 1
docs/web/manual/node1.html

@@ -168,7 +168,7 @@ http://www.cr0.net:8040/code/network/aircrack/
 <BR><HR>
 <ADDRESS>
 Aaron Turner
-2006-07-17
+2006-08-07
 </ADDRESS>
 </BODY>
 </HTML>

BIN
docs/web/manual/router-mode3.png


+ 8 - 114
doxygen.cfg.in

@@ -455,120 +455,14 @@ WARN_LOGFILE           =
 # with spaces.
 
 INPUT                  = \
-lib/queue.h \
-lib/sll.h \
-lib/strlcat.c \
-lib/strlcpy.c \
-lib/strlcpy.h \
-lib/tree.h \
-libopts/autoopts.c \
-libopts/autoopts.h \
-libopts/boolean.c \
-libopts/configfile.c \
-libopts/cook.c \
-libopts/enumeration.c \
-libopts/environment.c \
-libopts/genshell.c \
-libopts/genshell.h \
-libopts/libopts.c \
-libopts/load.c \
-libopts/makeshell.c \
-libopts/nested.c \
-libopts/numeric.c \
-libopts/pgusage.c \
-libopts/proto.h \
-libopts/putshell.c \
-libopts/restore.c \
-libopts/save.c \
-libopts/sort.c \
-libopts/stack.c \
-libopts/streqvcmp.c \
-libopts/text_mmap.c \
-libopts/tokenize.c \
-libopts/usage.c \
-libopts/version.c \
-scripts/man2html.c \
-src/bridge.c \
-src/bridge.h \
-src/common.h \
-src/defines.h \
-src/dlt.h \
-src/dlt_names.h \
-src/edit_packet.c \
-src/edit_packet.h \
-src/flowbuff.c \
-src/flowbuff.h \
-src/flowkey.c \
-src/flowkey.h \
-src/flownode.c \
-src/flownode.h \
-src/flowreplay.c \
-src/flowreplay.h \
-src/flowreplay_opts.c \
-src/flowreplay_opts.h \
-src/flowstate.c \
-src/flowstate.h \
-src/mac.c \
-src/mac.h \
-src/portmap.c \
-src/portmap.h \
-src/rewrite_l2.c \
-src/rewrite_l2.h \
-src/send_packets.c \
-src/send_packets.h \
-src/signal_handler.c \
-src/signal_handler.h \
-src/tcpbridge.c \
-src/tcpbridge.h \
-src/tcpbridge_opts.c \
-src/tcpbridge_opts.h \
-src/tcpprep.c \
-src/tcpprep.h \
-src/tcpprep_opts.c \
-src/tcpprep_opts.h \
-src/tcpreplay.c \
-src/tcpreplay.h \
-src/tcpreplay_opts.c \
-src/tcpreplay_opts.h \
-src/tcprewrite.c \
-src/tcprewrite.h \
-src/tcprewrite_opts.c \
-src/tcprewrite_opts.h \
-src/tree.c \
-src/tree.h \
-libopts/compat/pathfind.c \
-src/common/abort.c \
-src/common/cache.c \
-src/common/cidr.c \
-src/common/err.c \
-src/common/fakepcap.c \
-src/common/fakepcapnav.c \
-src/common/fakepoll.c \
-src/common/get.c \
-src/common/list.c \
-src/common/services.c \
-src/common/svn_version.c \
-src/common/tcpdump.c \
-src/common/timer.c \
-src/common/utils.c \
-src/common/xX.c \
-libopts/autoopts/options.h \
-libopts/autoopts/usage-txt.h \
-libopts/compat/compat.h \
-src/common/abort.h \
-src/common/cache.h \
-src/common/cidr.h \
-src/common/err.h \
-src/common/fakepcap.h \
-src/common/fakepcapnav.h \
-src/common/fakepoll.h \
-src/common/get.h \
-src/common/list.h \
-src/common/services.h \
-src/common/tcpdump.h \
-src/common/timer.h \
-src/common/utils.h \
-src/common/xX.h
+lib \
+libopts \
+libopts/compat \
+libopts/autoopts \
+src \
+src/common \
+src/tcpedit \
+src/flow 
 
 # If the value of the INPUT tag contains directories, you can use the 
 # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 

+ 4 - 4
lib/Makefile.in

@@ -100,14 +100,16 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ENABLE_FLOWREPLAY_FALSE = @ENABLE_FLOWREPLAY_FALSE@
+ENABLE_FLOWREPLAY_TRUE = @ENABLE_FLOWREPLAY_TRUE@
+ENABLE_TCPBRIDGE_FALSE = @ENABLE_TCPBRIDGE_FALSE@
+ENABLE_TCPBRIDGE_TRUE = @ENABLE_TCPBRIDGE_TRUE@
 EXEEXT = @EXEEXT@
 F77 = @F77@
 FFLAGS = @FFLAGS@
 FIG2DEV = @FIG2DEV@
 HAVE_DOCTOOLS_FALSE = @HAVE_DOCTOOLS_FALSE@
 HAVE_DOCTOOLS_TRUE = @HAVE_DOCTOOLS_TRUE@
-HAVE_LIBNIDS_FALSE = @HAVE_LIBNIDS_FALSE@
-HAVE_LIBNIDS_TRUE = @HAVE_LIBNIDS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
@@ -124,8 +126,6 @@ LNAVLIB = @LNAVLIB@
 LNAV_CFLAGS = @LNAV_CFLAGS@
 LNETINC = @LNETINC@
 LNETLIB = @LNETLIB@
-LNIDSINC = @LNIDSINC@
-LNIDSLIB = @LNIDSLIB@
 LN_S = @LN_S@
 LPCAPINC = @LPCAPINC@
 LPCAPLIB = @LPCAPLIB@

BIN
libopts/._README


+ 4 - 4
libopts/Makefile.in

@@ -103,14 +103,16 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ENABLE_FLOWREPLAY_FALSE = @ENABLE_FLOWREPLAY_FALSE@
+ENABLE_FLOWREPLAY_TRUE = @ENABLE_FLOWREPLAY_TRUE@
+ENABLE_TCPBRIDGE_FALSE = @ENABLE_TCPBRIDGE_FALSE@
+ENABLE_TCPBRIDGE_TRUE = @ENABLE_TCPBRIDGE_TRUE@
 EXEEXT = @EXEEXT@
 F77 = @F77@
 FFLAGS = @FFLAGS@
 FIG2DEV = @FIG2DEV@
 HAVE_DOCTOOLS_FALSE = @HAVE_DOCTOOLS_FALSE@
 HAVE_DOCTOOLS_TRUE = @HAVE_DOCTOOLS_TRUE@
-HAVE_LIBNIDS_FALSE = @HAVE_LIBNIDS_FALSE@
-HAVE_LIBNIDS_TRUE = @HAVE_LIBNIDS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
@@ -127,8 +129,6 @@ LNAVLIB = @LNAVLIB@
 LNAV_CFLAGS = @LNAV_CFLAGS@
 LNETINC = @LNETINC@
 LNETLIB = @LNETLIB@
-LNIDSINC = @LNIDSINC@
-LNIDSLIB = @LNIDSLIB@
 LN_S = @LN_S@
 LPCAPINC = @LPCAPINC@
 LPCAPLIB = @LPCAPLIB@

+ 4 - 4
scripts/Makefile.in

@@ -98,14 +98,16 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ENABLE_FLOWREPLAY_FALSE = @ENABLE_FLOWREPLAY_FALSE@
+ENABLE_FLOWREPLAY_TRUE = @ENABLE_FLOWREPLAY_TRUE@
+ENABLE_TCPBRIDGE_FALSE = @ENABLE_TCPBRIDGE_FALSE@
+ENABLE_TCPBRIDGE_TRUE = @ENABLE_TCPBRIDGE_TRUE@
 EXEEXT = @EXEEXT@
 F77 = @F77@
 FFLAGS = @FFLAGS@
 FIG2DEV = @FIG2DEV@
 HAVE_DOCTOOLS_FALSE = @HAVE_DOCTOOLS_FALSE@
 HAVE_DOCTOOLS_TRUE = @HAVE_DOCTOOLS_TRUE@
-HAVE_LIBNIDS_FALSE = @HAVE_LIBNIDS_FALSE@
-HAVE_LIBNIDS_TRUE = @HAVE_LIBNIDS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
@@ -122,8 +124,6 @@ LNAVLIB = @LNAVLIB@
 LNAV_CFLAGS = @LNAV_CFLAGS@
 LNETINC = @LNETINC@
 LNETLIB = @LNETLIB@
-LNIDSINC = @LNIDSINC@
-LNIDSLIB = @LNIDSLIB@
 LN_S = @LN_S@
 LPCAPINC = @LPCAPINC@
 LPCAPLIB = @LPCAPLIB@

+ 105 - 28
scripts/dlt2name.pl

@@ -3,16 +3,16 @@
 # Parses the bpf.h header file to generate the dlt_names.h header
 # which maps the DLT types to the DLT string name
 
-# run as:
-# cat /usr/include/net/bpf.h | ./scripts/dlt2name.pl
+# run from the tcpreplay source base directory as:
+# cat /usr/include/pcap-bpf.h | ./scripts/dlt2name.pl
 
 use strict;
-my $outfile = "dlt_names.h";
-
-defined $ARGV[0] or die("Please specify an output file");
+my $out_c = 'src/common/dlt_names.c';
+my $out_h = 'src/common/dlt_names.h';
 
 # open outfile
-open(OUT, ">$ARGV[0]") or die("Unable to open $ARGV[0] for writing: $!");
+open(OUT_C, ">$out_c") or die("Unable to open $out_c for writing: $!");
+open(OUT_H, ">$out_h") or die("Unable to open $out_h for writing: $!");
 
 # read STDIN
 
@@ -31,13 +31,13 @@ my %known = (107 => 'BSD/OS Frame Relay',
              121 => 'Siemens HiPath HDLC',
              122 => 'IP over Fibre Channel'
             );
-my @names = ( );
+my @names;
 
 # put our known DLT types in names since the format of bpf.h is 
 # inconsistent
 
 foreach my $dlt (keys %known) {
-  $names[$dlt] = { name => $known{$dlt} };
+  $names[$dlt]{name} = $known{$dlt};
 }
 
 while (my $line = <STDIN>) {
@@ -45,44 +45,121 @@ while (my $line = <STDIN>) {
   if ($line =~ /^\#define\s+(DLT_[a-zA-Z0-9_]+)\s+(\d+)/) {
     my $key = $1;
     my $dlt = $2;
-    my $name = $names[$dlt]->{name} ? $names[$dlt]->{name} : "";
+    my $name = $names[$dlt]{name} ? $names[$dlt]{name} : "";
     if ($line =~ /\/\*\s+(.*)\s+\*\//) {
       $name = $1;
     }
-    $names[$dlt] = { key => $key,
-                     name => $name
-                 };
+    $names[$dlt]{key} = $key;
+    $names[$dlt]{name} = $name;
   }
 
 }
 
+# print the license info 
+while (my $line = <DATA>) {
+    print OUT_C $line;
+    print OUT_H $line;
+}
+
 # prep the header
-print OUT (<<HEADER);
-/*
- * This file is generated by scripts/dlt2name.pl which converts your bpf.h
- * header file which comes with libpcap into a header file
- * which translates DLT values to their string names
- *
- * Hence DO NOT EDIT THIS FILE!
- * If your DLT type is not listed here, edit the %known hash in
- * scripts/dlt2name.pl
- */
+print OUT_C <<HEADER;
+
+#include <stdlib.h>
 
 /* DLT to descriptions */
 char *dlt2desc[] = {
 HEADER
 
-
 for (my $i = 0; $i < $#names; $i ++) {
   if (! defined $names[$i]) {
-    print OUT "\t\t\"Unknown\",\n";
+    print OUT_C "\t\t\"Unknown\",\n";
   } else {
-    print OUT "\t\t\"$names[$i]->{name}\",\n";
+    print OUT_C "\t\t\"$names[$i]->{name}\",\n";
   }
 }
 
-print OUT "\t\tNULL\n};\n";
-print OUT "\#define DLT2DESC_LEN $#names\n";
-close OUT;
+print OUT_C <<FOOTER;
+\t\tNULL
+};
+
+FOOTER
+
+print OUT_H <<HEADER;
+
+/* include all the DLT types form pcap-bpf.h */
+
+extern char *dlt2desc[];
+#define DLT2DESC_LEN $#names
+
+HEADER
+
+for (my $i = 0; $i < 255; $i++) {
+    next if ! defined $names[$i];
+    print OUT_H "#ifndef $names[$i]{key}\n#define $names[$i]{key} $i\n#endif\n\n";
+}
+
+close OUT_C;
+close OUT_H;
 
 exit 0;
+
+__DATA__
+/*
+ * Copyright (c) 2006 Aaron Turner
+ * All rights reserved.
+ *
+ * This file is generated by scripts/dlt2name.pl which converts your pcap-bpf.h
+ * header file which comes with libpcap into a header file
+ * which translates DLT values to their string names as well as a list of all
+ * of the available DLT types.
+ *
+ * Hence DO NOT EDIT THIS FILE!
+ * If your DLT type is not listed here, edit the %known hash in
+ * scripts/dlt2name.pl
+ * 
+ * This file contains data which was taken from libpcap's pcap-bpf.h.  
+ * The copyright/license is included below:
+ */
+ 
+ /*-
+  * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
+  *      The Regents of the University of California.  All rights reserved.
+  *
+  * This code is derived from the Stanford/CMU enet packet filter,
+  * (net/enet.c) distributed as part of 4.3BSD, and code contributed
+  * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence 
+  * Berkeley Laboratory.
+  *
+  * Redistribution and use in source and binary forms, with or without
+  * modification, are permitted provided that the following conditions
+  * are met:
+  * 1. Redistributions of source code must retain the above copyright
+  *    notice, this list of conditions and the following disclaimer.
+  * 2. Redistributions in binary form must reproduce the above copyright
+  *    notice, this list of conditions and the following disclaimer in the
+  *    documentation and/or other materials provided with the distribution.
+  * 3. All advertising materials mentioning features or use of this software
+  *    must display the following acknowledgement:
+  *      This product includes software developed by the University of
+  *      California, Berkeley and its contributors.
+  * 4. Neither the name of the University nor the names of its contributors
+  *    may be used to endorse or promote products derived from this software
+  *    without specific prior written permission.
+  *
+  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+  * SUCH DAMAGE.
+  *
+  *      @(#)bpf.h       7.1 (Berkeley) 5/7/91
+  *
+  * @(#) $Header: /tcpdump/master/libpcap/pcap-bpf.h,v 1.34.2.6 2005/08/13 22:29:47 hannes Exp $ (LBL)
+  */
+

BIN
src/._common.h


BIN
src/._defines.h.in


BIN
src/._dlt_names.h


BIN
src/._flowreplay.c


BIN
src/._flowreplay_opts.def


BIN
src/._mac.c


BIN
src/._send_packets.c


BIN
src/._signal_handler.c


BIN
src/._tcpbridge_opts.def


BIN
src/._tcpprep.c


BIN
src/._tcpprep.h


BIN
src/._tcpprep_opts.def


BIN
src/._tcprewrite.c


BIN
src/._tcprewrite.h


BIN
src/._tcprewrite_opts.def


BIN
src/._tree.c


BIN
src/._tree.h


+ 18 - 14
src/Makefile.am

@@ -1,4 +1,4 @@
-# $Id: Makefile.am 1518 2006-07-18 02:47:33Z aturner $
+# $Id: Makefile.am 1577 2006-08-08 02:50:05Z aturner $
 SUBDIRS = common tcpedit flow
 
 if SYSTEM_STRLCPY
@@ -16,7 +16,7 @@ autoopts: tcpreplay_opts.c tcprewrite_opts.c \
 tcpprep.1: tcpprep_opts.def
 	@AUTOGEN@ -T agman1.tpl --base-name tcpprep tcpprep_opts.def
 
-tcprewrite.1: tcprewrite_opts.def
+tcprewrite.1: tcprewrite_opts.def tcpedit/tcpedit_opts.def
 	@AUTOGEN@ -T agman1.tpl --base-name tcprewrite tcprewrite_opts.def
 
 tcpreplay.1: tcpreplay_opts.def
@@ -25,17 +25,21 @@ tcpreplay.1: tcpreplay_opts.def
 flowreplay.1: flowreplay_opts.def
 	@AUTOGEN@ -T agman1.tpl --base-name flowreplay flowreplay_opts.def
 
-tcpbridge.1: tcpbridge_opts.def
+tcpbridge.1: tcpbridge_opts.def tcpedit/tcpedit_opts.def
 	@AUTOGEN@ -T agman1.tpl --base-name tcpbridge tcpbridge_opts.def
 
-man_MANS = tcpreplay.1 tcpprep.1 tcprewrite.1  tcpbridge.1
-EXTRA_DIST = tcpreplay.1 tcpprep.1 tcprewrite.1 tcpbridge.1
+man_MANS = tcpreplay.1 tcpprep.1 tcprewrite.1
+EXTRA_DIST = tcpreplay.1 tcpprep.1 tcprewrite.1 tcpbridge.1 flowreplay.1
+bin_PROGRAMS = tcpreplay tcpprep tcprewrite
 
-bin_PROGRAMS = tcpreplay tcpprep tcprewrite tcpbridge
-if HAVE_LIBNIDS
-bin_PROGRAMS += flowreplay
+if ENABLE_FLOWREPLAY
 man_MANS += flowreplay.1
-EXTRA_DIST += flowreplay.1
+bin_PROGRAMS += flowreplay
+endif
+
+if ENABLE_TCPBRIDGE
+man_MANS += tcpbridge.1
+bin_PROGRAMS += tcpbridge
 endif
 
 tcpreplay_CFLAGS = $(LIBOPTS_CFLAGS) -I.. $(LNAV_CFLAGS) -DTCPREPLAY
@@ -54,7 +58,7 @@ tcprewrite_LDADD = ./tcpedit/libtcpedit.a ./common/libcommon.a \
 tcprewrite_SOURCES = tcprewrite_opts.c tcprewrite.c mac.c
 tcprewrite_OBJECTS: tcprewrite_opts.h
 tcprewrite_opts.h: tcprewrite_opts.c
-tcprewrite_opts.c: tcprewrite_opts.def
+tcprewrite_opts.c: tcprewrite_opts.def tcpedit/tcpedit_opts.def
 	@AUTOGEN@ tcprewrite_opts.def
 
 
@@ -69,7 +73,7 @@ tcpprep_opts.c: tcpprep_opts.def
 
 flowreplay_CFLAGS = $(LIBOPTS_CFLAGS) -I.. $(LNAV_CFLAGS) -DFLOWREPLAY
 flowreplay_LDADD = ./common/libcommon.a $(LIBSTRL) ./flow/libflow.a \
-		  @LNIDSLIB@ @LNETLIB@ @LPCAPLIB@ $(LIBOPTS_LDADD)
+		  @LNETLIB@ @LPCAPLIB@ $(LIBOPTS_LDADD)
 flowreplay_SOURCES = flowreplay_opts.c flowreplay.c 
 flowreplay_OBJECTS: flowreplay_opts.h
 flowreplay_opts.h: flowreplay_opts.c
@@ -83,16 +87,16 @@ tcpbridge_SOURCES = tcpbridge_opts.c tcpbridge.c bridge.c send_packets.c \
 		mac.c
 tcpbridge_OBJECTS: tcpbridge_opts.h
 tcpbridge_opts.h: tcpbridge_opts.c
-tcpbridge_opts.c: tcpbridge_opts.def
+tcpbridge_opts.c: tcpbridge_opts.def tcpedit/tcpedit_opts.def
 	@AUTOGEN@ tcpbridge_opts.def
 
 noinst_HEADERS = tcpreplay.h tcpprep.h flowreplay.h bridge.h \
-		 defines.h dlt_names.h tree.h mac.h \
+		 defines.h tree.h mac.h \
 		 send_packets.h signal_handler.h common.h tcpreplay_opts.h \
 		 tcprewrite.h tcprewrite_opts.h tcpprep_opts.h \
 		 tcpprep_opts.def tcprewrite_opts.def tcpreplay_opts.def \
 		 flowreplay_opts.def tcpbridge_opts.def tcpbridge.h \
-		 flowreplay_opts.h tcpbridge_opts.h 
+		 flowreplay_opts.h tcpbridge_opts.h tcpr.h
 
 
 MOSTLYCLEANFILES = *~ *.o

+ 21 - 20
src/Makefile.in

@@ -39,10 +39,11 @@ build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
 bin_PROGRAMS = tcpreplay$(EXEEXT) tcpprep$(EXEEXT) tcprewrite$(EXEEXT) \
-	tcpbridge$(EXEEXT) $(am__EXEEXT_1)
-@HAVE_LIBNIDS_TRUE@am__append_1 = flowreplay
-@HAVE_LIBNIDS_TRUE@am__append_2 = flowreplay.1
-@HAVE_LIBNIDS_TRUE@am__append_3 = flowreplay.1
+	$(am__EXEEXT_1) $(am__EXEEXT_2)
+@ENABLE_FLOWREPLAY_TRUE@am__append_1 = flowreplay.1
+@ENABLE_FLOWREPLAY_TRUE@am__append_2 = flowreplay
+@ENABLE_TCPBRIDGE_TRUE@am__append_3 = tcpbridge.1
+@ENABLE_TCPBRIDGE_TRUE@am__append_4 = tcpbridge
 subdir = src
 DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
 	$(srcdir)/Makefile.in $(srcdir)/config.h.in \
@@ -54,7 +55,8 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
 CONFIG_HEADER = config.h
 CONFIG_CLEAN_FILES = defines.h
-@HAVE_LIBNIDS_TRUE@am__EXEEXT_1 = flowreplay$(EXEEXT)
+@ENABLE_FLOWREPLAY_TRUE@am__EXEEXT_1 = flowreplay$(EXEEXT)
+@ENABLE_TCPBRIDGE_TRUE@am__EXEEXT_2 = tcpbridge$(EXEEXT)
 am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"
 binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 PROGRAMS = $(bin_PROGRAMS)
@@ -147,14 +149,16 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ENABLE_FLOWREPLAY_FALSE = @ENABLE_FLOWREPLAY_FALSE@
+ENABLE_FLOWREPLAY_TRUE = @ENABLE_FLOWREPLAY_TRUE@
+ENABLE_TCPBRIDGE_FALSE = @ENABLE_TCPBRIDGE_FALSE@
+ENABLE_TCPBRIDGE_TRUE = @ENABLE_TCPBRIDGE_TRUE@
 EXEEXT = @EXEEXT@
 F77 = @F77@
 FFLAGS = @FFLAGS@
 FIG2DEV = @FIG2DEV@
 HAVE_DOCTOOLS_FALSE = @HAVE_DOCTOOLS_FALSE@
 HAVE_DOCTOOLS_TRUE = @HAVE_DOCTOOLS_TRUE@
-HAVE_LIBNIDS_FALSE = @HAVE_LIBNIDS_FALSE@
-HAVE_LIBNIDS_TRUE = @HAVE_LIBNIDS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
@@ -171,8 +175,6 @@ LNAVLIB = @LNAVLIB@
 LNAV_CFLAGS = @LNAV_CFLAGS@
 LNETINC = @LNETINC@
 LNETLIB = @LNETLIB@
-LNIDSINC = @LNIDSINC@
-LNIDSLIB = @LNIDSLIB@
 LN_S = @LN_S@
 LPCAPINC = @LPCAPINC@
 LPCAPLIB = @LPCAPLIB@
@@ -257,14 +259,13 @@ target_os = @target_os@
 target_vendor = @target_vendor@
 td = @td@
 
-# $Id: Makefile.am 1518 2006-07-18 02:47:33Z aturner $
+# $Id: Makefile.am 1577 2006-08-08 02:50:05Z aturner $
 SUBDIRS = common tcpedit flow
 @SYSTEM_STRLCPY_FALSE@LIBSTRL = ../lib/libstrl.a
 @SYSTEM_STRLCPY_TRUE@LIBSTRL = 
-man_MANS = tcpreplay.1 tcpprep.1 tcprewrite.1 tcpbridge.1 \
-	$(am__append_2)
-EXTRA_DIST = tcpreplay.1 tcpprep.1 tcprewrite.1 tcpbridge.1 \
+man_MANS = tcpreplay.1 tcpprep.1 tcprewrite.1 $(am__append_1) \
 	$(am__append_3)
+EXTRA_DIST = tcpreplay.1 tcpprep.1 tcprewrite.1 tcpbridge.1 flowreplay.1
 tcpreplay_CFLAGS = $(LIBOPTS_CFLAGS) -I.. $(LNAV_CFLAGS) -DTCPREPLAY
 tcpreplay_LDADD = ./common/libcommon.a $(LIBSTRL) \
 		  @LNETLIB@ @LPCAPLIB@ $(LIBOPTS_LDADD)
@@ -282,7 +283,7 @@ tcpprep_LDADD = ./common/libcommon.a \
 tcpprep_SOURCES = tcpprep_opts.c tcpprep.c tree.c mac.c
 flowreplay_CFLAGS = $(LIBOPTS_CFLAGS) -I.. $(LNAV_CFLAGS) -DFLOWREPLAY
 flowreplay_LDADD = ./common/libcommon.a $(LIBSTRL) ./flow/libflow.a \
-		  @LNIDSLIB@ @LNETLIB@ @LPCAPLIB@ $(LIBOPTS_LDADD)
+		  @LNETLIB@ @LPCAPLIB@ $(LIBOPTS_LDADD)
 
 flowreplay_SOURCES = flowreplay_opts.c flowreplay.c 
 tcpbridge_CFLAGS = $(LIBOPTS_CFLAGS) -I.. $(LNAV_CFLAGS) -DTCPBRIDGE
@@ -293,12 +294,12 @@ tcpbridge_SOURCES = tcpbridge_opts.c tcpbridge.c bridge.c send_packets.c \
 		mac.c
 
 noinst_HEADERS = tcpreplay.h tcpprep.h flowreplay.h bridge.h \
-		 defines.h dlt_names.h tree.h mac.h \
+		 defines.h tree.h mac.h \
 		 send_packets.h signal_handler.h common.h tcpreplay_opts.h \
 		 tcprewrite.h tcprewrite_opts.h tcpprep_opts.h \
 		 tcpprep_opts.def tcprewrite_opts.def tcpreplay_opts.def \
 		 flowreplay_opts.def tcpbridge_opts.def tcpbridge.h \
-		 flowreplay_opts.h tcpbridge_opts.h 
+		 flowreplay_opts.h tcpbridge_opts.h tcpr.h
 
 MOSTLYCLEANFILES = *~ *.o
 MAINTAINERCLEANFILES = Makefile.in tcpreplay_opts.h tcpreplay_opts.c \
@@ -1045,7 +1046,7 @@ autoopts: tcpreplay_opts.c tcprewrite_opts.c \
 tcpprep.1: tcpprep_opts.def
 	@AUTOGEN@ -T agman1.tpl --base-name tcpprep tcpprep_opts.def
 
-tcprewrite.1: tcprewrite_opts.def
+tcprewrite.1: tcprewrite_opts.def tcpedit/tcpedit_opts.def
 	@AUTOGEN@ -T agman1.tpl --base-name tcprewrite tcprewrite_opts.def
 
 tcpreplay.1: tcpreplay_opts.def
@@ -1054,7 +1055,7 @@ tcpreplay.1: tcpreplay_opts.def
 flowreplay.1: flowreplay_opts.def
 	@AUTOGEN@ -T agman1.tpl --base-name flowreplay flowreplay_opts.def
 
-tcpbridge.1: tcpbridge_opts.def
+tcpbridge.1: tcpbridge_opts.def tcpedit/tcpedit_opts.def
 	@AUTOGEN@ -T agman1.tpl --base-name tcpbridge tcpbridge_opts.def
 tcpreplay_OBJECTS: tcpreplay_opts.h
 tcpreplay_opts.h: tcpreplay_opts.c
@@ -1062,7 +1063,7 @@ tcpreplay_opts.c: tcpreplay_opts.def
 	@AUTOGEN@ tcpreplay_opts.def
 tcprewrite_OBJECTS: tcprewrite_opts.h
 tcprewrite_opts.h: tcprewrite_opts.c
-tcprewrite_opts.c: tcprewrite_opts.def
+tcprewrite_opts.c: tcprewrite_opts.def tcpedit/tcpedit_opts.def
 	@AUTOGEN@ tcprewrite_opts.def
 tcpprep_OBJECTS: tcpprep_opts.h
 tcpprep_opts.h: tcpprep_opts.c
@@ -1074,7 +1075,7 @@ flowreplay_opts.c: flowreplay_opts.def
 	@AUTOGEN@ flowreplay_opts.def
 tcpbridge_OBJECTS: tcpbridge_opts.h
 tcpbridge_opts.h: tcpbridge_opts.c
-tcpbridge_opts.c: tcpbridge_opts.def
+tcpbridge_opts.c: tcpbridge_opts.def tcpedit/tcpedit_opts.def
 	@AUTOGEN@ tcpbridge_opts.def
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.

+ 15 - 22
src/bridge.c

@@ -1,4 +1,4 @@
-/* $Id: bridge.c 1462 2006-04-13 05:10:27Z aturner $ */
+/* $Id: bridge.c 1540 2006-07-29 06:17:04Z aturner $ */
 
 /*
  * Copyright (c) 2001-2005 Aaron Turner.
@@ -39,6 +39,8 @@
 #include <string.h>
 #include <netinet/in.h>
 #include <time.h>
+#include <errno.h>
+#include <stdlib.h>
 
 #include "tcpbridge.h"
 #include "bridge.h"
@@ -192,14 +194,14 @@ static int
 live_callback(struct live_data_t *livedata, struct pcap_pkthdr *pkthdr,
               const u_char * nextpkt)
 {
-    ip_hdr_t *ip_hdr = NULL;
-    libnet_t *l = NULL;
+    ipv4_hdr_t *ip_hdr = NULL;
+    sendpacket_t *sp = NULL;
     static u_char *pktdata = NULL;     /* full packet buffer */
 #ifdef FORCE_ALIGN
     u_char *ipbuff = NULL;      /* IP header and above buffer */
 #endif
     static int first_time = 1;
-    int ret, newl2len, cache_mode;
+    int newl2len, cache_mode;
     static unsigned long packetnum = 0;
     struct macsrc_t *node, finder;  /* rb tree nodes */
 #ifdef DEBUG
@@ -243,12 +245,12 @@ live_callback(struct live_data_t *livedata, struct pcap_pkthdr *pkthdr,
 #endif
 
     /* first, is this a packet sent locally?  If so, ignore it */
-    if ((memcmp(libnet_get_hwaddr(options.send1), &finder.key, 
+    if ((memcmp(sendpacket_get_hwaddr(options.sp1), &finder.key, 
                 ETHER_ADDR_LEN)) == 0) {
         dbgx(1, "Packet matches the MAC of %s, skipping.", options.intf1);
         return (1);
     }
-    else if ((memcmp(libnet_get_hwaddr(options.send2), &finder.key,
+    else if ((memcmp(sendpacket_get_hwaddr(options.sp2), &finder.key,
                      ETHER_ADDR_LEN)) == 0) {
         dbgx(1, "Packet matches the MAC of %s, skipping.", options.intf2);
         return (1);
@@ -292,12 +294,12 @@ live_callback(struct live_data_t *livedata, struct pcap_pkthdr *pkthdr,
     if (node->source == PCAP_INT1) {
         dbgx(2, "Packet source was %s... sending out on %s", options.intf1, 
             options.intf2);
-        l = options.send2;
+        sp = options.sp2;
     }
     else if (node->source == PCAP_INT2) {
         dbgx(2, "Packet source was %s... sending out on %s", options.intf2, 
             options.intf1);
-        l = options.send1;
+        sp = options.sp1;
     } else {
         errx(1, "wtf?  our node->source != PCAP_INT1 and != PCAP_INT2: %c", 
              node->source);
@@ -314,14 +316,14 @@ live_callback(struct live_data_t *livedata, struct pcap_pkthdr *pkthdr,
          * back onto the pkt.data + newl2len buffer
          * we do all this work to prevent byte alignment issues
          */
-        ip_hdr = (ip_hdr_t *) ipbuff;
+        ip_hdr = (ipv4_hdr_t *) ipbuff;
         memcpy(ip_hdr, (&pktdata[newl2len]), pkthdr->caplen - newl2len);
 #else
         /*
          * on non-strict byte align systems, don't need to memcpy(), 
          * just point to 14 bytes into the existing buffer
          */
-        ip_hdr = (ip_hdr_t *) (&pktdata[newl2len]);
+        ip_hdr = (ipv4_hdr_t *) (&pktdata[newl2len]);
 #endif
 
         /* look for include or exclude CIDR match */
@@ -350,18 +352,9 @@ live_callback(struct live_data_t *livedata, struct pcap_pkthdr *pkthdr,
     /*
      * write packet out on the network 
      */
-    do {
-        ret = libnet_adv_write_link(l, pktdata, pkthdr->caplen);
-        if (ret == -1) {
-            /* Make note of failed writes due to full buffers */
-            if (errno == ENOBUFS) {
-                failed++;
-            }
-            else {
-                errx(1, "libnet_adv_write_link(): %s", strerror(errno));
-            }
-        }
-    } while (ret == -1 && !didsig);
+     if (sendpacket(sp, pktdata, pkthdr->caplen) < pkthdr->caplen) {
+         errx(1, "Unable to send packet out %s: %s", sp->device, sendpacket_geterr(sp));
+     }
 
     bytes_sent += pkthdr->caplen;
     pkts_sent++;

+ 2 - 2
src/bridge.h

@@ -1,4 +1,4 @@
-/* $Id: bridge.h 1462 2006-04-13 05:10:27Z aturner $ */
+/* $Id: bridge.h 1540 2006-07-29 06:17:04Z aturner $ */
 
 /*
  * Copyright (c) 2001-2004 Aaron Turner.
@@ -44,7 +44,7 @@ struct macsrc_t {
     RB_ENTRY(macsrc_t) node;
     u_char key[ETHER_ADDR_LEN];
     u_char source;              /* interface device name we first saw the source MAC */
-    libnet_t *libnet;           /* libnet handle to send packets out */
+    sendpacket_t *sp;           /* sendpacket handle to send packets out */
 };
 
 /* pri and secondary pcap interfaces */

+ 1 - 0
src/common.h

@@ -17,6 +17,7 @@
 #include "common/tcpdump.h"
 #include "common/timer.h"
 #include "common/abort.h"
+#include "common/sendpacket.h"
 
 const char *svn_version(void); /* svn_version.c */
 

BIN
src/common/._cache.c


BIN
src/common/._cache.h


BIN
src/common/._cidr.c


BIN
src/common/._cidr.h


BIN
src/common/._fakepcapnav.h


BIN
src/common/._get.c


BIN
src/common/._get.h


BIN
src/common/._list.c


BIN
src/common/._services.c


BIN
src/common/._tcpdump.h


BIN
src/common/._xX.c


BIN
src/common/._xX.h


+ 5 - 3
src/common/Makefile.am

@@ -1,4 +1,4 @@
-# $Id: Makefile.am 1472 2006-06-11 23:14:48Z aturner $
+# $Id: Makefile.am 1533 2006-07-28 22:30:56Z aturner $
 noinst_LIBRARIES = libcommon.a
 
 BUILT_SOURCES = svn_version.c
@@ -13,7 +13,8 @@ svn_version.c:
 
 libcommon_a_SOURCES = cidr.c err.c list.c cache.c services.c get.c \
 		      fakepcap.c fakepcapnav.c fakepoll.c xX.c utils.c \
-		      tcpdump.c timer.c svn_version.c abort.c
+		      tcpdump.c timer.c svn_version.c abort.c sendpacket.c \
+			  dlt_names.c
 
 AM_CFLAGS = -I.. -I../.. $(LNAV_CFLAGS)
 
@@ -21,7 +22,8 @@ libcommon_a_LIBADD = ../../lib/libstrl.a
 
 noinst_HEADERS = cidr.h err.h list.h cache.h services.h get.h \
 		 fakepcap.h fakepcapnav.h fakepoll.h xX.h utils.h \
-		 tcpdump.h timer.h abort.h pcap_dlt.h
+		 tcpdump.h timer.h abort.h pcap_dlt.h sendpacket.h \
+		 dlt_names.h
 
 MOSTLYCLEANFILES = *~
 

+ 13 - 8
src/common/Makefile.in

@@ -56,7 +56,8 @@ am_libcommon_a_OBJECTS = cidr.$(OBJEXT) err.$(OBJEXT) list.$(OBJEXT) \
 	cache.$(OBJEXT) services.$(OBJEXT) get.$(OBJEXT) \
 	fakepcap.$(OBJEXT) fakepcapnav.$(OBJEXT) fakepoll.$(OBJEXT) \
 	xX.$(OBJEXT) utils.$(OBJEXT) tcpdump.$(OBJEXT) timer.$(OBJEXT) \
-	svn_version.$(OBJEXT) abort.$(OBJEXT)
+	svn_version.$(OBJEXT) abort.$(OBJEXT) sendpacket.$(OBJEXT) \
+	dlt_names.$(OBJEXT)
 libcommon_a_OBJECTS = $(am_libcommon_a_OBJECTS)
 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/src
 depcomp = $(SHELL) $(top_srcdir)/config/depcomp
@@ -104,14 +105,16 @@ ECHO_C = @ECHO_C@
 ECHO_N = @ECHO_N@
 ECHO_T = @ECHO_T@
 EGREP = @EGREP@
+ENABLE_FLOWREPLAY_FALSE = @ENABLE_FLOWREPLAY_FALSE@
+ENABLE_FLOWREPLAY_TRUE = @ENABLE_FLOWREPLAY_TRUE@
+ENABLE_TCPBRIDGE_FALSE = @ENABLE_TCPBRIDGE_FALSE@
+ENABLE_TCPBRIDGE_TRUE = @ENABLE_TCPBRIDGE_TRUE@
 EXEEXT = @EXEEXT@
 F77 = @F77@
 FFLAGS = @FFLAGS@
 FIG2DEV = @FIG2DEV@
 HAVE_DOCTOOLS_FALSE = @HAVE_DOCTOOLS_FALSE@
 HAVE_DOCTOOLS_TRUE = @HAVE_DOCTOOLS_TRUE@
-HAVE_LIBNIDS_FALSE = @HAVE_LIBNIDS_FALSE@
-HAVE_LIBNIDS_TRUE = @HAVE_LIBNIDS_TRUE@
 INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
@@ -128,8 +131,6 @@ LNAVLIB = @LNAVLIB@
 LNAV_CFLAGS = @LNAV_CFLAGS@
 LNETINC = @LNETINC@
 LNETLIB = @LNETLIB@
-LNIDSINC = @LNIDSINC@
-LNIDSLIB = @LNIDSLIB@
 LN_S = @LN_S@
 LPCAPINC = @LPCAPINC@
 LPCAPLIB = @LPCAPLIB@
@@ -214,18 +215,20 @@ target_os = @target_os@
 target_vendor = @target_vendor@
 td = @td@
 
-# $Id: Makefile.am 1472 2006-06-11 23:14:48Z aturner $
+# $Id: Makefile.am 1533 2006-07-28 22:30:56Z aturner $
 noinst_LIBRARIES = libcommon.a
 BUILT_SOURCES = svn_version.c
 libcommon_a_SOURCES = cidr.c err.c list.c cache.c services.c get.c \
 		      fakepcap.c fakepcapnav.c fakepoll.c xX.c utils.c \
-		      tcpdump.c timer.c svn_version.c abort.c
+		      tcpdump.c timer.c svn_version.c abort.c sendpacket.c \
+			  dlt_names.c
 
 AM_CFLAGS = -I.. -I../.. $(LNAV_CFLAGS)
 libcommon_a_LIBADD = ../../lib/libstrl.a
 noinst_HEADERS = cidr.h err.h list.h cache.h services.h get.h \
 		 fakepcap.h fakepcapnav.h fakepoll.h xX.h utils.h \
-		 tcpdump.h timer.h abort.h pcap_dlt.h
+		 tcpdump.h timer.h abort.h pcap_dlt.h sendpacket.h \
+		 dlt_names.h
 
 MOSTLYCLEANFILES = *~
 MAINTAINERCLEANFILES = Makefile.in svn_version.c
@@ -280,12 +283,14 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/abort.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cache.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cidr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dlt_names.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/err.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fakepcap.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fakepcapnav.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fakepoll.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sendpacket.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/services.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/svn_version.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpdump.Po@am__quote@

+ 4 - 1
src/common/abort.c

@@ -1,4 +1,4 @@
-/* $Id: abort.c 1462 2006-04-13 05:10:27Z aturner $ */
+/* $Id: abort.c 1543 2006-07-29 06:20:25Z aturner $ */
 
 /*
  * Copyright (c) 2005 Aaron Turner.
@@ -34,6 +34,9 @@
 #include "defines.h"
 #include "common.h"
 
+#include <signal.h>
+#include <stdlib.h>
+
 extern volatile int didsig;
 extern COUNTER bytes_sent, pkts_sent, failed;
 extern struct timeval begin, end;

+ 2 - 1
src/common/cache.c

@@ -1,4 +1,4 @@
-/* $Id: cache.c 1486 2006-07-09 02:40:21Z aturner $ */
+/* $Id: cache.c 1543 2006-07-29 06:20:25Z aturner $ */
 
 /*
  * Copyright (c) 2001-2005 Aaron Turner.
@@ -42,6 +42,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#include <errno.h>
 
 #ifdef DEBUG
 extern int debug;

+ 2 - 2
src/common/cidr.c

@@ -1,4 +1,4 @@
-/* $Id: cidr.c 1498 2006-07-16 04:32:37Z aturner $ */
+/* $Id: cidr.c 1543 2006-07-29 06:20:25Z aturner $ */
 
 /*
  * Copyright (c) 2001-2004 Aaron Turner.
@@ -130,7 +130,7 @@ ip2cidr(const unsigned long ip, const int masklen)
 
     network = (u_char *)safe_malloc(20);
 
-    strlcpy((char *)network, (char *)get_addr2name4(ip, LIBNET_DONT_RESOLVE),
+    strlcpy((char *)network, (char *)get_addr2name4(ip, RESOLVE),
             sizeof(network));
 
     strcat((char *)network, "/");

+ 248 - 0
src/common/dlt_names.c

@@ -0,0 +1,248 @@
+/*
+ * Copyright (c) 2006 Aaron Turner
+ * All rights reserved.
+ *
+ * This file is generated by scripts/dlt2name.pl which converts your pcap-bpf.h
+ * header file which comes with libpcap into a header file
+ * which translates DLT values to their string names as well as a list of all
+ * of the available DLT types.
+ *
+ * Hence DO NOT EDIT THIS FILE!
+ * If your DLT type is not listed here, edit the %known hash in
+ * scripts/dlt2name.pl
+ * 
+ * This file contains data which was taken from libpcap's pcap-bpf.h.  
+ * The copyright/license is included below:
+ */
+ 
+ /*-
+  * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
+  *      The Regents of the University of California.  All rights reserved.
+  *
+  * This code is derived from the Stanford/CMU enet packet filter,
+  * (net/enet.c) distributed as part of 4.3BSD, and code contributed
+  * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence 
+  * Berkeley Laboratory.
+  *
+  * Redistribution and use in source and binary forms, with or without
+  * modification, are permitted provided that the following conditions
+  * are met:
+  * 1. Redistributions of source code must retain the above copyright
+  *    notice, this list of conditions and the following disclaimer.
+  * 2. Redistributions in binary form must reproduce the above copyright
+  *    notice, this list of conditions and the following disclaimer in the
+  *    documentation and/or other materials provided with the distribution.
+  * 3. All advertising materials mentioning features or use of this software
+  *    must display the following acknowledgement:
+  *      This product includes software developed by the University of
+  *      California, Berkeley and its contributors.
+  * 4. Neither the name of the University nor the names of its contributors
+  *    may be used to endorse or promote products derived from this software
+  *    without specific prior written permission.
+  *
+  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+  * SUCH DAMAGE.
+  *
+  *      @(#)bpf.h       7.1 (Berkeley) 5/7/91
+  *
+  * @(#) $Header: /tcpdump/master/libpcap/pcap-bpf.h,v 1.34.2.6 2005/08/13 22:29:47 hannes Exp $ (LBL)
+  */
+
+
+#include <stdlib.h>
+
+/* DLT to descriptions */
+char *dlt2desc[] = {
+		"BSD loopback encapsulation",
+		"Ethernet (10Mb)",
+		"Experimental Ethernet (3Mb)",
+		"Amateur Radio AX.25",
+		"Proteon ProNET Token Ring",
+		"Chaos",
+		"IEEE 802 Networks",
+		"ARCNET, with BSD-style header",
+		"Serial Line IP",
+		"Point-to-point Protocol",
+		"FDDI",
+		"LLC-encapsulated ATM",
+		"raw IP",
+		"BSD/OS Serial Line IP",
+		"BSD/OS Point-to-point Protocol",
+		"BSD/OS Serial Line IP",
+		"BSD/OS Point-to-point Protocol",
+		"",
+		"",
+		"Linux Classical-IP over ATM",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"PPP over serial with HDLC encapsulation",
+		"PPP over Ethernet",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Cisco HDLC",
+		"IEEE 802.11 wireless",
+		"Unknown",
+		"BSD/OS Frame Relay",
+		"OpenBSD Loopback",
+		"",
+		"Unknown",
+		"Unknown",
+		"Unknown",
+		"Linux Cooked Sockets",
+		"Apple LocalTalk",
+		"Acorn Econet",
+		"OpenBSD IPFilter",
+		"OpenBSD PF Log/SuSE 6.3 LANE 802.3",
+		"Cisco IOS",
+		"802.11 Prism Header",
+		"802.11 Aironet Header",
+		"Siemens HiPath HDLC",
+		"IP over Fibre Channel",
+		"Solaris+SunATM",
+		"RapidIO",
+		"PCI Express",
+		"Xilinx Aurora link layer",
+		"802.11 plus radiotap radio header",
+		"Tazmen Sniffer Protocol",
+		"ARCNET",
+		"",
+		"",
+		"",
+		"",
+		"",
+		"",
+		"",
+		"",
+		"",
+		"pseudo-header with various info, followed by MTP2",
+		"MTP2, without pseudo-header",
+		"MTP3, without pseudo-header or MTP2",
+		"SCCP, without pseudo-header or MTP2 or MTP3",
+		"",
+		"",
+		"",
+		"",
+		"",
+		"",
+		"",
+		"",
+		"",
+		"",
+		"",
+		"",
+		"",
+		"",
+		"",
+		"",
+		"",
+		"",
+		"",
+		"",
+		"802.11 plus AVS radio header",
+		"",
+		"",
+		"",
+		"",
+		"",
+		"GPRS LLC",
+		"GPF-T (ITU-T G.7041/Y.1303)",
+		"GPF-F (ITU-T G.7041/Y.1303)",
+		"",
+		"",
+		"",
+		"Ethernet",
+		"Packet-over-SONET",
+		"",
+		"",
+		"",
+		"",
+		NULL
+};
+

+ 457 - 0
src/common/dlt_names.h

@@ -0,0 +1,457 @@
+/*
+ * Copyright (c) 2006 Aaron Turner
+ * All rights reserved.
+ *
+ * This file is generated by scripts/dlt2name.pl which converts your pcap-bpf.h
+ * header file which comes with libpcap into a header file
+ * which translates DLT values to their string names as well as a list of all
+ * of the available DLT types.
+ *
+ * Hence DO NOT EDIT THIS FILE!
+ * If your DLT type is not listed here, edit the %known hash in
+ * scripts/dlt2name.pl
+ * 
+ * This file contains data which was taken from libpcap's pcap-bpf.h.  
+ * The copyright/license is included below:
+ */
+ 
+ /*-
+  * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
+  *      The Regents of the University of California.  All rights reserved.
+  *
+  * This code is derived from the Stanford/CMU enet packet filter,
+  * (net/enet.c) distributed as part of 4.3BSD, and code contributed
+  * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence 
+  * Berkeley Laboratory.
+  *
+  * Redistribution and use in source and binary forms, with or without
+  * modification, are permitted provided that the following conditions
+  * are met:
+  * 1. Redistributions of source code must retain the above copyright
+  *    notice, this list of conditions and the following disclaimer.
+  * 2. Redistributions in binary form must reproduce the above copyright
+  *    notice, this list of conditions and the following disclaimer in the
+  *    documentation and/or other materials provided with the distribution.
+  * 3. All advertising materials mentioning features or use of this software
+  *    must display the following acknowledgement:
+  *      This product includes software developed by the University of
+  *      California, Berkeley and its contributors.
+  * 4. Neither the name of the University nor the names of its contributors
+  *    may be used to endorse or promote products derived from this software
+  *    without specific prior written permission.
+  *
+  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+  * SUCH DAMAGE.
+  *
+  *      @(#)bpf.h       7.1 (Berkeley) 5/7/91
+  *
+  * @(#) $Header: /tcpdump/master/libpcap/pcap-bpf.h,v 1.34.2.6 2005/08/13 22:29:47 hannes Exp $ (LBL)
+  */
+
+
+/* include all the DLT types form pcap-bpf.h */
+
+extern char *dlt2desc[];
+#define DLT2DESC_LEN 181
+
+#ifndef DLT_NULL
+#define DLT_NULL 0
+#endif
+
+#ifndef DLT_EN10MB
+#define DLT_EN10MB 1
+#endif
+
+#ifndef DLT_EN3MB
+#define DLT_EN3MB 2
+#endif
+
+#ifndef DLT_AX25
+#define DLT_AX25 3
+#endif
+
+#ifndef DLT_PRONET
+#define DLT_PRONET 4
+#endif
+
+#ifndef DLT_CHAOS
+#define DLT_CHAOS 5
+#endif
+
+#ifndef DLT_IEEE802
+#define DLT_IEEE802 6
+#endif
+
+#ifndef DLT_ARCNET
+#define DLT_ARCNET 7
+#endif
+
+#ifndef DLT_SLIP
+#define DLT_SLIP 8
+#endif
+
+#ifndef DLT_PPP
+#define DLT_PPP 9
+#endif
+
+#ifndef DLT_FDDI
+#define DLT_FDDI 10
+#endif
+
+#ifndef DLT_ATM_RFC1483
+#define DLT_ATM_RFC1483 11
+#endif
+
+#ifndef DLT_RAW
+#define DLT_RAW 12
+#endif
+
+#ifndef DLT_ENC
+#define DLT_ENC 13
+#endif
+
+#ifndef DLT_PPP_BSDOS
+#define DLT_PPP_BSDOS 14
+#endif
+
+#ifndef DLT_SLIP_BSDOS
+#define DLT_SLIP_BSDOS 15
+#endif
+
+#ifndef DLT_PPP_BSDOS
+#define DLT_PPP_BSDOS 16
+#endif
+
+#ifndef DLT_OLD_PFLOG
+#define DLT_OLD_PFLOG 17
+#endif
+
+#ifndef DLT_PFSYNC
+#define DLT_PFSYNC 18
+#endif
+
+#ifndef DLT_ATM_CLIP
+#define DLT_ATM_CLIP 19
+#endif
+
+#ifndef DLT_REDBACK_SMARTEDGE
+#define DLT_REDBACK_SMARTEDGE 32
+#endif
+
+#ifndef DLT_PPP_SERIAL
+#define DLT_PPP_SERIAL 50
+#endif
+
+#ifndef DLT_PPP_ETHER
+#define DLT_PPP_ETHER 51
+#endif
+
+#ifndef DLT_SYMANTEC_FIREWALL
+#define DLT_SYMANTEC_FIREWALL 99
+#endif
+
+#ifndef DLT_C_HDLC
+#define DLT_C_HDLC 104
+#endif
+
+#ifndef DLT_IEEE802_11
+#define DLT_IEEE802_11 105
+#endif
+
+#ifndef DLT_FRELAY
+#define DLT_FRELAY 107
+#endif
+
+#ifndef DLT_LOOP
+#define DLT_LOOP 108
+#endif
+
+#ifndef DLT_ENC
+#define DLT_ENC 109
+#endif
+
+#ifndef DLT_LINUX_SLL
+#define DLT_LINUX_SLL 113
+#endif
+
+#ifndef DLT_LTALK
+#define DLT_LTALK 114
+#endif
+
+#ifndef DLT_ECONET
+#define DLT_ECONET 115
+#endif
+
+#ifndef DLT_IPFILTER
+#define DLT_IPFILTER 116
+#endif
+
+#ifndef DLT_PFLOG
+#define DLT_PFLOG 117
+#endif
+
+#ifndef DLT_CISCO_IOS
+#define DLT_CISCO_IOS 118
+#endif
+
+#ifndef DLT_PRISM_HEADER
+#define DLT_PRISM_HEADER 119
+#endif
+
+#ifndef DLT_AIRONET_HEADER
+#define DLT_AIRONET_HEADER 120
+#endif
+
+#ifndef DLT_HHDLC
+#define DLT_HHDLC 121
+#endif
+
+#ifndef DLT_IP_OVER_FC
+#define DLT_IP_OVER_FC 122
+#endif
+
+#ifndef DLT_SUNATM
+#define DLT_SUNATM 123
+#endif
+
+#ifndef DLT_RIO
+#define DLT_RIO 124
+#endif
+
+#ifndef DLT_PCI_EXP
+#define DLT_PCI_EXP 125
+#endif
+
+#ifndef DLT_AURORA
+#define DLT_AURORA 126
+#endif
+
+#ifndef DLT_IEEE802_11_RADIO
+#define DLT_IEEE802_11_RADIO 127
+#endif
+
+#ifndef DLT_TZSP
+#define DLT_TZSP 128
+#endif
+
+#ifndef DLT_ARCNET_LINUX
+#define DLT_ARCNET_LINUX 129
+#endif
+
+#ifndef DLT_JUNIPER_MLPPP
+#define DLT_JUNIPER_MLPPP 130
+#endif
+
+#ifndef DLT_JUNIPER_MLFR
+#define DLT_JUNIPER_MLFR 131
+#endif
+
+#ifndef DLT_JUNIPER_ES
+#define DLT_JUNIPER_ES 132
+#endif
+
+#ifndef DLT_JUNIPER_GGSN
+#define DLT_JUNIPER_GGSN 133
+#endif
+
+#ifndef DLT_JUNIPER_MFR
+#define DLT_JUNIPER_MFR 134
+#endif
+
+#ifndef DLT_JUNIPER_ATM2
+#define DLT_JUNIPER_ATM2 135
+#endif
+
+#ifndef DLT_JUNIPER_SERVICES
+#define DLT_JUNIPER_SERVICES 136
+#endif
+
+#ifndef DLT_JUNIPER_ATM1
+#define DLT_JUNIPER_ATM1 137
+#endif
+
+#ifndef DLT_APPLE_IP_OVER_IEEE1394
+#define DLT_APPLE_IP_OVER_IEEE1394 138
+#endif
+
+#ifndef DLT_MTP2_WITH_PHDR
+#define DLT_MTP2_WITH_PHDR 139
+#endif
+
+#ifndef DLT_MTP2
+#define DLT_MTP2 140
+#endif
+
+#ifndef DLT_MTP3
+#define DLT_MTP3 141
+#endif
+
+#ifndef DLT_SCCP
+#define DLT_SCCP 142
+#endif
+
+#ifndef DLT_DOCSIS
+#define DLT_DOCSIS 143
+#endif
+
+#ifndef DLT_LINUX_IRDA
+#define DLT_LINUX_IRDA 144
+#endif
+
+#ifndef DLT_IBM_SP
+#define DLT_IBM_SP 145
+#endif
+
+#ifndef DLT_IBM_SN
+#define DLT_IBM_SN 146
+#endif
+
+#ifndef DLT_USER0
+#define DLT_USER0 147
+#endif
+
+#ifndef DLT_USER1
+#define DLT_USER1 148
+#endif
+
+#ifndef DLT_USER2
+#define DLT_USER2 149
+#endif
+
+#ifndef DLT_USER3
+#define DLT_USER3 150
+#endif
+
+#ifndef DLT_USER4
+#define DLT_USER4 151
+#endif
+
+#ifndef DLT_USER5
+#define DLT_USER5 152
+#endif
+
+#ifndef DLT_USER6
+#define DLT_USER6 153
+#endif
+
+#ifndef DLT_USER7
+#define DLT_USER7 154
+#endif
+
+#ifndef DLT_USER8
+#define DLT_USER8 155
+#endif
+
+#ifndef DLT_USER9
+#define DLT_USER9 156
+#endif
+
+#ifndef DLT_USER10
+#define DLT_USER10 157
+#endif
+
+#ifndef DLT_USER11
+#define DLT_USER11 158
+#endif
+
+#ifndef DLT_USER12
+#define DLT_USER12 159
+#endif
+
+#ifndef DLT_USER13
+#define DLT_USER13 160
+#endif
+
+#ifndef DLT_USER14
+#define DLT_USER14 161
+#endif
+
+#ifndef DLT_USER15
+#define DLT_USER15 162
+#endif
+
+#ifndef DLT_IEEE802_11_RADIO_AVS
+#define DLT_IEEE802_11_RADIO_AVS 163
+#endif
+
+#ifndef DLT_JUNIPER_MONITOR
+#define DLT_JUNIPER_MONITOR 164
+#endif
+
+#ifndef DLT_BACNET_MS_TP
+#define DLT_BACNET_MS_TP 165
+#endif
+
+#ifndef DLT_PPP_PPPD
+#define DLT_PPP_PPPD 166
+#endif
+
+#ifndef DLT_JUNIPER_PPPOE
+#define DLT_JUNIPER_PPPOE 167
+#endif
+
+#ifndef DLT_JUNIPER_PPPOE_ATM
+#define DLT_JUNIPER_PPPOE_ATM 168
+#endif
+
+#ifndef DLT_GPRS_LLC
+#define DLT_GPRS_LLC 169
+#endif
+
+#ifndef DLT_GPF_T
+#define DLT_GPF_T 170
+#endif
+
+#ifndef DLT_GPF_F
+#define DLT_GPF_F 171
+#endif
+
+#ifndef DLT_GCOM_T1E1
+#define DLT_GCOM_T1E1 172
+#endif
+
+#ifndef DLT_GCOM_SERIAL
+#define DLT_GCOM_SERIAL 173
+#endif
+
+#ifndef DLT_JUNIPER_PIC_PEER
+#define DLT_JUNIPER_PIC_PEER 174
+#endif
+
+#ifndef DLT_ERF_ETH
+#define DLT_ERF_ETH 175
+#endif
+
+#ifndef DLT_ERF_POS
+#define DLT_ERF_POS 176
+#endif
+
+#ifndef DLT_LINUX_LAPD
+#define DLT_LINUX_LAPD 177
+#endif
+
+#ifndef DLT_JUNIPER_ETHER
+#define DLT_JUNIPER_ETHER 178
+#endif
+
+#ifndef DLT_JUNIPER_PPP
+#define DLT_JUNIPER_PPP 179
+#endif
+
+#ifndef DLT_JUNIPER_FRELAY
+#define DLT_JUNIPER_FRELAY 180
+#endif
+
+#ifndef DLT_JUNIPER_CHDLC
+#define DLT_JUNIPER_CHDLC 181
+#endif
+

+ 1 - 3
src/common/fakepcap.c

@@ -1,4 +1,4 @@
-/* $Id: fakepcap.c 1462 2006-04-13 05:10:27Z aturner $ */
+/* $Id: fakepcap.c 1543 2006-07-29 06:20:25Z aturner $ */
 
 /*
  * Copyright (c) 2004 Aaron Turner.
@@ -41,8 +41,6 @@
 #include "defines.h"
 #include "common.h"
 
-#include "dlt_names.h"
-
 #include <stdlib.h>
 
 #ifndef HAVE_DLT_VAL_TO_DESC

+ 16 - 8
src/common/get.c

@@ -1,4 +1,4 @@
-/* $Id: get.c 1493 2006-07-11 22:51:39Z aturner $ */
+/* $Id: get.c 1543 2006-07-29 06:20:25Z aturner $ */
 
 /*
  * Copyright (c) 2001-2005 Aaron Turner.
@@ -36,6 +36,12 @@
 #include "common.h"
 #include "../../lib/sll.h"
 
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <ctype.h>
+
 #ifdef DEBUG
 extern int debug;
 #endif
@@ -119,10 +125,10 @@ get_l2len(const u_char *pktdata, const int datalen, const int datalink)
         ether_type = ntohs(eth_hdr->ether_type);
         switch (ether_type) {
         case ETHERTYPE_VLAN:            /* 802.1q */
-            return LIBNET_802_1Q_H;
+            return TCPR_802_1Q_H;
             break;
         default:              /* ethernet */
-            return LIBNET_ETH_H;
+            return TCPR_ETH_H;
             break;
         }
         break;
@@ -167,7 +173,7 @@ get_ipv4(const u_char *pktdata, int datalen, int datalink, u_char **newbuff)
     l2_len = get_l2len(pktdata, datalen, datalink);
 
     /* sanity... datalen must be > l2_len + IP header len*/
-    if (l2_len + LIBNET_IPV4_H > datalen) {
+    if (l2_len + TCPR_IPV4_H > datalen) {
         dbg(1, "get_ipv4(): Layer 2 len > total packet len, hence no IP header");
         return NULL;
     }
@@ -208,7 +214,7 @@ get_ipv4(const u_char *pktdata, int datalen, int datalink, u_char **newbuff)
  * returns a pointer to the layer 4 header which is just beyond the IP header
  */
 void *
-get_layer4(const ip_hdr_t * ip_hdr)
+get_layer4(const ipv4_hdr_t * ip_hdr)
 {
     void *ptr;
 
@@ -228,12 +234,14 @@ u_int32_t
 get_name2addr4(const char *hostname, u_int8_t dnslookup)
 {
     struct in_addr addr;
+#ifndef HAVE_INET_ATON && defined HAVE_INET_ADDR
     struct hostent *host_ent; 
+#endif
     u_int32_t m;
     u_int val;
     int i;
 
-    if (dnslookup == LIBNET_RESOLVE) {
+    if (dnslookup == 1) {
 #ifdef HAVE_INET_ATON
         if (inet_aton(hostname, &addr) != 1) {
             return(0xffffffff);
@@ -309,7 +317,7 @@ get_addr2name4(const u_int32_t ip, u_int8_t dnslookup)
 #ifdef HAVE_INET_NTOP
     if (inet_ntop(AF_INET, &addr, new_string, 255) == NULL) {
         warnx("Unable to convert 0x%x to a string", ip);
-        strcpy(new_string, "");
+        strlcpy(new_string, "", sizeof(new_string));
     }
     return new_string;
 #elif defined HAVE_INET_NTOA
@@ -318,7 +326,7 @@ get_addr2name4(const u_int32_t ip, u_int8_t dnslookup)
 #error "Unable to support get_addr2name4."
 #endif
 
-    if (dnslookup != 0) {
+    if (dnslookup != DNS_DONT_RESOLVE) {
         warn("Sorry, we don't support name resolution.");
     }
     return new_string;

+ 3 - 2
src/common/get.h

@@ -1,4 +1,4 @@
-/* $Id: get.h 1462 2006-04-13 05:10:27Z aturner $ */
+/* $Id: get.h 1543 2006-07-29 06:20:25Z aturner $ */
 
 /*
  * Copyright (c) 2001-2005 Aaron Turner.
@@ -43,12 +43,13 @@ int get_l2len(const u_char *pktdata, const int datalen, const int datalink);
 
 u_int16_t get_l2protocol(const u_char *pktdata, const int datalen, const int datalink);
 
-void *get_layer4(const ip_hdr_t * ip_hdr);
+void *get_layer4(const ipv4_hdr_t * ip_hdr);
 
 const u_char *get_ipv4(const u_char *pktdata, int datalen, int datalink, u_char **newbuff);
 
 u_int32_t get_name2addr4(const char *hostname, u_int8_t dnslookup);
 const char *get_addr2name4(const u_int32_t ip, u_int8_t dnslookup);
+
 #endif
 
 /*

+ 693 - 0
src/common/sendpacket.c

@@ -0,0 +1,693 @@
+/* $Id: sendpacket.c 1583 2006-08-08 04:25:31Z aturner $ */
+
+/*
+ * Copyright (c) 2006 Aaron Turner.
+ * Copyright (c) 1998 - 2004 Mike D. Schiffman <mike@infonexus.com>
+ * Copyright (c) 2000 Torsten Landschoff <torsten@debian.org>
+ *                    Sebastian Krahmer  <krahmer@cs.uni-potsdam.de>
+ * Copyright (c) 1993, 1994, 1995, 1996, 1998
+ *      The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the names of the copyright owners nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ * 4. All advertising materials mentioning features or use of this software
+ *    display the following acknowledgement:
+ *    ``This product includes software developed by the University of 
+ *    California,  Lawrence Berkeley Laboratory and its contributors.''
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+ 
+ /* sendpacket.[ch] is my attempt to write a universal packet injection
+  * API for BPF, libpcap, libnet, and Linux's PF_PACKET.  I got sick
+  * and tired dealing with libnet bugs and its lack of active maintenence,
+  * but unfortunately, libpcap frame injection support is relatively new 
+  * and not everyone uses Linux, so I decided to support all four as
+  * best as possible.  If your platform/OS/hardware supports an additional
+  * injection method, then by all means add it here (and send me a patch).
+  *
+  * Anyways, long story short, for now the order of preference is:
+  * 1. PF_PACKET
+  * 2. BPF
+  * 3. libnet
+  * 4. pcap_inject()
+  * 5. pcap_sendpacket()
+  *
+  * Right now, one big problem with the pcap_* methods is that libpcap 
+  * doesn't provide a reliable method of getting the MAC address of 
+  * an interface (required for tcpbridge).  
+  * You can use PF_PACKET or BPF to get that, but if your system suports 
+  * those, might as well inject directly without going through another 
+  * level of indirection.
+  * 
+  * Please note that some of this code was copied from Libnet 1.1.3
+  */
+
+#include "config.h"
+#include "defines.h"
+#include "common.h"
+#include "sendpacket.h"
+
+#if !defined HAVE_PCAP_INJECT && !defined HAVE_PCAP_SENDPACKET && !defined HAVE_LIBNET && !defined HAVE_PF_PACKET && !defined HAVE_BPF
+#error You need pcap_inject() or pcap_sendpacket() from libpcap, libnet 1.1.3+, Linux's PF_PACKET or *BSD's BPF
+#endif
+
+#include <string.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+#include <sys/file.h>
+#include <sys/sysctl.h>
+#include <net/route.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#if defined HAVE_PF_PACKET
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <sys/utsname.h>
+#include <net/if.h>
+#include <netinet/in.h>
+#include <linux/if_ether.h>
+#include <net/if_arp.h>
+#include <netpacket/packet.h>
+
+#ifndef __GLIBC__
+typedef int socklen_t;
+#endif
+
+static sendpacket_t *sendpacket_open_pf(const char *, char *);
+static struct tcpr_ether_addr *sendpacket_get_hwaddr_pf(sendpacket_t *);
+static int get_iface_index(int fd, const int8_t *device, char *);
+
+#elif defined HAVE_BPF
+#include <net/bpf.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#include <sys/uio.h>
+#include <pcap.h>
+#include <net/if_dl.h> // used for get_hwaddr_bpf()
+
+static sendpacket_t *sendpacket_open_bpf(const char *, char *);
+static struct tcpr_ether_addr *sendpacket_get_hwaddr_bpf(sendpacket_t *);
+
+#elif defined HAVE_LIBNET
+static sendpacket_t *sendpacket_open_libnet(const char *, char *);
+static struct tcpr_ether_addr *sendpacket_get_hwaddr_libnet(sendpacket_t *);
+
+#elif defined HAVE_PCAP_INJECT || defined HAVE_PACKET_SENDPACKET
+#include <pcap.h>
+static sendpacket_t *sendpacket_open_pcap(const char *, char *);
+static struct tcpr_ether_addr *sendpacket_get_hwaddr_pcap(sendpacket_t *);
+#endif
+
+static void sendpacket_seterr(sendpacket_t *sp, const char *fmt, ...);
+
+/* You need to define didsig in your main .c file.  Set to 1 if CTRL-C was pressed */
+extern volatile int didsig;
+
+
+/*
+ * returns number of bytes sent on success or -1 on error
+ * Note: it is theoretically possible to get a return code >0 and < len
+ * which for most people would be considered an error (the packet wasn't fully sent)
+ * so you may want to test for recode != len too.
+ */
+int
+sendpacket(sendpacket_t *sp, const u_char *data, size_t len)
+{
+    int retcode;
+
+    assert(sp);
+    assert(data);
+        
+    if (len <= 0)
+        return -1;
+                
+TRY_SEND_AGAIN:
+    sp->attempt ++;
+
+#if defined HAVE_PF_PACKET 
+    retcode = (int)send(sp->handle.fd, (void *)data, len, 0);
+        
+    /* out of buffers, silently retry */
+    if (retcode < 0 && errno == ENOBUFS && !didsig) {
+        sp->retry ++;
+        goto TRY_SEND_AGAIN;
+    } 
+    /* some other kind of error */
+    else if (retcode < 0) {
+        sendpacket_seterr(sp, "Error with pf send(): %s", strerror(errno));
+    }
+    
+#elif defined HAVE_BPF
+    retcode = write(sp->handle.fd, (void *)data, len);
+    if (retcode < 0 && errno == ENOBUFS && !didsig) {
+        sp->retry ++;
+        goto TRY_SEND_AGAIN;
+    } else if (retcode < 0) {
+        sendpacket_seterr(sp, "Error with bpf write(): %s", strerror(errno));
+    }
+    
+#elif defined HAVE_LIBNET
+    retcode = libnet_adv_write_link(sp->handle.lnet, (u_int8_t*)data, (u_int32_t)len);
+    if (retcode < 0 && errno == ENOBUFS && !didsig) {
+        sp->retry ++;
+        goto TRY_SEND_AGAIN;
+    } else if (retcode < 0) {
+        sendpacket_seterr(sp, "Error with libnet write: %s", libnet_geterror(sp->handle.lnet));
+    }
+
+    /* 
+     * pcap methods don't seem to support ENOBUFS, so we just straight fail
+     * is there a better way???
+     */    
+#elif defined HAVE_PCAP_INJECT
+    if ((retcode = pcap_inject(sp->handle.pcap, (void*)data, len)) < 0)
+        sendpacket_seterr(sp, "Error with pcap_inject(): %s", pcap_geterr(sp->handle.pcap));
+
+#elif defined HAVE_PCAP_SENDPACKET
+    if ((retcode = pcap_sendpacket(sp->handle.pcap, data, (int)len)) < 0)
+        sendpacket_seterr(sp, "Error with pcap_sendpacket(): %s", pcap_geterr(sp->handle.pcap));
+#endif
+
+    if (retcode < 0) {
+        sp->failed ++;
+    } else if (retcode != (int)len) {
+        sendpacket_seterr(sp, "Only able to write %d bytes out of %u bytes total",
+            retcode, len);
+    } else {
+        sp->bytes_sent += len;
+        sp->sent ++;
+    }
+    return retcode;
+}
+
+
+sendpacket_t *
+sendpacket_open(const char *device, char *errbuf)
+{
+    sendpacket_t *sp;
+
+    assert(device);
+    assert(errbuf);
+
+#if defined HAVE_PF_PACKET
+    sp = sendpacket_open_pf(device, errbuf);
+#elif defined HAVE_BPF
+    sp = sendpacket_open_bpf(device, errbuf);
+#elif defined HAVE_LIBNET
+    sp = sendpacket_open_libnet(device, errbuf);
+#elif (defined HAVE_PCAP_INJECT || defined HAVE_PCAP_SENDPACKET)
+    sp = sendpacket_open_pcap(device, errbuf);
+#endif
+    if (sp != NULL)
+        sp->open = 1;
+    return sp;
+}
+
+
+char *
+sendpacket_getstat(sendpacket_t *sp)
+{
+    static char buf[1024];
+    
+    assert(sp);
+    
+    memset(buf, 0, sizeof(buf));
+    sprintf(buf, "Statistics for network device: %s\n", sp->device);
+    sprintf(buf, "Attempted packets:   " COUNTER_SPEC "\n", sp->attempt);
+    sprintf(buf, "Successful packets:  " COUNTER_SPEC "\n", sp->sent);
+    sprintf(buf, "Failed packets:      " COUNTER_SPEC "\n", sp->failed);
+    sprintf(buf, "Retried packets:     " COUNTER_SPEC "\n", sp->retry);
+    return(buf);
+}
+
+int
+sendpacket_close(sendpacket_t *sp)
+{
+    assert(sp);
+
+    free(sp);
+    return 0;
+}
+
+/*
+ * returns the Layer 2 address of the interface current 
+ * open.  on error, return NULL
+ */
+struct tcpr_ether_addr *
+sendpacket_get_hwaddr(sendpacket_t *sp)
+{
+    struct tcpr_ether_addr *addr;    
+    assert(sp);
+    
+    /* if we already have our MAC address stored, just return it */
+    if (memcmp(&sp->ether, "\00\00\00\00\00\00", ETHER_ADDR_LEN) != 0)
+        return &sp->ether;
+        
+#if defined HAVE_PF_PACKET
+    addr = sendpacket_get_hwaddr_pf(sp);
+#elif defined HAVE_BPF
+    addr = sendpacket_get_hwaddr_bpf(sp);
+#elif defined HAVE_LIBNET
+    addr = sendpacket_get_hwaddr_libnet(sp);
+#elif (defined HAVE_PCAP_INJECT || defined HAVE_PCAP_SENDPACKET)
+    addr = sendpacket_get_hwaddr_pcap(sp);
+#endif
+    return addr;
+}
+
+/*
+ * returns the error string
+ */
+char *
+sendpacket_geterr(sendpacket_t *sp)
+{
+    assert(sp);
+    return sp->errbuf;
+}
+
+/*
+ * Set's the error string
+ */
+static void
+sendpacket_seterr(sendpacket_t *sp, const char *fmt, ...)
+{
+    va_list ap;
+    
+    assert(sp);
+    
+    va_start(ap, fmt);
+    if (fmt != NULL)
+        (void)vsnprintf(sp->errbuf, SENDPACKET_ERRBUF_SIZE, fmt, ap);
+    va_end(ap);
+    
+    sp->errbuf[(SENDPACKET_ERRBUF_SIZE-1)] = '\0'; // be safe
+}
+
+
+#if defined HAVE_PCAP_INJECT || defined HAVE_PCAP_SENDPACKET
+static sendpacket_t *
+sendpacket_open_pcap(const char *device, char *errbuf)
+{
+    pcap_t *pcap;
+    sendpacket_t *sp;
+    
+    assert(device);
+    assert(errbuf);
+    
+    /* open_pcap_live automatically fills out our errbuf for us */
+    if ((pcap = pcap_open_live(device, 0, 0, 0, errbuf)) == NULL)
+        return NULL;
+        
+    sp = (sendpacket_t *)safe_malloc(sizeof(sendpacket_t));
+    strlcpy(sp->device, device, sizeof(sp->device));
+    sp->handle.pcap = pcap;
+    return sp;
+}
+
+static struct tcpr_ether_addr *
+sendpacket_get_hwaddr_pcap(sendpacket_t *sp)
+{
+    assert(sp);
+    sendpacket_seterr(sp, "Error: sendpacket_get_hwaddr() not yet supported for pcap injection");
+    return NULL;
+}
+#endif
+
+#if defined HAVE_LIBNET
+static sendpacket_t *
+sendpacket_open_libnet(const char *device, char *errbuf)
+{
+    libnet_t *lnet;
+    sendpacket_t *sp;
+    
+    assert(device);
+    assert(errbuf);
+    
+    if ((lnet = libnet_init(LIBNET_LINK_ADV, device, errbuf)) == NULL)
+        return NULL;
+
+    sp = (sendpacket_t *)safe_malloc(sizeof(sendpacket_t));
+    strlcpy(sp->device, device, sizeof(sp->device));
+    sp->handle.lnet = lnet;
+    return sp;    
+}
+
+static struct tcpr_ether_addr *
+sendpacket_get_hwaddr_libnet(sendpacket_t *sp)
+{
+    struct tcpr_ether_addr *addr;
+    assert(sp);
+    
+    addr = (struct tcpr_ether_addr *)libnet_get_hwaddr(sp->handle.lnet);
+    
+    if (addr == NULL) {
+        sendpacket_seterr(sp, "Error getting hwaddr via libnet: %s", libnet_geterror(sp->handle.lnet));
+        return NULL;
+    }
+    
+    memcpy(&sp->ether, addr, sizeof(struct tcpr_ether_addr));
+    return(&sp->ether);
+}
+#endif
+
+#if defined HAVE_PF_PACKET
+static sendpacket_t *
+sendpacket_open_pf(const char *device, char *errbuf)
+{
+    int mysocket;
+    sendpacket_t *sp;
+    struct ifreq ifr;
+    struct sockaddr_ll sa;
+    int n = 1, err;
+    socklen_t errlen = sizeof(err);
+
+    assert(device);
+    assert(errbuf);
+   
+    /* open our socket */
+    if ((mysocket = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) < 0) {
+        snprintf(errbuf, SENDPACKET_ERRBUF_SIZE, "socket: %s", strerror(errno));
+        return NULL;
+    }
+
+   
+    /* get the interface id for the device */
+    if ((sa.sll_ifindex = get_iface_index(mysocket, device, errbuf)) < 0) {
+        close(mysocket);
+        return NULL; 
+    }
+
+    /* bind socket to our interface id */
+    sa.sll_family = AF_PACKET;
+    sa.sll_protocol = htons(ETH_P_ALL);
+    if (bind(mysocket, (struct sockaddr *)&sa, sizeof(sa)) < 0) {
+        snprintf(errbuf, SENDPACKET_ERRBUF_SIZE, "bind error: %s", strerror(errno));
+        close(mysocket);
+        return NULL;
+    }
+    
+    /* check for errors, network down, etc... */
+    if (getsockopt(mysocket, SOL_SOCKET, SO_ERROR, &err, &errlen) < 0) {
+        snprintf(errbuf, SENDPACKET_ERRBUF_SIZE, "error opening %s: %s", device, 
+            strerror(errno));
+        close(mysocket);
+        return NULL;
+    }
+    
+    if (err > 0) {
+        snprintf(errbuf, SENDPACKET_ERRBUF_SIZE, "error opening %s: %s", device, 
+            strerror(err));
+        close(mysocket);
+        return NULL;
+    }
+
+    /* get hardware type for our interface */
+    memset(&ifr, 0, sizeof(ifr));
+    strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
+    
+    if (ioctl(mysocket, SIOCGIFHWADDR, &ifr) < 0) {
+        close(mysocket);
+        sendpacket_seterr(sp, "Error getting hardware type: %s", strerror(errno));
+        return NULL;
+    }
+
+    /* make sure it's ethernet */
+    switch (ifr.ifr_hwaddr.sa_family) {
+        case ARPHRD_ETHER:
+            break;
+        default:
+            snprintf(errbuf, SENDPACKET_ERRBUF_SIZE, 
+                "unsupported pysical layer type 0x%x", ifr.ifr_hwaddr.sa_family);
+            close(mysocket);
+            return NULL;
+    }
+  
+#ifdef SO_BROADCAST
+    /*
+     * man 7 socket
+     *
+     * Set or get the broadcast flag. When  enabled,  datagram  sockets
+     * receive packets sent to a broadcast address and they are allowed
+     * to send packets to a broadcast  address.   This  option  has no
+     * effect on stream-oriented sockets.
+     */ 
+    if (setsockopt(mysocket, SOL_SOCKET, SO_BROADCAST, &n, sizeof(n)) == -1) {
+        snprintf(errbuf, SENDPACKET_ERRBUF_SIZE,
+                "SO_BROADCAS: %s\n", strerror(errno));
+        close(mysocket);
+        return NULL;
+    }
+#endif  /*  SO_BROADCAST  */
+   
+ 
+    /* prep & return our sp handle */
+    sp = (sendpacket_t *)safe_malloc(sizeof(sendpacket_t));
+    strlcpy(sp->device, device, sizeof(sp->device));
+    sp->handle.fd = mysocket;   
+    
+    return sp;
+}
+
+/* get the interface index (necessary for sending packets w/ PF_PACKET) */
+static int
+get_iface_index(int fd, const int8_t *device, char *errbuf) {
+    struct ifreq ifr;
+
+    memset(&ifr, 0, sizeof(ifr));
+    strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
+
+    if (ioctl(fd, SIOCGIFINDEX, &ifr) == -1) {
+        snprintf(errbuf, SENDPACKET_ERRBUF_SIZE, "ioctl: %s", strerror(errno));
+        return (-1);
+    }
+
+    return ifr.ifr_ifindex;
+}              
+
+/*
+ * get's the hardware address via Linux's PF packet
+ * interface
+ */
+struct tcpr_ether_addr *
+sendpacket_get_hwaddr_pf(sendpacket_t *sp)
+{
+    struct ifreq ifr;
+    int fd;
+    
+    assert(sp);
+    
+    if (!sp->open) {
+        sendpacket_seterr(sp, "Unable to get hardware address on un-opened sendpacket handle");
+        return NULL;
+    }
+    
+
+    /* create dummy socket for ioctl */
+    if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+        sendpacket_seterr(sp, "Unable to open dummy socket for get_hwaddr: %s", strerror(errno));
+        return NULL;
+    }
+
+    memset(&ifr, 0, sizeof(ifr));
+    strlcpy(ifr.ifr_name, sp->device, sizeof(ifr.ifr_name));
+    
+    if (ioctl(fd, SIOCGIFHWADDR, (int8_t *)&ifr) < 0) {
+        close(fd);
+        sendpacket_seterr(sp, "Error getting hardware address: %s", strerror(errno));
+        return NULL;
+    }
+    
+    memcpy(&sp->ether, &ifr.ifr_hwaddr.sa_data, ETHER_ADDR_LEN);
+    close(fd);
+    return(&sp->ether);
+}
+#endif
+
+#if defined HAVE_BPF
+static sendpacket_t *
+sendpacket_open_bpf(const char *device, char *errbuf)
+{
+    sendpacket_t *sp;
+    char bpf_dev[10];
+    int dev, mysocket, link_offset, link_type;
+    struct ifreq ifr;
+    struct bpf_version bv;
+    u_int v;
+#if defined(BIOCGHDRCMPLT) && defined(BIOCSHDRCMPLT) && !(__APPLE__)
+    u_int spoof_eth_src = 1;
+#endif
+    
+    assert(device);
+    assert(errbuf);
+    memset(&ifr, '\0', sizeof(struct ifreq));
+    
+    /* open socket */
+    mysocket = -1;
+    for (dev = 0; dev <= 9; dev ++) {
+        memset(bpf_dev, '\0', sizeof(bpf_dev));
+        snprintf(bpf_dev, sizeof(bpf_dev), "/dev/bpf%d", dev);
+        if ((mysocket = open(bpf_dev, O_RDWR, 0)) > 0) {
+            break;
+        }
+    }
+    
+    /* error?? */
+    if (mysocket < 0) {
+        snprintf(errbuf, SENDPACKET_ERRBUF_SIZE, 
+            "Unable to open /dev/bpfX: %s", strerror(errno));
+        errbuf[SENDPACKET_ERRBUF_SIZE -1] = '\0';
+        return NULL;
+    }
+    
+    /* get BPF version */
+    if (ioctl(mysocket, BIOCVERSION, (caddr_t)&bv) < 0) {
+        snprintf(errbuf, SENDPACKET_ERRBUF_SIZE, "Unable to get bpf version: %s", strerror(errno));
+        return NULL;
+    }
+
+    if (bv.bv_major != BPF_MAJOR_VERSION || bv.bv_minor != BPF_MINOR_VERSION) {
+        snprintf(errbuf, SENDPACKET_ERRBUF_SIZE, "Kernel's bpf version is out of date.");
+        return NULL;
+    }
+
+    /* attach to device */
+    strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
+    if (ioctl(mysocket, BIOCSETIF, (caddr_t)&ifr) < 0) {
+       snprintf(errbuf, SENDPACKET_ERRBUF_SIZE, "Unable to bind %s to %s: %s", 
+           bpf_dev, device, strerror(errno));
+       return NULL;
+    }
+    
+    /* get datalink type */
+    if (ioctl(mysocket, BIOCGDLT, (caddr_t)&v) < 0) {
+        snprintf(errbuf, SENDPACKET_ERRBUF_SIZE, "Unable to get datalink type: %s",
+            strerror(errno));
+        return NULL;
+    }
+    
+    /*
+     *  NetBSD and FreeBSD BPF have an ioctl for enabling/disabling
+     *  automatic filling of the link level source address.
+     */
+#if defined(BIOCGHDRCMPLT) && defined(BIOCSHDRCMPLT) && !(__APPLE__)
+    if (ioctl(mysocket, BIOCSHDRCMPLT, &spoof_eth_src) == -1) {
+        snprintf(errbuf, SENDPACKET_ERRBUF_SIZE, 
+            "Unable to enable spoofing src MAC: %s", strerror(errno));
+        return NULL;
+    }
+#endif
+    
+    /* assign link type and offset */
+    switch (v) {
+        case DLT_SLIP:
+            link_offset = 0x10;
+            break;
+        case DLT_RAW:
+            link_offset = 0x0;
+            break;
+        case DLT_PPP:
+            link_offset = 0x04;
+            break;
+        case DLT_EN10MB:
+        default: /* default to Ethernet */
+            link_offset = 0xe;
+            break;
+    }
+#if _BSDI_VERSION - 0 > 199510
+    switch (v) {
+        case DLT_SLIP:
+            v = DLT_SLIP_BSDOS;
+            link_offset = 0x10;
+            break;
+        case DLT_PPP:
+            v = DLT_PPP_BSDOS;
+            link_offset = 0x04;
+            break;
+    }
+#endif
+    
+    link_type = v;
+    
+    /* allocate our sp handle, and return it */
+    sp = (sendpacket_t *)safe_malloc(sizeof(sendpacket_t));
+    strlcpy(sp->device, device, sizeof(sp->device));
+    sp->handle.fd = mysocket;
+    //sp->link_type = link_type;
+    //sp->link_offset = link_offset;
+    
+    return sp; 
+}
+
+struct tcpr_ether_addr *
+sendpacket_get_hwaddr_bpf(sendpacket_t *sp)
+{
+    int mib[6];
+    size_t len;
+    int8_t *buf, *next, *end;
+    struct if_msghdr *ifm;
+    struct sockaddr_dl *sdl;
+
+    assert(sp);
+
+    mib[0] = CTL_NET;
+    mib[1] = AF_ROUTE;
+    mib[2] = 0;
+    mib[3] = AF_LINK;
+    mib[4] = NET_RT_IFLIST;
+    mib[5] = 0;
+    
+    if (sysctl(mib, 6, NULL, &len, NULL, 0) == -1) {
+        sendpacket_seterr(sp, "%s(): sysctl(): %s", __func__, strerror(errno));
+        return NULL;
+    }
+    
+    buf = (int8_t *)safe_malloc(len);
+
+    if (sysctl(mib, 6, buf, &len, NULL, 0) == -1) {
+        sendpacket_seterr(sp, "%s(): sysctl(): %s", __func__, strerror(errno));
+        free(buf);
+        return NULL;
+    }
+    
+    end = buf + len;
+    for (next = buf; next < end; next += ifm->ifm_msglen) {
+        ifm = (struct if_msghdr *)next;
+        if (ifm->ifm_type == RTM_IFINFO) {
+            sdl = (struct sockaddr_dl *)(ifm + 1);
+            if (strncmp(&sdl->sdl_data[0], sp->device, sdl->sdl_len) == 0) {
+                memcpy(&sp->ether, LLADDR(sdl), ETHER_ADDR_LEN);
+                break;
+            }
+        }
+    }
+    free(buf);
+    return(&sp->ether);
+}
+
+#endif

+ 78 - 0
src/common/sendpacket.h

@@ -0,0 +1,78 @@
+/* $Id: sendpacket.h 1561 2006-08-01 19:24:04Z aturner $ */
+
+/*
+ * Copyright (c) 2006 Aaron Turner.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the names of the copyright owners nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "defines.h"
+#ifdef HAVE_PF_PACKET
+#include <netpacket/packet.h>
+#endif
+
+#ifndef _SENDPACKET_H_
+#define _SENDPACKET_H_
+
+union sendpacket_handle {
+    pcap_t *pcap;
+    int fd;
+#ifdef HAVE_LIBNET
+    libnet_t *lnet;
+#endif
+};
+
+#define SENDPACKET_ERRBUF_SIZE 1024
+
+struct sendpacket_s {
+    int open;
+    char device[20];
+    char errbuf[SENDPACKET_ERRBUF_SIZE];
+    COUNTER retry;
+    COUNTER failed;
+    COUNTER sent;
+    COUNTER bytes_sent;
+    COUNTER attempt;
+    union sendpacket_handle handle;
+    struct tcpr_ether_addr ether;
+#ifdef HAVE_PF_PACKET
+    struct sockaddr_ll sa;
+#endif
+};
+
+typedef struct sendpacket_s sendpacket_t;
+
+int sendpacket(sendpacket_t *, const u_char *, size_t);
+int sendpacket_close(sendpacket_t *);
+char *sendpacket_geterr(sendpacket_t *);
+char *sendpacket_getstat(sendpacket_t *);
+sendpacket_t *sendpacket_open(const char *, char *);
+struct tcpr_ether_addr *sendpacket_get_hwaddr(sendpacket_t *);
+
+#endif /* _SENDPACKET_H_ */
+

+ 4 - 1
src/common/services.c

@@ -1,4 +1,4 @@
-/* $Id: services.c 1462 2006-04-13 05:10:27Z aturner $ */
+/* $Id: services.c 1543 2006-07-29 06:20:25Z aturner $ */
 
 /*
  * Copyright (c) 2004 Aaron Turner.
@@ -36,6 +36,9 @@
 
 #include <sys/types.h>
 #include <regex.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
 
 /*
  * parses /etc/services so we know which ports are service ports

+ 1 - 1
src/common/svn_version.c

@@ -1,4 +1,4 @@
-const char SVN_Version[] = "1517M";
+const char SVN_Version[] = "1583:1584";
 const char *svn_version(void) {
 	return SVN_Version;
 }

+ 0 - 0
src/common/tcpdump.c


Some files were not shown because too many files changed in this diff