ソースを参照

Import upstream version 4.3.4

Fred Klassen 3 年 前
コミット
5e9a801caa
84 ファイル変更11328 行追加2972 行削除
  1. 17 18
      Makefile.in
  2. 9139 142
      aclocal.m4
  3. 2 2
      config/ar-lib
  4. 7 6
      config/compile
  5. 301 283
      config/config.guess
  6. 117 141
      config/config.sub
  7. 5 5
      config/depcomp
  8. 23 13
      config/install-sh
  9. 153 60
      config/ltmain.sh
  10. 8 8
      config/missing
  11. 256 690
      configure
  12. 101 120
      configure.ac
  13. 29 3
      docs/CHANGELOG
  14. 21 0
      docs/CREDIT
  15. 4 4
      docs/LICENSE
  16. 11 11
      docs/Makefile.in
  17. 35 26
      lib/Makefile.in
  18. 1 1
      libopts/Makefile.am
  19. 38 34
      libopts/Makefile.in
  20. 5 36
      libopts/autoopts/options.h
  21. 1 1
      libopts/boolean.c
  22. 3 4
      libopts/configfile.c
  23. 3 7
      libopts/m4/libopts.m4
  24. 9 8
      libopts/makeshell.c
  25. 6 0
      libopts/numeric.c
  26. 1 1
      libopts/restore.c
  27. 0 592
      m4/libopts.m4
  28. 8 7
      m4/libtool.m4
  29. 0 41
      m4/stdnoreturn.m4
  30. 11 11
      scripts/Makefile.in
  31. 142 57
      src/Makefile.in
  32. 15 21
      src/bridge.c
  33. 101 45
      src/common/Makefile.in
  34. 4 11
      src/common/cidr.c
  35. 51 18
      src/common/get.c
  36. 1 1
      src/common/git_version.c
  37. 6 6
      src/common/interface.c
  38. 4 1
      src/common/list.c
  39. 11 1
      src/common/sendpacket.c
  40. 1 0
      src/common/services.c
  41. 0 4
      src/common/tcpdump.c
  42. 2 0
      src/common/utils.h
  43. 0 10
      src/config.h.in
  44. 1 1
      src/defines.h
  45. 1 1
      src/defines.h.in
  46. 120 47
      src/fragroute/Makefile.in
  47. 63 207
      src/send_packets.c
  48. 2 2
      src/tcpbridge.1
  49. 6 2
      src/tcpbridge.c
  50. 1 1
      src/tcpcapinfo.1
  51. 134 52
      src/tcpedit/Makefile.in
  52. 8 4
      src/tcpedit/dlt.c
  53. 1 1
      src/tcpedit/dlt.h
  54. 1 1
      src/tcpedit/edit_packet.c
  55. 28 16
      src/tcpedit/plugins/dlt_en10mb/en10mb.c
  56. 15 13
      src/tcpedit/plugins/dlt_hdlc/hdlc.c
  57. 15 13
      src/tcpedit/plugins/dlt_ieee80211/ieee80211.c
  58. 5 7
      src/tcpedit/plugins/dlt_jnpr_ether/jnpr_ether.c
  59. 15 14
      src/tcpedit/plugins/dlt_linuxsll/linuxsll.c
  60. 25 1
      src/tcpedit/plugins/dlt_loop/loop.c
  61. 1 0
      src/tcpedit/plugins/dlt_loop/loop.h
  62. 17 12
      src/tcpedit/plugins/dlt_null/null.c
  63. 1 1
      src/tcpedit/plugins/dlt_opts.def
  64. 18 6
      src/tcpedit/plugins/dlt_plugins.c
  65. 10 9
      src/tcpedit/plugins/dlt_pppserial/pppserial.c
  66. 15 13
      src/tcpedit/plugins/dlt_radiotap/radiotap.c
  67. 15 14
      src/tcpedit/plugins/dlt_raw/raw.c
  68. 15 14
      src/tcpedit/plugins/dlt_user/user.c
  69. 4 4
      src/tcpedit/portmap.c
  70. 78 21
      src/tcpedit/tcpedit.c
  71. 1 1
      src/tcpedit/tcpedit.h
  72. 0 1
      src/tcpedit/tcpedit_types.h
  73. 1 1
      src/tcpliveplay.1
  74. 1 1
      src/tcpprep.1
  75. 0 3
      src/tcpprep.c
  76. 5 6
      src/tcpprep_api.c
  77. 2 2
      src/tcpreplay-edit.1
  78. 1 1
      src/tcpreplay.1
  79. 8 0
      src/tcpreplay.c
  80. 11 8
      src/tcpreplay_api.c
  81. 2 2
      src/tcprewrite.1
  82. 16 5
      src/tcprewrite.c
  83. 1 3
      src/tree.c
  84. 11 11
      test/Makefile.in

+ 17 - 18
Makefile.in

@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.16.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2018 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -90,12 +90,9 @@ host_triplet = @host@
 target_triplet = @target@
 subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/libopts.m4 \
-	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
-	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
-	$(top_srcdir)/m4/lt~obsolete.m4 \
-	$(top_srcdir)/m4/stdnoreturn.m4 $(top_srcdir)/acinclude.m4 \
-	$(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
+	$(top_srcdir)/libopts/m4/stdnoreturn.m4 \
+	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
@@ -140,7 +137,7 @@ am__recursive_targets = \
   $(RECURSIVE_CLEAN_TARGETS) \
   $(am__extra_recursive_targets)
 AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
-	cscope distdir dist dist-all distcheck
+	cscope distdir distdir-am dist dist-all distcheck
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
 # Read a list of newline-separated strings from the standard input,
 # and print each of them once, without duplicates.  Input order is
@@ -168,8 +165,7 @@ am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/doxygen.cfg.in \
 	$(top_srcdir)/config/install-sh $(top_srcdir)/config/ltmain.sh \
 	$(top_srcdir)/config/missing INSTALL config/ar-lib \
 	config/compile config/config.guess config/config.sub \
-	config/depcomp config/install-sh config/ltmain.sh \
-	config/missing
+	config/install-sh config/ltmain.sh config/missing
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 distdir = $(PACKAGE)-$(VERSION)
 top_distdir = $(distdir)
@@ -417,8 +413,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	    echo ' $(SHELL) ./config.status'; \
 	    $(SHELL) ./config.status;; \
 	  *) \
-	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
-	    cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__maybe_remake_depfiles);; \
 	esac;
 
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@@ -547,7 +543,10 @@ distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 	-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
 
-distdir: $(DISTFILES)
+distdir: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
 	$(am__remove_distdir)
 	test -d "$(distdir)" || mkdir "$(distdir)"
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
@@ -615,7 +614,7 @@ distdir: $(DISTFILES)
 	  ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
 	|| chmod -R a+r "$(distdir)"
 dist-gzip: distdir
-	tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+	tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz
 	$(am__post_remove_distdir)
 
 dist-bzip2: distdir
@@ -641,7 +640,7 @@ dist-shar: distdir
 	@echo WARNING: "Support for shar distribution archives is" \
 	               "deprecated." >&2
 	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
-	shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
+	shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz
 	$(am__post_remove_distdir)
 
 dist-zip: distdir
@@ -659,7 +658,7 @@ dist dist-all:
 distcheck: dist
 	case '$(DIST_ARCHIVES)' in \
 	*.tar.gz*) \
-	  GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
+	  eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\
 	*.tar.bz2*) \
 	  bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
 	*.tar.lz*) \
@@ -669,7 +668,7 @@ distcheck: dist
 	*.tar.Z*) \
 	  uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
 	*.shar.gz*) \
-	  GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
+	  eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\
 	*.zip*) \
 	  unzip $(distdir).zip ;;\
 	esac

ファイルの差分が大きいため隠しています
+ 9139 - 142
aclocal.m4


+ 2 - 2
config/ar-lib

@@ -4,7 +4,7 @@
 me=ar-lib
 scriptversion=2012-03-01.08; # UTC
 
-# Copyright (C) 2010-2014 Free Software Foundation, Inc.
+# Copyright (C) 2010-2018 Free Software Foundation, Inc.
 # Written by Peter Rosin <peda@lysator.liu.se>.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -18,7 +18,7 @@ scriptversion=2012-03-01.08; # UTC
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a

+ 7 - 6
config/compile

@@ -1,9 +1,9 @@
 #! /bin/sh
 # Wrapper for compilers which do not understand '-c -o'.
 
-scriptversion=2012-10-14.11; # UTC
+scriptversion=2018-03-07.03; # UTC
 
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2018 Free Software Foundation, Inc.
 # Written by Tom Tromey <tromey@cygnus.com>.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -17,7 +17,7 @@ scriptversion=2012-10-14.11; # UTC
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -255,7 +255,8 @@ EOF
     echo "compile $scriptversion"
     exit $?
     ;;
-  cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
+  cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
+  icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
     func_cl_wrapper "$@"      # Doesn't return...
     ;;
 esac
@@ -339,9 +340,9 @@ exit $ret
 # Local Variables:
 # mode: shell-script
 # sh-indentation: 2
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
 # time-stamp-end: "; # UTC"
 # End:

ファイルの差分が大きいため隠しています
+ 301 - 283
config/config.guess


+ 117 - 141
config/config.sub

@@ -1,8 +1,8 @@
 #! /bin/sh
 # Configuration validation subroutine script.
-#   Copyright 1992-2016 Free Software Foundation, Inc.
+#   Copyright 1992-2018 Free Software Foundation, Inc.
 
-timestamp='2016-11-04'
+timestamp='2018-02-22'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@ timestamp='2016-11-04'
 # General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, see <http://www.gnu.org/licenses/>.
+# along with this program; if not, see <https://www.gnu.org/licenses/>.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -33,7 +33,7 @@ timestamp='2016-11-04'
 # Otherwise, we print the canonical config type on stdout and succeed.
 
 # You can get the latest version of this script from:
-# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
+# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
 
 # This file is supposed to be the same for all GNU packages
 # and recognize all the CPU types, system types and aliases
@@ -57,7 +57,7 @@ Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
 
 Canonicalize a configuration name.
 
-Operation modes:
+Options:
   -h, --help         print this help, then exit
   -t, --time-stamp   print date of last modification, then exit
   -v, --version      print version number, then exit
@@ -67,7 +67,7 @@ Report bugs and patches to <config-patches@gnu.org>."
 version="\
 GNU config.sub ($timestamp)
 
-Copyright 1992-2016 Free Software Foundation, Inc.
+Copyright 1992-2018 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -94,7 +94,7 @@ while test $# -gt 0 ; do
 
     *local*)
        # First pass through any local machine types.
-       echo $1
+       echo "$1"
        exit ;;
 
     * )
@@ -112,7 +112,7 @@ esac
 
 # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
 # Here we must recognize all the valid KERNEL-OS combinations.
-maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+maybe_os=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
 case $maybe_os in
   nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
   linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
@@ -120,16 +120,16 @@ case $maybe_os in
   kopensolaris*-gnu* | cloudabi*-eabi* | \
   storm-chaos* | os2-emx* | rtmk-nova*)
     os=-$maybe_os
-    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+    basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
     ;;
   android-linux)
     os=-linux-android
-    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
+    basic_machine=`echo "$1" | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
     ;;
   *)
-    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
-    if [ $basic_machine != $1 ]
-    then os=`echo $1 | sed 's/.*-/-/'`
+    basic_machine=`echo "$1" | sed 's/-[^-]*$//'`
+    if [ "$basic_machine" != "$1" ]
+    then os=`echo "$1" | sed 's/.*-/-/'`
     else os=; fi
     ;;
 esac
@@ -178,44 +178,44 @@ case $os in
 		;;
 	-sco6)
 		os=-sco5v6
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
 		;;
 	-sco5)
 		os=-sco3.2v5
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
 		;;
 	-sco4)
 		os=-sco3.2v4
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
 		;;
 	-sco3.2.[4-9]*)
 		os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
 		;;
 	-sco3.2v[4-9]*)
 		# Don't forget version if it is 3.2v4 or newer.
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
 		;;
 	-sco5v6*)
 		# Don't forget version if it is 3.2v4 or newer.
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
 		;;
 	-sco*)
 		os=-sco3.2v2
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
 		;;
 	-udk*)
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
 		;;
 	-isc)
 		os=-isc2.2
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
 		;;
 	-clix*)
 		basic_machine=clipper-intergraph
 		;;
 	-isc*)
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		basic_machine=`echo "$1" | sed -e 's/86-.*/86-pc/'`
 		;;
 	-lynx*178)
 		os=-lynxos178
@@ -227,10 +227,7 @@ case $os in
 		os=-lynxos
 		;;
 	-ptx*)
-		basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
-		;;
-	-windowsnt*)
-		os=`echo $os | sed -e 's/windowsnt/winnt/'`
+		basic_machine=`echo "$1" | sed -e 's/86-.*/86-sequent/'`
 		;;
 	-psos*)
 		os=-psos
@@ -263,7 +260,7 @@ case $basic_machine in
 	| fido | fr30 | frv | ft32 \
 	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
 	| hexagon \
-	| i370 | i860 | i960 | ia64 \
+	| i370 | i860 | i960 | ia16 | ia64 \
 	| ip2k | iq2000 \
 	| k1om \
 	| le32 | le64 \
@@ -299,7 +296,7 @@ case $basic_machine in
 	| nios | nios2 | nios2eb | nios2el \
 	| ns16k | ns32k \
 	| open8 | or1k | or1knd | or32 \
-	| pdp10 | pdp11 | pj | pjl \
+	| pdp10 | pj | pjl \
 	| powerpc | powerpc64 | powerpc64le | powerpcle \
 	| pru \
 	| pyramid \
@@ -315,7 +312,7 @@ case $basic_machine in
 	| ubicom32 \
 	| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
 	| visium \
-	| we32k \
+	| wasm32 \
 	| x86 | xc16x | xstormy16 | xtensa \
 	| z8k | z80)
 		basic_machine=$basic_machine-unknown
@@ -336,7 +333,7 @@ case $basic_machine in
 		basic_machine=$basic_machine-unknown
 		os=-none
 		;;
-	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65)
 		;;
 	ms1)
 		basic_machine=mt-unknown
@@ -365,7 +362,7 @@ case $basic_machine in
 	  ;;
 	# Object if more than one company name word.
 	*-*-*)
-		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+		echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2
 		exit 1
 		;;
 	# Recognize the basic CPU types with company name.
@@ -388,7 +385,7 @@ case $basic_machine in
 	| h8300-* | h8500-* \
 	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
 	| hexagon-* \
-	| i*86-* | i860-* | i960-* | ia64-* \
+	| i*86-* | i860-* | i960-* | ia16-* | ia64-* \
 	| ip2k-* | iq2000-* \
 	| k1om-* \
 	| le32-* | le64-* \
@@ -446,6 +443,7 @@ case $basic_machine in
 	| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
 	| vax-* \
 	| visium-* \
+	| wasm32-* \
 	| we32k-* \
 	| x86-* | x86_64-* | xc16x-* | xps100-* \
 	| xstormy16-* | xtensa*-* \
@@ -459,7 +457,7 @@ case $basic_machine in
 	# Recognize the various machine names and aliases which stand
 	# for a CPU type and a company and sometimes even an OS.
 	386bsd)
-		basic_machine=i386-unknown
+		basic_machine=i386-pc
 		os=-bsd
 		;;
 	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
@@ -493,7 +491,7 @@ case $basic_machine in
 		basic_machine=x86_64-pc
 		;;
 	amd64-*)
-		basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+		basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'`
 		;;
 	amdahl)
 		basic_machine=580-amdahl
@@ -538,7 +536,7 @@ case $basic_machine in
 		os=-linux
 		;;
 	blackfin-*)
-		basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
+		basic_machine=bfin-`echo "$basic_machine" | sed 's/^[^-]*-//'`
 		os=-linux
 		;;
 	bluegene*)
@@ -546,13 +544,13 @@ case $basic_machine in
 		os=-cnk
 		;;
 	c54x-*)
-		basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
+		basic_machine=tic54x-`echo "$basic_machine" | sed 's/^[^-]*-//'`
 		;;
 	c55x-*)
-		basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
+		basic_machine=tic55x-`echo "$basic_machine" | sed 's/^[^-]*-//'`
 		;;
 	c6x-*)
-		basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
+		basic_machine=tic6x-`echo "$basic_machine" | sed 's/^[^-]*-//'`
 		;;
 	c90)
 		basic_machine=c90-cray
@@ -641,7 +639,7 @@ case $basic_machine in
 		basic_machine=rs6000-bull
 		os=-bosx
 		;;
-	dpx2* | dpx2*-bull)
+	dpx2*)
 		basic_machine=m68k-bull
 		os=-sysv3
 		;;
@@ -650,7 +648,7 @@ case $basic_machine in
 		os=$os"spe"
 		;;
 	e500v[12]-*)
-		basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+		basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'`
 		os=$os"spe"
 		;;
 	ebmon29k)
@@ -742,9 +740,6 @@ case $basic_machine in
 	hp9k8[0-9][0-9] | hp8[0-9][0-9])
 		basic_machine=hppa1.0-hp
 		;;
-	hppa-next)
-		os=-nextstep3
-		;;
 	hppaosf)
 		basic_machine=hppa1.1-hp
 		os=-osf
@@ -757,26 +752,26 @@ case $basic_machine in
 		basic_machine=i370-ibm
 		;;
 	i*86v32)
-		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
 		os=-sysv32
 		;;
 	i*86v4*)
-		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
 		os=-sysv4
 		;;
 	i*86v)
-		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
 		os=-sysv
 		;;
 	i*86sol2)
-		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
 		os=-solaris2
 		;;
 	i386mach)
 		basic_machine=i386-mach
 		os=-mach
 		;;
-	i386-vsta | vsta)
+	vsta)
 		basic_machine=i386-unknown
 		os=-vsta
 		;;
@@ -795,19 +790,16 @@ case $basic_machine in
 		os=-sysv
 		;;
 	leon-*|leon[3-9]-*)
-		basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'`
+		basic_machine=sparc-`echo "$basic_machine" | sed 's/-.*//'`
 		;;
 	m68knommu)
 		basic_machine=m68k-unknown
 		os=-linux
 		;;
 	m68knommu-*)
-		basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
+		basic_machine=m68k-`echo "$basic_machine" | sed 's/^[^-]*-//'`
 		os=-linux
 		;;
-	m88k-omron*)
-		basic_machine=m88k-omron
-		;;
 	magnum | m3230)
 		basic_machine=mips-mips
 		os=-sysv
@@ -839,10 +831,10 @@ case $basic_machine in
 		os=-mint
 		;;
 	mips3*-*)
-		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+		basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`
 		;;
 	mips3*)
-		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+		basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`-unknown
 		;;
 	monitor)
 		basic_machine=m68k-rom68k
@@ -861,7 +853,7 @@ case $basic_machine in
 		os=-msdos
 		;;
 	ms1-*)
-		basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+		basic_machine=`echo "$basic_machine" | sed -e 's/ms1-/mt-/'`
 		;;
 	msys)
 		basic_machine=i686-pc
@@ -903,7 +895,7 @@ case $basic_machine in
 		basic_machine=v70-nec
 		os=-sysv
 		;;
-	next | m*-next )
+	next | m*-next)
 		basic_machine=m68k-next
 		case $os in
 		    -nextstep* )
@@ -948,6 +940,12 @@ case $basic_machine in
 	nsr-tandem)
 		basic_machine=nsr-tandem
 		;;
+	nsv-tandem)
+		basic_machine=nsv-tandem
+		;;
+	nsx-tandem)
+		basic_machine=nsx-tandem
+		;;
 	op50n-* | op60c-*)
 		basic_machine=hppa1.1-oki
 		os=-proelf
@@ -980,7 +978,7 @@ case $basic_machine in
 		os=-linux
 		;;
 	parisc-*)
-		basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
+		basic_machine=hppa-`echo "$basic_machine" | sed 's/^[^-]*-//'`
 		os=-linux
 		;;
 	pbd)
@@ -996,7 +994,7 @@ case $basic_machine in
 		basic_machine=i386-pc
 		;;
 	pc98-*)
-		basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+		basic_machine=i386-`echo "$basic_machine" | sed 's/^[^-]*-//'`
 		;;
 	pentium | p5 | k5 | k6 | nexgen | viac3)
 		basic_machine=i586-pc
@@ -1011,16 +1009,16 @@ case $basic_machine in
 		basic_machine=i786-pc
 		;;
 	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
-		basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+		basic_machine=i586-`echo "$basic_machine" | sed 's/^[^-]*-//'`
 		;;
 	pentiumpro-* | p6-* | 6x86-* | athlon-*)
-		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+		basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'`
 		;;
 	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
-		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+		basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'`
 		;;
 	pentium4-*)
-		basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+		basic_machine=i786-`echo "$basic_machine" | sed 's/^[^-]*-//'`
 		;;
 	pn)
 		basic_machine=pn-gould
@@ -1030,23 +1028,23 @@ case $basic_machine in
 	ppc | ppcbe)	basic_machine=powerpc-unknown
 		;;
 	ppc-* | ppcbe-*)
-		basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+		basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'`
 		;;
 	ppcle | powerpclittle)
 		basic_machine=powerpcle-unknown
 		;;
 	ppcle-* | powerpclittle-*)
-		basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+		basic_machine=powerpcle-`echo "$basic_machine" | sed 's/^[^-]*-//'`
 		;;
 	ppc64)	basic_machine=powerpc64-unknown
 		;;
-	ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+	ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'`
 		;;
 	ppc64le | powerpc64little)
 		basic_machine=powerpc64le-unknown
 		;;
 	ppc64le-* | powerpc64little-*)
-		basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+		basic_machine=powerpc64le-`echo "$basic_machine" | sed 's/^[^-]*-//'`
 		;;
 	ps2)
 		basic_machine=i386-ibm
@@ -1100,17 +1098,10 @@ case $basic_machine in
 	sequent)
 		basic_machine=i386-sequent
 		;;
-	sh)
-		basic_machine=sh-hitachi
-		os=-hms
-		;;
 	sh5el)
 		basic_machine=sh5le-unknown
 		;;
-	sh64)
-		basic_machine=sh64-unknown
-		;;
-	sparclite-wrs | simso-wrs)
+	simso-wrs)
 		basic_machine=sparclite-wrs
 		os=-vxworks
 		;;
@@ -1129,7 +1120,7 @@ case $basic_machine in
 		os=-sysv4
 		;;
 	strongarm-* | thumb-*)
-		basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
+		basic_machine=arm-`echo "$basic_machine" | sed 's/^[^-]*-//'`
 		;;
 	sun2)
 		basic_machine=m68000-sun
@@ -1251,6 +1242,9 @@ case $basic_machine in
 		basic_machine=hppa1.1-winbond
 		os=-proelf
 		;;
+	x64)
+		basic_machine=x86_64-pc
+		;;
 	xbox)
 		basic_machine=i686-pc
 		os=-mingw32
@@ -1259,20 +1253,12 @@ case $basic_machine in
 		basic_machine=xps100-honeywell
 		;;
 	xscale-* | xscalee[bl]-*)
-		basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
+		basic_machine=`echo "$basic_machine" | sed 's/^xscale/arm/'`
 		;;
 	ymp)
 		basic_machine=ymp-cray
 		os=-unicos
 		;;
-	z8k-*-coff)
-		basic_machine=z8k-unknown
-		os=-sim
-		;;
-	z80-*-coff)
-		basic_machine=z80-unknown
-		os=-sim
-		;;
 	none)
 		basic_machine=none-none
 		os=-none
@@ -1301,10 +1287,6 @@ case $basic_machine in
 	vax)
 		basic_machine=vax-dec
 		;;
-	pdp10)
-		# there are many clones, so DEC is not a safe bet
-		basic_machine=pdp10-unknown
-		;;
 	pdp11)
 		basic_machine=pdp11-dec
 		;;
@@ -1314,9 +1296,6 @@ case $basic_machine in
 	sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
 		basic_machine=sh-unknown
 		;;
-	sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
-		basic_machine=sparc-sun
-		;;
 	cydra)
 		basic_machine=cydra-cydrome
 		;;
@@ -1336,7 +1315,7 @@ case $basic_machine in
 		# Make sure to match an already-canonicalized machine name.
 		;;
 	*)
-		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+		echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2
 		exit 1
 		;;
 esac
@@ -1344,10 +1323,10 @@ esac
 # Here we canonicalize certain aliases for manufacturers.
 case $basic_machine in
 	*-digital*)
-		basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+		basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'`
 		;;
 	*-commodore*)
-		basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+		basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'`
 		;;
 	*)
 		;;
@@ -1358,8 +1337,8 @@ esac
 if [ x"$os" != x"" ]
 then
 case $os in
-	# First match some system type aliases
-	# that might get confused with valid system types.
+	# First match some system type aliases that might get confused
+	# with valid system types.
 	# -solaris* is a basic system type, with this one exception.
 	-auroraux)
 		os=-auroraux
@@ -1370,18 +1349,19 @@ case $os in
 	-solaris)
 		os=-solaris2
 		;;
-	-svr4*)
-		os=-sysv4
-		;;
 	-unixware*)
 		os=-sysv4.2uw
 		;;
 	-gnu/linux*)
 		os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
 		;;
-	# First accept the basic system types.
+	# es1800 is here to avoid being matched by es* (a different OS)
+	-es1800*)
+		os=-ose
+		;;
+	# Now accept the basic system types.
 	# The portable systems comes first.
-	# Each alternative MUST END IN A *, to match a version number.
+	# Each alternative MUST end in a * to match a version number.
 	# -sysv* is not here because it comes later, after sysvr4.
 	-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
 	      | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
@@ -1391,25 +1371,26 @@ case $os in
 	      | -aos* | -aros* | -cloudabi* | -sortix* \
 	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
 	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
-	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+	      | -hiux* | -knetbsd* | -mirbsd* | -netbsd* \
 	      | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \
 	      | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
 	      | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
 	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
 	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
-	      | -chorusos* | -chorusrdb* | -cegcc* \
+	      | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \
 	      | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
 	      | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
 	      | -linux-newlib* | -linux-musl* | -linux-uclibc* \
 	      | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
-	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* \
 	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
 	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
 	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
-	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+	      | -morphos* | -superux* | -rtmk* | -windiss* \
 	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
 	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \
-	      | -onefs* | -tirtos* | -phoenix* | -fuchsia*)
+	      | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox* | -bme* \
+	      | -midnightbsd*)
 	# Remember, each alternative MUST END IN *, to match a version number.
 		;;
 	-qnx*)
@@ -1426,12 +1407,12 @@ case $os in
 	-nto*)
 		os=`echo $os | sed -e 's|nto|nto-qnx|'`
 		;;
-	-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
-	      | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+	-sim | -xray | -os68k* | -v88r* \
+	      | -windows* | -osx | -abug | -netware* | -os9* \
 	      | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
 		;;
 	-mac*)
-		os=`echo $os | sed -e 's|mac|macos|'`
+		os=`echo "$os" | sed -e 's|mac|macos|'`
 		;;
 	-linux-dietlibc)
 		os=-linux-dietlibc
@@ -1440,10 +1421,10 @@ case $os in
 		os=`echo $os | sed -e 's|linux|linux-gnu|'`
 		;;
 	-sunos5*)
-		os=`echo $os | sed -e 's|sunos5|solaris2|'`
+		os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
 		;;
 	-sunos6*)
-		os=`echo $os | sed -e 's|sunos6|solaris3|'`
+		os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
 		;;
 	-opened*)
 		os=-openedition
@@ -1454,12 +1435,6 @@ case $os in
 	-wince*)
 		os=-wince
 		;;
-	-osfrose*)
-		os=-osfrose
-		;;
-	-osf*)
-		os=-osf
-		;;
 	-utek*)
 		os=-bsd
 		;;
@@ -1484,7 +1459,7 @@ case $os in
 	-nova*)
 		os=-rtmk-nova
 		;;
-	-ns2 )
+	-ns2)
 		os=-nextstep2
 		;;
 	-nsk*)
@@ -1506,7 +1481,7 @@ case $os in
 	-oss*)
 		os=-sysv3
 		;;
-	-svr4)
+	-svr4*)
 		os=-sysv4
 		;;
 	-svr3)
@@ -1521,24 +1496,28 @@ case $os in
 	-ose*)
 		os=-ose
 		;;
-	-es1800*)
-		os=-ose
-		;;
-	-xenix)
-		os=-xenix
-		;;
 	-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
 		os=-mint
 		;;
-	-aros*)
-		os=-aros
-		;;
 	-zvmoe)
 		os=-zvmoe
 		;;
 	-dicos*)
 		os=-dicos
 		;;
+	-pikeos*)
+		# Until real need of OS specific support for
+		# particular features comes up, bare metal
+		# configurations are quite functional.
+		case $basic_machine in
+		    arm*)
+			os=-eabi
+			;;
+		    *)
+			os=-elf
+			;;
+		esac
+		;;
 	-nacl*)
 		;;
 	-ios)
@@ -1548,7 +1527,7 @@ case $os in
 	*)
 		# Get rid of the `-' at the beginning of $os.
 		os=`echo $os | sed 's/[^-]*-//'`
-		echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+		echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2
 		exit 1
 		;;
 esac
@@ -1638,12 +1617,12 @@ case $basic_machine in
 	sparc-* | *-sun)
 		os=-sunos4.1.1
 		;;
+	pru-*)
+		os=-elf
+		;;
 	*-be)
 		os=-beos
 		;;
-	*-haiku)
-		os=-haiku
-		;;
 	*-ibm)
 		os=-aix
 		;;
@@ -1683,7 +1662,7 @@ case $basic_machine in
 	m88k-omron*)
 		os=-luna
 		;;
-	*-next )
+	*-next)
 		os=-nextstep
 		;;
 	*-sequent)
@@ -1698,9 +1677,6 @@ case $basic_machine in
 	i370-*)
 		os=-mvs
 		;;
-	*-next)
-		os=-nextstep3
-		;;
 	*-gould)
 		os=-sysv
 		;;
@@ -1810,15 +1786,15 @@ case $basic_machine in
 				vendor=stratus
 				;;
 		esac
-		basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+		basic_machine=`echo "$basic_machine" | sed "s/unknown/$vendor/"`
 		;;
 esac
 
-echo $basic_machine$os
+echo "$basic_machine$os"
 exit
 
 # Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'write-file-functions 'time-stamp)
 # time-stamp-start: "timestamp='"
 # time-stamp-format: "%:y-%02m-%02d"
 # time-stamp-end: "'"

+ 5 - 5
config/depcomp

@@ -1,9 +1,9 @@
 #! /bin/sh
 # depcomp - compile a program generating dependencies as side-effects
 
-scriptversion=2013-05-30.07; # UTC
+scriptversion=2018-03-07.03; # UTC
 
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2018 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -16,7 +16,7 @@ scriptversion=2013-05-30.07; # UTC
 # GNU General Public License for more details.
 
 # You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -783,9 +783,9 @@ exit 0
 # Local Variables:
 # mode: shell-script
 # sh-indentation: 2
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
 # time-stamp-end: "; # UTC"
 # End:

+ 23 - 13
config/install-sh

@@ -1,7 +1,7 @@
 #!/bin/sh
 # install - install a program, script, or datafile
 
-scriptversion=2014-09-12.12; # UTC
+scriptversion=2018-03-11.20; # UTC
 
 # This originates from X11R5 (mit/util/scripts/install.sh), which was
 # later released in X11R6 (xc/config/util/install.sh) with the
@@ -271,15 +271,18 @@ do
     fi
     dst=$dst_arg
 
-    # If destination is a directory, append the input filename; won't work
-    # if double slashes aren't ignored.
+    # If destination is a directory, append the input filename.
     if test -d "$dst"; then
       if test "$is_target_a_directory" = never; then
         echo "$0: $dst_arg: Is a directory" >&2
         exit 1
       fi
       dstdir=$dst
-      dst=$dstdir/`basename "$src"`
+      dstbase=`basename "$src"`
+      case $dst in
+	*/) dst=$dst$dstbase;;
+	*)  dst=$dst/$dstbase;;
+      esac
       dstdir_status=0
     else
       dstdir=`dirname "$dst"`
@@ -288,6 +291,11 @@ do
     fi
   fi
 
+  case $dstdir in
+    */) dstdirslash=$dstdir;;
+    *)  dstdirslash=$dstdir/;;
+  esac
+
   obsolete_mkdir_used=false
 
   if test $dstdir_status != 0; then
@@ -324,14 +332,16 @@ do
             # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
             ;;
           *)
-            # $RANDOM is not portable (e.g. dash);  use it when possible to
-            # lower collision chance
+            # Note that $RANDOM variable is not portable (e.g. dash);  Use it
+            # here however when possible just to lower collision chance.
             tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+
             trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0
 
-            # As "mkdir -p" follows symlinks and we work in /tmp possibly;  so
-            # create the $tmpdir first (and fail if unsuccessful) to make sure
-            # that nobody tries to guess the $tmpdir name.
+            # Because "mkdir -p" follows existing symlinks and we likely work
+            # directly in world-writeable /tmp, make sure that the '$tmpdir'
+            # directory is successfully created first before we actually test
+            # 'mkdir -p' feature.
             if (umask $mkdir_umask &&
                 $mkdirprog $mkdir_mode "$tmpdir" &&
                 exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
@@ -434,8 +444,8 @@ do
   else
 
     # Make a couple of temp file names in the proper directory.
-    dsttmp=$dstdir/_inst.$$_
-    rmtmp=$dstdir/_rm.$$_
+    dsttmp=${dstdirslash}_inst.$$_
+    rmtmp=${dstdirslash}_rm.$$_
 
     # Trap to clean up those temp files at exit.
     trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
@@ -500,9 +510,9 @@ do
 done
 
 # Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
 # time-stamp-end: "; # UTC"
 # End:

+ 153 - 60
config/ltmain.sh

@@ -31,7 +31,7 @@
 
 PROGRAM=libtool
 PACKAGE=libtool
-VERSION="2.4.6 Debian-2.4.6-2"
+VERSION="2.4.6 Debian-2.4.6-9"
 package_revision=2.4.6
 
 
@@ -1370,7 +1370,7 @@ func_lt_ver ()
 #! /bin/sh
 
 # Set a version string for this script.
-scriptversion=2014-01-07.03; # UTC
+scriptversion=2015-10-07.11; # UTC
 
 # A portable, pluggable option parser for Bourne shell.
 # Written by Gary V. Vaughan, 2010
@@ -1530,6 +1530,8 @@ func_run_hooks ()
 {
     $debug_cmd
 
+    _G_rc_run_hooks=false
+
     case " $hookable_fns " in
       *" $1 "*) ;;
       *) func_fatal_error "'$1' does not support hook funcions.n" ;;
@@ -1538,16 +1540,16 @@ func_run_hooks ()
     eval _G_hook_fns=\$$1_hooks; shift
 
     for _G_hook in $_G_hook_fns; do
-      eval $_G_hook '"$@"'
-
-      # store returned options list back into positional
-      # parameters for next 'cmd' execution.
-      eval _G_hook_result=\$${_G_hook}_result
-      eval set dummy "$_G_hook_result"; shift
+      if eval $_G_hook '"$@"'; then
+        # store returned options list back into positional
+        # parameters for next 'cmd' execution.
+        eval _G_hook_result=\$${_G_hook}_result
+        eval set dummy "$_G_hook_result"; shift
+        _G_rc_run_hooks=:
+      fi
     done
 
-    func_quote_for_eval ${1+"$@"}
-    func_run_hooks_result=$func_quote_for_eval_result
+    $_G_rc_run_hooks && func_run_hooks_result=$_G_hook_result
 }
 
 
@@ -1557,10 +1559,16 @@ func_run_hooks ()
 ## --------------- ##
 
 # In order to add your own option parsing hooks, you must accept the
-# full positional parameter list in your hook function, remove any
-# options that you action, and then pass back the remaining unprocessed
+# full positional parameter list in your hook function, you may remove/edit
+# any options that you action, and then pass back the remaining unprocessed
 # options in '<hooked_function_name>_result', escaped suitably for
-# 'eval'.  Like this:
+# 'eval'.  In this case you also must return $EXIT_SUCCESS to let the
+# hook's caller know that it should pay attention to
+# '<hooked_function_name>_result'.  Returning $EXIT_FAILURE signalizes that
+# arguments are left untouched by the hook and therefore caller will ignore the
+# result variable.
+#
+# Like this:
 #
 #    my_options_prep ()
 #    {
@@ -1570,9 +1578,11 @@ func_run_hooks ()
 #        usage_message=$usage_message'
 #      -s, --silent       don'\''t print informational messages
 #    '
-#
-#        func_quote_for_eval ${1+"$@"}
-#        my_options_prep_result=$func_quote_for_eval_result
+#        # No change in '$@' (ignored completely by this hook).  There is
+#        # no need to do the equivalent (but slower) action:
+#        # func_quote_for_eval ${1+"$@"}
+#        # my_options_prep_result=$func_quote_for_eval_result
+#        false
 #    }
 #    func_add_hook func_options_prep my_options_prep
 #
@@ -1581,25 +1591,37 @@ func_run_hooks ()
 #    {
 #        $debug_cmd
 #
+#        args_changed=false
+#
 #        # Note that for efficiency, we parse as many options as we can
 #        # recognise in a loop before passing the remainder back to the
 #        # caller on the first unrecognised argument we encounter.
 #        while test $# -gt 0; do
 #          opt=$1; shift
 #          case $opt in
-#            --silent|-s) opt_silent=: ;;
+#            --silent|-s) opt_silent=:
+#                         args_changed=:
+#                         ;;
 #            # Separate non-argument short options:
 #            -s*)         func_split_short_opt "$_G_opt"
 #                         set dummy "$func_split_short_opt_name" \
 #                             "-$func_split_short_opt_arg" ${1+"$@"}
 #                         shift
+#                         args_changed=:
 #                         ;;
-#            *)            set dummy "$_G_opt" "$*"; shift; break ;;
+#            *)           # Make sure the first unrecognised option "$_G_opt"
+#                         # is added back to "$@", we could need that later
+#                         # if $args_changed is true.
+#                         set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
 #          esac
 #        done
 #
-#        func_quote_for_eval ${1+"$@"}
-#        my_silent_option_result=$func_quote_for_eval_result
+#        if $args_changed; then
+#          func_quote_for_eval ${1+"$@"}
+#          my_silent_option_result=$func_quote_for_eval_result
+#        fi
+#
+#        $args_changed
 #    }
 #    func_add_hook func_parse_options my_silent_option
 #
@@ -1611,16 +1633,32 @@ func_run_hooks ()
 #        $opt_silent && $opt_verbose && func_fatal_help "\
 #    '--silent' and '--verbose' options are mutually exclusive."
 #
-#        func_quote_for_eval ${1+"$@"}
-#        my_option_validation_result=$func_quote_for_eval_result
+#        false
 #    }
 #    func_add_hook func_validate_options my_option_validation
 #
-# You'll alse need to manually amend $usage_message to reflect the extra
+# You'll also need to manually amend $usage_message to reflect the extra
 # options you parse.  It's preferable to append if you can, so that
 # multiple option parsing hooks can be added safely.
 
 
+# func_options_finish [ARG]...
+# ----------------------------
+# Finishing the option parse loop (call 'func_options' hooks ATM).
+func_options_finish ()
+{
+    $debug_cmd
+
+    _G_func_options_finish_exit=false
+    if func_run_hooks func_options ${1+"$@"}; then
+      func_options_finish_result=$func_run_hooks_result
+      _G_func_options_finish_exit=:
+    fi
+
+    $_G_func_options_finish_exit
+}
+
+
 # func_options [ARG]...
 # ---------------------
 # All the functions called inside func_options are hookable. See the
@@ -1630,17 +1668,28 @@ func_options ()
 {
     $debug_cmd
 
-    func_options_prep ${1+"$@"}
-    eval func_parse_options \
-        ${func_options_prep_result+"$func_options_prep_result"}
-    eval func_validate_options \
-        ${func_parse_options_result+"$func_parse_options_result"}
+    _G_rc_options=false
 
-    eval func_run_hooks func_options \
-        ${func_validate_options_result+"$func_validate_options_result"}
+    for my_func in options_prep parse_options validate_options options_finish
+    do
+      if eval func_$my_func '${1+"$@"}'; then
+        eval _G_res_var='$'"func_${my_func}_result"
+        eval set dummy "$_G_res_var" ; shift
+        _G_rc_options=:
+      fi
+    done
+
+    # Save modified positional parameters for caller.  As a top-level
+    # options-parser function we always need to set the 'func_options_result'
+    # variable (regardless the $_G_rc_options value).
+    if $_G_rc_options; then
+      func_options_result=$_G_res_var
+    else
+      func_quote_for_eval ${1+"$@"}
+      func_options_result=$func_quote_for_eval_result
+    fi
 
-    # save modified positional parameters for caller
-    func_options_result=$func_run_hooks_result
+    $_G_rc_options
 }
 
 
@@ -1649,9 +1698,9 @@ func_options ()
 # All initialisations required before starting the option parse loop.
 # Note that when calling hook functions, we pass through the list of
 # positional parameters.  If a hook function modifies that list, and
-# needs to propogate that back to rest of this script, then the complete
+# needs to propagate that back to rest of this script, then the complete
 # modified list must be put in 'func_run_hooks_result' before
-# returning.
+# returning $EXIT_SUCCESS (otherwise $EXIT_FAILURE is returned).
 func_hookable func_options_prep
 func_options_prep ()
 {
@@ -1661,10 +1710,14 @@ func_options_prep ()
     opt_verbose=false
     opt_warning_types=
 
-    func_run_hooks func_options_prep ${1+"$@"}
+    _G_rc_options_prep=false
+    if func_run_hooks func_options_prep ${1+"$@"}; then
+      _G_rc_options_prep=:
+      # save modified positional parameters for caller
+      func_options_prep_result=$func_run_hooks_result
+    fi
 
-    # save modified positional parameters for caller
-    func_options_prep_result=$func_run_hooks_result
+    $_G_rc_options_prep
 }
 
 
@@ -1678,18 +1731,20 @@ func_parse_options ()
 
     func_parse_options_result=
 
+    _G_rc_parse_options=false
     # this just eases exit handling
     while test $# -gt 0; do
       # Defer to hook functions for initial option parsing, so they
       # get priority in the event of reusing an option name.
-      func_run_hooks func_parse_options ${1+"$@"}
-
-      # Adjust func_parse_options positional parameters to match
-      eval set dummy "$func_run_hooks_result"; shift
+      if func_run_hooks func_parse_options ${1+"$@"}; then
+        eval set dummy "$func_run_hooks_result"; shift
+        _G_rc_parse_options=:
+      fi
 
       # Break out of the loop if we already parsed every option.
       test $# -gt 0 || break
 
+      _G_match_parse_options=:
       _G_opt=$1
       shift
       case $_G_opt in
@@ -1704,7 +1759,10 @@ func_parse_options ()
 		      ;;
 
         --warnings|--warning|-W)
-                      test $# = 0 && func_missing_arg $_G_opt && break
+                      if test $# = 0 && func_missing_arg $_G_opt; then
+                        _G_rc_parse_options=:
+                        break
+                      fi
                       case " $warning_categories $1" in
                         *" $1 "*)
                           # trailing space prevents matching last $1 above
@@ -1757,15 +1815,25 @@ func_parse_options ()
                       shift
                       ;;
 
-        --)           break ;;
+        --)           _G_rc_parse_options=: ; break ;;
         -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
-        *)            set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
+        *)            set dummy "$_G_opt" ${1+"$@"}; shift
+                      _G_match_parse_options=false
+                      break
+                      ;;
       esac
+
+      $_G_match_parse_options && _G_rc_parse_options=:
     done
 
-    # save modified positional parameters for caller
-    func_quote_for_eval ${1+"$@"}
-    func_parse_options_result=$func_quote_for_eval_result
+
+    if $_G_rc_parse_options; then
+      # save modified positional parameters for caller
+      func_quote_for_eval ${1+"$@"}
+      func_parse_options_result=$func_quote_for_eval_result
+    fi
+
+    $_G_rc_parse_options
 }
 
 
@@ -1778,16 +1846,21 @@ func_validate_options ()
 {
     $debug_cmd
 
+    _G_rc_validate_options=false
+
     # Display all warnings if -W was not given.
     test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
 
-    func_run_hooks func_validate_options ${1+"$@"}
+    if func_run_hooks func_validate_options ${1+"$@"}; then
+      # save modified positional parameters for caller
+      func_validate_options_result=$func_run_hooks_result
+      _G_rc_validate_options=:
+    fi
 
     # Bail if the options were screwed!
     $exit_cmd $EXIT_FAILURE
 
-    # save modified positional parameters for caller
-    func_validate_options_result=$func_run_hooks_result
+    $_G_rc_validate_options
 }
 
 
@@ -2068,7 +2141,7 @@ include the following information:
        compiler:       $LTCC
        compiler flags: $LTCFLAGS
        linker:         $LD (gnu? $with_gnu_ld)
-       version:        $progname $scriptversion Debian-2.4.6-2
+       version:        $progname $scriptversion Debian-2.4.6-9
        automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
        autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
 
@@ -2270,6 +2343,8 @@ libtool_options_prep ()
     nonopt=
     preserve_args=
 
+    _G_rc_lt_options_prep=:
+
     # Shorthand for --mode=foo, only valid as the first argument
     case $1 in
     clean|clea|cle|cl)
@@ -2293,11 +2368,18 @@ libtool_options_prep ()
     uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
       shift; set dummy --mode uninstall ${1+"$@"}; shift
       ;;
+    *)
+      _G_rc_lt_options_prep=false
+      ;;
     esac
 
-    # Pass back the list of options.
-    func_quote_for_eval ${1+"$@"}
-    libtool_options_prep_result=$func_quote_for_eval_result
+    if $_G_rc_lt_options_prep; then
+      # Pass back the list of options.
+      func_quote_for_eval ${1+"$@"}
+      libtool_options_prep_result=$func_quote_for_eval_result
+    fi
+
+    $_G_rc_lt_options_prep
 }
 func_add_hook func_options_prep libtool_options_prep
 
@@ -2309,9 +2391,12 @@ libtool_parse_options ()
 {
     $debug_cmd
 
+    _G_rc_lt_parse_options=false
+
     # Perform our own loop to consume as many options as possible in
     # each iteration.
     while test $# -gt 0; do
+      _G_match_lt_parse_options=:
       _G_opt=$1
       shift
       case $_G_opt in
@@ -2386,15 +2471,22 @@ libtool_parse_options ()
                         func_append preserve_args " $_G_opt"
                         ;;
 
-	# An option not handled by this hook function:
-        *)		set dummy "$_G_opt" ${1+"$@"};	shift; break  ;;
+        # An option not handled by this hook function:
+        *)              set dummy "$_G_opt" ${1+"$@"} ; shift
+                        _G_match_lt_parse_options=false
+                        break
+                        ;;
       esac
+      $_G_match_lt_parse_options && _G_rc_lt_parse_options=:
     done
 
+    if $_G_rc_lt_parse_options; then
+      # save modified positional parameters for caller
+      func_quote_for_eval ${1+"$@"}
+      libtool_parse_options_result=$func_quote_for_eval_result
+    fi
 
-    # save modified positional parameters for caller
-    func_quote_for_eval ${1+"$@"}
-    libtool_parse_options_result=$func_quote_for_eval_result
+    $_G_rc_lt_parse_options
 }
 func_add_hook func_parse_options libtool_parse_options
 
@@ -7275,10 +7367,11 @@ func_mode_link ()
       # -specs=*             GCC specs files
       # -stdlib=*            select c++ std lib with clang
       # -fsanitize=*         Clang/GCC memory and address sanitizer
+      # -fuse-ld=*           Linker select flags for GCC
       -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
       -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
       -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
-      -specs=*|-fsanitize=*)
+      -specs=*|-fsanitize=*|-fuse-ld=*)
         func_quote_for_eval "$arg"
 	arg=$func_quote_for_eval_result
         func_append compile_command " $arg"

+ 8 - 8
config/missing

@@ -1,9 +1,9 @@
 #! /bin/sh
 # Common wrapper for a few potentially missing GNU programs.
 
-scriptversion=2013-10-28.13; # UTC
+scriptversion=2018-03-07.03; # UTC
 
-# Copyright (C) 1996-2014 Free Software Foundation, Inc.
+# Copyright (C) 1996-2018 Free Software Foundation, Inc.
 # Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
 
 # This program is free software; you can redistribute it and/or modify
@@ -17,7 +17,7 @@ scriptversion=2013-10-28.13; # UTC
 # GNU General Public License for more details.
 
 # You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -101,9 +101,9 @@ else
   exit $st
 fi
 
-perl_URL=http://www.perl.org/
-flex_URL=http://flex.sourceforge.net/
-gnu_software_URL=http://www.gnu.org/software
+perl_URL=https://www.perl.org/
+flex_URL=https://github.com/westes/flex
+gnu_software_URL=https://www.gnu.org/software
 
 program_details ()
 {
@@ -207,9 +207,9 @@ give_advice "$1" | sed -e '1s/^/WARNING: /' \
 exit $st
 
 # Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
 # time-stamp-end: "; # UTC"
 # End:

ファイルの差分が大きいため隠しています
+ 256 - 690
configure


+ 101 - 120
configure.ac

@@ -4,19 +4,16 @@ dnl $Id$
 AC_PREREQ([2.69])
 
 dnl Set version info here!
-AC_INIT([tcpreplay],[4.3.3],
-    [https://github.com/appneta/tcpreplay/issues],
-    [tcpreplay],
-    [http://tcpreplay.sourceforge.net/])
+AC_INIT([tcpreplay],[4.3.4],[https://github.com/appneta/tcpreplay/issues],[tcpreplay],[http://tcpreplay.sourceforge.net/])
 AC_CONFIG_SRCDIR([src/tcpreplay.c])
-AM_CONFIG_HEADER([src/config.h])
+AC_CONFIG_HEADERS([src/config.h])
 AC_CONFIG_AUX_DIR(config)
 AM_MAINTAINER_MODE([enable])
 AM_WITH_DMALLOC
 
 dnl People building from GitHub need the same version of Autogen as I'm using
 dnl or specify --disable-local-libopts to force using the locally-installed
-dnl copy of libopts rather than the source in the `./liopts/` directory.
+dnl copy of libopts rather than the source in the `./libopts/` directory.
 MAINTAINER_AUTOGEN_VERSION=5.18.12
 
 AC_CONFIG_MACRO_DIR([m4])
@@ -146,20 +143,14 @@ else
 fi
 
 
-AM_INIT_AUTOMAKE([foreign subdir-objects -Wall -Wno-override])
+AM_INIT_AUTOMAKE([1.15 foreign subdir-objects -Wall -Wno-override])
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
 dnl Checks for programs.
 AM_PROG_AR
 AC_PROG_INSTALL
-AC_PROG_LIBTOOL
+LT_INIT
 AC_PROG_CC
-
-# for compat with old systems.
-# deprecated in favor of AC_PROG_CC since automake 1.14 and is now no-op
-AM_PROG_CC_C_O
-
-AC_PROG_CC_STDC
 AC_PROG_CXX
 AC_PROG_CPP
 AC_PROG_LN_S
@@ -208,7 +199,7 @@ if test -n "${AUTOGEN}" ; then
             (test ${AUTOGEN_MAJOR} -eq 5 && test ${AUTOGEN_MINOR} -lt 18) ||
             test ${AUTOGEN_MAJOR} -lt 5 ; then
         AC_MSG_RESULT(no)
-        if test "x$enable_local_libopts" == "xno"; then
+        if test ! "x$enable_local_libopts" = "xyes"; then
             AC_MSG_ERROR([${AUTOGEN} is too old (${AUTOGEN_VERSION}) for building from source code. Upgrade to 5.18.4 or higher])
         fi
         AUTOGEN_VERSION="${AUTOGEN_VERSION} - downlevel"
@@ -224,7 +215,7 @@ if test -n "${AUTOGEN}" ; then
     fi
 else
     if test ! -f src/tcpreplay_opts.c ; then
-        AC_MSG_ERROR([Please install GNU autogen $MAINTAINER_AUTOGEN_VERSION or higher if you are building from GitHub. To avoid this message download source from http://tcpreplay.appneta.com/wiki/installation.html])
+        AC_MSG_ERROR([Please install GNU autogen $MAINTAINER_AUTOGEN_VERSION or higher if you are building from GitHub. To avoid this message download source from https://github.com/appneta/tcpreplay/releases/latest])
     fi
 fi
 AC_DEFINE([AUTOGEN_VERSION], [${AUTOGEN_VERSION}], [What version of autogen is installed on this system])
@@ -235,7 +226,7 @@ else
     AC_MSG_NOTICE([Using system libopts])
 fi
 
-AC_HEADER_STDC
+AC_PROG_EGREP
 AC_HEADER_MAJOR
 
 dnl Checks for typedefs, structures, and compiler characteristics.
@@ -253,7 +244,7 @@ AC_TYPE_UINT16_T
 AC_TYPE_UINT32_T
 AC_TYPE_UINT64_T
 AC_TYPE_UINT8_T
-AC_HEADER_TIME
+AC_CHECK_HEADERS_ONCE([sys/time.h])
 AC_C_CONST
 AC_C_INLINE
 AC_SYS_LARGEFILE
@@ -280,6 +271,7 @@ case $host in
             [ AC_MSG_RESULT(yes)
               wno_macro_redefined="-Wno-macro-redefined" ],
             [ AC_MSG_RESULT(no) ])
+        AC_MSG_CHECKING(for $CC -Wno-format)
         CFLAGS="$OLD_CFLAGS $wno_macro_redefined"
         CFLAGS="$CFLAGS -Wno-format -Werror"
         AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
@@ -368,11 +360,9 @@ dnl Checks for library functions.
 AC_FUNC_FORK
 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
 AC_FUNC_MEMCMP
-AC_TYPE_SIGNAL
 AC_FUNC_VPRINTF
 AC_FUNC_MKTIME
 AC_FUNC_MMAP
-AC_FUNC_REALLOC
 AC_CHECK_MEMBERS([struct timeval.tv_sec])
 AC_CHECK_FUNCS([alarm atexit bzero dup2 gethostbyname getpagesize gettimeofday])
 AC_CHECK_FUNCS([ctime inet_ntoa memmove memset munmap pow putenv realpath])
@@ -389,7 +379,7 @@ AC_C_BIGENDIAN
 AM_CONDITIONAL([WORDS_BIGENDIAN], [ test x$ac_cv_c_bigendian = xyes ])
 
 AC_ARG_ENABLE([asan],
-    AC_HELP_STRING([--enable-asan], [Enable Address Sanitizer support]))
+    AS_HELP_STRING([--enable-asan],[Enable Address Sanitizer support]))
 if test "x$enable_asan" = "xyes"; then
         build_asan=yes
         AC_CHECK_LIB([asan], [__asan_report_error], ,
@@ -407,7 +397,7 @@ debug=no
 debug_flag=NDEBUG
 debug_run_time_flag=
 AC_ARG_ENABLE(debug,
-    AC_HELP_STRING([--enable-debug], [Enable debugging code and support for the -d option]),
+    AS_HELP_STRING([--enable-debug],[Enable debugging code and support for the -d option]),
     [ if test x$enableval = xyes; then
         debug=yes
         dnl replace '-0X' and add '-g' flags
@@ -428,7 +418,7 @@ dnl Enable extra debugging in code/compiler options - may slow down performance
 extra_debug=no
 extra_debug_flag=NEXTRA_DBUG
 AC_ARG_ENABLE(extra-debug,
-    AC_HELP_STRING([--enable-extra-debug], [Enable additional debugging code (may affect performance)]),
+    AS_HELP_STRING([--enable-extra-debug],[Enable additional debugging code (may affect performance)]),
     [ if test x$enableval = xyes; then
         extra_debug=yes
         extra_debug_flag=EXTRA_DEBUG
@@ -439,7 +429,7 @@ AC_SUBST(extra_debug_flag)
 dnl Enable timestamp_trace in code/compiler options
 timestamp_trace=no
 AC_ARG_ENABLE(timestamp-trace,
-    AC_HELP_STRING([--timestamp-trace], [Enable dumping of trace timestamps at the end of a test]),
+    AS_HELP_STRING([--timestamp-trace],[Enable dumping of trace timestamps at the end of a test]),
     [ if test x$enableval = xyes; then
         timestamp_trace=yes
         CFLAGS="${CFLAGS} -DTIMESTAMP_TRACE"
@@ -449,7 +439,7 @@ AC_SUBST(timestamp_trace_flag)
 
 
 AC_ARG_ENABLE(dmalloc,
-    AC_HELP_STRING([--enable-dmalloc], [Enable linking to dmalloc for better memory debugging]),
+    AS_HELP_STRING([--enable-dmalloc],[Enable linking to dmalloc for better memory debugging]),
     [ if test x$enableval = xyes ; then
         dmalloc=yes
         AC_DEFINE([ENABLE_DMALLOC], [1], [Enable dmalloc])
@@ -461,14 +451,14 @@ AC_ARG_ENABLE(dmalloc,
 
 
 AC_ARG_ENABLE(pedantic,
-    AC_HELP_STRING([--enable-pedantic], [Enable gcc's -pedantic option]),
+    AS_HELP_STRING([--enable-pedantic],[Enable gcc's -pedantic option]),
     [ if test x$enableval = xyes; then
         CFLAGS="$CFLAGS -pedantic"
       fi ])
 
 dnl Enable Efense
 AC_ARG_ENABLE(efence,
-    AC_HELP_STRING([--enable-efence], [Enable Electric Fence memory debugger]),
+    AS_HELP_STRING([--enable-efence],[Enable Electric Fence memory debugger]),
     [ if test x$enableval = xyes; then
           CFLAGS="$CFLAGS -lefence"
           AC_DEFINE([EFENCE], [1], [Enable Electric Fence memory debugger])
@@ -476,7 +466,7 @@ AC_ARG_ENABLE(efence,
 
 dnl Enable Gprof
 AC_ARG_ENABLE(gprof,
-    AC_HELP_STRING([--enable-gprof], [Enable GNU Profiler]),
+    AS_HELP_STRING([--enable-gprof],[Enable GNU Profiler]),
     [ if test x$enableval = xyes; then
           if test $debug = yes; then
               CFLAGS="$CFLAGS -pg"
@@ -490,7 +480,7 @@ AC_ARG_ENABLE(gprof,
 dnl Enable libpcap auto discovery via pcap-config
 enable_pcap_config=no
 AC_ARG_ENABLE(pcapconfig,
-    AC_HELP_STRING([--enable-pcapconfig], [Enable automatic libpcap config, reverting to system scanning]),
+    AS_HELP_STRING([--enable-pcapconfig],[Enable automatic libpcap config, reverting to system scanning]),
     [
         if test $enableval = yes; then
             enable_pcap_config=yes
@@ -507,7 +497,7 @@ AC_ARG_ENABLE(pcapconfig,
 dnl Use 64bits for packet counters
 use64bit_counters=yes
 AC_ARG_ENABLE(64bits,
-    AC_HELP_STRING([--disable-64bits], [Do not use 64bit packet counters]),
+    AS_HELP_STRING([--disable-64bits],[Do not use 64bit packet counters]),
     [
          AC_MSG_NOTICE([Using u_int32_t for packet counters])
     ],
@@ -530,30 +520,30 @@ fi
 
 
 AC_ARG_ENABLE(force-bpf,
-    AC_HELP_STRING([--enable-force-bpf], [Force using BPF for sending packets]),
+    AS_HELP_STRING([--enable-force-bpf],[Force using BPF for sending packets]),
     [ AC_DEFINE([FORCE_INJECT_BPF], [1], [Force using BPF for sending packet])])
 
 AC_ARG_ENABLE(force-pf,
-    AC_HELP_STRING([--enable-force-pf], [Force using Linux's PF_PACKET for sending packets]),
+    AS_HELP_STRING([--enable-force-pf],[Force using Linux's PF_PACKET for sending packets]),
     [ AC_DEFINE([FORCE_INJECT_PF], [1], [Force using Linux's PF_PACKET for sending packets])])
 
 AC_ARG_ENABLE(force-libdnet,
-    AC_HELP_STRING([--enable-force-libdnet], [Force using libdnet for sending packets]),
+    AS_HELP_STRING([--enable-force-libdnet],[Force using libdnet for sending packets]),
     [ AC_DEFINE([FORCE_INJECT_LIBDNET], [1], [Force using libdnet for sending packets])])
 
 AC_ARG_ENABLE(force-inject,
-    AC_HELP_STRING([--enable-force-inject], [Force using libpcap's pcap_inject() for sending packets]),
+    AS_HELP_STRING([--enable-force-inject],[Force using libpcap's pcap_inject() for sending packets]),
     [ AC_DEFINE([FORCE_INJECT_PCAP_INJECT],[1], [Force using libpcap's pcap_inject() for sending packets])])
 
 AC_ARG_ENABLE(force-sendpacket,
-    AC_HELP_STRING([--enable-force-sendpacket], [Force using libpcap's pcap_sendpacket() for sending packets]),
+    AS_HELP_STRING([--enable-force-sendpacket],[Force using libpcap's pcap_sendpacket() for sending packets]),
     [ AC_DEFINE([FORCE_INJECT_PCAP_SENDPACKET], [1], [Force using libpcap's pcap_sendpacket() for sending packets])])
 
 dnl Static link libraries
 static_link=no
 dynamic_link=yes
 AC_ARG_ENABLE(static-link,
-    AC_HELP_STRING([--enable-static-link], [Use static libraries ( .a  or .A.tbd ) - default no]),
+    AS_HELP_STRING([--enable-static-link],[Use static libraries ( .a  or .A.tbd ) - default no]),
     [
     if test $enableval = yes; then
         static_link=yes
@@ -563,7 +553,7 @@ AC_ARG_ENABLE(static-link,
 
 dnl Dynamic link libraries
 AC_ARG_ENABLE(dynamic-link,
-    AC_HELP_STRING([--enable-dynamic-link], [Use shared libraries ( .so .dylib or .tbd ) - default yes]),
+    AS_HELP_STRING([--enable-dynamic-link],[Use shared libraries ( .so .dylib or .tbd ) - default yes]),
     [
     if test $enableval = no; then
         dynamic_link=no
@@ -635,8 +625,7 @@ pf_ring_lib=${with_pfring_lib}
 using_pcap_config=no
 AC_MSG_CHECKING(for libpcap)
 AC_ARG_WITH(libpcap,
-    AC_HELP_STRING([--with-libpcap=DIR],
-        [Use libpcap in DIR]),
+    AS_HELP_STRING([--with-libpcap=DIR],[Use libpcap in DIR]),
 [
     testdir=$withval
     for incl in ${testdir}/include/pcap.h ${testdir}/pcap.h ${testdir}/pcap/pcap.h; do
@@ -708,7 +697,7 @@ AC_ARG_WITH(libpcap,
         fi
 
         if test $foundpcap = no; then
-            AC_ERROR(["Unable to find matching library for header file in ${testdir}"])
+            AC_MSG_ERROR("Unable to find matching library for header file in ${testdir}")
         fi
 
         break
@@ -761,7 +750,7 @@ AC_ARG_WITH(libpcap,
                 foundpcap=yes
                 using_pcap_config=yes
             else
-                AC_WARN([Unable to find libpcap using pcap-config])
+                AC_MSG_WARN(Unable to find libpcap using pcap-config)
             fi
         fi
     fi
@@ -825,7 +814,7 @@ AC_ARG_WITH(libpcap,
 
 if test $foundpcap = no ; then
     AC_MSG_RESULT(no)
-    AC_ERROR(libpcap not found)
+    AC_MSG_ERROR(libpcap not found)
 else
     AC_MSG_RESULT($foundpcap)
 fi
@@ -886,7 +875,7 @@ AC_SEARCH_LIBS([pcap_get_pfring_id], [pcap], AC_DEFINE([HAVE_PF_RING_PCAP], [1],
 
 ## Does libpcap work with selected libraries?
 AC_SEARCH_LIBS([pcap_close], [pcap],
-    , AC_ERROR([Unable to link libpcap in ${foundpcap}]),)
+    , AC_MSG_ERROR(Unable to link libpcap in ${foundpcap}),)
 
 AC_SUBST(LPCAPINC)
 AC_SUBST(LPCAPLIB)
@@ -1176,15 +1165,15 @@ fi
 have_pcap_version=no
 dnl Check to see if we have pcap_version[]
 AC_MSG_CHECKING(for pcap_version[])
-AC_TRY_LINK([
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include "$LPCAPINC"
 extern char pcap_version[];
-],[
+]], [[
     printf("%s", pcap_version);
-],[
+]])],[
     AC_DEFINE([HAVE_PCAP_VERSION],[1], [Does libpcap have pcap_version[]])
     AC_MSG_RESULT(yes)
 ],[
@@ -1268,7 +1257,7 @@ enable_netmap=no
 trynetmapdir=
 AC_MSG_CHECKING(for netmap socket sending support)
 AC_ARG_WITH(netmap,
-    AC_HELP_STRING([--with-netmap=DIR], [Use netmap in DIR]),
+    AS_HELP_STRING([--with-netmap=DIR],[Use netmap in DIR]),
     [trynetmapdir=$withval])
 
 NETMAP_SEARCH_DIRS=
@@ -1416,15 +1405,15 @@ fi
 have_pf=no
 dnl Check for linux PF_PACKET support
 AC_MSG_CHECKING(for PF_PACKET socket sending support)
-AC_TRY_COMPILE([
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #include <sys/socket.h>
 #include <netpacket/packet.h>
 #include <net/ethernet.h>     /* the L2 protocols */
 #include <netinet/in.h>       /* htons */
-],[
+]], [[
     int pf_socket;
     pf_socket = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
-],[
+]])],[
     AC_DEFINE([HAVE_PF_PACKET], [1],
             [Do we have Linux PF_PACKET socket support?])
     AC_MSG_RESULT(yes)
@@ -1436,16 +1425,16 @@ AC_TRY_COMPILE([
 have_tx_ring=no
 dnl Check for older Linux TX_RING support
 AC_MSG_CHECKING(for TX_RING socket sending support)
-AC_TRY_COMPILE([
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #include <sys/socket.h>
 #include <netpacket/packet.h>
 #include <net/ethernet.h>     /* the L2 protocols */
 #include <netinet/in.h>       /* htons */
 #include <linux/if_packet.h>
-],[
+]], [[
     int test;
     test = TP_STATUS_WRONG_FORMAT
-],[
+]])],[
     AC_DEFINE([HAVE_TX_RING], [1],
             [Do we have Linux TX_RING socket support?])
     AC_MSG_RESULT(yes)
@@ -1481,33 +1470,35 @@ trydnetdir=/usr/local
 if test $have_cygwin = no ; then
     AC_MSG_CHECKING(for libdnet)
     AC_ARG_WITH(libdnet,
-        AC_HELP_STRING([--with-libdnet=DIR], [Use libdnet in DIR]),
+        AS_HELP_STRING([--with-libdnet=DIR],[Use libdnet in DIR]),
         [trydnetdir=$withval])
 
-    case "$build_os" in
-    linux*)
-        dnl # Debian/Ubuntu already have a package called libdnet
-        dnl # so you the package you want to install libdumbnet-dev
-        for testdir in $trydnetdir /usr/local /opt/local /usr ; do
-            if test -x ${testdir}/bin/dumbnet-config -a $founddnet = no ; then
-                LDNETINC="$($testdir/bin/dumbnet-config --cflags)"
-                LDNETLIB="$($testdir/bin/dumbnet-config --libs)"
-                libdnet_version="$($testdir/bin/dumbnet-config --version) (libdumbnet)"
-                founddnet=$testdir
-            fi
-        done
-        ;;
-    esac
+    if test $trydnetdir != no; then
+        case "$build_os" in
+        linux*)
+            dnl # Debian/Ubuntu already have a package called libdnet
+            dnl # so you the package you want to install libdumbnet-dev
+            for testdir in $trydnetdir /usr/local /opt/local /usr ; do
+                if test -x ${testdir}/bin/dumbnet-config -a $founddnet = no ; then
+                    LDNETINC="$($testdir/bin/dumbnet-config --cflags)"
+                    LDNETLIB="$($testdir/bin/dumbnet-config --libs)"
+                    libdnet_version="$($testdir/bin/dumbnet-config --version) (libdumbnet)"
+                    founddnet=$testdir
+                fi
+            done
+            ;;
+        esac
 
-    if test $founddnet = no ; then
-        for testdir in $trydnetdir /usr/local /opt/local $MACOSX_SDK_PATH/usr /usr ; do
-            if test -x ${testdir}/bin/dnet-config -a $founddnet = no ; then
-                LDNETINC="$($testdir/bin/dnet-config --cflags)"
-                LDNETLIB="$($testdir/bin/dnet-config --libs)"
-                libdnet_version="$($testdir/bin/dnet-config --version)"
-                founddnet=$testdir
-            fi
-        done
+        if test $founddnet = no ; then
+            for testdir in $trydnetdir /usr/local /opt/local $MACOSX_SDK_PATH/usr /usr ; do
+                if test -x ${testdir}/bin/dnet-config -a $founddnet = no ; then
+                    LDNETINC="$($testdir/bin/dnet-config --cflags)"
+                    LDNETLIB="$($testdir/bin/dnet-config --libs)"
+                    libdnet_version="$($testdir/bin/dnet-config --version)"
+                    founddnet=$testdir
+                fi
+            done
+        fi
     fi
 
     if test $founddnet = no ; then
@@ -1549,66 +1540,54 @@ fi
 dnl Older versions of libpcap are missing some DLT types
 dnl If doesn't exist, we'll define them in src/common/fakepcap.h
 AC_MSG_CHECKING(for DLT_LINUX_SLL in libpcap)
-AC_TRY_COMPILE([#include "$LPCAPINC"],
-               [ int foo;
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include "$LPCAPINC"]], [[ int foo;
                  foo = DLT_LINUX_SLL
-               ],
-               [ AC_DEFINE([HAVE_DLT_LINUX_SLL], [1],
+               ]])],[ AC_DEFINE([HAVE_DLT_LINUX_SLL], [1],
                            [Does pcap.h include a header with DLT_LINUX_SLL?])
                  AC_MSG_RESULT(yes)
-               ],
-               [AC_MSG_RESULT(no)]
-               )
+               ],[AC_MSG_RESULT(no)
+               ])
 
 AC_MSG_CHECKING(for DLT_C_HDLC in libpcap)
-AC_TRY_COMPILE([#include "$LPCAPINC"],
-               [ int foo;
-                 foo = DLT_C_HDLC ],
-                [ AC_DEFINE([HAVE_DLT_C_HDLC], [1],
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include "$LPCAPINC"]], [[ int foo;
+                 foo = DLT_C_HDLC ]])],[ AC_DEFINE([HAVE_DLT_C_HDLC], [1],
                             [Does pcap.h include a header with DLT_C_HDLC?])
                   AC_MSG_RESULT(yes)
-                ],
-                AC_MSG_RESULT(no)
-               )
+                ],[AC_MSG_RESULT(no)
+               ])
 
 PCAP_BPF_H_FILE="$LPCAPINCDIR/pcap-bpf.h"
 AC_MSG_CHECKING(for $PCAP_BPF_H_FILE)
-AC_TRY_COMPILE([#include <sys/types.h>
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
                 #include <sys/time.h>
                 #include <stdint.h>
-                #include "$PCAP_BPF_H_FILE"],
-               [ int foo;
-                 foo = BPF_MAJOR_VERSION; ],
-               [ AC_DEFINE([INCLUDE_PCAP_BPF_HEADER], [1],
+                #include "$PCAP_BPF_H_FILE"]], [[ int foo;
+                 foo = BPF_MAJOR_VERSION; ]])],[ AC_DEFINE([INCLUDE_PCAP_BPF_HEADER], [1],
                            [What is the path (if any) to the pcap-bpf.h
                             header?])
                  AC_MSG_RESULT(yes)
                  AC_SUBST(PCAP_BPF_H_FILE)
-               ],
-               AC_MSG_RESULT(no)
-               )
+               ],[AC_MSG_RESULT(no)
+               ])
 
 foundbpfheader=no
 AC_MSG_CHECKING(for libpcap bpf header)
 for testfile in $LPCAPINCDIR/pcap/bpf.h $LPCAPINCDIR/pcap-bpf.h ; do
     if test -f "${testfile}" -a $foundbpfheader = no ; then
-        AC_TRY_COMPILE([
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
             #include <sys/types.h>
             #include <sys/time.h>
             #include <stdint.h>
-            #include "$testfile"],
-            [
+            #include "$testfile"]], [[
                 int foo;
                 foo = BPF_MAJOR_VERSION;
-            ],
-            [
+            ]])],[
                 foundbpfheader=yes
                 PCAP_BPF_H_FILE=$testfile
                 AC_SUBST(PCAP_BPF_H_FILE)
                 AC_DEFINE([INCLUDE_PCAP_BPF_HEADER], [1],
                         [What is the path (if any) to the libpcap bpf header file?])
-            ]
-            )
+            ],[])
     fi
 done
 
@@ -1644,7 +1623,7 @@ dnl ##################################################
 pcapnav_ver=no
 pcncfg=no
 AC_ARG_WITH(pcapnav-config,
-    AC_HELP_STRING([--with-pcapnav-config=FILE], [Use given pcapnav-config]),
+    AS_HELP_STRING([--with-pcapnav-config=FILE],[Use given pcapnav-config]),
     [ AC_MSG_CHECKING(for pcapnav-config)
     if test -x $withval ; then
         pcncfg=$withval
@@ -1670,7 +1649,7 @@ dnl Check to see what version of libpcapnav
 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 libpcapnav version)
-    AC_TRY_RUN([
+    AC_RUN_IFELSE([AC_LANG_SOURCE([[
 #include <string.h>
 #define PCAPNAV_TEST "0.4"
 /*
@@ -1685,13 +1664,10 @@ main (int argc, char *argv[])
     if (strncmp(PCAPNAV_VERSION, PCAPNAV_TEST, 3) >= 0)
         exit(0);
     exit(1);
-}           ],
-            libpcapnav_ver=yes
-            AC_MSG_RESULT(>= 0.4),
-            libpcapnav_ver=no
-            AC_MSG_RESULT(< 0.4),
-            libpcapnav_ver=no
-    )
+}           ]])],[libpcapnav_ver=yes
+            AC_MSG_RESULT(>= 0.4)],[libpcapnav_ver=no
+            AC_MSG_RESULT(< 0.4)],[libpcapnav_ver=no
+    ])
 
 
 if test x$libpcapnav_ver = xno ; then
@@ -1775,7 +1751,7 @@ dnl ##################################################
 
 tcpdump_path=no
 AC_ARG_WITH(tcpdump,
-    AC_HELP_STRING([--with-tcpdump=FILE], [Path to tcpdump binary]),
+    AS_HELP_STRING([--with-tcpdump=FILE],[Path to tcpdump binary]),
     [ if test -x $withval ; then
           tcpdump_path=$withval
           AC_MSG_RESULT([Using tcpdump in $tcpdump_path])
@@ -1804,13 +1780,16 @@ fi
 dnl No 'make test' when cross compile
 
 AC_MSG_CHECKING(for 'make test' profile)
-if test "$host" != "$build" ; then
+if test "$host" == "$build" ; then
+    AC_MSG_RESULT([yes])
+else    
     AC_MSG_WARN(Unable to do tests when cross-compiling)
+    AC_MSG_RESULT([Unable to do tests when cross-compiling])
 fi
 
 dnl Allows user to choose which nic to use for testing purposes
 AC_ARG_WITH(testnic,
-    AC_HELP_STRING([--with-testnic=NIC], [Select which network card to use for testing]),
+    AS_HELP_STRING([--with-testnic=NIC],[Select which network card to use for testing]),
     [ nic1=$withval
       nic2=$withval
       AC_MSG_RESULT([Using --with-testnic=$withval])],
@@ -1862,6 +1841,8 @@ dnl There's a bug in OS X which causes pcap_findalldevs() to make the wifi NIC t
 dnl so under OSX we disable the interface list feature
 disable_pcap_findalldevs=no
 osx_frameworks=no
+
+AC_MSG_CHECKING([for OS version])
 dnl these need to be dynamic based on OS
 case $host in
     *-*-linux*)
@@ -1885,7 +1866,7 @@ case $host in
     fi
     osx_frameworks=yes
     AC_DEFINE([HAVE_DARWIN], [1], [Building Apple/Darwin])
-    AC_MSG_RESULT(Apple OS X)
+    AC_MSG_RESULT(Apple macOS)
     ;;
 
     *-*-openbsd*)
@@ -1910,7 +1891,7 @@ esac
 AM_CONDITIONAL([ENABLE_OSX_FRAMEWORKS], test "$osx_frameworks" = "yes")
 
 AC_ARG_WITH(testnic2,
-    AC_HELP_STRING([--with-testnic2=NIC2], [Select an optional 2nd network card to use for testing]),
+    AS_HELP_STRING([--with-testnic2=NIC2],[Select an optional 2nd network card to use for testing]),
     [ nic2=$withval ])
 
 AC_MSG_NOTICE([Using $nic1 for 1st test network interface card])

+ 29 - 3
docs/CHANGELOG

@@ -1,10 +1,36 @@
+04/01/2021 Version 4.3.4
+    - ASAN reports memory leaks while running tests (#662)
+    - local libopts compiler warnings (#658)
+    - DLT name for DLT_C_JNPR_ETHER in documentation (#649)
+    - clean up new_cidr_map() string manipulation on error exit (#648)
+    - fix gcc 8.3.0 build warnings (#634)
+    - invalid --pps value protection (#632)
+    - packets slowly drift further and further behind when they should be sent (#630)
+    - 64 bit rollover can cause pps replay issues after several hours (#629)
+    - typo fixes (#626) (#627)
+    - DLT_NULL/DLT_LOOP support for cross-platform PF_INET6 (#624)
+    - armv5 Freescale compile (#623)
+    - heap buffer overflow in tcpreplay fast_edit_packet (#620)
+    - heap buffer overflow in tcpreplay get_next_packet (#619)
+    - CVE-2020-24266 heap buffer overflow in tcpprep get_l2len (#617)
+    - CVE-2020-24265 heap buffer overflow in tcpprep (#616)
+    - fix UNUSED macro declaration (#614)
+    - handle malformed and unsupported packets as soft errors (#613)
+    - compile failure on aarch64-linux-android (#612)
+    - tcprewrite --fixlen not working on DLT conversion (#582)
+    - fix configure --without-libdnet (#567)
+    - ensure automake version is at least 1.15 (#553)
+    - with multiplier option only first file can be sent and hang (#472)
+    - do not create tap0 if device already exists (#411) (#651)
+
 05/20/2020 Version 4.3.3
     - Increase cache buffers size to accomodate VLAN edits (#594)
+    - CVE-2018-20553 Correct L2 header length calculations so that IP header offset is correct (#584)
     - Correct L2 header length to correct IP header offset (#583)
     - Fix warnings from gcc version 10 (#580)
     - Heap Buffer Overflow in randomize_iparp (#579)
     - Use after free in get_ipv6_next (#578)
-    - Heap Buffer Overflow in git_ipv6_next (#576)
+    - CVE-2020-12740 Heap Buffer Overflow in git_ipv6_next (#576)
     - Call pcap_freecode() on pcap_compile() (#572)
     - Increase max snaplen to 262144 (#571)
     - Fix divide by zero in fuzzing (#570)
@@ -16,7 +42,7 @@
     - Remove some duplicated SOURCES entries (#551)
     - Expand /dev/bpfX hard limit to fix macOS Mojave (#550)
     - Implement --loopdelay-ms when using --loop=0 (#546)
-    - Heap overflow packet2tree and get_l2len (#530)
+    - CVE-2018-20552 Heap overflow packet2tree and get_l2len (#530)
 
 03/12/2019 Version 4.3.2
     - CVE-2019-8381 memory access in do_checksum() (#538)
@@ -119,7 +145,7 @@
     - Support parallel builds (#259)
     - Give user CFLAGS precedence (#256)
     - Properly detect Brew install when Xcode is not available (#254)
-    - Increase max packet size to 65549 (#251)
+    - CVE-2016-6160 Increase max packet size to 65549 (#251)
     - Handle IP headers with zero length (#247)
 
 01/11/2016 Version 4.1.1

+ 21 - 0
docs/CREDIT

@@ -83,3 +83,24 @@ Gabriel Ganne <GitHub @GabrielGanne>
 
 Mario D Santana <GitHUB @@mariodsantana>
     - TCP seq/ack edit
+
+Guilherme Janczak <GitHub @guijan>
+    - memory safety primarily via strlcpy
+
+Fabrice Fontaine <GitHub @ffontaine>
+    - fix --without-libdnet configure option
+
+Gerald Combs <GitHub @geraldcombs>
+    - Wireshark and Ethereal reference updates
+
+Tim Gates <GitHub @timgates42>
+    - typos
+
+Dave DeAngelis <GitHub @ddeangelis>
+    - typos
+
+Dave Craig <GitHub @davecraig>
+    - Avoid clock drift
+
+Vincent Bernat <GitHub @vincentbernat>
+    - tcprewrite: fix DLT name for DLT_C_JNPR_ETHER in documentation

+ 4 - 4
docs/LICENSE

@@ -8,7 +8,7 @@ author: Aaron Turner.
                     GNU GENERAL PUBLIC LICENSE
                        Version 3, 29 June 2007
 
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
  Everyone is permitted to copy and distribute verbatim copies
  of this license document, but changing it is not allowed.
 
@@ -652,7 +652,7 @@ the "copyright" line and a pointer to where the full notice is found.
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+    along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 Also add information on how to contact you by electronic and paper mail.
 
@@ -671,11 +671,11 @@ might be different; for a GUI interface, you would use an "about box".
   You should also get your employer (if you work as a programmer) or school,
 if any, to sign a "copyright disclaimer" for the program, if necessary.
 For more information on this, and how to apply and follow the GNU GPL, see
-<http://www.gnu.org/licenses/>.
+<https://www.gnu.org/licenses/>.
 
   The GNU General Public License does not permit incorporating your program
 into proprietary programs.  If your program is a subroutine library, you
 may consider it more useful to permit linking proprietary applications with
 the library.  If this is what you want to do, use the GNU Lesser General
 Public License instead of this License.  But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+<https://www.gnu.org/licenses/why-not-lgpl.html>.

+ 11 - 11
docs/Makefile.in

@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.16.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2018 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -90,12 +90,9 @@ host_triplet = @host@
 target_triplet = @target@
 subdir = docs
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/libopts.m4 \
-	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
-	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
-	$(top_srcdir)/m4/lt~obsolete.m4 \
-	$(top_srcdir)/m4/stdnoreturn.m4 $(top_srcdir)/acinclude.m4 \
-	$(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
+	$(top_srcdir)/libopts/m4/stdnoreturn.m4 \
+	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
@@ -314,8 +311,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	  *config.status*) \
 	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
 	  *) \
-	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
-	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
 	esac;
 
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@@ -339,7 +336,10 @@ ctags CTAGS:
 cscope cscopelist:
 
 
-distdir: $(DISTFILES)
+distdir: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	list='$(DISTFILES)'; \

+ 35 - 26
lib/Makefile.in

@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.16.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2018 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -92,12 +92,9 @@ host_triplet = @host@
 target_triplet = @target@
 subdir = lib
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/libopts.m4 \
-	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
-	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
-	$(top_srcdir)/m4/lt~obsolete.m4 \
-	$(top_srcdir)/m4/stdnoreturn.m4 $(top_srcdir)/acinclude.m4 \
-	$(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
+	$(top_srcdir)/libopts/m4/stdnoreturn.m4 \
+	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \
@@ -132,7 +129,8 @@ am__v_at_0 = @
 am__v_at_1 = 
 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
 depcomp = $(SHELL) $(top_srcdir)/config/depcomp
-am__depfiles_maybe = depfiles
+am__maybe_remake_depfiles = depfiles
+am__depfiles_remade = ./$(DEPDIR)/strlcat.Po ./$(DEPDIR)/strlcpy.Po
 am__mv = mv -f
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -377,8 +375,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	  *config.status*) \
 	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
 	  *) \
-	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
-	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
 	esac;
 
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@@ -404,8 +402,14 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strlcat.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strlcpy.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strlcat.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strlcpy.Po@am__quote@ # am--include-marker
+
+$(am__depfiles_remade):
+	@$(MKDIR_P) $(@D)
+	@echo '# dummy' >$@-t && $(am__mv) $@-t $@
+
+am--depfiles: $(am__depfiles_remade)
 
 .c.o:
 @am__fastdepCC_TRUE@	$(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@@ -489,7 +493,10 @@ cscopelist-am: $(am__tagged_files)
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
-distdir: $(DISTFILES)
+distdir: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	list='$(DISTFILES)'; \
@@ -561,7 +568,8 @@ clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \
 	mostlyclean-am
 
 distclean: distclean-am
-	-rm -rf ./$(DEPDIR)
+		-rm -f ./$(DEPDIR)/strlcat.Po
+	-rm -f ./$(DEPDIR)/strlcpy.Po
 	-rm -f Makefile
 distclean-am: clean-am distclean-compile distclean-generic \
 	distclean-tags
@@ -607,7 +615,8 @@ install-ps-am:
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
-	-rm -rf ./$(DEPDIR)
+		-rm -f ./$(DEPDIR)/strlcat.Po
+	-rm -f ./$(DEPDIR)/strlcpy.Po
 	-rm -f Makefile
 maintainer-clean-am: distclean-am maintainer-clean-generic
 
@@ -628,16 +637,16 @@ uninstall-am:
 
 .MAKE: install-am install-strip
 
-.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
-	clean-libtool clean-noinstLIBRARIES cscopelist-am ctags \
-	ctags-am distclean distclean-compile distclean-generic \
-	distclean-libtool distclean-tags distdir dvi dvi-am html \
-	html-am info info-am install install-am install-data \
-	install-data-am install-dvi install-dvi-am install-exec \
-	install-exec-am install-html install-html-am install-info \
-	install-info-am install-man install-pdf install-pdf-am \
-	install-ps install-ps-am install-strip installcheck \
-	installcheck-am installdirs maintainer-clean \
+.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \
+	clean-generic clean-libtool clean-noinstLIBRARIES \
+	cscopelist-am ctags ctags-am distclean distclean-compile \
+	distclean-generic distclean-libtool distclean-tags distdir dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-data install-data-am install-dvi install-dvi-am \
+	install-exec install-exec-am install-html install-html-am \
+	install-info install-info-am install-man install-pdf \
+	install-pdf-am install-ps install-ps-am install-strip \
+	installcheck installcheck-am installdirs maintainer-clean \
 	maintainer-clean-generic mostlyclean mostlyclean-compile \
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am

+ 1 - 1
libopts/Makefile.am

@@ -7,7 +7,7 @@ noinst_LTLIBRARIES      = libopts.la
 endif
 libopts_la_SOURCES      = libopts.c
 libopts_la_CPPFLAGS     = -I$(srcdir)
-libopts_la_LDFLAGS      = -version-info  41:1:16
+#libopts_la_LDFLAGS      = -version-info  41:1:16
 EXTRA_DIST		=
 BUILT_SOURCES		=
 MOSTLYCLEANFILES	=

+ 38 - 34
libopts/Makefile.in

@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.16.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2018 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -91,12 +91,9 @@ host_triplet = @host@
 target_triplet = @target@
 subdir = libopts
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/libopts.m4 \
-	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
-	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
-	$(top_srcdir)/m4/lt~obsolete.m4 \
-	$(top_srcdir)/m4/stdnoreturn.m4 $(top_srcdir)/acinclude.m4 \
-	$(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
+	$(top_srcdir)/libopts/m4/stdnoreturn.m4 \
+	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
@@ -140,9 +137,6 @@ AM_V_lt = $(am__v_lt_@AM_V@)
 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
 am__v_lt_0 = --silent
 am__v_lt_1 = 
-libopts_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
-	$(libopts_la_LDFLAGS) $(LDFLAGS) -o $@
 @INSTALL_LIBOPTS_FALSE@am_libopts_la_rpath =
 @INSTALL_LIBOPTS_TRUE@am_libopts_la_rpath = -rpath $(libdir)
 AM_V_P = $(am__v_P_@AM_V@)
@@ -159,7 +153,8 @@ am__v_at_0 = @
 am__v_at_1 = 
 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
 depcomp = $(SHELL) $(top_srcdir)/config/depcomp
-am__depfiles_maybe = depfiles
+am__maybe_remake_depfiles = depfiles
+am__depfiles_remade = ./$(DEPDIR)/libopts_la-libopts.Plo
 am__mv = mv -f
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -379,7 +374,7 @@ MAINTAINERCLEANFILES = Makefile.in
 @INSTALL_LIBOPTS_FALSE@noinst_LTLIBRARIES = libopts.la
 libopts_la_SOURCES = libopts.c
 libopts_la_CPPFLAGS = -I$(srcdir)
-libopts_la_LDFLAGS = -version-info  41:1:16
+#libopts_la_LDFLAGS      = -version-info  41:1:16
 EXTRA_DIST = $(srcdir)/compat/_Noreturn.h stdnoreturn.in.h \
 	COPYING.gplv3 COPYING.lgplv3 COPYING.mbsd MakeDefs.inc README \
 	ag-char-map.h alias.c ao-strs.c ao-strs.h autoopts.c \
@@ -423,8 +418,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	  *config.status*) \
 	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
 	  *) \
-	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
-	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
 	esac;
 
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@@ -483,7 +478,7 @@ clean-noinstLTLIBRARIES:
 	}
 
 libopts.la: $(libopts_la_OBJECTS) $(libopts_la_DEPENDENCIES) $(EXTRA_libopts_la_DEPENDENCIES) 
-	$(AM_V_CCLD)$(libopts_la_LINK) $(am_libopts_la_rpath) $(libopts_la_OBJECTS) $(libopts_la_LIBADD) $(LIBS)
+	$(AM_V_CCLD)$(LINK) $(am_libopts_la_rpath) $(libopts_la_OBJECTS) $(libopts_la_LIBADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -491,7 +486,13 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libopts_la-libopts.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libopts_la-libopts.Plo@am__quote@ # am--include-marker
+
+$(am__depfiles_remade):
+	@$(MKDIR_P) $(@D)
+	@echo '# dummy' >$@-t && $(am__mv) $@-t $@
+
+am--depfiles: $(am__depfiles_remade)
 
 .c.o:
 @am__fastdepCC_TRUE@	$(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@@ -582,7 +583,10 @@ cscopelist-am: $(am__tagged_files)
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
-distdir: $(DISTFILES)
+distdir: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	list='$(DISTFILES)'; \
@@ -660,7 +664,7 @@ clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
 	clean-noinstLTLIBRARIES mostlyclean-am
 
 distclean: distclean-am
-	-rm -rf ./$(DEPDIR)
+		-rm -f ./$(DEPDIR)/libopts_la-libopts.Plo
 	-rm -f Makefile
 distclean-am: clean-am distclean-compile distclean-generic \
 	distclean-tags
@@ -706,7 +710,7 @@ install-ps-am:
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
-	-rm -rf ./$(DEPDIR)
+		-rm -f ./$(DEPDIR)/libopts_la-libopts.Plo
 	-rm -f Makefile
 maintainer-clean-am: distclean-am maintainer-clean-generic
 
@@ -727,20 +731,20 @@ uninstall-am: uninstall-libLTLIBRARIES
 
 .MAKE: all check install install-am install-strip
 
-.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
-	clean-libLTLIBRARIES clean-libtool clean-noinstLTLIBRARIES \
-	cscopelist-am ctags ctags-am distclean distclean-compile \
-	distclean-generic distclean-libtool distclean-tags distdir dvi \
-	dvi-am html html-am info info-am install install-am \
-	install-data install-data-am install-dvi install-dvi-am \
-	install-exec install-exec-am install-html install-html-am \
-	install-info install-info-am install-libLTLIBRARIES \
-	install-man install-pdf install-pdf-am install-ps \
-	install-ps-am install-strip installcheck installcheck-am \
-	installdirs maintainer-clean maintainer-clean-generic \
-	mostlyclean mostlyclean-compile mostlyclean-generic \
-	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
-	uninstall-am uninstall-libLTLIBRARIES
+.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \
+	clean-generic clean-libLTLIBRARIES clean-libtool \
+	clean-noinstLTLIBRARIES cscopelist-am ctags ctags-am distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-dvi \
+	install-dvi-am install-exec install-exec-am install-html \
+	install-html-am install-info install-info-am \
+	install-libLTLIBRARIES install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags tags-am uninstall uninstall-am uninstall-libLTLIBRARIES
 
 .PRECIOUS: Makefile
 

+ 5 - 36
libopts/autoopts/options.h

@@ -40,40 +40,9 @@
  */
 #include <sys/types.h>
 #include <stdio.h>
-
-#ifndef COMPAT_H_GUARD
-/*
- * This is needed for test compilations where the "compat.h"
- * header is not usually available.
- */
-#  if defined(HAVE_STDINT_H)
-#    include <stdint.h>
-#  elif defined(HAVE_INTTYPES_H)
-#    include <inttypes.h>
-#  endif /* HAVE_STDINT/INTTYPES_H */
-
-#  if defined(HAVE_LIMITS_H)
-#    include <limits.h>
-#  elif defined(HAVE_SYS_LIMITS_H)
-#    include <sys/limits.h>
-#  endif /* HAVE_LIMITS/SYS_LIMITS_H */
-
-#  if defined(HAVE_SYSEXITS_H)
-#    include <sysexits.h>
-#  endif /* HAVE_SYSEXITS_H */
-
-#  if defined(HAVE_STDBOOL_H)
-#    include <stdbool.h>
-#  else
-     typedef enum { false = 0, true = 1 } _Bool;
-#    define bool _Bool
-
-     /* The other macros must be usable in preprocessor directives.  */
-#    define false 0
-#    define true 1
-#  endif /* HAVE_SYSEXITS_H */
-#endif /* COMPAT_H_GUARD */
-// END-CONFIGURED-HEADERS
+#include <stdint.h>
+#include <limits.h>
+#include <stdbool.h>
 
 /**
  * Defined to abnormal value of EX_USAGE.  Used to indicate that paged usage
@@ -839,7 +808,7 @@ extern int optionFileLoad(tOptions *, char const *);
 
 
 /**
- * optionFindNextValue - find a hierarcicaly valued option instance
+ * optionFindNextValue - find a hierarchically valued option instance
  *
  *  This routine will find the next entry in a nested value option or
  *  configurable.  It will search through the list and return the next entry
@@ -856,7 +825,7 @@ extern const tOptionValue * optionFindNextValue(const tOptDesc *, const tOptionV
 
 
 /**
- * optionFindValue - find a hierarcicaly valued option instance
+ * optionFindValue - find a hierarchically valued option instance
  *
  *  This routine will find an entry in a nested value option or configurable.
  *  It will search through the list and return a matching entry.

+ 1 - 1
libopts/boolean.c

@@ -65,7 +65,7 @@ optionBooleanVal(tOptions * opts, tOptDesc * od)
         if ((val != 0) || (*pz != NUL))
             break;
     }
-    /* FALLTHROUGH */
+    /* fall through */
     case 'N':
     case 'n':
     case 'F':

+ 3 - 4
libopts/configfile.c

@@ -145,7 +145,7 @@ configFileLoad(char const * fname)
 
 /*=export_func  optionFindValue
  *
- * what:  find a hierarcicaly valued option instance
+ * what:  find a hierarchically valued option instance
  * arg:   + const tOptDesc * + odesc + an option with a nested arg type +
  * arg:   + char const *     + name  + name of value to find +
  * arg:   + char const *     + val   + the matching value    +
@@ -220,7 +220,7 @@ optionFindValue(const tOptDesc * odesc, char const * name, char const * val)
  *
  * FIXME: the handling of 'pzName' and 'pzVal' is just wrong.
  *
- * what:  find a hierarcicaly valued option instance
+ * what:  find a hierarchically valued option instance
  * arg:   + const tOptDesc * + odesc + an option with a nested arg type +
  * arg:   + const tOptionValue * + pPrevVal + the last entry +
  * arg:   + char const *     + name     + name of value to find +
@@ -466,8 +466,7 @@ file_preset(tOptions * opts, char const * fname, int dir)
                 ftext = strchr(ftext + 2, '>');
                 if (ftext++ != NULL)
                     break;
-                /* fallthrough */
-
+                /* fall through */
             default:
                 ftext = NULL;
             }

+ 3 - 7
libopts/m4/libopts.m4

@@ -9,7 +9,6 @@ dnl
 dnl do always before generated macros:
 dnl
 AC_DEFUN([INVOKE_LIBOPTS_MACROS_FIRST],[
-  AC_REQUIRE([AC_HEADER_STDC])
   AC_HEADER_DIRENT
 
   # =================
@@ -484,8 +483,7 @@ AC_DEFUN([LIBOPTS_CHECK_COMMON],[
   m4_pushdef([AO_Libopts_Dir],
 	    [ifelse($1, , [libopts], [$1])])
   AC_ARG_ENABLE([local-libopts],
-    AC_HELP_STRING([--enable-local-libopts],
-       [Use the supplied libopts tearoff code]),[
+    AS_HELP_STRING([--enable-local-libopts],[Use the supplied libopts tearoff code]),[
     if test x$enableval = xyes ; then
        AC_MSG_NOTICE([Using supplied libopts tearoff])
        LIBOPTS_CFLAGS='-I$(top_srcdir)/AO_Libopts_Dir'
@@ -494,15 +492,13 @@ AC_DEFUN([LIBOPTS_CHECK_COMMON],[
     fi])
 
   AC_ARG_ENABLE([libopts-install],
-    AC_HELP_STRING([--enable-libopts-install],
-       [Install libopts with client installation]))
+    AS_HELP_STRING([--enable-libopts-install],[Install libopts with client installation]))
   AM_CONDITIONAL([INSTALL_LIBOPTS],[test "X${enable_libopts_install}" = Xyes])
 
   [if test -z "${NEED_LIBOPTS_DIR}" ; then]
      AC_MSG_CHECKING([whether autoopts-config can be found])
      AC_ARG_WITH([autoopts-config],
-        AC_HELP_STRING([--with-autoopts-config],
-             [specify the config-info script]),
+        AS_HELP_STRING([--with-autoopts-config],[specify the config-info script]),
         [lo_cv_with_autoopts_config=${with_autoopts_config}],
         AC_CACHE_CHECK([whether autoopts-config is specified],
              [lo_cv_with_autoopts_config],

+ 9 - 8
libopts/makeshell.c

@@ -322,11 +322,11 @@ text_to_var(tOptions * opts, teTextTo which, tOptDesc * od)
         switch (which) {
         case TT_LONGUSAGE:
             (*(opts->pUsageProc))(opts, EXIT_SUCCESS);
-            /* NOTREACHED */
+            /* fall through */
 
         case TT_USAGE:
             (*(opts->pUsageProc))(opts, EXIT_FAILURE);
-            /* NOTREACHED */
+            /* fall through */
 
         case TT_VERSION:
             if (od->fOptState & OPTST_ALLOC_ARG) {
@@ -335,13 +335,13 @@ text_to_var(tOptions * opts, teTextTo which, tOptDesc * od)
             }
             od->optArg.argString = "c";
             optionPrintVersion(opts, od);
-            /* NOTREACHED */
+            /* fall through */
 
         default:
             option_exits(EXIT_FAILURE);
-            /* NOTREACHED */
+            /* fall through */
         }
-        /* NOTREACHED */
+        /* fall through */
 
     default:
         close(fdpair[1]);
@@ -885,13 +885,14 @@ genshelloptUsage(tOptions * opts, int exit_cd)
     switch (fork()) {
     case -1:
         optionUsage(opts, EXIT_FAILURE);
-        /* NOTREACHED */
+        /* fall through */
 
     case 0:
         pagerState = PAGER_STATE_CHILD;
         optionUsage(opts, EXIT_SUCCESS);
         /* NOTREACHED */
         _exit(EXIT_FAILURE);
+        /* fall through */
 
     default:
     {
@@ -927,10 +928,10 @@ genshelloptUsage(tOptions * opts, int exit_cd)
     switch (fork()) {
     case 0:
         pagerState = PAGER_STATE_CHILD;
-        /*FALLTHROUGH*/
+        /* fall through */
     case -1:
         optionUsage(optionParseShellOptions, EXIT_FAILURE);
-
+        /* fall through */
     default:
     {
         int  sts;

+ 6 - 0
libopts/numeric.c

@@ -137,13 +137,19 @@ optionNumericVal(tOptions * opts, tOptDesc * od)
         switch (*(pz++)) {
         case NUL:  pz--; break;
         case 't':  val *= 1000;
+        /* fall through */
         case 'g':  val *= 1000;
+        /* fall through */
         case 'm':  val *= 1000;
+        /* fall through */
         case 'k':  val *= 1000; break;
 
         case 'T':  val *= 1024;
+        /* fall through */
         case 'G':  val *= 1024;
+        /* fall through */
         case 'M':  val *= 1024;
+        /* fall through */
         case 'K':  val *= 1024; break;
 
         default:   goto bad_number;

+ 1 - 1
libopts/restore.c

@@ -34,7 +34,7 @@
 /*
  *  optionFixupSavedOpts  Really, it just wipes out option state for
  *  options that are troublesome to copy.  viz., stacked strings and
- *  hierarcicaly valued option args.  We do duplicate string args that
+ *  hierarchically valued option args.  We do duplicate string args that
  *  have been marked as allocated though.
  */
 static void

+ 0 - 592
m4/libopts.m4

@@ -1,592 +0,0 @@
-dnl  -*- buffer-read-only: t -*- vi: set ro:
-dnl
-dnl DO NOT EDIT THIS FILE   (libopts.m4)
-dnl
-dnl It has been AutoGen-ed
-dnl From the definitions    libopts.def
-dnl and the template file   conftest.tpl
-dnl
-dnl do always before generated macros:
-dnl
-AC_DEFUN([INVOKE_LIBOPTS_MACROS_FIRST],[
-  AC_REQUIRE([AC_HEADER_STDC])
-  AC_HEADER_DIRENT
-
-  # =================
-  # AC_CHECK_HEADERS
-  # =================
-  AC_CHECK_HEADERS([ \
-      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    dlfcn.h       errno.h \
-      fcntl.h       libgen.h      libintl.h     memory.h \
-      netinet/in.h  setjmp.h      stdbool.h     sysexits.h \
-      unistd.h      utime.h])
-
-  AC_CHECK_HEADERS([stdarg.h     varargs.h],
-      [lo_have_arg_hdr=true;break],
-      [lo_have_arg_hdr=false])
-
-  AC_CHECK_HEADERS([string.h     strings.h],
-      [lo_have_str_hdr=true;break],
-      [lo_have_str_hdr=false])
-
-  AC_CHECK_HEADERS([limits.h     sys/limits.h  values.h],
-      [lo_have_lim_hdr=true;break],
-      [lo_have_lim_hdr=false])
-
-  AC_CHECK_HEADERS([inttypes.h   stdint.h],
-      [lo_have_typ_hdr=true;break],
-      [lo_have_typ_hdr=false])
-  gl_STDNORETURN_H
-
-  # ----------------------------------------------------------------------
-  # check for various programs used during the build.
-  # On OS/X, "wchar.h" needs "runetype.h" to work properly.
-  # ----------------------------------------------------------------------
-  AC_CHECK_HEADERS([runetype.h wchar.h], [], [],[
-  AC_INCLUDES_DEFAULT
-  #if HAVE_RUNETYPE_H
-  # include <runetype.h>
-  #endif
-  ])
-
-  AC_ARG_ENABLE([nls],
-  AS_HELP_STRING([--disable-nls],[disable nls support in libopts]))
-  AS_IF([test "x$enable_nls" != "xno" && \
-  test "X${ac_cv_header_libintl_h}" = Xyes], [
-  AC_DEFINE([ENABLE_NLS],[1],[nls support in libopts])])
-
-  # --------------------------------------------
-  # Verify certain entries from AC_CHECK_HEADERS
-  # --------------------------------------------
-  [${lo_have_arg_hdr} || \
-    ]AC_MSG_ERROR([you must have stdarg.h or varargs.h on your system])[
-
-  ${lo_have_str_hdr} || \
-    ]AC_MSG_ERROR([you must have string.h or strings.h on your system])[
-
-  ${lo_have_lim_hdr} || \
-    ]AC_MSG_ERROR(
-      [you must have one of limits.h, sys/limits.h or values.h])[
-
-  ${lo_have_typ_hdr} || \
-    ]AC_MSG_ERROR([you must have inttypes.h or stdint.h on your system])[
-
-  for f in sys_types sys_param sys_stat string errno stdlib memory setjmp
-  do eval as_ac_var=\${ac_cv_header_${f}_h}
-     test "X${as_ac_var}" = Xyes || {
-       ]AC_MSG_ERROR([you must have ${f}.h on your system])[
-     }
-  done
-  test "X${ac_cv_header_inttypes_h-no}" = Xyes || \
-    echo '#include <stdint.h>' > inttypes.h]
-
-  # ----------------------------------------------------------------------
-  # Checks for typedefs
-  # ----------------------------------------------------------------------
-  AC_CHECK_TYPES(wchar_t)
-  AC_CHECK_TYPES(wint_t, [], [], [
-    AC_INCLUDES_DEFAULT
-    #if HAVE_RUNETYPE_H
-    # include <runetype.h>
-    #endif
-    #if HAVE_WCHAR_H
-    # include <wchar.h>
-    #endif
-  ])
-  AC_CHECK_TYPES([int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t,
-  intptr_t, uintptr_t, uint_t, pid_t, size_t, ptrdiff_t])
-  AC_CHECK_SIZEOF(char *, 8)
-  AC_CHECK_SIZEOF(int,    4)
-  AC_CHECK_SIZEOF(long,   8)
-  AC_CHECK_SIZEOF(short,  2)
-
-  # ------------
-  # AC_CHECK_LIB
-  # ------------
-  AC_CHECK_LIB(gen, pathfind)
-  AC_CHECK_LIB(intl,gettext)
-  AC_FUNC_VPRINTF
-  AC_FUNC_FORK
-  AC_CHECK_FUNCS([mmap canonicalize_file_name snprintf strdup strchr \
-                 strrchr strsignal fchmod fstat chmod])
-  AC_PROG_SED
-  [while :
-  do
-      POSIX_SHELL=`which bash`
-      test -x "$POSIX_SHELL" && break
-      POSIX_SHELL=`which dash`
-      test -x "$POSIX_SHELL" && break
-      POSIX_SHELL=/usr/xpg4/bin/sh
-      test -x "$POSIX_SHELL" && break
-      POSIX_SHELL=`/bin/sh -c '
-          exec 2>/dev/null
-          if ! true ; then exit 1 ; fi
-          echo /bin/sh'`
-      test -x "$POSIX_SHELL" && break
-      ]AC_MSG_ERROR([cannot locate a working POSIX shell])[
-  done]
-  AC_DEFINE_UNQUOTED([POSIX_SHELL], ["${POSIX_SHELL}"],
-           [define to a working POSIX compliant shell])
-  AC_SUBST([POSIX_SHELL])
-])
-
-dnl
-dnl @synopsis  INVOKE_LIBOPTS_MACROS
-dnl
-dnl  This macro will invoke the AutoConf macros specified in libopts.def
-dnl  that have not been disabled with "omit-invocation".
-dnl
-AC_DEFUN([LIBOPTS_WITH_REGEX_HEADER],[
-  AC_ARG_WITH([regex-header],
-    AS_HELP_STRING([--with-regex-header], [a reg expr header is specified]),
-    [libopts_cv_with_regex_header=${with_regex_header}],
-    AC_CACHE_CHECK([whether a reg expr header is specified], libopts_cv_with_regex_header,
-      libopts_cv_with_regex_header=no)
-  ) # end of AC_ARG_WITH
-  if test "X${libopts_cv_with_regex_header}" != Xno
-  then
-    AC_DEFINE_UNQUOTED([REGEX_HEADER],[<${libopts_cv_with_regex_header}>])
-  else
-    AC_DEFINE([REGEX_HEADER],[<regex.h>],[name of regex header file])
-  fi
-
-]) # end of AC_DEFUN of LIBOPTS_WITH_REGEX_HEADER
-
-
-AC_DEFUN([LIBOPTS_WITHLIB_REGEX],[
-  AC_ARG_WITH([libregex],
-    AS_HELP_STRING([--with-libregex], [libregex installation prefix]),
-    [libopts_cv_with_libregex_root=${with_libregex}],
-    AC_CACHE_CHECK([whether with-libregex was specified], libopts_cv_with_libregex_root,
-      libopts_cv_with_libregex_root=no)
-  ) # end of AC_ARG_WITH libregex
-
-  if test "${with_libregex+set}" = set && \
-     test "X${withval}" = Xno
-  then ## disabled by request
-    libopts_cv_with_libregex_root=no
-    libopts_cv_with_libregex_cflags=no
-    libopts_cv_with_libregex_libs=no
-  else
-
-  AC_ARG_WITH([libregex-cflags],
-    AS_HELP_STRING([--with-libregex-cflags], [libregex compile flags]),
-    [libopts_cv_with_libregex_cflags=${with_libregex_cflags}],
-    AC_CACHE_CHECK([whether with-libregex-cflags was specified], libopts_cv_with_libregex_cflags,
-      libopts_cv_with_libregex_cflags=no)
-  ) # end of AC_ARG_WITH libregex-cflags
-
-  AC_ARG_WITH([libregex-libs],
-    AS_HELP_STRING([--with-libregex-libs], [libregex link command arguments]),
-    [libopts_cv_with_libregex_libs=${with_libregex_libs}],
-    AC_CACHE_CHECK([whether with-libregex-libs was specified], libopts_cv_with_libregex_libs,
-      libopts_cv_with_libregex_libs=no)
-  ) # end of AC_ARG_WITH libregex-libs
-
-  case "X${libopts_cv_with_libregex_cflags}" in
-  Xyes|Xno|X )
-    case "X${libopts_cv_with_libregex_root}" in
-    Xyes|Xno|X ) libopts_cv_with_libregex_cflags=no ;;
-    * ) libopts_cv_with_libregex_cflags=-I${libopts_cv_with_libregex_root}/include ;;
-    esac
-  esac
-  case "X${libopts_cv_with_libregex_libs}" in
-  Xyes|Xno|X )
-    case "X${libopts_cv_with_libregex_root}" in
-    Xyes|Xno|X ) libopts_cv_with_libregex_libs=no ;;
-    * )        libopts_cv_with_libregex_libs="-L${libopts_cv_with_libregex_root}/lib -lregex" ;;
-    esac
-  esac
-  libopts_save_CPPFLAGS="${CPPFLAGS}"
-  libopts_save_LIBS="${LIBS}"
-  case "X${libopts_cv_with_libregex_cflags}" in
-  Xyes|Xno|X )
-    libopts_cv_with_libregex_cflags="" ;;
-  * ) CPPFLAGS="${CPPFLAGS} ${libopts_cv_with_libregex_cflags}" ;;
-  esac
-  case "X${libopts_cv_with_libregex_libs}" in
-  Xyes|Xno|X )
-    libopts_cv_with_libregex_libs="" ;;
-  * )
-    LIBS="${LIBS} ${libopts_cv_with_libregex_libs}" ;;
-  esac
-  LIBREGEX_CFLAGS=""
-  LIBREGEX_LIBS=""
-  AC_MSG_CHECKING([whether libregex functions properly])
-  AC_CACHE_VAL([libopts_cv_with_libregex],[
-  AC_RUN_IFELSE([AC_LANG_SOURCE([@%:@include <stdio.h>
-@%:@include <stdlib.h>
-@%:@include <sys/types.h>
-@%:@include REGEX_HEADER
-static regex_t re;
-void comp_re(char const * pzPat) {
-  int res = regcomp( &re, pzPat, REG_EXTENDED|REG_ICASE|REG_NEWLINE );
-  if (res == 0) return;
-  exit( res ); }
-int main() {
-  regmatch_t m@<:@2@:>@;
-  comp_re( "^.*\@S|@"   );
-  comp_re( "()|no.*" );
-  comp_re( "."       );
-  if (regexec( &re, "X", 2, m, 0 ) != 0)  return 1;
-  if ((m@<:@0@:>@.rm_so != 0) || (m@<:@0@:>@.rm_eo != 1)) {
-    fputs( "error: regex -->.<-- did not match\n", stderr );
-    return 1;
-  }
-  return 0; }])],
-    [libopts_cv_with_libregex=yes], [libopts_cv_with_libregex=no],
-    [libopts_cv_with_libregex=no]) # end of AC_RUN_IFELSE 
-  ]) # end of AC_CACHE_VAL for libopts_cv_with_libregex
-  fi ## disabled by request
-  AC_MSG_RESULT([${libopts_cv_with_libregex}])
-  if test "X${libopts_cv_with_libregex}" != Xno
-  then
-    AC_DEFINE([WITH_LIBREGEX],[1],
-        [Define this if a working libregex can be found])
-  else
-    CPPFLAGS="${libopts_save_CPPFLAGS}"
-    LIBS="${libopts_save_LIBS}"
-    libopts_cv_with_libregex_root=no
-libopts_cv_with_libregex_cflags=no
-libopts_cv_with_libregex_libs=no
-libopts_cv_with_libregex=no
-  fi
-
-]) # end of AC_DEFUN of LIBOPTS_WITHLIB_REGEX
-
-
-AC_DEFUN([LIBOPTS_RUN_PATHFIND],[
-  AC_MSG_CHECKING([whether pathfind(3) works])
-  AC_CACHE_VAL([libopts_cv_run_pathfind],[
-  AC_RUN_IFELSE([AC_LANG_SOURCE([@%:@include <string.h>
-@%:@include <stdlib.h>
-int main (int argc, char ** argv) {
-   char * pz = pathfind( getenv( "PATH" ), "sh", "x" );
-   return (pz == 0) ? 1 : 0;
-}])],
-    [libopts_cv_run_pathfind=yes],[libopts_cv_run_pathfind=no],[libopts_cv_run_pathfind=no]
-  ) # end of RUN_IFELSE
-  ]) # end of AC_CACHE_VAL for libopts_cv_run_pathfind
-  AC_MSG_RESULT([${libopts_cv_run_pathfind}])
-  if test "X${libopts_cv_run_pathfind}" != Xno
-  then
-    AC_DEFINE([HAVE_PATHFIND],[1],
-        [Define this if pathfind(3) works])
-  fi
-
-]) # end of AC_DEFUN of LIBOPTS_RUN_PATHFIND
-
-
-AC_DEFUN([LIBOPTS_TEST_DEV_ZERO],[
-  AC_MSG_CHECKING([whether /dev/zero is readable device])
-  AC_CACHE_VAL([libopts_cv_test_dev_zero],[
-    libopts_cv_test_dev_zero=`exec 2> /dev/null
-dzero=\`ls -lL /dev/zero | egrep ^c......r\`
-test -z "${dzero}" && exit 1
-echo ${dzero}`
-    if test $? -ne 0 || test -z "$libopts_cv_test_dev_zero"
-    then libopts_cv_test_dev_zero=no
-    fi
-  ]) # end of CACHE_VAL of libopts_cv_test_dev_zero
-  AC_MSG_RESULT([${libopts_cv_test_dev_zero}])
-  if test "X${libopts_cv_test_dev_zero}" != Xno
-  then
-    AC_DEFINE([HAVE_DEV_ZERO],[1],
-        [Define this if /dev/zero is readable device])
-  fi
-
-]) # end of AC_DEFUN of LIBOPTS_TEST_DEV_ZERO
-
-
-AC_DEFUN([LIBOPTS_RUN_REALPATH],[
-  AC_MSG_CHECKING([whether we have a functional realpath(3C)])
-  AC_CACHE_VAL([libopts_cv_run_realpath],[
-  AC_RUN_IFELSE([AC_LANG_SOURCE([@%:@include <limits.h>
-@%:@include <stdlib.h>
-int main (int argc, char ** argv) {
-@%:@ifndef PATH_MAX
-choke me!!
-@%:@else
-   char zPath@<:@PATH_MAX+1@:>@;
-@%:@endif
-   char *pz = realpath(argv@<:@0@:>@, zPath);
-   return (pz == zPath) ? 0 : 1;
-}])],
-    [libopts_cv_run_realpath=yes],[libopts_cv_run_realpath=no],[libopts_cv_run_realpath=no]
-  ) # end of RUN_IFELSE
-  ]) # end of AC_CACHE_VAL for libopts_cv_run_realpath
-  AC_MSG_RESULT([${libopts_cv_run_realpath}])
-  if test "X${libopts_cv_run_realpath}" != Xno
-  then
-    AC_DEFINE([HAVE_REALPATH],[1],
-        [Define this if we have a functional realpath(3C)])
-  fi
-
-]) # end of AC_DEFUN of LIBOPTS_RUN_REALPATH
-
-
-AC_DEFUN([LIBOPTS_RUN_STRFTIME],[
-  AC_MSG_CHECKING([whether strftime() works])
-  AC_CACHE_VAL([libopts_cv_run_strftime],[
-  AC_RUN_IFELSE([AC_LANG_SOURCE([@%:@include <time.h>
-@%:@include <string.h>
-char t_buf@<:@ 64 @:>@;
-int main() {
-  static char const z@<:@@:>@ = "Thursday Aug 28 240";
-  struct tm tm;
-  tm.tm_sec   = 36;  /* seconds after the minute @<:@0, 61@:>@  */
-  tm.tm_min   = 44;  /* minutes after the hour @<:@0, 59@:>@ */
-  tm.tm_hour  = 12;  /* hour since midnight @<:@0, 23@:>@ */
-  tm.tm_mday  = 28;  /* day of the month @<:@1, 31@:>@ */
-  tm.tm_mon   =  7;  /* months since January @<:@0, 11@:>@ */
-  tm.tm_year  = 86;  /* years since 1900 */
-  tm.tm_wday  =  4;  /* days since Sunday @<:@0, 6@:>@ */
-  tm.tm_yday  = 239; /* days since January 1 @<:@0, 365@:>@ */
-  tm.tm_isdst =  1;  /* flag for daylight savings time */
-  strftime( t_buf, sizeof( t_buf ), "%A %b %d %j", &tm );
-  return (strcmp( t_buf, z ) != 0); }])],
-    [libopts_cv_run_strftime=yes],[libopts_cv_run_strftime=no],[libopts_cv_run_strftime=no]
-  ) # end of RUN_IFELSE
-  ]) # end of AC_CACHE_VAL for libopts_cv_run_strftime
-  AC_MSG_RESULT([${libopts_cv_run_strftime}])
-  if test "X${libopts_cv_run_strftime}" != Xno
-  then
-    AC_DEFINE([HAVE_STRFTIME],[1],
-        [Define this if strftime() works])
-  fi
-
-]) # end of AC_DEFUN of LIBOPTS_RUN_STRFTIME
-
-
-AC_DEFUN([LIBOPTS_RUN_FOPEN_BINARY],[
-  AC_MSG_CHECKING([whether fopen accepts "b" mode])
-  AC_CACHE_VAL([libopts_cv_run_fopen_binary],[
-  AC_RUN_IFELSE([AC_LANG_SOURCE([@%:@include <stdio.h>
-int main (int argc, char ** argv) {
-FILE * fp = fopen("conftest.@S|@ac_ext", "rb");
-return (fp == NULL) ? 1 : fclose(fp); }])],
-    [libopts_cv_run_fopen_binary=yes],[libopts_cv_run_fopen_binary=no],[libopts_cv_run_fopen_binary=no]
-  ) # end of RUN_IFELSE
-  ]) # end of AC_CACHE_VAL for libopts_cv_run_fopen_binary
-  AC_MSG_RESULT([${libopts_cv_run_fopen_binary}])
-  if test "X${libopts_cv_run_fopen_binary}" != Xno
-  then
-    AC_DEFINE([FOPEN_BINARY_FLAG],"b",
-	[fopen(3) accepts a 'b' in the mode flag])
-  else
-    AC_DEFINE([FOPEN_BINARY_FLAG],"",
-	[fopen(3) accepts a 'b' in the mode flag])
-  fi
-
-]) # end of AC_DEFUN of LIBOPTS_RUN_FOPEN_BINARY
-
-
-AC_DEFUN([LIBOPTS_RUN_FOPEN_TEXT],[
-  AC_MSG_CHECKING([whether fopen accepts "t" mode])
-  AC_CACHE_VAL([libopts_cv_run_fopen_text],[
-  AC_RUN_IFELSE([AC_LANG_SOURCE([@%:@include <stdio.h>
-int main (int argc, char ** argv) {
-FILE * fp = fopen("conftest.@S|@ac_ext", "rt");
-return (fp == NULL) ? 1 : fclose(fp); }])],
-    [libopts_cv_run_fopen_text=yes],[libopts_cv_run_fopen_text=no],[libopts_cv_run_fopen_text=no]
-  ) # end of RUN_IFELSE
-  ]) # end of AC_CACHE_VAL for libopts_cv_run_fopen_text
-  AC_MSG_RESULT([${libopts_cv_run_fopen_text}])
-  if test "X${libopts_cv_run_fopen_text}" != Xno
-  then
-    AC_DEFINE([FOPEN_TEXT_FLAG],"t",
-	[fopen(3) accepts a 't' in the mode flag])
-  else
-    AC_DEFINE([FOPEN_TEXT_FLAG],"",
-	[fopen(3) accepts a 't' in the mode flag])
-  fi
-
-]) # end of AC_DEFUN of LIBOPTS_RUN_FOPEN_TEXT
-
-
-AC_DEFUN([LIBOPTS_DISABLE_OPTIONAL_ARGS],[
-  AC_ARG_ENABLE([optional-args],
-    AS_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],[
-  AC_REQUIRE([INVOKE_LIBOPTS_MACROS_FIRST])
-  # Check to see if a reg expr header is specified.
-  LIBOPTS_WITH_REGEX_HEADER
-
-  # Check to see if a working libregex can be found.
-  LIBOPTS_WITHLIB_REGEX
-
-  # Check to see if pathfind(3) works.
-  LIBOPTS_RUN_PATHFIND
-
-  # Check to see if /dev/zero is readable device.
-  LIBOPTS_TEST_DEV_ZERO
-
-  # Check to see if we have a functional realpath(3C).
-  LIBOPTS_RUN_REALPATH
-
-  # Check to see if strftime() works.
-  LIBOPTS_RUN_STRFTIME
-
-  # Check to see if fopen accepts "b" mode.
-  LIBOPTS_RUN_FOPEN_BINARY
-
-  # 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
-dnl
-dnl If autoopts-config works, add the linking information to LIBS.
-dnl Otherwise, add ``libopts-${ao_rev}'' to SUBDIRS and run all
-dnl the config tests that the library needs.  Invoke the
-dnl "INVOKE_LIBOPTS_MACROS" macro iff we are building libopts.
-dnl
-dnl  This file is part of AutoGen.
-dnl  AutoGen Copyright (C) 1992-2015 by Bruce Korb - all rights reserved
-dnl
-dnl  AutoGen is free software: you can redistribute it and/or modify it
-dnl  under the terms of the GNU General Public License as published by the
-dnl  Free Software Foundation, either version 3 of the License, or
-dnl  (at your option) any later version.
-dnl
-dnl  AutoGen is distributed in the hope that it will be useful, but
-dnl  WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-dnl  See the GNU General Public License for more details.
-dnl
-dnl  You should have received a copy of the GNU General Public License along
-dnl  with this program.  If not, see <http://www.gnu.org/licenses/>.
-dnl
-dnl Default to system libopts
-dnl
-AC_DEFUN([LIBOPTS_CHECK_COMMON],[
-  AC_REQUIRE([INVOKE_LIBOPTS_MACROS_FIRST])
-  [NEED_LIBOPTS_DIR='']
-  m4_pushdef([AO_Libopts_Dir],
-	    [ifelse($1, , [libopts], [$1])])
-  AC_ARG_ENABLE([local-libopts],
-    AC_HELP_STRING([--enable-local-libopts],
-       [Use the supplied libopts tearoff code]),[
-    if test x$enableval = xyes ; then
-       AC_MSG_NOTICE([Using supplied libopts tearoff])
-       LIBOPTS_CFLAGS='-I$(top_srcdir)/AO_Libopts_Dir'
-       NEED_LIBOPTS_DIR=true
-       LIBOPTS_LDADD='$(top_builddir)/AO_Libopts_Dir/libopts.la'
-    fi])
-
-  AC_ARG_ENABLE([libopts-install],
-    AC_HELP_STRING([--enable-libopts-install],
-       [Install libopts with client installation]))
-  AM_CONDITIONAL([INSTALL_LIBOPTS],[test "X${enable_libopts_install}" = Xyes])
-
-  [if test -z "${NEED_LIBOPTS_DIR}" ; then]
-     AC_MSG_CHECKING([whether autoopts-config can be found])
-     AC_ARG_WITH([autoopts-config],
-        AC_HELP_STRING([--with-autoopts-config],
-             [specify the config-info script]),
-        [lo_cv_with_autoopts_config=${with_autoopts_config}],
-        AC_CACHE_CHECK([whether autoopts-config is specified],
-             [lo_cv_with_autoopts_config],
-             [if autoopts-config --help 2>/dev/null 1>&2
-        then lo_cv_with_autoopts_config=autoopts-config
-        elif libopts-config --help 2>/dev/null 1>&2
-        then lo_cv_with_autoopts_config=libopts-config
-        else lo_cv_with_autoopts_config=no ; fi])
-     ) # end of AC_ARG_WITH
-
-     AC_CACHE_VAL([lo_cv_test_autoopts],[
-        if test -z "${lo_cv_with_autoopts_config}" \
-                -o X"${lo_cv_with_autoopts_config}" = Xno
-        then
-           if autoopts-config --help 2>/dev/null 1>&2
-           then lo_cv_with_autoopts_config=autoopts-config
-           elif libopts-config --help 2>/dev/null 1>&2
-           then lo_cv_with_autoopts_config=libopts-config
-           else lo_cv_with_autoopts_config=false ; fi
-        fi
-        lo_cv_test_autoopts=`
-            ${lo_cv_with_autoopts_config} --libs` 2> /dev/null
-        if test $? -ne 0 -o -z "${lo_cv_test_autoopts}"
-        then lo_cv_test_autoopts=no ; fi
-     ]) # end of CACHE_VAL
-     AC_MSG_RESULT([${lo_cv_test_autoopts}])
-
-     [if test "X${lo_cv_test_autoopts}" != Xno
-     then
-        LIBOPTS_LDADD="${lo_cv_test_autoopts}"
-        LIBOPTS_CFLAGS="`${lo_cv_with_autoopts_config} --cflags`"
-     else
-        LIBOPTS_LDADD='$(top_builddir)/]AO_Libopts_Dir[/libopts.la'
-        LIBOPTS_CFLAGS='-I$(top_srcdir)/]AO_Libopts_Dir['
-        NEED_LIBOPTS_DIR=true
-     fi
-  fi # end of if test -z "${NEED_LIBOPTS_DIR}"
-  if test -n "${LIBOPTS_BUILD_BLOCKED}" ; then
-    NEED_LIBOPTS_DIR=''
-  fi]
-  AM_CONDITIONAL([NEED_LIBOPTS], [test -n "${NEED_LIBOPTS_DIR}"])
-  AC_SUBST(LIBOPTS_LDADD)
-  AC_SUBST(LIBOPTS_CFLAGS)
-  AC_SUBST(LIBOPTS_DIR, AO_Libopts_Dir)
-  m4_popdef([AO_Libopts_Dir])
-[# end of AC_DEFUN of LIBOPTS_CHECK_COMMON]
-])
-dnl
-dnl AC_CONFIG_FILES conditionalization requires using AM_COND_IF, however
-dnl AM_COND_IF is new to Automake 1.11.  To use it on new Automake without
-dnl requiring same, a fallback implementation for older Automake is provided.
-dnl Note that disabling of AC_CONFIG_FILES requires Automake 1.11, this code
-dnl is correct only in terms of m4sh generated script.
-dnl
-m4_ifndef([AM_COND_IF],
-  [AC_DEFUN([AM_COND_IF], [
-    if test -z "$$1_TRUE"; then :
-      m4_n([$2])[]dnl
-      m4_ifval([$3],[
-    else
-      $3
-    ])dnl
-    fi[]dnl
-  ])dnl
-])
-dnl
-AC_DEFUN([LIBOPTS_CHECK_NOBUILD], [
-  m4_pushdef([AO_Libopts_Dir],
-	      [ifelse($1, , [libopts], [$1])])
-  LIBOPTS_BUILD_BLOCKED=true
-  LIBOPTS_CHECK_COMMON(AO_Libopts_Dir)
-  m4_popdef([AO_Libopts_Dir])dnl
-# end of AC_DEFUN of LIBOPTS_CHECK_NOBUILD
-])
-dnl
-AC_DEFUN([LIBOPTS_CHECK], [
-  m4_pushdef([AO_Libopts_Dir],
-	      [ifelse($1, , [libopts], [$1])])
-  LIBOPTS_BUILD_BLOCKED=''
-  LIBOPTS_CHECK_COMMON(AO_Libopts_Dir)
-  AM_COND_IF([NEED_LIBOPTS], [
-    INVOKE_LIBOPTS_MACROS
-  ])
-  AC_CONFIG_FILES(AO_Libopts_Dir/Makefile)
-  m4_popdef([AO_Libopts_Dir])dnl
-# end of AC_DEFUN of LIBOPTS_CHECK
-])

+ 8 - 7
m4/libtool.m4

@@ -4063,7 +4063,8 @@ _LT_EOF
   if AC_TRY_EVAL(ac_compile); then
     # Now try to grab the symbols.
     nlist=conftest.nm
-    if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then
+    $ECHO "$as_me:$LINENO: $NM conftest.$ac_objext | $lt_cv_sys_global_symbol_pipe > $nlist" >&AS_MESSAGE_LOG_FD
+    if eval "$NM" conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist 2>&AS_MESSAGE_LOG_FD && test -s "$nlist"; then
       # Try sorting and uniquifying the output.
       if sort "$nlist" | uniq > "$nlist"T; then
 	mv -f "$nlist"T "$nlist"
@@ -6438,7 +6439,7 @@ if test yes != "$_lt_caught_CXX_error"; then
       # Commands to make compiler produce verbose output that lists
       # what "hidden" libraries, object files and flags are used when
       # linking a shared library.
-      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"'
 
     else
       GXX=no
@@ -6813,7 +6814,7 @@ if test yes != "$_lt_caught_CXX_error"; then
             # explicitly linking system object files so we need to strip them
             # from the output so that they don't get included in the library
             # dependencies.
-            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
             ;;
           *)
             if test yes = "$GXX"; then
@@ -6878,7 +6879,7 @@ if test yes != "$_lt_caught_CXX_error"; then
 	    # explicitly linking system object files so we need to strip them
 	    # from the output so that they don't get included in the library
 	    # dependencies.
-	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP " \-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 	    ;;
           *)
 	    if test yes = "$GXX"; then
@@ -7217,7 +7218,7 @@ if test yes != "$_lt_caught_CXX_error"; then
 	      # Commands to make compiler produce verbose output that lists
 	      # what "hidden" libraries, object files and flags are used when
 	      # linking a shared library.
-	      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+	      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"'
 
 	    else
 	      # FIXME: insert proper C++ library support
@@ -7301,7 +7302,7 @@ if test yes != "$_lt_caught_CXX_error"; then
 	        # Commands to make compiler produce verbose output that lists
 	        # what "hidden" libraries, object files and flags are used when
 	        # linking a shared library.
-	        output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+	        output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"'
 	      else
 	        # g++ 2.7 appears to require '-G' NOT '-shared' on this
 	        # platform.
@@ -7312,7 +7313,7 @@ if test yes != "$_lt_caught_CXX_error"; then
 	        # Commands to make compiler produce verbose output that lists
 	        # what "hidden" libraries, object files and flags are used when
 	        # linking a shared library.
-	        output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+	        output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP " \-L"'
 	      fi
 
 	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $wl$libdir'

+ 0 - 41
m4/stdnoreturn.m4

@@ -1,41 +0,0 @@
-# Check for stdnoreturn.h that conforms to C11.
-
-dnl Copyright 2012-2016 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-# Prepare for substituting <stdnoreturn.h> if it is not supported.
-
-AC_DEFUN([gl_STDNORETURN_H],
-[
-  AC_CACHE_CHECK([for working stdnoreturn.h],
-    [gl_cv_header_working_stdnoreturn_h],
-    [AC_COMPILE_IFELSE(
-       [AC_LANG_PROGRAM(
-          [[#include <stdlib.h>
-            #include <stdnoreturn.h>
-            /* Do not check for 'noreturn' after the return type.
-               C11 allows it, but it's rarely done that way
-               and circa-2012 bleeding-edge GCC rejects it when given
-               -Werror=old-style-declaration.  */
-            noreturn void foo1 (void) { exit (0); }
-            _Noreturn void foo2 (void) { exit (0); }
-            int testit (int argc, char **argv) {
-              if (argc & 1)
-                return 0;
-              (argv[0][0] ? foo1 : foo2) ();
-            }
-          ]])],
-       [gl_cv_header_working_stdnoreturn_h=yes],
-       [gl_cv_header_working_stdnoreturn_h=no])])
-
-  if test $gl_cv_header_working_stdnoreturn_h = yes; then
-    STDNORETURN_H=''
-  else
-    STDNORETURN_H='stdnoreturn.h'
-  fi
-
-  AC_SUBST([STDNORETURN_H])
-  AM_CONDITIONAL([GL_GENERATE_STDNORETURN_H], [test -n "$STDNORETURN_H"])
-])

+ 11 - 11
scripts/Makefile.in

@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.16.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2018 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -90,12 +90,9 @@ host_triplet = @host@
 target_triplet = @target@
 subdir = scripts
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/libopts.m4 \
-	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
-	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
-	$(top_srcdir)/m4/lt~obsolete.m4 \
-	$(top_srcdir)/m4/stdnoreturn.m4 $(top_srcdir)/acinclude.m4 \
-	$(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
+	$(top_srcdir)/libopts/m4/stdnoreturn.m4 \
+	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
@@ -313,8 +310,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	  *config.status*) \
 	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
 	  *) \
-	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
-	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
 	esac;
 
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@@ -338,7 +335,10 @@ ctags CTAGS:
 cscope cscopelist:
 
 
-distdir: $(DISTFILES)
+distdir: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	list='$(DISTFILES)'; \

+ 142 - 57
src/Makefile.in

@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.16.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2018 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -99,12 +99,9 @@ bin_PROGRAMS = tcpreplay$(EXEEXT) tcpprep$(EXEEXT) tcprewrite$(EXEEXT) \
 @COMPILE_TCPLIVEPLAY_TRUE@am__append_4 = tcpliveplay.1
 subdir = src
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/libopts.m4 \
-	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
-	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
-	$(top_srcdir)/m4/lt~obsolete.m4 \
-	$(top_srcdir)/m4/stdnoreturn.m4 $(top_srcdir)/acinclude.m4 \
-	$(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
+	$(top_srcdir)/libopts/m4/stdnoreturn.m4 \
+	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \
@@ -208,7 +205,33 @@ am__v_at_0 = @
 am__v_at_1 = 
 DEFAULT_INCLUDES = -I.@am__isrc@
 depcomp = $(SHELL) $(top_srcdir)/config/depcomp
-am__depfiles_maybe = depfiles
+am__maybe_remake_depfiles = depfiles
+am__depfiles_remade = ./$(DEPDIR)/tcpbridge-bridge.Po \
+	./$(DEPDIR)/tcpbridge-tcpbridge.Po \
+	./$(DEPDIR)/tcpbridge-tcpbridge_opts.Po \
+	./$(DEPDIR)/tcpcapinfo-tcpcapinfo.Po \
+	./$(DEPDIR)/tcpcapinfo-tcpcapinfo_opts.Po \
+	./$(DEPDIR)/tcpliveplay-tcpliveplay.Po \
+	./$(DEPDIR)/tcpliveplay-tcpliveplay_opts.Po \
+	./$(DEPDIR)/tcpprep-tcpprep.Po \
+	./$(DEPDIR)/tcpprep-tcpprep_api.Po \
+	./$(DEPDIR)/tcpprep-tcpprep_opts.Po \
+	./$(DEPDIR)/tcpprep-tree.Po ./$(DEPDIR)/tcpreplay-replay.Po \
+	./$(DEPDIR)/tcpreplay-send_packets.Po \
+	./$(DEPDIR)/tcpreplay-signal_handler.Po \
+	./$(DEPDIR)/tcpreplay-sleep.Po \
+	./$(DEPDIR)/tcpreplay-tcpreplay.Po \
+	./$(DEPDIR)/tcpreplay-tcpreplay_api.Po \
+	./$(DEPDIR)/tcpreplay-tcpreplay_opts.Po \
+	./$(DEPDIR)/tcpreplay_edit-replay.Po \
+	./$(DEPDIR)/tcpreplay_edit-send_packets.Po \
+	./$(DEPDIR)/tcpreplay_edit-signal_handler.Po \
+	./$(DEPDIR)/tcpreplay_edit-sleep.Po \
+	./$(DEPDIR)/tcpreplay_edit-tcpreplay.Po \
+	./$(DEPDIR)/tcpreplay_edit-tcpreplay_api.Po \
+	./$(DEPDIR)/tcpreplay_edit-tcpreplay_edit_opts.Po \
+	./$(DEPDIR)/tcprewrite-tcprewrite.Po \
+	./$(DEPDIR)/tcprewrite-tcprewrite_opts.Po
 am__mv = mv -f
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -285,7 +308,7 @@ am__recursive_targets = \
   $(RECURSIVE_CLEAN_TARGETS) \
   $(am__extra_recursive_targets)
 AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
-	distdir
+	distdir distdir-am
 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
 	$(LISP)config.h.in
 # Read a list of newline-separated strings from the standard input,
@@ -592,8 +615,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	  *config.status*) \
 	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
 	  *) \
-	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
-	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
 	esac;
 
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@@ -705,33 +728,39 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpbridge-bridge.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpbridge-tcpbridge.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpbridge-tcpbridge_opts.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpcapinfo-tcpcapinfo.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpcapinfo-tcpcapinfo_opts.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpliveplay-tcpliveplay.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpliveplay-tcpliveplay_opts.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpprep-tcpprep.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpprep-tcpprep_api.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpprep-tcpprep_opts.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpprep-tree.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay-replay.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay-send_packets.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay-signal_handler.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay-sleep.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay-tcpreplay.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay-tcpreplay_api.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay-tcpreplay_opts.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay_edit-replay.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay_edit-send_packets.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay_edit-signal_handler.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay_edit-sleep.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay_edit-tcpreplay.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay_edit-tcpreplay_api.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay_edit-tcpreplay_edit_opts.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcprewrite-tcprewrite.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcprewrite-tcprewrite_opts.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpbridge-bridge.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpbridge-tcpbridge.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpbridge-tcpbridge_opts.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpcapinfo-tcpcapinfo.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpcapinfo-tcpcapinfo_opts.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpliveplay-tcpliveplay.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpliveplay-tcpliveplay_opts.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpprep-tcpprep.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpprep-tcpprep_api.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpprep-tcpprep_opts.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpprep-tree.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay-replay.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay-send_packets.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay-signal_handler.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay-sleep.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay-tcpreplay.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay-tcpreplay_api.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay-tcpreplay_opts.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay_edit-replay.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay_edit-send_packets.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay_edit-signal_handler.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay_edit-sleep.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay_edit-tcpreplay.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay_edit-tcpreplay_api.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpreplay_edit-tcpreplay_edit_opts.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcprewrite-tcprewrite.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcprewrite-tcprewrite_opts.Po@am__quote@ # am--include-marker
+
+$(am__depfiles_remade):
+	@$(MKDIR_P) $(@D)
+	@echo '# dummy' >$@-t && $(am__mv) $@-t $@
+
+am--depfiles: $(am__depfiles_remade)
 
 .c.o:
 @am__fastdepCC_TRUE@	$(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@@ -1283,7 +1312,10 @@ cscopelist-am: $(am__tagged_files)
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
-distdir: $(DISTFILES)
+distdir: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	list='$(DISTFILES)'; \
@@ -1386,7 +1418,33 @@ clean: clean-recursive
 clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
 
 distclean: distclean-recursive
-	-rm -rf ./$(DEPDIR)
+		-rm -f ./$(DEPDIR)/tcpbridge-bridge.Po
+	-rm -f ./$(DEPDIR)/tcpbridge-tcpbridge.Po
+	-rm -f ./$(DEPDIR)/tcpbridge-tcpbridge_opts.Po
+	-rm -f ./$(DEPDIR)/tcpcapinfo-tcpcapinfo.Po
+	-rm -f ./$(DEPDIR)/tcpcapinfo-tcpcapinfo_opts.Po
+	-rm -f ./$(DEPDIR)/tcpliveplay-tcpliveplay.Po
+	-rm -f ./$(DEPDIR)/tcpliveplay-tcpliveplay_opts.Po
+	-rm -f ./$(DEPDIR)/tcpprep-tcpprep.Po
+	-rm -f ./$(DEPDIR)/tcpprep-tcpprep_api.Po
+	-rm -f ./$(DEPDIR)/tcpprep-tcpprep_opts.Po
+	-rm -f ./$(DEPDIR)/tcpprep-tree.Po
+	-rm -f ./$(DEPDIR)/tcpreplay-replay.Po
+	-rm -f ./$(DEPDIR)/tcpreplay-send_packets.Po
+	-rm -f ./$(DEPDIR)/tcpreplay-signal_handler.Po
+	-rm -f ./$(DEPDIR)/tcpreplay-sleep.Po
+	-rm -f ./$(DEPDIR)/tcpreplay-tcpreplay.Po
+	-rm -f ./$(DEPDIR)/tcpreplay-tcpreplay_api.Po
+	-rm -f ./$(DEPDIR)/tcpreplay-tcpreplay_opts.Po
+	-rm -f ./$(DEPDIR)/tcpreplay_edit-replay.Po
+	-rm -f ./$(DEPDIR)/tcpreplay_edit-send_packets.Po
+	-rm -f ./$(DEPDIR)/tcpreplay_edit-signal_handler.Po
+	-rm -f ./$(DEPDIR)/tcpreplay_edit-sleep.Po
+	-rm -f ./$(DEPDIR)/tcpreplay_edit-tcpreplay.Po
+	-rm -f ./$(DEPDIR)/tcpreplay_edit-tcpreplay_api.Po
+	-rm -f ./$(DEPDIR)/tcpreplay_edit-tcpreplay_edit_opts.Po
+	-rm -f ./$(DEPDIR)/tcprewrite-tcprewrite.Po
+	-rm -f ./$(DEPDIR)/tcprewrite-tcprewrite_opts.Po
 	-rm -f Makefile
 distclean-am: clean-am distclean-compile distclean-generic \
 	distclean-hdr distclean-tags
@@ -1432,7 +1490,33 @@ install-ps-am:
 installcheck-am:
 
 maintainer-clean: maintainer-clean-recursive
-	-rm -rf ./$(DEPDIR)
+		-rm -f ./$(DEPDIR)/tcpbridge-bridge.Po
+	-rm -f ./$(DEPDIR)/tcpbridge-tcpbridge.Po
+	-rm -f ./$(DEPDIR)/tcpbridge-tcpbridge_opts.Po
+	-rm -f ./$(DEPDIR)/tcpcapinfo-tcpcapinfo.Po
+	-rm -f ./$(DEPDIR)/tcpcapinfo-tcpcapinfo_opts.Po
+	-rm -f ./$(DEPDIR)/tcpliveplay-tcpliveplay.Po
+	-rm -f ./$(DEPDIR)/tcpliveplay-tcpliveplay_opts.Po
+	-rm -f ./$(DEPDIR)/tcpprep-tcpprep.Po
+	-rm -f ./$(DEPDIR)/tcpprep-tcpprep_api.Po
+	-rm -f ./$(DEPDIR)/tcpprep-tcpprep_opts.Po
+	-rm -f ./$(DEPDIR)/tcpprep-tree.Po
+	-rm -f ./$(DEPDIR)/tcpreplay-replay.Po
+	-rm -f ./$(DEPDIR)/tcpreplay-send_packets.Po
+	-rm -f ./$(DEPDIR)/tcpreplay-signal_handler.Po
+	-rm -f ./$(DEPDIR)/tcpreplay-sleep.Po
+	-rm -f ./$(DEPDIR)/tcpreplay-tcpreplay.Po
+	-rm -f ./$(DEPDIR)/tcpreplay-tcpreplay_api.Po
+	-rm -f ./$(DEPDIR)/tcpreplay-tcpreplay_opts.Po
+	-rm -f ./$(DEPDIR)/tcpreplay_edit-replay.Po
+	-rm -f ./$(DEPDIR)/tcpreplay_edit-send_packets.Po
+	-rm -f ./$(DEPDIR)/tcpreplay_edit-signal_handler.Po
+	-rm -f ./$(DEPDIR)/tcpreplay_edit-sleep.Po
+	-rm -f ./$(DEPDIR)/tcpreplay_edit-tcpreplay.Po
+	-rm -f ./$(DEPDIR)/tcpreplay_edit-tcpreplay_api.Po
+	-rm -f ./$(DEPDIR)/tcpreplay_edit-tcpreplay_edit_opts.Po
+	-rm -f ./$(DEPDIR)/tcprewrite-tcprewrite.Po
+	-rm -f ./$(DEPDIR)/tcprewrite-tcprewrite_opts.Po
 	-rm -f Makefile
 maintainer-clean-am: distclean-am maintainer-clean-generic
 
@@ -1456,21 +1540,22 @@ uninstall-man: uninstall-man1
 .MAKE: $(am__recursive_targets) all check install install-am \
 	install-strip
 
-.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \
-	check-am clean clean-binPROGRAMS clean-generic clean-libtool \
-	cscopelist-am ctags ctags-am distclean distclean-compile \
-	distclean-generic distclean-hdr distclean-libtool \
-	distclean-tags distdir dvi dvi-am html html-am info info-am \
-	install install-am install-binPROGRAMS install-data \
-	install-data-am install-dvi install-dvi-am install-exec \
-	install-exec-am install-html install-html-am install-info \
-	install-info-am install-man install-man1 install-pdf \
-	install-pdf-am install-ps install-ps-am install-strip \
-	installcheck installcheck-am installdirs installdirs-am \
-	maintainer-clean maintainer-clean-generic mostlyclean \
-	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
-	pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \
-	uninstall-binPROGRAMS uninstall-man uninstall-man1
+.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
+	am--depfiles check check-am clean clean-binPROGRAMS \
+	clean-generic clean-libtool cscopelist-am ctags ctags-am \
+	distclean distclean-compile distclean-generic distclean-hdr \
+	distclean-libtool distclean-tags distdir dvi dvi-am html \
+	html-am info info-am install install-am install-binPROGRAMS \
+	install-data install-data-am install-dvi install-dvi-am \
+	install-exec install-exec-am install-html install-html-am \
+	install-info install-info-am install-man install-man1 \
+	install-pdf install-pdf-am install-ps install-ps-am \
+	install-strip installcheck installcheck-am installdirs \
+	installdirs-am maintainer-clean maintainer-clean-generic \
+	mostlyclean mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
+	uninstall-am uninstall-binPROGRAMS uninstall-man \
+	uninstall-man1
 
 .PRECIOUS: Makefile
 

+ 15 - 21
src/bridge.c

@@ -41,8 +41,7 @@ extern int debug;
 #endif
 volatile bool didsig;
 
-static int live_callback(struct live_data_t *,
-                         struct pcap_pkthdr *, const u_char *);
+static void live_callback(u_char *, const struct pcap_pkthdr *, const u_char *);
 
 static void signal_catcher(int signo);
 
@@ -106,8 +105,8 @@ do_bridge_unidirectional(tcpbridge_opt_t *options, tcpedit_t *tcpedit)
     livedata.pcap = options->pcap1;
     livedata.options = options;
 
-    if ((retcode = pcap_loop(options->pcap1, options->limit_send, 
-            (pcap_handler)live_callback, (u_char *) &livedata)) < 0) {
+    if ((retcode = pcap_loop(options->pcap1, options->limit_send,
+            live_callback, (u_char*)&livedata)) < 0) {
         warnx("Error in pcap_loop(): %s", pcap_geterr(options->pcap1));
     }
 }
@@ -250,10 +249,13 @@ do_bridge(tcpbridge_opt_t *options, tcpedit_t *tcpedit)
  * each packet received by libpcap on the two interfaces.
  * Need to return > 0 to denote success
  */
-static int
-live_callback(struct live_data_t *livedata, struct pcap_pkthdr *pkthdr,
+static void
+live_callback(u_char *usr_data, const struct pcap_pkthdr *const_pkthdr,
               const u_char * nextpkt)
 {
+    struct live_data_t *livedata = (struct live_data_t*)usr_data;
+    struct pcap_pkthdr pkthdr_buf = *const_pkthdr;
+    struct pcap_pkthdr *pkthdr = &pkthdr_buf;
     ipv4_hdr_t *ip_hdr = NULL;
     ipv6_hdr_t *ip6_hdr = NULL;
     pcap_t *send = NULL;
@@ -300,11 +302,11 @@ live_callback(struct live_data_t *livedata, struct pcap_pkthdr *pkthdr,
     /* first, is this a packet sent locally?  If so, ignore it */
     if ((memcmp(livedata->options->intf1_mac, &finder.key, ETHER_ADDR_LEN)) == 0) {
         dbgx(1, "Packet matches the MAC of %s, skipping.", livedata->options->intf1);
-        return (1);
+        return;
     }
     else if ((memcmp(livedata->options->intf2_mac, &finder.key, ETHER_ADDR_LEN)) == 0) {
         dbgx(1, "Packet matches the MAC of %s, skipping.", livedata->options->intf2);
-        return (1);
+        return;
     }
 
     node = RB_FIND(macsrc_tree, &macsrc_root, &finder);
@@ -325,7 +327,7 @@ live_callback(struct live_data_t *livedata, struct pcap_pkthdr *pkthdr,
          * IMPORTANT!!!
          * Never send a packet out the same interface we sourced it on!
          */
-        return (1);
+        return;
     }
 
     /* what is our cache mode? */
@@ -344,7 +346,7 @@ live_callback(struct live_data_t *livedata, struct pcap_pkthdr *pkthdr,
             if (!ip_hdr ||
                     !process_xX_by_cidr_ipv4(livedata->options->xX.mode, livedata->options->xX.cidr, ip_hdr)) {
                 dbg(2, "Skipping IPv4 packet due to CIDR match");
-                return (1);
+                return;
             }
         }
 
@@ -357,19 +359,14 @@ live_callback(struct live_data_t *livedata, struct pcap_pkthdr *pkthdr,
         if (livedata->options->xX.cidr != NULL) {
             if (!process_xX_by_cidr_ipv6(livedata->options->xX.mode, livedata->options->xX.cidr, ip6_hdr)) {
                 dbg(2, "Skipping IPv6 packet due to CIDR match");
-                return (1);
+                return;
             }
         }
 
     }
 
-    if ((retcode = tcpedit_packet(livedata->tcpedit, &pkthdr, &pktdata, cache_mode)) < 0) {
-        if (retcode == TCPEDIT_SOFT_ERROR) {
-            return 1;
-        } else { /* TCPEDIT_ERROR */
-            return -1;
-        }
-    }
+    if ((retcode = tcpedit_packet(livedata->tcpedit, &pkthdr, &pktdata, cache_mode)) < 0)
+        return;
 
     /* 
      * send packets out the OTHER interface
@@ -404,9 +401,6 @@ live_callback(struct live_data_t *livedata, struct pcap_pkthdr *pkthdr,
     stats.pkts_sent++;
 
     dbgx(1, "Sent packet " COUNTER_SPEC, stats.pkts_sent);
-
-
-    return (1);
 } /* live_callback() */
 
 static void

+ 101 - 45
src/common/Makefile.in

@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.16.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2018 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -94,12 +94,9 @@ target_triplet = @target@
 @COMPILE_NETMAP_TRUE@am__append_2 = netmap.c
 subdir = src/common
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/libopts.m4 \
-	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
-	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
-	$(top_srcdir)/m4/lt~obsolete.m4 \
-	$(top_srcdir)/m4/stdnoreturn.m4 $(top_srcdir)/acinclude.m4 \
-	$(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
+	$(top_srcdir)/libopts/m4/stdnoreturn.m4 \
+	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \
@@ -144,7 +141,17 @@ am__v_at_0 = @
 am__v_at_1 = 
 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
 depcomp = $(SHELL) $(top_srcdir)/config/depcomp
-am__depfiles_maybe = depfiles
+am__maybe_remake_depfiles = depfiles
+am__depfiles_remade = ./$(DEPDIR)/cache.Po ./$(DEPDIR)/cidr.Po \
+	./$(DEPDIR)/dlt_names.Po ./$(DEPDIR)/err.Po \
+	./$(DEPDIR)/fakepcap.Po ./$(DEPDIR)/fakepcapnav.Po \
+	./$(DEPDIR)/fakepoll.Po ./$(DEPDIR)/flows.Po \
+	./$(DEPDIR)/get.Po ./$(DEPDIR)/git_version.Po \
+	./$(DEPDIR)/interface.Po ./$(DEPDIR)/list.Po \
+	./$(DEPDIR)/mac.Po ./$(DEPDIR)/netmap.Po \
+	./$(DEPDIR)/sendpacket.Po ./$(DEPDIR)/services.Po \
+	./$(DEPDIR)/tcpdump.Po ./$(DEPDIR)/timer.Po \
+	./$(DEPDIR)/txring.Po ./$(DEPDIR)/utils.Po ./$(DEPDIR)/xX.Po
 am__mv = mv -f
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -403,8 +410,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	  *config.status*) \
 	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
 	  *) \
-	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
-	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
 	esac;
 
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@@ -430,27 +437,33 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cache.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cidr.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dlt_names.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/err.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fakepcap.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fakepcapnav.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fakepoll.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flows.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/git_version.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/interface.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mac.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netmap.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sendpacket.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/services.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpdump.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timer.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/txring.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xX.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cache.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cidr.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dlt_names.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/err.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fakepcap.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fakepcapnav.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fakepoll.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flows.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/git_version.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/interface.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mac.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netmap.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sendpacket.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/services.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpdump.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timer.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/txring.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utils.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xX.Po@am__quote@ # am--include-marker
+
+$(am__depfiles_remade):
+	@$(MKDIR_P) $(@D)
+	@echo '# dummy' >$@-t && $(am__mv) $@-t $@
+
+am--depfiles: $(am__depfiles_remade)
 
 .c.o:
 @am__fastdepCC_TRUE@	$(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@@ -534,7 +547,10 @@ cscopelist-am: $(am__tagged_files)
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
-distdir: $(DISTFILES)
+distdir: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	list='$(DISTFILES)'; \
@@ -609,7 +625,27 @@ clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \
 	mostlyclean-am
 
 distclean: distclean-am
-	-rm -rf ./$(DEPDIR)
+		-rm -f ./$(DEPDIR)/cache.Po
+	-rm -f ./$(DEPDIR)/cidr.Po
+	-rm -f ./$(DEPDIR)/dlt_names.Po
+	-rm -f ./$(DEPDIR)/err.Po
+	-rm -f ./$(DEPDIR)/fakepcap.Po
+	-rm -f ./$(DEPDIR)/fakepcapnav.Po
+	-rm -f ./$(DEPDIR)/fakepoll.Po
+	-rm -f ./$(DEPDIR)/flows.Po
+	-rm -f ./$(DEPDIR)/get.Po
+	-rm -f ./$(DEPDIR)/git_version.Po
+	-rm -f ./$(DEPDIR)/interface.Po
+	-rm -f ./$(DEPDIR)/list.Po
+	-rm -f ./$(DEPDIR)/mac.Po
+	-rm -f ./$(DEPDIR)/netmap.Po
+	-rm -f ./$(DEPDIR)/sendpacket.Po
+	-rm -f ./$(DEPDIR)/services.Po
+	-rm -f ./$(DEPDIR)/tcpdump.Po
+	-rm -f ./$(DEPDIR)/timer.Po
+	-rm -f ./$(DEPDIR)/txring.Po
+	-rm -f ./$(DEPDIR)/utils.Po
+	-rm -f ./$(DEPDIR)/xX.Po
 	-rm -f Makefile
 distclean-am: clean-am distclean-compile distclean-generic \
 	distclean-tags
@@ -655,7 +691,27 @@ install-ps-am:
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
-	-rm -rf ./$(DEPDIR)
+		-rm -f ./$(DEPDIR)/cache.Po
+	-rm -f ./$(DEPDIR)/cidr.Po
+	-rm -f ./$(DEPDIR)/dlt_names.Po
+	-rm -f ./$(DEPDIR)/err.Po
+	-rm -f ./$(DEPDIR)/fakepcap.Po
+	-rm -f ./$(DEPDIR)/fakepcapnav.Po
+	-rm -f ./$(DEPDIR)/fakepoll.Po
+	-rm -f ./$(DEPDIR)/flows.Po
+	-rm -f ./$(DEPDIR)/get.Po
+	-rm -f ./$(DEPDIR)/git_version.Po
+	-rm -f ./$(DEPDIR)/interface.Po
+	-rm -f ./$(DEPDIR)/list.Po
+	-rm -f ./$(DEPDIR)/mac.Po
+	-rm -f ./$(DEPDIR)/netmap.Po
+	-rm -f ./$(DEPDIR)/sendpacket.Po
+	-rm -f ./$(DEPDIR)/services.Po
+	-rm -f ./$(DEPDIR)/tcpdump.Po
+	-rm -f ./$(DEPDIR)/timer.Po
+	-rm -f ./$(DEPDIR)/txring.Po
+	-rm -f ./$(DEPDIR)/utils.Po
+	-rm -f ./$(DEPDIR)/xX.Po
 	-rm -f Makefile
 maintainer-clean-am: distclean-am maintainer-clean-generic
 
@@ -676,16 +732,16 @@ uninstall-am:
 
 .MAKE: all check install install-am install-strip
 
-.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
-	clean-libtool clean-noinstLIBRARIES cscopelist-am ctags \
-	ctags-am distclean distclean-compile distclean-generic \
-	distclean-libtool distclean-tags distdir dvi dvi-am html \
-	html-am info info-am install install-am install-data \
-	install-data-am install-dvi install-dvi-am install-exec \
-	install-exec-am install-html install-html-am install-info \
-	install-info-am install-man install-pdf install-pdf-am \
-	install-ps install-ps-am install-strip installcheck \
-	installcheck-am installdirs maintainer-clean \
+.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \
+	clean-generic clean-libtool clean-noinstLIBRARIES \
+	cscopelist-am ctags ctags-am distclean distclean-compile \
+	distclean-generic distclean-libtool distclean-tags distdir dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-data install-data-am install-dvi install-dvi-am \
+	install-exec install-exec-am install-html install-html-am \
+	install-info install-info-am install-man install-pdf \
+	install-pdf-am install-ps install-ps-am install-strip \
+	installcheck installcheck-am installdirs maintainer-clean \
 	maintainer-clean-generic mostlyclean mostlyclean-compile \
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am

+ 4 - 11
src/common/cidr.c

@@ -21,9 +21,6 @@
 #include "config.h"
 #include "defines.h"
 #include "common.h"
-#ifndef HAVE_STRLCPY
-#include "lib/strlcpy.h"
-#endif 
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -121,10 +118,10 @@ ip2cidr(const unsigned long ip, const int masklen)
 
     strcat((char *)network, "/");
     if (masklen < 10) {
-        snprintf(mask, 1, "%d", masklen);
+        snprintf(mask, sizeof(mask), "%d", masklen);
         strncat((char *)network, mask, 1);
     } else {
-        snprintf(mask, 2, "%d", masklen);
+        snprintf(mask, sizeof(mask), "%d", masklen);
         strncat((char *)network, mask, 2);
     }
 
@@ -176,12 +173,11 @@ cidr2cidr(char *cidr)
     int count = 0;
     unsigned int octets[4];     /* used in sscanf */
     tcpr_cidr_t *newcidr;
-    char networkip[16], tempoctet[4], ebuf[EBUF_SIZE];
+    char networkip[16], tempoctet[4];
     int family;
     char* p;
 
     assert(cidr);
-    assert(strlen(cidr) <= EBUF_SIZE);
 
     newcidr = new_cidr();
 
@@ -265,10 +261,7 @@ cidr2cidr(char *cidr)
 
     /* we only get here on error parsing input */
 error:
-    memset(ebuf, '\0', EBUF_SIZE);
-    strcpy(ebuf, "Unable to parse as a valid CIDR: ");
-    strlcat(ebuf, cidr, EBUF_SIZE);
-    errx(-1, "%s", ebuf);
+    errx(-1, "%s: %s", "Unable to parse as a valid CIDR", cidr);
     return NULL;
 }
 

+ 51 - 18
src/common/get.c

@@ -39,7 +39,9 @@ extern int debug;
 extern const char pcap_version[];
 #endif
 
-
+#define JUNIPER_FLAG_NO_L2          0x02     /* L2 header */
+#define JUNIPER_FLAG_EXT            0x80     /* Juniper extensions present */
+#define JUNIPER_PCAP_MAGIC          "MGC"
 /**
  * Depending on what version of libpcap/WinPcap there are different ways to get 
  * the version of the libpcap/WinPcap library.  This presents a unified way to 
@@ -88,6 +90,8 @@ get_l2protocol(const u_char *pktdata, const uint32_t datalen, const int datalink
 
     switch (datalink) {
     case DLT_RAW:
+        if (datalen < 1)
+            return 0;
         if ((pktdata[0] >> 4) == 4)
             return ETHERTYPE_IP;
         else if ((pktdata[0] >> 4) == 6)
@@ -95,20 +99,37 @@ get_l2protocol(const u_char *pktdata, const uint32_t datalen, const int datalink
         break;
 
     case DLT_JUNIPER_ETHER:
-        if (datalen < 5)
+        if (datalen < 4)
             return 0;
 
-        if (memcmp(pktdata, "MGC", 3))
-            warnx("No Magic Number found: %s (0x%x)",
+        if (memcmp(pktdata, JUNIPER_PCAP_MAGIC, 3)) {
+            warnx("No Magic Number found during protocol lookup: %s (0x%x)",
                  pcap_datalink_val_to_description(datalink), datalink);
+            return 0;
+        }
+
+        if ((pktdata[3] & JUNIPER_FLAG_EXT) == JUNIPER_FLAG_EXT) {
+            if (datalen < 6)
+                return 0;  /* datalen too short */
 
-        if ((pktdata[3] & 0x80) == 0x80) {
             eth_hdr_offset = ntohs(*((uint16_t*)&pktdata[4]));
-            eth_hdr_offset += 6;
+            eth_hdr_offset += 6; /* MGC + flags + ext_total_len */
         } else {
-            eth_hdr_offset = 4; /* no header extensions */
+            eth_hdr_offset = 4; /* MGC + flags (no header extensions) */
         }
-        /* fallthrough */
+        if ((pktdata[3] & JUNIPER_FLAG_NO_L2) == JUNIPER_FLAG_NO_L2) {
+             /* no L2 header present - eth_hdr_offset is actually IP offset */
+            uint32_t ip_hdr_offset = eth_hdr_offset;
+            if (datalen < ip_hdr_offset + 1)
+                return 0;
+            if ((pktdata[ip_hdr_offset] >> 4) == 4)
+                return ETHERTYPE_IP;
+            else if ((pktdata[ip_hdr_offset] >> 4) == 6)
+                return ETHERTYPE_IP6;
+            else
+                return 0;
+        }
+        /* fall through */
     case DLT_EN10MB:
         if ((size_t)datalen >= (sizeof(eth_hdr_t) + eth_hdr_offset)) {
             eth_hdr_t *eth_hdr = (eth_hdr_t *)(pktdata + eth_hdr_offset);
@@ -158,7 +179,6 @@ get_l2protocol(const u_char *pktdata, const uint32_t datalen, const int datalink
     }
 
     return 0;
-
 }
 
 /**
@@ -178,23 +198,36 @@ get_l2len(const u_char *pktdata, const int datalen, const int datalink)
         break;
 
     case DLT_JUNIPER_ETHER:
-        if (datalen >= 5) {
+        if (datalen < 4) {
             l2_len = -1;
             break;
         }
 
-        if (memcmp(pktdata, "MGC", 3))
-            warnx("No Magic Number found: %s (0x%x)",
-                 pcap_datalink_val_to_description(datalink), datalink);
+        if (memcmp(pktdata, JUNIPER_PCAP_MAGIC, 3)) {
+            warnx("No Magic Number found during L2 lookup: %s (0x%x)",
+                  pcap_datalink_val_to_description(datalink), datalink);
+            l2_len = -1;
+            break;
+        }
 
-        if ((pktdata[3] & 0x80) == 0x80) {
+        if ((pktdata[3] & JUNIPER_FLAG_NO_L2) == JUNIPER_FLAG_NO_L2) {
+            /* no L2 header present */
+            l2_len = 0;
+            break;
+        }
+
+        if ((pktdata[3] & JUNIPER_FLAG_EXT) == JUNIPER_FLAG_EXT) {
+            if (datalen < 6) {
+                /* datalen too short */
+                l2_len = -1;
+                break;
+            }
             l2_len = ntohs(*((uint16_t*)&pktdata[4]));
-            l2_len += 6;
+            l2_len += 6;        /* MGC + flags + ext_total_len */
         } else {
-            l2_len = 4; /* no header extensions */
+            l2_len = 4;         /* MGC + flags */
         }
-
-        /* fallthrough */
+        /* fall through */
     case DLT_EN10MB:
         if ((size_t)datalen >= sizeof(eth_hdr_t) + l2_len) {
             uint16_t ether_type = ntohs(((eth_hdr_t*)(pktdata + l2_len))->ether_type);

+ 1 - 1
src/common/git_version.c

@@ -1,4 +1,4 @@
-const char GIT_Version[] = "git:v4.3.3";
+const char GIT_Version[] = "git:v4.3.4";
 const char *git_version(void) {
     return GIT_Version;
 }

+ 6 - 6
src/common/interface.c

@@ -75,7 +75,7 @@ interface_list_t *
 get_interface_list(void)
 {
     interface_list_t *list_head, *list_ptr;
-    char ebuf[PCAP_ERRBUF_SIZE], testnic[255];
+    char ebuf[PCAP_ERRBUF_SIZE], testnic[320];
     pcap_if_t *pcap_if, *pcap_if_ptr;
     int i = 0;
     DIR *dir;
@@ -206,11 +206,11 @@ get_interface_list(void)
                     list_ptr = list_ptr->next;
                 }
                 dbgx(3, "Adding %s to interface list", dirdata->d_name);
-                snprintf(testnic, 254, "/dev/char/%s", dirdata->d_name);
-                strlcpy(list_ptr->name, testnic, 255);
-                snprintf(testnic, 255, "khial pseudo-nic: %s", dirdata->d_name);
-                strlcpy(list_ptr->description, testnic, 255);
-                strlcpy(list_ptr->alias, dirdata->d_name, 255);
+                snprintf(testnic, sizeof(testnic), "/dev/char/%s", dirdata->d_name);
+                strlcpy(list_ptr->name, testnic, sizeof(list_ptr->name));
+                snprintf(testnic, sizeof(testnic), "khial pseudo-nic: %s", dirdata->d_name);
+                strlcpy(list_ptr->description, testnic, sizeof(list_ptr->description));
+                strlcpy(list_ptr->alias, dirdata->d_name, sizeof(list_ptr->alias));
                 i += 1;
             }
         }

+ 4 - 1
src/common/list.c

@@ -80,10 +80,10 @@ parse_list(tcpr_list_t ** listdata, char *ourstr)
     /* regex test */
     if (regexec(&preg, this, 0, NULL, 0) != 0) {
         warnx("Unable to parse: %s", this);
+        regfree(&preg);
         return 0;
     }
 
-
     *listdata = new_list();
     list_ptr = *listdata;
     listcur = list_ptr;
@@ -115,6 +115,7 @@ parse_list(tcpr_list_t ** listdata, char *ourstr)
         /* regex test */
         if (regexec(&preg, this, 0, NULL, 0) != 0) {
             warnx("Unable to parse: %s", this);
+            regfree(&preg);
             return 0;
         }
 
@@ -138,6 +139,8 @@ parse_list(tcpr_list_t ** listdata, char *ourstr)
 
     }
 
+    regfree(&preg);
+
     return 1;
 }
 

+ 11 - 1
src/common/sendpacket.c

@@ -473,6 +473,10 @@ sendpacket_t *
 sendpacket_open(const char *device, char *errbuf, tcpr_dir_t direction,
         sendpacket_type_t sendpacket_type _U_, void *arg _U_)
 {
+#ifdef HAVE_TUNTAP
+    char sys_dev_dir[128];
+    bool device_exists;
+#endif
     sendpacket_t *sp;
     struct stat sdata;
 
@@ -480,6 +484,12 @@ sendpacket_open(const char *device, char *errbuf, tcpr_dir_t direction,
     assert(errbuf);
 
     errbuf[0] = '\0';
+
+#ifdef HAVE_TUNTAP
+    snprintf(sys_dev_dir, sizeof(sys_dev_dir), "/sys/class/net/%s/", device);
+    device_exists = access(sys_dev_dir, R_OK) == 0;
+#endif
+
     /* khial is universal */
     if (stat(device, &sdata) == 0) {
         if (((sdata.st_mode & S_IFMT) == S_IFCHR)) { 
@@ -515,7 +525,7 @@ sendpacket_open(const char *device, char *errbuf, tcpr_dir_t direction,
               }
         }
 #ifdef HAVE_TUNTAP
-    } else if (strncmp(device, "tap", 3) == 0) {
+    } else if (strncmp(device, "tap", 3) == 0 && !device_exists) {
         sp = sendpacket_open_tuntap(device, errbuf);
 #endif
     } else {

+ 1 - 0
src/common/services.c

@@ -91,5 +91,6 @@ parse_services(const char *file, tcpr_services_t *services)
         }
     }
 
+    regfree(&preg);
     fclose(service);
 }

+ 0 - 4
src/common/tcpdump.c

@@ -49,10 +49,6 @@
 
 #include "tcpdump.h"
 
-#ifndef HAVE_STRLCPY
-#include "lib/strlcpy.h"
-#endif
-
 #ifdef DEBUG
 extern int debug;
 #endif

+ 2 - 0
src/common/utils.h

@@ -36,6 +36,8 @@ typedef struct {
     struct timeval end_time;
     struct timeval pkt_ts_delta;
     struct timeval last_print;
+    struct timeval first_packet_sent_wall_time;
+    struct timeval first_packet_pcap_timestamp;
     COUNTER flow_non_flow_packets;
     COUNTER flows;
     COUNTER flows_unique;

+ 0 - 10
src/config.h.in

@@ -346,10 +346,6 @@
 /* Define to 1 if you have the `putenv' function. */
 #undef HAVE_PUTENV
 
-/* Define to 1 if your system has a GNU libc compatible `realloc' function,
-   and to 0 otherwise. */
-#undef HAVE_REALLOC
-
 /* Define this if we have a functional realpath(3C) */
 #undef HAVE_REALPATH
 
@@ -649,9 +645,6 @@
 /* name of regex header file */
 #undef REGEX_HEADER
 
-/* Define as the return type of signal handlers (`int' or `void'). */
-#undef RETSIGTYPE
-
 /* The size of `char *', as computed by sizeof. */
 #undef SIZEOF_CHAR_P
 
@@ -757,9 +750,6 @@
 /* Define to `int' if <sys/types.h> does not define. */
 #undef pid_t
 
-/* Define to rpl_realloc if the replacement function should be used. */
-#undef realloc
-
 /* Define to `unsigned int' if <sys/types.h> does not define. */
 #undef size_t
 

+ 1 - 1
src/defines.h

@@ -362,7 +362,7 @@ typedef u_int32_t uint32_t
 */
 #ifdef UNUSED 
 #elif defined(__GNUC__) 
-# define UNUSED(x) UNUSED_ ## x __attribute__((unused)) 
+# define UNUSED(x) x __attribute__((unused))
 #elif defined(__LCLINT__) 
 # define UNUSED(x) /*@unused@*/ x 
 #else 

+ 1 - 1
src/defines.h.in

@@ -362,7 +362,7 @@ typedef u_int32_t uint32_t
 */
 #ifdef UNUSED 
 #elif defined(__GNUC__) 
-# define UNUSED(x) UNUSED_ ## x __attribute__((unused)) 
+# define UNUSED(x) x __attribute__((unused))
 #elif defined(__LCLINT__) 
 # define UNUSED(x) /*@unused@*/ x 
 #else 

+ 120 - 47
src/fragroute/Makefile.in

@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.16.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2018 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -92,12 +92,9 @@ host_triplet = @host@
 target_triplet = @target@
 subdir = src/fragroute
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/libopts.m4 \
-	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
-	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
-	$(top_srcdir)/m4/lt~obsolete.m4 \
-	$(top_srcdir)/m4/stdnoreturn.m4 $(top_srcdir)/acinclude.m4 \
-	$(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
+	$(top_srcdir)/libopts/m4/stdnoreturn.m4 \
+	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \
@@ -150,7 +147,30 @@ am__v_at_0 = @
 am__v_at_1 = 
 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
 depcomp = $(SHELL) $(top_srcdir)/config/depcomp
-am__depfiles_maybe = depfiles
+am__maybe_remake_depfiles = depfiles
+am__depfiles_remade = ./$(DEPDIR)/libfragroute_a-argv.Po \
+	./$(DEPDIR)/libfragroute_a-bget.Po \
+	./$(DEPDIR)/libfragroute_a-fragroute.Po \
+	./$(DEPDIR)/libfragroute_a-iputil.Po \
+	./$(DEPDIR)/libfragroute_a-mod.Po \
+	./$(DEPDIR)/libfragroute_a-mod_delay.Po \
+	./$(DEPDIR)/libfragroute_a-mod_drop.Po \
+	./$(DEPDIR)/libfragroute_a-mod_dup.Po \
+	./$(DEPDIR)/libfragroute_a-mod_echo.Po \
+	./$(DEPDIR)/libfragroute_a-mod_ip6_opt.Po \
+	./$(DEPDIR)/libfragroute_a-mod_ip6_qos.Po \
+	./$(DEPDIR)/libfragroute_a-mod_ip_chaff.Po \
+	./$(DEPDIR)/libfragroute_a-mod_ip_frag.Po \
+	./$(DEPDIR)/libfragroute_a-mod_ip_opt.Po \
+	./$(DEPDIR)/libfragroute_a-mod_ip_tos.Po \
+	./$(DEPDIR)/libfragroute_a-mod_ip_ttl.Po \
+	./$(DEPDIR)/libfragroute_a-mod_order.Po \
+	./$(DEPDIR)/libfragroute_a-mod_print.Po \
+	./$(DEPDIR)/libfragroute_a-mod_tcp_chaff.Po \
+	./$(DEPDIR)/libfragroute_a-mod_tcp_opt.Po \
+	./$(DEPDIR)/libfragroute_a-mod_tcp_seg.Po \
+	./$(DEPDIR)/libfragroute_a-pkt.Po \
+	./$(DEPDIR)/libfragroute_a-randutil.Po
 am__mv = mv -f
 AM_V_lt = $(am__v_lt_@AM_V@)
 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@@ -407,8 +427,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	  *config.status*) \
 	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
 	  *) \
-	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
-	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
 	esac;
 
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@@ -434,29 +454,35 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-argv.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-bget.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-fragroute.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-iputil.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_delay.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_drop.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_dup.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_echo.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_ip6_opt.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_ip6_qos.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_ip_chaff.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_ip_frag.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_ip_opt.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_ip_tos.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_ip_ttl.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_order.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_print.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_tcp_chaff.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_tcp_opt.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_tcp_seg.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-pkt.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-randutil.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-argv.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-bget.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-fragroute.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-iputil.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_delay.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_drop.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_dup.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_echo.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_ip6_opt.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_ip6_qos.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_ip_chaff.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_ip_frag.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_ip_opt.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_ip_tos.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_ip_ttl.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_order.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_print.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_tcp_chaff.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_tcp_opt.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-mod_tcp_seg.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-pkt.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfragroute_a-randutil.Po@am__quote@ # am--include-marker
+
+$(am__depfiles_remade):
+	@$(MKDIR_P) $(@D)
+	@echo '# dummy' >$@-t && $(am__mv) $@-t $@
+
+am--depfiles: $(am__depfiles_remade)
 
 .c.o:
 @am__fastdepCC_TRUE@	$(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@@ -862,7 +888,10 @@ cscopelist-am: $(am__tagged_files)
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
-distdir: $(DISTFILES)
+distdir: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	list='$(DISTFILES)'; \
@@ -934,7 +963,29 @@ clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \
 	mostlyclean-am
 
 distclean: distclean-am
-	-rm -rf ./$(DEPDIR)
+		-rm -f ./$(DEPDIR)/libfragroute_a-argv.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-bget.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-fragroute.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-iputil.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_delay.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_drop.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_dup.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_echo.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_ip6_opt.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_ip6_qos.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_ip_chaff.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_ip_frag.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_ip_opt.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_ip_tos.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_ip_ttl.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_order.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_print.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_tcp_chaff.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_tcp_opt.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_tcp_seg.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-pkt.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-randutil.Po
 	-rm -f Makefile
 distclean-am: clean-am distclean-compile distclean-generic \
 	distclean-tags
@@ -980,7 +1031,29 @@ install-ps-am:
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
-	-rm -rf ./$(DEPDIR)
+		-rm -f ./$(DEPDIR)/libfragroute_a-argv.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-bget.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-fragroute.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-iputil.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_delay.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_drop.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_dup.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_echo.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_ip6_opt.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_ip6_qos.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_ip_chaff.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_ip_frag.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_ip_opt.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_ip_tos.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_ip_ttl.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_order.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_print.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_tcp_chaff.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_tcp_opt.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-mod_tcp_seg.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-pkt.Po
+	-rm -f ./$(DEPDIR)/libfragroute_a-randutil.Po
 	-rm -f Makefile
 maintainer-clean-am: distclean-am maintainer-clean-generic
 
@@ -1001,16 +1074,16 @@ uninstall-am:
 
 .MAKE: install-am install-strip
 
-.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
-	clean-libtool clean-noinstLIBRARIES cscopelist-am ctags \
-	ctags-am distclean distclean-compile distclean-generic \
-	distclean-libtool distclean-tags distdir dvi dvi-am html \
-	html-am info info-am install install-am install-data \
-	install-data-am install-dvi install-dvi-am install-exec \
-	install-exec-am install-html install-html-am install-info \
-	install-info-am install-man install-pdf install-pdf-am \
-	install-ps install-ps-am install-strip installcheck \
-	installcheck-am installdirs maintainer-clean \
+.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \
+	clean-generic clean-libtool clean-noinstLIBRARIES \
+	cscopelist-am ctags ctags-am distclean distclean-compile \
+	distclean-generic distclean-libtool distclean-tags distdir dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-data install-data-am install-dvi install-dvi-am \
+	install-exec install-exec-am install-html install-html-am \
+	install-info install-info-am install-man install-pdf \
+	install-pdf-am install-ps install-ps-am install-strip \
+	installcheck installcheck-am installdirs maintainer-clean \
 	maintainer-clean-generic mostlyclean mostlyclean-compile \
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am

+ 63 - 207
src/send_packets.c

@@ -77,155 +77,6 @@ static u_char *get_next_packet(tcpreplay_t *ctx, pcap_t *pcap,
         packet_cache_t **prev_packet);
 static uint32_t get_user_count(tcpreplay_t *ctx, sendpacket_t *sp, COUNTER counter);
 
-/**
- * Fast flow packet edit
- *
- * Attempts to alter the packet IP addresses without
- * changing CRC, which will avoid overhead of tcpreplay-edit
- *
- * This code is a bit bloated but it is the result of
- * optimizing. Test performance on 10GigE+ networks if
- * modifying.
- */
-static void
-fast_edit_packet_dl(struct pcap_pkthdr *pkthdr, u_char **pktdata,
-        COUNTER iteration, bool cached, int datalink)
-{
-    int l2_len = 0;
-    ipv4_hdr_t *ip_hdr;
-    ipv6_hdr_t *ip6_hdr;
-    hdlc_hdr_t *hdlc_hdr;
-    sll_hdr_t *sll_hdr;
-    struct tcpr_pppserial_hdr *ppp;
-    uint32_t src_ip, dst_ip;
-    uint32_t src_ip_orig, dst_ip_orig;
-    uint16_t ether_type = 0;
-
-    if (pkthdr->caplen < (bpf_u_int32)TCPR_IPV6_H) {
-        dbgx(1, "Packet too short for Unique IP feature: %u", pkthdr->caplen);
-        return;
-    }
-
-    switch (datalink) {
-    case DLT_LINUX_SLL:
-        l2_len = 16;
-        sll_hdr = (sll_hdr_t *)*pktdata;
-        ether_type = sll_hdr->sll_protocol;
-        break;
-
-    case DLT_PPP_SERIAL:
-        l2_len = 4;
-        ppp = (struct tcpr_pppserial_hdr *)*pktdata;
-        if (ntohs(ppp->protocol) == 0x0021)
-            ether_type = htons(ETHERTYPE_IP);
-        else
-            ether_type = ppp->protocol;
-        break;
-
-    case DLT_C_HDLC:
-        l2_len = 4;
-        hdlc_hdr = (hdlc_hdr_t *)*pktdata;
-        ether_type = hdlc_hdr->protocol;
-        break;
-
-    case DLT_RAW:
-        if ((*pktdata[0] >> 4) == 4)
-            ether_type = ETHERTYPE_IP;
-        else if ((*pktdata[0] >> 4) == 6)
-            ether_type = ETHERTYPE_IP6;
-        break;
-
-    default:
-        warnx("Unable to process unsupported DLT type: %s (0x%x)",
-             pcap_datalink_val_to_description(datalink), datalink);
-            return;
-    }
-
-    switch (ether_type) {
-    case ETHERTYPE_IP:
-        ip_hdr = (ipv4_hdr_t *)(*pktdata + l2_len);
-
-        if (ip_hdr->ip_v != 4) {
-            dbgx(2, "expected IPv4 but got: %u", ip_hdr->ip_v);
-            return;
-        }
-
-        if (pkthdr->caplen < (bpf_u_int32)sizeof(*ip_hdr)) {
-            dbgx(2, "Packet too short for Unique IP feature: %u", pkthdr->caplen);
-            return;
-        }
-
-        ip_hdr = (ipv4_hdr_t *)(*pktdata + l2_len);
-        src_ip_orig = src_ip = ntohl(ip_hdr->ip_src.s_addr);
-        dst_ip_orig = dst_ip = ntohl(ip_hdr->ip_dst.s_addr);
-        break;
-
-    case ETHERTYPE_IP6:
-
-        if ((*pktdata[0] >> 4) != 6) {
-            dbgx(2, "expected IPv6 but got: %u", *pktdata[0] >> 4);
-            return;
-        }
-
-        if (pkthdr->caplen < (bpf_u_int32)TCPR_IPV6_H) {
-            dbgx(2, "Packet too short for Unique IPv6 feature: %u", pkthdr->caplen);
-            return;
-        }
-
-        ip6_hdr = (ipv6_hdr_t *)(*pktdata + l2_len);
-        src_ip_orig = src_ip = ntohl(ip6_hdr->ip_src.__u6_addr.__u6_addr32[3]);
-        dst_ip_orig = dst_ip = ntohl(ip6_hdr->ip_dst.__u6_addr.__u6_addr32[3]);
-        break;
-
-    default:
-        return; /* non-IP */
-    }
-
-    /* swap src/dst IP's in a manner that does not affect CRC */
-    if ((!cached && dst_ip > src_ip) ||
-            (cached && (dst_ip - iteration) > (src_ip - 1 - iteration))) {
-        if (cached) {
-            --src_ip;
-            ++dst_ip;
-        } else {
-            src_ip -= iteration;
-            dst_ip += iteration;
-        }
-
-        /* CRC compensations  for wrap conditions */
-        if (src_ip > src_ip_orig && dst_ip > dst_ip_orig) {
-            dbgx(1, "dst_ip > src_ip(" COUNTER_SPEC "): before(1) src_ip=0x%08x dst_ip=0x%08x", iteration, src_ip, dst_ip);
-            --src_ip;
-            dbgx(1, "dst_ip > src_ip(" COUNTER_SPEC "): after(1)  src_ip=0x%08x dst_ip=0x%08x", iteration, src_ip, dst_ip);
-        } else if (dst_ip < dst_ip_orig && src_ip < src_ip_orig) {
-            dbgx(1, "dst_ip > src_ip(" COUNTER_SPEC "): before(2) src_ip=0x%08x dst_ip=0x%08x", iteration, src_ip, dst_ip);
-            ++dst_ip;
-            dbgx(1, "dst_ip > src_ip(" COUNTER_SPEC "): after(2)  src_ip=0x%08x dst_ip=0x%08x", iteration, src_ip, dst_ip);
-        }
-    } else {
-        if (cached) {
-            ++src_ip;
-            --dst_ip;
-        } else {
-            src_ip += iteration;
-            dst_ip -= iteration;
-        }
-
-        /* CRC compensations  for wrap conditions */
-        if (dst_ip > dst_ip_orig && src_ip > src_ip_orig) {
-            dbgx(1, "src_ip > dst_ip(" COUNTER_SPEC "): before(1) dst_ip=0x%08x src_ip=0x%08x", iteration, dst_ip, src_ip);
-            --dst_ip;
-            dbgx(1, "src_ip > dst_ip(" COUNTER_SPEC "): after(1)  dst_ip=0x%08x src_ip=0x%08x", iteration, dst_ip, src_ip);
-        } else if (src_ip < src_ip_orig && dst_ip < dst_ip_orig) {
-            dbgx(1, "src_ip > dst_ip(" COUNTER_SPEC "): before(2) dst_ip=0x%08x src_ip=0x%08x", iteration, dst_ip, src_ip);
-            ++src_ip;
-            dbgx(1, "src_ip > dst_ip(" COUNTER_SPEC "): after(2)  dst_ip=0x%08x src_ip=0x%08x", iteration, dst_ip, src_ip);
-        }
-    }
-
-    dbgx(1, "(" COUNTER_SPEC "): final src_ip=0x%08x dst_ip=0x%08x", iteration, src_ip, dst_ip);
-}
-
 static inline void wake_send_queues(sendpacket_t *sp _U_,
 		tcpreplay_opt_t *options _U_)
 {
@@ -235,7 +86,7 @@ static inline void wake_send_queues(sendpacket_t *sp _U_,
 #endif
 }
 
-static inline void
+static inline int
 fast_edit_packet(struct pcap_pkthdr *pkthdr, u_char **pktdata,
         COUNTER iteration, bool cached, int datalink)
 {
@@ -247,55 +98,34 @@ fast_edit_packet(struct pcap_pkthdr *pkthdr, u_char **pktdata,
     int l2_len;
     u_char *packet = *pktdata;
 
-    if (datalink != DLT_EN10MB && datalink != DLT_JUNIPER_ETHER)
-        fast_edit_packet_dl(pkthdr, pktdata, iteration, cached, datalink);
-
-    if (pkthdr->caplen < (bpf_u_int32)TCPR_IPV6_H) {
-        dbgx(2, "Packet too short for Unique IP feature: %u", pkthdr->caplen);
-        return;
-    }
-
-    l2_len = 0;
-    if (datalink == DLT_JUNIPER_ETHER) {
-        if (memcmp(packet, "MGC", 3))
-            warnx("No Magic Number found: %s (0x%x)",
-                 pcap_datalink_val_to_description(datalink), datalink);
-
-        if ((packet[3] & 0x80) == 0x80) {
-            l2_len = ntohs(*((uint16_t*)&packet[4]));
-            if (l2_len > 1024) {
-                warnx("L2 length too long: %u", l2_len);
-                return;
-            }
-            l2_len += 6;
-        } else
-            l2_len = 4; /* no header extensions */
-    }
-
-    /* assume Ethernet, IPv4 for now */
-    ether_type = ntohs(((eth_hdr_t*)(packet + l2_len))->ether_type);
-    l2_len += sizeof(eth_hdr_t);
-    while (ether_type == ETHERTYPE_VLAN) {
-         vlan_hdr_t *vlan_hdr = (vlan_hdr_t*)(pktdata + l2_len);
-         ether_type = ntohs(vlan_hdr->vlan_tpid);
-         l2_len += 4;
-    }
+    l2_len = get_l2len(packet, pkthdr->caplen, datalink);
+    if (l2_len < 0)
+        return -1;
 
+    ether_type = get_l2protocol(packet, pkthdr->caplen, datalink);
     switch (ether_type) {
     case ETHERTYPE_IP:
+        if (pkthdr->caplen < (bpf_u_int32)(l2_len + sizeof(ipv4_hdr_t))) {
+            dbgx(1, "IP packet too short for Unique IP feature: %u", pkthdr->caplen);
+            return -1;
+        }
         ip_hdr = (ipv4_hdr_t *)(packet + l2_len);
         src_ip_orig = src_ip = ntohl(ip_hdr->ip_src.s_addr);
         dst_ip_orig = dst_ip = ntohl(ip_hdr->ip_dst.s_addr);
         break;
 
     case ETHERTYPE_IP6:
+        if (pkthdr->caplen < (bpf_u_int32)(l2_len + sizeof(ipv6_hdr_t))) {
+            dbgx(1, "IP6 packet too short for Unique IP feature: %u", pkthdr->caplen);
+            return -1;
+        }
         ip6_hdr = (ipv6_hdr_t *)(packet + l2_len);
         src_ip_orig = src_ip = ntohl(ip6_hdr->ip_src.__u6_addr.__u6_addr32[3]);
         dst_ip_orig = dst_ip = ntohl(ip6_hdr->ip_dst.__u6_addr.__u6_addr32[3]);
         break;
 
     default:
-        return; /* non-IP */
+        return -1; /* non-IP or packet too short */
     }
 
     dbgx(2, "Layer 3 protocol type is: 0x%04x", ether_type);
@@ -355,6 +185,8 @@ fast_edit_packet(struct pcap_pkthdr *pkthdr, u_char **pktdata,
         ip6_hdr->ip_dst.__u6_addr.__u6_addr32[3] = htonl(dst_ip);
         break;
     }
+
+    return 0;
 }
 
 /**
@@ -507,6 +339,7 @@ send_packets(tcpreplay_t *ctx, pcap_t *pcap, int idx)
 
     ctx->skip_packets = 0;
     timerclear(&last_pkt_ts);
+    timerclear(&stats->first_packet_sent_wall_time);
     if (options->limit_time > 0)
         end_us = TIMEVAL_TO_MICROSEC(&stats->start_time) +
             SEC_TO_MICROSEC(options->limit_time);
@@ -559,8 +392,11 @@ send_packets(tcpreplay_t *ctx, pcap_t *pcap, int idx)
         if (ctx->options->unique_ip && ctx->unique_iteration &&
                 ctx->unique_iteration > ctx->last_unique_iteration) {
             /* edit packet to ensure every pass has unique IP addresses */
-            fast_edit_packet(&pkthdr, &pktdata, ctx->unique_iteration - 1,
-                    preload, datalink);
+            if (fast_edit_packet(&pkthdr, &pktdata, ctx->unique_iteration - 1,
+                    preload, datalink) == -1) {
+                ++stats->failed;
+                continue;
+            }
         }
 
         /* update flow stats */
@@ -588,18 +424,23 @@ send_packets(tcpreplay_t *ctx, pcap_t *pcap, int idx)
             ctx->skip_packets = 0;
 
             if (options->speed.mode == speed_multiplier) {
+                if(!timerisset(&stats->first_packet_sent_wall_time)) {
+                    /* We're sending the first packet, so we have an absolute time reference. */
+                    TIMEVAL_SET(&stats->first_packet_sent_wall_time, &now);
+                    TIMEVAL_SET(&stats->first_packet_pcap_timestamp, &pkthdr.ts);
+                }
+
                 if (!timerisset(&last_pkt_ts)) {
                     TIMEVAL_SET(&last_pkt_ts, &pkthdr.ts);
                 } else if (timercmp(&pkthdr.ts, &last_pkt_ts, >)) {
-                    struct timeval delta;
+                    /* pkt_ts_delta is the packet time stamp difference since the first packet */
+                    timersub(&pkthdr.ts, &stats->first_packet_pcap_timestamp, &stats->pkt_ts_delta);
+
+                    /* time_delta is the wall time difference since sending the first packet */
+                    timersub(&now, &stats->first_packet_sent_wall_time, &stats->time_delta);
 
-                    timersub(&pkthdr.ts, &last_pkt_ts, &delta);
-                    timeradd(&stats->pkt_ts_delta, &delta, &stats->pkt_ts_delta);
                     TIMEVAL_SET(&last_pkt_ts, &pkthdr.ts);
                 }
-
-                if (!timerisset(&stats->time_delta))
-                    TIMEVAL_SET(&stats->pkt_ts_delta, &stats->pkt_ts_delta);
             }
 
             if (!top_speed) {
@@ -749,6 +590,7 @@ send_dual_packets(tcpreplay_t *ctx, pcap_t *pcap1, int cache_file_idx1, pcap_t *
 
     ctx->skip_packets = 0;
     timerclear(&last_pkt_ts);
+    timerclear(&stats->first_packet_sent_wall_time);
     if (options->limit_time > 0)
         end_us = TIMEVAL_TO_MICROSEC(&stats->start_time) +
             SEC_TO_MICROSEC(options->limit_time);
@@ -833,8 +675,11 @@ send_dual_packets(tcpreplay_t *ctx, pcap_t *pcap1, int cache_file_idx1, pcap_t *
         if (ctx->options->unique_ip && ctx->unique_iteration &&
                 ctx->unique_iteration > ctx->last_unique_iteration) {
             /* edit packet to ensure every pass is unique */
-            fast_edit_packet(pkthdr_ptr, &pktdata, ctx->unique_iteration - 1,
-                    options->file_cache[cache_file_idx].cached, datalink);
+            if (fast_edit_packet(pkthdr_ptr, &pktdata, ctx->unique_iteration - 1,
+                    options->file_cache[cache_file_idx].cached, datalink) == -1) {
+                ++stats->failed;
+                continue;
+            }
         }
 
         /* update flow stats */
@@ -861,18 +706,23 @@ send_dual_packets(tcpreplay_t *ctx, pcap_t *pcap1, int cache_file_idx1, pcap_t *
             ctx->skip_packets = 0;
 
             if (options->speed.mode == speed_multiplier) {
+                if(!timerisset(&stats->first_packet_sent_wall_time)) {
+                    /* We're sending the first packet, so we have an absolute time reference. */
+                    TIMEVAL_SET(&stats->first_packet_sent_wall_time, &now);
+                    TIMEVAL_SET(&stats->first_packet_pcap_timestamp, &pkthdr_ptr->ts);
+                }
+
                 if (!timerisset(&last_pkt_ts)) {
                     TIMEVAL_SET(&last_pkt_ts, &pkthdr_ptr->ts);
                 } else if (timercmp(&pkthdr_ptr->ts, &last_pkt_ts, >)) {
-                    struct timeval delta;
+                    /* pkt_ts_delta is the packet time stamp difference since the first packet */
+                    timersub(&pkthdr_ptr->ts, &stats->first_packet_pcap_timestamp, &stats->pkt_ts_delta);
+
+                    /* time_delta is the wall time difference since sending the first packet */
+                    timersub(&now, &stats->first_packet_sent_wall_time, &stats->time_delta);
 
-                    timersub(&pkthdr_ptr->ts, &last_pkt_ts, &delta);
-                    timeradd(&stats->pkt_ts_delta, &delta, &stats->pkt_ts_delta);
                     TIMEVAL_SET(&last_pkt_ts, &pkthdr_ptr->ts);
                 }
-
-                if (!timerisset(&stats->time_delta))
-                    TIMEVAL_SET(&stats->pkt_ts_delta, &stats->pkt_ts_delta);
             }
 
             if (!top_speed) {
@@ -894,7 +744,7 @@ send_dual_packets(tcpreplay_t *ctx, pcap_t *pcap1, int cache_file_idx1, pcap_t *
              * Track the time of the "last packet sent".
              *
              * A number of 3rd party tools generate bad timestamps which go backwards
-             * in time.  Hence, don't update the "last" unless pkthdr.ts > last
+             * in time.  Hence, don't update the "last" unless pkthdr_ptr->ts > last
              */
             if (timercmp(&stats->time_delta, &stats->pkt_ts_delta, <))
                 TIMEVAL_SET(&stats->time_delta, &stats->pkt_ts_delta);
@@ -924,7 +774,7 @@ send_dual_packets(tcpreplay_t *ctx, pcap_t *pcap1, int cache_file_idx1, pcap_t *
          */
         TIMEVAL_SET(&stats->end_time, &now);
 
-        stats->pkts_sent++;
+        ++stats->pkts_sent;
         stats->bytes_sent += pktlen;
 
         /* print stats during the run? */
@@ -1054,7 +904,7 @@ get_next_packet(tcpreplay_t *ctx, pcap_t *pcap, struct pcap_pkthdr *pkthdr, int
 
                 if (*prev_packet != NULL) {
                     (*prev_packet)->next = NULL;
-                    pktlen = pkthdr->len;
+                    pktlen = pkthdr->caplen;
 
                     (*prev_packet)->pktdata = safe_malloc(pktlen + PACKET_HEADROOM);
                     memcpy((*prev_packet)->pktdata, pktdata, pktlen);
@@ -1205,15 +1055,21 @@ static void calc_sleep_time(tcpreplay_t *ctx, struct timeval *pkt_ts_delta,
           */
          now_us = TIMSTAMP_TO_MICROSEC(sent_timestamp);
          if (now_us) {
-             COUNTER pph = ctx->options->speed.speed *
-                     (ctx->options->speed.pps_multi > 0 ? ctx->options->speed.pps_multi : (60 * 60));
+             COUNTER next_tx_us;
+             COUNTER pph = ctx->options->speed.speed;
              COUNTER pkts_sent = ctx->stats.pkts_sent;
+             COUNTER tx_us = now_us - start_us;
              /*
               * packets * 1000000 divided by pps = microseconds
               * packets per sec (pps) = packets per hour / (60 * 60)
+              *
+              * Adjust for long running tests with high PPS to prevent overflow.
+              * When active, adjusted calculation may add a bit of jitter.
               */
-             COUNTER next_tx_us = (pkts_sent * 1000000) * (60 * 60) / pph;
-             COUNTER tx_us = now_us - start_us;
+             if ((pkts_sent < COUNTER_OVERFLOW_RISK))
+                 next_tx_us = (pkts_sent * 1000000) * (60 * 60) / pph;
+             else
+                 next_tx_us = (pkts_sent * 1000000) / pph / (60 * 60);
 
              if (next_tx_us > tx_us)
                  NANOSEC_TO_TIMESPEC((next_tx_us - tx_us) * 1000, &ctx->nap);

+ 2 - 2
src/tcpbridge.1

@@ -10,7 +10,7 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH tcpbridge 1 "14 Jun 2020" "tcpbridge" "User Commands"
+.TH tcpbridge 1 "01 May 2021" "tcpbridge" "User Commands"
 .\"
 .\" DO NOT EDIT THIS FILE (in-mem file)
 .\"
@@ -358,7 +358,7 @@ Ethernet aka DLT_EN10MB
 \fBhdlc\fP
 Cisco HDLC aka DLT_C_HDLC
 .sp 1
-\fBjnpr_ether\fP
+\fBjnpr_eth\fP
 Juniper Ethernet DLT_C_JNPR_ETHER
 .sp 1
 \fBpppserial\fP

+ 6 - 2
src/tcpbridge.c

@@ -79,12 +79,14 @@ main(int argc, char *argv[])
     /* parse the tcpedit args */
     rcode = tcpedit_post_args(tcpedit);
     if (rcode < 0) {
+        tcpedit_close(&tcpedit);
         errx(-1, "Unable to parse args: %s", tcpedit_geterr(tcpedit));
     } else if (rcode == 1) {
         warnx("%s", tcpedit_geterr(tcpedit));
     }
 
     if (tcpedit_validate(tcpedit) < 0) {
+        tcpedit_close(&tcpedit);
         errx(-1, "Unable to edit packets given options:\n%s",
                 tcpedit_geterr(tcpedit));
     }
@@ -96,9 +98,10 @@ main(int argc, char *argv[])
     }
 #endif
 
-    if (gettimeofday(&stats.start_time, NULL) < 0)
+    if (gettimeofday(&stats.start_time, NULL) < 0) {
+        tcpedit_close(&tcpedit);
         err(-1, "gettimeofday() failed");
-
+    }
 
     /* process packets */
     do_bridge(&options, tcpedit);
@@ -110,6 +113,7 @@ main(int argc, char *argv[])
         pcap_close(options.pcap2);
     }
 
+    tcpedit_close(&tcpedit);
 #ifdef ENABLE_VERBOSE
     tcpdump_close(options.tcpdump);
 #endif

+ 1 - 1
src/tcpcapinfo.1

@@ -10,7 +10,7 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH tcpcapinfo 1 "14 Jun 2020" "Tcpreplay Suite" "User Commands"
+.TH tcpcapinfo 1 "01 May 2021" "Tcpreplay Suite" "User Commands"
 .\"
 .\" DO NOT EDIT THIS FILE (in-mem file)
 .\"

+ 134 - 52
src/tcpedit/Makefile.in

@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.16.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2018 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -185,12 +185,9 @@ host_triplet = @host@
 target_triplet = @target@
 subdir = src/tcpedit
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/libopts.m4 \
-	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
-	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
-	$(top_srcdir)/m4/lt~obsolete.m4 \
-	$(top_srcdir)/m4/stdnoreturn.m4 $(top_srcdir)/acinclude.m4 \
-	$(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
+	$(top_srcdir)/libopts/m4/stdnoreturn.m4 \
+	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \
@@ -243,7 +240,29 @@ am__v_at_0 = @
 am__v_at_1 = 
 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
 depcomp = $(SHELL) $(top_srcdir)/config/depcomp
-am__depfiles_maybe = depfiles
+am__maybe_remake_depfiles = depfiles
+am__depfiles_remade = ./$(DEPDIR)/checksum.Po ./$(DEPDIR)/dlt.Po \
+	./$(DEPDIR)/edit_packet.Po ./$(DEPDIR)/fuzzing.Po \
+	./$(DEPDIR)/incremental_checksum.Po ./$(DEPDIR)/parse_args.Po \
+	./$(DEPDIR)/portmap.Po ./$(DEPDIR)/rewrite_sequence.Po \
+	./$(DEPDIR)/tcpedit.Po ./$(DEPDIR)/tcpedit_api.Po \
+	plugins/$(DEPDIR)/dlt_plugins.Po \
+	plugins/$(DEPDIR)/dlt_utils.Po plugins/$(DEPDIR)/ethernet.Po \
+	plugins/dlt_en10mb/$(DEPDIR)/en10mb.Po \
+	plugins/dlt_en10mb/$(DEPDIR)/en10mb_api.Po \
+	plugins/dlt_hdlc/$(DEPDIR)/hdlc.Po \
+	plugins/dlt_hdlc/$(DEPDIR)/hdlc_api.Po \
+	plugins/dlt_ieee80211/$(DEPDIR)/ieee80211.Po \
+	plugins/dlt_ieee80211/$(DEPDIR)/ieee80211_hdr.Po \
+	plugins/dlt_jnpr_ether/$(DEPDIR)/jnpr_ether.Po \
+	plugins/dlt_linuxsll/$(DEPDIR)/linuxsll.Po \
+	plugins/dlt_loop/$(DEPDIR)/loop.Po \
+	plugins/dlt_null/$(DEPDIR)/null.Po \
+	plugins/dlt_pppserial/$(DEPDIR)/pppserial.Po \
+	plugins/dlt_radiotap/$(DEPDIR)/radiotap.Po \
+	plugins/dlt_raw/$(DEPDIR)/raw.Po \
+	plugins/dlt_user/$(DEPDIR)/user.Po \
+	plugins/dlt_user/$(DEPDIR)/user_api.Po
 am__mv = mv -f
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -595,8 +614,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	  *config.status*) \
 	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
 	  *) \
-	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
-	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
 	esac;
 $(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 $(srcdir)/plugins/dlt_jnpr_ether/Makefile.am $(srcdir)/plugins/dlt_pppserial/Makefile.am $(am__empty):
 
@@ -751,34 +770,40 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checksum.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dlt.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edit_packet.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fuzzing.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/incremental_checksum.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)/rewrite_sequence.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpedit.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpedit_api.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/dlt_plugins.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/dlt_utils.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/ethernet.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_en10mb/$(DEPDIR)/en10mb.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_en10mb/$(DEPDIR)/en10mb_api.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_hdlc/$(DEPDIR)/hdlc.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_hdlc/$(DEPDIR)/hdlc_api.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_ieee80211/$(DEPDIR)/ieee80211.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_ieee80211/$(DEPDIR)/ieee80211_hdr.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_jnpr_ether/$(DEPDIR)/jnpr_ether.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_linuxsll/$(DEPDIR)/linuxsll.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_loop/$(DEPDIR)/loop.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_null/$(DEPDIR)/null.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_pppserial/$(DEPDIR)/pppserial.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_radiotap/$(DEPDIR)/radiotap.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_raw/$(DEPDIR)/raw.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_user/$(DEPDIR)/user.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_user/$(DEPDIR)/user_api.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checksum.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dlt.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edit_packet.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fuzzing.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/incremental_checksum.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse_args.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/portmap.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rewrite_sequence.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpedit.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpedit_api.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/dlt_plugins.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/dlt_utils.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@plugins/$(DEPDIR)/ethernet.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_en10mb/$(DEPDIR)/en10mb.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_en10mb/$(DEPDIR)/en10mb_api.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_hdlc/$(DEPDIR)/hdlc.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_hdlc/$(DEPDIR)/hdlc_api.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_ieee80211/$(DEPDIR)/ieee80211.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_ieee80211/$(DEPDIR)/ieee80211_hdr.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_jnpr_ether/$(DEPDIR)/jnpr_ether.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_linuxsll/$(DEPDIR)/linuxsll.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_loop/$(DEPDIR)/loop.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_null/$(DEPDIR)/null.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_pppserial/$(DEPDIR)/pppserial.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_radiotap/$(DEPDIR)/radiotap.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_raw/$(DEPDIR)/raw.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_user/$(DEPDIR)/user.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@plugins/dlt_user/$(DEPDIR)/user_api.Po@am__quote@ # am--include-marker
+
+$(am__depfiles_remade):
+	@$(MKDIR_P) $(@D)
+	@echo '# dummy' >$@-t && $(am__mv) $@-t $@
+
+am--depfiles: $(am__depfiles_remade)
 
 .c.o:
 @am__fastdepCC_TRUE@	$(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@@ -862,7 +887,10 @@ cscopelist-am: $(am__tagged_files)
 distclean-tags:
 	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
-distdir: $(DISTFILES)
+distdir: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	list='$(DISTFILES)'; \
@@ -961,7 +989,34 @@ clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \
 	mostlyclean-am
 
 distclean: distclean-am
-	-rm -rf ./$(DEPDIR) plugins/$(DEPDIR) plugins/dlt_en10mb/$(DEPDIR) plugins/dlt_hdlc/$(DEPDIR) plugins/dlt_ieee80211/$(DEPDIR) plugins/dlt_jnpr_ether/$(DEPDIR) plugins/dlt_linuxsll/$(DEPDIR) plugins/dlt_loop/$(DEPDIR) plugins/dlt_null/$(DEPDIR) plugins/dlt_pppserial/$(DEPDIR) plugins/dlt_radiotap/$(DEPDIR) plugins/dlt_raw/$(DEPDIR) plugins/dlt_user/$(DEPDIR)
+		-rm -f ./$(DEPDIR)/checksum.Po
+	-rm -f ./$(DEPDIR)/dlt.Po
+	-rm -f ./$(DEPDIR)/edit_packet.Po
+	-rm -f ./$(DEPDIR)/fuzzing.Po
+	-rm -f ./$(DEPDIR)/incremental_checksum.Po
+	-rm -f ./$(DEPDIR)/parse_args.Po
+	-rm -f ./$(DEPDIR)/portmap.Po
+	-rm -f ./$(DEPDIR)/rewrite_sequence.Po
+	-rm -f ./$(DEPDIR)/tcpedit.Po
+	-rm -f ./$(DEPDIR)/tcpedit_api.Po
+	-rm -f plugins/$(DEPDIR)/dlt_plugins.Po
+	-rm -f plugins/$(DEPDIR)/dlt_utils.Po
+	-rm -f plugins/$(DEPDIR)/ethernet.Po
+	-rm -f plugins/dlt_en10mb/$(DEPDIR)/en10mb.Po
+	-rm -f plugins/dlt_en10mb/$(DEPDIR)/en10mb_api.Po
+	-rm -f plugins/dlt_hdlc/$(DEPDIR)/hdlc.Po
+	-rm -f plugins/dlt_hdlc/$(DEPDIR)/hdlc_api.Po
+	-rm -f plugins/dlt_ieee80211/$(DEPDIR)/ieee80211.Po
+	-rm -f plugins/dlt_ieee80211/$(DEPDIR)/ieee80211_hdr.Po
+	-rm -f plugins/dlt_jnpr_ether/$(DEPDIR)/jnpr_ether.Po
+	-rm -f plugins/dlt_linuxsll/$(DEPDIR)/linuxsll.Po
+	-rm -f plugins/dlt_loop/$(DEPDIR)/loop.Po
+	-rm -f plugins/dlt_null/$(DEPDIR)/null.Po
+	-rm -f plugins/dlt_pppserial/$(DEPDIR)/pppserial.Po
+	-rm -f plugins/dlt_radiotap/$(DEPDIR)/radiotap.Po
+	-rm -f plugins/dlt_raw/$(DEPDIR)/raw.Po
+	-rm -f plugins/dlt_user/$(DEPDIR)/user.Po
+	-rm -f plugins/dlt_user/$(DEPDIR)/user_api.Po
 	-rm -f Makefile
 distclean-am: clean-am distclean-compile distclean-generic \
 	distclean-tags
@@ -1007,7 +1062,34 @@ install-ps-am:
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
-	-rm -rf ./$(DEPDIR) plugins/$(DEPDIR) plugins/dlt_en10mb/$(DEPDIR) plugins/dlt_hdlc/$(DEPDIR) plugins/dlt_ieee80211/$(DEPDIR) plugins/dlt_jnpr_ether/$(DEPDIR) plugins/dlt_linuxsll/$(DEPDIR) plugins/dlt_loop/$(DEPDIR) plugins/dlt_null/$(DEPDIR) plugins/dlt_pppserial/$(DEPDIR) plugins/dlt_radiotap/$(DEPDIR) plugins/dlt_raw/$(DEPDIR) plugins/dlt_user/$(DEPDIR)
+		-rm -f ./$(DEPDIR)/checksum.Po
+	-rm -f ./$(DEPDIR)/dlt.Po
+	-rm -f ./$(DEPDIR)/edit_packet.Po
+	-rm -f ./$(DEPDIR)/fuzzing.Po
+	-rm -f ./$(DEPDIR)/incremental_checksum.Po
+	-rm -f ./$(DEPDIR)/parse_args.Po
+	-rm -f ./$(DEPDIR)/portmap.Po
+	-rm -f ./$(DEPDIR)/rewrite_sequence.Po
+	-rm -f ./$(DEPDIR)/tcpedit.Po
+	-rm -f ./$(DEPDIR)/tcpedit_api.Po
+	-rm -f plugins/$(DEPDIR)/dlt_plugins.Po
+	-rm -f plugins/$(DEPDIR)/dlt_utils.Po
+	-rm -f plugins/$(DEPDIR)/ethernet.Po
+	-rm -f plugins/dlt_en10mb/$(DEPDIR)/en10mb.Po
+	-rm -f plugins/dlt_en10mb/$(DEPDIR)/en10mb_api.Po
+	-rm -f plugins/dlt_hdlc/$(DEPDIR)/hdlc.Po
+	-rm -f plugins/dlt_hdlc/$(DEPDIR)/hdlc_api.Po
+	-rm -f plugins/dlt_ieee80211/$(DEPDIR)/ieee80211.Po
+	-rm -f plugins/dlt_ieee80211/$(DEPDIR)/ieee80211_hdr.Po
+	-rm -f plugins/dlt_jnpr_ether/$(DEPDIR)/jnpr_ether.Po
+	-rm -f plugins/dlt_linuxsll/$(DEPDIR)/linuxsll.Po
+	-rm -f plugins/dlt_loop/$(DEPDIR)/loop.Po
+	-rm -f plugins/dlt_null/$(DEPDIR)/null.Po
+	-rm -f plugins/dlt_pppserial/$(DEPDIR)/pppserial.Po
+	-rm -f plugins/dlt_radiotap/$(DEPDIR)/radiotap.Po
+	-rm -f plugins/dlt_raw/$(DEPDIR)/raw.Po
+	-rm -f plugins/dlt_user/$(DEPDIR)/user.Po
+	-rm -f plugins/dlt_user/$(DEPDIR)/user_api.Po
 	-rm -f Makefile
 maintainer-clean-am: distclean-am maintainer-clean-generic
 
@@ -1028,16 +1110,16 @@ uninstall-am:
 
 .MAKE: all check install install-am install-strip
 
-.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
-	clean-libtool clean-noinstLIBRARIES cscopelist-am ctags \
-	ctags-am distclean distclean-compile distclean-generic \
-	distclean-libtool distclean-tags distdir dvi dvi-am html \
-	html-am info info-am install install-am install-data \
-	install-data-am install-dvi install-dvi-am install-exec \
-	install-exec-am install-html install-html-am install-info \
-	install-info-am install-man install-pdf install-pdf-am \
-	install-ps install-ps-am install-strip installcheck \
-	installcheck-am installdirs maintainer-clean \
+.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \
+	clean-generic clean-libtool clean-noinstLIBRARIES \
+	cscopelist-am ctags ctags-am distclean distclean-compile \
+	distclean-generic distclean-libtool distclean-tags distdir dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-data install-data-am install-dvi install-dvi-am \
+	install-exec install-exec-am install-html install-html-am \
+	install-info install-info-am install-man install-pdf \
+	install-pdf-am install-ps install-ps-am install-strip \
+	installcheck installcheck-am installdirs maintainer-clean \
 	maintainer-clean-generic mostlyclean mostlyclean-compile \
 	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
 	tags tags-am uninstall uninstall-am

+ 8 - 4
src/tcpedit/dlt.c

@@ -160,10 +160,14 @@ dlt2mtu(tcpedit_t *tcpedit, int dlt)
  * for it to be at all useful.
  */
 int
-layer2len(tcpedit_t *tcpedit)
+layer2len(tcpedit_t *tcpedit, u_char *packet, uint32_t caplen)
 {
-   assert(tcpedit);
-   
-   return tcpedit->dlt_ctx->l2len;
+    assert(tcpedit);
+    assert(tcpedit->dlt_ctx);
+    assert(tcpedit->dlt_ctx->encoder);
+
+    return tcpedit->dlt_ctx->encoder->plugin_l2len(tcpedit->dlt_ctx,
+                                                   packet,
+                                                   caplen);
 }
 

+ 1 - 1
src/tcpedit/dlt.h

@@ -32,7 +32,7 @@
 int dlt2layer2len(tcpedit_t *tcpedit, int dlt);
 int dltrequires(tcpedit_t *tcpedit, int dlt);
 int dlt2mtu(tcpedit_t *tcpedit, int dlt);
-int layer2len(tcpedit_t *tcpedit);
+int layer2len(tcpedit_t *tcpedit, u_char *packet, uint32_t caplen);
 
 #endif /* _DLT_H_ */
 

+ 1 - 1
src/tcpedit/edit_packet.c

@@ -508,7 +508,7 @@ untrunc_packet(tcpedit_t *tcpedit, struct pcap_pkthdr *pkthdr,
             return(0);
     }
     
-    if ((l2len = layer2len(tcpedit)) < 0) {
+    if ((l2len = layer2len(tcpedit, packet, pkthdr->caplen)) < 0) {
         tcpedit_seterr(tcpedit, "Non-sensical layer 2 length: %d", l2len);
         return -1;
     }

+ 28 - 16
src/tcpedit/plugins/dlt_en10mb/en10mb.c

@@ -30,7 +30,7 @@
 #include "en10mb.h"
 
 
-static char _U_ dlt_name[] = "en10mb";
+static char dlt_name[] = "en10mb";
 static char dlt_prefix[] = "enet";
 static uint16_t dlt_value = DLT_EN10MB;
 
@@ -104,8 +104,17 @@ dlt_en10mb_init(tcpeditdlt_t *ctx)
         return TCPEDIT_ERROR;
     }
     
-    ctx->decoded_extra_size = sizeof(en10mb_extra_t);
-    ctx->decoded_extra = safe_malloc(ctx->decoded_extra_size);
+    if (ctx->decoded_extra_size > 0) {
+        if (ctx->decoded_extra_size < sizeof(en10mb_extra_t)) {
+            ctx->decoded_extra_size = sizeof(en10mb_extra_t);
+            ctx->decoded_extra = safe_realloc(ctx->decoded_extra,
+                                              ctx->decoded_extra_size);
+        }
+    } else {
+        ctx->decoded_extra_size = sizeof(en10mb_extra_t);
+        ctx->decoded_extra = safe_malloc(ctx->decoded_extra_size);
+    }
+
     plugin->config_size = sizeof(en10mb_config_t);
     plugin->config = safe_malloc(plugin->config_size);
     config = (en10mb_config_t *)plugin->config;
@@ -128,24 +137,25 @@ int
 dlt_en10mb_cleanup(tcpeditdlt_t *ctx)
 {
     tcpeditdlt_plugin_t *plugin;
-    
+
     assert(ctx);
-    
-    if ((plugin = tcpedit_dlt_getplugin(ctx, dlt_value)) == NULL)
-        return TCPEDIT_OK;
 
-    if (ctx->decoded_extra != NULL) {
-        safe_free(ctx->decoded_extra);
-        ctx->decoded_extra = NULL;
-        ctx->decoded_extra_size = 0;
+    if ((plugin = tcpedit_dlt_getplugin(ctx, dlt_value)) == NULL) {
+        tcpedit_seterr(ctx->tcpedit, "Unable to cleanup unregistered plugin %s",
+                       dlt_name);
+        return TCPEDIT_ERROR;
     }
 
+    safe_free(plugin->name);
+    plugin->name = NULL;
     if (plugin->config != NULL) {
+        en10mb_config_t *config = (en10mb_config_t*)plugin->config;
+        safe_free(config->subs.entries);
         safe_free(plugin->config);
         plugin->config = NULL;
         plugin->config_size = 0;
     }
-        
+
     return TCPEDIT_OK; /* success */
 }
 
@@ -164,14 +174,16 @@ en10mb_sub_entry_t *
 dlt_en10mb_realloc_merge(en10mb_sub_conf_t config, en10mb_sub_entry_t *new_entries, int entries_count)
 {
     int i;
-    en10mb_sub_entry_t *merged = safe_realloc(
-        config.entries, (config.count + entries_count) * sizeof(en10mb_sub_entry_t));
+
+    config.entries = safe_realloc(config.entries,
+                                  (config.count + entries_count)
+                                  * sizeof(en10mb_sub_entry_t));
 
     for (i = 0; i < entries_count; i++) {
-        merged[config.count + i] = new_entries[i];
+        config.entries[config.count + i] = new_entries[i];
     }
 
-    return merged;
+    return config.entries;
 }
 
 int

+ 15 - 13
src/tcpedit/plugins/dlt_hdlc/hdlc.c

@@ -102,8 +102,16 @@ dlt_hdlc_init(tcpeditdlt_t *ctx)
     }
     
     /* allocate memory for our deocde extra data */
-    ctx->decoded_extra_size = sizeof(hdlc_extra_t);
-    ctx->decoded_extra = safe_malloc(ctx->decoded_extra_size);
+    if (ctx->decoded_extra_size > 0) {
+        if (ctx->decoded_extra_size < sizeof(hdlc_extra_t)) {
+            ctx->decoded_extra_size = sizeof(hdlc_extra_t);
+            ctx->decoded_extra = safe_realloc(ctx->decoded_extra,
+                                              ctx->decoded_extra_size);
+        }
+    } else {
+        ctx->decoded_extra_size = sizeof(hdlc_extra_t);
+        ctx->decoded_extra = safe_malloc(ctx->decoded_extra_size);
+    }
 
     /* allocate memory for our config data */
     plugin->config_size = sizeof(hdlc_config_t);
@@ -132,17 +140,11 @@ dlt_hdlc_cleanup(tcpeditdlt_t *ctx)
         return TCPEDIT_ERROR;
     }
 
-    if (ctx->decoded_extra != NULL) {
-        safe_free(ctx->decoded_extra);
-        ctx->decoded_extra = NULL;
-        ctx->decoded_extra_size = 0;
-    }
-        
-    if (plugin->config != NULL) {
-        safe_free(plugin->config);
-        plugin->config = NULL;
-        plugin->config_size = 0;
-    }
+    safe_free(plugin->name);
+    plugin->name = NULL;
+    safe_free(plugin->config);
+    plugin->config = NULL;
+    plugin->config_size = 0;
 
     return TCPEDIT_OK; /* success */
 }

+ 15 - 13
src/tcpedit/plugins/dlt_ieee80211/ieee80211.c

@@ -109,8 +109,16 @@ dlt_ieee80211_init(tcpeditdlt_t *ctx)
     }
     
     /* allocate memory for our decode extra data */
-    ctx->decoded_extra_size = sizeof(ieee80211_extra_t);
-    ctx->decoded_extra = safe_malloc(ctx->decoded_extra_size);
+    if (ctx->decoded_extra_size > 0) {
+        if (ctx->decoded_extra_size < sizeof(ieee80211_extra_t)) {
+            ctx->decoded_extra_size = sizeof(ieee80211_extra_t);
+            ctx->decoded_extra = safe_realloc(ctx->decoded_extra,
+                                              ctx->decoded_extra_size);
+        }
+    } else {
+        ctx->decoded_extra_size = sizeof(ieee80211_extra_t);
+        ctx->decoded_extra = safe_malloc(ctx->decoded_extra_size);
+    }
 
     /* allocate memory for our config data */
     plugin->config_size = sizeof(ieee80211_config_t);
@@ -137,17 +145,11 @@ dlt_ieee80211_cleanup(tcpeditdlt_t *ctx)
         return TCPEDIT_ERROR;
     }
 
-    if (ctx->decoded_extra != NULL) {
-        safe_free(ctx->decoded_extra);
-        ctx->decoded_extra = NULL;
-        ctx->decoded_extra_size = 0;
-    }
-        
-    if (plugin->config != NULL) {
-        safe_free(plugin->config);
-        plugin->config = NULL;
-        plugin->config_size = 0;
-    }
+    safe_free(plugin->name);
+    plugin->name = NULL;
+    safe_free(plugin->config);
+    plugin->config = NULL;
+    plugin->config_size = 0;
 
     return TCPEDIT_OK; /* success */
 }

+ 5 - 7
src/tcpedit/plugins/dlt_jnpr_ether/jnpr_ether.c

@@ -160,18 +160,16 @@ dlt_jnpr_ether_cleanup(tcpeditdlt_t *ctx)
         return TCPEDIT_ERROR;
     }
 
-    if (ctx->decoded_extra != NULL) {
-        safe_free(ctx->decoded_extra);
-        ctx->decoded_extra = NULL;
-        ctx->decoded_extra_size = 0;
-    }
-    
+    safe_free(plugin->name);
+    plugin->name = NULL;
     if (plugin->config != NULL) {
         /* clean up the en10mb plugin */
-        jnpr_ether_config_t * config;
+        jnpr_ether_config_t *config;
 
         config = (jnpr_ether_config_t *)ctx->encoder->config;
         tcpedit_dlt_cleanup(config->subctx);
+        safe_free(config->subctx);
+        safe_free(plugin->config);
         plugin->config = NULL;
         plugin->config_size = 0;
     }

+ 15 - 14
src/tcpedit/plugins/dlt_linuxsll/linuxsll.c

@@ -104,8 +104,16 @@ dlt_linuxsll_init(tcpeditdlt_t *ctx)
     }
 
     /* allocate memory for our decode extra data */
-    ctx->decoded_extra_size = sizeof(linuxsll_extra_t);
-    ctx->decoded_extra = safe_malloc(ctx->decoded_extra_size);
+    if (ctx->decoded_extra_size > 0) {
+        if (ctx->decoded_extra_size < sizeof(linuxsll_extra_t)) {
+            ctx->decoded_extra_size = sizeof(linuxsll_extra_t);
+            ctx->decoded_extra = safe_realloc(ctx->decoded_extra,
+                                              ctx->decoded_extra_size);
+        }
+    } else {
+        ctx->decoded_extra_size = sizeof(linuxsll_extra_t);
+        ctx->decoded_extra = safe_malloc(ctx->decoded_extra_size);
+    }
 
     /* allocate memory for our config data */
     plugin->config_size = sizeof(linuxsll_config_t);
@@ -130,18 +138,11 @@ dlt_linuxsll_cleanup(tcpeditdlt_t *ctx)
         return TCPEDIT_ERROR;
     }
 
-    /* FIXME: make this function do something if necessary */
-    if (ctx->decoded_extra != NULL) {
-        safe_free(ctx->decoded_extra);
-        ctx->decoded_extra = NULL;
-        ctx->decoded_extra_size = 0;
-    }
-
-    if (plugin->config != NULL) {
-        safe_free(plugin->config);
-        plugin->config = NULL;
-        plugin->config_size = 0;
-    }
+    safe_free(plugin->name);
+    plugin->name = NULL;
+    safe_free(plugin->config);
+    plugin->config = NULL;
+    plugin->config_size = 0;
 
     return TCPEDIT_OK; /* success */
 }

+ 25 - 1
src/tcpedit/plugins/dlt_loop/loop.c

@@ -72,7 +72,7 @@ dlt_loop_register(tcpeditdlt_t *ctx)
 
     /* we actually call all the DLT_NULL functions since NULL and LOOP are basically the same thing */
     plugin->plugin_init = dlt_loop_init;
-    plugin->plugin_cleanup = dlt_null_cleanup;
+    plugin->plugin_cleanup = dlt_loop_cleanup;
     plugin->plugin_parse_opts = dlt_null_parse_opts;
     plugin->plugin_decode = dlt_null_decode;
     plugin->plugin_encode = dlt_null_encode;
@@ -107,5 +107,29 @@ dlt_loop_init(tcpeditdlt_t *ctx)
     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_loop_init(), this is just an stub.
+ * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN
+ */
+int dlt_loop_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;
+    }
+
+    safe_free(plugin->name);
+    plugin->name = NULL;
+    safe_free(plugin->config);
+    plugin->config = NULL;
+    plugin->config_size = 0;
+
+    return TCPEDIT_OK; /* success */
+}
 
 /* that's all folks! */

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

@@ -30,6 +30,7 @@ extern "C" {
 
 int dlt_loop_register(tcpeditdlt_t *ctx);
 int dlt_loop_init(tcpeditdlt_t *ctx);
+int dlt_loop_cleanup(tcpeditdlt_t *ctx);
 
 /* empty because we use DLT_NULL */
 

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

@@ -137,17 +137,11 @@ dlt_null_cleanup(tcpeditdlt_t *ctx)
         return TCPEDIT_ERROR;
     }
 
-    if (ctx->decoded_extra != NULL) {
-        safe_free(ctx->decoded_extra);
-        ctx->decoded_extra = NULL;
-        ctx->decoded_extra_size = 0;
-    }
-        
-    if (plugin->config != NULL) {
-        safe_free(plugin->config);
-        plugin->config = NULL;
-        plugin->config_size = 0;
-    }
+    safe_free(plugin->name);
+    plugin->name = NULL;
+    safe_free(plugin->config);
+    plugin->config = NULL;
+    plugin->config_size = 0;
 
     return TCPEDIT_OK; /* success */
 }
@@ -222,10 +216,21 @@ dlt_null_proto(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen)
     if (pktlen < 4)
         return TCPEDIT_ERROR;
     
+    /* PF_INET is always 2 but PF_INET6 varies based on platform, i.e
+     * Linux - 10
+     * NetBSD,OpenBSD,BSD/OS - 24
+     * NetBSD,OpenBSD,BSD/OS - 28
+     * Darwin/macOS - 30
+     * See https://gitlab.com/wireshark/wireshark/-/wikis/NullLoopback
+     */
     af_type = (uint32_t *)packet;
     if (*af_type == PF_INET || SWAPLONG(*af_type) == PF_INET) {
         protocol = ETHERTYPE_IP;
-    } else if (*af_type == PF_INET6 || SWAPLONG(*af_type) == PF_INET6) {
+    } else if (*af_type == PF_INET6 || SWAPLONG(*af_type) == PF_INET6 ||
+               *af_type == 10 || SWAPLONG(*af_type) == 10 ||
+               *af_type == 24 || SWAPLONG(*af_type) == 24 ||
+               *af_type == 28 || SWAPLONG(*af_type) == 28 ||
+               *af_type == 30 || SWAPLONG(*af_type) == 30) {
         protocol = ETHERTYPE_IP6;
     } else {
         tcpedit_seterr(ctx->tcpedit, "Unsupported DLT_NULL/DLT_LOOP PF_ type: 0x%04x", *af_type);

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

@@ -35,7 +35,7 @@ Ethernet aka DLT_EN10MB
 @var{hdlc}
 Cisco HDLC aka DLT_C_HDLC
 @item
-@var{jnpr_ether}
+@var{jnpr_eth}
 Juniper Ethernet DLT_C_JNPR_ETHER
 @item
 @var{pppserial}

+ 18 - 6
src/tcpedit/plugins/dlt_plugins.c

@@ -452,20 +452,32 @@ tcpedit_dlt_dst(tcpeditdlt_t *ctx)
 void
 tcpedit_dlt_cleanup(tcpeditdlt_t *ctx)
 {
+    tcpeditdlt_plugin_t *plugin;
+
     assert(ctx);
     
-    if (ctx->encoder != NULL)
-        ctx->encoder->plugin_cleanup(ctx);
-    
-    if (ctx->decoder != NULL)
-        ctx->decoder->plugin_cleanup(ctx);
+    plugin = ctx->plugins;
+    while (plugin != NULL) {
+        plugin->plugin_cleanup(ctx);
+        plugin = plugin->next;
+    }
+
+    plugin = ctx->plugins;
+    while (plugin != NULL) {
+        tcpeditdlt_plugin_t *plugin_next = plugin->next;
+        safe_free(plugin);
+        plugin = plugin_next;
+    }
 
 #ifdef FORCE_ALIGN
     safe_free(ctx->l3buff);
 #endif
 
-    if (ctx->decoded_extra != NULL)
+    if (ctx->decoded_extra != NULL) {
         safe_free(ctx->decoded_extra);
+        ctx->decoded_extra = NULL;
+        ctx->decoded_extra_size = 0;
+    }
 
     safe_free(ctx);
 }

+ 10 - 9
src/tcpedit/plugins/dlt_pppserial/pppserial.c

@@ -123,9 +123,8 @@ dlt_pppserial_init(tcpeditdlt_t *ctx)
  * It basically allows decoders to properly initialize sub-plugins.
  */
 int 
-dlt_pppserial_post_init(tcpeditdlt_t *ctx)
+dlt_pppserial_post_init(tcpeditdlt_t _U_ *ctx)
 {
-    assert(ctx);
 /* FIXME: Only needs to do something if we're using a sub-plugin
  * See the jnpr_ether_plugin for an example of this
 
@@ -158,14 +157,16 @@ dlt_pppserial_cleanup(tcpeditdlt_t *ctx)
         return TCPEDIT_ERROR;
     }
 
-    /* FIXME: make this function do something if necessary */
-    if (ctx->decoded_extra != NULL) {
-        safe_free(ctx->decoded_extra);
-        ctx->decoded_extra = NULL;
-        ctx->decoded_extra_size = 0;
-    }
-        
+    safe_free(plugin->name);
+    plugin->name = NULL;
     if (plugin->config != NULL) {
+        /* clean up the en10mb plugin */
+        /* FIXME: Only needs to do something if we're using a sub-plugin
+         pppserial_config_t *config;
+         config = (pppserial_config_t *)ctx->encoder->config;
+         tcpedit_dlt_cleanup(config->subctx);
+         safe_free(config->subctx);
+         */
         safe_free(plugin->config);
         plugin->config = NULL;
         plugin->config_size = 0;

+ 15 - 13
src/tcpedit/plugins/dlt_radiotap/radiotap.c

@@ -110,8 +110,16 @@ dlt_radiotap_init(tcpeditdlt_t *ctx)
     }
 
     /* allocate memory for our decode extra data */
-    ctx->decoded_extra_size = sizeof(radiotap_extra_t);
-    ctx->decoded_extra = safe_malloc(ctx->decoded_extra_size);
+    if (ctx->decoded_extra_size > 0) {
+        if (ctx->decoded_extra_size < sizeof(radiotap_extra_t)) {
+            ctx->decoded_extra_size = sizeof(radiotap_extra_t);
+            ctx->decoded_extra = safe_realloc(ctx->decoded_extra,
+                                              ctx->decoded_extra_size);
+        }
+    } else {
+        ctx->decoded_extra_size = sizeof(radiotap_extra_t);
+        ctx->decoded_extra = safe_malloc(ctx->decoded_extra_size);
+    }
 
     /* allocate memory for our config data */
     plugin->config_size = sizeof(radiotap_config_t);
@@ -136,18 +144,12 @@ dlt_radiotap_cleanup(tcpeditdlt_t *ctx)
         return TCPEDIT_ERROR;
     }
 
-    if (ctx->decoded_extra != NULL) {
-        safe_free(ctx->decoded_extra);
-        ctx->decoded_extra = NULL;
-        ctx->decoded_extra_size = 0;
-    }
+    safe_free(plugin->name);
+    plugin->name = NULL;
+    safe_free(plugin->config);
+    plugin->config = NULL;
+    plugin->config_size = 0;
         
-    if (plugin->config != NULL) {
-        safe_free(plugin->config);
-        plugin->config = NULL;
-        plugin->config_size = 0;
-    }
-
     return TCPEDIT_OK; /* success */
 }
 

+ 15 - 14
src/tcpedit/plugins/dlt_raw/raw.c

@@ -104,8 +104,16 @@ dlt_raw_init(tcpeditdlt_t *ctx)
     }
 
     /* allocate memory for our config data */
-    ctx->decoded_extra_size = sizeof(raw_extra_t);
-    ctx->decoded_extra = safe_malloc(ctx->decoded_extra_size);
+    if (ctx->decoded_extra_size > 0) {
+        if (ctx->decoded_extra_size < sizeof(raw_extra_t)) {
+            ctx->decoded_extra_size = sizeof(raw_extra_t);
+            ctx->decoded_extra = safe_realloc(ctx->decoded_extra,
+                                              ctx->decoded_extra_size);
+        }
+    } else {
+        ctx->decoded_extra_size = sizeof(raw_extra_t);
+        ctx->decoded_extra = safe_malloc(ctx->decoded_extra_size);
+    }
 
     /* allocate memory for our config data */
     plugin->config_size = sizeof(raw_config_t);
@@ -130,18 +138,11 @@ dlt_raw_cleanup(tcpeditdlt_t *ctx)
         return TCPEDIT_ERROR;
     }
 
-    /* FIXME: make this function do something if necessary */
-    if (ctx->decoded_extra != NULL) {
-        safe_free(ctx->decoded_extra);
-        ctx->decoded_extra = NULL;
-        ctx->decoded_extra_size = 0;
-    }
-        
-    if (plugin->config != NULL) {
-        safe_free(plugin->config);
-        plugin->config = NULL;
-        plugin->config_size = 0;
-    }
+    safe_free(plugin->name);
+    plugin->name = NULL;
+    safe_free(plugin->config);
+    plugin->config = NULL;
+    plugin->config_size = 0;
 
     return TCPEDIT_OK; /* success */
 }

+ 15 - 14
src/tcpedit/plugins/dlt_user/user.c

@@ -104,8 +104,16 @@ dlt_user_init(tcpeditdlt_t *ctx)
     /* allocate memory for our decode extra data - plus some space for
      * other DLT decodes
      */
-    ctx->decoded_extra_size = USER_L2MAXLEN;
-    ctx->decoded_extra = safe_malloc(ctx->decoded_extra_size);
+    if (ctx->decoded_extra_size > 0) {
+        if (ctx->decoded_extra_size < USER_L2MAXLEN) {
+            ctx->decoded_extra_size = USER_L2MAXLEN;
+            ctx->decoded_extra = safe_realloc(ctx->decoded_extra,
+                                              ctx->decoded_extra_size);
+        }
+    } else {
+        ctx->decoded_extra_size = USER_L2MAXLEN;
+        ctx->decoded_extra = safe_malloc(ctx->decoded_extra_size);
+    }
 
     /* allocate memory for our config data */
     plugin->config_size = sizeof(user_config_t);
@@ -134,18 +142,11 @@ dlt_user_cleanup(tcpeditdlt_t *ctx)
         return TCPEDIT_ERROR;
     }
 
-    /* FIXME: make this function do something if necessary */
-    if (ctx->decoded_extra != NULL) {
-        safe_free(ctx->decoded_extra);
-        ctx->decoded_extra = NULL;
-        ctx->decoded_extra_size = 0;
-    }
-        
-    if (plugin->config != NULL) {
-        safe_free(plugin->config);
-        plugin->config = NULL;
-        plugin->config_size = 0;
-    }
+    safe_free(plugin->name);
+    plugin->name = NULL;
+    safe_free(plugin->config);
+    plugin->config = NULL;
+    plugin->config_size = 0;
 
     return TCPEDIT_OK; /* success */
 }

+ 4 - 4
src/tcpedit/portmap.c

@@ -125,8 +125,8 @@ ports2PORT(char *ports)
             portmap->from = htons(i);
             portmap->to = htons(to_l);
             portmap->next = new_portmap();
-            portmap_last = portmap;
             portmap = portmap->next;
+            portmap_last = portmap;
         }
         portmap_last->next = NULL;
     }
@@ -135,7 +135,7 @@ ports2PORT(char *ports)
         from_begin = strtok_r(from_s, "+", &token2);
         from_l = strtol(from_begin, &badchar, 10);
         if (strlen(badchar) != 0) {
-            free(portmap);
+            safe_free(portmap);
             return NULL;
         }
         portmap->to = htons(to_l);
@@ -147,7 +147,7 @@ ports2PORT(char *ports)
                 portmap = portmap_head;
                 while (portmap) {
                     tcpedit_portmap_t *tmp_portmap = portmap->next;
-                    free(portmap);
+                    safe_free(portmap);
                     portmap = tmp_portmap;
                 }
                 return NULL;
@@ -166,7 +166,7 @@ ports2PORT(char *ports)
         */
         from_l = strtol(from_s, &badchar, 10);
         if (strlen(badchar) != 0 || from_l > 65535 || from_l < 0) {
-            free(portmap);
+            safe_free(portmap);
             return NULL;
         }
         portmap->to = htons(to_l);

+ 78 - 21
src/tcpedit/tcpedit.c

@@ -148,7 +148,7 @@ tcpedit_packet(tcpedit_t *tcpedit, struct pcap_pkthdr **pkthdr,
     dst_dlt = tcpedit_dlt_dst(tcpedit->dlt_ctx);
     l2len = tcpedit_dlt_l2len(tcpedit->dlt_ctx, dst_dlt, packet, (*pkthdr)->caplen);
     if (l2len == -1)
-        return TCPEDIT_ERROR;
+        return TCPEDIT_SOFT_ERROR;
 
     dbgx(2, "dst_dlt = %04x\tsrc_dlt = %04x\tproto = %04x\tl2len = %d", dst_dlt, src_dlt, ntohs(l2proto), l2len);
 
@@ -157,20 +157,20 @@ tcpedit_packet(tcpedit_t *tcpedit, struct pcap_pkthdr **pkthdr,
         u_char *p;
 
         if ((*pkthdr)->caplen < l2len + sizeof(*ip_hdr)) {
-            tcpedit_seterr(tcpedit, "Packet length %d is to short to contain a layer IP header for DLT 0x%04x",
+            tcpedit_seterr(tcpedit, "Packet length %d is too short to contain a layer IP header for DLT 0x%04x",
                     pktlen, dst_dlt);
-            return TCPEDIT_ERROR;
+            return TCPEDIT_SOFT_ERROR;
         }
 
         ip_hdr = (ipv4_hdr_t *)tcpedit_dlt_l3data(tcpedit->dlt_ctx, dst_dlt, packet, (*pkthdr)->caplen);
         if (ip_hdr == NULL)
-            return TCPEDIT_ERROR;
+            return TCPEDIT_SOFT_ERROR;
 
         p = get_layer4_v4(ip_hdr, (*pkthdr)->caplen - l2len);
         if (!p) {
-            tcpedit_seterr(tcpedit, "Packet length %d is to short to contain a layer %d byte IP header for DLT 0x%04x",
+            tcpedit_seterr(tcpedit, "Packet length %d is too short to contain a layer %d byte IP header for DLT 0x%04x",
                     pktlen, ip_hdr->ip_hl << 2,  dst_dlt);
-            return TCPEDIT_ERROR;
+            return TCPEDIT_SOFT_ERROR;
         }
 
         dbgx(3, "Packet has an IPv4 header: 0x%p...", ip_hdr);
@@ -178,20 +178,20 @@ tcpedit_packet(tcpedit_t *tcpedit, struct pcap_pkthdr **pkthdr,
         u_char *p;
 
         if ((*pkthdr)->caplen < l2len + sizeof(*ip6_hdr)) {
-            tcpedit_seterr(tcpedit, "Packet length %d is to short to contain a layer IPv6 header for DLT 0x%04x",
+            tcpedit_seterr(tcpedit, "Packet length %d is too short to contain a layer IPv6 header for DLT 0x%04x",
                     pktlen, dst_dlt);
-            return TCPEDIT_ERROR;
+            return TCPEDIT_SOFT_ERROR;
         }
 
         ip6_hdr = (ipv6_hdr_t *)tcpedit_dlt_l3data(tcpedit->dlt_ctx, dst_dlt, packet, (*pkthdr)->caplen);
         if (ip6_hdr == NULL)
-            return TCPEDIT_ERROR;
+            return TCPEDIT_SOFT_ERROR;
 
         p = get_layer4_v6(ip6_hdr, (*pkthdr)->caplen - l2len);
         if (!p) {
-            tcpedit_seterr(tcpedit, "Packet length %d is to short to contain an IPv6 header for DLT 0x%04x",
+            tcpedit_seterr(tcpedit, "Packet length %d is too short to contain an IPv6 header for DLT 0x%04x",
                     pktlen, dst_dlt);
-            return TCPEDIT_ERROR;
+            return TCPEDIT_SOFT_ERROR;
         }
 
         dbgx(3, "Packet has an IPv6 header: 0x%p...", ip6_hdr);
@@ -469,20 +469,20 @@ void
 __tcpedit_seterr(tcpedit_t *tcpedit, const char *func, const int line, const char *file, const char *fmt, ...)
 {
     va_list ap;
-    char errormsg[TCPEDIT_ERRSTR_LEN];
+    char errormsg[TCPEDIT_ERRSTR_LEN - 32];
     
     assert(tcpedit);
 
     va_start(ap, fmt);
     if (fmt != NULL) {
-        (void)vsnprintf(errormsg, 
-              (TCPEDIT_ERRSTR_LEN - 1), fmt, ap);
+        (void)vsnprintf(errormsg, sizeof(errormsg), fmt, ap);
     }
 
     va_end(ap);
     
-    snprintf(tcpedit->runtime.errstr, (TCPEDIT_ERRSTR_LEN -1), "From %s:%s() line %d:\n%s",
-        file, func, line, errormsg);
+    snprintf(tcpedit->runtime.errstr, sizeof(tcpedit->runtime.errstr),
+             "From %s:%s() line %d:\n%s",
+             file, func, line, errormsg);
 }
 
 /**
@@ -508,7 +508,8 @@ tcpedit_setwarn(tcpedit_t *tcpedit, const char *fmt, ...)
 
     va_start(ap, fmt);
     if (fmt != NULL)
-        (void)vsnprintf(tcpedit->runtime.warnstr, (TCPEDIT_ERRSTR_LEN - 1), fmt, ap);
+        (void)vsnprintf(tcpedit->runtime.warnstr,
+                        sizeof(tcpedit->runtime.warnstr), fmt, ap);
 
     va_end(ap);
         
@@ -560,22 +561,78 @@ tcpedit_checkerror(tcpedit_t *tcpedit, const int rcode, const char *prefix) {
 /**
  * \brief Cleans up after ourselves.  Return 0 on success. 
  * 
- * Clean up after ourselves, but does not actually free the ptr.
+ * Clean up after ourselves and free the ptr.
  */
 int
-tcpedit_close(tcpedit_t *tcpedit)
+tcpedit_close(tcpedit_t **tcpedit_ex)
 {
 
-    assert(tcpedit);
+    assert(*tcpedit_ex);
+    tcpedit_t *tcpedit;
+
+    tcpedit = *tcpedit_ex;
+
     dbgx(1, "tcpedit processed " COUNTER_SPEC " bytes in " COUNTER_SPEC
             " packets.", tcpedit->runtime.total_bytes,
             tcpedit->runtime.pkts_edited);
 
-    /* free buffer if required */
+    /* free if required */
+    if (tcpedit->dlt_ctx) {
+        tcpedit_dlt_cleanup(tcpedit->dlt_ctx);
+        tcpedit->dlt_ctx = NULL;
+    }
+
+    if (tcpedit->cidrmap1) {
+        destroy_cidr(tcpedit->cidrmap1->from);
+        tcpedit->cidrmap1->from = NULL;
+        destroy_cidr(tcpedit->cidrmap1->to);
+        tcpedit->cidrmap1->to = NULL;
+    }
+
+    if (tcpedit->cidrmap2 && tcpedit->cidrmap2 != tcpedit->cidrmap1) {
+        destroy_cidr(tcpedit->cidrmap2->from);
+        tcpedit->cidrmap2->from = NULL;
+        destroy_cidr(tcpedit->cidrmap2->to);
+        tcpedit->cidrmap2->to = NULL;
+        safe_free(tcpedit->cidrmap2);
+        tcpedit->cidrmap2 = NULL;
+    }
+
+    safe_free(tcpedit->cidrmap1);
+    tcpedit->cidrmap1 = NULL;
+
+    if (tcpedit->srcipmap) {
+        destroy_cidr(tcpedit->srcipmap->from);
+        tcpedit->srcipmap->from = NULL;
+        destroy_cidr(tcpedit->srcipmap->to);
+        tcpedit->srcipmap->to = NULL;
+    }
+
+    if (tcpedit->dstipmap && tcpedit->dstipmap != tcpedit->srcipmap) {
+        destroy_cidr(tcpedit->dstipmap->from);
+        tcpedit->dstipmap->from = NULL;
+        destroy_cidr(tcpedit->dstipmap->to);
+        tcpedit->dstipmap->to = NULL;
+        safe_free(tcpedit->dstipmap);
+        tcpedit->dstipmap = NULL;
+    }
+
+    safe_free(tcpedit->srcipmap);
+    tcpedit->srcipmap = NULL;
+
+    if (tcpedit->portmap) {
+        free_portmap(tcpedit->portmap);
+        tcpedit->portmap = NULL;
+    }
+
 #ifdef FORCE_ALIGN
     safe_free(tcpedit->runtime.l3buff);
+    tcpedit->runtime.l3buff = NULL;
 #endif
 
+    safe_free(*tcpedit_ex);
+    *tcpedit_ex = NULL;
+
     return 0;
 }
 

+ 1 - 1
src/tcpedit/tcpedit.h

@@ -48,7 +48,7 @@ int tcpedit_validate(tcpedit_t *tcpedit);
 int tcpedit_packet(tcpedit_t *tcpedit, struct pcap_pkthdr **pkthdr, 
         u_char **pktdata, tcpr_dir_t direction);
 
-int tcpedit_close(tcpedit_t *tcpedit);
+int tcpedit_close(tcpedit_t **tcpedit_ex);
 int tcpedit_get_output_dlt(tcpedit_t *tcpedit);
 
 const u_char *tcpedit_l3data(tcpedit_t *tcpedit, tcpedit_coder code, u_char *packet, const int pktlen);

+ 0 - 1
src/tcpedit/tcpedit_types.h

@@ -105,7 +105,6 @@ typedef struct tcpedit_portmap_s {
 typedef struct {
     bool validated;  /* have we run tcpedit_validate()? */
     struct tcpeditdlt_s *dlt_ctx;
-    tcpedit_packet_t *packet;
     
     /* runtime variables, don't mess with these */
     tcpedit_runtime_t runtime;

+ 1 - 1
src/tcpliveplay.1

@@ -10,7 +10,7 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH tcpliveplay 1 "14 Jun 2020" "tcpliveplay" "User Commands"
+.TH tcpliveplay 1 "01 May 2021" "tcpliveplay" "User Commands"
 .\"
 .\" DO NOT EDIT THIS FILE (in-mem file)
 .\"

+ 1 - 1
src/tcpprep.1

@@ -10,7 +10,7 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH tcpprep 1 "14 Jun 2020" "tcpprep" "User Commands"
+.TH tcpprep 1 "01 May 2021" "tcpprep" "User Commands"
 .\"
 .\" DO NOT EDIT THIS FILE (in-mem file)
 .\"

+ 0 - 3
src/tcpprep.c

@@ -49,9 +49,6 @@
 #include "lib/tree.h"
 #include "tree.h"
 #include "lib/sll.h"
-#ifndef HAVE_STRLCPY
-#include "lib/strlcpy.h"
-#endif
 
 /*
  * global variables

+ 5 - 6
src/tcpprep_api.c

@@ -320,20 +320,19 @@ __tcpprep_seterr(tcpprep_t *ctx, const char *func, const int line,
         const char *file, const char *fmt, ...)
 {
     va_list ap;
-    char errormsg[TCPREPLAY_ERRSTR_LEN];
+    char errormsg[TCPREPLAY_ERRSTR_LEN - 32];
 
     assert(ctx);
 
     va_start(ap, fmt);
     if (fmt != NULL) {
-        (void)vsnprintf(errormsg,
-              (TCPREPLAY_ERRSTR_LEN - 1), fmt, ap);
+        (void)vsnprintf(errormsg, sizeof(errormsg), fmt, ap);
     }
 
     va_end(ap);
 
-    snprintf(ctx->errstr, (TCPREPLAY_ERRSTR_LEN -1), "From %s:%s() line %d:\n%s",
-        file, func, line, errormsg);
+    snprintf(ctx->errstr, sizeof(ctx->errstr), "From %s:%s() line %d:\n%s",
+             file, func, line, errormsg);
 }
 
 /**
@@ -350,7 +349,7 @@ tcpprep_setwarn(tcpprep_t *ctx, const char *fmt, ...)
 
     va_start(ap, fmt);
     if (fmt != NULL)
-        (void)vsnprintf(ctx->warnstr, (TCPREPLAY_ERRSTR_LEN - 1), fmt, ap);
+        (void)vsnprintf(ctx->warnstr, sizeof(ctx->warnstr), fmt, ap);
 
     va_end(ap);
 }

+ 2 - 2
src/tcpreplay-edit.1

@@ -10,7 +10,7 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH tcpreplay-edit 1 "14 Jun 2020" "tcpreplay" "User Commands"
+.TH tcpreplay-edit 1 "01 May 2021" "tcpreplay" "User Commands"
 .\"
 .\" DO NOT EDIT THIS FILE (in-mem file)
 .\"
@@ -358,7 +358,7 @@ Ethernet aka DLT_EN10MB
 \fBhdlc\fP
 Cisco HDLC aka DLT_C_HDLC
 .sp 1
-\fBjnpr_ether\fP
+\fBjnpr_eth\fP
 Juniper Ethernet DLT_C_JNPR_ETHER
 .sp 1
 \fBpppserial\fP

+ 1 - 1
src/tcpreplay.1

@@ -10,7 +10,7 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH tcpreplay 1 "14 Jun 2020" "tcpreplay" "User Commands"
+.TH tcpreplay 1 "01 May 2021" "tcpreplay" "User Commands"
 .\"
 .\" DO NOT EDIT THIS FILE (in-mem file)
 .\"

+ 8 - 0
src/tcpreplay.c

@@ -91,12 +91,14 @@ main(int argc, char *argv[])
     /* parse the tcpedit args */
     rcode = tcpedit_post_args(tcpedit);
     if (rcode < 0) {
+        tcpedit_close(&tcpedit);
         errx(-1, "Unable to parse args: %s", tcpedit_geterr(tcpedit));
     } else if (rcode == 1) {
         warnx("%s", tcpedit_geterr(tcpedit));
     }
 
     if (tcpedit_validate(tcpedit) < 0) {
+        tcpedit_close(&tcpedit);
         errx(-1, "Unable to edit packets given options:\n%s",
                tcpedit_geterr(tcpedit));
     }
@@ -140,6 +142,9 @@ main(int argc, char *argv[])
 
     if (rcode < 0) {
         notice("\nFailed: %s\n", tcpreplay_geterr(ctx));
+#ifdef TCPREPLAY_EDIT
+        tcpedit_close(&tcpedit);
+#endif
         exit(rcode);
     } else if (rcode == 1) {
         notice("\nWarning: %s\n", tcpreplay_getwarn(ctx));
@@ -163,6 +168,9 @@ main(int argc, char *argv[])
     dump_timestamp_trace_array(&ctx->stats.start_time, &ctx->stats.end_time,
             ctx->options->speed.speed);
 #endif
+#ifdef TCPREPLAY_EDIT
+    tcpedit_close(&tcpedit);
+#endif
     tcpreplay_close(ctx);
     restore_stdin();
     return 0;

+ 11 - 8
src/tcpreplay_api.c

@@ -178,6 +178,11 @@ tcpreplay_post_args(tcpreplay_t *ctx, int argc)
         options->speed.speed = 0;
     } else if (HAVE_OPT(PPS)) {
         n = atof(OPT_ARG(PPS));
+        if (!n) {
+            tcpreplay_seterr(ctx, "invalid pps value '%s'", OPT_ARG(PPS));
+            ret = -1;
+            goto out;
+        }
         options->speed.speed = (COUNTER)(n * 60.0 * 60.0); /* convert to packets per hour */
         options->speed.mode = speed_packetrate;
         options->speed.pps_multi = OPT_VALUE_PPS_MULTI;
@@ -914,7 +919,7 @@ __tcpreplay_seterr(tcpreplay_t *ctx, const char *func,
         const int line, const char *file, const char *fmt, ...)
 {
     va_list ap;
-    char errormsg[TCPREPLAY_ERRSTR_LEN];
+    char errormsg[TCPREPLAY_ERRSTR_LEN - 32];
 
     assert(ctx);
     assert(file);
@@ -922,18 +927,16 @@ __tcpreplay_seterr(tcpreplay_t *ctx, const char *func,
     assert(line);
 
     va_start(ap, fmt);
-    if (fmt != NULL) {
-        (void)vsnprintf(errormsg,
-              (TCPREPLAY_ERRSTR_LEN - 1), fmt, ap);
-    }
+    if (fmt != NULL)
+        (void)vsnprintf(errormsg, sizeof(errormsg), fmt, ap);
 
     va_end(ap);
 
 #ifdef DEBUG
-    snprintf(ctx->errstr, (TCPREPLAY_ERRSTR_LEN -1), "From %s:%s() line %d:\n%s",
+    snprintf(ctx->errstr, sizeof(ctx->errstr), "From %s:%s() line %d:\n%s",
         file, func, line, errormsg);
 #else
-    snprintf(ctx->errstr, (TCPREPLAY_ERRSTR_LEN -1), "%s", errormsg);
+    snprintf(ctx->errstr, sizeof(ctx->errstr), "%s", errormsg);
 #endif
 }
 
@@ -951,7 +954,7 @@ tcpreplay_setwarn(tcpreplay_t *ctx, const char *fmt, ...)
 
     va_start(ap, fmt);
     if (fmt != NULL)
-        (void)vsnprintf(ctx->warnstr, (TCPREPLAY_ERRSTR_LEN - 1), fmt, ap);
+        (void)vsnprintf(ctx->warnstr, sizeof(ctx->warnstr), fmt, ap);
 
     va_end(ap);
 }

+ 2 - 2
src/tcprewrite.1

@@ -10,7 +10,7 @@
 .ds B-Font B
 .ds I-Font I
 .ds R-Font R
-.TH tcprewrite 1 "14 Jun 2020" "tcprewrite" "User Commands"
+.TH tcprewrite 1 "01 May 2021" "tcprewrite" "User Commands"
 .\"
 .\" DO NOT EDIT THIS FILE (in-mem file)
 .\"
@@ -383,7 +383,7 @@ Ethernet aka DLT_EN10MB
 \fBhdlc\fP
 Cisco HDLC aka DLT_C_HDLC
 .sp 1
-\fBjnpr_ether\fP
+\fBjnpr_eth\fP
 Juniper Ethernet DLT_C_JNPR_ETHER
 .sp 1
 \fBpppserial\fP

+ 16 - 5
src/tcprewrite.c

@@ -86,12 +86,14 @@ main(int argc, char *argv[])
     /* parse the tcpedit args */
     rcode = tcpedit_post_args(tcpedit);
     if (rcode < 0) {
+        tcpedit_close(&tcpedit);
         errx(-1, "Unable to parse args: %s", tcpedit_geterr(tcpedit));
     } else if (rcode == 1) {
         warnx("%s", tcpedit_geterr(tcpedit));
     }
 
     if (tcpedit_validate(tcpedit) < 0) {
+        tcpedit_close(&tcpedit);
         errx(-1, "Unable to edit packets given options:\n%s",
                 tcpedit_geterr(tcpedit));
     }
@@ -103,16 +105,20 @@ main(int argc, char *argv[])
     options.outfile = safe_strdup(OPT_ARG(OUTFILE));
     dbgx(1, "Rewriting DLT to %s",
             pcap_datalink_val_to_name(tcpedit_get_output_dlt(tcpedit)));
-    if ((dlt_pcap = pcap_open_dead(tcpedit_get_output_dlt(tcpedit), 65535)) == NULL)
+    if ((dlt_pcap = pcap_open_dead(tcpedit_get_output_dlt(tcpedit), 65535)) == NULL) {
+        tcpedit_close(&tcpedit);
         err(-1, "Unable to open dead pcap handle.");
+    }
 
     dbgx(1, "DLT of dlt_pcap is %s",
         pcap_datalink_val_to_name(pcap_datalink(dlt_pcap)));
 
 #ifdef ENABLE_FRAGROUTE
     if (options.fragroute_args) {
-        if ((options.frag_ctx = fragroute_init(65535, pcap_datalink(dlt_pcap), options.fragroute_args, ebuf)) == NULL)
+        if ((options.frag_ctx = fragroute_init(65535, pcap_datalink(dlt_pcap), options.fragroute_args, ebuf)) == NULL) {
+            tcpedit_close(&tcpedit);
             errx(-1, "%s", ebuf);
+        }
     }
 #endif
 
@@ -122,18 +128,23 @@ main(int argc, char *argv[])
     }
 #endif
 
-    if ((options.pout = pcap_dump_open(dlt_pcap, options.outfile)) == NULL)
+    if ((options.pout = pcap_dump_open(dlt_pcap, options.outfile)) == NULL) {
+        tcpedit_close(&tcpedit);
         errx(-1, "Unable to open output pcap file: %s", pcap_geterr(dlt_pcap));
+    }
+
     pcap_close(dlt_pcap);
 
     /* rewrite packets */
-    if (rewrite_packets(tcpedit, options.pin, options.pout) != 0)
+    if (rewrite_packets(tcpedit, options.pin, options.pout) != 0) {
+        tcpedit_close(&tcpedit);
         errx(-1, "Error rewriting packets: %s", tcpedit_geterr(tcpedit));
-
+    }
 
     /* clean up after ourselves */
     pcap_dump_close(options.pout);
     pcap_close(options.pin);
+    tcpedit_close(&tcpedit);
 
 #ifdef ENABLE_VERBOSE
     tcpdump_close(&tcpdump);

+ 1 - 3
src/tree.c

@@ -789,9 +789,7 @@ packet2tree(const u_char * data, const int len)
 
 
     /* copy over the source mac */
-    memset(&node->mac[0], 0, sizeof(node->mac));
-    strncpy((char *)node->mac, (char *)eth_hdr->ether_shost,
-            sizeof(node->mac) - 1);
+    strlcpy((char *)node->mac, (char *)eth_hdr->ether_shost, sizeof(node->mac));
 
     /* 
      * TCP 

+ 11 - 11
test/Makefile.in

@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15 from Makefile.am.
+# Makefile.in generated by automake 1.16.1 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+# Copyright (C) 1994-2018 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -90,12 +90,9 @@ host_triplet = @host@
 target_triplet = @target@
 subdir = test
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/libopts.m4 \
-	$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
-	$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
-	$(top_srcdir)/m4/lt~obsolete.m4 \
-	$(top_srcdir)/m4/stdnoreturn.m4 $(top_srcdir)/acinclude.m4 \
-	$(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
+	$(top_srcdir)/libopts/m4/stdnoreturn.m4 \
+	$(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
 	$(ACLOCAL_M4)
 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
@@ -352,8 +349,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 	  *config.status*) \
 	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
 	  *) \
-	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
-	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
 	esac;
 
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@@ -379,7 +376,10 @@ ctags CTAGS:
 cscope cscopelist:
 
 
-distdir: $(DISTFILES)
+distdir: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
 	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
 	list='$(DISTFILES)'; \