Browse Source

Import upstream version 3.1.1

Aaron Turner 17 years ago
parent
commit
20feef3563
100 changed files with 4256 additions and 1190 deletions
  1. 234 0
      INSTALL
  2. 2 2
      Makefile.in
  3. 388 180
      aclocal.m4
  4. 929 515
      configure
  5. 103 26
      configure.in
  6. 21 1
      docs/CHANGELOG
  7. 1 1
      docs/Makefile.in
  8. 1 1
      lib/Makefile.in
  9. 1 1
      lib/tree.h
  10. 4 2
      libopts/Makefile.am
  11. 5 3
      libopts/Makefile.in
  12. 1 1
      libopts/README
  13. 29 10
      libopts/autoopts.c
  14. 43 33
      libopts/autoopts.h
  15. 60 47
      libopts/autoopts/options.h
  16. 1 1
      libopts/autoopts/usage-txt.h
  17. 319 0
      libopts/compat.h
  18. 16 14
      libopts/configfile.c
  19. 74 55
      libopts/environment.c
  20. 20 11
      libopts/genshell.c
  21. 5 5
      libopts/genshell.h
  22. 22 2
      libopts/m4/libopts.m4
  23. 339 0
      libopts/pathfind.c
  24. 2 2
      libopts/pgusage.c
  25. 1 1
      libopts/proto.h
  26. 2 2
      libopts/save.c
  27. 60 0
      libopts/snprintf.c
  28. 2 2
      libopts/sort.c
  29. 60 0
      libopts/strchr.c
  30. 19 0
      libopts/strdup.c
  31. 2 2
      libopts/streqvcmp.c
  32. 20 11
      libopts/usage.c
  33. 12 10
      libopts/version.c
  34. 130 0
      libopts/windows-config.h
  35. 1 1
      scripts/Makefile.in
  36. BIN
      src/._defines.h.in
  37. BIN
      src/._send_packets.c
  38. BIN
      src/._tcpprep.c
  39. BIN
      src/._tcpreplay.c
  40. BIN
      src/._tcpreplay.h
  41. 1 1
      src/Makefile.in
  42. BIN
      src/common/._cidr.c
  43. BIN
      src/common/._cidr.h
  44. BIN
      src/common/._timer.h
  45. BIN
      src/common/._xX.c
  46. 1 1
      src/common/Makefile.in
  47. 2 5
      src/common/cache.c
  48. 1 1
      src/common/cidr.c
  49. 1 1
      src/common/cidr.h
  50. 1 1
      src/common/get.c
  51. 1 1
      src/common/interface.c
  52. 7 7
      src/common/sendpacket.c
  53. 1 1
      src/common/svn_version.c
  54. 1 1
      src/common/timer.h
  55. 2 2
      src/common/xX.c
  56. 3 0
      src/config.h.in
  57. BIN
      src/flow/._flownode.c
  58. 1 1
      src/flow/Makefile.in
  59. 1 1
      src/flow/flownode.c
  60. 3 3
      src/flowreplay.1
  61. 11 11
      src/flowreplay_opts.c
  62. 1 1
      src/flowreplay_opts.def
  63. 6 6
      src/flowreplay_opts.h
  64. 8 8
      src/send_packets.c
  65. 23 4
      src/tcpbridge.1
  66. 2 2
      src/tcpbridge.c
  67. 130 74
      src/tcpbridge_opts.c
  68. 1 1
      src/tcpbridge_opts.def
  69. 58 54
      src/tcpbridge_opts.h
  70. BIN
      src/tcpedit/._edit_packet.c
  71. 108 15
      src/tcpedit/Makefile.in
  72. 18 2
      src/tcpedit/edit_packet.c
  73. 21 1
      src/tcpedit/parse_args.c
  74. 2 0
      src/tcpedit/plugins/Makefile.am
  75. BIN
      src/tcpedit/plugins/dlt_en10mb/._en10mb.c
  76. BIN
      src/tcpedit/plugins/dlt_en10mb/._en10mb.h
  77. 1 1
      src/tcpedit/plugins/dlt_en10mb/Makefile.am
  78. 34 9
      src/tcpedit/plugins/dlt_en10mb/en10mb.c
  79. 2 2
      src/tcpedit/plugins/dlt_en10mb/en10mb.h
  80. 1 1
      src/tcpedit/plugins/dlt_hdlc/Makefile.am
  81. 32 4
      src/tcpedit/plugins/dlt_hdlc/hdlc.c
  82. 3 2
      src/tcpedit/plugins/dlt_hdlc/hdlc.h
  83. 26 0
      src/tcpedit/plugins/dlt_ieee80211/Makefile.am
  84. 382 0
      src/tcpedit/plugins/dlt_ieee80211/ieee80211.c
  85. 115 0
      src/tcpedit/plugins/dlt_ieee80211/ieee80211.h
  86. 188 0
      src/tcpedit/plugins/dlt_ieee80211/ieee80211_hdr.c
  87. 46 0
      src/tcpedit/plugins/dlt_ieee80211/ieee80211_hdr.h
  88. 1 0
      src/tcpedit/plugins/dlt_ieee80211/ieee80211_opts.def
  89. 1 1
      src/tcpedit/plugins/dlt_linuxsll/Makefile.am
  90. 32 4
      src/tcpedit/plugins/dlt_linuxsll/linuxsll.c
  91. 3 2
      src/tcpedit/plugins/dlt_linuxsll/linuxsll.h
  92. 1 1
      src/tcpedit/plugins/dlt_loop/Makefile.am
  93. 5 4
      src/tcpedit/plugins/dlt_loop/loop.c
  94. 1 1
      src/tcpedit/plugins/dlt_loop/loop.h
  95. 1 1
      src/tcpedit/plugins/dlt_null/Makefile.am
  96. 17 3
      src/tcpedit/plugins/dlt_null/null.c
  97. 3 2
      src/tcpedit/plugins/dlt_null/null.h
  98. 1 2
      src/tcpedit/plugins/dlt_opts.def
  99. 15 2
      src/tcpedit/plugins/dlt_plugins-int.h
  100. 0 0
      src/tcpedit/plugins/dlt_plugins.c

+ 234 - 0
INSTALL

@@ -0,0 +1,234 @@
+Installation Instructions
+*************************
+
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006 Free Software Foundation, Inc.
+
+This file is free documentation; the Free Software Foundation gives
+unlimited permission to copy, distribute and modify it.
+
+Basic Installation
+==================
+
+Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package.  The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package.
+
+   The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation.  It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions.  Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+   It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring.  Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.
+
+   If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release.  If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+   The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'.  You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
+
+The simplest way to compile this package is:
+
+  1. `cd' to the directory containing the package's source code and type
+     `./configure' to configure the package for your system.
+
+     Running `configure' might take a while.  While running, it prints
+     some messages telling which features it is checking for.
+
+  2. Type `make' to compile the package.
+
+  3. Optionally, type `make check' to run any self-tests that come with
+     the package.
+
+  4. Type `make install' to install the programs and any data files and
+     documentation.
+
+  5. You can remove the program binaries and object files from the
+     source code directory by typing `make clean'.  To also remove the
+     files that `configure' created (so you can compile the package for
+     a different kind of computer), type `make distclean'.  There is
+     also a `make maintainer-clean' target, but that is intended mainly
+     for the package's developers.  If you use it, you may have to get
+     all sorts of other programs in order to regenerate files that came
+     with the distribution.
+
+Compilers and Options
+=====================
+
+Some systems require unusual options for compilation or linking that the
+`configure' script does not know about.  Run `./configure --help' for
+details on some of the pertinent environment variables.
+
+   You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment.  Here
+is an example:
+
+     ./configure CC=c99 CFLAGS=-g LIBS=-lposix
+
+   *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory.  To do this, you can use GNU `make'.  `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script.  `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+   With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory.  After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
+
+Installation Names
+==================
+
+By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc.  You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX'.
+
+   You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files.  If you
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
+
+   In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files.  Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+   If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System).  The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+   For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+There may be some features `configure' cannot figure out automatically,
+but needs to determine by the type of machine the package will run on.
+Usually, assuming the package is built to be run on the _same_
+architectures, `configure' can figure that out, but if it prints a
+message saying it cannot guess the machine type, give it the
+`--build=TYPE' option.  TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+     CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+     OS KERNEL-OS
+
+   See the file `config.sub' for the possible values of each field.  If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+   If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
+
+   If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+If you want to set default values for `configure' scripts to share, you
+can create a site shell script called `config.site' that gives default
+values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists.  Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+Variables not defined in a site shell script can be set in the
+environment passed to `configure'.  However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost.  In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'.  For example:
+
+     ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug.  Until the bug is fixed you can use this workaround:
+
+     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+`configure' Invocation
+======================
+
+`configure' recognizes the following options to control how it operates.
+
+`--help'
+`-h'
+     Print a summary of the options to `configure', and exit.
+
+`--version'
+`-V'
+     Print the version of Autoconf used to generate the `configure'
+     script, and exit.
+
+`--cache-file=FILE'
+     Enable the cache: use and save the results of the tests in FILE,
+     traditionally `config.cache'.  FILE defaults to `/dev/null' to
+     disable caching.
+
+`--config-cache'
+`-C'
+     Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+     Do not print messages saying which checks are being made.  To
+     suppress all normal output, redirect it to `/dev/null' (any error
+     messages will still be shown).
+
+`--srcdir=DIR'
+     Look for the package's source code in directory DIR.  Usually
+     `configure' can determine that directory automatically.
+
+`configure' also accepts some other, not widely useful, options.  Run
+`configure --help' for more details.
+

+ 2 - 2
Makefile.in

@@ -35,7 +35,7 @@ target_triplet = @target@
 subdir = .
 DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
 	$(srcdir)/Makefile.in $(srcdir)/doxygen.cfg.in \
-	$(srcdir)/tcpreplay.spec.in $(top_srcdir)/configure \
+	$(srcdir)/tcpreplay.spec.in $(top_srcdir)/configure INSTALL \
 	config/compile config/config.guess config/config.sub \
 	config/depcomp config/install-sh config/ltmain.sh \
 	config/missing config/mkinstalldirs
@@ -199,7 +199,7 @@ target_alias = @target_alias@
 target_cpu = @target_cpu@
 target_os = @target_os@
 target_vendor = @target_vendor@
-td = @td@
+tcpdump_path = @tcpdump_path@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 

File diff suppressed because it is too large
+ 388 - 180
aclocal.m4


File diff suppressed because it is too large
+ 929 - 515
configure


+ 103 - 26
configure.in

@@ -1,5 +1,5 @@
 
-dnl $Id: configure.in 1857 2007-05-02 05:07:52Z aturner $
+dnl $Id: configure.in 1886 2007-07-19 16:09:41Z aturner $
 
 AC_INIT(tcpreplay)
 AC_CONFIG_SRCDIR(src/tcpreplay.c)
@@ -10,7 +10,7 @@ AM_WITH_DMALLOC
 
 dnl Set version info here!
 MAJOR_VERSION=3
-MINOR_VERSION=0
+MINOR_VERSION=1
 MICRO_VERSION=1
 TCPREPLAY_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
 
@@ -151,6 +151,7 @@ dnl Checks for libraries.
 AC_CHECK_LIB(socket, socket)
 AC_CHECK_LIB(nsl, gethostbyname)
 AC_CHECK_LIB(rt, nanosleep)
+AC_CHECK_LIB(resolv, resolv)
 
 dnl Checks for library functions.
 AC_FUNC_MALLOC
@@ -211,17 +212,31 @@ AC_ARG_ENABLE(gprof,
       fi])
 
 dnl Use 64bits for packet counters
+use64bit_counters=no
 AC_ARG_ENABLE(64bits,
     AC_HELP_STRING([--enable-64bits], [Use 64bit packet counters]),
     [ if test x$enableval = xyes; then
          AC_DEFINE([ENABLE_64BITS], [1], [Use 64bit packet counters])
          AC_MSG_NOTICE([Using u_int64_t for packet counters])
+         use64bit_counters=yes
       else
          AC_MSG_NOTICE([Using u_int32_t for packet counters])
       fi
     ])
 
 
+# If we're running gcc add '-D_U_="__attribute__((unused))"' to CFLAGS as well,
+# so we can use _U_ to flag unused function arguments and not get warnings
+# about them. Otherwise, add '-D_U_=""', so that _U_ used to flag an unused
+# function argument will compile with non-GCC compilers.
+#
+if test "x$GCC" = "xyes" ; then
+    CFLAGS="-D_U_=\"__attribute__((unused))\" $CFLAGS"
+else
+    CFLAGS="-D_U_=\"\" $CFLAGS"
+fi
+
+
 AC_ARG_ENABLE(force-bpf,
 	AC_HELP_STRING([--enable-force-bpf], [Force using BPF for sending packets]),
 	[ AC_DEFINE([FORCE_INJECT_BPF], [1], [Force using BPF for sending packet])])
@@ -333,17 +348,17 @@ if test x$use_libnet = xyes ; then
         	LNETINC="${testdir}/include/libnet.h"
 	        LNETINCDIR="${testdir}/include"
 	        if test $dynamic_link = yes; then
-				if test -f "${testdir}/lib64/libnet.a" ; then
+				if test -f "${testdir}/lib64/libnet${shrext_cmds}" ; then
 		            LNETLIB="-L${testdir}/lib64 -lnet"
-				elif test -f "${testdir}/lib/libnet.a" ; then
+				elif test -f "${testdir}/lib/libnet${shrext_cmds}" ; then
 					LNETLIB="-L${testdir}/lib -lnet"
 				else
 					AC_ERROR([Unable to find libnet in ${testdir}])
 				fi
-	        elif test -f "${testdir}/lib64/libnet.a" ; then
-	            LNETLIB="${testdir}/lib64/libnet.a"
-	        elif test -f "${testdir}/lib/libnet.a" ; then
-	            LNETLIB="${testdir}/lib/libnet.a"
+	        elif test -f "${testdir}/lib64/libnet.${libext}" ; then
+	            LNETLIB="${testdir}/lib64/libnet.${libext}"
+	        elif test -f "${testdir}/lib/libnet.${libext}" ; then
+	            LNETLIB="${testdir}/lib/libnet.${libext}"
 		 	else
 				AC_ERROR([Unable to find matching library for header file in ${testdir}])
 			fi
@@ -458,19 +473,19 @@ AC_ARG_WITH(libpcap,
         	LPCAPINC="${testdir}/include/pcap.h"
 	        LPCAPINCDIR="${testdir}/include"
 	        if test $dynamic_link = yes; then
-				if test -f "${testdir}/lib64/libpcap.a" ; then
+				if test -f "${testdir}/lib64/libpcap${shrext_cmds}" ; then
 		            LPCAPLIB="-L${testdir}/lib64 -lpcap"
-				elif test -f "${testdir}/lib/libpcap.a" ; then
+				elif test -f "${testdir}/lib/libpcap${shrext_cmds}" ; then
 					LPCAPLIB="-L${testdir}/lib -lpcap"
 				else
 					AC_ERROR([Unable to find libpcap in ${testdir}])
 				fi
-	        elif test -f "${testdir}/lib64/libpcap.a" ; then
-	            LPCAPLIB="${testdir}/lib64/libpcap.a"
-	        elif test -f "${testdir}/lib/libpcap.a" ; then
-	            LPCAPLIB="${testdir}/lib/libpcap.a"
-	        elif test -f "${testdir}/lib/libwpcap.a" ; then
-	            LPCAPLIB="${testdir}/lib/libwpcap.a"
+	        elif test -f "${testdir}/lib64/libpcap.${libext}" ; then
+	            LPCAPLIB="${testdir}/lib64/libpcap.${libext}"
+	        elif test -f "${testdir}/lib/libpcap.${libext}" ; then
+	            LPCAPLIB="${testdir}/lib/libpcap.${libext}"
+	        elif test -f "${testdir}/lib/libwpcap.${libext}" ; then
+	            LPCAPLIB="${testdir}/lib/libwpcap.${libext}"
 				AC_DEFINE([HAVE_WINPCAP], [1], [Do we have WinPcap?])
 		 	else
 				AC_ERROR([Unable to find matching library for header file in ${testdir}])
@@ -501,6 +516,29 @@ 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 libpcap version)
 
+dnl 0.9.6 (which is still thinks it is 0.9.5 due to a bug) introduces an important
+dnl fix for OSX.  See: http://tcpreplay.synfin.net/trac/ticket/167
+libpcap_version_096=no
+AC_RUN_IFELSE(AC_LANG_PROGRAM([[
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "$LPCAPINC"
+#define PCAP_TEST "0.9.6"
+]], [[
+/* 
+ * simple proggy to test the version of libpcap
+ * returns zero if version >= 0.9.6
+ * or one otherwise
+ */
+    if (strncmp(pcap_lib_version(), PCAP_TEST, 5) >= 0)
+            exit(0);
+
+    exit(1);
+]]), [
+    libpcap_version_096=yes
+])
+
 AC_RUN_IFELSE(AC_LANG_PROGRAM([[
 #include <string.h>
 #include <stdlib.h>
@@ -560,6 +598,15 @@ else
     Please upgrade to version 0.7.2 or better])
 fi
 
+libpcap_version=unknown
+if test $libpcap_version_096 = yes ; then
+    libpcap_version=">= 0.9.6"
+elif test $libpcap_ver8 = yes ; then
+    libpcap_version=">= 0.8.0"
+elif test $libcap_ver7 = yes ; then
+    libpcap_version=">= 0.7.0"
+fi
+
 dnl Check to see if we've got pcap_datalink_val_to_name()
 AC_MSG_CHECKING(for pcap_datalink_val_to_description)
 AC_LINK_IFELSE(AC_LANG_PROGRAM([[
@@ -952,29 +999,29 @@ dnl ##################################################
 dnl # Check for tcpdump.
 dnl ##################################################
 
-td=no
+tcpdump_path=no
 AC_ARG_WITH(tcpdump,
     AC_HELP_STRING([--with-tcpdump=FILE], [Path to tcpdump binary]),
     [ if test -x $withval ; then
           td=$withval
-          AC_MSG_RESULT([Using tcpdump in $td])
+          AC_MSG_RESULT([Using tcpdump in $tcpdump_path])
       else
           AC_MSG_RESULT([Error: $withval does not exist or is not executable])
       fi ],
-    [ AC_PATH_PROG(td, tcpdump, "no", [$PATH:/usr/sbin:/sbin:/usr/local/sbin]) ])
+    [ AC_PATH_PROG(tcpdump_path, tcpdump, "no", [$PATH:/usr/sbin:/sbin:/usr/local/sbin]) ])
            
 
-if test "$td" = "no"; then
+if test "$tcpdump_path" = "no"; then
     AC_MSG_WARN([Unable to find tcpdump.  Please specify --with-tcpdump.
                  Disabling --verbose])
 else
     AC_DEFINE([HAVE_TCPDUMP], [1], [Do we have tcpdump?])
-    AC_DEFINE_UNQUOTED(TCPDUMP_BINARY, "$td", [The tcpdump binary initially used])
+    AC_DEFINE_UNQUOTED(TCPDUMP_BINARY, "$tcpdump_path", [The tcpdump binary initially used])
 fi
 
 
-AM_CONDITIONAL([ENABLE_TCPDUMP], test "$td" != "no" -a x$have_pcap_dump_fopen = xyes)
-if test x$td != xno -a x$have_pcap_dump_fopen = xyes ; then
+AM_CONDITIONAL([ENABLE_TCPDUMP], test "$tcpdump_path" != "no" -a x$have_pcap_dump_fopen = xyes)
+if test x$tcpdump_path != xno -a x$have_pcap_dump_fopen = xyes ; then
 	AC_DEFINE([ENABLE_VERBOSE], [1], [Do we have tcpdump and pcap_dump_fopen()?])
 else
 	AC_MSG_WARN([Your version of libpcap is too old for --verbose support])
@@ -1023,7 +1070,9 @@ case $host in
 	*-apple-darwin*)
 	nic1=en0
 	nic2=en0
-	disable_pcap_findalldevs=yes
+	if test x$libpcap_version_096 = xno ; then
+    	disable_pcap_findalldevs=yes
+    fi
 	AC_MSG_RESULT(Apple OS X)
 	;;
 
@@ -1067,6 +1116,7 @@ fi
 
 LIBOPTS_CHECK
 
+
 AC_OUTPUT([Makefile
            doxygen.cfg
            lib/Makefile
@@ -1081,12 +1131,39 @@ AC_OUTPUT([Makefile
            scripts/Makefile
            tcpreplay.spec])
 
+# Configuration results
+AC_MSG_RESULT(
+##########################################################################
+             TCPREPLAY Suite Configuration Results (${TCPREPLAY_VERSION})
+##########################################################################
+libpcap:                    ${foundpcap} (${libpcap_version})
+libnet:                     ${foundnet}
+autogen:                    ${AUTOGEN}
+64bit counter support:      ${use64bit_counters}
+tcpdump binary path:        ${tcpdump_path}
+tcpreplay edit support:     ${tcpreplay_edit}
+tcpbridge support:          ${enable_tcpbridge}
+
+Supported Packet Injection Methods (*):
+Linux PF_PACKET:            ${have_pf}
+BSD BPF:                    ${have_bpf}
+libnet:                     ${have_libnet}
+pcap_inject:                ${have_pcap_inject}
+pcap_sendpacket:            ${have_pcap_sendpacket}
+
+* In order of preference; see configure --help to override
+)
+
+
 case $host in
 	*-apple-darwin*)
-	AC_MSG_WARN([OS X <= 10.4.9 has a serious problem.  Please see: http://tcpreplay.synfin.net/trac/ticket/142])
+	AC_MSG_WARN([Apple OS X has a serious problem!
+	Please see: http://tcpreplay.synfin.net/trac/ticket/142 for more details])
 	;;
 	
 	*-*-cygwin)
-	AC_MSG_WARN([Windows/Cygwin support is still somewhat experimental.  Please report any bugs!])
+	AC_MSG_WARN([Windows/Cygwin support is still somewhat experimental.  Please report any bugs!
+	http://tcpreplay.synfin.net/trac/newticket])
 	;;
 esac
+

+ 21 - 1
docs/CHANGELOG

@@ -1,4 +1,24 @@
-$Id: CHANGELOG 1860 2007-05-02 05:18:08Z aturner $
+$Id: CHANGELOG 1886 2007-07-19 16:09:41Z aturner $
+
+07/19/2007: Version 3.1.1
+    - Upgrade libopts tearoff to 29:0:4 so that everyone else in the world can
+      compile tcpreplay (#189)
+
+07/18/2007: Version 3.1.0
+    - Add tcprewrite --srcmap & --dstmap for rewriting only source or destination IP's (#185)
+    - ./configure now reports configuration at end (#155)
+    - Fix svn:keywords (#160)
+    - Optimize performance of dlt_en10mb plugin (#161)
+    - Performance improvements on strictly aligned systems (#162)
+    - Improve tcpprep error messages and handling (#163)
+    - Add support for warnings in libtcpedit (#165)
+    - Only use __attribute__((unused)) w/ GCC (#168)
+    - Fix compile issues under Solaris (#178)
+    - Gracefully handle systems w/o static libraries (#179)
+    - Fix segfault when using BPF filters (#182)
+    - Add additional DLT Plugins:
+        - 802.11 (#103)
+        - 802.11 w/ Radiotap (#177)
 
 05/01/2007: Version 3.0.1
 	- Stop tcpreplay causing OS X WiFi from disassociating (#167)

+ 1 - 1
docs/Makefile.in

@@ -171,7 +171,7 @@ target_alias = @target_alias@
 target_cpu = @target_cpu@
 target_os = @target_os@
 target_vendor = @target_vendor@
-td = @td@
+tcpdump_path = @tcpdump_path@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 MAKEFLAGS = -s

+ 1 - 1
lib/Makefile.in

@@ -195,7 +195,7 @@ target_alias = @target_alias@
 target_cpu = @target_cpu@
 target_os = @target_os@
 target_vendor = @target_vendor@
-td = @td@
+tcpdump_path = @tcpdump_path@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 noinst_LIBRARIES = libstrl.a

+ 1 - 1
lib/tree.h

@@ -622,7 +622,7 @@ name##_RB_FIND(struct name *head, struct type *elm)			\
 }									\
 									\
 struct type *								\
-name##_RB_NEXT(struct name *head, struct type *elm)			\
+name##_RB_NEXT(_U_ struct name *head, struct type *elm)			\
 {									\
 	if (RB_RIGHT(elm, field)) {					\
 		elm = RB_RIGHT(elm, field);				\

+ 4 - 2
libopts/Makefile.am

@@ -7,7 +7,7 @@ noinst_LTLIBRARIES      = libopts.la
 endif
 libopts_la_SOURCES      = libopts.c
 libopts_la_CPPFLAGS     = -I$(top_srcdir)
-libopts_la_LDFLAGS      = -version-info  28:0:3
+libopts_la_LDFLAGS      = -version-info  29:0:4
 EXTRA_DIST              = \
     COPYING.lgpl            COPYING.mbsd            MakeDefs.inc  \
     README                  autoopts/options.h      autoopts/usage-txt.h  \
@@ -21,4 +21,6 @@ EXTRA_DIST              = \
     pgusage.c               proto.h                 putshell.c  \
     restore.c               save.c                  sort.c  \
     stack.c                 streqvcmp.c             text_mmap.c  \
-    tokenize.c              usage.c                 version.c
+    tokenize.c              usage.c                 version.c \
+    snprintf.c              strchr.c                pathfind.c \
+    windows-config.h        strdup.c                compat.h

+ 5 - 3
libopts/Makefile.in

@@ -203,7 +203,7 @@ target_alias = @target_alias@
 target_cpu = @target_cpu@
 target_os = @target_os@
 target_vendor = @target_vendor@
-td = @td@
+tcpdump_path = @tcpdump_path@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 MAINTAINERCLEANFILES = Makefile.in
@@ -211,7 +211,7 @@ MAINTAINERCLEANFILES = Makefile.in
 @INSTALL_LIBOPTS_FALSE@noinst_LTLIBRARIES = libopts.la
 libopts_la_SOURCES = libopts.c
 libopts_la_CPPFLAGS = -I$(top_srcdir)
-libopts_la_LDFLAGS = -version-info  28:0:3
+libopts_la_LDFLAGS = -version-info  29:0:4
 EXTRA_DIST = \
     COPYING.lgpl            COPYING.mbsd            MakeDefs.inc  \
     README                  autoopts/options.h      autoopts/usage-txt.h  \
@@ -225,7 +225,9 @@ EXTRA_DIST = \
     pgusage.c               proto.h                 putshell.c  \
     restore.c               save.c                  sort.c  \
     stack.c                 streqvcmp.c             text_mmap.c  \
-    tokenize.c              usage.c                 version.c
+    tokenize.c              usage.c                 version.c \
+    snprintf.c              strchr.c                pathfind.c \
+    windows-config.h        strdup.c                compat.h
 
 all: all-am
 

+ 1 - 1
libopts/README

@@ -85,7 +85,7 @@ will need to hand craft the rules for building the library.
 
 LICENSING:
 
-This material is copyright 1993-2006 by Bruce Korb.
+This material is copyright 1993-2007 by Bruce Korb.
 You are licensed to use this under the terms of either
 the GNU Lesser General Public License (see: COPYING.lgpl), or,
 at your option, the modified Berkeley Software Distribution

+ 29 - 10
libopts/autoopts.c

@@ -1,7 +1,7 @@
 
 /*
- *  $Id: autoopts.c,v 4.23 2007/02/13 19:43:46 bkorb Exp $
- *  Time-stamp:      "2007-02-13 11:26:59 bkorb"
+ *  $Id: autoopts.c,v 4.25 2007/04/15 19:01:18 bkorb Exp $
+ *  Time-stamp:      "2007-04-15 11:10:40 bkorb"
  *
  *  This file contains all of the routines that must be linked into
  *  an executable to use the generated option processing.  The optional
@@ -54,9 +54,6 @@
 
 static char const zNil[] = "";
 
-#define SKIP_RC_FILES(po) \
-    DISABLED_OPT(&((po)->pOptDesc[ (po)->specOptIdx.save_opts+1]))
-
 /* = = = START-STATIC-FORWARD = = = */
 /* static forward declarations maintained by :mkfwd */
 static tSuccess
@@ -697,7 +694,7 @@ nextOption( tOptions* pOpts, tOptState* pOptState )
         case TOPT_DEFAULT:
             fputs( "AutoOpts lib error: defaulted to option with optional arg\n",
                    stderr );
-            exit( EXIT_FAILURE );
+            exit( EX_SOFTWARE );
         }
 
         /*
@@ -830,10 +827,23 @@ doRegularOpts( tOptions* pOpts )
 static tSuccess
 doPresets( tOptions* pOpts )
 {
+    tOptDesc * pOD = NULL;
+
     if (! SUCCESSFUL( doImmediateOpts( pOpts )))
         return FAILURE;
 
     /*
+     *  IF this option set has a --save-opts option, then it also
+     *  has a --load-opts option.  See if a command line option has disabled
+     *  option presetting.
+     */
+    if (pOpts->specOptIdx.save_opts != 0) {
+        pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts + 1;
+        if (DISABLED_OPT(pOD))
+            return SUCCESS;
+    }
+
+    /*
      *  Until we return from this procedure, disable non-presettable opts
      */
     pOpts->fOptSet |= OPTPROC_PRESETTING;
@@ -841,13 +851,22 @@ doPresets( tOptions* pOpts )
      *  IF there are no config files,
      *  THEN do any environment presets and leave.
      */
-    if (  (pOpts->papzHomeList == NULL)
-       || SKIP_RC_FILES(pOpts) )  {
+    if (pOpts->papzHomeList == NULL) {
         doEnvPresets( pOpts, ENV_ALL );
     }
     else {
         doEnvPresets( pOpts, ENV_IMM );
-        internalFileLoad( pOpts );
+
+        /*
+         *  Check to see if environment variables have disabled presetting.
+         */
+        if ((pOD != NULL) && ! DISABLED_OPT(pOD))
+            internalFileLoad( pOpts );
+
+        /*
+         *  ${PROGRAM_LOAD_OPTS} value of "no" cannot disable other environment
+         *  variable options.  Only the loading of .rc files.
+         */
         doEnvPresets( pOpts, ENV_NON_IMM );
     }
     pOpts->fOptSet &= ~OPTPROC_PRESETTING;
@@ -1031,7 +1050,7 @@ optionProcess(
     char**     argVect )
 {
     if (! SUCCESSFUL( validateOptionsStruct( pOpts, argVect[0] )))
-        exit( EXIT_FAILURE );
+        exit( EX_SOFTWARE );
 
     /*
      *  Establish the real program name, the program full path,

+ 43 - 33
libopts/autoopts.h

@@ -1,8 +1,8 @@
 
 /*
- *  Time-stamp:      "2007-01-17 16:37:34 bkorb"
+ *  Time-stamp:      "2007-04-15 09:59:39 bkorb"
  *
- *  autoopts.h  $Id: autoopts.h,v 4.22 2007/02/04 17:44:12 bkorb Exp $
+ *  autoopts.h  $Id: autoopts.h,v 4.23 2007/04/15 19:01:18 bkorb Exp $
  *  Time-stamp:      "2005-02-14 05:59:50 bkorb"
  *
  *  This file defines all the global structures and special values
@@ -57,19 +57,19 @@
 
 #include "compat/compat.h"
 
-#define AO_NAME_LIMIT    127
-#define AO_NAME_SIZE     ((size_t)(AO_NAME_LIMIT + 1))
+#define AO_NAME_LIMIT           127
+#define AO_NAME_SIZE            ((size_t)(AO_NAME_LIMIT + 1))
 
 #ifndef AG_PATH_MAX
 #  ifdef PATH_MAX
-#    define AG_PATH_MAX   ((size_t)PATH_MAX)
+#    define AG_PATH_MAX         ((size_t)PATH_MAX)
 #  else
-#    define AG_PATH_MAX   ((size_t)4096)
+#    define AG_PATH_MAX         ((size_t)4096)
 #  endif
 #else
 #  if defined(PATH_MAX) && (PATH_MAX > MAXPATHLEN)
 #     undef  AG_PATH_MAX
-#     define AG_PATH_MAX  ((size_t)PATH_MAX)
+#     define AG_PATH_MAX        ((size_t)PATH_MAX)
 #  endif
 #endif
 
@@ -77,15 +77,25 @@
 #define EXPORT
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
-# define DIRCH '\\'
+# define DIRCH                  '\\'
 #else
-# define DIRCH '/'
+# define DIRCH                  '/'
+#endif
+
+#ifndef EX_NOINPUT
+#  define EX_NOINPUT            66
+#endif
+#ifndef EX_SOFTWARE
+#  define EX_SOFTWARE           70
+#endif
+#ifndef EX_CONFIG
+#  define EX_CONFIG             78
 #endif
 
 /*
  *  Convert the number to a list usable in a printf call
  */
-#define NUM_TO_VER(n)       ((n) >> 12), ((n) >> 7) & 0x001F, (n) & 0x007F
+#define NUM_TO_VER(n)           ((n) >> 12), ((n) >> 7) & 0x001F, (n) & 0x007F
 
 #define NAMED_OPTS(po) \
         (((po)->fOptSet & (OPTPROC_SHORTOPT | OPTPROC_LONGOPT)) == 0)
@@ -93,14 +103,14 @@
 #define SKIP_OPT(p)  (((p)->fOptState & (OPTST_DOCUMENT|OPTST_OMITTED)) != 0)
 
 typedef int tDirection;
-#define DIRECTION_PRESET  -1
-#define DIRECTION_PROCESS  1
-#define DIRECTION_CALLED   0
+#define DIRECTION_PRESET        -1
+#define DIRECTION_PROCESS       1
+#define DIRECTION_CALLED        0
 
-#define PROCESSING(d)     ((d)>0)
-#define PRESETTING(d)     ((d)<0)
+#define PROCESSING(d)           ((d)>0)
+#define PRESETTING(d)           ((d)<0)
 
-#define ISNAMECHAR( c )    (isalnum(c) || ((c) == '_') || ((c) == '-'))
+#define ISNAMECHAR( c )         (isalnum(c) || ((c) == '_') || ((c) == '-'))
 
 /*
  *  Procedure success codes
@@ -119,16 +129,16 @@ typedef int tDirection;
 #undef  FAILED
 #undef  HADGLITCH
 
-#define SUCCESS  ((tSuccess) 0)
-#define FAILURE  ((tSuccess)-1)
-#define PROBLEM  ((tSuccess) 1)
+#define SUCCESS                 ((tSuccess) 0)
+#define FAILURE                 ((tSuccess)-1)
+#define PROBLEM                 ((tSuccess) 1)
 
 typedef int tSuccess;
 
-#define SUCCEEDED( p )     ((p) == SUCCESS)
-#define SUCCESSFUL( p )    SUCCEEDED( p )
-#define FAILED( p )        ((p) <  SUCCESS)
-#define HADGLITCH( p )     ((p) >  SUCCESS)
+#define SUCCEEDED( p )          ((p) == SUCCESS)
+#define SUCCESSFUL( p )         SUCCEEDED( p )
+#define FAILED( p )             ((p) <  SUCCESS)
+#define HADGLITCH( p )          ((p) >  SUCCESS)
 
 /*
  *  When loading a line (or block) of text as an option, the value can
@@ -224,10 +234,10 @@ typedef struct {
     tCC*    pzOptFmt;
 } arg_types_t;
 
-#define AGALOC( c, w )        ao_malloc((size_t)c)
-#define AGREALOC( p, c, w )   ao_realloc((void*)p, (size_t)c)
-#define AGFREE( p )           ao_free((void*)p)
-#define AGDUPSTR( p, s, w )   (p = ao_strdup(s))
+#define AGALOC( c, w )          ao_malloc((size_t)c)
+#define AGREALOC( p, c, w )     ao_realloc((void*)p, (size_t)c)
+#define AGFREE( p )             ao_free((void*)p)
+#define AGDUPSTR( p, s, w )     (p = ao_strdup(s))
 
 static void *
 ao_malloc( size_t sz );
@@ -324,26 +334,26 @@ ao_strdup( char const *str );
 #  include <sys/mman.h>
 #else
 #  ifndef  PROT_READ
-#   define PROT_READ    0x01
+#   define PROT_READ            0x01
 #  endif
 #  ifndef  PROT_WRITE
-#   define PROT_WRITE   0x02
+#   define PROT_WRITE           0x02
 #  endif
 #  ifndef  MAP_SHARED
-#   define MAP_SHARED   0x01
+#   define MAP_SHARED           0x01
 #  endif
 #  ifndef  MAP_PRIVATE
-#   define MAP_PRIVATE  0x02
+#   define MAP_PRIVATE          0x02
 #  endif
 #endif
 
 #ifndef MAP_FAILED
-#  define  MAP_FAILED   ((void*)-1)
+#  define  MAP_FAILED           ((void*)-1)
 #endif
 
 #ifndef  _SC_PAGESIZE
 # ifdef  _SC_PAGE_SIZE
-#  define _SC_PAGESIZE _SC_PAGE_SIZE
+#  define _SC_PAGESIZE          _SC_PAGE_SIZE
 # endif
 #endif
 

+ 60 - 47
libopts/autoopts/options.h

@@ -2,7 +2,7 @@
  *  
  *  DO NOT EDIT THIS FILE   (options.h)
  *  
- *  It has been AutoGen-ed  Saturday February 17, 2007 at 12:49:35 PM PST
+ *  It has been AutoGen-ed  Saturday May  5, 2007 at 12:02:34 PM PDT
  *  From the definitions    funcs.def
  *  and the template file   options_h
  *
@@ -43,6 +43,14 @@
 # include <sys/limits.h>
 #endif /* HAVE_LIMITS/SYS_LIMITS_H */
 
+#if defined(HAVE_SYSEXITS_H)
+#  include <sysexits.h>
+#endif /* HAVE_SYSEXITS_H */
+
+#ifndef EX_USAGE
+#  define EX_USAGE              64
+#endif
+
 /*
  *  PUBLIC DEFINES
  *
@@ -60,8 +68,8 @@
  *  values for "opt_name" are available.
  */
 
-#define  OPTIONS_STRUCT_VERSION  114688
-#define  OPTIONS_VERSION_STRING  "28:0:3"
+#define  OPTIONS_STRUCT_VERSION  118784
+#define  OPTIONS_VERSION_STRING  "29:0:4"
 #define  OPTIONS_MINIMUM_VERSION 102400
 #define  OPTIONS_MIN_VER_STRING  "25:0:0"
 
@@ -92,28 +100,28 @@ typedef struct optionValue {
  *  Bits in the fOptState option descriptor field.
  */
 typedef enum {
-        OPTST_SET_ID             =   0, /* Set via the "SET_OPT()" macro */
-        OPTST_PRESET_ID          =   1, /* Set via an RC/INI file        */
-        OPTST_DEFINED_ID         =   2, /* Set via a command line option */
-        OPTST_EQUIVALENCE_ID     =   4, /* selected by equiv'ed option   */
-        OPTST_DISABLED_ID        =   5, /* option is in disabled state   */
-        OPTST_ALLOC_ARG_ID       =   6, /* pzOptArg was allocated        */
-        OPTST_NO_INIT_ID         =   8, /* option cannot be preset       */
-        OPTST_NUMBER_OPT_ID      =   9, /* opt value (flag) is any digit */
-        OPTST_STACKED_ID         =  10, /* opt uses optionStackArg proc  */
-        OPTST_INITENABLED_ID     =  11, /* option defaults to enabled    */
-        OPTST_ARG_TYPE_1_ID      =  12, /* bit 1 of arg type enum        */
-        OPTST_ARG_TYPE_2_ID      =  13, /* bit 2 of arg type enum        */
-        OPTST_ARG_TYPE_3_ID      =  14, /* bit 3 of arg type enum        */
-        OPTST_ARG_TYPE_4_ID      =  15, /* bit 4 of arg type enum        */
-        OPTST_ARG_OPTIONAL_ID    =  16, /* the option arg not required   */
-        OPTST_IMM_ID             =  17, /* process opt on first pass     */
-        OPTST_DISABLE_IMM_ID     =  18, /* process disablement immed.    */
-        OPTST_OMITTED_ID         =  19, /* compiled out of program       */
-        OPTST_MUST_SET_ID        =  20, /* must be set or pre-set        */
-        OPTST_DOCUMENT_ID        =  21, /* opt is for doc only           */
-        OPTST_TWICE_ID           =  22, /* process opt twice - imm + reg */
-        OPTST_DISABLE_TWICE_ID   =  23  /* process disabled option twice */
+    OPTST_SET_ID             =   0, /* Set via the "SET_OPT()" macro */
+    OPTST_PRESET_ID          =   1, /* Set via an RC/INI file        */
+    OPTST_DEFINED_ID         =   2, /* Set via a command line option */
+    OPTST_EQUIVALENCE_ID     =   4, /* selected by equiv'ed option   */
+    OPTST_DISABLED_ID        =   5, /* option is in disabled state   */
+    OPTST_ALLOC_ARG_ID       =   6, /* pzOptArg was allocated        */
+    OPTST_NO_INIT_ID         =   8, /* option cannot be preset       */
+    OPTST_NUMBER_OPT_ID      =   9, /* opt value (flag) is any digit */
+    OPTST_STACKED_ID         =  10, /* opt uses optionStackArg proc  */
+    OPTST_INITENABLED_ID     =  11, /* option defaults to enabled    */
+    OPTST_ARG_TYPE_1_ID      =  12, /* bit 1 of arg type enum        */
+    OPTST_ARG_TYPE_2_ID      =  13, /* bit 2 of arg type enum        */
+    OPTST_ARG_TYPE_3_ID      =  14, /* bit 3 of arg type enum        */
+    OPTST_ARG_TYPE_4_ID      =  15, /* bit 4 of arg type enum        */
+    OPTST_ARG_OPTIONAL_ID    =  16, /* the option arg not required   */
+    OPTST_IMM_ID             =  17, /* process opt on first pass     */
+    OPTST_DISABLE_IMM_ID     =  18, /* process disablement immed.    */
+    OPTST_OMITTED_ID         =  19, /* compiled out of program       */
+    OPTST_MUST_SET_ID        =  20, /* must be set or pre-set        */
+    OPTST_DOCUMENT_ID        =  21, /* opt is for doc only           */
+    OPTST_TWICE_ID           =  22, /* process opt twice - imm + reg */
+    OPTST_DISABLE_TWICE_ID   =  23  /* process disabled option twice */
 } opt_state_enum_t;
 
 #define OPTST_INIT           0U
@@ -164,6 +172,11 @@ typedef enum {
         OPTST_ARG_TYPE_3 | \
         OPTST_ARG_TYPE_4 )
 
+#ifdef NO_OPTIONAL_OPT_ARGS
+# undef  OPTST_ARG_OPTIONAL
+# define OPTST_ARG_OPTIONAL   0
+#endif
+
 #define OPTST_PERSISTENT_MASK (~OPTST_MUTABLE_MASK)
 
 #define SELECTED_OPT( pod )   ((pod)->fOptState  & OPTST_SELECTED_MASK)
@@ -186,22 +199,22 @@ typedef enum {
  *  Define the processing state flags
  */
 typedef enum {
-        OPTPROC_LONGOPT_ID       =   0, /* Process long style options      */
-        OPTPROC_SHORTOPT_ID      =   1, /* Process short style "flags"     */
-        OPTPROC_ERRSTOP_ID       =   2, /* Stop on argument errors         */
-        OPTPROC_DISABLEDOPT_ID   =   3, /* Current option is disabled      */
-        OPTPROC_NO_REQ_OPT_ID    =   4, /* no options are required         */
-        OPTPROC_NUM_OPT_ID       =   5, /* there is a number option        */
-        OPTPROC_INITDONE_ID      =   6, /* have initializations been done? */
-        OPTPROC_NEGATIONS_ID     =   7, /* any negation options?           */
-        OPTPROC_ENVIRON_ID       =   8, /* check environment?              */
-        OPTPROC_NO_ARGS_ID       =   9, /* Disallow remaining arguments    */
-        OPTPROC_ARGS_REQ_ID      =  10, /* Require arguments after options */
-        OPTPROC_REORDER_ID       =  11, /* reorder operands after options  */
-        OPTPROC_GNUUSAGE_ID      =  12, /* emit usage in GNU style         */
-        OPTPROC_TRANSLATE_ID     =  13, /* Translate strings in tOptions   */
-        OPTPROC_HAS_IMMED_ID     =  14, /* program defines immed options   */
-        OPTPROC_PRESETTING_ID    =  19  /* opt processing in preset state  */
+    OPTPROC_LONGOPT_ID       =   0, /* Process long style options      */
+    OPTPROC_SHORTOPT_ID      =   1, /* Process short style "flags"     */
+    OPTPROC_ERRSTOP_ID       =   2, /* Stop on argument errors         */
+    OPTPROC_DISABLEDOPT_ID   =   3, /* Current option is disabled      */
+    OPTPROC_NO_REQ_OPT_ID    =   4, /* no options are required         */
+    OPTPROC_NUM_OPT_ID       =   5, /* there is a number option        */
+    OPTPROC_INITDONE_ID      =   6, /* have initializations been done? */
+    OPTPROC_NEGATIONS_ID     =   7, /* any negation options?           */
+    OPTPROC_ENVIRON_ID       =   8, /* check environment?              */
+    OPTPROC_NO_ARGS_ID       =   9, /* Disallow remaining arguments    */
+    OPTPROC_ARGS_REQ_ID      =  10, /* Require arguments after options */
+    OPTPROC_REORDER_ID       =  11, /* reorder operands after options  */
+    OPTPROC_GNUUSAGE_ID      =  12, /* emit usage in GNU style         */
+    OPTPROC_TRANSLATE_ID     =  13, /* Translate strings in tOptions   */
+    OPTPROC_HAS_IMMED_ID     =  14, /* program defines immed options   */
+    OPTPROC_PRESETTING_ID    =  19  /* opt processing in preset state  */
 } optproc_state_enum_t;
 
 #define OPTPROC_NONE         0U
@@ -350,7 +363,7 @@ struct optSpecIndex {
 typedef void (tOptionXlateProc)(void);
 
 struct options {
-    const int           structVersion;
+    int const           structVersion;
     int                 origArgCt;
     char**              origArgVect;
     unsigned int        fOptSet;
@@ -364,7 +377,7 @@ struct options {
     char const* const   pzCopyright;
     char const* const   pzCopyNotice;
     char const* const   pzFullVersion;
-    char const* const*  papzHomeList;
+    char const* const* const papzHomeList;
     char const* const   pzUsageTitle;
     char const* const   pzExplain;
     char const* const   pzDetail;
@@ -378,8 +391,8 @@ struct options {
     tOptionXlateProc*   pTransProc;
 
     tOptSpecIndex       specOptIdx;
-    const int           optCt;
-    const int           presetOptCt;
+    int const           optCt;
+    int const           presetOptCt;
 };
 
 /*
@@ -498,7 +511,7 @@ extern token_list_t* ao_string_tokenize( char const* );
 extern const tOptionValue* configFileLoad( char const* );
 
 
-/* From: configfile.c line 880
+/* From: configfile.c line 883
  *
  * optionFileLoad - Load the locatable config files, in order
  *
@@ -653,7 +666,7 @@ extern const tOptionValue* optionNextValue( const tOptionValue*, const tOptionVa
 extern void optionOnlyUsage( tOptions*, int );
 
 
-/* From: autoopts.c line 993
+/* From: autoopts.c line 1012
  *
  * optionProcess - this is the main option processing routine
  *

+ 1 - 1
libopts/autoopts/usage-txt.h

@@ -2,7 +2,7 @@
  *  
  *  DO NOT EDIT THIS FILE   (usage-txt.h)
  *  
- *  It has been AutoGen-ed  Saturday February 17, 2007 at 12:49:33 PM PST
+ *  It has been AutoGen-ed  Saturday May  5, 2007 at 12:02:33 PM PDT
  *  From the definitions    usage-txt.def
  *  and the template file   usage-txt.tpl
  *

+ 319 - 0
libopts/compat.h

@@ -0,0 +1,319 @@
+/*  -*- Mode: C -*-  */
+
+/* --- fake the preprocessor into handlng portability */
+/*
+ *  Time-stamp:      "2007-02-03 17:41:06 bkorb"
+ *
+ * Author:           Gary V Vaughan <gvaughan@oranda.demon.co.uk>
+ * Created:          Mon Jun 30 15:54:46 1997
+ *
+ * $Id: compat.h,v 4.16 2007/04/27 01:10:47 bkorb Exp $
+ */
+#ifndef COMPAT_H_GUARD
+#define COMPAT_H_GUARD 1
+
+#if defined(HAVE_CONFIG_H)
+#  include <config.h>
+
+#elif defined(_WIN32) && !defined(__CYGWIN__)
+#  include "windows-config.h"
+
+#else
+#  error "compat.h" requires "config.h"
+   choke me.
+#endif
+
+
+#ifndef HAVE_STRSIGNAL
+   char * strsignal( int signo );
+#endif
+
+#define  _GNU_SOURCE    1 /* for strsignal in GNU's libc */
+#define  __USE_GNU      1 /* exact same thing as above   */
+#define  __EXTENSIONS__ 1 /* and another way to call for it */
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  SYSTEM HEADERS:
+ */
+#include <sys/types.h>
+#ifdef HAVE_SYS_MMAN_H
+#  include <sys/mman.h>
+#endif
+#include <sys/param.h>
+#if HAVE_SYS_PROCSET_H
+#  include <sys/procset.h>
+#endif
+#include <sys/stat.h>
+#include <sys/wait.h>
+
+#if defined( HAVE_SOLARIS_SYSINFO )
+#  include <sys/systeminfo.h>
+#elif defined( HAVE_UNAME_SYSCALL )
+#  include <sys/utsname.h>
+#endif
+
+#ifdef DAEMON_ENABLED
+#  if HAVE_SYS_STROPTS_H
+#  include <sys/stropts.h>
+#  endif
+
+#  if HAVE_SYS_SOCKET_H
+#  include <sys/socket.h>
+#  endif
+
+#  if ! defined(HAVE_SYS_POLL_H) && ! defined(HAVE_SYS_SELECT_H)
+#    error This system cannot support daemon processing
+     Choke Me.
+#  endif
+
+#  if HAVE_SYS_POLL_H
+#  include <sys/poll.h>
+#  endif
+
+#  if HAVE_SYS_SELECT_H
+#  include <sys/select.h>
+#  endif
+
+#  if HAVE_NETINET_IN_H
+#  include <netinet/in.h>
+#  endif
+
+#  if HAVE_SYS_UN_H
+#  include <sys/un.h>
+#  endif
+#endif
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  USER HEADERS:
+ */
+#include <stdio.h>
+#include <assert.h>
+#include <ctype.h>
+
+/*
+ *  Directory opening stuff:
+ */
+# if defined (_POSIX_SOURCE)
+/* Posix does not require that the d_ino field be present, and some
+   systems do not provide it. */
+#    define REAL_DIR_ENTRY(dp) 1
+# else /* !_POSIX_SOURCE */
+#    define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)
+# endif /* !_POSIX_SOURCE */
+
+# if defined (HAVE_DIRENT_H)
+#   include <dirent.h>
+#   define D_NAMLEN(dirent) strlen((dirent)->d_name)
+# else /* !HAVE_DIRENT_H */
+#   define dirent direct
+#   define D_NAMLEN(dirent) (dirent)->d_namlen
+#   if defined (HAVE_SYS_NDIR_H)
+#     include <sys/ndir.h>
+#   endif /* HAVE_SYS_NDIR_H */
+#   if defined (HAVE_SYS_DIR_H)
+#     include <sys/dir.h>
+#   endif /* HAVE_SYS_DIR_H */
+#   if defined (HAVE_NDIR_H)
+#     include <ndir.h>
+#   endif /* HAVE_NDIR_H */
+# endif /* !HAVE_DIRENT_H */
+
+#include <errno.h>
+#ifdef HAVE_FCNTL_H
+# include <fcntl.h>
+#endif
+#ifndef O_NONBLOCK
+# define O_NONBLOCK FNDELAY
+#endif
+
+#if defined(HAVE_LIBGEN) && defined(HAVE_LIBGEN_H)
+#  include <libgen.h>
+#endif
+
+#if defined(HAVE_LIMITS_H)  /* this is also in options.h */
+#  include <limits.h>
+#elif defined(HAVE_SYS_LIMITS_H)
+#  include <sys/limits.h>
+#endif /* HAVE_LIMITS/SYS_LIMITS_H */
+
+#include <memory.h>
+#include <setjmp.h>
+#include <signal.h>
+
+#if defined( HAVE_STDINT_H )
+#  include <stdint.h>
+#elif defined( HAVE_INTTYPES_H )
+#  include <inttypes.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <time.h>
+
+#ifdef HAVE_UTIME_H
+#  include <utime.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+#  include <unistd.h>
+#endif
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  FIXUPS and CONVIENCE STUFF:
+ */
+#ifdef __cplusplus
+#   define EXTERN extern "C"
+#else
+#   define EXTERN extern
+#endif
+
+/* some systems #def errno! and others do not declare it!! */
+#ifndef errno
+   extern int errno;
+#endif
+
+/* Some machines forget this! */
+
+# ifndef EXIT_FAILURE
+#   define EXIT_SUCCESS 0
+#   define EXIT_FAILURE 1
+# endif
+
+#ifndef NUL
+#  define NUL '\0'
+#endif
+
+#ifndef NULL
+#  define NULL 0
+#endif
+
+#if !defined (MAXPATHLEN) && defined (HAVE_SYS_PARAM_H)
+#  include <sys/param.h>
+#endif /* !MAXPATHLEN && HAVE_SYS_PARAM_H */
+
+#if !defined (MAXPATHLEN) && defined (PATH_MAX)
+#  define MAXPATHLEN PATH_MAX
+#endif /* !MAXPATHLEN && PATH_MAX */
+
+#if !defined (MAXPATHLEN) && defined(_MAX_PATH)
+#  define PATH_MAX _MAX_PATH
+#  define MAXPATHLEN _MAX_PATH
+#endif
+
+#if !defined (MAXPATHLEN)
+#  define MAXPATHLEN ((size_t)4096)
+#endif /* MAXPATHLEN */
+
+#define AG_PATH_MAX  ((size_t)MAXPATHLEN)
+
+#ifndef LONG_MAX
+#  define LONG_MAX      ~(1L << (8*sizeof(long) -1))
+#  define INT_MAX       ~(1 << (8*sizeof(int) -1))
+#endif
+
+#ifndef ULONG_MAX
+#  define ULONG_MAX     ~(OUL)
+#  define UINT_MAX      ~(OU)
+#endif
+
+#ifndef SHORT_MAX
+#  define SHORT_MAX     ~(1 << (8*sizeof(short) -1))
+#else
+#  define USHORT_MAX    ~(OUS)
+#endif
+
+#ifndef HAVE_INT8_T
+  typedef signed char       int8_t;
+#endif
+#ifndef HAVE_UINT8_T
+  typedef unsigned char     uint8_t;
+#endif
+#ifndef HAVE_INT16_T
+  typedef signed short      int16_t;
+#endif
+#ifndef HAVE_UINT16_T
+  typedef unsigned short    uint16_t;
+#endif
+#ifndef HAVE_UINT_T
+  typedef unsigned int      uint_t;
+#endif
+
+#ifndef HAVE_INT32_T
+# if SIZEOF_INT == 4
+        typedef signed int      int32_t;
+# elif SIZEOF_LONG == 4
+        typedef signed long     int32_t;
+# endif
+#endif
+
+#ifndef HAVE_UINT32_T
+# if SIZEOF_INT == 4
+        typedef unsigned int    uint32_t;
+# elif SIZEOF_LONG == 4
+        typedef unsigned long   uint32_t;
+# else
+#   error Cannot create a uint32_t type.
+    Choke Me.
+# endif
+#endif
+
+#ifndef HAVE_INTPTR_T
+  typedef signed long   intptr_t;
+#endif
+#ifndef HAVE_UINTPTR_T
+  typedef unsigned long uintptr_t;
+#endif
+
+/* redefine these for BSD style string libraries */
+#ifndef HAVE_STRCHR
+#  define strchr        index
+#  define strrchr       rindex
+#endif
+
+#ifdef USE_FOPEN_BINARY
+#  ifndef FOPEN_BINARY_FLAG
+#    define FOPEN_BINARY_FLAG   "b"
+#  endif
+#  ifndef FOPEN_TEXT_FLAG
+#    define FOPEN_TEXT_FLAG     "t"
+#  endif
+#else
+#  ifndef FOPEN_BINARY_FLAG
+#    define FOPEN_BINARY_FLAG
+#  endif
+#  ifndef FOPEN_TEXT_FLAG
+#    define FOPEN_TEXT_FLAG
+#  endif
+#endif
+
+#ifndef STR
+#  define _STR(s) #s
+#  define STR(s)  _STR(s)
+#endif
+
+/* ##### Pointer sized word ##### */
+
+/* FIXME:  the MAX stuff in here is broken! */
+#if SIZEOF_CHARP > SIZEOF_INT
+   typedef long t_word;
+   #define WORD_MAX  LONG_MAX
+   #define WORD_MIN  LONG_MIN
+#else /* SIZEOF_CHARP <= SIZEOF_INT */
+   typedef int t_word;
+   #define WORD_MAX  INT_MAX
+   #define WORD_MIN  INT_MIN
+#endif
+
+#endif /* COMPAT_H_GUARD */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of compat/compat.h */

+ 16 - 14
libopts/configfile.c

@@ -1,6 +1,6 @@
 /*
- *  $Id: configfile.c,v 1.20 2007/02/04 17:44:12 bkorb Exp $
- *  Time-stamp:      "2007-01-13 12:49:10 bkorb"
+ *  $Id: configfile.c,v 1.21 2007/04/15 19:01:18 bkorb Exp $
+ *  Time-stamp:      "2007-04-15 11:22:46 bkorb"
  *
  *  configuration/rc/ini file handling.
  */
@@ -869,11 +869,14 @@ internalFileLoad( tOptions* pOpts )
          *  IF we are now to skip config files AND we are presetting,
          *  THEN change direction.  We must go the other way.
          */
-        if (SKIP_RC_FILES(pOpts) && PRESETTING(inc)) {
-            idx -= inc;  /* go back and reprocess current file */
-            inc =  DIRECTION_PROCESS;
+        {
+            tOptDesc * pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts+1;
+            if (DISABLED_OPT(pOD) && PRESETTING(inc)) {
+                idx -= inc;  /* go back and reprocess current file */
+                inc =  DIRECTION_PROCESS;
+            }
         }
-    } /* For every path in the home list, ... */
+    } /* twice for every path in the home list, ... */
 }
 
 
@@ -937,11 +940,10 @@ void
 optionLoadOpt( tOptions* pOpts, tOptDesc* pOptDesc )
 {
     /*
-     *  IF the option is not being disabled,
-     *  THEN load the file.  There must be a file.
-     *  (If it is being disabled, then the disablement processing
-     *  already took place.  It must be done to suppress preloading
-     *  of ini/rc files.)
+     *  IF the option is not being disabled, THEN load the file.  There must
+     *  be a file.  (If it is being disabled, then the disablement processing
+     *  already took place.  It must be done to suppress preloading of ini/rc
+     *  files.)
      */
     if (! DISABLED_OPT( pOptDesc )) {
         struct stat sb;
@@ -951,7 +953,7 @@ optionLoadOpt( tOptions* pOpts, tOptDesc* pOptDesc )
 
             fprintf( stderr, zFSErrOptLoad, errno, strerror( errno ),
                      pOptDesc->optArg.argString );
-            (*pOpts->pUsageProc)( pOpts, EXIT_FAILURE );
+            exit(EX_NOINPUT);
             /* NOT REACHED */
         }
 
@@ -960,7 +962,7 @@ optionLoadOpt( tOptions* pOpts, tOptDesc* pOptDesc )
                 return;
 
             fprintf( stderr, zNotFile, pOptDesc->optArg.argString );
-            (*pOpts->pUsageProc)( pOpts, EXIT_FAILURE );
+            exit(EX_NOINPUT);
             /* NOT REACHED */
         }
 
@@ -1223,7 +1225,7 @@ validateOptionsStruct( tOptions* pOpts, char const* pzProgram )
 {
     if (pOpts == NULL) {
         fputs( zAO_Bad, stderr );
-        exit( EXIT_FAILURE );
+        exit( EX_CONFIG );
     }
 
     /*

+ 74 - 55
libopts/environment.c

@@ -1,7 +1,7 @@
 
 /*
- *  $Id: environment.c,v 4.12 2007/02/04 17:44:12 bkorb Exp $
- * Time-stamp:      "2007-01-13 10:02:07 bkorb"
+ *  $Id: environment.c,v 4.13 2007/04/15 19:01:18 bkorb Exp $
+ * Time-stamp:      "2007-04-15 11:50:35 bkorb"
  *
  *  This file contains all of the routines that must be linked into
  *  an executable to use the generated option processing.  The optional
@@ -54,6 +54,9 @@
 
 /* = = = START-STATIC-FORWARD = = = */
 /* static forward declarations maintained by :mkfwd */
+static void
+checkEnvOpt(tOptState * os, char * env_name,
+            tOptions* pOpts, teEnvPresetType type);
 /* = = = END-STATIC-FORWARD = = = */
 
 /*
@@ -145,6 +148,66 @@ doPrognameEnv( tOptions* pOpts, teEnvPresetType type )
     pOpts->fOptSet     = sv_flag;
 }
 
+static void
+checkEnvOpt(tOptState * os, char * env_name,
+            tOptions* pOpts, teEnvPresetType type)
+{
+    os->pzOptArg = getenv( env_name );
+    if (os->pzOptArg == NULL)
+        return;
+
+    os->flags    = OPTST_PRESET | OPTST_ALLOC_ARG | os->pOD->fOptState;
+    os->optType  = TOPT_UNDEFINED;
+
+    if (  (os->pOD->pz_DisablePfx != NULL)
+       && (streqvcmp( os->pzOptArg, os->pOD->pz_DisablePfx ) == 0)) {
+        os->flags |= OPTST_DISABLED;
+        os->pzOptArg = NULL;
+    }
+
+    switch (type) {
+    case ENV_IMM:
+        /*
+         *  Process only immediate actions
+         */
+        if (DO_IMMEDIATELY(os->flags))
+            break;
+        return;
+
+    case ENV_NON_IMM:
+        /*
+         *  Process only NON immediate actions
+         */
+        if (DO_NORMALLY(os->flags) || DO_SECOND_TIME(os->flags))
+            break;
+        return;
+
+    default: /* process everything */
+        break;
+    }
+
+    /*
+     *  Make sure the option value string is persistent and consistent.
+     *
+     *  The interpretation of the option value depends
+     *  on the type of value argument the option takes
+     */
+    if (os->pzOptArg != NULL) {
+        if (OPTST_GET_ARGTYPE(os->pOD->fOptState) == OPARG_TYPE_NONE) {
+            os->pzOptArg = NULL;
+        } else if (  (os->pOD->fOptState & OPTST_ARG_OPTIONAL)
+                     && (*os->pzOptArg == NUL)) {
+            os->pzOptArg = NULL;
+        } else if (*os->pzOptArg == NUL) {
+            os->pzOptArg = zNil;
+        } else {
+            AGDUPSTR( os->pzOptArg, os->pzOptArg, "option argument" );
+            os->flags |= OPTST_ALLOC_ARG;
+        }
+    }
+
+    handleOption( pOpts, os );
+}
 
 /*
  *  doEnvPresets - check for preset values from the envrionment
@@ -194,60 +257,16 @@ doEnvPresets( tOptions* pOpts, teEnvPresetType type )
          *  Set up the option state
          */
         strcpy( pzFlagName, st.pOD->pz_NAME );
-        st.pzOptArg = getenv( zEnvName );
-        if (st.pzOptArg == NULL)
-            continue;
-        st.flags    = OPTST_PRESET | OPTST_ALLOC_ARG | st.pOD->fOptState;
-        st.optType  = TOPT_UNDEFINED;
-
-        if (  (st.pOD->pz_DisablePfx != NULL)
-           && (streqvcmp( st.pzOptArg, st.pOD->pz_DisablePfx ) == 0)) {
-            st.flags |= OPTST_DISABLED;
-            st.pzOptArg = NULL;
-        }
-
-        switch (type) {
-        case ENV_IMM:
-            /*
-             *  Process only immediate actions
-             */
-            if (DO_IMMEDIATELY(st.flags))
-                break;
-            continue;
-
-        case ENV_NON_IMM:
-            /*
-             *  Process only NON immediate actions
-             */
-            if (DO_NORMALLY(st.flags) || DO_SECOND_TIME(st.flags))
-                break;
-            continue;
-
-        default: /* process everything */
-            break;
-        }
-
-        /*
-         *  Make sure the option value string is persistent and consistent.
-         *
-         *  The interpretation of the option value depends
-         *  on the type of value argument the option takes
-         */
-        if (st.pzOptArg != NULL) {
-            if (OPTST_GET_ARGTYPE(st.pOD->fOptState) == OPARG_TYPE_NONE) {
-                st.pzOptArg = NULL;
-            } else if (  (st.pOD->fOptState & OPTST_ARG_OPTIONAL)
-                      && (*st.pzOptArg == NUL)) {
-                    st.pzOptArg = NULL;
-            } else if (*st.pzOptArg == NUL) {
-                st.pzOptArg = zNil;
-            } else {
-                AGDUPSTR( st.pzOptArg, st.pzOptArg, "option argument" );
-                st.flags |= OPTST_ALLOC_ARG;
-            }
-        }
+        checkEnvOpt(&st, zEnvName, pOpts, type);
+    }
 
-        handleOption( pOpts, &st );
+    /*
+     *  Special handling for ${PROGNAME_LOAD_OPTS}
+     */
+    if (pOpts->specOptIdx.save_opts != 0) {
+        st.pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts + 1;
+        strcpy( pzFlagName, st.pOD->pz_NAME );
+        checkEnvOpt(&st, zEnvName, pOpts, type);
     }
 }
 

+ 20 - 11
libopts/genshell.c

@@ -2,11 +2,11 @@
  *  
  *  DO NOT EDIT THIS FILE   (genshell.c)
  *  
- *  It has been AutoGen-ed  Saturday February 17, 2007 at 12:49:35 PM PST
+ *  It has been AutoGen-ed  Saturday May  5, 2007 at 12:02:35 PM PDT
  *  From the definitions    genshell.def
  *  and the template file   options
  *
- * Generated from AutoOpts 28:0:3 templates.
+ * Generated from AutoOpts 29:0:4 templates.
  */
 
 /*
@@ -20,7 +20,7 @@
  *
  * This source file is copyrighted and licensed under the following terms:
  *
- * genshellopt copyright 1999-2006 Bruce Korb - all rights reserved
+ * genshellopt copyright 1999-2007 Bruce Korb - all rights reserved
  *
  * genshellopt is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -49,7 +49,7 @@
 extern "C" {
 #endif
 tSCC zCopyright[] =
-       "genshellopt copyright (c) 1999-2006 Bruce Korb, all rights reserved";
+       "genshellopt copyright (c) 1999-2007 Bruce Korb, all rights reserved";
 tSCC zCopyrightNotice[] =
        "genshellopt is free software; you can redistribute it and/or\n\
 modify it under the terms of the GNU Lesser General Public\n\
@@ -145,12 +145,18 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zShellText, zShell_NAME, zShell_Name,
      /* disablement strs */ zNotShell_Name, zNotShell_Pfx },
 
+#ifdef NO_OPTIONAL_OPT_ARGS
+#  define VERSION_OPT_FLAGS     OPTST_IMM | OPTST_NO_INIT
+#else
+#  define VERSION_OPT_FLAGS     OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
+                                OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT
+#endif
+
   {  /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
      /* equiv idx value  */ NO_EQUIVALENT, 0,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
-     /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
-                          | OPTST_ARG_OPTIONAL | OPTST_IMM, 0,
+     /* opt state flags  */ VERSION_OPT_FLAGS, 0,
      /* last opt argumnt */ { NULL },
      /* arg list/cookie  */ NULL,
      /* must/cannot opts */ NULL, NULL,
@@ -158,11 +164,14 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zVersionText, NULL, zVersion_Name,
      /* disablement strs */ NULL, NULL },
 
+#undef VERSION_OPT_FLAGS
+
+
   {  /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
      /* equiv idx value  */ NO_EQUIVALENT, 0,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
-     /* opt state flags  */ OPTST_IMM, 0,
+     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
      /* last opt argumnt */ { NULL },
      /* arg list/cookie  */ NULL,
      /* must/cannot opts */ NULL, NULL,
@@ -174,7 +183,7 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* equiv idx value  */ NO_EQUIVALENT, 0,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
-     /* opt state flags  */ OPTST_IMM, 0,
+     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
      /* last opt argumnt */ { NULL },
      /* arg list/cookie  */ NULL,
      /* must/cannot opts */ NULL,  NULL,
@@ -204,7 +213,7 @@ If the script file already exists and contains Automated Option Processing\n\
 text, the second line of the file through the ending tag will be replaced\n\
 by the newly generated text.  The first `#!' line will be regenerated.\n";
 tSCC    zFullVersion[] = GENSHELLOPT_FULL_VERSION;
-/* extracted from optcode.tpl near line 378 */
+/* extracted from optcode.tpl near line 408 */
 
 #if defined(ENABLE_NLS)
 # define OPTPROC_BASE OPTPROC_TRANSLATE
@@ -241,7 +250,7 @@ tOptions genshelloptOptions = {
       NO_EQUIVALENT /* index of '-#' option */,
       NO_EQUIVALENT /* index of default opt */
     },
-    OPTION_CT, 2 /* user option count */
+    5 /* full option count */, 2 /* user option count */
 };
 
 /*
@@ -254,7 +263,7 @@ doUsageOpt(
 {
     USAGE( EXIT_SUCCESS );
 }
-/* extracted from optcode.tpl near line 475 */
+/* extracted from optcode.tpl near line 514 */
 
 #if ENABLE_NLS
 #include <stdio.h>

+ 5 - 5
libopts/genshell.h

@@ -2,11 +2,11 @@
  *  
  *  DO NOT EDIT THIS FILE   (genshell.h)
  *  
- *  It has been AutoGen-ed  Saturday February 17, 2007 at 12:49:35 PM PST
+ *  It has been AutoGen-ed  Saturday May  5, 2007 at 12:02:35 PM PDT
  *  From the definitions    genshell.def
  *  and the template file   options
  *
- * Generated from AutoOpts 28:0:3 templates.
+ * Generated from AutoOpts 29:0:4 templates.
  */
 
 /*
@@ -20,7 +20,7 @@
  *
  * This source file is copyrighted and licensed under the following terms:
  *
- * genshellopt copyright 1999-2006 Bruce Korb - all rights reserved
+ * genshellopt copyright 1999-2007 Bruce Korb - all rights reserved
  *
  * genshellopt is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -55,7 +55,7 @@
  *  tolerable version is at least as old as what was current when the header
  *  template was released.
  */
-#define AO_TEMPLATE_VERSION 114688
+#define AO_TEMPLATE_VERSION 118784
 #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
  || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
 # error option template version mismatches autoopts/options.h header
@@ -117,7 +117,7 @@ typedef enum {
                 genshelloptOptions.pzCurOpt  = NULL )
 #define START_OPT       RESTART_OPT(1)
 #define USAGE(c)        (*genshelloptOptions.pUsageProc)( &genshelloptOptions, c )
-/* extracted from opthead.tpl near line 345 */
+/* extracted from opthead.tpl near line 360 */
 
 /* * * * * *
  *

+ 22 - 2
libopts/m4/libopts.m4

@@ -2,7 +2,7 @@ dnl  -*- buffer-read-only: t -*- vi: set ro:
 dnl 
 dnl DO NOT EDIT THIS FILE   (libopts.m4)
 dnl 
-dnl It has been AutoGen-ed  Saturday February 17, 2007 at 12:49:37 PM PST
+dnl It has been AutoGen-ed  Saturday May  5, 2007 at 12:02:37 PM PDT
 dnl From the definitions    libopts.def
 dnl and the template file   conftest.tpl
 dnl
@@ -25,7 +25,7 @@ AC_DEFUN([INVOKE_LIBOPTS_MACROS_FIRST],[
   AC_CHECK_HEADERS(dlfcn.h errno.h fcntl.h libgen.h memory.h netinet/in.h \
     setjmp.h sys/mman.h sys/param.h sys/poll.h sys/procset.h sys/select.h \
     sys/socket.h sys/stropts.h sys/time.h sys/un.h sys/wait.h unistd.h    \
-    utime.h )
+    utime.h sysexits.h)
   
   # --------------------------------------------
   # Verify certain entries from AC_CHECK_HEADERS
@@ -370,6 +370,23 @@ return (fp == NULL) ? 1 : fclose(fp); }],
 ]) # end of AC_DEFUN of LIBOPTS_RUN_FOPEN_TEXT
 
 
+AC_DEFUN([LIBOPTS_DISABLE_OPTIONAL_ARGS],[
+  AC_ARG_ENABLE([optional-args],
+    AC_HELP_STRING([--disable-optional-args], [not wanting optional option args]),
+    [libopts_cv_enable_optional_args=${enable_optional_args}],
+    AC_CACHE_CHECK([whether not wanting optional option args], libopts_cv_enable_optional_args,
+      libopts_cv_enable_optional_args=yes)
+  ) # end of AC_ARG_ENABLE
+
+  if test "X${libopts_cv_enable_optional_args}" = Xno
+  then
+    AC_DEFINE([NO_OPTIONAL_OPT_ARGS], [1],
+          [Define this if optional arguments are disallowed])
+  fi
+  
+]) # end of AC_DEFUN of LIBOPTS_DISABLE_OPTIONAL_ARGS
+
+
 AC_DEFUN([INVOKE_LIBOPTS_MACROS],[
   INVOKE_LIBOPTS_MACROS_FIRST
   # Check to see if a reg expr header is specified.
@@ -396,6 +413,9 @@ AC_DEFUN([INVOKE_LIBOPTS_MACROS],[
   # Check to see if fopen accepts "t" mode.
   LIBOPTS_RUN_FOPEN_TEXT
 
+  # Check to see if not wanting optional option args.
+  LIBOPTS_DISABLE_OPTIONAL_ARGS
+
 ]) # end AC_DEFUN of INVOKE_LIBOPTS_MACROS
 
 dnl @synopsis  LIBOPTS_CHECK

+ 339 - 0
libopts/pathfind.c

@@ -0,0 +1,339 @@
+/*  -*- Mode: C -*-  */
+
+/* pathfind.c --- find a FILE  MODE along PATH */
+
+/*
+ * Author:           Gary V Vaughan <gvaughan@oranda.demon.co.uk>
+ * Time-stamp:       "2006-09-23 19:46:16 bkorb"
+ * Created:          Tue Jun 24 15:07:31 1997
+ * Last Modified:    $Date: 2006/11/27 01:52:23 $
+ *            by: bkorb
+ *
+ * $Id: pathfind.c,v 4.10 2006/11/27 01:52:23 bkorb Exp $
+ */
+
+/* Code: */
+
+#include "compat.h"
+#ifndef HAVE_PATHFIND
+#if defined(__windows__) && !defined(__CYGWIN__)
+char*
+pathfind( char const*  path,
+          char const*  fileName,
+          char const*  mode )
+{
+    return NULL;
+}
+#else
+
+static char* make_absolute( char const *string, char const *dot_path );
+static char* canonicalize_pathname( char *path );
+static char* extract_colon_unit( char* dir, char const *string, int *p_index );
+
+
+/*=export_func pathfind
+ *
+ * what: fild a file in a list of directories
+ *
+ * ifndef: HAVE_PATHFIND
+ *
+ * arg:  + char const* + path + colon separated list of search directories +
+ * arg:  + char const* + file + the name of the file to look for +
+ * arg:  + char const* + mode + the mode bits that must be set to match +
+ *
+ * ret_type:  char*
+ * ret_desc:  the path to the located file
+ *
+ * doc:
+ *
+ * pathfind looks for a a file with name "FILE" and "MODE" access
+ * along colon delimited "PATH", and returns the full pathname as a
+ * string, or NULL if not found.  If "FILE" contains a slash, then
+ * it is treated as a relative or absolute path and "PATH" is ignored.
+ *
+ * @strong{NOTE}: this function is compiled into @file{libopts} only if
+ * it is not natively supplied.
+ *
+ * The "MODE" argument is a string of option letters chosen from the
+ * list below:
+ * @example
+ *          Letter    Meaning
+ *          r         readable
+ *          w         writable
+ *          x         executable
+ *          f         normal file       (NOT IMPLEMENTED)
+ *          b         block special     (NOT IMPLEMENTED)
+ *          c         character special (NOT IMPLEMENTED)
+ *          d         directory         (NOT IMPLEMENTED)
+ *          p         FIFO (pipe)       (NOT IMPLEMENTED)
+ *          u         set user ID bit   (NOT IMPLEMENTED)
+ *          g         set group ID bit  (NOT IMPLEMENTED)
+ *          k         sticky bit        (NOT IMPLEMENTED)
+ *          s         size nonzero      (NOT IMPLEMENTED)
+ * @end example
+ *
+ * example:
+ * To find the "ls" command using the "PATH" environment variable:
+ * @example
+ *    #include <stdlib.h>
+ *    char* pz_ls = pathfind( getenv("PATH"), "ls", "rx" );
+ *    <<do whatever with pz_ls>>
+ *    free( pz_ls );
+ * @end example
+ * The path is allocated with @code{malloc(3C)}, so you must @code{free(3C)}
+ * the result.  Also, do not use unimplemented file modes.  :-)
+ *
+ * err:  returns NULL if the file is not found.
+=*/
+char*
+pathfind( char const*  path,
+          char const*  fileName,
+          char const*  mode )
+{
+    int   p_index   = 0;
+    int   mode_bits = 0;
+    char* pathName  = NULL;
+    char  zPath[ AG_PATH_MAX + 1 ];
+
+    if (strchr( mode, 'r' )) mode_bits |= R_OK;
+    if (strchr( mode, 'w' )) mode_bits |= W_OK;
+    if (strchr( mode, 'x' )) mode_bits |= X_OK;
+
+    /*
+     *  FOR each non-null entry in the colon-separated path, DO ...
+     */
+    for (;;) {
+        DIR*  dirP;
+        char* colon_unit = extract_colon_unit( zPath, path, &p_index );
+
+        /*
+         *  IF no more entries, THEN quit
+         */
+        if (colon_unit == NULL)
+            break;
+
+        dirP = opendir( colon_unit );
+
+        /*
+         *  IF the directory is inaccessable, THEN next directory
+         */
+        if (dirP == NULL)
+            continue;
+
+        /*
+         *  FOR every entry in the given directory, ...
+         */
+        for (;;) {
+            struct dirent *entP = readdir( dirP );
+
+            if (entP == (struct dirent*)NULL)
+                break;
+
+            /*
+             *  IF the file name matches the one we are looking for, ...
+             */
+            if (strcmp( entP->d_name, fileName ) == 0) {
+                char* pzFullName = make_absolute( fileName, colon_unit);
+
+                /*
+                 *  Make sure we can access it in the way we want
+                 */
+                if (access( pzFullName, mode_bits ) >= 0) {
+                    /*
+                     *  We can, so normalize the name and return it below
+                     */
+                    pathName = canonicalize_pathname( pzFullName );
+                }
+
+                free( (void*)pzFullName );
+                break;
+            }
+        }
+
+        closedir( dirP );
+
+        if (pathName != NULL)
+            break;
+    }
+
+    return pathName;
+}
+
+/*
+ * Turn STRING  (a pathname) into an  absolute  pathname, assuming  that
+ * DOT_PATH contains the symbolic location of  `.'.  This always returns
+ * a new string, even if STRING was an absolute pathname to begin with.
+ */
+static char*
+make_absolute( char const *string, char const *dot_path )
+{
+    char *result;
+    int result_len;
+
+    if (!dot_path || *string == '/') {
+        result = strdup( string );
+    } else {
+        if (dot_path && dot_path[0]) {
+            result = malloc( 2 + strlen( dot_path ) + strlen( string ) );
+            strcpy( result, dot_path );
+            result_len = strlen( result );
+            if (result[result_len - 1] != '/') {
+                result[result_len++] = '/';
+                result[result_len] = '\0';
+            }
+        } else {
+            result = malloc( 3 + strlen( string ) );
+            result[0] = '.'; result[1] = '/'; result[2] = '\0';
+            result_len = 2;
+        }
+
+        strcpy( result + result_len, string );
+    }
+
+    return result;
+}
+
+/*
+ * Canonicalize PATH, and return a  new path.  The new path differs from
+ * PATH in that:
+ *
+ *    Multiple `/'s     are collapsed to a single `/'.
+ *    Leading `./'s     are removed.
+ *    Trailing `/.'s    are removed.
+ *    Trailing `/'s     are removed.
+ *    Non-leading `../'s and trailing `..'s are handled by removing
+ *                    portions of the path.
+ */
+static char*
+canonicalize_pathname( char *path )
+{
+    int i, start;
+    char stub_char, *result;
+
+    /* The result cannot be larger than the input PATH. */
+    result = strdup( path );
+
+    stub_char = (*path == '/') ? '/' : '.';
+
+    /* Walk along RESULT looking for things to compact. */
+    i = 0;
+    while (result[i]) {
+        while (result[i] != '\0' && result[i] != '/')
+            i++;
+
+        start = i++;
+
+        /* If we didn't find any  slashes, then there is nothing left to
+         * do.
+         */
+        if (!result[start])
+            break;
+
+        /* Handle multiple `/'s in a row. */
+        while (result[i] == '/')
+            i++;
+
+#if !defined (apollo)
+        if ((start + 1) != i)
+#else
+        if ((start + 1) != i && (start != 0 || i != 2))
+#endif /* apollo */
+        {
+            strcpy( result + start + 1, result + i );
+            i = start + 1;
+        }
+
+        /* Handle backquoted `/'. */
+        if (start > 0 && result[start - 1] == '\\')
+            continue;
+
+        /* Check for trailing `/', and `.' by itself. */
+        if ((start && !result[i])
+            || (result[i] == '.' && !result[i+1])) {
+            result[--i] = '\0';
+            break;
+        }
+
+        /* Check for `../', `./' or trailing `.' by itself. */
+        if (result[i] == '.') {
+            /* Handle `./'. */
+            if (result[i + 1] == '/') {
+                strcpy( result + i, result + i + 1 );
+                i = (start < 0) ? 0 : start;
+                continue;
+            }
+
+            /* Handle `../' or trailing `..' by itself. */
+            if (result[i + 1] == '.' &&
+                (result[i + 2] == '/' || !result[i + 2])) {
+                while (--start > -1 && result[start] != '/')
+                    ;
+                strcpy( result + start + 1, result + i + 2 );
+                i = (start < 0) ? 0 : start;
+                continue;
+            }
+        }
+    }
+
+    if (!*result) {
+        *result = stub_char;
+        result[1] = '\0';
+    }
+
+    return result;
+}
+
+/*
+ * Given a  string containing units of information separated  by colons,
+ * return the next one  pointed to by (P_INDEX), or NULL if there are no
+ * more.  Advance (P_INDEX) to the character after the colon.
+ */
+static char*
+extract_colon_unit( char* pzDir, char const *string, int *p_index )
+{
+    char*  pzDest = pzDir;
+    int    ix     = *p_index;
+
+    if (string == NULL)
+        return NULL;
+
+    if ((unsigned)ix >= strlen( string ))
+        return NULL;
+
+    {
+        char const* pzSrc = string + ix;
+
+        while (*pzSrc == ':')  pzSrc++;
+
+        for (;;) {
+            char ch = (*(pzDest++) = *(pzSrc++));
+            switch (ch) {
+            case ':':
+                pzDest[-1] = NUL;
+            case NUL:
+                goto copy_done;
+            }
+
+            if ((pzDest - pzDir) >= AG_PATH_MAX)
+                break;
+        } copy_done:;
+
+        ix = pzSrc - string;
+    }
+
+    if (*pzDir == NUL)
+        return NULL;
+
+    *p_index = ix;
+    return pzDir;
+}
+#endif /* __windows__ / __CYGWIN__ */
+#endif /* HAVE_PATHFIND */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of compat/pathfind.c */

+ 2 - 2
libopts/pgusage.c

@@ -1,6 +1,6 @@
 
 /*
- *  $Id: pgusage.c,v 4.11 2006/09/24 02:11:16 bkorb Exp $
+ *  $Id: pgusage.c,v 4.12 2007/04/28 22:19:23 bkorb Exp $
  * Time-stamp:      "2006-07-16 08:13:26 bkorb"
  *
  *   Automated Options Paged Usage module.
@@ -10,7 +10,7 @@
  */
 
 /*
- *  Automated Options copyright 1992-2006 Bruce Korb
+ *  Automated Options copyright 1992-2007 Bruce Korb
  *
  *  Automated Options is free software.
  *  You may redistribute it and/or modify it under the terms of the

+ 1 - 1
libopts/proto.h

@@ -1,7 +1,7 @@
 /* -*- buffer-read-only: t -*- vi: set ro:
  *
  * Prototypes for autoopts
- * Generated Sat Feb 17 12:49:36 PST 2007
+ * Generated Sat May  5 12:02:36 PDT 2007
  */
 #ifndef AUTOOPTS_PROTO_H_GUARD
 #define AUTOOPTS_PROTO_H_GUARD 1

+ 2 - 2
libopts/save.c

@@ -1,7 +1,7 @@
 
 /*
- *  save.c  $Id: save.c,v 4.17 2007/02/04 17:44:12 bkorb Exp $
- * Time-stamp:      "2007-01-13 10:32:27 bkorb"
+ *  save.c  $Id: save.c,v 4.18 2007/04/15 19:01:18 bkorb Exp $
+ * Time-stamp:      "2007-04-15 11:11:10 bkorb"
  *
  *  This module's routines will take the currently set options and
  *  store them into an ".rc" file for re-interpretation the next

+ 60 - 0
libopts/snprintf.c

@@ -0,0 +1,60 @@
+
+#ifndef HAVE_VPRINTF
+#include "choke-me: no vprintf and no snprintf"
+#endif
+
+#if defined(HAVE_STDARG_H)
+#  include <stdarg.h>
+#  ifndef   VA_START
+#    define VA_START(a, f)  va_start(a, f)
+#    define VA_END(a)       va_end(a)
+#  endif /* VA_START */
+#  define SNV_USING_STDARG_H
+
+#elif defined(HAVE_VARARGS_H)
+#  include <varargs.h>
+#  ifndef   VA_START
+#    define VA_START(a, f) va_start(a)
+#    define VA_END(a)    va_end(a)
+#  endif /* VA_START */
+#  undef  SNV_USING_STDARG_H
+
+#else
+#  include "must-have-stdarg-or-varargs"
+#endif
+
+static int
+snprintf(char *str, size_t n, char const *fmt, ...)
+{
+    va_list ap;
+    int rval;
+
+#ifdef VSPRINTF_CHARSTAR
+    char *rp;
+    VA_START(ap, fmt);
+    rp = vsprintf(str, fmt, ap);
+    VA_END(ap);
+    rval = strlen(rp);
+
+#else
+    VA_START(ap, fmt);
+    rval = vsprintf(str, fmt, ap);
+    VA_END(ap);
+#endif
+
+    if (rval > n) {
+        fprintf(stderr, "snprintf buffer overrun %d > %d\n", rval, (int)n);
+        abort();
+    }
+    return rval;
+}
+
+static int
+vsnprintf( char *str, size_t n, char const *fmt, va_list ap )
+{
+#ifdef VSPRINTF_CHARSTAR
+    return (strlen(vsprintf(str, fmt, ap)));
+#else
+    return (vsprintf(str, fmt, ap));
+#endif
+}

+ 2 - 2
libopts/sort.c

@@ -1,13 +1,13 @@
 
 /*
- *  sort.c  $Id: sort.c,v 4.9 2006/10/21 15:42:49 bkorb Exp $
+ *  sort.c  $Id: sort.c,v 4.10 2007/04/28 22:19:23 bkorb Exp $
  * Time-stamp:      "2006-10-18 11:29:04 bkorb"
  *
  *  This module implements argument sorting.
  */
 
 /*
- *  Automated Options copyright 1992-2006 Bruce Korb
+ *  Automated Options copyright 1992-2007 Bruce Korb
  *
  *  Automated Options is free software.
  *  You may redistribute it and/or modify it under the terms of the

+ 60 - 0
libopts/strchr.c

@@ -0,0 +1,60 @@
+/*
+   SYNOPSIS
+       #include <string.h>
+
+       char *strchr(char const *s, int c);
+
+       char *strrchr(char const *s, int c);
+
+   DESCRIPTION
+       The  strchr() function returns a pointer to the first occurrence of the
+       character c in the string s.
+
+       The strrchr() function returns a pointer to the last occurrence of  the
+       character c in the string s.
+
+       Here  "character"  means "byte" - these functions do not work with wide
+       or multi-byte characters.
+
+   RETURN VALUE
+       The strchr() and strrchr() functions return a pointer  to  the  matched
+       character or NULL if the character is not found.
+
+   CONFORMING TO
+       SVID 3, POSIX, BSD 4.3, ISO 9899
+*/
+
+char*
+strchr( char const *s, int c)
+{
+    do {
+        if ((unsigned)*s == (unsigned)c)
+            return s;
+
+    } while (*(++s) != NUL);
+
+    return NULL;
+}
+
+char*
+strrchr( char const *s, int c)
+{
+    char const *e = s + strlen(s);
+
+    for (;;) {
+        if (--e < s)
+            break;
+
+        if ((unsigned)*e == (unsigned)c)
+            return e;
+    }
+    return NULL;
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of compat/strsignal.c */

+ 19 - 0
libopts/strdup.c

@@ -0,0 +1,19 @@
+/*
+ * Platforms without strdup ?!?!?!
+ */
+
+static char *
+strdup( char const *s )
+{
+    char *cp;
+
+    if (s == NULL)
+        return NULL;
+
+    cp = (char *) AGALOC((unsigned) (strlen(s)+1), "strdup");
+
+    if (cp != NULL)
+        (void) strcpy(cp, s);
+
+    return cp;
+}

+ 2 - 2
libopts/streqvcmp.c

@@ -1,6 +1,6 @@
 
 /*
- *  $Id: streqvcmp.c,v 4.9 2006/09/24 02:11:16 bkorb Exp $
+ *  $Id: streqvcmp.c,v 4.10 2007/04/28 22:19:23 bkorb Exp $
  * Time-stamp:      "2006-07-26 18:25:53 bkorb"
  *
  *  String Equivalence Comparison
@@ -12,7 +12,7 @@
  */
 
 /*
- *  Automated Options copyright 1992-2006 Bruce Korb
+ *  Automated Options copyright 1992-2007 Bruce Korb
  *
  *  Automated Options is free software.
  *  You may redistribute it and/or modify it under the terms of the

+ 20 - 11
libopts/usage.c

@@ -1,7 +1,7 @@
 
 /*
- *  usage.c  $Id: usage.c,v 4.13 2006/11/27 01:52:23 bkorb Exp $
- * Time-stamp:      "2006-07-01 12:41:02 bkorb"
+ *  usage.c  $Id: usage.c,v 4.15 2007/04/28 22:19:23 bkorb Exp $
+ * Time-stamp:      "2007-04-15 11:02:46 bkorb"
  *
  *  This module implements the default usage procedure for
  *  Automated Options.  It may be overridden, of course.
@@ -13,7 +13,7 @@
  */
 
 /*
- *  Automated Options copyright 1992-2006 Bruce Korb
+ *  Automated Options copyright 1992-2007 Bruce Korb
  *
  *  Automated Options is free software.
  *  You may redistribute it and/or modify it under the terms of the
@@ -169,12 +169,18 @@ optionOnlyUsage(
  *  formats.  The descriptor specifies the default, but AUTOOPTS_USAGE will
  *  over-ride this, providing the value of it is set to either "gnu" or
  *  "autoopts".  This routine will @strong{not} return.
+ *
+ *  If "exitCode" is "EX_USAGE" (normally 64), then output will to to stdout
+ *  and the actual exit code will be "EXIT_SUCCESS".
 =*/
 void
 optionUsage(
     tOptions* pOptions,
-    int       exitCode )
+    int       usage_exit_code )
 {
+    int actual_exit_code =
+        (usage_exit_code == EX_USAGE) ? EXIT_SUCCESS : usage_exit_code;
+
     displayEnum = AG_FALSE;
 
     /*
@@ -183,7 +189,7 @@ optionUsage(
      *  on successful exit (help was requested), otherwise error out.
      */
     if (option_usage_fp == NULL)
-        option_usage_fp = (exitCode != EXIT_SUCCESS) ? stderr : stdout;
+        option_usage_fp = (actual_exit_code != EXIT_SUCCESS) ? stderr : stdout;
 
     fprintf( option_usage_fp, pOptions->pzUsageTitle, pOptions->pzProgName );
 
@@ -207,13 +213,13 @@ optionUsage(
              *  option, we do *NOT* want to emit the column headers.
              *  Otherwise, we do.
              */
-            if (  (exitCode != EXIT_SUCCESS)
+            if (  (usage_exit_code != EXIT_SUCCESS)
                || ((pOptions->pOptDesc->fOptState & OPTST_DOCUMENT) == 0) )
 
                 fputs( pOptTitle, option_usage_fp );
         }
 
-        printOptionUsage( pOptions, exitCode, pOptTitle );
+        printOptionUsage( pOptions, usage_exit_code, pOptTitle );
     }
 
     /*
@@ -241,14 +247,14 @@ optionUsage(
      *  IF the user is asking for help (thus exiting with SUCCESS),
      *  THEN see what additional information we can provide.
      */
-    if (exitCode == EXIT_SUCCESS)
+    if (usage_exit_code == EXIT_SUCCESS)
         printProgramDetails( pOptions );
 
     if (pOptions->pzBugAddr != NULL)
         fprintf( option_usage_fp, zPlsSendBugs, pOptions->pzBugAddr );
     fflush( option_usage_fp );
 
-    exit( exitCode );
+    exit( actual_exit_code );
 }
 
 
@@ -344,12 +350,15 @@ printExtendedUsage(
     /*
      *  IF this particular option can NOT be preset
      *    AND some form of presetting IS allowed,
+     *    AND it is not an auto-managed option (e.g. --help, et al.)
      *  THEN advise that this option may not be preset.
      */
     if (  ((pOD->fOptState & OPTST_NO_INIT) != 0)
        && (  (pOptions->papzHomeList != NULL)
           || (pOptions->pzPROGNAME != NULL)
-       )  )
+          )
+       && (pOD->optIndex < pOptions->presetOptCt)
+       )
 
         fputs( zNoPreset, option_usage_fp );
 
@@ -509,7 +518,7 @@ printOneUsage(
 
  bogus_desc:
     fprintf( stderr, zInvalOptDesc, pOD->pz_Name );
-    exit( EXIT_FAILURE );
+    exit( EX_SOFTWARE );
 }
 
 

+ 12 - 10
libopts/version.c

@@ -1,13 +1,13 @@
 
-/*  $Id: version.c,v 4.9 2006/09/24 02:11:16 bkorb Exp $
- * Time-stamp:      "2006-09-22 18:15:00 bkorb"
+/*  $Id: version.c,v 4.10 2007/04/28 22:19:23 bkorb Exp $
+ * Time-stamp:      "2007-04-28 10:08:34 bkorb"
  *
  *  This module implements the default usage procedure for
  *  Automated Options.  It may be overridden, of course.
  */
 
 static char const zAOV[] =
-    "Automated Options version %s, copyright (c) 1999-2006 Bruce Korb\n";
+    "Automated Options version %s, copyright (c) 1999-2007 Bruce Korb\n";
 
 /*  Automated Options is free software.
  *  You may redistribute it and/or modify it under the terms of the
@@ -79,9 +79,14 @@ printVersion( tOptions* pOpts, tOptDesc* pOD, FILE* fp )
 {
     char swCh;
 
-    if (pOD->optArg.argString == NULL)
+    /*
+     *  IF the optional argument flag is off, or the argument is not provided,
+     *  then just print the version.
+     */
+    if (  ((pOD->fOptState & OPTST_ARG_OPTIONAL) == 0)
+       || (pOD->optArg.argString == NULL))
          swCh = 'v';
-    else swCh = pOD->optArg.argString[0];
+    else swCh = tolower(pOD->optArg.argString[0]);
 
     if (pOpts->pzFullVersion != NULL) {
         fputs( pOpts->pzFullVersion, fp );
@@ -89,17 +94,15 @@ printVersion( tOptions* pOpts, tOptDesc* pOD, FILE* fp )
 
     } else {
         char const *pz = pOpts->pzUsageTitle;
-        do { fputc( *pz, fp ); } while (*(pz++) != '\n');
+        do { fputc(*pz, fp); } while (*(pz++) != '\n');
     }
 
     switch (swCh) {
-    case NUL:
+    case NUL: /* arg provided, but empty */
     case 'v':
-    case 'V':
         break;
 
     case 'c':
-    case 'C':
         if (pOpts->pzCopyright != NULL) {
             fputs( pOpts->pzCopyright, fp );
             fputc( '\n', fp );
@@ -110,7 +113,6 @@ printVersion( tOptions* pOpts, tOptDesc* pOD, FILE* fp )
         break;
 
     case 'n':
-    case 'N':
         if (pOpts->pzCopyright != NULL) {
             fputs( pOpts->pzCopyright, fp );
             fputc( '\n', fp );

+ 130 - 0
libopts/windows-config.h

@@ -0,0 +1,130 @@
+
+/*
+ * Time-stamp:        "2006-10-14 14:55:09 bkorb"
+ *             by: bkorb
+ * Last Committed:    $Date: 2007/04/28 22:19:23 $
+ */
+#ifndef WINDOWS_CONFIG_HACKERY
+#define WINDOWS_CONFIG_HACKERY 1
+
+/*
+ * The definitions below have been stolen from NTP's config.h for Windows.
+ * However, they may be kept here in order to keep libopts independent from
+ * the NTP project.
+ */
+#ifndef __windows__
+#  define __windows__ 4
+#endif
+
+/*
+ * Miscellaneous functions that Microsoft maps
+ * to other names
+ *
+ * #define inline __inline
+ * #define vsnprintf _vsnprintf
+ */
+#define snprintf _snprintf
+/*
+ * #define stricmp _stricmp
+ * #define strcasecmp _stricmp
+ * #define isascii __isascii
+ * #define finite _finite
+ * #define random      rand
+ * #define srandom     srand
+ */
+
+#define SIZEOF_INT   4
+#define SIZEOF_CHARP 4
+#define SIZEOF_LONG  4
+#define SIZEOF_SHORT 2
+
+typedef unsigned long uintptr_t;
+
+/*
+ * # define HAVE_NET_IF_H
+ * # define QSORT_USES_VOID_P
+ * # define HAVE_SETVBUF
+ * # define HAVE_VSPRINTF
+ * # define HAVE_SNPRINTF
+ * # define HAVE_VSNPRINTF
+ * # define HAVE_PROTOTYPES             /* from ntpq.mak * /
+ * # define HAVE_MEMMOVE
+ * # define HAVE_TERMIOS_H
+ * # define HAVE_ERRNO_H
+ * # define HAVE_STDARG_H
+ * # define HAVE_NO_NICE
+ * # define HAVE_MKTIME
+ * # define TIME_WITH_SYS_TIME
+ * # define HAVE_IO_COMPLETION_PORT
+ * # define ISC_PLATFORM_NEEDNTOP
+ * # define ISC_PLATFORM_NEEDPTON
+ * # define NEED_S_CHAR_TYPEDEF
+ * # define USE_PROTOTYPES              /* for ntp_types.h * /
+ *
+ * #define ULONG_CONST(a) a ## UL
+ */
+
+#define HAVE_LIMITS_H   1
+#define HAVE_STRDUP     1
+#define HAVE_STRCHR     1
+#define HAVE_FCNTL_H    1
+
+/*
+ * VS.NET's version of wspiapi.h has a bug in it
+ * where it assigns a value to a variable inside
+ * an if statement. It should be comparing them.
+ * We prevent inclusion since we are not using this
+ * code so we don't have to see the warning messages
+ */
+#ifndef _WSPIAPI_H_
+#define _WSPIAPI_H_
+#endif
+
+/* Prevent inclusion of winsock.h in windows.h */
+#ifndef _WINSOCKAPI_
+#define _WINSOCKAPI_
+#endif
+
+#ifndef __RPCASYNC_H__
+#define __RPCASYNC_H__
+#endif
+
+/* Include Windows headers */
+#include <windows.h>
+#include <winsock2.h>
+#include <limits.h>
+
+/*
+ * Compatibility declarations for Windows, assuming SYS_WINNT
+ * has been defined.
+ */
+#define strdup  _strdup
+#define stat    _stat       /* struct stat from <sys/stat.h> */
+#define unlink  _unlink
+#define fchmod( _x, _y );
+#define ssize_t SSIZE_T
+
+#include <io.h>
+#define open    _open
+#define close   _close
+#define read    _read
+#define write   _write
+#define lseek   _lseek
+#define pipe    _pipe
+#define dup2    _dup2
+
+#define O_RDWR     _O_RDWR
+#define O_RDONLY   _O_RDONLY
+#define O_EXCL     _O_EXCL
+
+#ifndef S_ISREG
+#  define S_IFREG _S_IFREG
+#  define       S_ISREG(mode)   (((mode) & S_IFREG) == S_IFREG)
+#endif
+
+#ifndef S_ISDIR
+#  define S_IFDIR _S_IFDIR
+#  define       S_ISDIR(mode)   (((mode) & S_IFDIR) == S_IFDIR)
+#endif
+
+#endif /* WINDOWS_CONFIG_HACKERY */

+ 1 - 1
scripts/Makefile.in

@@ -191,7 +191,7 @@ target_alias = @target_alias@
 target_cpu = @target_cpu@
 target_os = @target_os@
 target_vendor = @target_vendor@
-td = @td@
+tcpdump_path = @tcpdump_path@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 man2html_SOURCES = man2html.c

BIN
src/._defines.h.in


BIN
src/._send_packets.c


BIN
src/._tcpprep.c


BIN
src/._tcpreplay.c


BIN
src/._tcpreplay.h


+ 1 - 1
src/Makefile.in

@@ -259,7 +259,7 @@ target_alias = @target_alias@
 target_cpu = @target_cpu@
 target_os = @target_os@
 target_vendor = @target_vendor@
-td = @td@
+tcpdump_path = @tcpdump_path@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 

BIN
src/common/._cidr.c


BIN
src/common/._cidr.h


BIN
src/common/._timer.h


BIN
src/common/._xX.c


+ 1 - 1
src/common/Makefile.in

@@ -207,7 +207,7 @@ target_alias = @target_alias@
 target_cpu = @target_cpu@
 target_os = @target_os@
 target_vendor = @target_vendor@
-td = @td@
+tcpdump_path = @tcpdump_path@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 

+ 2 - 5
src/common/cache.c

@@ -1,4 +1,4 @@
-/* $Id: cache.c 1757 2007-03-22 05:38:56Z aturner $ */
+/* $Id: cache.c 1837 2007-04-22 18:18:44Z aturner $ */
 
 /*
  * Copyright (c) 2001-2005 Aaron Turner.
@@ -121,11 +121,8 @@ read_cache(char **cachedata, const char *cachefile, char **comment)
 
     /* malloc our cache block */
     header.num_packets = ntohll(header.num_packets);
-    header.packets_per_byte = ntohs(header.packets_per_byte);
+    header.packets_per_byte = ntohs(header.packets_per_byte);    
     cache_size = header.num_packets / header.packets_per_byte;
-
-    if (cache_size == 0)
-        err(1, "Cache size must be greater then zero");
         
     /* deal with any remainder, becuase above divsion is integer */
     if (header.num_packets % header.packets_per_byte)

+ 1 - 1
src/common/cidr.c

@@ -1,4 +1,4 @@
-/* $Id: cidr.c 1844 2007-04-27 02:42:36Z aturner $ */
+/* $Id: cidr.c 1846 2007-04-27 23:28:06Z aturner $ */
 
 /*
  * Copyright (c) 2001-2004 Aaron Turner.

+ 1 - 1
src/common/cidr.h

@@ -1,4 +1,4 @@
-/* $Id: cidr.h 1844 2007-04-27 02:42:36Z aturner $ */
+/* $Id: cidr.h 1846 2007-04-27 23:28:06Z aturner $ */
 
 /*
  * Copyright (c) 2001-2004 Aaron Turner.

+ 1 - 1
src/common/get.c

@@ -1,4 +1,4 @@
-/* $Id: get.c 1847 2007-04-30 20:55:46Z aturner $ */
+/* $Id: get.c 1848 2007-04-30 20:59:57Z aturner $ */
 
 /*
  * Copyright (c) 2001-2005 Aaron Turner.

+ 1 - 1
src/common/interface.c

@@ -1,4 +1,4 @@
-/* $Id: interface.c 1845 2007-04-27 02:48:10Z aturner $ */
+/* $Id: interface.c 1839 2007-04-22 22:22:54Z aturner $ */
 
 /*
  * Copyright (c) 2007 Aaron Turner.

+ 7 - 7
src/common/sendpacket.c

@@ -1,4 +1,4 @@
-/* $Id: sendpacket.c 1804 2007-04-14 22:48:15Z aturner $ */
+/* $Id: sendpacket.c 1863 2007-05-04 05:50:23Z aturner $ */
 
 /*
  * Copyright (c) 2006 Aaron Turner.
@@ -145,19 +145,19 @@ static int get_iface_index(int fd, const int8_t *device, char *);
 #include <sys/uio.h>
 #include <net/if_dl.h> // used for get_hwaddr_bpf()
 
-static sendpacket_t *sendpacket_open_bpf(const char *, char *) __attribute__((unused));
-static struct tcpr_ether_addr *sendpacket_get_hwaddr_bpf(sendpacket_t *) __attribute__((unused));
+static sendpacket_t *sendpacket_open_bpf(const char *, char *) _U_;
+static struct tcpr_ether_addr *sendpacket_get_hwaddr_bpf(sendpacket_t *) _U_;
 
 #endif /* HAVE_BPF */
 
 #ifdef HAVE_LIBNET
-static sendpacket_t *sendpacket_open_libnet(const char *, char *) __attribute__((unused));
-static struct tcpr_ether_addr *sendpacket_get_hwaddr_libnet(sendpacket_t *) __attribute__((unused));
+static sendpacket_t *sendpacket_open_libnet(const char *, char *) _U_;
+static struct tcpr_ether_addr *sendpacket_get_hwaddr_libnet(sendpacket_t *) _U_;
 #endif /* HAVE_LIBNET */
 
 #if (defined HAVE_PCAP_INJECT || defined HAVE_PCAP_SENDPACKET)
-static sendpacket_t *sendpacket_open_pcap(const char *, char *) __attribute__((unused));
-static struct tcpr_ether_addr *sendpacket_get_hwaddr_pcap(sendpacket_t *) __attribute__((unused));
+static sendpacket_t *sendpacket_open_pcap(const char *, char *) _U_;
+static struct tcpr_ether_addr *sendpacket_get_hwaddr_pcap(sendpacket_t *) _U_;
 #endif /* HAVE_PCAP_INJECT || HAVE_PACKET_SENDPACKET */
 
 static void sendpacket_seterr(sendpacket_t *sp, const char *fmt, ...);

+ 1 - 1
src/common/svn_version.c

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

+ 1 - 1
src/common/timer.h

@@ -1,4 +1,4 @@
-/* $Id: timer.h 1853 2007-05-02 04:40:39Z aturner $ */
+/* $Id: timer.h 1854 2007-05-02 04:41:29Z aturner $ */
 
 /*
  * Copyright (c) 2001-2007 Aaron Turner.

+ 2 - 2
src/common/xX.c

@@ -1,4 +1,4 @@
-/* $Id: xX.c 1844 2007-04-27 02:42:36Z aturner $ */
+/* $Id: xX.c 1875 2007-07-10 06:04:22Z aturner $ */
 
 /*
  * Copyright (c) 2001-2004 Aaron Turner.
@@ -77,7 +77,7 @@ parse_xX_str(tcpr_xX_t *xX, char *str, tcpr_bpf_t *bpf)
     case 'F':                  /* bpf filter */
         str = str + 2;
         out = xXBPF;
-        bpf->filter = str;
+        bpf->filter = safe_strdup(str);
         /* 
          * note: it's temping to compile the BPF here, but we don't
          * yet know what the link type is for the file, so we have 

+ 3 - 0
src/config.h.in

@@ -133,6 +133,9 @@
 /* Define to 1 if you have the `nsl' library (-lnsl). */
 #undef HAVE_LIBNSL
 
+/* Define to 1 if you have the `resolv' library (-lresolv). */
+#undef HAVE_LIBRESOLV
+
 /* Define to 1 if you have the `rt' library (-lrt). */
 #undef HAVE_LIBRT
 

BIN
src/flow/._flownode.c


+ 1 - 1
src/flow/Makefile.in

@@ -196,7 +196,7 @@ target_alias = @target_alias@
 target_cpu = @target_cpu@
 target_os = @target_os@
 target_vendor = @target_vendor@
-td = @td@
+tcpdump_path = @tcpdump_path@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 

+ 1 - 1
src/flow/flownode.c

@@ -108,7 +108,7 @@ getnodebykey(char proto, u_char * key)
  * we then return the node or NULL on error
  */
 struct session_t *
-newnode(__attribute__((unused)) char proto, u_char * key, ipv4_hdr_t * ip_hdr, void *l4)
+newnode(_U_ char proto, u_char * key, ipv4_hdr_t * ip_hdr, void *l4)
 {
     struct sockaddr_in sa;
     struct session_t *newnode = NULL;

+ 3 - 3
src/flowreplay.1

@@ -1,7 +1,7 @@
-.TH FLOWREPLAY 1 2007-04-21 "(flowreplay )" "Programmer's Manual"
+.TH FLOWREPLAY 1 2007-07-19 "(flowreplay )" "Programmer's Manual"
 .\"  DO NOT EDIT THIS FILE   (flowreplay.1)
 .\"  
-.\"  It has been AutoGen-ed  Saturday April 21, 2007 at 10:41:06 AM PDT
+.\"  It has been AutoGen-ed  Thursday July 19, 2007 at 09:17:46 AM PDT
 .\"  From the definitions    flowreplay_opts.def
 .\"  and the template file   agman1.tpl
 .\"
@@ -25,7 +25,7 @@ you have the skill and interest to help make flowreplay work better, please
 contact Aaron Turner.
 
 For more details, please see the Tcpreplay Manual at:
-http://tcpreplay.synfin.net/wiki/manual
+http://tcpreplay.synfin.net/trac/wiki/manual
 .SH OPTIONS
 .TP
 .BR \-d " \fInumber\fP, " \--dbug "=" \fInumber\fP

+ 11 - 11
src/flowreplay_opts.c

@@ -2,11 +2,11 @@
  *  
  *  DO NOT EDIT THIS FILE   (flowreplay_opts.c)
  *  
- *  It has been AutoGen-ed  Saturday April 21, 2007 at 06:52:24 PM PDT
+ *  It has been AutoGen-ed  Thursday July 19, 2007 at 09:17:44 AM PDT
  *  From the definitions    flowreplay_opts.def
  *  and the template file   options
  *
- * Generated from AutoOpts 28:0:3 templates.
+ * Generated from AutoOpts 29:0:4 templates.
  */
 
 /*
@@ -466,7 +466,7 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* equiv idx value  */ NO_EQUIVALENT, 0,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
-     /* opt state flags  */ OPTST_IMM, 0,
+     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
      /* last opt argumnt */ { NULL },
      /* arg list/cookie  */ NULL,
      /* must/cannot opts */ NULL, NULL,
@@ -478,7 +478,7 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* equiv idx value  */ NO_EQUIVALENT, 0,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
-     /* opt state flags  */ OPTST_IMM, 0,
+     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
      /* last opt argumnt */ { NULL },
      /* arg list/cookie  */ NULL,
      /* must/cannot opts */ NULL,  NULL,
@@ -491,7 +491,7 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
-                          | OPTST_ARG_OPTIONAL, 0,
+                          | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0,
      /* last opt argumnt */ { NULL },
      /* arg list/cookie  */ NULL,
      /* must/cannot opts */ NULL,  NULL,
@@ -503,8 +503,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* equiv idx value  */ NO_EQUIVALENT, 0,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, NOLIMIT, 0,
-     /* opt state flags  */ OPTST_DISABLE_IMM | \
-			OPTST_SET_ARGTYPE(OPARG_TYPE_STRING), 0,
+     /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) \
+			  | OPTST_DISABLE_IMM, 0,
      /* last opt argumnt */ { NULL },
      /* arg list/cookie  */ NULL,
      /* must/cannot opts */ NULL, NULL,
@@ -536,9 +536,9 @@ very much a work in progress and currently will not work for most uses.  If\n\
 you have the skill and interest to help make flowreplay work better, please\n\
 contact Aaron Turner.\n\n\
 For more details, please see the Tcpreplay Manual at:\n\
-http://tcpreplay.synfin.net/wiki/manual\n";
+http://tcpreplay.synfin.net/trac/wiki/manual\n";
 #define zFullVersion    NULL
-/* extracted from /opt/local/share/autogen/optcode.tpl near line 378 */
+/* extracted from /opt/local/share/autogen/optcode.tpl near line 408 */
 
 #if defined(ENABLE_NLS)
 # define OPTPROC_BASE OPTPROC_TRANSLATE
@@ -576,7 +576,7 @@ tOptions flowreplayOptions = {
       NO_EQUIVALENT /* index of '-#' option */,
       4 /* index of default opt */
     },
-    OPTION_CT, 13 /* user option count */
+    17 /* full option count */, 13 /* user option count */
 };
 
 /*
@@ -840,7 +840,7 @@ doOptLess_Help(
 
 }
 
-/* extracted from /opt/local/share/autogen/optcode.tpl near line 475 */
+/* extracted from /opt/local/share/autogen/optcode.tpl near line 514 */
 
 #if ENABLE_NLS
 #include <stdio.h>

+ 1 - 1
src/flowreplay_opts.def

@@ -48,7 +48,7 @@ you have the skill and interest to help make flowreplay work better, please
 contact Aaron Turner.
 
 For more details, please see the Tcpreplay Manual at:
-http://tcpreplay.synfin.net/wiki/manual
+http://tcpreplay.synfin.net/trac/wiki/manual
 EODetail;
 
 flag = {

+ 6 - 6
src/flowreplay_opts.h

@@ -2,11 +2,11 @@
  *  
  *  DO NOT EDIT THIS FILE   (flowreplay_opts.h)
  *  
- *  It has been AutoGen-ed  Saturday April 21, 2007 at 06:52:24 PM PDT
+ *  It has been AutoGen-ed  Thursday July 19, 2007 at 09:17:44 AM PDT
  *  From the definitions    flowreplay_opts.def
  *  and the template file   options
  *
- * Generated from AutoOpts 28:0:3 templates.
+ * Generated from AutoOpts 29:0:4 templates.
  */
 
 /*
@@ -66,7 +66,7 @@
  *  tolerable version is at least as old as what was current when the header
  *  template was released.
  */
-#define AO_TEMPLATE_VERSION 114688
+#define AO_TEMPLATE_VERSION 118784
 #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
  || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
 # error option template version mismatches autoopts/options.h header
@@ -148,10 +148,10 @@ typedef enum {
 #define VALUE_OPT_VERSION        'V'
 #define VALUE_OPT_LESS_HELP      'h'
 
-#define VALUE_OPT_SAVE_OPTS     INDEX_OPT_SAVE_OPTS
-#define VALUE_OPT_LOAD_OPTS     INDEX_OPT_LOAD_OPTS
 #define VALUE_OPT_HELP          'H'
 #define VALUE_OPT_MORE_HELP     '!'
+#define VALUE_OPT_SAVE_OPTS     INDEX_OPT_SAVE_OPTS
+#define VALUE_OPT_LOAD_OPTS     INDEX_OPT_LOAD_OPTS
 #define SET_OPT_SAVE_OPTS(a)   STMTS( \
         DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
         DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
@@ -166,7 +166,7 @@ typedef enum {
                 flowreplayOptions.pzCurOpt  = NULL )
 #define START_OPT       RESTART_OPT(1)
 #define USAGE(c)        (*flowreplayOptions.pUsageProc)( &flowreplayOptions, c )
-/* extracted from /opt/local/share/autogen/opthead.tpl near line 345 */
+/* extracted from /opt/local/share/autogen/opthead.tpl near line 360 */
 
 /* * * * * *
  *

+ 8 - 8
src/send_packets.c

@@ -1,4 +1,4 @@
-/* $Id: send_packets.c 1853 2007-05-02 04:40:39Z aturner $ */
+/* $Id: send_packets.c 1874 2007-07-10 05:36:43Z aturner $ */
 
 /*
  * Copyright (c) 2001-2007 Aaron Turner.
@@ -100,11 +100,11 @@ send_packets(pcap_t *pcap, int cache_file_idx)
         (void)signal(SIGINT, break_now);
     }
 
-	if (options.enable_file_cache) {
-		prev_packet = &cached_packet;
-	} else {
-		prev_packet = NULL;
-	}
+    if (options.enable_file_cache) {
+        prev_packet = &cached_packet;
+    } else {
+        prev_packet = NULL;
+    }
 
 	
     /* MAIN LOOP 
@@ -339,7 +339,7 @@ do_sleep(struct timeval *time, struct timeval *last, int len, int accurate, send
     dbgx(3, "Now time: " TIMEVAL_FORMAT, now.tv_sec, now.tv_usec);
 
     /* First time through for this file */
-    if (!timerisset(last)) {
+    if (pkts_sent == 0 || ((options.speed.mode != SPEED_MBPSRATE) && (counter == 0))) {
         start = now;
         timerclear(&delta);
         timerclear(&didsleep);
@@ -372,7 +372,7 @@ do_sleep(struct timeval *time, struct timeval *last, int len, int accurate, send
          * Ignore the time supplied by the capture file and send data at
          * a constant 'rate' (bytes per second).
          */
-        if (timerisset(last)) {
+        if (pkts_sent != 0) {
             n = (float)len / (options.speed.speed * 1024 * 1024 / 8); /* convert Mbps to bps */
             nap.tv_sec = n;
             nap.tv_usec = (n - nap.tv_sec) * 1000000;

+ 23 - 4
src/tcpbridge.1

@@ -1,7 +1,7 @@
-.TH TCPBRIDGE 1 2007-04-21 "(tcpbridge )" "Programmer's Manual"
+.TH TCPBRIDGE 1 2007-07-19 "(tcpbridge )" "Programmer's Manual"
 .\"  DO NOT EDIT THIS FILE   (tcpbridge.1)
 .\"  
-.\"  It has been AutoGen-ed  Saturday April 21, 2007 at 10:41:06 AM PDT
+.\"  It has been AutoGen-ed  Thursday July 19, 2007 at 09:17:46 AM PDT
 .\"  From the definitions    tcpbridge_opts.def
 .\"  and the template file   agman1.tpl
 .\"
@@ -24,7 +24,7 @@ subnets.  All packets received on one interface are sent via the other.
 Optionally, packets can be edited in a variety of ways according to your needs.
 
 For more details, please see the Tcpreplay Manual at:
-http://tcpreplay.synfin.net/wiki/manual
+http://tcpreplay.synfin.net/trac/wiki/manual
 .SH OPTIONS
 .SS ""
 .TP
@@ -54,6 +54,8 @@ you can reuse the same seed value to recreate the traffic.
 .BR \-N " \fIstring\fP, " \--pnat "=" \fIstring\fP
 Rewrite IP addresses using pseudo-NAT.
 This option may appear up to 2 times.
+This option must not appear in combination with any of the following options:
+srcipmap.
 .sp
 Takes a comma delimited series of colon delimited CIDR
 netblock pairs.  Each netblock pair is evaluated in order against
@@ -66,6 +68,24 @@ Example:
     \--pnat=192.168.0.0/16:10.77.0.0/16,172.16.0.0/12:10.1.0.0/24
 .fi
 .TP
+.BR \-S " \fIstring\fP, " \--srcipmap "=" \fIstring\fP
+Rewrite source IP addresses using pseudo-NAT.
+This option may appear up to 1 times.
+This option must not appear in combination with any of the following options:
+pnat.
+.sp
+Works just like the \--pnat option, but only affects the source IP
+addresses in the IPv4 header.
+.TP
+.BR \-D " \fIstring\fP, " \--dstipmap "=" \fIstring\fP
+Rewrite destination IP addresses using pseudo-NAT.
+This option may appear up to 1 times.
+This option must not appear in combination with any of the following options:
+pnat.
+.sp
+Works just like the \--pnat option, but only affects the destination IP
+addresses in the IPv4 header.
+.TP
 .BR \-e " \fIstring\fP, " \--endpoints "=" \fIstring\fP
 Rewrite IP addresses to be between two endpoints.
 This option may appear up to 1 times.
@@ -158,7 +178,6 @@ Cisco HDLC aka DLT_C_HDLC
 .sp 1
 \fBuser\fP
 User specified Layer 2 header and DLT type
-.sp 1
 .br
 .TP
 .BR \--enet-dmac "=\fIstring\fP"

+ 2 - 2
src/tcpbridge.c

@@ -1,4 +1,4 @@
-/* $Id: tcpbridge.c 1845 2007-04-27 02:48:10Z aturner $ */
+/* $Id: tcpbridge.c 1842 2007-04-26 04:34:11Z aturner $ */
 
 /*
  * Copyright (c) 2004-2005 Aaron Turner.
@@ -154,7 +154,7 @@ init(void)
 
 
 void 
-post_args(__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
+post_args(_U_ int argc, _U_ char *argv[])
 {
     char ebuf[SENDPACKET_ERRBUF_SIZE];
     char *intname;

+ 130 - 74
src/tcpbridge_opts.c

@@ -2,11 +2,11 @@
  *  
  *  DO NOT EDIT THIS FILE   (tcpbridge_opts.c)
  *  
- *  It has been AutoGen-ed  Saturday April 21, 2007 at 06:52:23 PM PDT
+ *  It has been AutoGen-ed  Thursday July 19, 2007 at 09:17:45 AM PDT
  *  From the definitions    tcpbridge_opts.def
  *  and the template file   options
  *
- * Generated from AutoOpts 28:0:3 templates.
+ * Generated from AutoOpts 29:0:4 templates.
  */
 
 /*
@@ -137,16 +137,48 @@ tSCC    zSeed_Name[]               = "seed";
         | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
 
 /*
- *  Pnat option description:
+ *  Pnat option description with
+ *  "Must also have options" and "Incompatible options":
  */
 tSCC    zPnatText[] =
         "Rewrite IP addresses using pseudo-NAT";
 tSCC    zPnat_NAME[]               = "PNAT";
 tSCC    zPnat_Name[]               = "pnat";
+static const int
+    aPnatCantList[] = {
+    INDEX_OPT_SRCIPMAP, NO_EQUIVALENT };
 #define PNAT_FLAGS       (OPTST_DISABLED | OPTST_STACKED \
         | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
 
 /*
+ *  Srcipmap option description with
+ *  "Must also have options" and "Incompatible options":
+ */
+tSCC    zSrcipmapText[] =
+        "Rewrite source IP addresses using pseudo-NAT";
+tSCC    zSrcipmap_NAME[]           = "SRCIPMAP";
+tSCC    zSrcipmap_Name[]           = "srcipmap";
+static const int
+    aSrcipmapCantList[] = {
+    INDEX_OPT_PNAT, NO_EQUIVALENT };
+#define SRCIPMAP_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Dstipmap option description with
+ *  "Must also have options" and "Incompatible options":
+ */
+tSCC    zDstipmapText[] =
+        "Rewrite destination IP addresses using pseudo-NAT";
+tSCC    zDstipmap_NAME[]           = "DSTIPMAP";
+tSCC    zDstipmap_Name[]           = "dstipmap";
+static const int
+    aDstipmapCantList[] = {
+    INDEX_OPT_PNAT, NO_EQUIVALENT };
+#define DSTIPMAP_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
  *  Endpoints option description with
  *  "Must also have options" and "Incompatible options":
  */
@@ -591,13 +623,37 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* opt state flags  */ PNAT_FLAGS, 0,
      /* last opt argumnt */ { NULL },
      /* arg list/cookie  */ NULL,
-     /* must/cannot opts */ NULL, NULL,
+     /* must/cannot opts */ NULL, aPnatCantList,
      /* option proc      */ optionStackArg,
      /* desc, NAME, name */ zPnatText, zPnat_NAME, zPnat_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 4, VALUE_OPT_ENDPOINTS,
-     /* equiv idx, value */ 4, VALUE_OPT_ENDPOINTS,
+  {  /* entry idx, value */ 4, VALUE_OPT_SRCIPMAP,
+     /* equiv idx, value */ 4, VALUE_OPT_SRCIPMAP,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ SRCIPMAP_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, aSrcipmapCantList,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zSrcipmapText, zSrcipmap_NAME, zSrcipmap_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 5, VALUE_OPT_DSTIPMAP,
+     /* equiv idx, value */ 5, VALUE_OPT_DSTIPMAP,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ DSTIPMAP_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, aDstipmapCantList,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zDstipmapText, zDstipmap_NAME, zDstipmap_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 6, VALUE_OPT_ENDPOINTS,
+     /* equiv idx, value */ 6, VALUE_OPT_ENDPOINTS,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ ENDPOINTS_FLAGS, 0,
@@ -608,8 +664,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zEndpointsText, zEndpoints_NAME, zEndpoints_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 5, VALUE_OPT_SKIPBROADCAST,
-     /* equiv idx, value */ 5, VALUE_OPT_SKIPBROADCAST,
+  {  /* entry idx, value */ 7, VALUE_OPT_SKIPBROADCAST,
+     /* equiv idx, value */ 7, VALUE_OPT_SKIPBROADCAST,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ SKIPBROADCAST_FLAGS, 0,
@@ -620,8 +676,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zSkipbroadcastText, zSkipbroadcast_NAME, zSkipbroadcast_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 6, VALUE_OPT_FIXCSUM,
-     /* equiv idx, value */ 6, VALUE_OPT_FIXCSUM,
+  {  /* entry idx, value */ 8, VALUE_OPT_FIXCSUM,
+     /* equiv idx, value */ 8, VALUE_OPT_FIXCSUM,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ FIXCSUM_FLAGS, 0,
@@ -632,8 +688,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zFixcsumText, zFixcsum_NAME, zFixcsum_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 7, VALUE_OPT_MTU,
-     /* equiv idx, value */ 7, VALUE_OPT_MTU,
+  {  /* entry idx, value */ 9, VALUE_OPT_MTU,
+     /* equiv idx, value */ 9, VALUE_OPT_MTU,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ MTU_FLAGS, 0,
@@ -644,8 +700,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zMtuText, zMtu_NAME, zMtu_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 8, VALUE_OPT_EFCS,
-     /* equiv idx, value */ 8, VALUE_OPT_EFCS,
+  {  /* entry idx, value */ 10, VALUE_OPT_EFCS,
+     /* equiv idx, value */ 10, VALUE_OPT_EFCS,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ EFCS_FLAGS, 0,
@@ -656,8 +712,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zEfcsText, zEfcs_NAME, zEfcs_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 9, VALUE_OPT_FIXLEN,
-     /* equiv idx, value */ 9, VALUE_OPT_FIXLEN,
+  {  /* entry idx, value */ 11, VALUE_OPT_FIXLEN,
+     /* equiv idx, value */ 11, VALUE_OPT_FIXLEN,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ FIXLEN_FLAGS, 0,
@@ -668,8 +724,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zFixlenText, zFixlen_NAME, zFixlen_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 10, VALUE_OPT_SKIPL2BROADCAST,
-     /* equiv idx, value */ 10, VALUE_OPT_SKIPL2BROADCAST,
+  {  /* entry idx, value */ 12, VALUE_OPT_SKIPL2BROADCAST,
+     /* equiv idx, value */ 12, VALUE_OPT_SKIPL2BROADCAST,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ SKIPL2BROADCAST_FLAGS, 0,
@@ -680,8 +736,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zSkipl2broadcastText, zSkipl2broadcast_NAME, zSkipl2broadcast_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 11, VALUE_OPT_DLT,
-     /* equiv idx, value */ 11, VALUE_OPT_DLT,
+  {  /* entry idx, value */ 13, VALUE_OPT_DLT,
+     /* equiv idx, value */ 13, VALUE_OPT_DLT,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ DLT_FLAGS, 0,
@@ -692,8 +748,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zDltText, zDlt_NAME, zDlt_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 12, VALUE_OPT_ENET_DMAC,
-     /* equiv idx, value */ 12, VALUE_OPT_ENET_DMAC,
+  {  /* entry idx, value */ 14, VALUE_OPT_ENET_DMAC,
+     /* equiv idx, value */ 14, VALUE_OPT_ENET_DMAC,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ ENET_DMAC_FLAGS, 0,
@@ -704,8 +760,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zEnet_DmacText, zEnet_Dmac_NAME, zEnet_Dmac_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 13, VALUE_OPT_ENET_SMAC,
-     /* equiv idx, value */ 13, VALUE_OPT_ENET_SMAC,
+  {  /* entry idx, value */ 15, VALUE_OPT_ENET_SMAC,
+     /* equiv idx, value */ 15, VALUE_OPT_ENET_SMAC,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ ENET_SMAC_FLAGS, 0,
@@ -716,8 +772,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zEnet_SmacText, zEnet_Smac_NAME, zEnet_Smac_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 14, VALUE_OPT_ENET_VLAN,
-     /* equiv idx, value */ 14, VALUE_OPT_ENET_VLAN,
+  {  /* entry idx, value */ 16, VALUE_OPT_ENET_VLAN,
+     /* equiv idx, value */ 16, VALUE_OPT_ENET_VLAN,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ ENET_VLAN_FLAGS, 0,
@@ -728,8 +784,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zEnet_VlanText, zEnet_Vlan_NAME, zEnet_Vlan_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 15, VALUE_OPT_ENET_VLAN_TAG,
-     /* equiv idx, value */ 15, VALUE_OPT_ENET_VLAN_TAG,
+  {  /* entry idx, value */ 17, VALUE_OPT_ENET_VLAN_TAG,
+     /* equiv idx, value */ 17, VALUE_OPT_ENET_VLAN_TAG,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ ENET_VLAN_TAG_FLAGS, 0,
@@ -740,8 +796,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zEnet_Vlan_TagText, zEnet_Vlan_Tag_NAME, zEnet_Vlan_Tag_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 16, VALUE_OPT_ENET_VLAN_CFI,
-     /* equiv idx, value */ 16, VALUE_OPT_ENET_VLAN_CFI,
+  {  /* entry idx, value */ 18, VALUE_OPT_ENET_VLAN_CFI,
+     /* equiv idx, value */ 18, VALUE_OPT_ENET_VLAN_CFI,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ ENET_VLAN_CFI_FLAGS, 0,
@@ -752,8 +808,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zEnet_Vlan_CfiText, zEnet_Vlan_Cfi_NAME, zEnet_Vlan_Cfi_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 17, VALUE_OPT_ENET_VLAN_PRI,
-     /* equiv idx, value */ 17, VALUE_OPT_ENET_VLAN_PRI,
+  {  /* entry idx, value */ 19, VALUE_OPT_ENET_VLAN_PRI,
+     /* equiv idx, value */ 19, VALUE_OPT_ENET_VLAN_PRI,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ ENET_VLAN_PRI_FLAGS, 0,
@@ -764,8 +820,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zEnet_Vlan_PriText, zEnet_Vlan_Pri_NAME, zEnet_Vlan_Pri_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 18, VALUE_OPT_HDLC_CONTROL,
-     /* equiv idx, value */ 18, VALUE_OPT_HDLC_CONTROL,
+  {  /* entry idx, value */ 20, VALUE_OPT_HDLC_CONTROL,
+     /* equiv idx, value */ 20, VALUE_OPT_HDLC_CONTROL,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ HDLC_CONTROL_FLAGS, 0,
@@ -776,8 +832,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zHdlc_ControlText, zHdlc_Control_NAME, zHdlc_Control_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 19, VALUE_OPT_HDLC_ADDRESS,
-     /* equiv idx, value */ 19, VALUE_OPT_HDLC_ADDRESS,
+  {  /* entry idx, value */ 21, VALUE_OPT_HDLC_ADDRESS,
+     /* equiv idx, value */ 21, VALUE_OPT_HDLC_ADDRESS,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ HDLC_ADDRESS_FLAGS, 0,
@@ -788,8 +844,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zHdlc_AddressText, zHdlc_Address_NAME, zHdlc_Address_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 20, VALUE_OPT_USER_DLT,
-     /* equiv idx, value */ 20, VALUE_OPT_USER_DLT,
+  {  /* entry idx, value */ 22, VALUE_OPT_USER_DLT,
+     /* equiv idx, value */ 22, VALUE_OPT_USER_DLT,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ USER_DLT_FLAGS, 0,
@@ -800,8 +856,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zUser_DltText, zUser_Dlt_NAME, zUser_Dlt_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 21, VALUE_OPT_USER_DLINK,
-     /* equiv idx, value */ 21, VALUE_OPT_USER_DLINK,
+  {  /* entry idx, value */ 23, VALUE_OPT_USER_DLINK,
+     /* equiv idx, value */ 23, VALUE_OPT_USER_DLINK,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 2, 0,
      /* opt state flags  */ USER_DLINK_FLAGS, 0,
@@ -812,8 +868,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zUser_DlinkText, zUser_Dlink_NAME, zUser_Dlink_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 22, VALUE_OPT_DBUG,
-     /* equiv idx, value */ 22, VALUE_OPT_DBUG,
+  {  /* entry idx, value */ 24, VALUE_OPT_DBUG,
+     /* equiv idx, value */ 24, VALUE_OPT_DBUG,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ DBUG_FLAGS, 0,
@@ -824,8 +880,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zDbugText, zDbug_NAME, zDbug_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 23, VALUE_OPT_INTF1,
-     /* equiv idx, value */ 23, VALUE_OPT_INTF1,
+  {  /* entry idx, value */ 25, VALUE_OPT_INTF1,
+     /* equiv idx, value */ 25, VALUE_OPT_INTF1,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 1, 1, 0,
      /* opt state flags  */ INTF1_FLAGS, 0,
@@ -836,8 +892,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zIntf1Text, zIntf1_NAME, zIntf1_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 24, VALUE_OPT_INTF2,
-     /* equiv idx, value */ 24, VALUE_OPT_INTF2,
+  {  /* entry idx, value */ 26, VALUE_OPT_INTF2,
+     /* equiv idx, value */ 26, VALUE_OPT_INTF2,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ INTF2_FLAGS, 0,
@@ -848,8 +904,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zIntf2Text, zIntf2_NAME, zIntf2_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 25, VALUE_OPT_UNIDIR,
-     /* equiv idx, value */ 25, VALUE_OPT_UNIDIR,
+  {  /* entry idx, value */ 27, VALUE_OPT_UNIDIR,
+     /* equiv idx, value */ 27, VALUE_OPT_UNIDIR,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ UNIDIR_FLAGS, 0,
@@ -860,8 +916,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zUnidirText, zUnidir_NAME, zUnidir_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 26, VALUE_OPT_LIMIT,
-     /* equiv idx, value */ 26, VALUE_OPT_LIMIT,
+  {  /* entry idx, value */ 28, VALUE_OPT_LIMIT,
+     /* equiv idx, value */ 28, VALUE_OPT_LIMIT,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ LIMIT_FLAGS, 0,
@@ -872,8 +928,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zLimitText, zLimit_NAME, zLimit_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 27, VALUE_OPT_INCLUDE,
-     /* equiv idx, value */ 27, VALUE_OPT_INCLUDE,
+  {  /* entry idx, value */ 29, VALUE_OPT_INCLUDE,
+     /* equiv idx, value */ 29, VALUE_OPT_INCLUDE,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ INCLUDE_FLAGS, 0,
@@ -884,8 +940,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zIncludeText, zInclude_NAME, zInclude_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 28, VALUE_OPT_EXCLUDE,
-     /* equiv idx, value */ 28, VALUE_OPT_EXCLUDE,
+  {  /* entry idx, value */ 30, VALUE_OPT_EXCLUDE,
+     /* equiv idx, value */ 30, VALUE_OPT_EXCLUDE,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ EXCLUDE_FLAGS, 0,
@@ -896,8 +952,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zExcludeText, zExclude_NAME, zExclude_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 29, VALUE_OPT_PID,
-     /* equiv idx, value */ 29, VALUE_OPT_PID,
+  {  /* entry idx, value */ 31, VALUE_OPT_PID,
+     /* equiv idx, value */ 31, VALUE_OPT_PID,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ PID_FLAGS, 0,
@@ -908,8 +964,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zPidText, zPid_NAME, zPid_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 30, VALUE_OPT_VERBOSE,
-     /* equiv idx, value */ 30, VALUE_OPT_VERBOSE,
+  {  /* entry idx, value */ 32, VALUE_OPT_VERBOSE,
+     /* equiv idx, value */ 32, VALUE_OPT_VERBOSE,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ VERBOSE_FLAGS, 0,
@@ -920,8 +976,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zVerboseText, zVerbose_NAME, zVerbose_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 31, VALUE_OPT_DECODE,
-     /* equiv idx, value */ 31, VALUE_OPT_DECODE,
+  {  /* entry idx, value */ 33, VALUE_OPT_DECODE,
+     /* equiv idx, value */ 33, VALUE_OPT_DECODE,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ DECODE_FLAGS, 0,
@@ -932,8 +988,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zDecodeText, zDecode_NAME, zDecode_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 32, VALUE_OPT_VERSION,
-     /* equiv idx, value */ 32, VALUE_OPT_VERSION,
+  {  /* entry idx, value */ 34, VALUE_OPT_VERSION,
+     /* equiv idx, value */ 34, VALUE_OPT_VERSION,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ VERSION_FLAGS, 0,
@@ -944,8 +1000,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* desc, NAME, name */ zVersionText, zVersion_NAME, zVersion_Name,
      /* disablement strs */ NULL, NULL },
 
-  {  /* entry idx, value */ 33, VALUE_OPT_LESS_HELP,
-     /* equiv idx, value */ 33, VALUE_OPT_LESS_HELP,
+  {  /* entry idx, value */ 35, VALUE_OPT_LESS_HELP,
+     /* equiv idx, value */ 35, VALUE_OPT_LESS_HELP,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ LESS_HELP_FLAGS, 0,
@@ -960,7 +1016,7 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* equiv idx value  */ NO_EQUIVALENT, 0,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
-     /* opt state flags  */ OPTST_IMM, 0,
+     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
      /* last opt argumnt */ { NULL },
      /* arg list/cookie  */ NULL,
      /* must/cannot opts */ NULL, NULL,
@@ -972,7 +1028,7 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* equiv idx value  */ NO_EQUIVALENT, 0,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
-     /* opt state flags  */ OPTST_IMM, 0,
+     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
      /* last opt argumnt */ { NULL },
      /* arg list/cookie  */ NULL,
      /* must/cannot opts */ NULL,  NULL,
@@ -985,7 +1041,7 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, 1, 0,
      /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
-                          | OPTST_ARG_OPTIONAL, 0,
+                          | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0,
      /* last opt argumnt */ { NULL },
      /* arg list/cookie  */ NULL,
      /* must/cannot opts */ NULL,  NULL,
@@ -997,8 +1053,8 @@ static tOptDesc optDesc[ OPTION_CT ] = {
      /* equiv idx value  */ NO_EQUIVALENT, 0,
      /* equivalenced to  */ NO_EQUIVALENT,
      /* min, max, act ct */ 0, NOLIMIT, 0,
-     /* opt state flags  */ OPTST_DISABLE_IMM | \
-			OPTST_SET_ARGTYPE(OPARG_TYPE_STRING), 0,
+     /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) \
+			  | OPTST_DISABLE_IMM, 0,
      /* last opt argumnt */ { NULL },
      /* arg list/cookie  */ NULL,
      /* must/cannot opts */ NULL, NULL,
@@ -1030,9 +1086,9 @@ The basic operation of tcpbridge is to be a network bridge between two\n\
 subnets.  All packets received on one interface are sent via the other.\n\n\
 Optionally, packets can be edited in a variety of ways according to your needs.\n\n\
 For more details, please see the Tcpreplay Manual at:\n\
-http://tcpreplay.synfin.net/wiki/manual\n";
+http://tcpreplay.synfin.net/trac/wiki/manual\n";
 #define zFullVersion    NULL
-/* extracted from /opt/local/share/autogen/optcode.tpl near line 378 */
+/* extracted from /opt/local/share/autogen/optcode.tpl near line 408 */
 
 #if defined(ENABLE_NLS)
 # define OPTPROC_BASE OPTPROC_TRANSLATE
@@ -1068,9 +1124,9 @@ tOptions tcpbridgeOptions = {
     { INDEX_OPT_MORE_HELP,
       INDEX_OPT_SAVE_OPTS,
       NO_EQUIVALENT /* index of '-#' option */,
-      7 /* index of default opt */
+      9 /* index of default opt */
     },
-    OPTION_CT, 34 /* user option count */
+    40 /* full option count */, 36 /* user option count */
 };
 
 /*
@@ -1509,7 +1565,7 @@ doOptLess_Help(
 
 }
 
-/* extracted from /opt/local/share/autogen/optcode.tpl near line 475 */
+/* extracted from /opt/local/share/autogen/optcode.tpl near line 514 */
 
 #if ENABLE_NLS
 #include <stdio.h>

+ 1 - 1
src/tcpbridge_opts.def

@@ -53,7 +53,7 @@ subnets.  All packets received on one interface are sent via the other.
 Optionally, packets can be edited in a variety of ways according to your needs.
 
 For more details, please see the Tcpreplay Manual at:
-http://tcpreplay.synfin.net/wiki/manual
+http://tcpreplay.synfin.net/trac/wiki/manual
 EODetail;
 
 man-doc = <<- EOMan

+ 58 - 54
src/tcpbridge_opts.h

@@ -2,11 +2,11 @@
  *  
  *  DO NOT EDIT THIS FILE   (tcpbridge_opts.h)
  *  
- *  It has been AutoGen-ed  Saturday April 21, 2007 at 06:52:23 PM PDT
+ *  It has been AutoGen-ed  Thursday July 19, 2007 at 09:17:44 AM PDT
  *  From the definitions    tcpbridge_opts.def
  *  and the template file   options
  *
- * Generated from AutoOpts 28:0:3 templates.
+ * Generated from AutoOpts 29:0:4 templates.
  */
 
 /*
@@ -66,7 +66,7 @@
  *  tolerable version is at least as old as what was current when the header
  *  template was released.
  */
-#define AO_TEMPLATE_VERSION 114688
+#define AO_TEMPLATE_VERSION 118784
 #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
  || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
 # error option template version mismatches autoopts/options.h header
@@ -80,43 +80,45 @@ typedef enum {
         INDEX_OPT_PORTMAP          =  1,
         INDEX_OPT_SEED             =  2,
         INDEX_OPT_PNAT             =  3,
-        INDEX_OPT_ENDPOINTS        =  4,
-        INDEX_OPT_SKIPBROADCAST    =  5,
-        INDEX_OPT_FIXCSUM          =  6,
-        INDEX_OPT_MTU              =  7,
-        INDEX_OPT_EFCS             =  8,
-        INDEX_OPT_FIXLEN           =  9,
-        INDEX_OPT_SKIPL2BROADCAST  = 10,
-        INDEX_OPT_DLT              = 11,
-        INDEX_OPT_ENET_DMAC        = 12,
-        INDEX_OPT_ENET_SMAC        = 13,
-        INDEX_OPT_ENET_VLAN        = 14,
-        INDEX_OPT_ENET_VLAN_TAG    = 15,
-        INDEX_OPT_ENET_VLAN_CFI    = 16,
-        INDEX_OPT_ENET_VLAN_PRI    = 17,
-        INDEX_OPT_HDLC_CONTROL     = 18,
-        INDEX_OPT_HDLC_ADDRESS     = 19,
-        INDEX_OPT_USER_DLT         = 20,
-        INDEX_OPT_USER_DLINK       = 21,
-        INDEX_OPT_DBUG             = 22,
-        INDEX_OPT_INTF1            = 23,
-        INDEX_OPT_INTF2            = 24,
-        INDEX_OPT_UNIDIR           = 25,
-        INDEX_OPT_LIMIT            = 26,
-        INDEX_OPT_INCLUDE          = 27,
-        INDEX_OPT_EXCLUDE          = 28,
-        INDEX_OPT_PID              = 29,
-        INDEX_OPT_VERBOSE          = 30,
-        INDEX_OPT_DECODE           = 31,
-        INDEX_OPT_VERSION          = 32,
-        INDEX_OPT_LESS_HELP        = 33,
-        INDEX_OPT_HELP             = 34,
-        INDEX_OPT_MORE_HELP        = 35,
-        INDEX_OPT_SAVE_OPTS        = 36,
-        INDEX_OPT_LOAD_OPTS        = 37
+        INDEX_OPT_SRCIPMAP         =  4,
+        INDEX_OPT_DSTIPMAP         =  5,
+        INDEX_OPT_ENDPOINTS        =  6,
+        INDEX_OPT_SKIPBROADCAST    =  7,
+        INDEX_OPT_FIXCSUM          =  8,
+        INDEX_OPT_MTU              =  9,
+        INDEX_OPT_EFCS             = 10,
+        INDEX_OPT_FIXLEN           = 11,
+        INDEX_OPT_SKIPL2BROADCAST  = 12,
+        INDEX_OPT_DLT              = 13,
+        INDEX_OPT_ENET_DMAC        = 14,
+        INDEX_OPT_ENET_SMAC        = 15,
+        INDEX_OPT_ENET_VLAN        = 16,
+        INDEX_OPT_ENET_VLAN_TAG    = 17,
+        INDEX_OPT_ENET_VLAN_CFI    = 18,
+        INDEX_OPT_ENET_VLAN_PRI    = 19,
+        INDEX_OPT_HDLC_CONTROL     = 20,
+        INDEX_OPT_HDLC_ADDRESS     = 21,
+        INDEX_OPT_USER_DLT         = 22,
+        INDEX_OPT_USER_DLINK       = 23,
+        INDEX_OPT_DBUG             = 24,
+        INDEX_OPT_INTF1            = 25,
+        INDEX_OPT_INTF2            = 26,
+        INDEX_OPT_UNIDIR           = 27,
+        INDEX_OPT_LIMIT            = 28,
+        INDEX_OPT_INCLUDE          = 29,
+        INDEX_OPT_EXCLUDE          = 30,
+        INDEX_OPT_PID              = 31,
+        INDEX_OPT_VERBOSE          = 32,
+        INDEX_OPT_DECODE           = 33,
+        INDEX_OPT_VERSION          = 34,
+        INDEX_OPT_LESS_HELP        = 35,
+        INDEX_OPT_HELP             = 36,
+        INDEX_OPT_MORE_HELP        = 37,
+        INDEX_OPT_SAVE_OPTS        = 38,
+        INDEX_OPT_LOAD_OPTS        = 39
 } teOptIndex;
 
-#define OPTION_CT    38
+#define OPTION_CT    40
 
 /*
  *  Interface defines for all options.  Replace "n" with the UPPER_CASED
@@ -146,6 +148,8 @@ typedef enum {
 #define VALUE_OPT_SEED           's'
 #define OPT_VALUE_SEED           (DESC(SEED).optArg.argInt)
 #define VALUE_OPT_PNAT           'N'
+#define VALUE_OPT_SRCIPMAP       'S'
+#define VALUE_OPT_DSTIPMAP       'D'
 #ifdef HAVE_CACHEFILE_SUPPORT
 #define VALUE_OPT_ENDPOINTS      'e'
 #endif /* HAVE_CACHEFILE_SUPPORT */
@@ -155,24 +159,24 @@ typedef enum {
 #define OPT_VALUE_MTU            (DESC(MTU).optArg.argInt)
 #define VALUE_OPT_EFCS           'E'
 #define VALUE_OPT_FIXLEN         'F'
-#define VALUE_OPT_SKIPL2BROADCAST 10
-#define VALUE_OPT_DLT            11
-#define VALUE_OPT_ENET_DMAC      12
-#define VALUE_OPT_ENET_SMAC      13
-#define VALUE_OPT_ENET_VLAN      14
-#define VALUE_OPT_ENET_VLAN_TAG  15
+#define VALUE_OPT_SKIPL2BROADCAST 12
+#define VALUE_OPT_DLT            13
+#define VALUE_OPT_ENET_DMAC      14
+#define VALUE_OPT_ENET_SMAC      15
+#define VALUE_OPT_ENET_VLAN      16
+#define VALUE_OPT_ENET_VLAN_TAG  17
 #define OPT_VALUE_ENET_VLAN_TAG  (DESC(ENET_VLAN_TAG).optArg.argInt)
-#define VALUE_OPT_ENET_VLAN_CFI  16
+#define VALUE_OPT_ENET_VLAN_CFI  18
 #define OPT_VALUE_ENET_VLAN_CFI  (DESC(ENET_VLAN_CFI).optArg.argInt)
-#define VALUE_OPT_ENET_VLAN_PRI  17
+#define VALUE_OPT_ENET_VLAN_PRI  19
 #define OPT_VALUE_ENET_VLAN_PRI  (DESC(ENET_VLAN_PRI).optArg.argInt)
-#define VALUE_OPT_HDLC_CONTROL   18
+#define VALUE_OPT_HDLC_CONTROL   20
 #define OPT_VALUE_HDLC_CONTROL   (DESC(HDLC_CONTROL).optArg.argInt)
-#define VALUE_OPT_HDLC_ADDRESS   19
+#define VALUE_OPT_HDLC_ADDRESS   21
 #define OPT_VALUE_HDLC_ADDRESS   (DESC(HDLC_ADDRESS).optArg.argInt)
-#define VALUE_OPT_USER_DLT       20
+#define VALUE_OPT_USER_DLT       22
 #define OPT_VALUE_USER_DLT       (DESC(USER_DLT).optArg.argInt)
-#define VALUE_OPT_USER_DLINK     21
+#define VALUE_OPT_USER_DLINK     23
 #ifdef DEBUG
 #define VALUE_OPT_DBUG           'd'
 #define OPT_VALUE_DBUG           (DESC(DBUG).optArg.argInt)
@@ -188,7 +192,7 @@ typedef enum {
 #ifdef ENABLE_VERBOSE
 #define VALUE_OPT_VERBOSE        'v'
 #define SET_OPT_VERBOSE   STMTS( \
-        DESC(VERBOSE).optActualIndex = 30; \
+        DESC(VERBOSE).optActualIndex = 32; \
         DESC(VERBOSE).optActualValue = VALUE_OPT_VERBOSE; \
         DESC(VERBOSE).fOptState &= OPTST_PERSISTENT_MASK; \
         DESC(VERBOSE).fOptState |= OPTST_SET )
@@ -199,10 +203,10 @@ typedef enum {
 #define VALUE_OPT_VERSION        'V'
 #define VALUE_OPT_LESS_HELP      'h'
 
-#define VALUE_OPT_SAVE_OPTS     INDEX_OPT_SAVE_OPTS
-#define VALUE_OPT_LOAD_OPTS     INDEX_OPT_LOAD_OPTS
 #define VALUE_OPT_HELP          'H'
 #define VALUE_OPT_MORE_HELP     '!'
+#define VALUE_OPT_SAVE_OPTS     INDEX_OPT_SAVE_OPTS
+#define VALUE_OPT_LOAD_OPTS     INDEX_OPT_LOAD_OPTS
 #define SET_OPT_SAVE_OPTS(a)   STMTS( \
         DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
         DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
@@ -217,7 +221,7 @@ typedef enum {
                 tcpbridgeOptions.pzCurOpt  = NULL )
 #define START_OPT       RESTART_OPT(1)
 #define USAGE(c)        (*tcpbridgeOptions.pUsageProc)( &tcpbridgeOptions, c )
-/* extracted from /opt/local/share/autogen/opthead.tpl near line 345 */
+/* extracted from /opt/local/share/autogen/opthead.tpl near line 360 */
 
 /* * * * * *
  *

BIN
src/tcpedit/._edit_packet.c


+ 108 - 15
src/tcpedit/Makefile.in

@@ -19,7 +19,7 @@
 
 # $Id: $
 
-# $Id:$
+# $Id: Makefile.am 1830 2007-04-21 07:33:54Z aturner $
 # START OF: dlt_en10mb
 # Note, if you add any files to your plugin, you will need to edit dlt_<plugin>/Makefile.am
 # add your .c files to libdltplugin_a_SOURCES
@@ -27,7 +27,7 @@
 # add any other files (like documentation, notes, etc) to EXTRA_DIST
 # add your dependancy information (see comment below)
 
-# $Id:$
+# $Id: Makefile.am 1830 2007-04-21 07:33:54Z aturner $
 # START OF: dlt_hdlc
 # Note, if you add any files to your plugin, you will need to edit dlt_<plugin>/Makefile.am
 # add your .c files to libtcpedit_a_SOURCES
@@ -35,7 +35,7 @@
 # add any other files (like documentation, notes, etc) to EXTRA_DIST
 # add your dependancy information (see comment below)
 
-# $Id:$
+# $Id: Makefile.am 1830 2007-04-21 07:33:54Z aturner $
 # START OF: dlt_user
 # Note, if you add any files to your plugin, you will need to edit dlt_<plugin>/Makefile.am
 # add your .c files to libtcpedit_a_SOURCES
@@ -43,7 +43,7 @@
 # add any other files (like documentation, notes, etc) to EXTRA_DIST
 # add your dependancy information (see comment below)
 
-# $Id:$
+# $Id: Makefile.am 1830 2007-04-21 07:33:54Z aturner $
 # START OF: dlt_raw
 # Note, if you add any files to your plugin, you will need to edit dlt_<plugin>/Makefile.am
 # add your .c files to libtcpedit_a_SOURCES
@@ -51,7 +51,7 @@
 # add any other files (like documentation, notes, etc) to EXTRA_DIST
 # add your dependancy information (see comment below)
 
-# $Id:$
+# $Id: Makefile.am 1830 2007-04-21 07:33:54Z aturner $
 # START OF: dlt_null
 # Note, if you add any files to your plugin, you will need to edit dlt_<plugin>/Makefile.am
 # add your .c files to libtcpedit_a_SOURCES
@@ -59,7 +59,7 @@
 # add any other files (like documentation, notes, etc) to EXTRA_DIST
 # add your dependancy information (see comment below)
 
-# $Id:$
+# $Id: Makefile.am 1830 2007-04-21 07:33:54Z aturner $
 # START OF: dlt_loop
 # Note, if you add any files to your plugin, you will need to edit dlt_<plugin>/Makefile.am
 # add your .c files to libtcpedit_a_SOURCES
@@ -67,7 +67,7 @@
 # add any other files (like documentation, notes, etc) to EXTRA_DIST
 # add your dependancy information (see comment below)
 
-# $Id:$
+# $Id: Makefile.am 1830 2007-04-21 07:33:54Z aturner $
 # START OF: dlt_linuxsll
 # Note, if you add any files to your plugin, you will need to edit dlt_<plugin>/Makefile.am
 # add your .c files to libtcpedit_a_SOURCES
@@ -75,6 +75,22 @@
 # add any other files (like documentation, notes, etc) to EXTRA_DIST
 # add your dependancy information (see comment below)
 
+# $Id: Makefile.am 1838 2007-04-22 18:23:38Z aturner $
+# START OF: dlt_ieee80211
+# Note, if you add any files to your plugin, you will need to edit dlt_ieee80211/Makefile.am
+# add your .c files to libtcpedit_a_SOURCES
+# add your .h files to noinst_HEADERS
+# add any other files (like documentation, notes, etc) to EXTRA_DIST
+# add your dependancy information (see comment below)
+
+# $Id: Makefile.am 1869 2007-05-12 19:53:15Z aturner $
+# START OF: dlt_radiotap
+# Note, if you add any files to your plugin, you will need to edit dlt_radiotap/Makefile.am
+# add your .c files to libtcpedit_a_SOURCES
+# add your .h files to noinst_HEADERS
+# add any other files (like documentation, notes, etc) to EXTRA_DIST
+# add your dependancy information (see comment below)
+
 
 VPATH = @srcdir@
 pkgdatadir = $(datadir)/@PACKAGE@
@@ -99,9 +115,11 @@ DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
 	$(srcdir)/Makefile.in $(srcdir)/plugins/Makefile.am \
 	$(srcdir)/plugins/dlt_en10mb/Makefile.am \
 	$(srcdir)/plugins/dlt_hdlc/Makefile.am \
+	$(srcdir)/plugins/dlt_ieee80211/Makefile.am \
 	$(srcdir)/plugins/dlt_linuxsll/Makefile.am \
 	$(srcdir)/plugins/dlt_loop/Makefile.am \
 	$(srcdir)/plugins/dlt_null/Makefile.am \
+	$(srcdir)/plugins/dlt_radiotap/Makefile.am \
 	$(srcdir)/plugins/dlt_raw/Makefile.am \
 	$(srcdir)/plugins/dlt_user/Makefile.am
 subdir = src/tcpedit
@@ -121,7 +139,8 @@ am_libtcpedit_a_OBJECTS = tcpedit.$(OBJEXT) parse_args.$(OBJEXT) \
 	checksum.$(OBJEXT) dlt_plugins.$(OBJEXT) ethernet.$(OBJEXT) \
 	dlt_utils.$(OBJEXT) en10mb.$(OBJEXT) hdlc.$(OBJEXT) \
 	user.$(OBJEXT) raw.$(OBJEXT) null.$(OBJEXT) loop.$(OBJEXT) \
-	linuxsll.$(OBJEXT)
+	linuxsll.$(OBJEXT) ieee80211.$(OBJEXT) ieee80211_hdr.$(OBJEXT) \
+	radiotap.$(OBJEXT)
 libtcpedit_a_OBJECTS = $(am_libtcpedit_a_OBJECTS)
 DEFAULT_INCLUDES = -I. -I$(top_builddir)/src@am__isrc@
 depcomp = $(SHELL) $(top_srcdir)/config/depcomp
@@ -268,7 +287,7 @@ target_alias = @target_alias@
 target_cpu = @target_cpu@
 target_os = @target_os@
 target_vendor = @target_vendor@
-td = @td@
+tcpdump_path = @tcpdump_path@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 noinst_LIBRARIES = libtcpedit.a
@@ -282,7 +301,10 @@ libtcpedit_a_SOURCES = tcpedit.c parse_args.c edit_packet.c portmap.c \
 	$(srcdir)/plugins/dlt_raw/raw.c \
 	$(srcdir)/plugins/dlt_null/null.c \
 	$(srcdir)/plugins/dlt_loop/loop.c \
-	$(srcdir)/plugins/dlt_linuxsll/linuxsll.c
+	$(srcdir)/plugins/dlt_linuxsll/linuxsll.c \
+	$(srcdir)/plugins/dlt_ieee80211/ieee80211.c \
+	$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c \
+	$(srcdir)/plugins/dlt_radiotap/radiotap.c
 AM_CFLAGS = -I.. -I../common -I../.. $(LIBOPTS_CFLAGS) $(LNAV_CFLAGS) \
 	-I. -I$(srcdir)/plugins -I$(srcdir)/../common \
 	$(LIBOPTS_CFLAGS)
@@ -297,14 +319,19 @@ noinst_HEADERS = tcpedit.h edit_packet.h portmap.h tcpedit_stub.h \
 	$(srcdir)/plugins/dlt_raw/raw.h \
 	$(srcdir)/plugins/dlt_null/null.h \
 	$(srcdir)/plugins/dlt_loop/loop.h \
-	$(srcdir)/plugins/dlt_linuxsll/linuxsll.h
+	$(srcdir)/plugins/dlt_linuxsll/linuxsll.h \
+	$(srcdir)/plugins/dlt_ieee80211/ieee80211.h \
+	$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.h \
+	$(srcdir)/plugins/dlt_radiotap/radiotap.h
 
 # You probably don't want to touch anything below this line until the end of the plugin
 MOSTLYCLEANFILES = *~ $(srcdir)/plugins/*~ \
 	$(srcdir)/plugins/dlt_en10mb/*~ $(srcdir)/plugins/dlt_hdlc/*~ \
 	$(srcdir)/plugins/dlt_user/*~ $(srcdir)/plugins/dlt_raw/*~ \
 	$(srcdir)/plugins/dlt_null/*~ $(srcdir)/plugins/dlt_loop/*~ \
-	$(srcdir)/plugins/dlt_linuxsll/*~
+	$(srcdir)/plugins/dlt_linuxsll/*~ \
+	$(srcdir)/plugins/dlt_ieee80211/*~ \
+	$(srcdir)/plugins/dlt_radiotap/*~
 MAINTAINERCLEANFILES = Makefile.in tcpedit_stub.h tcpedit.1 \
 	Makefile.in
 EXTRA_DIST = tcpedit_stub.def tcpedit_opts.def \
@@ -315,7 +342,9 @@ EXTRA_DIST = tcpedit_stub.def tcpedit_opts.def \
 	$(srcdir)/plugins/dlt_raw/raw_opts.def \
 	$(srcdir)/plugins/dlt_null/null_opts.def \
 	$(srcdir)/plugins/dlt_loop/loop_opts.def \
-	$(srcdir)/plugins/dlt_linuxsll/linuxsll_opts.def
+	$(srcdir)/plugins/dlt_linuxsll/linuxsll_opts.def \
+	$(srcdir)/plugins/dlt_ieee80211/ieee80211_opts.def \
+	$(srcdir)/plugins/dlt_radiotap/radiotap_opts.def
 
 # Note:
 # You probably don't want to touch anything below this line until the end of the plugin
@@ -329,19 +358,25 @@ EXTRA_DIST = tcpedit_stub.def tcpedit_opts.def \
 # You probably don't want to touch anything below this line until the end of the plugin
 
 # You probably don't want to touch anything below this line until the end of the plugin
+
+# You probably don't want to touch anything below this line until the end of the plugin
+
+# You probably don't want to touch anything below this line until the end of the plugin
 DLT_STUB_DEPS = $(srcdir)/plugins/dlt_opts.def \
 	$(srcdir)/plugins/dlt_en10mb/en10mb_opts.def \
 	$(srcdir)/plugins/dlt_user/user_opts.def \
 	$(srcdir)/plugins/dlt_raw/raw_opts.def \
 	$(srcdir)/plugins/dlt_null/null_opts.def \
 	$(srcdir)/plugins/dlt_loop/loop_opts.def \
-	$(srcdir)/plugins/dlt_linuxsll/linuxsll_opts.def
+	$(srcdir)/plugins/dlt_linuxsll/linuxsll_opts.def \
+	$(srcdir)/plugins/dlt_ieee80211/ieee80211_opts.def \
+	$(srcdir)/plugins/dlt_radiotap/radiotap_opts.def
 all: $(BUILT_SOURCES)
 	$(MAKE) $(AM_MAKEFLAGS) all-am
 
 .SUFFIXES:
 .SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/plugins/Makefile.am $(srcdir)/plugins/dlt_en10mb/Makefile.am $(srcdir)/plugins/dlt_hdlc/Makefile.am $(srcdir)/plugins/dlt_user/Makefile.am $(srcdir)/plugins/dlt_raw/Makefile.am $(srcdir)/plugins/dlt_null/Makefile.am $(srcdir)/plugins/dlt_loop/Makefile.am $(srcdir)/plugins/dlt_linuxsll/Makefile.am $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/plugins/Makefile.am $(srcdir)/plugins/dlt_en10mb/Makefile.am $(srcdir)/plugins/dlt_hdlc/Makefile.am $(srcdir)/plugins/dlt_user/Makefile.am $(srcdir)/plugins/dlt_raw/Makefile.am $(srcdir)/plugins/dlt_null/Makefile.am $(srcdir)/plugins/dlt_loop/Makefile.am $(srcdir)/plugins/dlt_linuxsll/Makefile.am $(srcdir)/plugins/dlt_ieee80211/Makefile.am $(srcdir)/plugins/dlt_radiotap/Makefile.am $(am__configure_deps)
 	@for dep in $?; do \
 	  case '$(am__configure_deps)' in \
 	    *$$dep*) \
@@ -392,11 +427,14 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/en10mb.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ethernet.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hdlc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ieee80211.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ieee80211_hdr.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linuxsll.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loop.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/null.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse_args.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/portmap.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/radiotap.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/raw.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpedit.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/user.Po@am__quote@
@@ -562,6 +600,48 @@ linuxsll.obj: $(srcdir)/plugins/dlt_linuxsll/linuxsll.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o linuxsll.obj `if test -f '$(srcdir)/plugins/dlt_linuxsll/linuxsll.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_linuxsll/linuxsll.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_linuxsll/linuxsll.c'; fi`
 
+ieee80211.o: $(srcdir)/plugins/dlt_ieee80211/ieee80211.c
+@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ieee80211.o -MD -MP -MF $(DEPDIR)/ieee80211.Tpo -c -o ieee80211.o `test -f '$(srcdir)/plugins/dlt_ieee80211/ieee80211.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_ieee80211/ieee80211.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/ieee80211.Tpo $(DEPDIR)/ieee80211.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$(srcdir)/plugins/dlt_ieee80211/ieee80211.c' object='ieee80211.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ieee80211.o `test -f '$(srcdir)/plugins/dlt_ieee80211/ieee80211.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_ieee80211/ieee80211.c
+
+ieee80211.obj: $(srcdir)/plugins/dlt_ieee80211/ieee80211.c
+@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ieee80211.obj -MD -MP -MF $(DEPDIR)/ieee80211.Tpo -c -o ieee80211.obj `if test -f '$(srcdir)/plugins/dlt_ieee80211/ieee80211.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_ieee80211/ieee80211.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_ieee80211/ieee80211.c'; fi`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/ieee80211.Tpo $(DEPDIR)/ieee80211.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$(srcdir)/plugins/dlt_ieee80211/ieee80211.c' object='ieee80211.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ieee80211.obj `if test -f '$(srcdir)/plugins/dlt_ieee80211/ieee80211.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_ieee80211/ieee80211.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_ieee80211/ieee80211.c'; fi`
+
+ieee80211_hdr.o: $(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c
+@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ieee80211_hdr.o -MD -MP -MF $(DEPDIR)/ieee80211_hdr.Tpo -c -o ieee80211_hdr.o `test -f '$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/ieee80211_hdr.Tpo $(DEPDIR)/ieee80211_hdr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c' object='ieee80211_hdr.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ieee80211_hdr.o `test -f '$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c
+
+ieee80211_hdr.obj: $(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c
+@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ieee80211_hdr.obj -MD -MP -MF $(DEPDIR)/ieee80211_hdr.Tpo -c -o ieee80211_hdr.obj `if test -f '$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c'; fi`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/ieee80211_hdr.Tpo $(DEPDIR)/ieee80211_hdr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c' object='ieee80211_hdr.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ieee80211_hdr.obj `if test -f '$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c'; fi`
+
+radiotap.o: $(srcdir)/plugins/dlt_radiotap/radiotap.c
+@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT radiotap.o -MD -MP -MF $(DEPDIR)/radiotap.Tpo -c -o radiotap.o `test -f '$(srcdir)/plugins/dlt_radiotap/radiotap.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_radiotap/radiotap.c
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/radiotap.Tpo $(DEPDIR)/radiotap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$(srcdir)/plugins/dlt_radiotap/radiotap.c' object='radiotap.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o radiotap.o `test -f '$(srcdir)/plugins/dlt_radiotap/radiotap.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_radiotap/radiotap.c
+
+radiotap.obj: $(srcdir)/plugins/dlt_radiotap/radiotap.c
+@am__fastdepCC_TRUE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT radiotap.obj -MD -MP -MF $(DEPDIR)/radiotap.Tpo -c -o radiotap.obj `if test -f '$(srcdir)/plugins/dlt_radiotap/radiotap.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_radiotap/radiotap.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_radiotap/radiotap.c'; fi`
+@am__fastdepCC_TRUE@	mv -f $(DEPDIR)/radiotap.Tpo $(DEPDIR)/radiotap.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$(srcdir)/plugins/dlt_radiotap/radiotap.c' object='radiotap.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o radiotap.obj `if test -f '$(srcdir)/plugins/dlt_radiotap/radiotap.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_radiotap/radiotap.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_radiotap/radiotap.c'; fi`
+
 mostlyclean-libtool:
 	-rm -f *.lo
 
@@ -807,6 +887,19 @@ $(srcdir)/plugins/dlt_linuxsll/linuxsll.c:  $(srcdir)/tcpedit_stub.h $(srcdir)/p
 
 # END OF: dlt_linuxsll
 
+# dependancies for your plugin source code.  Edit as necessary
+$(srcdir)/plugins/dlt_ieee80211/ieee80211.c:  $(srcdir)/tcpedit_stub.h $(srcdir)/plugins/dlt_utils.h \
+	$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c $(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.h \
+	$(srcdir)/plugins/dlt_ieee80211/ieee80211.h $(srcdir)/plugins/dlt_plugins.h $(srcdir)/plugins/dlt_plugins-int.h
+
+# END OF: dlt_ieee80211
+
+# dependancies for your plugin source code.  Edit as necessary
+$(srcdir)/plugins/dlt_radiotap/radiotap.c:  $(srcdir)/tcpedit_stub.h $(srcdir)/plugins/dlt_utils.h \
+	$(srcdir)/plugins/dlt_radiotap/radiotap.h $(srcdir)/plugins/dlt_plugins.h $(srcdir)/plugins/dlt_plugins-int.h
+
+# END OF: dlt_radiotap
+
 ########################################################
 # Add your plugin Makefile.am's below this line
 ########################################################

+ 18 - 2
src/tcpedit/edit_packet.c

@@ -1,4 +1,4 @@
-/* $Id: edit_packet.c 1797 2007-04-12 01:16:08Z aturner $ */
+/* $Id: edit_packet.c 1873 2007-07-10 03:51:46Z aturner $ */
 
 /*
  * Copyright (c) 2001-2007 Aaron Turner.
@@ -333,6 +333,7 @@ remap_ipv4(tcpedit_t *tcpedit, tcpr_cidr_t *cidr, const u_int32_t original)
 /*
  * rewrite IP address (layer3)
  * uses -N to rewrite (map) one subnet onto another subnet
+ * also support --srcipmap and --dstipmap
  * return 0 if no change, 1 or 2 if changed
  */
 int
@@ -344,7 +345,22 @@ rewrite_ipv4l3(tcpedit_t *tcpedit, ipv4_hdr_t *ip_hdr, tcpr_dir_t direction)
     assert(tcpedit);
     assert(ip_hdr);
 
-    /* anything to rewrite? */
+    /* first check the src/dst IP maps */
+    if (tcpedit->srcipmap != NULL) {
+        if (ip_in_cidr(tcpedit->srcipmap->from, ip_hdr->ip_src.s_addr)) {
+            ip_hdr->ip_src.s_addr = remap_ipv4(tcpedit, tcpedit->srcipmap->to, ip_hdr->ip_src.s_addr);
+            dbgx(2, "Remapped src addr to: %s", get_addr2name4(ip_hdr->ip_src.s_addr, RESOLVE));
+        }
+    }
+
+    if (tcpedit->dstipmap != NULL) {
+        if (ip_in_cidr(tcpedit->dstipmap->from, ip_hdr->ip_dst.s_addr)) {
+            ip_hdr->ip_dst.s_addr = remap_ipv4(tcpedit, tcpedit->dstipmap->to, ip_hdr->ip_dst.s_addr);
+            dbgx(2, "Remapped src addr to: %s", get_addr2name4(ip_hdr->ip_dst.s_addr, RESOLVE));
+        }
+    }
+
+    /* anything else to rewrite? */
     if (tcpedit->cidrmap1 == NULL)
         return(0);
 

+ 21 - 1
src/tcpedit/parse_args.c

@@ -1,4 +1,4 @@
-/* $Id: parse_args.c 1758 2007-03-22 06:10:49Z aturner $ */
+/* $Id: parse_args.c 1873 2007-07-10 03:51:46Z aturner $ */
 
 /*
  * Copyright (c) 2006 Aaron Turner.
@@ -84,6 +84,26 @@ tcpedit_post_args(tcpedit_t **tcpedit_ex) {
             first = 0;
         } while (--ct > 0);
     }
+    
+    /* --srcipmap */
+    if (HAVE_OPT(SRCIPMAP)) {
+        tcpedit->rewrite_ip ++;
+        if (! parse_cidr_map(&tcpedit->srcipmap, OPT_ARG(SRCIPMAP))) {
+            tcpedit_seterr(tcpedit, 
+                "Unable to parse --srcipmap=%s", OPT_ARG(SRCIPMAP));
+            return -1;
+        }
+    }
+
+    /* --dstipmap */
+    if (HAVE_OPT(DSTIPMAP)) {
+        tcpedit->rewrite_ip ++;
+        if (! parse_cidr_map(&tcpedit->dstipmap, OPT_ARG(DSTIPMAP))) {
+            tcpedit_seterr(tcpedit, 
+                "Unable to parse --dstipmap=%s", OPT_ARG(DSTIPMAP));
+            return -1;
+        }
+    }
 
     /*
      * If we have one and only one -N, then use the same map data

+ 2 - 0
src/tcpedit/plugins/Makefile.am

@@ -29,3 +29,5 @@ include $(srcdir)/plugins/dlt_raw/Makefile.am
 include $(srcdir)/plugins/dlt_null/Makefile.am
 include $(srcdir)/plugins/dlt_loop/Makefile.am
 include $(srcdir)/plugins/dlt_linuxsll/Makefile.am
+include $(srcdir)/plugins/dlt_ieee80211/Makefile.am
+include $(srcdir)/plugins/dlt_radiotap/Makefile.am

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


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


+ 1 - 1
src/tcpedit/plugins/dlt_en10mb/Makefile.am

@@ -1,4 +1,4 @@
-# $Id:$
+# $Id: Makefile.am 1830 2007-04-21 07:33:54Z aturner $
 # START OF: dlt_en10mb
 # Note, if you add any files to your plugin, you will need to edit dlt_<plugin>/Makefile.am
 # add your .c files to libdltplugin_a_SOURCES

+ 34 - 9
src/tcpedit/plugins/dlt_en10mb/en10mb.c

@@ -1,4 +1,4 @@
-/* $Id$ */
+/* $Id: en10mb.c 1850 2007-05-01 06:10:58Z aturner $ */
 
 /*
  * Copyright (c) 2006-2007 Aaron Turner.
@@ -42,7 +42,7 @@
 #include "tcpedit_stub.h"
 #include "../ethernet.h"
 
-static char __attribute__((unused)) dlt_name[] = "en10mb";
+static char _U_ dlt_name[] = "en10mb";
 static char dlt_prefix[] = "enet";
 static u_int16_t dlt_value = DLT_EN10MB;
 
@@ -90,7 +90,8 @@ dlt_en10mb_register(tcpeditdlt_t *ctx)
     plugin->plugin_l2len = dlt_en10mb_l2len;
     plugin->plugin_get_layer3 = dlt_en10mb_get_layer3;
     plugin->plugin_merge_layer3 = dlt_en10mb_merge_layer3;
-
+    plugin->plugin_get_mac = dlt_en10mb_get_mac;
+    
     /* add it to the available plugin list */
     return tcpedit_dlt_addplugin(ctx, plugin);
 }
@@ -341,7 +342,6 @@ dlt_en10mb_encode(tcpeditdlt_t *ctx, u_char **packet_ex, int pktlen, tcpr_dir_t
     en10mb_extra_t *extra = NULL;
     
     int newl2len = 0;
-    u_char tmpbuff[MAXPACKET];
 
     assert(ctx);
     assert(packet_ex);
@@ -372,12 +372,8 @@ dlt_en10mb_encode(tcpeditdlt_t *ctx, u_char **packet_ex, int pktlen, tcpr_dir_t
     }
 
     /* Make space for our new L2 header */
-    if (newl2len > ctx->l2len) {
-        memcpy(tmpbuff, packet, pktlen);
-        memcpy(packet + newl2len, (tmpbuff + ctx->l2len), pktlen - ctx->l2len);
-    } else if (newl2len < ctx->l2len) {
+    if (newl2len != ctx->l2len)
         memmove(packet + newl2len, packet + ctx->l2len, pktlen - ctx->l2len);
-    } /* else same size, so do nothing */
 
     /* update the total packet length */
     pktlen += newl2len - ctx->l2len;
@@ -570,6 +566,35 @@ dlt_en10mb_merge_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen, u_c
     return tcpedit_dlt_l3data_merge(ctx, packet, pktlen, l3data, l2len);
 }
 
+/*
+ * return a static pointer to the source/destination MAC address
+ * return NULL on error/address doesn't exist
+ */    
+u_char *
+dlt_en10mb_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen)
+{
+    assert(ctx);
+    assert(packet);
+    assert(pktlen);
+
+    /* FIXME: return a ptr to the source or dest mac address. */
+    switch(mac) {
+    case SRC_MAC:
+        memcpy(ctx->srcmac, &packet[6], ETHER_ADDR_LEN);
+        return(ctx->srcmac);
+        break;
+        
+    case DST_MAC:
+        memcpy(ctx->dstmac, packet, ETHER_ADDR_LEN);
+        return(ctx->dstmac);
+        break;
+        
+    default:
+        errx(1, "Invalid tcpeditdlt_mac_type_t: %d", mac);
+    }
+    return(NULL);
+}
+
 /* 
  * return the length of the L2 header of the current packet
  */

+ 2 - 2
src/tcpedit/plugins/dlt_en10mb/en10mb.h

@@ -1,4 +1,4 @@
-/* $Id:$ */
+/* $Id: en10mb.h 1841 2007-04-26 03:43:14Z aturner $ */
 
 /*
  * Copyright (c) 2006-2007 Aaron Turner.
@@ -46,7 +46,7 @@ int dlt_en10mb_proto(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen);
 u_char *dlt_en10mb_get_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen);
 u_char *dlt_en10mb_merge_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen, u_char *l3data);
 int dlt_en10mb_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen);
-
+u_char *dlt_en10mb_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen);
 
 tcpeditdlt_l2addr_type_t dlt_en10mb_l2addr_type(void);
 

+ 1 - 1
src/tcpedit/plugins/dlt_hdlc/Makefile.am

@@ -1,4 +1,4 @@
-# $Id:$
+# $Id: Makefile.am 1830 2007-04-21 07:33:54Z aturner $
 # START OF: dlt_hdlc
 # Note, if you add any files to your plugin, you will need to edit dlt_<plugin>/Makefile.am
 # add your .c files to libtcpedit_a_SOURCES

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

@@ -1,4 +1,4 @@
-/* $Id:$ */
+/* $Id: hdlc.c 1856 2007-05-02 04:55:26Z aturner $ */
 
 /*
  * Copyright (c) 2006-2007 Aaron Turner.
@@ -41,7 +41,7 @@
 #include "tcpr.h"
 
 static char dlt_name[] = "hdlc";
-static char __attribute__((unused)) dlt_prefix[] = "hdlc";
+static char _U_ dlt_prefix[] = "hdlc";
 static u_int16_t dlt_value = DLT_C_HDLC;
 
 /*
@@ -88,7 +88,8 @@ dlt_hdlc_register(tcpeditdlt_t *ctx)
     plugin->plugin_l2len = dlt_hdlc_l2len;
     plugin->plugin_get_layer3 = dlt_hdlc_get_layer3;
     plugin->plugin_merge_layer3 = dlt_hdlc_merge_layer3;
-
+    plugin->plugin_get_mac = dlt_hdlc_get_mac;
+    
     /* add it to the available plugin list */
     return tcpedit_dlt_addplugin(ctx, plugin);
 }
@@ -220,7 +221,7 @@ dlt_hdlc_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen)
  * Returns: total packet len or TCPEDIT_ERROR
  */
 int 
-dlt_hdlc_encode(tcpeditdlt_t *ctx, u_char **packet_ex, int pktlen, __attribute__((unused)) tcpr_dir_t dir)
+dlt_hdlc_encode(tcpeditdlt_t *ctx, u_char **packet_ex, int pktlen, _U_ tcpr_dir_t dir)
 {
     cisco_hdlc_t *hdlc;
     hdlc_config_t *config = NULL;
@@ -352,6 +353,33 @@ dlt_hdlc_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen)
     return 4;
 }
 
+/*
+ * return a static pointer to the source/destination MAC address
+ * return NULL on error/address doesn't exist
+ */    
+u_char *
+dlt_hdlc_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen)
+{
+    assert(ctx);
+    assert(packet);
+    assert(pktlen);
+
+    /* FIXME: return a ptr to the source or dest mac address. */
+    switch(mac) {
+    case SRC_MAC:
+        return(NULL);
+        break;
+        
+    case DST_MAC:
+        memcpy(ctx->dstmac, packet, 2);
+        return(ctx->dstmac);
+        break;
+        
+    default:
+        errx(1, "Invalid tcpeditdlt_mac_type_t: %d", mac);
+    }
+    return(NULL);
+}
 
 tcpeditdlt_l2addr_type_t 
 dlt_hdlc_l2addr_type(void)

+ 3 - 2
src/tcpedit/plugins/dlt_hdlc/hdlc.h

@@ -1,4 +1,4 @@
-/* $Id:$ */
+/* $Id: hdlc.h 1841 2007-04-26 03:43:14Z aturner $ */
 
 /*
  * Copyright (c) 2006-2007 Aaron Turner.
@@ -47,9 +47,10 @@ u_char *dlt_hdlc_get_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen)
 u_char *dlt_hdlc_merge_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen, u_char *l3data);
 tcpeditdlt_l2addr_type_t dlt_hdlc_l2addr_type(void);
 int dlt_hdlc_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen);
+u_char *dlt_hdlc_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen);
 
 /*
- * FIXME: structure to hold any data parsed from the packet by the decoder.
+ * structure to hold any data parsed from the packet by the decoder.
  * Example: Ethernet VLAN tag info
  */
 struct hdlc_extra_s {

+ 26 - 0
src/tcpedit/plugins/dlt_ieee80211/Makefile.am

@@ -0,0 +1,26 @@
+# $Id: Makefile.am 1838 2007-04-22 18:23:38Z aturner $
+# START OF: dlt_ieee80211
+# Note, if you add any files to your plugin, you will need to edit dlt_ieee80211/Makefile.am
+# add your .c files to libtcpedit_a_SOURCES
+# add your .h files to noinst_HEADERS
+# add any other files (like documentation, notes, etc) to EXTRA_DIST
+# add your dependancy information (see comment below)
+
+libtcpedit_a_SOURCES += $(srcdir)/plugins/dlt_ieee80211/ieee80211.c $(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c
+
+noinst_HEADERS += $(srcdir)/plugins/dlt_ieee80211/ieee80211.h $(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.h
+
+EXTRA_DIST += $(srcdir)/plugins/dlt_ieee80211/ieee80211_opts.def
+
+# dependancies for your plugin source code.  Edit as necessary
+$(srcdir)/plugins/dlt_ieee80211/ieee80211.c:  $(srcdir)/tcpedit_stub.h $(srcdir)/plugins/dlt_utils.h \
+	$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c $(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.h \
+	$(srcdir)/plugins/dlt_ieee80211/ieee80211.h $(srcdir)/plugins/dlt_plugins.h $(srcdir)/plugins/dlt_plugins-int.h
+
+# You probably don't want to touch anything below this line until the end of the plugin
+
+DLT_STUB_DEPS += $(srcdir)/plugins/dlt_ieee80211/ieee80211_opts.def
+
+MOSTLYCLEANFILES += $(srcdir)/plugins/dlt_ieee80211/*~
+
+# END OF: dlt_ieee80211

+ 382 - 0
src/tcpedit/plugins/dlt_ieee80211/ieee80211.c

@@ -0,0 +1,382 @@
+/* $Id: ieee80211.c 1863 2007-05-04 05:50:23Z aturner $ */
+
+/*
+ * Copyright (c) 2006-2007 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 <stdlib.h>
+#include <string.h>
+
+#include "dlt_plugins-int.h"
+#include "dlt_utils.h"
+#include "ieee80211.h"
+#include "ieee80211_hdr.h"
+#include "tcpedit.h"
+#include "common.h"
+#include "tcpr.h"
+
+/*
+ * Notes about the ieee80211 plugin:
+ * 802.11 is a little different from most other L2 protocols:
+ * - Not all frames are data frames (control, data, management)
+ */
+static char dlt_name[] = "ieee80211";
+_U_ static char dlt_prefix[] = "ieee802_11";
+static u_int16_t dlt_value = DLT_IEEE802_11;
+
+/*
+ * Function to register ourselves.  This function is always called, regardless
+ * of what DLT types are being used, so it shouldn't be allocating extra buffers
+ * or anything like that (use the dlt_ieee80211_init() function below for that).
+ * Tasks:
+ * - Create a new plugin struct
+ * - Fill out the provides/requires bit masks.  Note:  Only specify which fields are
+ *   actually in the header.
+ * - Add the plugin to the context's plugin chain
+ * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN
+ */
+int 
+dlt_ieee80211_register(tcpeditdlt_t *ctx)
+{
+    tcpeditdlt_plugin_t *plugin;
+    assert(ctx);
+
+    /* create  a new plugin structure */
+    plugin = tcpedit_dlt_newplugin();
+
+    /* we're a decoder only plugin */
+    plugin->provides += PLUGIN_MASK_PROTO + PLUGIN_MASK_SRCADDR + PLUGIN_MASK_DSTADDR;
+    plugin->requires += 0;
+    
+     /* what is our DLT value? */
+    plugin->dlt = dlt_value;
+
+    /* set the prefix name of our plugin.  This is also used as the prefix for our options */
+    plugin->name = safe_strdup(dlt_name);
+
+    /* 
+     * Point to our functions, note, you need a function for EVERY method.  
+     * Even if it is only an empty stub returning success.
+     */
+    plugin->plugin_init = dlt_ieee80211_init;
+    plugin->plugin_cleanup = dlt_ieee80211_cleanup;
+    plugin->plugin_parse_opts = dlt_ieee80211_parse_opts;
+    plugin->plugin_decode = dlt_ieee80211_decode;
+    plugin->plugin_encode = dlt_ieee80211_encode;
+    plugin->plugin_proto = dlt_ieee80211_proto;
+    plugin->plugin_l2addr_type = dlt_ieee80211_l2addr_type;
+    plugin->plugin_l2len = dlt_ieee80211_l2len;
+    plugin->plugin_get_layer3 = dlt_ieee80211_get_layer3;
+    plugin->plugin_merge_layer3 = dlt_ieee80211_merge_layer3;
+    plugin->plugin_get_mac = dlt_ieee80211_get_mac;
+
+    /* add it to the available plugin list */
+    return tcpedit_dlt_addplugin(ctx, plugin);
+}
+
+ 
+/*
+ * Initializer function.  This function is called only once, if and only iif
+ * this plugin will be utilized.  Remember, if you need to keep track of any state, 
+ * store it in your plugin->config, not a global!
+ * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN
+ */
+int 
+dlt_ieee80211_init(tcpeditdlt_t *ctx)
+{
+    tcpeditdlt_plugin_t *plugin;
+    ieee80211_config_t *config;
+    assert(ctx);
+    
+    if ((plugin = tcpedit_dlt_getplugin(ctx, dlt_value)) == NULL) {
+        tcpedit_seterr(ctx->tcpedit, "Unable to initalize unregistered plugin %s", dlt_name);
+        return TCPEDIT_ERROR;
+    }
+    
+    /* allocate memory for our deocde extra data */
+    if (sizeof(ieee80211_extra_t) > 0)
+        ctx->decoded_extra = safe_malloc(sizeof(ieee80211_extra_t));
+
+    /* allocate memory for our config data */
+    if (sizeof(ieee80211_config_t) > 0)
+        plugin->config = safe_malloc(sizeof(ieee80211_config_t));
+    
+    config = (ieee80211_config_t *)plugin->config;
+    
+    /* FIXME: set default config values here */
+
+    return TCPEDIT_OK; /* success */
+}
+
+/*
+ * Since this is used in a library, we should manually clean up after ourselves
+ * Unless you allocated some memory in dlt_ieee80211_init(), this is just an stub.
+ * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN
+ */
+int 
+dlt_ieee80211_cleanup(tcpeditdlt_t *ctx)
+{
+    tcpeditdlt_plugin_t *plugin;
+    assert(ctx);
+
+    if ((plugin = tcpedit_dlt_getplugin(ctx, dlt_value)) == NULL) {
+        tcpedit_seterr(ctx->tcpedit, "Unable to cleanup unregistered plugin %s", dlt_name);
+        return TCPEDIT_ERROR;
+    }
+
+    if (ctx->decoded_extra != NULL) {
+        free(ctx->decoded_extra);
+        ctx->decoded_extra = NULL;
+    }
+        
+    if (plugin->config != NULL) {
+        free(plugin->config);
+        plugin->config = NULL;
+    }
+
+    return TCPEDIT_OK; /* success */
+}
+
+/*
+ * This is where you should define all your AutoGen AutoOpts option parsing.
+ * Any user specified option should have it's bit turned on in the 'provides'
+ * bit mask.
+ * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN
+ */
+int 
+dlt_ieee80211_parse_opts(tcpeditdlt_t *ctx)
+{
+    assert(ctx);
+
+    /* we have none */
+    
+    return TCPEDIT_OK; /* success */
+}
+
+/*
+ * Function to decode the layer 2 header in the packet.
+ * You need to fill out:
+ * - ctx->l2len
+ * - ctx->srcaddr
+ * - ctx->dstaddr
+ * - ctx->proto
+ * - ctx->decoded_extra
+ * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN
+ */
+int 
+dlt_ieee80211_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen)
+{
+    assert(ctx);
+    assert(packet);
+    assert(pktlen > dlt_ieee80211_l2len(ctx, packet, pktlen));
+
+    if (!ieee80211_is_data(ctx, packet, pktlen)) {
+        tcpedit_seterr(ctx->tcpedit, "Packet " COUNTER_SPEC " is not a normal 802.11 data frame",
+            ctx->tcpedit->runtime.packetnum);
+        return TCPEDIT_SOFT_ERROR;
+    }
+    
+    if (ieee80211_is_encrypted(ctx, packet, pktlen)) {
+        tcpedit_seterr(ctx->tcpedit, "Packet " COUNTER_SPEC " is encrypted.  Unable to decode frame.",
+            ctx->tcpedit->runtime.packetnum);
+        return TCPEDIT_SOFT_ERROR;
+    }
+
+    memcpy(&(ctx->srcaddr), ieee80211_get_src((ieee80211_hdr_t *)packet), ETHER_ADDR_LEN);
+    memcpy(&(ctx->dstaddr), ieee80211_get_dst((ieee80211_hdr_t *)packet), ETHER_ADDR_LEN);
+    ctx->proto = dlt_ieee80211_proto(ctx, packet, pktlen);
+
+    return TCPEDIT_OK; /* success */
+}
+
+/*
+ * Function to encode the layer 2 header back into the packet.
+ * Returns: total packet len or TCPEDIT_ERROR
+ */
+int 
+dlt_ieee80211_encode(tcpeditdlt_t *ctx, u_char **packet_ex, int pktlen, _U_ tcpr_dir_t dir)
+{
+    u_char *packet;
+    assert(ctx);
+    assert(packet_ex);
+    assert(pktlen);
+    
+    packet = *packet_ex;
+    assert(packet);
+    
+    tcpedit_seterr(ctx->tcpedit, "%s", "DLT_IEEE802_11 plugin does not support packet encoding");
+    return TCPEDIT_ERROR;
+}
+
+/*
+ * Function returns the Layer 3 protocol type of the given packet, or TCPEDIT_ERROR on error
+ * Make sure you return this in host byte order since all the comparisions will be
+ * against the ETHERTYPE_* values which are oddly in host byte order.
+ */
+int 
+dlt_ieee80211_proto(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen)
+{
+    int protocol, l2len;
+
+    assert(ctx);
+    assert(packet);
+
+    l2len = dlt_ieee80211_l2len(ctx, packet, pktlen);
+
+    assert(pktlen >= l2len);
+    
+    protocol = (u_int16_t)packet[l2len - 2];
+    
+    return ntohs(protocol);
+}
+
+/*
+ * Function returns a pointer to the layer 3 protocol header or NULL on error
+ */
+u_char *
+dlt_ieee80211_get_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen)
+{
+    int l2len;
+    assert(ctx);
+    assert(packet);
+
+    l2len = dlt_ieee80211_l2len(ctx, packet, pktlen);
+
+    assert(pktlen >= l2len);
+    
+    return tcpedit_dlt_l3data_copy(ctx, packet, pktlen, l2len);
+}
+
+/*
+ * function merges the packet (containing L2 and old L3) with the l3data buffer
+ * containing the new l3 data.  Note, if L2 % 4 == 0, then they're pointing to the
+ * same buffer, otherwise there was a memcpy involved on strictly aligned architectures
+ * like SPARC
+ */
+u_char *
+dlt_ieee80211_merge_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen, u_char *l3data)
+{
+    int l2len;
+    assert(ctx);
+    assert(packet);
+    assert(l3data);
+    
+    l2len = dlt_ieee80211_l2len(ctx, packet, pktlen);
+    
+    assert(pktlen >= l2len);
+    
+    return tcpedit_dlt_l3data_merge(ctx, packet, pktlen, l3data, l2len);
+}
+
+/* 
+ * return the length of the L2 header of the current packet
+ * based on: http://www.tcpdump.org/lists/workers/2004/07/msg00121.html
+ * Returns >= 0 or TCPEDIT_SOFT_ERROR on error
+ *
+ */
+int
+dlt_ieee80211_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen)
+{
+    u_int16_t *frame_control, fc;
+    struct tcpr_802_2snap_hdr *hdr;
+    int hdrlen = 0;
+
+
+    assert(ctx);
+    assert(packet);
+    assert(pktlen);
+    
+
+    frame_control = (u_int16_t *)packet;
+    fc = ntohs(*frame_control);
+
+    if (ieee80211_USE_4(fc)) {
+        hdrlen = sizeof(ieee80211_addr4_hdr_t);
+    } else {
+        hdrlen = sizeof(ieee80211_hdr_t);
+    }
+
+    /* 
+     * FIXME: 802.11e?  has a QoS feature which apparently extends the header by another
+     * 2 bytes, but I don't know how to test for that yet.
+     */
+    
+    if (pktlen < hdrlen + (int)sizeof(struct tcpr_802_2snap_hdr)) {
+        return TCPEDIT_SOFT_ERROR;
+    }
+    hdr = (struct tcpr_802_2snap_hdr *)&packet[hdrlen];
+    
+    /* verify the header is 802.2SNAP (8 bytes) not 802.2 (3 bytes) */
+    if (hdr->snap_dsap == 0xAA && hdr->snap_ssap == 0xAA) {
+        hdrlen += (int)sizeof(struct tcpr_802_2snap_hdr);
+    } else {
+        hdrlen += (int)sizeof(struct tcpr_802_2_hdr);
+    }
+
+    return hdrlen;
+}
+
+/*
+ * return a static pointer to the source/destination MAC address
+ * return NULL on error/address doesn't exist
+ */    
+u_char *
+dlt_ieee80211_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen)
+{
+    assert(ctx);
+    assert(packet);
+    assert(pktlen);
+    char *macaddr;
+    
+    switch(mac) {
+    case SRC_MAC:
+        macaddr = ieee80211_get_src(packet);
+        memcpy(ctx->srcmac, macaddr, ETHER_ADDR_LEN);
+        return(ctx->srcmac);
+        break;
+        
+    case DST_MAC:
+        macaddr = ieee80211_get_dst(packet);
+        memcpy(ctx->dstmac, macaddr, ETHER_ADDR_LEN);
+        return(ctx->dstmac);
+        break;
+        
+    default:
+        errx(1, "Invalid tcpeditdlt_mac_type_t: %d", mac);
+    }
+    return(NULL);
+}
+
+
+tcpeditdlt_l2addr_type_t 
+dlt_ieee80211_l2addr_type(void)
+{
+    return ETHERNET;
+}
+

+ 115 - 0
src/tcpedit/plugins/dlt_ieee80211/ieee80211.h

@@ -0,0 +1,115 @@
+/* $Id: ieee80211.h 1841 2007-04-26 03:43:14Z aturner $ */
+
+/*
+ * Copyright (c) 2006-2007 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 "dlt_plugins-int.h"
+
+#ifndef _DLT_ieee80211_H_
+#define _DLT_ieee80211_H_
+
+int dlt_ieee80211_register(tcpeditdlt_t *ctx);
+int dlt_ieee80211_init(tcpeditdlt_t *ctx);
+int dlt_ieee80211_cleanup(tcpeditdlt_t *ctx);
+int dlt_ieee80211_parse_opts(tcpeditdlt_t *ctx);
+int dlt_ieee80211_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen);
+int dlt_ieee80211_encode(tcpeditdlt_t *ctx, u_char **packet, int pktlen, tcpr_dir_t dir);
+int dlt_ieee80211_proto(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen);
+u_char *dlt_ieee80211_get_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen);
+u_char *dlt_ieee80211_merge_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen, u_char *l3data);
+tcpeditdlt_l2addr_type_t dlt_ieee80211_l2addr_type(void);
+int dlt_ieee80211_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen);
+u_char *dlt_ieee80211_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen);
+
+/* 802.11 packet header w/ 3 addresses (non-WDS) */
+struct ieee80211_hdr_s {
+    u_int16_t frame_control;
+#define ieee80211_FC_VERSION_MASK   0xC000
+#define ieee80211_FC_TYPE_MASK      0x3000
+#define ieee80211_FC_SUBTYPE_MASK   0x0F00
+#define ieee80211_FC_TO_DS_MASK     0x0080
+#define ieee80211_FC_FROM_DS_MASK   0x0040
+#define ieee80211_FC_MORE_FRAG      0x0020
+#define ieee80211_FC_RETRY_MASK     0x0010
+#define ieee80211_FC_PWR_MGMT_MASK  0x0008
+#define ieee80211_FC_MORE_DATA_MASK 0x0004
+#define ieee80211_FC_WEP_MASK       0x0002
+#define ieee80211_FC_ORDER_MASK     0x0001
+    u_int16_t duration;
+    u_char addr1[6];
+    u_char addr2[6];
+    u_char addr3[6];
+    u_int16_t fragid;
+    u_int16_t seqid;
+};
+typedef struct ieee80211_hdr_s ieee80211_hdr_t;
+
+struct ieee80211_addr4_hdr_s {
+    u_int16_t frame_control;
+    u_int16_t duration;
+    u_char addr1[6];
+    u_char addr2[6];
+    u_char addr3[6];
+    u_char addr4[6];
+    u_int16_t fragid;
+    u_int16_t seqid;
+};
+typedef struct ieee80211_addr4_hdr_s ieee80211_addr4_hdr_t;
+
+#define ieee80211_USE_4(frame_control)                                          \
+    (frame_control & (ieee80211_FC_TO_DS_MASK + ieee80211_FC_FROM_DS_MASK)) ==   \
+    (ieee80211_FC_TO_DS_MASK + ieee80211_FC_FROM_DS_MASK)
+
+/*
+ * FIXME: structure to hold any data parsed from the packet by the decoder.
+ * Example: Ethernet VLAN tag info
+ */
+struct ieee80211_extra_s {
+
+};
+typedef struct ieee80211_extra_s ieee80211_extra_t;
+
+
+/* 
+ * FIXME: structure to hold any data in the tcpeditdlt_plugin_t->config 
+ * Things like: 
+ * - Parsed user options
+ * - State between packets
+ * - Note, you should only use this for the encoder function, decoder functions should place
+ *   "extra" data parsed from the packet in the tcpeditdlt_t->decoded_extra buffer since that 
+ *   is available to any encoder plugin.
+ */
+struct ieee80211_config_s {
+    
+};
+typedef struct ieee80211_config_s ieee80211_config_t;
+
+#endif

+ 188 - 0
src/tcpedit/plugins/dlt_ieee80211/ieee80211_hdr.c

@@ -0,0 +1,188 @@
+/* $Id: ieee80211_hdr.c 1866 2007-05-12 19:48:48Z aturner $ */
+
+/*
+ * Copyright (c) 2006-2007 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 <stdlib.h>
+#include <string.h>
+
+#include "dlt_plugins-int.h"
+#include "ieee80211.h"
+
+/*
+ * Does the given 802.11 header have data?
+ * returns 1 for true & 0 for false
+ */
+int
+ieee80211_is_data(tcpeditdlt_t *ctx, const void *packet, const int pktlen) 
+{
+    u_int16_t *frame_control, fc;
+    struct tcpr_802_2snap_hdr *snap;
+    int hdrlen;
+    
+    assert(ctx);
+    assert(packet);
+    
+    /* Ack, Auth, NULL packets often are very small (10-30 bytes) */
+    if (pktlen >= (int)sizeof(ieee80211_hdr_t))
+        return 0;
+        
+    /* 
+     * Fields: Version|Type|Subtype|Flags
+     * Bytes: 2|2|4|8
+     * Types: 00 = Management, 01 = Control, 10 = Data
+     * Data Subtypes (in binary): 
+     * 0000 - Data
+     * 0001 - Data + Ack
+     * 0010 - Data + Poll
+     * 0011 - Data + Ack + Poll
+     * 01?? - Data + Null (no data)
+     * 1??? - Reserved
+     * FIXME:
+     * So right now, we only look for pure data frames, since I'm not sure what to do with ACK/Poll
+     */
+     
+    frame_control = (u_int16_t *)packet;
+    fc = ntohs(*frame_control);
+    if ((fc & 0x2000) != 0x2000) {
+        return 0;
+    }
+    
+    /* frame must also have a 802.2 SNAP header */
+    if (ieee80211_USE_4(fc)) {
+        hdrlen = sizeof(ieee80211_addr4_hdr_t);
+    } else {
+        hdrlen = sizeof(ieee80211_hdr_t);
+    }
+
+    /* 
+     * FIXME: 802.11e?  has a QoS feature which apparently extends the header by another
+     * 2 bytes, but I don't know how to test for that yet.
+     */
+    if (pktlen < hdrlen + (int)sizeof(struct tcpr_802_2snap_hdr)) {
+        return 0; /* not long enough for SNAP */
+    }
+    
+    snap = (struct tcpr_802_2snap_hdr *)&((u_char *)packet)[hdrlen];
+    
+    /* verify the header is 802.2SNAP (8 bytes) not 802.2 (3 bytes) */
+    if (snap->snap_dsap == 0xAA && snap->snap_ssap == 0xAA) {
+        return 1;
+    } 
+    
+    return 0;
+}
+
+/* 
+ * returns 1 if WEP is enabled, 0 if not
+ */
+int
+ieee80211_is_encrypted(tcpeditdlt_t *ctx, const void *packet, const int pktlen)
+{
+    u_int16_t *frame_control, fc;
+
+    assert(ctx);
+    assert(packet);
+    assert(pktlen >= (int)sizeof(ieee80211_hdr_t));
+
+    frame_control = (u_int16_t *)packet;
+    fc = ntohs(*frame_control);
+    
+    if ((fc & 0x0002) == 0x0002) {
+        return 1;
+    }
+    return 0;
+}
+
+/*
+ * 802.11 headers are variable length and the clients (non-AP's) have their
+ * src & dst MAC addresses in different places in the header based on the
+ * flags set in the first two bytes of the header (frame control)
+ */
+
+u_char *
+ieee80211_get_src(const void *header)
+{
+    ieee80211_hdr_t *addr3;
+    ieee80211_addr4_hdr_t *addr4;
+    u_int16_t *frame_control, fc;
+    
+    assert(header);
+    frame_control = (u_int16_t *)header;
+    fc = ntohs(*frame_control);
+
+    if (ieee80211_USE_4(fc)) {
+        addr4 = (ieee80211_addr4_hdr_t *)header;
+        return addr4->addr4;
+    } else {
+        addr3 = (ieee80211_hdr_t *)header;
+        switch (fc & (ieee80211_FC_TO_DS_MASK + ieee80211_FC_FROM_DS_MASK)) {
+            case ieee80211_FC_TO_DS_MASK:
+                return addr3->addr2;
+            case ieee80211_FC_FROM_DS_MASK:
+                return addr3->addr3;
+            case 0:
+                return addr3->addr2;
+            default:
+                err(1, "Whoops... we shouldn't of gotten here.");
+        }
+    }
+    return NULL;
+}
+
+u_char *
+ieee80211_get_dst(const void *header)
+{
+    ieee80211_hdr_t *addr3;
+    ieee80211_addr4_hdr_t *addr4;
+    u_int16_t *frame_control, fc;
+    
+    assert(header);
+    frame_control = (u_int16_t *)header;
+    fc = ntohs(*frame_control);
+
+    if (ieee80211_USE_4(fc)) {
+        addr4 = (ieee80211_addr4_hdr_t *)header;
+        return addr4->addr3;
+    } else {
+        addr3 = (ieee80211_hdr_t *)header;
+        switch (fc & (ieee80211_FC_TO_DS_MASK + ieee80211_FC_FROM_DS_MASK)) {
+            case ieee80211_FC_TO_DS_MASK:
+                return addr3->addr3;
+            case ieee80211_FC_FROM_DS_MASK:
+                return addr3->addr2;
+            case 0:
+                return addr3->addr3;
+            default:
+                err(1, "Whoops... we shouldn't of gotten here.");
+        }
+    }
+    return NULL;
+}

+ 46 - 0
src/tcpedit/plugins/dlt_ieee80211/ieee80211_hdr.h

@@ -0,0 +1,46 @@
+/* $Id: ieee80211_hdr.h 1840 2007-04-22 22:47:59Z aturner $ */
+
+/*
+ * Copyright (c) 2007 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 "dlt_plugins-int.h"
+
+#ifndef _DLT_ieee80211_hdr_H_
+#define _DLT_ieee80211_hdr_H_
+#include "ieee80211.h"
+
+int ieee80211_is_data(tcpeditdlt_t *ctx, const void *packet, const int pktlen);
+int ieee80211_is_encrypted(tcpeditdlt_t *ctx, const void *packet, const int pktlen);
+
+char *ieee80211_get_src(const void *header);
+char *ieee80211_get_dst(const void *header);
+
+#endif

+ 1 - 0
src/tcpedit/plugins/dlt_ieee80211/ieee80211_opts.def

@@ -0,0 +1 @@
+/* Add the flag definitions for your plugin here */

+ 1 - 1
src/tcpedit/plugins/dlt_linuxsll/Makefile.am

@@ -1,4 +1,4 @@
-# $Id:$
+# $Id: Makefile.am 1830 2007-04-21 07:33:54Z aturner $
 # START OF: dlt_linuxsll
 # Note, if you add any files to your plugin, you will need to edit dlt_<plugin>/Makefile.am
 # add your .c files to libtcpedit_a_SOURCES

+ 32 - 4
src/tcpedit/plugins/dlt_linuxsll/linuxsll.c

@@ -1,4 +1,4 @@
-/* $Id:$ */
+/* $Id: linuxsll.c 1842 2007-04-26 04:34:11Z aturner $ */
 
 /*
  * Copyright (c) 2006-2007 Aaron Turner.
@@ -41,7 +41,7 @@
 #include "tcpr.h"
 
 static char dlt_name[] = "linuxsll";
-static char __attribute__((unused)) dlt_prefix[] = "linuxsll";
+static char _U_ dlt_prefix[] = "linuxsll";
 static u_int16_t dlt_value = DLT_LINUX_SLL;
 
 /*
@@ -89,7 +89,8 @@ dlt_linuxsll_register(tcpeditdlt_t *ctx)
     plugin->plugin_l2len = dlt_linuxsll_l2len;
     plugin->plugin_get_layer3 = dlt_linuxsll_get_layer3;
     plugin->plugin_merge_layer3 = dlt_linuxsll_merge_layer3;
-
+    plugin->plugin_get_mac = dlt_linuxsll_get_mac;
+    
     /* add it to the available plugin list */
     return tcpedit_dlt_addplugin(ctx, plugin);
 }
@@ -209,7 +210,7 @@ dlt_linuxsll_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen)
  * Returns: total packet len or TCPEDIT_ERROR
  */
 int 
-dlt_linuxsll_encode(tcpeditdlt_t *ctx, u_char **packet_ex, int pktlen, __attribute__((unused)) tcpr_dir_t dir)
+dlt_linuxsll_encode(tcpeditdlt_t *ctx, u_char **packet_ex, int pktlen, _U_ tcpr_dir_t dir)
 {
     u_char *packet;
     assert(ctx);
@@ -290,6 +291,33 @@ dlt_linuxsll_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen)
     return sizeof(linux_sll_header_t);
 }
 
+/*
+ * return a static pointer to the source/destination MAC address
+ * return NULL on error/address doesn't exist
+ */    
+u_char *
+dlt_linuxsll_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen)
+{
+    assert(ctx);
+    assert(packet);
+    assert(pktlen);
+
+    /* FIXME: return a ptr to the source or dest mac address. */
+    switch(mac) {
+    case SRC_MAC:
+        memcpy(ctx->srcmac, &packet[6], 8); /* linuxssl defines the src mac field to be 8 bytes, not 6 */
+        return(ctx->srcmac);
+        break;
+        
+    case DST_MAC:
+        return(NULL);
+        break;
+        
+    default:
+        errx(1, "Invalid tcpeditdlt_mac_type_t: %d", mac);
+    }
+    return(NULL);
+}
 
 tcpeditdlt_l2addr_type_t 
 dlt_linuxsll_l2addr_type(void)

+ 3 - 2
src/tcpedit/plugins/dlt_linuxsll/linuxsll.h

@@ -1,4 +1,4 @@
-/* $Id:$ */
+/* $Id: linuxsll.h 1841 2007-04-26 03:43:14Z aturner $ */
 
 /*
  * Copyright (c) 2006-2007 Aaron Turner.
@@ -47,9 +47,10 @@ u_char *dlt_linuxsll_get_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pkt
 u_char *dlt_linuxsll_merge_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen, u_char *l3data);
 tcpeditdlt_l2addr_type_t dlt_linuxsll_l2addr_type(void);
 int dlt_linuxsll_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen);
+u_char *dlt_linuxsll_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen);
 
 /*
- * FIXME: structure to hold any data parsed from the packet by the decoder.
+ * structure to hold any data parsed from the packet by the decoder.
  * Example: Ethernet VLAN tag info
  */
 struct linuxsll_extra_s {

+ 1 - 1
src/tcpedit/plugins/dlt_loop/Makefile.am

@@ -1,4 +1,4 @@
-# $Id:$
+# $Id: Makefile.am 1830 2007-04-21 07:33:54Z aturner $
 # START OF: dlt_loop
 # Note, if you add any files to your plugin, you will need to edit dlt_<plugin>/Makefile.am
 # add your .c files to libtcpedit_a_SOURCES

+ 5 - 4
src/tcpedit/plugins/dlt_loop/loop.c

@@ -1,4 +1,4 @@
-/* $Id:$ */
+/* $Id: loop.c 1842 2007-04-26 04:34:11Z aturner $ */
 
 /*
  * Copyright (c) 2006-2007 Aaron Turner.
@@ -49,7 +49,7 @@
  */
 
 static char dlt_name[] = "loop";
-static char __attribute__((unused)) dlt_prefix[] = "loop";
+static char _U_ dlt_prefix[] = "loop";
 static u_int16_t dlt_value = DLT_LOOP;
 
 /*
@@ -72,7 +72,7 @@ dlt_loop_register(tcpeditdlt_t *ctx)
     /* create  a new plugin structure */
     plugin = tcpedit_dlt_newplugin();
 
-    /* FIXME: set what we provide & require */
+    /* set what we provide & require */
     plugin->provides += PLUGIN_MASK_PROTO;
     plugin->requires += 0;
 
@@ -93,7 +93,8 @@ dlt_loop_register(tcpeditdlt_t *ctx)
     plugin->plugin_l2len = dlt_null_l2len;
     plugin->plugin_get_layer3 = dlt_null_get_layer3;
     plugin->plugin_merge_layer3 = dlt_null_merge_layer3;
-
+    plugin->plugin_get_mac = dlt_null_get_mac;
+    
     /* add it to the available plugin list */
     return tcpedit_dlt_addplugin(ctx, plugin);
 }

+ 1 - 1
src/tcpedit/plugins/dlt_loop/loop.h

@@ -1,4 +1,4 @@
-/* $Id:$ */
+/* $Id: loop.h 1830 2007-04-21 07:33:54Z aturner $ */
 
 /*
  * Copyright (c) 2006-2007 Aaron Turner.

+ 1 - 1
src/tcpedit/plugins/dlt_null/Makefile.am

@@ -1,4 +1,4 @@
-# $Id:$
+# $Id: Makefile.am 1830 2007-04-21 07:33:54Z aturner $
 # START OF: dlt_null
 # Note, if you add any files to your plugin, you will need to edit dlt_<plugin>/Makefile.am
 # add your .c files to libtcpedit_a_SOURCES

+ 17 - 3
src/tcpedit/plugins/dlt_null/null.c

@@ -1,4 +1,4 @@
-/* $Id:$ */
+/* $Id: null.c 1863 2007-05-04 05:50:23Z aturner $ */
 
 /*
  * Copyright (c) 2006-2007 Aaron Turner.
@@ -43,7 +43,7 @@
 #include <sys/socket.h> // PF_* values
 
 static char dlt_name[] = "null";
-static char __attribute__((unused)) dlt_prefix[] = "null";
+static char _U_ dlt_prefix[] = "null";
 static u_int16_t dlt_value = DLT_NULL;
 
 /*
@@ -221,7 +221,7 @@ dlt_null_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen)
  * Returns: total packet len or TCPEDIT_ERROR
  */
 int 
-dlt_null_encode(tcpeditdlt_t *ctx, u_char **packet_ex, int pktlen, __attribute__((unused)) tcpr_dir_t dir)
+dlt_null_encode(tcpeditdlt_t *ctx, u_char **packet_ex, int pktlen, _U_ tcpr_dir_t dir)
 {
     u_char *packet;
     assert(ctx);
@@ -312,6 +312,20 @@ dlt_null_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen)
     return 4;
 }
 
+/*
+ * return a static pointer to the source/destination MAC address
+ * return NULL on error/address doesn't exist
+ */    
+u_char *
+dlt_null_get_mac(tcpeditdlt_t *ctx, _U_ tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen)
+{
+    assert(ctx);
+    assert(packet);
+    assert(pktlen);
+
+    return(NULL);
+
+}
 
 tcpeditdlt_l2addr_type_t 
 dlt_null_l2addr_type(void)

+ 3 - 2
src/tcpedit/plugins/dlt_null/null.h

@@ -1,4 +1,4 @@
-/* $Id:$ */
+/* $Id: null.h 1841 2007-04-26 03:43:14Z aturner $ */
 
 /*
  * Copyright (c) 2006-2007 Aaron Turner.
@@ -47,9 +47,10 @@ u_char *dlt_null_get_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen)
 u_char *dlt_null_merge_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen, u_char *l3data);
 tcpeditdlt_l2addr_type_t dlt_null_l2addr_type(void);
 int dlt_null_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen);
+u_char *dlt_null_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen);
 
 /*
- * FIXME: structure to hold any data parsed from the packet by the decoder.
+ * structure to hold any data parsed from the packet by the decoder.
  * Example: Ethernet VLAN tag info
  */
 struct null_extra_s {

+ 1 - 2
src/tcpedit/plugins/dlt_opts.def

@@ -37,7 +37,6 @@ Cisco HDLC aka DLT_C_HDLC
 @item
 @var{user}
 User specified Layer 2 header and DLT type
-@item
 @end table
 EO_DLT_DOC;
-};
+};

+ 15 - 2
src/tcpedit/plugins/dlt_plugins-int.h

@@ -1,4 +1,4 @@
-/* $Id: dlt_plugins-int.h 1802 2007-04-14 22:30:11Z aturner $ */
+/* $Id: dlt_plugins-int.h 1841 2007-04-26 03:43:14Z aturner $ */
 
 /*
  * Copyright (c) 2006-2007 Aaron Turner.
@@ -74,6 +74,16 @@ enum tcpeditdlt_l2addr_type_e {
 };
 typedef enum tcpeditdlt_l2addr_type_e tcpeditdlt_l2addr_type_t;
 
+/* src or dst mac */
+enum tcpeditdlt_mac_type_e {
+    SRC_MAC,
+    DST_MAC
+};
+typedef enum tcpeditdlt_mac_type_e tcpeditdlt_mac_type_t;
+
+/* MAC address buffer length */
+#define MAX_MAC_LEN 10
+
 /* 
  * Each plugin must fill this out so that we know what function
  * to call from the external API
@@ -91,9 +101,10 @@ struct tcpeditdlt_plugin_s {
     int (*plugin_encode)(tcpeditdlt_t *, u_char **, int, tcpr_dir_t);
     int (*plugin_proto)(tcpeditdlt_t *, const u_char *, const int);
     int (*plugin_l2len)(tcpeditdlt_t *, const u_char *, const int);
-    u_char *(*plugin_get_layer3)(tcpeditdlt_t *, u_char *, const int);
+    u_char *(*plugin_get_layer3)(tcpeditdlt_t *,  u_char *, const int);
     u_char *(*plugin_merge_layer3)(tcpeditdlt_t *, u_char *, const int, u_char *);
     tcpeditdlt_l2addr_type_t (*plugin_l2addr_type)(void);
+    u_char *(*plugin_get_mac)(tcpeditdlt_t *, tcpeditdlt_mac_type_t, const u_char *, const int);
     void *config; /* user configuration data for the encoder */
     
 };
@@ -131,6 +142,8 @@ struct tcpeditdlt_s {
     int l2len;                              /* set by decoder and updated by encoder */
     u_int16_t proto;                        /* layer 3 proto type?? */
     void *decoded_extra;                    /* any extra L2 data from decoder like VLAN tags */
+    u_char srcmac[MAX_MAC_LEN];             /* buffers to store the src & dst MAC */
+    u_char dstmac[MAX_MAC_LEN];
 };
 
 #endif

+ 0 - 0
src/tcpedit/plugins/dlt_plugins.c


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