commit f36a4fca258fc0a725352cfc744037634a08b076 Author: lijia Date: Wed Jul 10 17:54:02 2019 +0800 copy from intranet. diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..5458714 --- /dev/null +++ b/INSTALL @@ -0,0 +1,234 @@ +Installation Instructions +************************* + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, +2006 Free Software Foundation, Inc. + +This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +Basic Installation +================== + +Briefly, the shell commands `./configure; make; make install' should +configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. Caching is +disabled by default to prevent problems with accidental use of stale +cache files. + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You need `configure.ac' if +you want to change it or regenerate `configure' using a newer version +of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. + + Running `configure' might take a while. While running, it prints + some messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + +Some systems require unusual options for compilation or linking that the +`configure' script does not know about. Run `./configure --help' for +details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c99 CFLAGS=-g LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + +You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you can use GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + With a non-GNU `make', it is safer to compile the package for one +architecture at a time in the source code directory. After you have +installed the package for one architecture, use `make distclean' before +reconfiguring for another architecture. + +Installation Names +================== + +By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + +Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + +There may be some features `configure' cannot figure out automatically, +but needs to determine by the type of machine the package will run on. +Usually, assuming the package is built to be run on the _same_ +architectures, `configure' can figure that out, but if it prints a +message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option `--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + +If you want to set default values for `configure' scripts to share, you +can create a site shell script called `config.site' that gives default +values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + +Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). + +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf bug. Until the bug is fixed you can use this workaround: + + CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash + +`configure' Invocation +====================== + +`configure' recognizes the following options to control how it operates. + +`--help' +`-h' + Print a summary of the options to `configure', and exit. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..3ca7633 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,69 @@ +# $Id$ +AUTOMAKE_OPTIONS = foreign + +ACLOCAL_AMFLAGS = -I m4 -I libopts/m4 + +if NEED_LIBOPTS +SUBDIRS = scripts lib $(LIBOPTS_DIR) src +else +SUBDIRS = scripts lib src +endif + +DIST_SUBDIRS = scripts lib libopts src docs test +.PHONY: manpages docs test man2html + + +dist-hook: version manpages update + +update: + svn update + +DOCS_DIR = $(top_builddir)/docs + +manpages: + cd src && make manpages + +docs: manpages + echo Making docs in $(DOCS_DIR) + cd $(DOCS_DIR) && make docs + +clean-docs: + cd $(DOCS_DIR) && make clean-docs + +postweb: docs doxygen + cd $(DOCS_DIR) && make postweb + +TEST_DIR = $(top_builddir)/test + +autoopts: + cd src && make autoopts + +test: + echo Making test in $(TEST_DIR) + cd $(TEST_DIR) && make test + +dlt_names: + cat @SAVEFILE_C@ | $(top_builddir)/scripts/dlt2name.pl src/dlt_names.h + +version: + -rm -f src/common/svn_version.c + cd src/common && make svn_version.c + +distclean-local: + -rm -rf autom4te.cache doxygen + +doxygen: version + doxygen doxygen.cfg + +ncc: + CC=ncc make + +MOSTLYCLEANFILES = tcpreplay.spec *~ + +DISTCLEANFILES = .tm_project.cache stamp-h1 *.tar.* + +MAINTAINERCLEANFILES = Makefile.in configure *.bak + +EXTRA_DIST = doxygen.cfg.in autogen.sh \ + m4/libtool.m4 m4/ltoptions.m4 m4/ltsugar.m4 \ + m4/ltversion.m4 m4/lt~obsolete.m4 diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..14cae6c --- /dev/null +++ b/Makefile.in @@ -0,0 +1,797 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = . +DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(srcdir)/doxygen.cfg.in \ + $(top_srcdir)/configure INSTALL config/compile \ + config/config.guess config/config.sub config/depcomp \ + config/install-sh config/ltmain.sh config/missing \ + config/mkinstalldirs +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno config.status.lineno +mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/src/config.h +CONFIG_CLEAN_FILES = doxygen.cfg +CONFIG_CLEAN_VPATH_FILES = +SOURCES = +DIST_SOURCES = +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ + $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ + distdir dist dist-all distcheck +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) +am__remove_distdir = \ + { test ! -d "$(distdir)" \ + || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -fr "$(distdir)"; }; } +am__relativize = \ + dir0=`pwd`; \ + sed_first='s,^\([^/]*\)/.*$$,\1,'; \ + sed_rest='s,^[^/]*/*,,'; \ + sed_last='s,^.*/\([^/]*\)$$,\1,'; \ + sed_butlast='s,/*[^/]*$$,,'; \ + while test -n "$$dir1"; do \ + first=`echo "$$dir1" | sed -e "$$sed_first"`; \ + if test "$$first" != "."; then \ + if test "$$first" = ".."; then \ + dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ + dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ + else \ + first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ + if test "$$first2" = "$$first"; then \ + dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ + else \ + dir2="../$$dir2"; \ + fi; \ + dir0="$$dir0"/"$$first"; \ + fi; \ + fi; \ + dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ + done; \ + reldir="$$dir2" +DIST_ARCHIVES = $(distdir).tar.gz +GZIP_ENV = --best +distuninstallcheck_listfiles = find . -type f -print +distcleancheck_listfiles = find . -type f -print +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOGEN = @AUTOGEN@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CUT = @CUT@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DMALLOC_LIB = @DMALLOC_LIB@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +GROFF = @GROFF@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LDNETINC = @LDNETINC@ +LDNETLIB = @LDNETLIB@ +LIBOBJS = @LIBOBJS@ +LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@ +LIBOPTS_DIR = @LIBOPTS_DIR@ +LIBOPTS_LDADD = @LIBOPTS_LDADD@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LNAVLIB = @LNAVLIB@ +LNAV_CFLAGS = @LNAV_CFLAGS@ +LN_S = @LN_S@ +LPCAPINC = @LPCAPINC@ +LPCAPLIB = @LPCAPLIB@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@ +PRINTF = @PRINTF@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TCPREPLAY_RELEASE = @TCPREPLAY_RELEASE@ +TCPREPLAY_VERSION = @TCPREPLAY_VERSION@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +debug_flag = @debug_flag@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +nic1 = @nic1@ +nic2 = @nic2@ +oldincludedir = @oldincludedir@ +pcncfg = @pcncfg@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +tcpdump_path = @tcpdump_path@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ + +# $Id$ +AUTOMAKE_OPTIONS = foreign +ACLOCAL_AMFLAGS = -I m4 -I libopts/m4 +@NEED_LIBOPTS_FALSE@SUBDIRS = scripts lib src +@NEED_LIBOPTS_TRUE@SUBDIRS = scripts lib $(LIBOPTS_DIR) src +DIST_SUBDIRS = scripts lib libopts src docs test +DOCS_DIR = $(top_builddir)/docs +TEST_DIR = $(top_builddir)/test +MOSTLYCLEANFILES = tcpreplay.spec *~ +DISTCLEANFILES = .tm_project.cache stamp-h1 *.tar.* +MAINTAINERCLEANFILES = Makefile.in configure *.bak +EXTRA_DIST = doxygen.cfg.in autogen.sh \ + m4/libtool.m4 m4/ltoptions.m4 m4/ltsugar.m4 \ + m4/ltversion.m4 m4/lt~obsolete.m4 + +all: all-recursive + +.SUFFIXES: +am--refresh: + @: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ + $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *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);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + $(am__cd) $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) +$(am__aclocal_m4_deps): +doxygen.cfg: $(top_builddir)/config.status $(srcdir)/doxygen.cfg.in + cd $(top_builddir) && $(SHELL) ./config.status $@ + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool config.lt + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +$(RECURSIVE_CLEAN_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(am__remove_distdir) + test -d "$(distdir)" || mkdir "$(distdir)" + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ + $(am__relativize); \ + new_distdir=$$reldir; \ + dir1=$$subdir; dir2="$(top_distdir)"; \ + $(am__relativize); \ + new_top_distdir=$$reldir; \ + echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ + echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ + ($(am__cd) $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$new_top_distdir" \ + distdir="$$new_distdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + am__skip_mode_fix=: \ + distdir) \ + || exit 1; \ + fi; \ + done + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" distdir="$(distdir)" \ + dist-hook + -test -n "$(am__skip_mode_fix)" \ + || find "$(distdir)" -type d ! -perm -755 \ + -exec chmod u+rwx,go+rx {} \; -o \ + ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ + ! -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 + $(am__remove_distdir) + +dist-bzip2: distdir + tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 + $(am__remove_distdir) + +dist-lzma: distdir + tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma + $(am__remove_distdir) + +dist-xz: distdir + tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz + $(am__remove_distdir) + +dist-tarZ: distdir + tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z + $(am__remove_distdir) + +dist-shar: distdir + shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz + $(am__remove_distdir) + +dist-zip: distdir + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) + $(am__remove_distdir) + +dist dist-all: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + case '$(DIST_ARCHIVES)' in \ + *.tar.gz*) \ + GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ + *.tar.bz2*) \ + bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ + *.tar.lzma*) \ + lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ + *.tar.xz*) \ + xz -dc $(distdir).tar.xz | $(am__untar) ;;\ + *.tar.Z*) \ + uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ + *.shar.gz*) \ + GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ + *.zip*) \ + unzip $(distdir).zip ;;\ + esac + chmod -R a-w $(distdir); chmod a+w $(distdir) + mkdir $(distdir)/_build + mkdir $(distdir)/_inst + chmod a-w $(distdir) + test -d $(distdir)/_build || exit 0; \ + dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ + && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ + && am__cwd=`pwd` \ + && $(am__cd) $(distdir)/_build \ + && ../configure --srcdir=.. --prefix="$$dc_install_base" \ + $(DISTCHECK_CONFIGURE_FLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ + distuninstallcheck \ + && chmod -R a-w "$$dc_install_base" \ + && ({ \ + (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ + distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ + } || { rm -rf "$$dc_destdir"; exit 1; }) \ + && rm -rf "$$dc_destdir" \ + && $(MAKE) $(AM_MAKEFLAGS) dist \ + && rm -rf $(DIST_ARCHIVES) \ + && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ + && cd "$$am__cwd" \ + || exit 1 + $(am__remove_distdir) + @(echo "$(distdir) archives ready for distribution: "; \ + list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ + sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' +distuninstallcheck: + @$(am__cd) '$(distuninstallcheck_dir)' \ + && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ + || { echo "ERROR: files left after uninstall:" ; \ + if test -n "$(DESTDIR)"; then \ + echo " (check DESTDIR support)"; \ + fi ; \ + $(distuninstallcheck_listfiles) ; \ + exit 1; } >&2 +distcleancheck: distclean + @if test '$(srcdir)' = . ; then \ + echo "ERROR: distcleancheck can only run from a VPATH build" ; \ + exit 1 ; \ + fi + @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left in build directory after distclean:" ; \ + $(distcleancheck_listfiles) ; \ + exit 1; } >&2 +check-am: all-am +check: check-recursive +all-am: Makefile +installdirs: installdirs-recursive +installdirs-am: +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-recursive + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-libtool \ + distclean-local distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +html-am: + +info: info-recursive + +info-am: + +install-data-am: + +install-dvi: install-dvi-recursive + +install-dvi-am: + +install-exec-am: + +install-html: install-html-recursive + +install-html-am: + +install-info: install-info-recursive + +install-info-am: + +install-man: + +install-pdf: install-pdf-recursive + +install-pdf-am: + +install-ps: install-ps-recursive + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: + +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \ + install-am install-strip tags-recursive + +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am am--refresh check check-am clean clean-generic \ + clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \ + dist-gzip dist-hook dist-lzma dist-shar dist-tarZ dist-xz \ + dist-zip distcheck distclean distclean-generic \ + distclean-libtool distclean-local distclean-tags \ + distcleancheck distdir distuninstallcheck 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 installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \ + uninstall uninstall-am + +.PHONY: manpages docs test man2html + +dist-hook: version manpages update + +update: + svn update + +manpages: + cd src && make manpages + +docs: manpages + echo Making docs in $(DOCS_DIR) + cd $(DOCS_DIR) && make docs + +clean-docs: + cd $(DOCS_DIR) && make clean-docs + +postweb: docs doxygen + cd $(DOCS_DIR) && make postweb + +autoopts: + cd src && make autoopts + +test: + echo Making test in $(TEST_DIR) + cd $(TEST_DIR) && make test + +dlt_names: + cat @SAVEFILE_C@ | $(top_builddir)/scripts/dlt2name.pl src/dlt_names.h + +version: + -rm -f src/common/svn_version.c + cd src/common && make svn_version.c + +distclean-local: + -rm -rf autom4te.cache doxygen + +doxygen: version + doxygen doxygen.cfg + +ncc: + CC=ncc make + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/README.md b/README.md new file mode 100644 index 0000000..1a3e408 --- /dev/null +++ b/README.md @@ -0,0 +1,77 @@ +/* +Version Maintenance : LiJia(lijia01@iie.ac.cn) +Create Time : 2013-06-06 +Latest Time : 2018-06-12 + +tcpburst-2.1: + 支持vxlan封装格式, 将已有的pcap包内容封装在vxlan数据包内, 用于模拟测试串联模式下的平台处理流量情况. + +tcpburst-2.0: + 支持marsio发包接口. + +tcpburst-1.2: + 20161214, 增加对GRE, 6over4, IPinIP等隧道协议的支持. + +tcpburst-1.1 + 修改流放大部分算法. + +tcpburst-1.0: + 基于标准tcpreplay,增加基于TCP或UDP流的放大功能,可用于大流量包回放、性能测试等. + +修改背景: + 标准的tcpreplay读包速率受硬盘传输速度影响,一般最高在600Mbps左右. + 本程序在tcpreplay的基础上,针对上述瓶颈做了一些修改: + 每读到一个TCP或UDP包,原始包原样转发,然后对其IP地址进行修改后,再次发送N个包, + 这样捕包时会得到不同四元组、但应用层数据相同的流,达到流量放大目的. + +功能介绍: + 例: + 原始TCP流 1.1.1.1:12345<-->10.10.10.10:80 + + 假设流放大倍数=4,则新回放的包中包含如下TCP流: + 1.1.1.1:12345<-->10.10.10.10:80 + 2.1.1.1:12345<-->9.10.10.10:80 + 3.1.1.1:12345<-->8.10.10.10:80 + 4.1.1.1:12345<-->7.10.10.10:80 + 5.1.1.1:12345<--->6.10.10.10:80 + +使用说明: + configure + make + make install + + 在标准tcpreplay基础上,新增加了2个参数: + + -m, --stream-multiple=num Replay streams at a given multiple,流放大倍数; + -d, --packet-distance=num The distance between raw packet and fake replay packet,原始包与虚假回放包的间距. + + packet-distance的作用: + 假设原始流CPU近似占用率如下: + cpu + 20| /\ + 15| / \ + 10| / \ /\ + 05| / \ / \ + 0|--/--------\/----\-----time + + 设参数stream-multiple=4, packet-distance=0, CPU近似占用率(注意纵坐标的变化!!!): + + cpu + 80| /\ + 40| / \ + 60| / \ /\ + 20| / \ / \ + 0|--/--------\/----\-----time + (因为只改变了四元组,应用层数据是相同的,包间距=0的话,即同样的应用层数据会在短时间内重复处理N次) + + 设参数stream-multiple=4, packet-distance=100,有可能会得到这样的CPU占用率: + cpu + 40| /\/\/\/\/\/\/\/\/\/\/ + 30| + 20| + 10| + 0|---------------------- time + + 所以,使用流放大功能的话,强烈推荐加-d选项,合理设置packet-distance的值! + +*/ \ No newline at end of file diff --git a/README.tcpreplay b/README.tcpreplay new file mode 100644 index 0000000..0313645 --- /dev/null +++ b/README.tcpreplay @@ -0,0 +1,48 @@ +$Id: README 1796 2007-04-11 04:55:14Z aturner $ +[Please note that licensing, compiling, usage and other documentation can be +found in the docs subdirectory.] + +If you have a question or think you are experiancing a bug, it is important +that you provide enough information for us to help you. Failure to provide +enough information will likely cause your email to be ignored or get an +annoyed reply from the author. + +If your problem has to do with COMPILING tcpreplay: +- Version of tcpreplay you are trying to compile +- Platform (Red Hat Linux 9 on x86, Solaris 7 on SPARC, OS X on PPC, etc) +- ./configure arguments +- Contents of config.log +- Output from 'make' +- Any additional information you think that would be useful. + +If your problem has to do with RUNNING tcpreplay or one of the sub-tools: +- Version information (output of -V) +- Command line used (options and arguments) +- Platform (Red Hat Linux 9 on Intel, Solaris 7 on SPARC, etc) +- Make & model of the network card(s) and driver(s) version +- Error message (if available) and/or description of problem +- If possible, attach the pcap file used (compressed with bzip2 or gzip + preferred) +- The core dump or backtrace if available +- Detailed description of your problem or what you are trying to accomplish + +Note: The author of tcpreplay primarily uses OS X; hence, if you're reporting +an issue on another platform, it is important that you give very detailed +information as I may not be able to reproduce your issue. + +You are also strongly encouraged to read the extensive documentation (man +pages, FAQ, documents in /docs and email list archives) BEFORE posting to the +tcpreplay-users email list: + +http://lists.sourceforge.net/lists/listinfo/tcpreplay-users + +Lastly, please don't email the author directly with your questions. Doing so +prevents others from potentially helping you and your question/answer from +showing up in the list archives. + +Thanks, +Aaron (tcpreplay author) + +PS: +This product includes software developed by the University of +California, Berkeley, Lawrence Berkeley Laboratory and its contributors. diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 0000000..5c1d74b --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,9013 @@ +# generated automatically by aclocal 1.11.1 -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.65],, +[m4_warning([this file was generated for autoconf 2.65. +You have another version of autoconf. It may work, but is not guaranteed to. +If you have problems, you may need to regenerate the build system entirely. +To do so, use the procedure documented by the package, typically `autoreconf'.])]) + +# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, +# 2006, 2007, 2008 Free Software Foundation, Inc. +# Written by Gordon Matzigkeit, 1996 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +m4_define([_LT_COPYING], [dnl +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, +# 2006, 2007, 2008 Free Software Foundation, Inc. +# Written by Gordon Matzigkeit, 1996 +# +# This file is part of GNU Libtool. +# +# GNU Libtool is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# As a special exception to the GNU General Public License, +# if you distribute this file as part of a program or library that +# is built using GNU Libtool, you may include this file under the +# same distribution terms that you use for the rest of that program. +# +# GNU Libtool is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Libtool; see the file COPYING. If not, a copy +# can be downloaded from http://www.gnu.org/licenses/gpl.html, or +# obtained by writing to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +]) + +# serial 56 LT_INIT + + +# LT_PREREQ(VERSION) +# ------------------ +# Complain and exit if this libtool version is less that VERSION. +m4_defun([LT_PREREQ], +[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, + [m4_default([$3], + [m4_fatal([Libtool version $1 or higher is required], + 63)])], + [$2])]) + + +# _LT_CHECK_BUILDDIR +# ------------------ +# Complain if the absolute build directory name contains unusual characters +m4_defun([_LT_CHECK_BUILDDIR], +[case `pwd` in + *\ * | *\ *) + AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; +esac +]) + + +# LT_INIT([OPTIONS]) +# ------------------ +AC_DEFUN([LT_INIT], +[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT +AC_BEFORE([$0], [LT_LANG])dnl +AC_BEFORE([$0], [LT_OUTPUT])dnl +AC_BEFORE([$0], [LTDL_INIT])dnl +m4_require([_LT_CHECK_BUILDDIR])dnl + +dnl Autoconf doesn't catch unexpanded LT_ macros by default: +m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl +m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl +dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 +dnl unless we require an AC_DEFUNed macro: +AC_REQUIRE([LTOPTIONS_VERSION])dnl +AC_REQUIRE([LTSUGAR_VERSION])dnl +AC_REQUIRE([LTVERSION_VERSION])dnl +AC_REQUIRE([LTOBSOLETE_VERSION])dnl +m4_require([_LT_PROG_LTMAIN])dnl + +dnl Parse OPTIONS +_LT_SET_OPTIONS([$0], [$1]) + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ltmain" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +_LT_SETUP + +# Only expand once: +m4_define([LT_INIT]) +])# LT_INIT + +# Old names: +AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) +AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_PROG_LIBTOOL], []) +dnl AC_DEFUN([AM_PROG_LIBTOOL], []) + + +# _LT_CC_BASENAME(CC) +# ------------------- +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +m4_defun([_LT_CC_BASENAME], +[for cc_temp in $1""; do + case $cc_temp in + compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; + distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` +]) + + +# _LT_FILEUTILS_DEFAULTS +# ---------------------- +# It is okay to use these file commands and assume they have been set +# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. +m4_defun([_LT_FILEUTILS_DEFAULTS], +[: ${CP="cp -f"} +: ${MV="mv -f"} +: ${RM="rm -f"} +])# _LT_FILEUTILS_DEFAULTS + + +# _LT_SETUP +# --------- +m4_defun([_LT_SETUP], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +_LT_DECL([], [host_alias], [0], [The host system])dnl +_LT_DECL([], [host], [0])dnl +_LT_DECL([], [host_os], [0])dnl +dnl +_LT_DECL([], [build_alias], [0], [The build system])dnl +_LT_DECL([], [build], [0])dnl +_LT_DECL([], [build_os], [0])dnl +dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([LT_PATH_LD])dnl +AC_REQUIRE([LT_PATH_NM])dnl +dnl +AC_REQUIRE([AC_PROG_LN_S])dnl +test -z "$LN_S" && LN_S="ln -s" +_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl +dnl +AC_REQUIRE([LT_CMD_MAX_LEN])dnl +_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl +_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl +dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_CHECK_SHELL_FEATURES])dnl +m4_require([_LT_CMD_RELOAD])dnl +m4_require([_LT_CHECK_MAGIC_METHOD])dnl +m4_require([_LT_CMD_OLD_ARCHIVE])dnl +m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl + +_LT_CONFIG_LIBTOOL_INIT([ +# See if we are running on zsh, and set the options which allow our +# commands through without removal of \ escapes INIT. +if test -n "\${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST +fi +]) +if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST +fi + +_LT_CHECK_OBJDIR + +m4_require([_LT_TAG_COMPILER])dnl +_LT_PROG_ECHO_BACKSLASH + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\([["`\\]]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to delay expansion of an escaped single quote. +delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' + +# Global variables: +ofile=libtool +can_build_shared=yes + +# All known linkers require a `.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a + +with_gnu_ld="$lt_cv_prog_gnu_ld" + +old_CC="$CC" +old_CFLAGS="$CFLAGS" + +# Set sane defaults for various variables +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS +test -z "$LD" && LD=ld +test -z "$ac_objext" && ac_objext=o + +_LT_CC_BASENAME([$compiler]) + +# Only perform the check for file, if the check method requires it +test -z "$MAGIC_CMD" && MAGIC_CMD=file +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + _LT_PATH_MAGIC + fi + ;; +esac + +# Use C for the default configuration in the libtool script +LT_SUPPORTED_TAG([CC]) +_LT_LANG_C_CONFIG +_LT_LANG_DEFAULT_CONFIG +_LT_CONFIG_COMMANDS +])# _LT_SETUP + + +# _LT_PROG_LTMAIN +# --------------- +# Note that this code is called both from `configure', and `config.status' +# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, +# `config.status' has no value for ac_aux_dir unless we are using Automake, +# so we pass a copy along to make sure it has a sensible value anyway. +m4_defun([_LT_PROG_LTMAIN], +[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl +_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) +ltmain="$ac_aux_dir/ltmain.sh" +])# _LT_PROG_LTMAIN + + + +# So that we can recreate a full libtool script including additional +# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS +# in macros and then make a single call at the end using the `libtool' +# label. + + +# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) +# ---------------------------------------- +# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. +m4_define([_LT_CONFIG_LIBTOOL_INIT], +[m4_ifval([$1], + [m4_append([_LT_OUTPUT_LIBTOOL_INIT], + [$1 +])])]) + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_INIT]) + + +# _LT_CONFIG_LIBTOOL([COMMANDS]) +# ------------------------------ +# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. +m4_define([_LT_CONFIG_LIBTOOL], +[m4_ifval([$1], + [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], + [$1 +])])]) + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) + + +# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) +# ----------------------------------------------------- +m4_defun([_LT_CONFIG_SAVE_COMMANDS], +[_LT_CONFIG_LIBTOOL([$1]) +_LT_CONFIG_LIBTOOL_INIT([$2]) +]) + + +# _LT_FORMAT_COMMENT([COMMENT]) +# ----------------------------- +# Add leading comment marks to the start of each line, and a trailing +# full-stop to the whole comment if one is not present already. +m4_define([_LT_FORMAT_COMMENT], +[m4_ifval([$1], [ +m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], + [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) +)]) + + + + + +# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) +# ------------------------------------------------------------------- +# CONFIGNAME is the name given to the value in the libtool script. +# VARNAME is the (base) name used in the configure script. +# VALUE may be 0, 1 or 2 for a computed quote escaped value based on +# VARNAME. Any other value will be used directly. +m4_define([_LT_DECL], +[lt_if_append_uniq([lt_decl_varnames], [$2], [, ], + [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], + [m4_ifval([$1], [$1], [$2])]) + lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) + m4_ifval([$4], + [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) + lt_dict_add_subkey([lt_decl_dict], [$2], + [tagged?], [m4_ifval([$5], [yes], [no])])]) +]) + + +# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) +# -------------------------------------------------------- +m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) + + +# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) +# ------------------------------------------------ +m4_define([lt_decl_tag_varnames], +[_lt_decl_filter([tagged?], [yes], $@)]) + + +# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) +# --------------------------------------------------------- +m4_define([_lt_decl_filter], +[m4_case([$#], + [0], [m4_fatal([$0: too few arguments: $#])], + [1], [m4_fatal([$0: too few arguments: $#: $1])], + [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], + [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], + [lt_dict_filter([lt_decl_dict], $@)])[]dnl +]) + + +# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) +# -------------------------------------------------- +m4_define([lt_decl_quote_varnames], +[_lt_decl_filter([value], [1], $@)]) + + +# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) +# --------------------------------------------------- +m4_define([lt_decl_dquote_varnames], +[_lt_decl_filter([value], [2], $@)]) + + +# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) +# --------------------------------------------------- +m4_define([lt_decl_varnames_tagged], +[m4_assert([$# <= 2])dnl +_$0(m4_quote(m4_default([$1], [[, ]])), + m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), + m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) +m4_define([_lt_decl_varnames_tagged], +[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) + + +# lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) +# ------------------------------------------------ +m4_define([lt_decl_all_varnames], +[_$0(m4_quote(m4_default([$1], [[, ]])), + m4_if([$2], [], + m4_quote(lt_decl_varnames), + m4_quote(m4_shift($@))))[]dnl +]) +m4_define([_lt_decl_all_varnames], +[lt_join($@, lt_decl_varnames_tagged([$1], + lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl +]) + + +# _LT_CONFIG_STATUS_DECLARE([VARNAME]) +# ------------------------------------ +# Quote a variable value, and forward it to `config.status' so that its +# declaration there will have the same value as in `configure'. VARNAME +# must have a single quote delimited value for this to work. +m4_define([_LT_CONFIG_STATUS_DECLARE], +[$1='`$ECHO "X$][$1" | $Xsed -e "$delay_single_quote_subst"`']) + + +# _LT_CONFIG_STATUS_DECLARATIONS +# ------------------------------ +# We delimit libtool config variables with single quotes, so when +# we write them to config.status, we have to be sure to quote all +# embedded single quotes properly. In configure, this macro expands +# each variable declared with _LT_DECL (and _LT_TAGDECL) into: +# +# ='`$ECHO "X$" | $Xsed -e "$delay_single_quote_subst"`' +m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], +[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), + [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) + + +# _LT_LIBTOOL_TAGS +# ---------------- +# Output comment and list of tags supported by the script +m4_defun([_LT_LIBTOOL_TAGS], +[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl +available_tags="_LT_TAGS"dnl +]) + + +# _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) +# ----------------------------------- +# Extract the dictionary values for VARNAME (optionally with TAG) and +# expand to a commented shell variable setting: +# +# # Some comment about what VAR is for. +# visible_name=$lt_internal_name +m4_define([_LT_LIBTOOL_DECLARE], +[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], + [description])))[]dnl +m4_pushdef([_libtool_name], + m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl +m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), + [0], [_libtool_name=[$]$1], + [1], [_libtool_name=$lt_[]$1], + [2], [_libtool_name=$lt_[]$1], + [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl +m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl +]) + + +# _LT_LIBTOOL_CONFIG_VARS +# ----------------------- +# Produce commented declarations of non-tagged libtool config variables +# suitable for insertion in the LIBTOOL CONFIG section of the `libtool' +# script. Tagged libtool config variables (even for the LIBTOOL CONFIG +# section) are produced by _LT_LIBTOOL_TAG_VARS. +m4_defun([_LT_LIBTOOL_CONFIG_VARS], +[m4_foreach([_lt_var], + m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), + [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) + + +# _LT_LIBTOOL_TAG_VARS(TAG) +# ------------------------- +m4_define([_LT_LIBTOOL_TAG_VARS], +[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), + [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) + + +# _LT_TAGVAR(VARNAME, [TAGNAME]) +# ------------------------------ +m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) + + +# _LT_CONFIG_COMMANDS +# ------------------- +# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of +# variables for single and double quote escaping we saved from calls +# to _LT_DECL, we can put quote escaped variables declarations +# into `config.status', and then the shell code to quote escape them in +# for loops in `config.status'. Finally, any additional code accumulated +# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. +m4_defun([_LT_CONFIG_COMMANDS], +[AC_PROVIDE_IFELSE([LT_OUTPUT], + dnl If the libtool generation code has been placed in $CONFIG_LT, + dnl instead of duplicating it all over again into config.status, + dnl then we will have config.status run $CONFIG_LT later, so it + dnl needs to know what name is stored there: + [AC_CONFIG_COMMANDS([libtool], + [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], + dnl If the libtool generation code is destined for config.status, + dnl expand the accumulated commands and init code now: + [AC_CONFIG_COMMANDS([libtool], + [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) +])#_LT_CONFIG_COMMANDS + + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], +[ + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +sed_quote_subst='$sed_quote_subst' +double_quote_subst='$double_quote_subst' +delay_variable_subst='$delay_variable_subst' +_LT_CONFIG_STATUS_DECLARATIONS +LTCC='$LTCC' +LTCFLAGS='$LTCFLAGS' +compiler='$compiler_DEFAULT' + +# Quote evaled strings. +for var in lt_decl_all_varnames([[ \ +]], lt_decl_quote_varnames); do + case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in + *[[\\\\\\\`\\"\\\$]]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +# Double-quote double-evaled strings. +for var in lt_decl_all_varnames([[ \ +]], lt_decl_dquote_varnames); do + case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in + *[[\\\\\\\`\\"\\\$]]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +# Fix-up fallback echo if it was mangled by the above quoting rules. +case \$lt_ECHO in +*'\\\[$]0 --fallback-echo"')dnl " + lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\[$]0 --fallback-echo"\[$]/\[$]0 --fallback-echo"/'\` + ;; +esac + +_LT_OUTPUT_LIBTOOL_INIT +]) + + +# LT_OUTPUT +# --------- +# This macro allows early generation of the libtool script (before +# AC_OUTPUT is called), incase it is used in configure for compilation +# tests. +AC_DEFUN([LT_OUTPUT], +[: ${CONFIG_LT=./config.lt} +AC_MSG_NOTICE([creating $CONFIG_LT]) +cat >"$CONFIG_LT" <<_LTEOF +#! $SHELL +# Generated by $as_me. +# Run this file to recreate a libtool stub with the current configuration. + +lt_cl_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_LTEOF + +cat >>"$CONFIG_LT" <<\_LTEOF +AS_SHELL_SANITIZE +_AS_PREPARE + +exec AS_MESSAGE_FD>&1 +exec AS_MESSAGE_LOG_FD>>config.log +{ + echo + AS_BOX([Running $as_me.]) +} >&AS_MESSAGE_LOG_FD + +lt_cl_help="\ +\`$as_me' creates a local libtool stub from the current configuration, +for use in further configure time tests before the real libtool is +generated. + +Usage: $[0] [[OPTIONS]] + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + +Report bugs to ." + +lt_cl_version="\ +m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl +m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) +configured by $[0], generated by m4_PACKAGE_STRING. + +Copyright (C) 2008 Free Software Foundation, Inc. +This config.lt script is free software; the Free Software Foundation +gives unlimited permision to copy, distribute and modify it." + +while test $[#] != 0 +do + case $[1] in + --version | --v* | -V ) + echo "$lt_cl_version"; exit 0 ;; + --help | --h* | -h ) + echo "$lt_cl_help"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --quiet | --q* | --silent | --s* | -q ) + lt_cl_silent=: ;; + + -*) AC_MSG_ERROR([unrecognized option: $[1] +Try \`$[0] --help' for more information.]) ;; + + *) AC_MSG_ERROR([unrecognized argument: $[1] +Try \`$[0] --help' for more information.]) ;; + esac + shift +done + +if $lt_cl_silent; then + exec AS_MESSAGE_FD>/dev/null +fi +_LTEOF + +cat >>"$CONFIG_LT" <<_LTEOF +_LT_OUTPUT_LIBTOOL_COMMANDS_INIT +_LTEOF + +cat >>"$CONFIG_LT" <<\_LTEOF +AC_MSG_NOTICE([creating $ofile]) +_LT_OUTPUT_LIBTOOL_COMMANDS +AS_EXIT(0) +_LTEOF +chmod +x "$CONFIG_LT" + +# configure is writing to config.log, but config.lt does its own redirection, +# appending to config.log, which fails on DOS, as config.log is still kept +# open by configure. Here we exec the FD to /dev/null, effectively closing +# config.log, so it can be properly (re)opened and appended to by config.lt. +if test "$no_create" != yes; then + lt_cl_success=: + test "$silent" = yes && + lt_config_lt_args="$lt_config_lt_args --quiet" + exec AS_MESSAGE_LOG_FD>/dev/null + $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false + exec AS_MESSAGE_LOG_FD>>config.log + $lt_cl_success || AS_EXIT(1) +fi +])# LT_OUTPUT + + +# _LT_CONFIG(TAG) +# --------------- +# If TAG is the built-in tag, create an initial libtool script with a +# default configuration from the untagged config vars. Otherwise add code +# to config.status for appending the configuration named by TAG from the +# matching tagged config vars. +m4_defun([_LT_CONFIG], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +_LT_CONFIG_SAVE_COMMANDS([ + m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl + m4_if(_LT_TAG, [C], [ + # See if we are running on zsh, and set the options which allow our + # commands through without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + + cfgfile="${ofile}T" + trap "$RM \"$cfgfile\"; exit 1" 1 2 15 + $RM "$cfgfile" + + cat <<_LT_EOF >> "$cfgfile" +#! $SHELL + +# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# NOTE: Changes made to this file will be lost: look at ltmain.sh. +# +_LT_COPYING +_LT_LIBTOOL_TAGS + +# ### BEGIN LIBTOOL CONFIG +_LT_LIBTOOL_CONFIG_VARS +_LT_LIBTOOL_TAG_VARS +# ### END LIBTOOL CONFIG + +_LT_EOF + + case $host_os in + aix3*) + cat <<\_LT_EOF >> "$cfgfile" +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +_LT_EOF + ;; + esac + + _LT_PROG_LTMAIN + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + _LT_PROG_XSI_SHELLFNS + + sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" +], +[cat <<_LT_EOF >> "$ofile" + +dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded +dnl in a comment (ie after a #). +# ### BEGIN LIBTOOL TAG CONFIG: $1 +_LT_LIBTOOL_TAG_VARS(_LT_TAG) +# ### END LIBTOOL TAG CONFIG: $1 +_LT_EOF +])dnl /m4_if +], +[m4_if([$1], [], [ + PACKAGE='$PACKAGE' + VERSION='$VERSION' + TIMESTAMP='$TIMESTAMP' + RM='$RM' + ofile='$ofile'], []) +])dnl /_LT_CONFIG_SAVE_COMMANDS +])# _LT_CONFIG + + +# LT_SUPPORTED_TAG(TAG) +# --------------------- +# Trace this macro to discover what tags are supported by the libtool +# --tag option, using: +# autoconf --trace 'LT_SUPPORTED_TAG:$1' +AC_DEFUN([LT_SUPPORTED_TAG], []) + + +# C support is built-in for now +m4_define([_LT_LANG_C_enabled], []) +m4_define([_LT_TAGS], []) + + +# LT_LANG(LANG) +# ------------- +# Enable libtool support for the given language if not already enabled. +AC_DEFUN([LT_LANG], +[AC_BEFORE([$0], [LT_OUTPUT])dnl +m4_case([$1], + [C], [_LT_LANG(C)], + [C++], [_LT_LANG(CXX)], + [Java], [_LT_LANG(GCJ)], + [Fortran 77], [_LT_LANG(F77)], + [Fortran], [_LT_LANG(FC)], + [Windows Resource], [_LT_LANG(RC)], + [m4_ifdef([_LT_LANG_]$1[_CONFIG], + [_LT_LANG($1)], + [m4_fatal([$0: unsupported language: "$1"])])])dnl +])# LT_LANG + + +# _LT_LANG(LANGNAME) +# ------------------ +m4_defun([_LT_LANG], +[m4_ifdef([_LT_LANG_]$1[_enabled], [], + [LT_SUPPORTED_TAG([$1])dnl + m4_append([_LT_TAGS], [$1 ])dnl + m4_define([_LT_LANG_]$1[_enabled], [])dnl + _LT_LANG_$1_CONFIG($1)])dnl +])# _LT_LANG + + +# _LT_LANG_DEFAULT_CONFIG +# ----------------------- +m4_defun([_LT_LANG_DEFAULT_CONFIG], +[AC_PROVIDE_IFELSE([AC_PROG_CXX], + [LT_LANG(CXX)], + [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) + +AC_PROVIDE_IFELSE([AC_PROG_F77], + [LT_LANG(F77)], + [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) + +AC_PROVIDE_IFELSE([AC_PROG_FC], + [LT_LANG(FC)], + [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) + +dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal +dnl pulling things in needlessly. +AC_PROVIDE_IFELSE([AC_PROG_GCJ], + [LT_LANG(GCJ)], + [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], + [LT_LANG(GCJ)], + [AC_PROVIDE_IFELSE([LT_PROG_GCJ], + [LT_LANG(GCJ)], + [m4_ifdef([AC_PROG_GCJ], + [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) + m4_ifdef([A][M_PROG_GCJ], + [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) + m4_ifdef([LT_PROG_GCJ], + [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) + +AC_PROVIDE_IFELSE([LT_PROG_RC], + [LT_LANG(RC)], + [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) +])# _LT_LANG_DEFAULT_CONFIG + +# Obsolete macros: +AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) +AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) +AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) +AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_CXX], []) +dnl AC_DEFUN([AC_LIBTOOL_F77], []) +dnl AC_DEFUN([AC_LIBTOOL_FC], []) +dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) + + +# _LT_TAG_COMPILER +# ---------------- +m4_defun([_LT_TAG_COMPILER], +[AC_REQUIRE([AC_PROG_CC])dnl + +_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl +_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl +_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl +_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC +])# _LT_TAG_COMPILER + + +# _LT_COMPILER_BOILERPLATE +# ------------------------ +# Check for compiler boilerplate output or warnings with +# the simple compiler test code. +m4_defun([_LT_COMPILER_BOILERPLATE], +[m4_require([_LT_DECL_SED])dnl +ac_outfile=conftest.$ac_objext +echo "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$RM conftest* +])# _LT_COMPILER_BOILERPLATE + + +# _LT_LINKER_BOILERPLATE +# ---------------------- +# Check for linker boilerplate output or warnings with +# the simple link test code. +m4_defun([_LT_LINKER_BOILERPLATE], +[m4_require([_LT_DECL_SED])dnl +ac_outfile=conftest.$ac_objext +echo "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$RM -r conftest* +])# _LT_LINKER_BOILERPLATE + +# _LT_REQUIRED_DARWIN_CHECKS +# ------------------------- +m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ + case $host_os in + rhapsody* | darwin*) + AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) + AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) + AC_CHECK_TOOL([LIPO], [lipo], [:]) + AC_CHECK_TOOL([OTOOL], [otool], [:]) + AC_CHECK_TOOL([OTOOL64], [otool64], [:]) + _LT_DECL([], [DSYMUTIL], [1], + [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) + _LT_DECL([], [NMEDIT], [1], + [Tool to change global to local symbols on Mac OS X]) + _LT_DECL([], [LIPO], [1], + [Tool to manipulate fat objects and archives on Mac OS X]) + _LT_DECL([], [OTOOL], [1], + [ldd/readelf like tool for Mach-O binaries on Mac OS X]) + _LT_DECL([], [OTOOL64], [1], + [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) + + AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], + [lt_cv_apple_cc_single_mod=no + if test -z "${LT_MULTI_MODULE}"; then + # By default we will add the -single_module flag. You can override + # by either setting the environment variable LT_MULTI_MODULE + # non-empty at configure time, or by adding -multi_module to the + # link flags. + rm -rf libconftest.dylib* + echo "int foo(void){return 1;}" > conftest.c + echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ +-dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD + $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ + -dynamiclib -Wl,-single_module conftest.c 2>conftest.err + _lt_result=$? + if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then + lt_cv_apple_cc_single_mod=yes + else + cat conftest.err >&AS_MESSAGE_LOG_FD + fi + rm -rf libconftest.dylib* + rm -f conftest.* + fi]) + AC_CACHE_CHECK([for -exported_symbols_list linker flag], + [lt_cv_ld_exported_symbols_list], + [lt_cv_ld_exported_symbols_list=no + save_LDFLAGS=$LDFLAGS + echo "_main" > conftest.sym + LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [lt_cv_ld_exported_symbols_list=yes], + [lt_cv_ld_exported_symbols_list=no]) + LDFLAGS="$save_LDFLAGS" + ]) + case $host_os in + rhapsody* | darwin1.[[012]]) + _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; + darwin1.*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + darwin*) # darwin 5.x on + # if running on 10.5 or later, the deployment target defaults + # to the OS version, if on x86, and 10.4, the deployment + # target defaults to 10.4. Don't you love it? + case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in + 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + 10.[[012]]*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + 10.*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + esac + ;; + esac + if test "$lt_cv_apple_cc_single_mod" = "yes"; then + _lt_dar_single_mod='$single_module' + fi + if test "$lt_cv_ld_exported_symbols_list" = "yes"; then + _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' + else + _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' + fi + if test "$DSYMUTIL" != ":"; then + _lt_dsymutil='~$DSYMUTIL $lib || :' + else + _lt_dsymutil= + fi + ;; + esac +]) + + +# _LT_DARWIN_LINKER_FEATURES +# -------------------------- +# Checks for linker and compiler features on darwin +m4_defun([_LT_DARWIN_LINKER_FEATURES], +[ + m4_require([_LT_REQUIRED_DARWIN_CHECKS]) + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_automatic, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_TAGVAR(whole_archive_flag_spec, $1)='' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" + case $cc_basename in + ifort*) _lt_dar_can_shared=yes ;; + *) _lt_dar_can_shared=$GCC ;; + esac + if test "$_lt_dar_can_shared" = "yes"; then + output_verbose_link_cmd=echo + _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" + _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" + _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" + _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" + m4_if([$1], [CXX], +[ if test "$lt_cv_apple_cc_single_mod" != "yes"; then + _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" + _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" + fi +],[]) + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi +]) + +# _LT_SYS_MODULE_PATH_AIX +# ----------------------- +# Links a minimal program and checks the executable +# for the system default hardcoded library path. In most cases, +# this is /usr/lib:/lib, but when the MPI compilers are used +# the location of the communication and MPI libs are included too. +# If we don't find anything, use the default library path according +# to the aix ld manual. +m4_defun([_LT_SYS_MODULE_PATH_AIX], +[m4_require([_LT_DECL_SED])dnl +AC_LINK_IFELSE(AC_LANG_PROGRAM,[ +lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\(.*\)$/\1/ + p + } + }' +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +fi],[]) +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +])# _LT_SYS_MODULE_PATH_AIX + + +# _LT_SHELL_INIT(ARG) +# ------------------- +m4_define([_LT_SHELL_INIT], +[ifdef([AC_DIVERSION_NOTICE], + [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], + [AC_DIVERT_PUSH(NOTICE)]) +$1 +AC_DIVERT_POP +])# _LT_SHELL_INIT + + +# _LT_PROG_ECHO_BACKSLASH +# ----------------------- +# Add some code to the start of the generated configure script which +# will find an echo command which doesn't interpret backslashes. +m4_defun([_LT_PROG_ECHO_BACKSLASH], +[_LT_SHELL_INIT([ +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} + +case X$lt_ECHO in +X*--fallback-echo) + # Remove one level of quotation (which was required for Make). + ECHO=`echo "$lt_ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` + ;; +esac + +ECHO=${lt_ECHO-echo} +if test "X[$]1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X[$]1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then + # Yippee, $ECHO works! + : +else + # Restart under the correct shell. + exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} +fi + +if test "X[$]1" = X--fallback-echo; then + # used as fallback echo + shift + cat <<_LT_EOF +[$]* +_LT_EOF + exit 0 +fi + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +if test -z "$lt_ECHO"; then + if test "X${echo_test_string+set}" != Xset; then + # find a string as large as possible, as long as the shell can cope with it + for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do + # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... + if { echo_test_string=`eval $cmd`; } 2>/dev/null && + { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null + then + break + fi + done + fi + + if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + : + else + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for dir in $PATH /usr/ucb; do + IFS="$lt_save_ifs" + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + ECHO="$dir/echo" + break + fi + done + IFS="$lt_save_ifs" + + if test "X$ECHO" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # This shell has a builtin print -r that does the trick. + ECHO='print -r' + elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running configure again with it. + ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} + else + # Try using printf. + ECHO='printf %s\n' + if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # Cool, printf works + : + elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + ECHO="$CONFIG_SHELL [$]0 --fallback-echo" + elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + ECHO="$CONFIG_SHELL [$]0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do + if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null + then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "[$]0"'; then + echo_test_string=`eval $prev` + export echo_test_string + exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} + else + # Oops. We lost completely, so just stick with echo. + ECHO=echo + fi + fi + fi + fi + fi +fi + +# Copy echo and quote the copy suitably for passing to libtool from +# the Makefile, instead of quoting the original, which is used later. +lt_ECHO=$ECHO +if test "X$lt_ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then + lt_ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" +fi + +AC_SUBST(lt_ECHO) +]) +_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) +_LT_DECL([], [ECHO], [1], + [An echo program that does not interpret backslashes]) +])# _LT_PROG_ECHO_BACKSLASH + + +# _LT_ENABLE_LOCK +# --------------- +m4_defun([_LT_ENABLE_LOCK], +[AC_ARG_ENABLE([libtool-lock], + [AS_HELP_STRING([--disable-libtool-lock], + [avoid locking (might break parallel builds)])]) +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE="32" + ;; + *ELF-64*) + HPUX_IA64_MODE="64" + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out which ABI we are using. + echo '[#]line __oline__ "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + if test "$lt_cv_prog_gnu_ld" = yes; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ +s390*-*linux*|s390*-*tpf*|sparc*-*linux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.o` in + *32-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_i386_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_i386" + ;; + ppc64-*linux*|powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_x86_64_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + ppc*-*linux*|powerpc*-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*|s390*-*tpf*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, + [AC_LANG_PUSH(C) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) + AC_LANG_POP]) + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; +sparc*-*solaris*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.o` in + *64-bit*) + case $lt_cv_prog_gnu_ld in + yes*) LD="${LD-ld} -m elf64_sparc" ;; + *) + if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then + LD="${LD-ld} -64" + fi + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; +esac + +need_locks="$enable_libtool_lock" +])# _LT_ENABLE_LOCK + + +# _LT_CMD_OLD_ARCHIVE +# ------------------- +m4_defun([_LT_CMD_OLD_ARCHIVE], +[AC_CHECK_TOOL(AR, ar, false) +test -z "$AR" && AR=ar +test -z "$AR_FLAGS" && AR_FLAGS=cru +_LT_DECL([], [AR], [1], [The archiver]) +_LT_DECL([], [AR_FLAGS], [1]) + +AC_CHECK_TOOL(STRIP, strip, :) +test -z "$STRIP" && STRIP=: +_LT_DECL([], [STRIP], [1], [A symbol stripping program]) + +AC_CHECK_TOOL(RANLIB, ranlib, :) +test -z "$RANLIB" && RANLIB=: +_LT_DECL([], [RANLIB], [1], + [Commands used to install an old-style archive]) + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + openbsd*) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" + ;; + *) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" +fi +_LT_DECL([], [old_postinstall_cmds], [2]) +_LT_DECL([], [old_postuninstall_cmds], [2]) +_LT_TAGDECL([], [old_archive_cmds], [2], + [Commands used to build an old-style archive]) +])# _LT_CMD_OLD_ARCHIVE + + +# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------------------- +# Check whether the given compiler option works +AC_DEFUN([_LT_COMPILER_OPTION], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_SED])dnl +AC_CACHE_CHECK([$1], [$2], + [$2=no + m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$3" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + $2=yes + fi + fi + $RM conftest* +]) + +if test x"[$]$2" = xyes; then + m4_if([$5], , :, [$5]) +else + m4_if([$6], , :, [$6]) +fi +])# _LT_COMPILER_OPTION + +# Old name: +AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) + + +# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------- +# Check whether the given linker option works +AC_DEFUN([_LT_LINKER_OPTION], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_SED])dnl +AC_CACHE_CHECK([$1], [$2], + [$2=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $3" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&AS_MESSAGE_LOG_FD + $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + $2=yes + fi + else + $2=yes + fi + fi + $RM -r conftest* + LDFLAGS="$save_LDFLAGS" +]) + +if test x"[$]$2" = xyes; then + m4_if([$4], , :, [$4]) +else + m4_if([$5], , :, [$5]) +fi +])# _LT_LINKER_OPTION + +# Old name: +AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) + + +# LT_CMD_MAX_LEN +#--------------- +AC_DEFUN([LT_CMD_MAX_LEN], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +# find the maximum length of command line arguments +AC_MSG_CHECKING([the maximum length of command line arguments]) +AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl + i=0 + teststring="ABCD" + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw* | cegcc*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` + elif test -x /usr/sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` + else + lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs + fi + # And add a safety zone + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + ;; + + interix*) + # We know the value 262144 and hardcode it with a safety zone (like BSD) + lt_cv_sys_max_cmd_len=196608 + ;; + + osf*) + # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure + # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not + # nice to cause kernel panics so lets avoid the loop below. + # First set a reasonable default. + lt_cv_sys_max_cmd_len=16384 + # + if test -x /sbin/sysconfig; then + case `/sbin/sysconfig -q proc exec_disable_arg_limit` in + *1*) lt_cv_sys_max_cmd_len=-1 ;; + esac + fi + ;; + sco3.2v5*) + lt_cv_sys_max_cmd_len=102400 + ;; + sysv5* | sco5v6* | sysv4.2uw2*) + kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` + if test -n "$kargmax"; then + lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` + else + lt_cv_sys_max_cmd_len=32768 + fi + ;; + *) + lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` + if test -n "$lt_cv_sys_max_cmd_len"; then + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + else + # Make teststring a little bigger before we do anything with it. + # a 1K string should be a reasonable start. + for i in 1 2 3 4 5 6 7 8 ; do + teststring=$teststring$teststring + done + SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} + # If test is not a shell built-in, we'll probably end up computing a + # maximum length that is only half of the actual maximum length, but + # we can't tell. + while { test "X"`$SHELL [$]0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \ + = "XX$teststring$teststring"; } >/dev/null 2>&1 && + test $i != 17 # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + # Only check the string length outside the loop. + lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` + teststring= + # Add a significant safety factor because C++ compilers can tack on + # massive amounts of additional arguments before passing them to the + # linker. It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + fi + ;; + esac +]) +if test -n $lt_cv_sys_max_cmd_len ; then + AC_MSG_RESULT($lt_cv_sys_max_cmd_len) +else + AC_MSG_RESULT(none) +fi +max_cmd_len=$lt_cv_sys_max_cmd_len +_LT_DECL([], [max_cmd_len], [0], + [What is the maximum length of a command?]) +])# LT_CMD_MAX_LEN + +# Old name: +AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) + + +# _LT_HEADER_DLFCN +# ---------------- +m4_defun([_LT_HEADER_DLFCN], +[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl +])# _LT_HEADER_DLFCN + + +# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, +# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) +# ---------------------------------------------------------------- +m4_defun([_LT_TRY_DLOPEN_SELF], +[m4_require([_LT_HEADER_DLFCN])dnl +if test "$cross_compiling" = yes; then : + [$4] +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +[#line __oline__ "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + else + puts (dlerror ()); + + return status; +}] +_LT_EOF + if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) $1 ;; + x$lt_dlneed_uscore) $2 ;; + x$lt_dlunknown|x*) $3 ;; + esac + else : + # compilation failed + $3 + fi +fi +rm -fr conftest* +])# _LT_TRY_DLOPEN_SELF + + +# LT_SYS_DLOPEN_SELF +# ------------------ +AC_DEFUN([LT_SYS_DLOPEN_SELF], +[m4_require([_LT_HEADER_DLFCN])dnl +if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32* | cegcc*) + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen="dlopen" + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ + lt_cv_dlopen="dyld" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ]) + ;; + + *) + AC_CHECK_FUNC([shl_load], + [lt_cv_dlopen="shl_load"], + [AC_CHECK_LIB([dld], [shl_load], + [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], + [AC_CHECK_FUNC([dlopen], + [lt_cv_dlopen="dlopen"], + [AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], + [AC_CHECK_LIB([svld], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], + [AC_CHECK_LIB([dld], [dld_link], + [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) + ]) + ]) + ]) + ]) + ]) + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS="$LDFLAGS" + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS="$LIBS" + LIBS="$lt_cv_dlopen_libs $LIBS" + + AC_CACHE_CHECK([whether a program can dlopen itself], + lt_cv_dlopen_self, [dnl + _LT_TRY_DLOPEN_SELF( + lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, + lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) + ]) + + if test "x$lt_cv_dlopen_self" = xyes; then + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" + AC_CACHE_CHECK([whether a statically linked program can dlopen itself], + lt_cv_dlopen_self_static, [dnl + _LT_TRY_DLOPEN_SELF( + lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, + lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) + ]) + fi + + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi +_LT_DECL([dlopen_support], [enable_dlopen], [0], + [Whether dlopen is supported]) +_LT_DECL([dlopen_self], [enable_dlopen_self], [0], + [Whether dlopen of programs is supported]) +_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], + [Whether dlopen of statically linked programs is supported]) +])# LT_SYS_DLOPEN_SELF + +# Old name: +AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) + + +# _LT_COMPILER_C_O([TAGNAME]) +# --------------------------- +# Check to see if options -c and -o are simultaneously supported by compiler. +# This macro does not hard code the compiler like AC_PROG_CC_C_O. +m4_defun([_LT_COMPILER_C_O], +[m4_require([_LT_DECL_SED])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_TAG_COMPILER])dnl +AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], + [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], + [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + fi + fi + chmod u+w . 2>&AS_MESSAGE_LOG_FD + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* +]) +_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], + [Does compiler simultaneously support -c and -o options?]) +])# _LT_COMPILER_C_O + + +# _LT_COMPILER_FILE_LOCKS([TAGNAME]) +# ---------------------------------- +# Check to see if we can do hard links to lock some files if needed +m4_defun([_LT_COMPILER_FILE_LOCKS], +[m4_require([_LT_ENABLE_LOCK])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +_LT_COMPILER_C_O([$1]) + +hard_links="nottested" +if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + AC_MSG_CHECKING([if we can lock with hard links]) + hard_links=yes + $RM conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + AC_MSG_RESULT([$hard_links]) + if test "$hard_links" = no; then + AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) + need_locks=warn + fi +else + need_locks=no +fi +_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) +])# _LT_COMPILER_FILE_LOCKS + + +# _LT_CHECK_OBJDIR +# ---------------- +m4_defun([_LT_CHECK_OBJDIR], +[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], +[rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null]) +objdir=$lt_cv_objdir +_LT_DECL([], [objdir], [0], + [The name of the directory that contains temporary libtool files])dnl +m4_pattern_allow([LT_OBJDIR])dnl +AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", + [Define to the sub-directory in which libtool stores uninstalled libraries.]) +])# _LT_CHECK_OBJDIR + + +# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) +# -------------------------------------- +# Check hardcoding attributes. +m4_defun([_LT_LINKER_HARDCODE_LIBPATH], +[AC_MSG_CHECKING([how to hardcode library paths into programs]) +_LT_TAGVAR(hardcode_action, $1)= +if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || + test -n "$_LT_TAGVAR(runpath_var, $1)" || + test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then + + # We can hardcode non-existent directories. + if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && + test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then + # Linking always hardcodes the temporary library directory. + _LT_TAGVAR(hardcode_action, $1)=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + _LT_TAGVAR(hardcode_action, $1)=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + _LT_TAGVAR(hardcode_action, $1)=unsupported +fi +AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) + +if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || + test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi +_LT_TAGDECL([], [hardcode_action], [0], + [How to hardcode a shared library path into an executable]) +])# _LT_LINKER_HARDCODE_LIBPATH + + +# _LT_CMD_STRIPLIB +# ---------------- +m4_defun([_LT_CMD_STRIPLIB], +[m4_require([_LT_DECL_EGREP]) +striplib= +old_striplib= +AC_MSG_CHECKING([whether stripping libraries is possible]) +if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + AC_MSG_RESULT([yes]) +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP" ; then + striplib="$STRIP -x" + old_striplib="$STRIP -S" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + ;; + *) + AC_MSG_RESULT([no]) + ;; + esac +fi +_LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) +_LT_DECL([], [striplib], [1]) +])# _LT_CMD_STRIPLIB + + +# _LT_SYS_DYNAMIC_LINKER([TAG]) +# ----------------------------- +# PORTME Fill in your ld.so characteristics +m4_defun([_LT_SYS_DYNAMIC_LINKER], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_OBJDUMP])dnl +m4_require([_LT_DECL_SED])dnl +AC_MSG_CHECKING([dynamic linker characteristics]) +m4_if([$1], + [], [ +if test "$GCC" = yes; then + case $host_os in + darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; + *) lt_awk_arg="/^libraries:/" ;; + esac + lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'` + else + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + # Ok, now we have the path, separated by spaces, we can step through it + # and add multilib dir if necessary. + lt_tmp_lt_search_path_spec= + lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + for lt_sys_path in $lt_search_path_spec; do + if test -d "$lt_sys_path/$lt_multi_os_dir"; then + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" + else + test -d "$lt_sys_path" && \ + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" + fi + done + lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk ' +BEGIN {RS=" "; FS="/|\n";} { + lt_foo=""; + lt_count=0; + for (lt_i = NF; lt_i > 0; lt_i--) { + if ($lt_i != "" && $lt_i != ".") { + if ($lt_i == "..") { + lt_count++; + } else { + if (lt_count == 0) { + lt_foo="/" $lt_i lt_foo; + } else { + lt_count--; + } + } + } + } + if (lt_foo != "") { lt_freq[[lt_foo]]++; } + if (lt_freq[[lt_foo]] == 1) { print lt_foo; } +}'` + sys_lib_search_path_spec=`$ECHO $lt_search_path_spec` +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi]) +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix[[4-9]]*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[[01]] | aix4.[[01]].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + case $host_cpu in + powerpc) + # Since July 2007 AmigaOS4 officially supports .so libraries. + # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + ;; + m68k) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + esac + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[[45]]*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32* | cegcc*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw* | cegcc*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' +m4_if([$1], [],[ + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[[123]]*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[[01]]* | freebsdelf3.[[01]]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ + freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + *) # from 4.6 on, and DragonFly + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +interix[[3-9]]*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux* | k*bsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # Some binutils ld are patched to set DT_RUNPATH + save_LDFLAGS=$LDFLAGS + save_libdir=$libdir + eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ + LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], + [shlibpath_overrides_runpath=yes])]) + LDFLAGS=$save_LDFLAGS + libdir=$save_libdir + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +*nto* | *qnx*) + version_type=qnx + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='ldqnx.so' + ;; + +openbsd*) + version_type=sunos + sys_lib_dlsearch_path_spec="/usr/lib" + need_lib_prefix=no + # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. + case $host_os in + openbsd3.3 | openbsd3.3.*) need_version=yes ;; + *) need_version=no ;; + esac + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[[89]] | openbsd2.[[89]].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +rdos*) + dynamic_linker=no + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=freebsd-elf + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + if test "$with_gnu_ld" = yes; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +tpf*) + # TPF is a cross-target only. Preferred cross-host = GNU/Linux. + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +AC_MSG_RESULT([$dynamic_linker]) +test "$dynamic_linker" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then + sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" +fi +if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then + sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" +fi + +_LT_DECL([], [variables_saved_for_relink], [1], + [Variables whose values should be saved in libtool wrapper scripts and + restored at link time]) +_LT_DECL([], [need_lib_prefix], [0], + [Do we need the "lib" prefix for modules?]) +_LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) +_LT_DECL([], [version_type], [0], [Library versioning type]) +_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) +_LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) +_LT_DECL([], [shlibpath_overrides_runpath], [0], + [Is shlibpath searched before the hard-coded library search path?]) +_LT_DECL([], [libname_spec], [1], [Format of library name prefix]) +_LT_DECL([], [library_names_spec], [1], + [[List of archive names. First name is the real one, the rest are links. + The last name is the one that the linker finds with -lNAME]]) +_LT_DECL([], [soname_spec], [1], + [[The coded name of the library, if different from the real name]]) +_LT_DECL([], [postinstall_cmds], [2], + [Command to use after installation of a shared archive]) +_LT_DECL([], [postuninstall_cmds], [2], + [Command to use after uninstallation of a shared archive]) +_LT_DECL([], [finish_cmds], [2], + [Commands used to finish a libtool library installation in a directory]) +_LT_DECL([], [finish_eval], [1], + [[As "finish_cmds", except a single script fragment to be evaled but + not shown]]) +_LT_DECL([], [hardcode_into_libs], [0], + [Whether we should hardcode library paths into libraries]) +_LT_DECL([], [sys_lib_search_path_spec], [2], + [Compile-time system search path for libraries]) +_LT_DECL([], [sys_lib_dlsearch_path_spec], [2], + [Run-time system search path for libraries]) +])# _LT_SYS_DYNAMIC_LINKER + + +# _LT_PATH_TOOL_PREFIX(TOOL) +# -------------------------- +# find a file program which can recognize shared library +AC_DEFUN([_LT_PATH_TOOL_PREFIX], +[m4_require([_LT_DECL_EGREP])dnl +AC_MSG_CHECKING([for $1]) +AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, +[case $MAGIC_CMD in +[[\\/*] | ?:[\\/]*]) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR +dnl $ac_dummy forces splitting on constant user-supplied paths. +dnl POSIX.2 word splitting is done only on the output of word expansions, +dnl not every word. This closes a longstanding sh security hole. + ac_dummy="m4_if([$2], , $PATH, [$2])" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$1; then + lt_cv_path_MAGIC_CMD="$ac_dir/$1" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<_LT_EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +_LT_EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac]) +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + AC_MSG_RESULT($MAGIC_CMD) +else + AC_MSG_RESULT(no) +fi +_LT_DECL([], [MAGIC_CMD], [0], + [Used to examine libraries when file_magic_cmd begins with "file"])dnl +])# _LT_PATH_TOOL_PREFIX + +# Old name: +AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) + + +# _LT_PATH_MAGIC +# -------------- +# find a file program which can recognize a shared library +m4_defun([_LT_PATH_MAGIC], +[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) + else + MAGIC_CMD=: + fi +fi +])# _LT_PATH_MAGIC + + +# LT_PATH_LD +# ---------- +# find the pathname to the GNU or non-GNU linker +AC_DEFUN([LT_PATH_LD], +[AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_DECL_EGREP])dnl + +AC_ARG_WITH([gnu-ld], + [AS_HELP_STRING([--with-gnu-ld], + [assume the C compiler uses GNU ld @<:@default=no@:>@])], + [test "$withval" = no || with_gnu_ld=yes], + [with_gnu_ld=no])dnl + +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by $CC]) + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [[\\/]]* | ?:[[\\/]]*) + re_direlt='/[[^/]][[^/]]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` + while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do + ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(lt_cv_path_LD, +[if test -z "$LD"; then + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + else + lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + fi + ;; + +cegcc) + # use the weaker test based on 'objdump'. See mingw*. + lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + ;; + +darwin* | rhapsody*) + lt_cv_deplibs_check_method=pass_all + ;; + +freebsd* | dragonfly*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case $host_cpu in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'] + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; + *) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +interix[[3-9]]*) + # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be Linux ELF. +linux* | k*bsd*-gnu) + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +*nto* | *qnx*) + lt_cv_deplibs_check_method=pass_all + ;; + +openbsd*) + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +rdos*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.3*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + pc) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +tpf*) + lt_cv_deplibs_check_method=pass_all + ;; +esac +]) +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown + +_LT_DECL([], [deplibs_check_method], [1], + [Method to check whether dependent libraries are shared objects]) +_LT_DECL([], [file_magic_cmd], [1], + [Command to use when deplibs_check_method == "file_magic"]) +])# _LT_CHECK_MAGIC_METHOD + + +# LT_PATH_NM +# ---------- +# find the pathname to a BSD- or MS-compatible name lister +AC_DEFUN([LT_PATH_NM], +[AC_REQUIRE([AC_PROG_CC])dnl +AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, +[if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM="$NM" +else + lt_nm_to_check="${ac_tool_prefix}nm" + if test -n "$ac_tool_prefix" && test "$build" = "$host"; then + lt_nm_to_check="$lt_nm_to_check nm" + fi + for lt_tmp_nm in $lt_nm_to_check; do + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + tmp_nm="$ac_dir/$lt_tmp_nm" + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in + */dev/null* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + ;; + esac + fi + done + IFS="$lt_save_ifs" + done + : ${lt_cv_path_NM=no} +fi]) +if test "$lt_cv_path_NM" != "no"; then + NM="$lt_cv_path_NM" +else + # Didn't find any BSD compatible name lister, look for dumpbin. + AC_CHECK_TOOLS(DUMPBIN, ["dumpbin -symbols" "link -dump -symbols"], :) + AC_SUBST([DUMPBIN]) + if test "$DUMPBIN" != ":"; then + NM="$DUMPBIN" + fi +fi +test -z "$NM" && NM=nm +AC_SUBST([NM]) +_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl + +AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], + [lt_cv_nm_interface="BSD nm" + echo "int some_variable = 0;" > conftest.$ac_ext + (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$ac_compile" 2>conftest.err) + cat conftest.err >&AS_MESSAGE_LOG_FD + (eval echo "\"\$as_me:__oline__: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) + (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) + cat conftest.err >&AS_MESSAGE_LOG_FD + (eval echo "\"\$as_me:__oline__: output\"" >&AS_MESSAGE_LOG_FD) + cat conftest.out >&AS_MESSAGE_LOG_FD + if $GREP 'External.*some_variable' conftest.out > /dev/null; then + lt_cv_nm_interface="MS dumpbin" + fi + rm -f conftest*]) +])# LT_PATH_NM + +# Old names: +AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) +AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_PROG_NM], []) +dnl AC_DEFUN([AC_PROG_NM], []) + + +# LT_LIB_M +# -------- +# check for math library +AC_DEFUN([LT_LIB_M], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case $host in +*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*) + # These system don't have libm, or don't need it + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") + AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, cos, LIBM="-lm") + ;; +esac +AC_SUBST([LIBM]) +])# LT_LIB_M + +# Old name: +AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_CHECK_LIBM], []) + + +# _LT_COMPILER_NO_RTTI([TAGNAME]) +# ------------------------------- +m4_defun([_LT_COMPILER_NO_RTTI], +[m4_require([_LT_TAG_COMPILER])dnl + +_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + +if test "$GCC" = yes; then + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' + + _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], + lt_cv_prog_compiler_rtti_exceptions, + [-fno-rtti -fno-exceptions], [], + [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) +fi +_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], + [Compiler flag to turn off builtin functions]) +])# _LT_COMPILER_NO_RTTI + + +# _LT_CMD_GLOBAL_SYMBOLS +# ---------------------- +m4_defun([_LT_CMD_GLOBAL_SYMBOLS], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([LT_PATH_NM])dnl +AC_REQUIRE([LT_PATH_LD])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_TAG_COMPILER])dnl + +# Check for command to grab the raw symbol name followed by C symbol from nm. +AC_MSG_CHECKING([command to parse $NM output from $compiler object]) +AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], +[ +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[[BCDEGRST]]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[[BCDT]]' + ;; +cygwin* | mingw* | pw32* | cegcc*) + symcode='[[ABCDGISTW]]' + ;; +hpux*) + if test "$host_cpu" = ia64; then + symcode='[[ABCDEGRST]]' + fi + ;; +irix* | nonstopux*) + symcode='[[BCDEGRST]]' + ;; +osf*) + symcode='[[BCDEGQRST]]' + ;; +solaris*) + symcode='[[BDRT]]' + ;; +sco3.2v5*) + symcode='[[DT]]' + ;; +sysv4.2uw2*) + symcode='[[DT]]' + ;; +sysv5* | sco5v6* | unixware* | OpenUNIX*) + symcode='[[ABDT]]' + ;; +sysv4) + symcode='[[DFNSTU]]' + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[[ABCDGIRSTW]]' ;; +esac + +# Transform an extracted symbol line into a proper C declaration. +# Some systems (esp. on ia64) link data and code symbols differently, +# so use this general approach. +lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# Try without a prefix underscore, then with it. +for ac_symprfx in "" "_"; do + + # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. + symxfrm="\\1 $ac_symprfx\\2 \\2" + + # Write the raw and C identifiers. + if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Fake it for dumpbin and say T for any non-static function + # and D for any global variable. + # Also find C++ and __fastcall symbols from MSVC++, + # which start with @ or ?. + lt_cv_sys_global_symbol_pipe="$AWK ['"\ +" {last_section=section; section=\$ 3};"\ +" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ +" \$ 0!~/External *\|/{next};"\ +" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ +" {if(hide[section]) next};"\ +" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ +" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ +" s[1]~/^[@?]/{print s[1], s[1]; next};"\ +" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ +" ' prfx=^$ac_symprfx]" + else + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + fi + + # Check to see that the pipe works correctly. + pipe_works=no + + rm -f conftest* + cat > conftest.$ac_ext <<_LT_EOF +#ifdef __cplusplus +extern "C" { +#endif +char nm_test_var; +void nm_test_func(void); +void nm_test_func(void){} +#ifdef __cplusplus +} +#endif +int main(){nm_test_var='a';nm_test_func();return(0);} +_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 + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if $GREP ' nm_test_var$' "$nlist" >/dev/null; then + if $GREP ' nm_test_func$' "$nlist" >/dev/null; then + cat <<_LT_EOF > conftest.$ac_ext +#ifdef __cplusplus +extern "C" { +#endif + +_LT_EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' + + cat <<_LT_EOF >> conftest.$ac_ext + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + void *address; +} +lt__PROGRAM__LTX_preloaded_symbols[[]] = +{ + { "@PROGRAM@", (void *) 0 }, +_LT_EOF + $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext + cat <<\_LT_EOF >> conftest.$ac_ext + {0, (void *) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt__PROGRAM__LTX_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif +_LT_EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_save_LIBS="$LIBS" + lt_save_CFLAGS="$CFLAGS" + LIBS="conftstm.$ac_objext" + CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" + if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then + pipe_works=yes + fi + LIBS="$lt_save_LIBS" + CFLAGS="$lt_save_CFLAGS" + else + echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD + fi + else + echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD + cat conftest.$ac_ext >&5 + fi + rm -rf conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done +]) +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + AC_MSG_RESULT(failed) +else + AC_MSG_RESULT(ok) +fi + +_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], + [Take the output of nm and produce a listing of raw symbols and C names]) +_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], + [Transform the output of nm in a proper C declaration]) +_LT_DECL([global_symbol_to_c_name_address], + [lt_cv_sys_global_symbol_to_c_name_address], [1], + [Transform the output of nm in a C name address pair]) +_LT_DECL([global_symbol_to_c_name_address_lib_prefix], + [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], + [Transform the output of nm in a C name address pair when lib prefix is needed]) +]) # _LT_CMD_GLOBAL_SYMBOLS + + +# _LT_COMPILER_PIC([TAGNAME]) +# --------------------------- +m4_defun([_LT_COMPILER_PIC], +[m4_require([_LT_TAG_COMPILER])dnl +_LT_TAGVAR(lt_prog_compiler_wl, $1)= +_LT_TAGVAR(lt_prog_compiler_pic, $1)= +_LT_TAGVAR(lt_prog_compiler_static, $1)= + +AC_MSG_CHECKING([for $compiler option to produce PIC]) +m4_if([$1], [CXX], [ + # C++ specific cases for pic, static, wl, etc. + if test "$GXX" = yes; then + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + mingw* | cygwin* | os2* | pw32* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + *djgpp*) + # DJGPP does not support shared libraries at all + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + interix[[3-9]]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + case $host_os in + aix[[4-9]]*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + chorus*) + case $cc_basename in + cxch68*) + # Green Hills C++ Compiler + # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" + ;; + esac + ;; + dgux*) + case $cc_basename in + ec++*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + ghcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + freebsd* | dragonfly*) + # FreeBSD uses GNU C++ + ;; + hpux9* | hpux10* | hpux11*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + if test "$host_cpu" != ia64; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + fi + ;; + aCC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + ;; + *) + ;; + esac + ;; + interix*) + # This is c89, which is MS Visual C++ (no shared libs) + # Anyone wants to do a port? + ;; + irix5* | irix6* | nonstopux*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + # CC pic flag -KPIC is the default. + ;; + *) + ;; + esac + ;; + linux* | k*bsd*-gnu) + case $cc_basename in + KCC*) + # KAI C++ Compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + ecpc* ) + # old Intel C++ for x86_64 which still supported -KPIC. + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + icpc* ) + # Intel C++, used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + cxx*) + # Compaq C++ + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + xlc* | xlC*) + # IBM XL 8.0 on PPC + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + esac + ;; + esac + ;; + lynxos*) + ;; + m88k*) + ;; + mvs*) + case $cc_basename in + cxx*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' + ;; + *) + ;; + esac + ;; + netbsd*) + ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + ;; + RCC*) + # Rational C++ 2.4.1 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + cxx*) + # Digital/Compaq C++ + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + *) + ;; + esac + ;; + psos*) + ;; + solaris*) + case $cc_basename in + CC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + ;; + *) + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + lcc*) + # Lucid + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + *) + ;; + esac + ;; + vxworks*) + ;; + *) + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +], +[ + if test "$GCC" = yes; then + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + + interix[[3-9]]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + enable_shared=no + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + + hpux9* | hpux10* | hpux11*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC (with -KPIC) is the default. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + linux* | k*bsd*-gnu) + case $cc_basename in + # old Intel for x86_64 which still supported -KPIC. + ecc*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + # icc used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + icc* | ifort*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + # Lahey Fortran 8.1. + lf95*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' + _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' + ;; + pgcc* | pgf77* | pgf90* | pgf95*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + ccc*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All Alpha code is PIC. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + xl*) + # IBM XL C 8.0/Fortran 10.1 on PPC + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C 5.9 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + ;; + *Sun\ F*) + # Sun Fortran 8.3 passes all unrecognized flags to the linker + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='' + ;; + esac + ;; + esac + ;; + + newsos6) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + + osf3* | osf4* | osf5*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All OSF/1 code is PIC. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + rdos*) + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + solaris*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + case $cc_basename in + f77* | f90* | f95*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; + *) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; + esac + ;; + + sunos4*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + unicos*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + + uts4*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *) + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +]) +case $host_os in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" + ;; +esac +AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) +_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], + [How to pass a linker flag through the compiler]) + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then + _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], + [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], + [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], + [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in + "" | " "*) ;; + *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; + esac], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) +fi +_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], + [Additional compiler flags for building library objects]) + +# +# Check to make sure the static flag actually works. +# +wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" +_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], + _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), + $lt_tmp_static_flag, + [], + [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) +_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], + [Compiler flag to prevent dynamic linking]) +])# _LT_COMPILER_PIC + + +# _LT_LINKER_SHLIBS([TAGNAME]) +# ---------------------------- +# See if the linker supports building shared libraries. +m4_defun([_LT_LINKER_SHLIBS], +[AC_REQUIRE([LT_PATH_LD])dnl +AC_REQUIRE([LT_PATH_NM])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl +m4_require([_LT_TAG_COMPILER])dnl +AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) +m4_if([$1], [CXX], [ + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + case $host_os in + aix[[4-9]]*) + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + else + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + fi + ;; + pw32*) + _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" + ;; + cygwin* | mingw* | cegcc*) + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' + ;; + *) + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + ;; + esac + _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] +], [ + runpath_var= + _LT_TAGVAR(allow_undefined_flag, $1)= + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(archive_cmds, $1)= + _LT_TAGVAR(archive_expsym_cmds, $1)= + _LT_TAGVAR(compiler_needs_object, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + _LT_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(hardcode_automatic, $1)=no + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= + _LT_TAGVAR(hardcode_libdir_separator, $1)= + _LT_TAGVAR(hardcode_minus_L, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_TAGVAR(inherit_rpath, $1)=no + _LT_TAGVAR(link_all_deplibs, $1)=unknown + _LT_TAGVAR(module_cmds, $1)= + _LT_TAGVAR(module_expsym_cmds, $1)= + _LT_TAGVAR(old_archive_from_new_cmds, $1)= + _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= + _LT_TAGVAR(thread_safe_flag_spec, $1)= + _LT_TAGVAR(whole_archive_flag_spec, $1)= + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + _LT_TAGVAR(include_expsyms, $1)= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + # Exclude shared library initialization/finalization symbols. +dnl Note also adjust exclude_expsyms for C++ above. + extract_expsyms_cmds= + + case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; + esac + + _LT_TAGVAR(ld_shlibs, $1)=yes + if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then + _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + supports_anon_versioning=no + case `$LD -v 2>&1` in + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + + # See if GNU ld supports shared libraries. + case $host_os in + aix[[3-9]]*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +_LT_EOF + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='' + ;; + m68k) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + interix[[3-9]]*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + gnu* | linux* | tpf* | k*bsd*-gnu) + tmp_diet=no + if test "$host_os" = linux-dietlibc; then + case $cc_basename in + diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) + esac + fi + if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ + && test "$tmp_diet" = no + then + tmp_addflag= + tmp_sharedflag='-shared' + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + lf95*) # Lahey Fortran 8.1 + _LT_TAGVAR(whole_archive_flag_spec, $1)= + tmp_sharedflag='--shared' ;; + xl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) + tmp_sharedflag='-qmkshrobj' + tmp_addflag= ;; + esac + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) # Sun C 5.9 + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + _LT_TAGVAR(compiler_needs_object, $1)=yes + tmp_sharedflag='-G' ;; + *Sun\ F*) # Sun Fortran 8.3 + tmp_sharedflag='-G' ;; + esac + _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + + if test "x$supports_anon_versioning" = xyes; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + fi + + case $cc_basename in + xlf*) + # IBM XL Fortran 10.1 on PPC cannot create shared libs itself + _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' + _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib' + if test "x$supports_anon_versioning" = xyes; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' + fi + ;; + esac + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris*) + if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + ;; + *) + # For security reasons, it is highly recommended that you always + # use absolute paths for naming shared libraries, and exclude the + # DT_RUNPATH tag from executables and libraries. But doing so + # requires that you compile everything twice, which is a pain. + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + sunos4*) + _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + + if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then + runpath_var= + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=yes + _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + _LT_TAGVAR(hardcode_direct, $1)=unsupported + fi + ;; + + aix[[4-9]]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + else + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_TAGVAR(archive_cmds, $1)='' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' + + if test "$GCC" = yes; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + _LT_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)= + fi + ;; + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + _LT_TAGVAR(always_export_symbols, $1)=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + # This is similar to how AIX traditionally builds its shared libraries. + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='' + ;; + m68k) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + ;; + + bsdi[[45]]*) + _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' + # FIXME: Should let the user specify the lib program. + _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' + _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + + darwin* | rhapsody*) + _LT_DARWIN_LINKER_FEATURES($1) + ;; + + dgux*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + freebsd1*) + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | dragonfly*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + hpux9*) + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_direct, $1)=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + ;; + + hpux10*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test "$with_gnu_ld" = no; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + fi + ;; + + hpux11*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + fi + if test "$with_gnu_ld" = no; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + # Try to use the -exported_symbol ld option, if it does not + # work, assume that -exports_file does not work either and + # implicitly export all symbols. + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" + AC_LINK_IFELSE(int foo(void) {}, + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' + ) + LDFLAGS="$save_LDFLAGS" + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(inherit_rpath, $1)=yes + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + newsos6) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *nto* | *qnx*) + ;; + + openbsd*) + if test -f /usr/libexec/ld.so; then + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + else + case $host_os in + openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + ;; + esac + fi + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + os2*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + else + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ + $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' + + # Both c and cxx compiler support -rpath directly + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + solaris*) + _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' + if test "$GCC" = yes; then + wlarc='${wl}' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + else + case `$CC -V 2>&1` in + *"Compilers 5.0"*) + wlarc='' + _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' + ;; + *) + wlarc='${wl}' + _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + ;; + esac + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands `-z linker_flag'. GCC discards it without `$wl', + # but is careful enough not to reorder. + # Supported since Solaris 2.6 (maybe 2.5.1?) + if test "$GCC" = yes; then + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' + fi + ;; + esac + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4) + case $host_vendor in + sni) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' + _LT_TAGVAR(hardcode_direct, $1)=no + ;; + motorola) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4.3*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + _LT_TAGVAR(ld_shlibs, $1)=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + + if test x$host_vendor = xsni; then + case $host in + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' + ;; + esac + fi + fi +]) +AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) +test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no + +_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld + +_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl +_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl +_LT_DECL([], [extract_expsyms_cmds], [2], + [The commands to extract the exported symbol list from a shared archive]) + +# +# Do we need to explicitly link libc? +# +case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in +x|xyes) + # Assume -lc should be added + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $_LT_TAGVAR(archive_cmds, $1) in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + AC_MSG_CHECKING([whether -lc should be explicitly linked in]) + $RM conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + if AC_TRY_EVAL(ac_compile) 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) + pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) + _LT_TAGVAR(allow_undefined_flag, $1)= + if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) + then + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + else + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + fi + _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $RM conftest* + AC_MSG_RESULT([$_LT_TAGVAR(archive_cmds_need_lc, $1)]) + ;; + esac + fi + ;; +esac + +_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], + [Whether or not to add -lc for building shared libraries]) +_LT_TAGDECL([allow_libtool_libs_with_static_runtimes], + [enable_shared_with_static_runtimes], [0], + [Whether or not to disallow shared libs when runtime libs are static]) +_LT_TAGDECL([], [export_dynamic_flag_spec], [1], + [Compiler flag to allow reflexive dlopens]) +_LT_TAGDECL([], [whole_archive_flag_spec], [1], + [Compiler flag to generate shared objects directly from archives]) +_LT_TAGDECL([], [compiler_needs_object], [1], + [Whether the compiler copes with passing no objects directly]) +_LT_TAGDECL([], [old_archive_from_new_cmds], [2], + [Create an old-style archive from a shared archive]) +_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], + [Create a temporary old-style archive to link instead of a shared archive]) +_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) +_LT_TAGDECL([], [archive_expsym_cmds], [2]) +_LT_TAGDECL([], [module_cmds], [2], + [Commands used to build a loadable module if different from building + a shared archive.]) +_LT_TAGDECL([], [module_expsym_cmds], [2]) +_LT_TAGDECL([], [with_gnu_ld], [1], + [Whether we are building with GNU ld or not]) +_LT_TAGDECL([], [allow_undefined_flag], [1], + [Flag that allows shared libraries with undefined symbols to be built]) +_LT_TAGDECL([], [no_undefined_flag], [1], + [Flag that enforces no undefined symbols]) +_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], + [Flag to hardcode $libdir into a binary during linking. + This must work even if $libdir does not exist]) +_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1], + [[If ld is used when linking, flag to hardcode $libdir into a binary + during linking. This must work even if $libdir does not exist]]) +_LT_TAGDECL([], [hardcode_libdir_separator], [1], + [Whether we need a single "-rpath" flag with a separated argument]) +_LT_TAGDECL([], [hardcode_direct], [0], + [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes + DIR into the resulting binary]) +_LT_TAGDECL([], [hardcode_direct_absolute], [0], + [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes + DIR into the resulting binary and the resulting library dependency is + "absolute", i.e impossible to change by setting ${shlibpath_var} if the + library is relocated]) +_LT_TAGDECL([], [hardcode_minus_L], [0], + [Set to "yes" if using the -LDIR flag during linking hardcodes DIR + into the resulting binary]) +_LT_TAGDECL([], [hardcode_shlibpath_var], [0], + [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR + into the resulting binary]) +_LT_TAGDECL([], [hardcode_automatic], [0], + [Set to "yes" if building a shared library automatically hardcodes DIR + into the library and all subsequent libraries and executables linked + against it]) +_LT_TAGDECL([], [inherit_rpath], [0], + [Set to yes if linker adds runtime paths of dependent libraries + to runtime path list]) +_LT_TAGDECL([], [link_all_deplibs], [0], + [Whether libtool must link a program against all its dependency libraries]) +_LT_TAGDECL([], [fix_srcfile_path], [1], + [Fix the shell variable $srcfile for the compiler]) +_LT_TAGDECL([], [always_export_symbols], [0], + [Set to "yes" if exported symbols are required]) +_LT_TAGDECL([], [export_symbols_cmds], [2], + [The commands to list exported symbols]) +_LT_TAGDECL([], [exclude_expsyms], [1], + [Symbols that should not be listed in the preloaded symbols]) +_LT_TAGDECL([], [include_expsyms], [1], + [Symbols that must always be exported]) +_LT_TAGDECL([], [prelink_cmds], [2], + [Commands necessary for linking programs (against libraries) with templates]) +_LT_TAGDECL([], [file_list_spec], [1], + [Specify filename containing input files]) +dnl FIXME: Not yet implemented +dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], +dnl [Compiler flag to generate thread safe objects]) +])# _LT_LINKER_SHLIBS + + +# _LT_LANG_C_CONFIG([TAG]) +# ------------------------ +# Ensure that the configuration variables for a C compiler are suitably +# defined. These variables are subsequently used by _LT_CONFIG to write +# the compiler configuration to `libtool'. +m4_defun([_LT_LANG_C_CONFIG], +[m4_require([_LT_DECL_EGREP])dnl +lt_save_CC="$CC" +AC_LANG_PUSH(C) + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}' + +_LT_TAG_COMPILER +# Save the default compiler, since it gets overwritten when the other +# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. +compiler_DEFAULT=$CC + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + LT_SYS_DLOPEN_SELF + _LT_CMD_STRIPLIB + + # Report which library types will actually be built + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test "$can_build_shared" = "no" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + + aix[[4-9]]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test "$enable_shared" = yes || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_CONFIG($1) +fi +AC_LANG_POP +CC="$lt_save_CC" +])# _LT_LANG_C_CONFIG + + +# _LT_PROG_CXX +# ------------ +# Since AC_PROG_CXX is broken, in that it returns g++ if there is no c++ +# compiler, we have our own version here. +m4_defun([_LT_PROG_CXX], +[ +pushdef([AC_MSG_ERROR], [_lt_caught_CXX_error=yes]) +AC_PROG_CXX +if test -n "$CXX" && ( test "X$CXX" != "Xno" && + ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || + (test "X$CXX" != "Xg++"))) ; then + AC_PROG_CXXCPP +else + _lt_caught_CXX_error=yes +fi +popdef([AC_MSG_ERROR]) +])# _LT_PROG_CXX + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([_LT_PROG_CXX], []) + + +# _LT_LANG_CXX_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for a C++ compiler are suitably +# defined. These variables are subsequently used by _LT_CONFIG to write +# the compiler configuration to `libtool'. +m4_defun([_LT_LANG_CXX_CONFIG], +[AC_REQUIRE([_LT_PROG_CXX])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_EGREP])dnl + +AC_LANG_PUSH(C++) +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(compiler_needs_object, $1)=no +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for C++ test sources. +ac_ext=cpp + +# Object file extension for compiled C++ test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the CXX compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test "$_lt_caught_CXX_error" != yes; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="int some_variable = 0;" + + # Code to be used in simple link tests + lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC=$CC + lt_save_LD=$LD + lt_save_GCC=$GCC + GCC=$GXX + lt_save_with_gnu_ld=$with_gnu_ld + lt_save_path_LD=$lt_cv_path_LD + if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then + lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx + else + $as_unset lt_cv_prog_gnu_ld + fi + if test -n "${lt_cv_path_LDCXX+set}"; then + lt_cv_path_LD=$lt_cv_path_LDCXX + else + $as_unset lt_cv_path_LD + fi + test -z "${LDCXX+set}" || LD=$LDCXX + CC=${CXX-"c++"} + compiler=$CC + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + + if test -n "$compiler"; then + # We don't want -fno-exception when compiling C++ code, so set the + # no_builtin_flag separately + if test "$GXX" = yes; then + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' + else + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + fi + + if test "$GXX" = yes; then + # Set up default GNU C++ configuration + + LT_PATH_LD + + # Check if GNU C++ uses GNU ld as the underlying linker, since the + # archiving commands below assume that GNU ld is being used. + if test "$with_gnu_ld" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + + # If archive_cmds runs LD, not CC, wlarc should be empty + # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to + # investigate it a little bit more. (MM) + wlarc='${wl}' + + # ancient GNU ld didn't support --whole-archive et. al. + if eval "`$CC -print-prog-name=ld` --help 2>&1" | + $GREP 'no-whole-archive' > /dev/null; then + _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + with_gnu_ld=no + wlarc= + + # A generic and very simple default shared library creation + # command for GNU C++ for the case where it uses the native + # linker, instead of GNU ld. If possible, this setting should + # overridden to take advantage of the native linker features on + # the platform it is being used on. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + fi + + # 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 "\-L"' + + else + GXX=no + with_gnu_ld=no + wlarc= + fi + + # PORTME: fill in a description of your system's C++ link characteristics + AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) + _LT_TAGVAR(ld_shlibs, $1)=yes + case $host_os in + aix3*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aix[[4-9]]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) + for ld_flag in $LDFLAGS; do + case $ld_flag in + *-brtl*) + aix_use_runtimelinking=yes + break + ;; + esac + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_TAGVAR(archive_cmds, $1)='' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' + + if test "$GXX" = yes; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + _LT_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)= + fi + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to + # export. + _LT_TAGVAR(always_export_symbols, $1)=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an empty + # executable. + _LT_SYS_MODULE_PATH_AIX + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + # This is similar to how AIX traditionally builds its shared + # libraries. + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + chorus*) + case $cc_basename in + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + darwin* | rhapsody*) + _LT_DARWIN_LINKER_FEATURES($1) + ;; + + dgux*) + case $cc_basename in + ec++*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + ghcx*) + # Green Hills C++ Compiler + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + freebsd[[12]]*) + # C++ shared libraries reported to be fairly broken before + # switch to ELF + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + freebsd-elf*) + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + ;; + + freebsd* | dragonfly*) + # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF + # conventions + _LT_TAGVAR(ld_shlibs, $1)=yes + ;; + + gnu*) + ;; + + hpux9*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # 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; $ECHO "X$list" | $Xsed' + ;; + *) + if test "$GXX" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + hpux10*|hpux11*) + if test $with_gnu_ld = no; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) + ;; + *) + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + ;; + esac + fi + case $host_cpu in + hppa*64*|ia64*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + esac + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # 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; $ECHO "X$list" | $Xsed' + ;; + *) + if test "$GXX" = yes; then + if test $with_gnu_ld = no; then + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + fi + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + interix[[3-9]]*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + irix5* | irix6*) + case $cc_basename in + CC*) + # SGI C++ + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + + # Archives containing C++ object files must be created using + # "CC -ar", where "CC" is the IRIX C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' + ;; + *) + if test "$GXX" = yes; then + if test "$with_gnu_ld" = no; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib' + fi + fi + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + esac + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(inherit_rpath, $1)=yes + ;; + + linux* | k*bsd*-gnu) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # 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 $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' + ;; + icpc* | ecpc* ) + # Intel C++ + with_gnu_ld=yes + # version 8.0 and above of icpc choke on multiply defined symbols + # if we add $predep_objects and $postdep_objects, however 7.1 and + # earlier do not add the objects themselves. + case `$CC -V 2>&1` in + *"Version 7."*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + *) # Version 8.0 or newer + tmp_idyn= + case $host_cpu in + ia64*) tmp_idyn=' -i_dynamic';; + esac + _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + esac + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + case `$CC -V` in + *pgCC\ [[1-5]]* | *pgcpp\ [[1-5]]*) + _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ + compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"' + _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ + $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~ + $RANLIB $oldlib' + _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' + ;; + *) # Version 6 will use weak symbols + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + ;; + cxx*) + # Compaq C++ + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' + + runpath_var=LD_RUN_PATH + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # 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 -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + ;; + xl*) + # IBM XL 8.0 on PPC, with GNU ld + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + if test "x$supports_anon_versioning" = xyes; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + fi + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + _LT_TAGVAR(compiler_needs_object, $1)=yes + + # Not sure whether something based on + # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 + # would be better. + output_verbose_link_cmd='echo' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + esac + ;; + esac + ;; + + lynxos*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + m88k*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + mvs*) + case $cc_basename in + cxx*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' + wlarc= + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + fi + # Workaround some broken pre-1.5 toolchains + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' + ;; + + *nto* | *qnx*) + _LT_TAGVAR(ld_shlibs, $1)=yes + ;; + + openbsd2*) + # C++ shared libraries are fairly broken + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + openbsd*) + if test -f /usr/libexec/ld.so; then + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + fi + output_verbose_link_cmd=echo + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Archives containing C++ object files must be created using + # the KAI C++ compiler. + case $host in + osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; + *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; + esac + ;; + RCC*) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + cxx*) + case $host in + osf3*) + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + ;; + *) + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ + echo "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~ + $RM $lib.exp' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # 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 -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + case $host in + osf3*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # 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 "\-L"' + + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + psos*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + lcc*) + # Lucid + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + solaris*) + case $cc_basename in + CC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_TAGVAR(archive_cmds_need_lc,$1)=yes + _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands `-z linker_flag'. + # Supported since Solaris 2.6 (maybe 2.5.1?) + _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' + ;; + esac + _LT_TAGVAR(link_all_deplibs, $1)=yes + + output_verbose_link_cmd='echo' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + + # The C++ compiler must be used to create the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' + ;; + *) + # GNU C++ compiler with Solaris linker + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' + if $CC --version | $GREP -v '^2\.7' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + # 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 "\-L"' + else + # g++ 2.7 appears to require `-G' NOT `-shared' on this + # platform. + _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + # 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 "\-L"' + fi + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + ;; + esac + fi + ;; + esac + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + vxworks*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + + AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) + test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no + + _LT_TAGVAR(GCC, $1)="$GXX" + _LT_TAGVAR(LD, $1)="$LD" + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_SYS_HIDDEN_LIBDEPS($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + CC=$lt_save_CC + LDCXX=$LD + LD=$lt_save_LD + GCC=$lt_save_GCC + with_gnu_ld=$lt_save_with_gnu_ld + lt_cv_path_LDCXX=$lt_cv_path_LD + lt_cv_path_LD=$lt_save_path_LD + lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld + lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld +fi # test "$_lt_caught_CXX_error" != yes + +AC_LANG_POP +])# _LT_LANG_CXX_CONFIG + + +# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) +# --------------------------------- +# Figure out "hidden" library dependencies from verbose +# compiler output when linking a shared library. +# Parse the compiler output and extract the necessary +# objects, libraries and library flags. +m4_defun([_LT_SYS_HIDDEN_LIBDEPS], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +# Dependencies to place before and after the object being linked: +_LT_TAGVAR(predep_objects, $1)= +_LT_TAGVAR(postdep_objects, $1)= +_LT_TAGVAR(predeps, $1)= +_LT_TAGVAR(postdeps, $1)= +_LT_TAGVAR(compiler_lib_search_path, $1)= + +dnl we can't use the lt_simple_compile_test_code here, +dnl because it contains code intended for an executable, +dnl not a library. It's possible we should let each +dnl tag define a new lt_????_link_test_code variable, +dnl but it's only used here... +m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF +int a; +void foo (void) { a = 0; } +_LT_EOF +], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF +class Foo +{ +public: + Foo (void) { a = 0; } +private: + int a; +}; +_LT_EOF +], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF + subroutine foo + implicit none + integer*4 a + a=0 + return + end +_LT_EOF +], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF + subroutine foo + implicit none + integer a + a=0 + return + end +_LT_EOF +], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF +public class foo { + private int a; + public void bar (void) { + a = 0; + } +}; +_LT_EOF +]) +dnl Parse the compiler output and extract the necessary +dnl objects, libraries and library flags. +if AC_TRY_EVAL(ac_compile); then + # Parse the compiler output and extract the necessary + # objects, libraries and library flags. + + # Sentinel used to keep track of whether or not we are before + # the conftest object file. + pre_test_object_deps_done=no + + for p in `eval "$output_verbose_link_cmd"`; do + case $p in + + -L* | -R* | -l*) + # Some compilers place space between "-{L,R}" and the path. + # Remove the space. + if test $p = "-L" || + test $p = "-R"; then + prev=$p + continue + else + prev= + fi + + if test "$pre_test_object_deps_done" = no; then + case $p in + -L* | -R*) + # Internal compiler library paths should come after those + # provided the user. The postdeps already come after the + # user supplied libs so there is no need to process them. + if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then + _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" + else + _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" + fi + ;; + # The "-l" case would never come before the object being + # linked, so don't bother handling this case. + esac + else + if test -z "$_LT_TAGVAR(postdeps, $1)"; then + _LT_TAGVAR(postdeps, $1)="${prev}${p}" + else + _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" + fi + fi + ;; + + *.$objext) + # This assumes that the test object file only shows up + # once in the compiler output. + if test "$p" = "conftest.$objext"; then + pre_test_object_deps_done=yes + continue + fi + + if test "$pre_test_object_deps_done" = no; then + if test -z "$_LT_TAGVAR(predep_objects, $1)"; then + _LT_TAGVAR(predep_objects, $1)="$p" + else + _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" + fi + else + if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then + _LT_TAGVAR(postdep_objects, $1)="$p" + else + _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" + fi + fi + ;; + + *) ;; # Ignore the rest. + + esac + done + + # Clean up. + rm -f a.out a.exe +else + echo "libtool.m4: error: problem compiling $1 test program" +fi + +$RM -f confest.$objext + +# PORTME: override above test on systems where it is broken +m4_if([$1], [CXX], +[case $host_os in +interix[[3-9]]*) + # Interix 3.5 installs completely hosed .la files for C++, so rather than + # hack all around it, let's just trust "g++" to DTRT. + _LT_TAGVAR(predep_objects,$1)= + _LT_TAGVAR(postdep_objects,$1)= + _LT_TAGVAR(postdeps,$1)= + ;; + +linux*) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + + # The more standards-conforming stlport4 library is + # incompatible with the Cstd library. Avoid specifying + # it if it's in CXXFLAGS. Ignore libCrun as + # -library=stlport4 depends on it. + case " $CXX $CXXFLAGS " in + *" -library=stlport4 "*) + solaris_use_stlport4=yes + ;; + esac + + if test "$solaris_use_stlport4" != yes; then + _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' + fi + ;; + esac + ;; + +solaris*) + case $cc_basename in + CC*) + # The more standards-conforming stlport4 library is + # incompatible with the Cstd library. Avoid specifying + # it if it's in CXXFLAGS. Ignore libCrun as + # -library=stlport4 depends on it. + case " $CXX $CXXFLAGS " in + *" -library=stlport4 "*) + solaris_use_stlport4=yes + ;; + esac + + # Adding this requires a known-good setup of shared libraries for + # Sun compiler versions before 5.6, else PIC objects from an old + # archive will be linked into the output, leading to subtle bugs. + if test "$solaris_use_stlport4" != yes; then + _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' + fi + ;; + esac + ;; +esac +]) + +case " $_LT_TAGVAR(postdeps, $1) " in +*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; +esac + _LT_TAGVAR(compiler_lib_search_dirs, $1)= +if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then + _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` +fi +_LT_TAGDECL([], [compiler_lib_search_dirs], [1], + [The directories searched by this compiler when creating a shared library]) +_LT_TAGDECL([], [predep_objects], [1], + [Dependencies to place before and after the objects being linked to + create a shared library]) +_LT_TAGDECL([], [postdep_objects], [1]) +_LT_TAGDECL([], [predeps], [1]) +_LT_TAGDECL([], [postdeps], [1]) +_LT_TAGDECL([], [compiler_lib_search_path], [1], + [The library search path used internally by the compiler when linking + a shared library]) +])# _LT_SYS_HIDDEN_LIBDEPS + + +# _LT_PROG_F77 +# ------------ +# Since AC_PROG_F77 is broken, in that it returns the empty string +# if there is no fortran compiler, we have our own version here. +m4_defun([_LT_PROG_F77], +[ +pushdef([AC_MSG_ERROR], [_lt_disable_F77=yes]) +AC_PROG_F77 +if test -z "$F77" || test "X$F77" = "Xno"; then + _lt_disable_F77=yes +fi +popdef([AC_MSG_ERROR]) +])# _LT_PROG_F77 + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([_LT_PROG_F77], []) + + +# _LT_LANG_F77_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for a Fortran 77 compiler are +# suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_F77_CONFIG], +[AC_REQUIRE([_LT_PROG_F77])dnl +AC_LANG_PUSH(Fortran 77) + +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for f77 test sources. +ac_ext=f + +# Object file extension for compiled f77 test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the F77 compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test "$_lt_disable_F77" != yes; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="\ + subroutine t + return + end +" + + # Code to be used in simple link tests + lt_simple_link_test_code="\ + program t + end +" + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC="$CC" + lt_save_GCC=$GCC + CC=${F77-"f77"} + compiler=$CC + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + GCC=$G77 + if test -n "$compiler"; then + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test "$can_build_shared" = "no" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + aix[[4-9]]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test "$enable_shared" = yes || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_TAGVAR(GCC, $1)="$G77" + _LT_TAGVAR(LD, $1)="$LD" + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + GCC=$lt_save_GCC + CC="$lt_save_CC" +fi # test "$_lt_disable_F77" != yes + +AC_LANG_POP +])# _LT_LANG_F77_CONFIG + + +# _LT_PROG_FC +# ----------- +# Since AC_PROG_FC is broken, in that it returns the empty string +# if there is no fortran compiler, we have our own version here. +m4_defun([_LT_PROG_FC], +[ +pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes]) +AC_PROG_FC +if test -z "$FC" || test "X$FC" = "Xno"; then + _lt_disable_FC=yes +fi +popdef([AC_MSG_ERROR]) +])# _LT_PROG_FC + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([_LT_PROG_FC], []) + + +# _LT_LANG_FC_CONFIG([TAG]) +# ------------------------- +# Ensure that the configuration variables for a Fortran compiler are +# suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_FC_CONFIG], +[AC_REQUIRE([_LT_PROG_FC])dnl +AC_LANG_PUSH(Fortran) + +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for fc test sources. +ac_ext=${ac_fc_srcext-f} + +# Object file extension for compiled fc test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the FC compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test "$_lt_disable_FC" != yes; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="\ + subroutine t + return + end +" + + # Code to be used in simple link tests + lt_simple_link_test_code="\ + program t + end +" + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC="$CC" + lt_save_GCC=$GCC + CC=${FC-"f95"} + compiler=$CC + GCC=$ac_cv_fc_compiler_gnu + + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + + if test -n "$compiler"; then + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test "$can_build_shared" = "no" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + aix[[4-9]]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test "$enable_shared" = yes || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" + _LT_TAGVAR(LD, $1)="$LD" + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_SYS_HIDDEN_LIBDEPS($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + GCC=$lt_save_GCC + CC="$lt_save_CC" +fi # test "$_lt_disable_FC" != yes + +AC_LANG_POP +])# _LT_LANG_FC_CONFIG + + +# _LT_LANG_GCJ_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for the GNU Java Compiler compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_GCJ_CONFIG], +[AC_REQUIRE([LT_PROG_GCJ])dnl +AC_LANG_SAVE + +# Source file extension for Java test sources. +ac_ext=java + +# Object file extension for compiled Java test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="class foo {}" + +# Code to be used in simple link tests +lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +lt_save_GCC=$GCC +GCC=yes +CC=${GCJ-"gcj"} +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_TAGVAR(LD, $1)="$LD" +_LT_CC_BASENAME([$compiler]) + +# GCJ did not exist at the time GCC didn't implicitly link libc in. +_LT_TAGVAR(archive_cmds_need_lc, $1)=no + +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds + +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) +fi + +AC_LANG_RESTORE + +GCC=$lt_save_GCC +CC="$lt_save_CC" +])# _LT_LANG_GCJ_CONFIG + + +# _LT_LANG_RC_CONFIG([TAG]) +# ------------------------- +# Ensure that the configuration variables for the Windows resource compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_RC_CONFIG], +[AC_REQUIRE([LT_PROG_RC])dnl +AC_LANG_SAVE + +# Source file extension for RC test sources. +ac_ext=rc + +# Object file extension for compiled RC test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' + +# Code to be used in simple link tests +lt_simple_link_test_code="$lt_simple_compile_test_code" + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +lt_save_GCC=$GCC +GCC= +CC=${RC-"windres"} +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_CC_BASENAME([$compiler]) +_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + +if test -n "$compiler"; then + : + _LT_CONFIG($1) +fi + +GCC=$lt_save_GCC +AC_LANG_RESTORE +CC="$lt_save_CC" +])# _LT_LANG_RC_CONFIG + + +# LT_PROG_GCJ +# ----------- +AC_DEFUN([LT_PROG_GCJ], +[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], + [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], + [AC_CHECK_TOOL(GCJ, gcj,) + test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" + AC_SUBST(GCJFLAGS)])])[]dnl +]) + +# Old name: +AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_GCJ], []) + + +# LT_PROG_RC +# ---------- +AC_DEFUN([LT_PROG_RC], +[AC_CHECK_TOOL(RC, windres,) +]) + +# Old name: +AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_RC], []) + + +# _LT_DECL_EGREP +# -------------- +# If we don't have a new enough Autoconf to choose the best grep +# available, choose the one first in the user's PATH. +m4_defun([_LT_DECL_EGREP], +[AC_REQUIRE([AC_PROG_EGREP])dnl +AC_REQUIRE([AC_PROG_FGREP])dnl +test -z "$GREP" && GREP=grep +_LT_DECL([], [GREP], [1], [A grep program that handles long lines]) +_LT_DECL([], [EGREP], [1], [An ERE matcher]) +_LT_DECL([], [FGREP], [1], [A literal string matcher]) +dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too +AC_SUBST([GREP]) +]) + + +# _LT_DECL_OBJDUMP +# -------------- +# If we don't have a new enough Autoconf to choose the best objdump +# available, choose the one first in the user's PATH. +m4_defun([_LT_DECL_OBJDUMP], +[AC_CHECK_TOOL(OBJDUMP, objdump, false) +test -z "$OBJDUMP" && OBJDUMP=objdump +_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) +AC_SUBST([OBJDUMP]) +]) + + +# _LT_DECL_SED +# ------------ +# Check for a fully-functional sed program, that truncates +# as few characters as possible. Prefer GNU sed if found. +m4_defun([_LT_DECL_SED], +[AC_PROG_SED +test -z "$SED" && SED=sed +Xsed="$SED -e 1s/^X//" +_LT_DECL([], [SED], [1], [A sed program that does not truncate output]) +_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], + [Sed that helps us avoid accidentally triggering echo(1) options like -n]) +])# _LT_DECL_SED + +m4_ifndef([AC_PROG_SED], [ +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_SED. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # + +m4_defun([AC_PROG_SED], +[AC_MSG_CHECKING([for a sed that does not truncate output]) +AC_CACHE_VAL(lt_cv_path_SED, +[# Loop through the user's path and test for sed and gsed. +# Then use that list of sed's as ones to test for truncation. +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for lt_ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then + lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" + fi + done + done +done +IFS=$as_save_IFS +lt_ac_max=0 +lt_ac_count=0 +# Add /usr/xpg4/bin/sed as it is typically found on Solaris +# along with /bin/sed that truncates output. +for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do + test ! -f $lt_ac_sed && continue + cat /dev/null > conftest.in + lt_ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >conftest.in + # Check for GNU sed and select it if it is found. + if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then + lt_cv_path_SED=$lt_ac_sed + break + fi + while true; do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo >>conftest.nl + $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break + cmp -s conftest.out conftest.nl || break + # 10000 chars as input seems more than enough + test $lt_ac_count -gt 10 && break + lt_ac_count=`expr $lt_ac_count + 1` + if test $lt_ac_count -gt $lt_ac_max; then + lt_ac_max=$lt_ac_count + lt_cv_path_SED=$lt_ac_sed + fi + done +done +]) +SED=$lt_cv_path_SED +AC_SUBST([SED]) +AC_MSG_RESULT([$SED]) +])#AC_PROG_SED +])#m4_ifndef + +# Old name: +AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_SED], []) + + +# _LT_CHECK_SHELL_FEATURES +# ------------------------ +# Find out whether the shell is Bourne or XSI compatible, +# or has some other useful features. +m4_defun([_LT_CHECK_SHELL_FEATURES], +[AC_MSG_CHECKING([whether the shell understands some XSI constructs]) +# Try some XSI features +xsi_shell=no +( _lt_dummy="a/b/c" + test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ + = c,a/b,, \ + && eval 'test $(( 1 + 1 )) -eq 2 \ + && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ + && xsi_shell=yes +AC_MSG_RESULT([$xsi_shell]) +_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) + +AC_MSG_CHECKING([whether the shell understands "+="]) +lt_shell_append=no +( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ + >/dev/null 2>&1 \ + && lt_shell_append=yes +AC_MSG_RESULT([$lt_shell_append]) +_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) + +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + lt_unset=unset +else + lt_unset=false +fi +_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl + +# test EBCDIC or ASCII +case `echo X|tr X '\101'` in + A) # ASCII based system + # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr + lt_SP2NL='tr \040 \012' + lt_NL2SP='tr \015\012 \040\040' + ;; + *) # EBCDIC based system + lt_SP2NL='tr \100 \n' + lt_NL2SP='tr \r\n \100\100' + ;; +esac +_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl +_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl +])# _LT_CHECK_SHELL_FEATURES + + +# _LT_PROG_XSI_SHELLFNS +# --------------------- +# Bourne and XSI compatible variants of some useful shell functions. +m4_defun([_LT_PROG_XSI_SHELLFNS], +[case $xsi_shell in + yes) + cat << \_LT_EOF >> "$cfgfile" + +# func_dirname file append nondir_replacement +# Compute the dirname of FILE. If nonempty, add APPEND to the result, +# otherwise set result to NONDIR_REPLACEMENT. +func_dirname () +{ + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac +} + +# func_basename file +func_basename () +{ + func_basename_result="${1##*/}" +} + +# func_dirname_and_basename file append nondir_replacement +# perform func_basename and func_dirname in a single function +# call: +# dirname: Compute the dirname of FILE. If nonempty, +# add APPEND to the result, otherwise set result +# to NONDIR_REPLACEMENT. +# value returned in "$func_dirname_result" +# basename: Compute filename of FILE. +# value retuned in "$func_basename_result" +# Implementation must be kept synchronized with func_dirname +# and func_basename. For efficiency, we do not delegate to +# those functions but instead duplicate the functionality here. +func_dirname_and_basename () +{ + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac + func_basename_result="${1##*/}" +} + +# func_stripname prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +func_stripname () +{ + # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are + # positional parameters, so assign one to ordinary parameter first. + func_stripname_result=${3} + func_stripname_result=${func_stripname_result#"${1}"} + func_stripname_result=${func_stripname_result%"${2}"} +} + +# func_opt_split +func_opt_split () +{ + func_opt_split_opt=${1%%=*} + func_opt_split_arg=${1#*=} +} + +# func_lo2o object +func_lo2o () +{ + case ${1} in + *.lo) func_lo2o_result=${1%.lo}.${objext} ;; + *) func_lo2o_result=${1} ;; + esac +} + +# func_xform libobj-or-source +func_xform () +{ + func_xform_result=${1%.*}.lo +} + +# func_arith arithmetic-term... +func_arith () +{ + func_arith_result=$(( $[*] )) +} + +# func_len string +# STRING may not start with a hyphen. +func_len () +{ + func_len_result=${#1} +} + +_LT_EOF + ;; + *) # Bourne compatible functions. + cat << \_LT_EOF >> "$cfgfile" + +# func_dirname file append nondir_replacement +# Compute the dirname of FILE. If nonempty, add APPEND to the result, +# otherwise set result to NONDIR_REPLACEMENT. +func_dirname () +{ + # Extract subdirectory from the argument. + func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` + if test "X$func_dirname_result" = "X${1}"; then + func_dirname_result="${3}" + else + func_dirname_result="$func_dirname_result${2}" + fi +} + +# func_basename file +func_basename () +{ + func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` +} + +dnl func_dirname_and_basename +dnl A portable version of this function is already defined in general.m4sh +dnl so there is no need for it here. + +# func_stripname prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +# func_strip_suffix prefix name +func_stripname () +{ + case ${2} in + .*) func_stripname_result=`$ECHO "X${3}" \ + | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;; + *) func_stripname_result=`$ECHO "X${3}" \ + | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;; + esac +} + +# sed scripts: +my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q' +my_sed_long_arg='1s/^-[[^=]]*=//' + +# func_opt_split +func_opt_split () +{ + func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"` + func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"` +} + +# func_lo2o object +func_lo2o () +{ + func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"` +} + +# func_xform libobj-or-source +func_xform () +{ + func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[[^.]]*$/.lo/'` +} + +# func_arith arithmetic-term... +func_arith () +{ + func_arith_result=`expr "$[@]"` +} + +# func_len string +# STRING may not start with a hyphen. +func_len () +{ + func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len` +} + +_LT_EOF +esac + +case $lt_shell_append in + yes) + cat << \_LT_EOF >> "$cfgfile" + +# func_append var value +# Append VALUE to the end of shell variable VAR. +func_append () +{ + eval "$[1]+=\$[2]" +} +_LT_EOF + ;; + *) + cat << \_LT_EOF >> "$cfgfile" + +# func_append var value +# Append VALUE to the end of shell variable VAR. +func_append () +{ + eval "$[1]=\$$[1]\$[2]" +} + +_LT_EOF + ;; + esac +]) + +# Helper functions for option handling. -*- Autoconf -*- +# +# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. +# Written by Gary V. Vaughan, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 6 ltoptions.m4 + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) + + +# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) +# ------------------------------------------ +m4_define([_LT_MANGLE_OPTION], +[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) + + +# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) +# --------------------------------------- +# Set option OPTION-NAME for macro MACRO-NAME, and if there is a +# matching handler defined, dispatch to it. Other OPTION-NAMEs are +# saved as a flag. +m4_define([_LT_SET_OPTION], +[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl +m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), + _LT_MANGLE_DEFUN([$1], [$2]), + [m4_warning([Unknown $1 option `$2'])])[]dnl +]) + + +# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) +# ------------------------------------------------------------ +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +m4_define([_LT_IF_OPTION], +[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) + + +# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) +# ------------------------------------------------------- +# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME +# are set. +m4_define([_LT_UNLESS_OPTIONS], +[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), + [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), + [m4_define([$0_found])])])[]dnl +m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 +])[]dnl +]) + + +# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) +# ---------------------------------------- +# OPTION-LIST is a space-separated list of Libtool options associated +# with MACRO-NAME. If any OPTION has a matching handler declared with +# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about +# the unknown option and exit. +m4_defun([_LT_SET_OPTIONS], +[# Set options +m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), + [_LT_SET_OPTION([$1], _LT_Option)]) + +m4_if([$1],[LT_INIT],[ + dnl + dnl Simply set some default values (i.e off) if boolean options were not + dnl specified: + _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no + ]) + _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no + ]) + dnl + dnl If no reference was made to various pairs of opposing options, then + dnl we run the default mode handler for the pair. For example, if neither + dnl `shared' nor `disable-shared' was passed, we enable building of shared + dnl archives by default: + _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) + _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) + _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) + _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], + [_LT_ENABLE_FAST_INSTALL]) + ]) +])# _LT_SET_OPTIONS + + + +# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) +# ----------------------------------------- +m4_define([_LT_MANGLE_DEFUN], +[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) + + +# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) +# ----------------------------------------------- +m4_define([LT_OPTION_DEFINE], +[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl +])# LT_OPTION_DEFINE + + +# dlopen +# ------ +LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes +]) + +AU_DEFUN([AC_LIBTOOL_DLOPEN], +[_LT_SET_OPTION([LT_INIT], [dlopen]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the `dlopen' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) + + +# win32-dll +# --------- +# Declare package support for building win32 dll's. +LT_OPTION_DEFINE([LT_INIT], [win32-dll], +[enable_win32_dll=yes + +case $host in +*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-cegcc*) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) + ;; +esac + +test -z "$AS" && AS=as +_LT_DECL([], [AS], [0], [Assembler program])dnl + +test -z "$DLLTOOL" && DLLTOOL=dlltool +_LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl + +test -z "$OBJDUMP" && OBJDUMP=objdump +_LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl +])# win32-dll + +AU_DEFUN([AC_LIBTOOL_WIN32_DLL], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +_LT_SET_OPTION([LT_INIT], [win32-dll]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the `win32-dll' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) + + +# _LT_ENABLE_SHARED([DEFAULT]) +# ---------------------------- +# implement the --enable-shared flag, and supports the `shared' and +# `disable-shared' LT_INIT options. +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +m4_define([_LT_ENABLE_SHARED], +[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([shared], + [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], + [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) + + _LT_DECL([build_libtool_libs], [enable_shared], [0], + [Whether or not to build shared libraries]) +])# _LT_ENABLE_SHARED + +LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) + +# Old names: +AC_DEFUN([AC_ENABLE_SHARED], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) +]) + +AC_DEFUN([AC_DISABLE_SHARED], +[_LT_SET_OPTION([LT_INIT], [disable-shared]) +]) + +AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) +AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_ENABLE_SHARED], []) +dnl AC_DEFUN([AM_DISABLE_SHARED], []) + + + +# _LT_ENABLE_STATIC([DEFAULT]) +# ---------------------------- +# implement the --enable-static flag, and support the `static' and +# `disable-static' LT_INIT options. +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +m4_define([_LT_ENABLE_STATIC], +[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([static], + [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], + [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_static=]_LT_ENABLE_STATIC_DEFAULT) + + _LT_DECL([build_old_libs], [enable_static], [0], + [Whether or not to build static libraries]) +])# _LT_ENABLE_STATIC + +LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) + +# Old names: +AC_DEFUN([AC_ENABLE_STATIC], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) +]) + +AC_DEFUN([AC_DISABLE_STATIC], +[_LT_SET_OPTION([LT_INIT], [disable-static]) +]) + +AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) +AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_ENABLE_STATIC], []) +dnl AC_DEFUN([AM_DISABLE_STATIC], []) + + + +# _LT_ENABLE_FAST_INSTALL([DEFAULT]) +# ---------------------------------- +# implement the --enable-fast-install flag, and support the `fast-install' +# and `disable-fast-install' LT_INIT options. +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +m4_define([_LT_ENABLE_FAST_INSTALL], +[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([fast-install], + [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], + [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) + +_LT_DECL([fast_install], [enable_fast_install], [0], + [Whether or not to optimize for fast installation])dnl +])# _LT_ENABLE_FAST_INSTALL + +LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) + +# Old names: +AU_DEFUN([AC_ENABLE_FAST_INSTALL], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you put +the `fast-install' option into LT_INIT's first parameter.]) +]) + +AU_DEFUN([AC_DISABLE_FAST_INSTALL], +[_LT_SET_OPTION([LT_INIT], [disable-fast-install]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you put +the `disable-fast-install' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) +dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) + + +# _LT_WITH_PIC([MODE]) +# -------------------- +# implement the --with-pic flag, and support the `pic-only' and `no-pic' +# LT_INIT options. +# MODE is either `yes' or `no'. If omitted, it defaults to `both'. +m4_define([_LT_WITH_PIC], +[AC_ARG_WITH([pic], + [AS_HELP_STRING([--with-pic], + [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], + [pic_mode="$withval"], + [pic_mode=default]) + +test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) + +_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl +])# _LT_WITH_PIC + +LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) +LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) + +# Old name: +AU_DEFUN([AC_LIBTOOL_PICMODE], +[_LT_SET_OPTION([LT_INIT], [pic-only]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the `pic-only' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) + + +m4_define([_LTDL_MODE], []) +LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], + [m4_define([_LTDL_MODE], [nonrecursive])]) +LT_OPTION_DEFINE([LTDL_INIT], [recursive], + [m4_define([_LTDL_MODE], [recursive])]) +LT_OPTION_DEFINE([LTDL_INIT], [subproject], + [m4_define([_LTDL_MODE], [subproject])]) + +m4_define([_LTDL_TYPE], []) +LT_OPTION_DEFINE([LTDL_INIT], [installable], + [m4_define([_LTDL_TYPE], [installable])]) +LT_OPTION_DEFINE([LTDL_INIT], [convenience], + [m4_define([_LTDL_TYPE], [convenience])]) + +# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- +# +# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. +# Written by Gary V. Vaughan, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 6 ltsugar.m4 + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) + + +# lt_join(SEP, ARG1, [ARG2...]) +# ----------------------------- +# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their +# associated separator. +# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier +# versions in m4sugar had bugs. +m4_define([lt_join], +[m4_if([$#], [1], [], + [$#], [2], [[$2]], + [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) +m4_define([_lt_join], +[m4_if([$#$2], [2], [], + [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) + + +# lt_car(LIST) +# lt_cdr(LIST) +# ------------ +# Manipulate m4 lists. +# These macros are necessary as long as will still need to support +# Autoconf-2.59 which quotes differently. +m4_define([lt_car], [[$1]]) +m4_define([lt_cdr], +[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], + [$#], 1, [], + [m4_dquote(m4_shift($@))])]) +m4_define([lt_unquote], $1) + + +# lt_append(MACRO-NAME, STRING, [SEPARATOR]) +# ------------------------------------------ +# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. +# Note that neither SEPARATOR nor STRING are expanded; they are appended +# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). +# No SEPARATOR is output if MACRO-NAME was previously undefined (different +# than defined and empty). +# +# This macro is needed until we can rely on Autoconf 2.62, since earlier +# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. +m4_define([lt_append], +[m4_define([$1], + m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) + + + +# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) +# ---------------------------------------------------------- +# Produce a SEP delimited list of all paired combinations of elements of +# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list +# has the form PREFIXmINFIXSUFFIXn. +# Needed until we can rely on m4_combine added in Autoconf 2.62. +m4_define([lt_combine], +[m4_if(m4_eval([$# > 3]), [1], + [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl +[[m4_foreach([_Lt_prefix], [$2], + [m4_foreach([_Lt_suffix], + ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, + [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) + + +# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) +# ----------------------------------------------------------------------- +# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited +# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. +m4_define([lt_if_append_uniq], +[m4_ifdef([$1], + [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], + [lt_append([$1], [$2], [$3])$4], + [$5])], + [lt_append([$1], [$2], [$3])$4])]) + + +# lt_dict_add(DICT, KEY, VALUE) +# ----------------------------- +m4_define([lt_dict_add], +[m4_define([$1($2)], [$3])]) + + +# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) +# -------------------------------------------- +m4_define([lt_dict_add_subkey], +[m4_define([$1($2:$3)], [$4])]) + + +# lt_dict_fetch(DICT, KEY, [SUBKEY]) +# ---------------------------------- +m4_define([lt_dict_fetch], +[m4_ifval([$3], + m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), + m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) + + +# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) +# ----------------------------------------------------------------- +m4_define([lt_if_dict_fetch], +[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], + [$5], + [$6])]) + + +# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) +# -------------------------------------------------------------- +m4_define([lt_dict_filter], +[m4_if([$5], [], [], + [lt_join(m4_quote(m4_default([$4], [[, ]])), + lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), + [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl +]) + +# ltversion.m4 -- version numbers -*- Autoconf -*- +# +# Copyright (C) 2004 Free Software Foundation, Inc. +# Written by Scott James Remnant, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# Generated from ltversion.in. + +# serial 3017 ltversion.m4 +# This file is part of GNU Libtool + +m4_define([LT_PACKAGE_VERSION], [2.2.6b]) +m4_define([LT_PACKAGE_REVISION], [1.3017]) + +AC_DEFUN([LTVERSION_VERSION], +[macro_version='2.2.6b' +macro_revision='1.3017' +_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) +_LT_DECL(, macro_revision, 0) +]) + +# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- +# +# Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. +# Written by Scott James Remnant, 2004. +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 4 lt~obsolete.m4 + +# These exist entirely to fool aclocal when bootstrapping libtool. +# +# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) +# which have later been changed to m4_define as they aren't part of the +# exported API, or moved to Autoconf or Automake where they belong. +# +# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN +# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us +# using a macro with the same name in our local m4/libtool.m4 it'll +# pull the old libtool.m4 in (it doesn't see our shiny new m4_define +# and doesn't know about Autoconf macros at all.) +# +# So we provide this file, which has a silly filename so it's always +# included after everything else. This provides aclocal with the +# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything +# because those macros already exist, or will be overwritten later. +# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. +# +# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. +# Yes, that means every name once taken will need to remain here until +# we give up compatibility with versions before 1.7, at which point +# we need to keep only those names which we still refer to. + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) + +m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) +m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) +m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) +m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) +m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) +m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) +m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) +m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) +m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) +m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) +m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) +m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) +m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) +m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) +m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) +m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) +m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) +m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) +m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) +m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) +m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) +m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) +m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) +m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) +m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) +m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) +m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) +m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) +m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) +m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) +m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) +m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) +m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) +m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) +m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) +m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) +m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) +m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) +m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) +m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) +m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) +m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) +m4_ifndef([AC_LIBTOOL_RC], [AC_DEFUN([AC_LIBTOOL_RC])]) +m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) +m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) +m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) +m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) +m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) +m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) +m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) +m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) + +# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_AUTOMAKE_VERSION(VERSION) +# ---------------------------- +# Automake X.Y traces this macro to ensure aclocal.m4 has been +# generated from the m4 files accompanying Automake X.Y. +# (This private macro should not be called outside this file.) +AC_DEFUN([AM_AUTOMAKE_VERSION], +[am__api_version='1.11' +dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to +dnl require some minimum version. Point them to the right macro. +m4_if([$1], [1.11.1], [], + [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl +]) + +# _AM_AUTOCONF_VERSION(VERSION) +# ----------------------------- +# aclocal traces this macro to find the Autoconf version. +# This is a private macro too. Using m4_define simplifies +# the logic in aclocal, which can simply ignore this definition. +m4_define([_AM_AUTOCONF_VERSION], []) + +# AM_SET_CURRENT_AUTOMAKE_VERSION +# ------------------------------- +# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. +# This function is AC_REQUIREd by AM_INIT_AUTOMAKE. +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], +[AM_AUTOMAKE_VERSION([1.11.1])dnl +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) + +# AM_AUX_DIR_EXPAND -*- Autoconf -*- + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets +# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to +# `$srcdir', `$srcdir/..', or `$srcdir/../..'. +# +# Of course, Automake must honor this variable whenever it calls a +# tool from the auxiliary directory. The problem is that $srcdir (and +# therefore $ac_aux_dir as well) can be either absolute or relative, +# depending on how configure is run. This is pretty annoying, since +# it makes $ac_aux_dir quite unusable in subdirectories: in the top +# source directory, any form will work fine, but in subdirectories a +# relative path needs to be adjusted first. +# +# $ac_aux_dir/missing +# fails when called from a subdirectory if $ac_aux_dir is relative +# $top_srcdir/$ac_aux_dir/missing +# fails if $ac_aux_dir is absolute, +# fails when called from a subdirectory in a VPATH build with +# a relative $ac_aux_dir +# +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir +# are both prefixed by $srcdir. In an in-source build this is usually +# harmless because $srcdir is `.', but things will broke when you +# start a VPATH build or use an absolute $srcdir. +# +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, +# iff we strip the leading $srcdir from $ac_aux_dir. That would be: +# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` +# and then we would define $MISSING as +# MISSING="\${SHELL} $am_aux_dir/missing" +# This will work as long as MISSING is not called from configure, because +# unfortunately $(top_srcdir) has no meaning in configure. +# However there are other variables, like CC, which are often used in +# configure, and could therefore not use this "fixed" $ac_aux_dir. +# +# Another solution, used here, is to always expand $ac_aux_dir to an +# absolute PATH. The drawback is that using absolute paths prevent a +# configured tree to be moved without reconfiguration. + +AC_DEFUN([AM_AUX_DIR_EXPAND], +[dnl Rely on autoconf to set up CDPATH properly. +AC_PREREQ([2.50])dnl +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` +]) + +# AM_CONDITIONAL -*- Autoconf -*- + +# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 9 + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +AC_DEFUN([AM_CONDITIONAL], +[AC_PREREQ(2.52)dnl + ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_SUBST([$1_TRUE])dnl +AC_SUBST([$1_FALSE])dnl +_AM_SUBST_NOTMAKE([$1_TRUE])dnl +_AM_SUBST_NOTMAKE([$1_FALSE])dnl +m4_define([_AM_COND_VALUE_$1], [$2])dnl +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi +AC_CONFIG_COMMANDS_PRE( +[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then + AC_MSG_ERROR([[conditional "$1" was never defined. +Usually this means the macro was only invoked conditionally.]]) +fi])]) + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 10 + +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be +# written in clear, in which case automake, when reading aclocal.m4, +# will think it sees a *use*, and therefore will trigger all it's +# C support machinery. Also note that it means that autoscan, seeing +# CC etc. in the Makefile, will ask for an AC_PROG_CC use... + + +# _AM_DEPENDENCIES(NAME) +# ---------------------- +# See how the compiler implements dependency checking. +# NAME is "CC", "CXX", "GCJ", or "OBJC". +# We try a few techniques and use that to set a single cache variable. +# +# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was +# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular +# dependency, and given that the user is not expected to run this macro, +# just rely on AC_PROG_CC. +AC_DEFUN([_AM_DEPENDENCIES], +[AC_REQUIRE([AM_SET_DEPDIR])dnl +AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl +AC_REQUIRE([AM_MAKE_INCLUDE])dnl +AC_REQUIRE([AM_DEP_TRACK])dnl + +ifelse([$1], CC, [depcc="$CC" am_compiler_list=], + [$1], CXX, [depcc="$CXX" am_compiler_list=], + [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], UPC, [depcc="$UPC" am_compiler_list=], + [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) + +AC_CACHE_CHECK([dependency style of $depcc], + [am_cv_$1_dependencies_compiler_type], +[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_$1_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` + fi + am__universal=false + m4_case([$1], [CC], + [case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac], + [CXX], + [case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac]) + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvisualcpp | msvcmsys) + # This compiler won't grok `-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_$1_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_$1_dependencies_compiler_type=none +fi +]) +AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) +AM_CONDITIONAL([am__fastdep$1], [ + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) +]) + + +# AM_SET_DEPDIR +# ------------- +# Choose a directory name for dependency files. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES +AC_DEFUN([AM_SET_DEPDIR], +[AC_REQUIRE([AM_SET_LEADING_DOT])dnl +AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl +]) + + +# AM_DEP_TRACK +# ------------ +AC_DEFUN([AM_DEP_TRACK], +[AC_ARG_ENABLE(dependency-tracking, +[ --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors]) +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) +AC_SUBST([AMDEPBACKSLASH])dnl +_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl +]) + +# Generate code to set up dependency tracking. -*- Autoconf -*- + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +#serial 5 + +# _AM_OUTPUT_DEPENDENCY_COMMANDS +# ------------------------------ +AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], +[{ + # Autoconf 2.62 quotes --file arguments for eval, but not when files + # are listed without --file. Let's play safe and only enable the eval + # if we detect the quoting. + case $CONFIG_FILES in + *\'*) eval set x "$CONFIG_FILES" ;; + *) set x $CONFIG_FILES ;; + esac + shift + for mf + do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # Grep'ing the whole file is not good either: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then + dirpart=`AS_DIRNAME("$mf")` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`AS_DIRNAME(["$file"])` + AS_MKDIR_P([$dirpart/$fdir]) + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done + done +} +])# _AM_OUTPUT_DEPENDENCY_COMMANDS + + +# AM_OUTPUT_DEPENDENCY_COMMANDS +# ----------------------------- +# This macro should only be invoked once -- use via AC_REQUIRE. +# +# This code is only required when automatic dependency tracking +# is enabled. FIXME. This creates each `.P' file that we will +# need in order to bootstrap the dependency handling code. +AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], +[AC_CONFIG_COMMANDS([depfiles], + [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], + [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) +]) + + +# Copyright (C) 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 3 + +AC_DEFUN([AM_WITH_DMALLOC], +[AC_MSG_CHECKING([if malloc debugging is wanted]) +AC_ARG_WITH(dmalloc, +[ --with-dmalloc use dmalloc, as in + http://www.dmalloc.com/dmalloc.tar.gz], +[if test "$withval" = yes; then + AC_MSG_RESULT(yes) + AC_DEFINE(WITH_DMALLOC,1, + [Define if using the dmalloc debugging malloc package]) + LIBS="$LIBS -ldmalloc" + LDFLAGS="$LDFLAGS -g" +else + AC_MSG_RESULT(no) +fi], [AC_MSG_RESULT(no)]) +]) + +AU_DEFUN([fp_WITH_DMALLOC], [AM_WITH_DMALLOC]) + +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 8 + +# AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS. +AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)]) + +# Do all the work for Automake. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2008, 2009 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 16 + +# This macro actually does too much. Some checks are only needed if +# your package does certain things. But this isn't really a big deal. + +# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) +# AM_INIT_AUTOMAKE([OPTIONS]) +# ----------------------------------------------- +# The call with PACKAGE and VERSION arguments is the old style +# call (pre autoconf-2.50), which is being phased out. PACKAGE +# and VERSION should now be passed to AC_INIT and removed from +# the call to AM_INIT_AUTOMAKE. +# We support both call styles for the transition. After +# the next Automake release, Autoconf can make the AC_INIT +# arguments mandatory, and then we can depend on a new Autoconf +# release and drop the old call support. +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_PREREQ([2.62])dnl +dnl Autoconf wants to disallow AM_ names. We explicitly allow +dnl the ones we care about. +m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl +AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl +AC_REQUIRE([AC_PROG_INSTALL])dnl +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi +AC_SUBST([CYGPATH_W]) + +# Define the identity of the package. +dnl Distinguish between old-style and new-style calls. +m4_ifval([$2], +[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl + AC_SUBST([PACKAGE], [$1])dnl + AC_SUBST([VERSION], [$2])], +[_AM_SET_OPTIONS([$1])dnl +dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. +m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, + [m4_fatal([AC_INIT should be called with package and version arguments])])dnl + AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl + AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl + +_AM_IF_OPTION([no-define],, +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) + AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl + +# Some tools Automake needs. +AC_REQUIRE([AM_SANITY_CHECK])dnl +AC_REQUIRE([AC_ARG_PROGRAM])dnl +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) +AM_MISSING_PROG(AUTOCONF, autoconf) +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) +AM_MISSING_PROG(AUTOHEADER, autoheader) +AM_MISSING_PROG(MAKEINFO, makeinfo) +AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl +AC_REQUIRE([AM_PROG_MKDIR_P])dnl +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([AC_PROG_MAKE_SET])dnl +AC_REQUIRE([AM_SET_LEADING_DOT])dnl +_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], + [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], + [_AM_PROG_TAR([v7])])]) +_AM_IF_OPTION([no-dependencies],, +[AC_PROVIDE_IFELSE([AC_PROG_CC], + [_AM_DEPENDENCIES(CC)], + [define([AC_PROG_CC], + defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_CXX], + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_CXX], + defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_OBJC], + [_AM_DEPENDENCIES(OBJC)], + [define([AC_PROG_OBJC], + defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl +]) +_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl +dnl The `parallel-tests' driver may need to know about EXEEXT, so add the +dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro +dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. +AC_CONFIG_COMMANDS_PRE(dnl +[m4_provide_if([_AM_COMPILER_EXEEXT], + [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl +]) + +dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not +dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further +dnl mangled by Autoconf and run in a shell conditional statement. +m4_define([_AC_COMPILER_EXEEXT], +m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) + + +# When config.status generates a header, we must update the stamp-h file. +# This file resides in the same directory as the config header +# that is generated. The stamp files are numbered to have different names. + +# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the +# loop where config.status creates the headers, so we can generate +# our stamp files there. +AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], +[# Compute $1's index in $config_headers. +_am_arg=$1 +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) + +# Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +if test x"${install_sh}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; + *) + install_sh="\${SHELL} $am_aux_dir/install-sh" + esac +fi +AC_SUBST(install_sh)]) + +# Copyright (C) 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# Check whether the underlying file-system supports filenames +# with a leading dot. For instance MS-DOS doesn't. +AC_DEFUN([AM_SET_LEADING_DOT], +[rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null +AC_SUBST([am__leading_dot])]) + +# Add --enable-maintainer-mode option to configure. -*- Autoconf -*- +# From Jim Meyering + +# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 5 + +# AM_MAINTAINER_MODE([DEFAULT-MODE]) +# ---------------------------------- +# Control maintainer-specific portions of Makefiles. +# Default is to disable them, unless `enable' is passed literally. +# For symmetry, `disable' may be passed as well. Anyway, the user +# can override the default with the --enable/--disable switch. +AC_DEFUN([AM_MAINTAINER_MODE], +[m4_case(m4_default([$1], [disable]), + [enable], [m4_define([am_maintainer_other], [disable])], + [disable], [m4_define([am_maintainer_other], [enable])], + [m4_define([am_maintainer_other], [enable]) + m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) +AC_MSG_CHECKING([whether to am_maintainer_other maintainer-specific portions of Makefiles]) + dnl maintainer-mode's default is 'disable' unless 'enable' is passed + AC_ARG_ENABLE([maintainer-mode], +[ --][am_maintainer_other][-maintainer-mode am_maintainer_other make rules and dependencies not useful + (and sometimes confusing) to the casual installer], + [USE_MAINTAINER_MODE=$enableval], + [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes])) + AC_MSG_RESULT([$USE_MAINTAINER_MODE]) + AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes]) + MAINT=$MAINTAINER_MODE_TRUE + AC_SUBST([MAINT])dnl +] +) + +AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE]) + +# Check to see how 'make' treats includes. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + +# AM_MAKE_INCLUDE() +# ----------------- +# Check to see how make treats includes. +AC_DEFUN([AM_MAKE_INCLUDE], +[am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo this is the am__doit target +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +AC_MSG_CHECKING([for style of include used by $am_make]) +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# Ignore all kinds of additional output from `make'. +case `$am_make -s -f confmf 2> /dev/null` in #( +*the\ am__doit\ target*) + am__include=include + am__quote= + _am_result=GNU + ;; +esac +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + case `$am_make -s -f confmf 2> /dev/null` in #( + *the\ am__doit\ target*) + am__include=.include + am__quote="\"" + _am_result=BSD + ;; + esac +fi +AC_SUBST([am__include]) +AC_SUBST([am__quote]) +AC_MSG_RESULT([$_am_result]) +rm -f confinc confmf +]) + +# Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 6 + +# AM_PROG_CC_C_O +# -------------- +# Like AC_PROG_CC_C_O, but changed for automake. +AC_DEFUN([AM_PROG_CC_C_O], +[AC_REQUIRE([AC_PROG_CC_C_O])dnl +AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +AC_REQUIRE_AUX_FILE([compile])dnl +# FIXME: we rely on the cache variable name because +# there is no other way. +set dummy $CC +am_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']` +eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o +if test "$am_t" != yes; then + # Losing compiler, so override with the script. + # FIXME: It is wrong to rewrite CC. + # But if we don't then we get into trouble of one sort or another. + # A longer-term fix would be to have automake use am__CC in this case, + # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" + CC="$am_aux_dir/compile $CC" +fi +dnl Make sure AC_PROG_CC is never called again, or it will override our +dnl setting of CC. +m4_define([AC_PROG_CC], + [m4_fatal([AC_PROG_CC cannot be called after AM_PROG_CC_C_O])]) +]) + +# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- + +# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 6 + +# AM_MISSING_PROG(NAME, PROGRAM) +# ------------------------------ +AC_DEFUN([AM_MISSING_PROG], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +$1=${$1-"${am_missing_run}$2"} +AC_SUBST($1)]) + + +# AM_MISSING_HAS_RUN +# ------------------ +# Define MISSING if not defined so far and test if it supports --run. +# If it does, set am_missing_run to use it, otherwise, to nothing. +AC_DEFUN([AM_MISSING_HAS_RUN], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +AC_REQUIRE_AUX_FILE([missing])dnl +if test x"${MISSING+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; + *) + MISSING="\${SHELL} $am_aux_dir/missing" ;; + esac +fi +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + AC_MSG_WARN([`missing' script is too old or missing]) +fi +]) + +# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_MKDIR_P +# --------------- +# Check for `mkdir -p'. +AC_DEFUN([AM_PROG_MKDIR_P], +[AC_PREREQ([2.60])dnl +AC_REQUIRE([AC_PROG_MKDIR_P])dnl +dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, +dnl while keeping a definition of mkdir_p for backward compatibility. +dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. +dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of +dnl Makefile.ins that do not define MKDIR_P, so we do our own +dnl adjustment using top_builddir (which is defined more often than +dnl MKDIR_P). +AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl +case $mkdir_p in + [[\\/$]]* | ?:[[\\/]]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac +]) + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + +# _AM_MANGLE_OPTION(NAME) +# ----------------------- +AC_DEFUN([_AM_MANGLE_OPTION], +[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) + +# _AM_SET_OPTION(NAME) +# ------------------------------ +# Set option NAME. Presently that only means defining a flag for this option. +AC_DEFUN([_AM_SET_OPTION], +[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) + +# _AM_SET_OPTIONS(OPTIONS) +# ---------------------------------- +# OPTIONS is a space-separated list of Automake options. +AC_DEFUN([_AM_SET_OPTIONS], +[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) + +# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) +# ------------------------------------------- +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +AC_DEFUN([_AM_IF_OPTION], +[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) + +# Check to make sure that the build environment is sane. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 5 + +# AM_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftest.file +# Reject unsafe characters in $srcdir or the absolute working directory +# name. Accept space and tab only in the latter. +am_lf=' +' +case `pwd` in + *[[\\\"\#\$\&\'\`$am_lf]]*) + AC_MSG_ERROR([unsafe absolute working directory name]);; +esac +case $srcdir in + *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) + AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; +esac + +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + rm -f conftest.file + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "$[2]" = conftest.file + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +AC_MSG_RESULT(yes)]) + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_STRIP +# --------------------- +# One issue with vendor `install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in `make install-strip', and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be `maybe'. +if test "$cross_compiling" != no; then + AC_CHECK_TOOL([STRIP], [strip], :) +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +# Copyright (C) 2006, 2008 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# _AM_SUBST_NOTMAKE(VARIABLE) +# --------------------------- +# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. +# This macro is traced by Automake. +AC_DEFUN([_AM_SUBST_NOTMAKE]) + +# AM_SUBST_NOTMAKE(VARIABLE) +# --------------------------- +# Public sister of _AM_SUBST_NOTMAKE. +AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) + +# Check how to create a tarball. -*- Autoconf -*- + +# Copyright (C) 2004, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# _AM_PROG_TAR(FORMAT) +# -------------------- +# Check how to create a tarball in format FORMAT. +# FORMAT should be one of `v7', `ustar', or `pax'. +# +# Substitute a variable $(am__tar) that is a command +# writing to stdout a FORMAT-tarball containing the directory +# $tardir. +# tardir=directory && $(am__tar) > result.tar +# +# Substitute a variable $(am__untar) that extract such +# a tarball read from stdin. +# $(am__untar) < result.tar +AC_DEFUN([_AM_PROG_TAR], +[# Always define AMTAR for backward compatibility. +AM_MISSING_PROG([AMTAR], [tar]) +m4_if([$1], [v7], + [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], + [m4_case([$1], [ustar],, [pax],, + [m4_fatal([Unknown tar format])]) +AC_MSG_CHECKING([how to create a $1 tar archive]) +# Loop over all known methods to create a tar archive until one works. +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' +_am_tools=${am_cv_prog_tar_$1-$_am_tools} +# Do not fold the above two line into one, because Tru64 sh and +# Solaris sh will not grok spaces in the rhs of `-'. +for _am_tool in $_am_tools +do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; + do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac + + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break + + # tar/untar a dummy directory, and stop if the command works + rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar /dev/null 2>&1 && break + fi +done +rm -rf conftest.dir + +AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) +AC_MSG_RESULT([$am_cv_prog_tar_$1])]) +AC_SUBST([am__tar]) +AC_SUBST([am__untar]) +]) # _AM_PROG_TAR + +m4_include([libopts/m4/libopts.m4]) diff --git a/autogen.sh b/autogen.sh new file mode 100644 index 0000000..f342bf9 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,14 @@ +#!/bin/sh +rm -f config/config.guess config/config.sub config/ltmain.sh 2>/dev/null +rm -f aclocal.m4 2>/dev/null +aclocal -I libopts/m4/ +if test -x "`which libtoolize`" ; then + libtoolize --copy +else + # Necessary under OS X + glibtoolize --copy +fi +autoheader +automake --add-missing --copy +autoconf + diff --git a/compile_cn.txt b/compile_cn.txt new file mode 100644 index 0000000..bf8e5ee --- /dev/null +++ b/compile_cn.txt @@ -0,0 +1,21 @@ +/* +make clean +make distclean + +ʱconfigure.ac34: +#CFLAGS="${CFLAGS} -Wall -O3 -std=gnu99" +Ϊ: +CFLAGS="${CFLAGS} -Wall -g -std=gnu99 -DTCPBURST=1" + +ԡDEBUG +ʽʹʱΪ +CFLAGS="${CFLAGS} -Wall -O3 -std=gnu99 -DTCPBURST=1" + +ʹMARSIOģʽ +CFLAGS="${CFLAGS} -Wall -O3 -std=gnu99 -DTCPBURST=1 -DMARSIO=1 -lmarsio" + +./configure +make +make install + +*/ \ No newline at end of file diff --git a/config/compile b/config/compile new file mode 100644 index 0000000..a81e000 --- /dev/null +++ b/config/compile @@ -0,0 +1,136 @@ +#! /bin/sh +# Wrapper for compilers which do not understand `-c -o'. + +scriptversion=2003-11-09.00 + +# Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc. +# Written by Tom Tromey . +# +# 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 +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + +case $1 in + '') + echo "$0: No command. Try \`$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: compile [--help] [--version] PROGRAM [ARGS] + +Wrapper for compilers which do not understand `-c -o'. +Remove `-o dest.o' from ARGS, run PROGRAM with the remaining +arguments, and rename the output as expected. + +If you are trying to build a whole package this is not the +right script to run: please start by reading the file `INSTALL'. + +Report bugs to . +EOF + exit 0 + ;; + -v | --v*) + echo "compile $scriptversion" + exit 0 + ;; +esac + + +prog=$1 +shift + +ofile= +cfile= +args= +while test $# -gt 0; do + case "$1" in + -o) + # configure might choose to run compile as `compile cc -o foo foo.c'. + # So we do something ugly here. + ofile=$2 + shift + case "$ofile" in + *.o | *.obj) + ;; + *) + args="$args -o $ofile" + ofile= + ;; + esac + ;; + *.c) + cfile=$1 + args="$args $1" + ;; + *) + args="$args $1" + ;; + esac + shift +done + +if test -z "$ofile" || test -z "$cfile"; then + # If no `-o' option was seen then we might have been invoked from a + # pattern rule where we don't need one. That is ok -- this is a + # normal compilation that the losing compiler can handle. If no + # `.c' file was seen then we are probably linking. That is also + # ok. + exec "$prog" $args +fi + +# Name of file we expect compiler to create. +cofile=`echo $cfile | sed -e 's|^.*/||' -e 's/\.c$/.o/'` + +# Create the lock directory. +# Note: use `[/.-]' here to ensure that we don't use the same name +# that we are using for the .o file. Also, base the name on the expected +# object file name, since that is what matters with a parallel build. +lockdir=`echo $cofile | sed -e 's|[/.-]|_|g'`.d +while true; do + if mkdir $lockdir > /dev/null 2>&1; then + break + fi + sleep 1 +done +# FIXME: race condition here if user kills between mkdir and trap. +trap "rmdir $lockdir; exit 1" 1 2 15 + +# Run the compile. +"$prog" $args +status=$? + +if test -f "$cofile"; then + mv "$cofile" "$ofile" +fi + +rmdir $lockdir +exit $status + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/config/config.guess b/config/config.guess new file mode 100644 index 0000000..dc84c68 --- /dev/null +++ b/config/config.guess @@ -0,0 +1,1501 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 +# Free Software Foundation, Inc. + +timestamp='2009-11-20' + +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Originally written by Per Bothner. Please send patches (context +# diff format) to and include a ChangeLog +# entry. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006, 2007, 2008 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." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + sh5el) machine=sh5le-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ELF__ + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerpc-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit ;; + arm:riscos:*:*|arm:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + s390x:SunOS:*:*) + echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + echo i386-pc-auroraux${UNAME_RELEASE} + exit ;; + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) + eval $set_cc_for_build + SUN_ARCH="i386" + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH="x86_64" + fi + fi + echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos${UNAME_RELEASE} + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[456]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + grep -q __LP64__ + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:FreeBSD:*:*) + case ${UNAME_MACHINE} in + pc98) + echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + amd64) + echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + *:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit ;; + *:Interix*:*) + case ${UNAME_MACHINE} in + x86) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + authenticamd | genuineintel | EM64T) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; + IA64) + echo ia64-unknown-interix${UNAME_RELEASE} + exit ;; + esac ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit ;; + 8664:Windows_NT:*) + echo x86_64-pc-mks + exit ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit ;; + arm*:Linux:*:*) + eval $set_cc_for_build + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then + echo ${UNAME_MACHINE}-unknown-linux-gnu + else + echo ${UNAME_MACHINE}-unknown-linux-gnueabi + fi + exit ;; + avr32*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + cris:Linux:*:*) + echo cris-axis-linux-gnu + exit ;; + crisv32:Linux:*:*) + echo crisv32-axis-linux-gnu + exit ;; + frv:Linux:*:*) + echo frv-unknown-linux-gnu + exit ;; + i*86:Linux:*:*) + LIBC=gnu + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #ifdef __dietlibc__ + LIBC=dietlibc + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` + echo "${UNAME_MACHINE}-pc-linux-${LIBC}" + exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + mips:Linux:*:* | mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef ${UNAME_MACHINE} + #undef ${UNAME_MACHINE}el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=${UNAME_MACHINE}el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=${UNAME_MACHINE} + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + or32:Linux:*:*) + echo or32-unknown-linux-gnu + exit ;; + padre:Linux:*:*) + echo sparc-unknown-linux-gnu + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-gnu + exit ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux-gnu + exit ;; + xtensa*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configury will decide that + # this is a cross-build. + echo i586-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + echo i586-pc-haiku + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit ;; + SX-7:SUPER-UX:*:*) + echo sx7-nec-superux${UNAME_RELEASE} + exit ;; + SX-8:SUPER-UX:*:*) + echo sx8-nec-superux${UNAME_RELEASE} + exit ;; + SX-8R:SUPER-UX:*:*) + echo sx8r-nec-superux${UNAME_RELEASE} + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + case $UNAME_PROCESSOR in + i386) + eval $set_cc_for_build + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + UNAME_PROCESSOR="x86_64" + fi + fi ;; + unknown) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NSE-?:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; + i*86:AROS:*:*) + echo ${UNAME_MACHINE}-pc-aros + exit ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +eval $set_cc_for_build +cat >$dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix\n"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + c34*) + echo c34-convex-bsd + exit ;; + c38*) + echo c38-convex-bsd + exit ;; + c4*) + echo c4-convex-bsd + exit ;; + esac +fi + +cat >&2 < in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/config/config.sub b/config/config.sub new file mode 100644 index 0000000..2a55a50 --- /dev/null +++ b/config/config.sub @@ -0,0 +1,1705 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 +# Free Software Foundation, Inc. + +timestamp='2009-11-20' + +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# 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, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Please send patches to . Submit a context +# diff and a properly formatted GNU ChangeLog entry. +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# 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;hb=HEAD + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006, 2007, 2008 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." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +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/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ + uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ + kopensolaris*-gnu* | \ + storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray | -microblaze) + os= + basic_machine=$1 + ;; + -bluegene*) + os=-cnk + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco6) + os=-sco5v6 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + 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/'` + ;; + -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/'` + ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + 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/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ + | bfin \ + | c4x | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | fido | fr30 | frv \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | lm32 \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | mcore | mep | metag \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nios | nios2 \ + | ns16k | ns32k \ + | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ + | rx \ + | score \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ + | spu | strongarm \ + | tahoe | thumb | tic4x | tic80 | tron \ + | ubicom32 \ + | v850 | v850e \ + | we32k \ + | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ + | z8k | z80) + basic_machine=$basic_machine-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12 | picochip) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + ms1) + basic_machine=mt-unknown + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* | avr32-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | lm32-* \ + | m32c-* | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64octeon-* | mips64octeonel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64r5900-* | mips64r5900el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nios-* | nios2-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ + | romp-* | rs6000-* | rx-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \ + | tron-* \ + | ubicom32-* \ + | v850-* | v850e-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ + | xstormy16-* | xtensa*-* \ + | ymp-* \ + | z8k-* | z80-*) + ;; + # Recognize the basic CPU types without company name, with glob match. + xtensa*) + basic_machine=$basic_machine-unknown + ;; + # 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 + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aros) + basic_machine=i386-pc + os=-aros + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + blackfin) + basic_machine=bfin-unknown + os=-linux + ;; + blackfin-*) + basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + bluegene*) + basic_machine=powerpc-ibm + os=-cnk + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + cegcc) + basic_machine=arm-unknown + os=-cegcc + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16) + basic_machine=cr16-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dicos) + basic_machine=i686-pc + os=-dicos + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + 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 + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m68knommu) + basic_machine=m68k-unknown + os=-linux + ;; + m68knommu-*) + basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + microblaze) + basic_machine=microblaze-xilinx + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + os=-mingw32ce + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + ms1-*) + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + parisc) + basic_machine=hppa-unknown + os=-linux + ;; + parisc-*) + basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rdos) + basic_machine=i386-pc + os=-rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sde) + basic_machine=mipsisa32-sde + os=-elf + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + 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) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; + tic55x | c55x*) + basic_machine=tic55x-unknown + os=-coff + ;; + tic6x | c6x*) + basic_machine=tic6x-unknown + os=-coff + ;; + tile*) + basic_machine=tile-unknown + os=-linux-gnu + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + 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 + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + 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 + ;; + we32k) + basic_machine=we32k-att + ;; + 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 + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # 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 + ;; + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -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. + # The portable systems comes first. + # 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]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* | -aros* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -openbsd* | -solidbsd* \ + | -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* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -kaos*) + os=-kaos + ;; + -zvmoe) + os=-zvmoe + ;; + -dicos*) + os=-dicos + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + score-*) + os=-elf + ;; + spu-*) + os=-elf + ;; + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) + os=-aout + ;; + mep-*) + os=-elf + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-haiku) + os=-haiku + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -cnk*|-aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/config/depcomp b/config/depcomp new file mode 100644 index 0000000..25bdb18 --- /dev/null +++ b/config/depcomp @@ -0,0 +1,526 @@ +#! /bin/sh +# depcomp - compile a program generating dependencies as side-effects + +scriptversion=2004-04-25.13 + +# Copyright (C) 1999, 2000, 2003, 2004 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 +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Alexandre Oliva . + +case $1 in + '') + echo "$0: No command. Try \`$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: depcomp [--help] [--version] PROGRAM [ARGS] + +Run PROGRAMS ARGS to compile a file, generating dependencies +as side-effects. + +Environment variables: + depmode Dependency tracking mode. + source Source file read by `PROGRAMS ARGS'. + object Object file output by `PROGRAMS ARGS'. + depfile Dependency file to output. + tmpdepfile Temporary file to use when outputing dependencies. + libtool Whether libtool is used (yes/no). + +Report bugs to . +EOF + exit 0 + ;; + -v | --v*) + echo "depcomp $scriptversion" + exit 0 + ;; +esac + +if test -z "$depmode" || test -z "$source" || test -z "$object"; then + echo "depcomp: Variables source, object and depmode must be set" 1>&2 + exit 1 +fi +# `libtool' can also be set to `yes' or `no'. + +if test -z "$depfile"; then + base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'` + dir=`echo "$object" | sed 's,/.*$,/,'` + if test "$dir" = "$object"; then + dir= + fi + # FIXME: should be _deps on DOS. + depfile="$dir.deps/$base" +fi + +tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} + +rm -f "$tmpdepfile" + +# Some modes work just like other modes, but use different flags. We +# parameterize here, but still list the modes in the big case below, +# to make depend.m4 easier to write. Note that we *cannot* use a case +# here, because this file can only contain one case statement. +if test "$depmode" = hp; then + # HP compiler uses -M and no extra arg. + gccflag=-M + depmode=gcc +fi + +if test "$depmode" = dashXmstdout; then + # This is just like dashmstdout with a different argument. + dashmflag=-xM + depmode=dashmstdout +fi + +case "$depmode" in +gcc3) +## gcc 3 implements dependency tracking that does exactly what +## we want. Yay! Note: for some reason libtool 1.4 doesn't like +## it if -MD -MP comes after the -MF stuff. Hmm. + "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + mv "$tmpdepfile" "$depfile" + ;; + +gcc) +## There are various ways to get dependency output from gcc. Here's +## why we pick this rather obscure method: +## - Don't want to use -MD because we'd like the dependencies to end +## up in a subdir. Having to rename by hand is ugly. +## (We might end up doing this anyway to support other compilers.) +## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like +## -MM, not -M (despite what the docs say). +## - Using -M directly means running the compiler twice (even worse +## than renaming). + if test -z "$gccflag"; then + gccflag=-MD, + fi + "$@" -Wp,"$gccflag$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz +## The second -e expression handles DOS-style file names with drive letters. + sed -e 's/^[^:]*: / /' \ + -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" +## This next piece of magic avoids the `deleted header file' problem. +## The problem is that when a header file which appears in a .P file +## is deleted, the dependency causes make to die (because there is +## typically no way to rebuild the header). We avoid this by adding +## dummy dependencies for each header file. Too bad gcc doesn't do +## this for us directly. + tr ' ' ' +' < "$tmpdepfile" | +## Some versions of gcc put a space before the `:'. On the theory +## that the space means something, we add a space to the output as +## well. +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +sgi) + if test "$libtool" = yes; then + "$@" "-Wp,-MDupdate,$tmpdepfile" + else + "$@" -MDupdate "$tmpdepfile" + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + + if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files + echo "$object : \\" > "$depfile" + + # Clip off the initial element (the dependent). Don't try to be + # clever and replace this with sed code, as IRIX sed won't handle + # lines with more than a fixed number of characters (4096 in + # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; + # the IRIX cc adds comments like `#:fec' to the end of the + # dependency line. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ + tr ' +' ' ' >> $depfile + echo >> $depfile + + # The second pass generates a dummy entry for each header file. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ + >> $depfile + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +aix) + # The C for AIX Compiler uses -M and outputs the dependencies + # in a .u file. In older versions, this file always lives in the + # current directory. Also, the AIX compiler puts `$object:' at the + # start of each line; $object doesn't have directory information. + # Version 6 uses the directory in both cases. + stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` + tmpdepfile="$stripped.u" + if test "$libtool" = yes; then + "$@" -Wc,-M + else + "$@" -M + fi + stat=$? + + if test -f "$tmpdepfile"; then : + else + stripped=`echo "$stripped" | sed 's,^.*/,,'` + tmpdepfile="$stripped.u" + fi + + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + + if test -f "$tmpdepfile"; then + outname="$stripped.o" + # Each line is of the form `foo.o: dependent.h'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" + sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +icc) + # Intel's C compiler understands `-MD -MF file'. However on + # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c + # ICC 7.0 will fill foo.d with something like + # foo.o: sub/foo.c + # foo.o: sub/foo.h + # which is wrong. We want: + # sub/foo.o: sub/foo.c + # sub/foo.o: sub/foo.h + # sub/foo.c: + # sub/foo.h: + # ICC 7.1 will output + # foo.o: sub/foo.c sub/foo.h + # and will wrap long lines using \ : + # foo.o: sub/foo.c ... \ + # sub/foo.h ... \ + # ... + + "$@" -MD -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each line is of the form `foo.o: dependent.h', + # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | + sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +tru64) + # The Tru64 compiler uses -MD to generate dependencies as a side + # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put + # dependencies in `foo.d' instead, so we check for that too. + # Subdirectories are respected. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + + if test "$libtool" = yes; then + # Dependencies are output in .lo.d with libtool 1.4. + # They are output in .o.d with libtool 1.5. + tmpdepfile1="$dir.libs/$base.lo.d" + tmpdepfile2="$dir.libs/$base.o.d" + tmpdepfile3="$dir.libs/$base.d" + "$@" -Wc,-MD + else + tmpdepfile1="$dir$base.o.d" + tmpdepfile2="$dir$base.d" + tmpdepfile3="$dir$base.d" + "$@" -MD + fi + + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + exit $stat + fi + + if test -f "$tmpdepfile1"; then + tmpdepfile="$tmpdepfile1" + elif test -f "$tmpdepfile2"; then + tmpdepfile="$tmpdepfile2" + else + tmpdepfile="$tmpdepfile3" + fi + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" + # That's a tab and a space in the []. + sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +#nosideeffect) + # This comment above is used by automake to tell side-effect + # dependency tracking mechanisms from slower ones. + +dashmstdout) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + test -z "$dashmflag" && dashmflag=-M + # Require at least two characters before searching for `:' + # in the target name. This is to cope with DOS-style filenames: + # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. + "$@" $dashmflag | + sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + tr ' ' ' +' < "$tmpdepfile" | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +dashXmstdout) + # This case only exists to satisfy depend.m4. It is never actually + # run, as this mode is specially recognized in the preamble. + exit 1 + ;; + +makedepend) + "$@" || exit $? + # Remove any Libtool call + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + # X makedepend + shift + cleared=no + for arg in "$@"; do + case $cleared in + no) + set ""; shift + cleared=yes ;; + esac + case "$arg" in + -D*|-I*) + set fnord "$@" "$arg"; shift ;; + # Strip any option that makedepend may not understand. Remove + # the object too, otherwise makedepend will parse it as a source file. + -*|$object) + ;; + *) + set fnord "$@" "$arg"; shift ;; + esac + done + obj_suffix="`echo $object | sed 's/^.*\././'`" + touch "$tmpdepfile" + ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + sed '1,2d' "$tmpdepfile" | tr ' ' ' +' | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" "$tmpdepfile".bak + ;; + +cpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + "$@" -E | + sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | + sed '$ s: \\$::' > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + cat < "$tmpdepfile" >> "$depfile" + sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvisualcpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o, + # because we must use -o when running libtool. + "$@" || exit $? + IFS=" " + for arg + do + case "$arg" in + "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") + set fnord "$@" + shift + shift + ;; + *) + set fnord "$@" "$arg" + shift + shift + ;; + esac + done + "$@" -E | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" + echo " " >> "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +none) + exec "$@" + ;; + +*) + echo "Unknown depmode $depmode" 1>&2 + exit 1 + ;; +esac + +exit 0 + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/config/install-sh b/config/install-sh new file mode 100644 index 0000000..e4160c9 --- /dev/null +++ b/config/install-sh @@ -0,0 +1,325 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2004-04-01.17 + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename= +transform_arg= +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd= +chgrpcmd= +stripcmd= +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src= +dst= +dir_arg= + +usage="Usage: $0 [OPTION]... SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 -d DIRECTORIES... + +In the first form, install SRCFILE to DSTFILE, removing SRCFILE by default. +In the second, create the directory path DIR. + +Options: +-b=TRANSFORMBASENAME +-c copy source (using $cpprog) instead of moving (using $mvprog). +-d create directories instead of installing files. +-g GROUP $chgrp installed files to GROUP. +-m MODE $chmod installed files to MODE. +-o USER $chown installed files to USER. +-s strip installed files (using $stripprog). +-t=TRANSFORM +--help display this help and exit. +--version display version info and exit. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG +" + +while test -n "$1"; do + case $1 in + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + -c) instcmd=$cpprog + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + --help) echo "$usage"; exit 0;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -s) stripcmd=$stripprog + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + --version) echo "$0 $scriptversion"; exit 0;; + + *) # When -d is used, all remaining arguments are directories to create. + test -n "$dir_arg" && break + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dstarg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dstarg" + shift # fnord + fi + shift # arg + dstarg=$arg + done + break;; + esac +done + +if test -z "$1"; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call `install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +for src +do + # Protect names starting with `-'. + case $src in + -*) src=./$src ;; + esac + + if test -n "$dir_arg"; then + dst=$src + src= + + if test -d "$dst"; then + instcmd=: + chmodcmd= + else + instcmd=$mkdirprog + fi + else + # Waiting for this to be detected by the "$instcmd $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dstarg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + + dst=$dstarg + # Protect names starting with `-'. + case $dst in + -*) dst=./$dst ;; + esac + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + dst=$dst/`basename "$src"` + fi + fi + + # This sed command emulates the dirname command. + dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + + # Make sure that the destination directory exists. + + # Skip lots of stat calls in the usual case. + if test ! -d "$dstdir"; then + defaultIFS=' + ' + IFS="${IFS-$defaultIFS}" + + oIFS=$IFS + # Some sh's can't handle IFS=/ for some reason. + IFS='%' + set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` + IFS=$oIFS + + pathcomp= + + while test $# -ne 0 ; do + pathcomp=$pathcomp$1 + shift + if test ! -d "$pathcomp"; then + $mkdirprog "$pathcomp" || lasterr=$? + # mkdir can fail with a `File exist' error in case several + # install-sh are creating the directory concurrently. This + # is OK. + test ! -d "$pathcomp" && { (exit ${lasterr-1}); exit; } + fi + pathcomp=$pathcomp/ + done + fi + + if test -n "$dir_arg"; then + $doit $instcmd "$dst" \ + && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \ + && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \ + && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \ + && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; } + + else + # If we're going to rename the final executable, determine the name now. + if test -z "$transformarg"; then + dstfile=`basename "$dst"` + else + dstfile=`basename "$dst" $transformbasename \ + | sed $transformarg`$transformbasename + fi + + # don't allow the sed command to completely eliminate the filename. + test -z "$dstfile" && dstfile=`basename "$dst"` + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0 + trap '(exit $?); exit' 1 2 13 15 + + # Move or copy the file name to the temp name + $doit $instcmd "$src" "$dsttmp" && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $instcmd $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \ + && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \ + && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ + && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } && + + # Now rename the file to the real destination. + { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \ + || { + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + if test -f "$dstdir/$dstfile"; then + $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \ + || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \ + || { + echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 + (exit 1); exit + } + else + : + fi + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" + } + } + fi || { (exit 1); exit; } +done + +# The final little trick to "correctly" pass the exit status to the exit trap. +{ + (exit 0); exit +} + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/config/ltmain.sh b/config/ltmain.sh new file mode 100644 index 0000000..a72f2fd --- /dev/null +++ b/config/ltmain.sh @@ -0,0 +1,8406 @@ +# Generated from ltmain.m4sh. + +# ltmain.sh (GNU libtool) 2.2.6b +# Written by Gordon Matzigkeit , 1996 + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 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. + +# GNU Libtool is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# As a special exception to the GNU General Public License, +# if you distribute this file as part of a program or library that +# is built using GNU Libtool, you may include this file under the +# same distribution terms that you use for the rest of that program. +# +# GNU Libtool is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Libtool; see the file COPYING. If not, a copy +# can be downloaded from http://www.gnu.org/licenses/gpl.html, +# or obtained by writing to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# Usage: $progname [OPTION]... [MODE-ARG]... +# +# Provide generalized library-building support services. +# +# --config show all configuration variables +# --debug enable verbose shell tracing +# -n, --dry-run display commands without modifying any files +# --features display basic configuration information and exit +# --mode=MODE use operation mode MODE +# --preserve-dup-deps don't remove duplicate dependency libraries +# --quiet, --silent don't print informational messages +# --tag=TAG use configuration variables from tag TAG +# -v, --verbose print informational messages (default) +# --version print version information +# -h, --help print short or long help message +# +# MODE must be one of the following: +# +# clean remove files from the build directory +# compile compile a source file into a libtool object +# execute automatically set library path, then run a program +# finish complete the installation of libtool libraries +# install install libraries or executables +# link create a library or an executable +# uninstall remove libraries from an installed directory +# +# MODE-ARGS vary depending on the MODE. +# Try `$progname --help --mode=MODE' for a more detailed description of MODE. +# +# When reporting a bug, please describe a test case to reproduce it and +# include the following information: +# +# host-triplet: $host +# shell: $SHELL +# compiler: $LTCC +# compiler flags: $LTCFLAGS +# linker: $LD (gnu? $with_gnu_ld) +# $progname: (GNU libtool) 2.2.6b +# automake: $automake_version +# autoconf: $autoconf_version +# +# Report bugs to . + +PROGRAM=ltmain.sh +PACKAGE=libtool +VERSION=2.2.6b +TIMESTAMP="" +package_revision=1.3017 + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# NLS nuisances: We save the old values to restore during execute mode. +# Only set LANG and LC_ALL to C if already set. +# These must not be set unconditionally because not all systems understand +# e.g. LANG=C (notably SCO). +lt_user_locale= +lt_safe_locale= +for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES +do + eval "if test \"\${$lt_var+set}\" = set; then + save_$lt_var=\$$lt_var + $lt_var=C + export $lt_var + lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" + lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" + fi" +done + +$lt_unset CDPATH + + + + + +: ${CP="cp -f"} +: ${ECHO="echo"} +: ${EGREP="/bin/grep -E"} +: ${FGREP="/bin/grep -F"} +: ${GREP="/bin/grep"} +: ${LN_S="ln -s"} +: ${MAKE="make"} +: ${MKDIR="mkdir"} +: ${MV="mv -f"} +: ${RM="rm -f"} +: ${SED="/bin/sed"} +: ${SHELL="${CONFIG_SHELL-/bin/sh}"} +: ${Xsed="$SED -e 1s/^X//"} + +# Global variables: +EXIT_SUCCESS=0 +EXIT_FAILURE=1 +EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. +EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. + +exit_status=$EXIT_SUCCESS + +# Make sure IFS has a sensible default +lt_nl=' +' +IFS=" $lt_nl" + +dirname="s,/[^/]*$,," +basename="s,^.*/,," + +# func_dirname_and_basename file append nondir_replacement +# perform func_basename and func_dirname in a single function +# call: +# dirname: Compute the dirname of FILE. If nonempty, +# add APPEND to the result, otherwise set result +# to NONDIR_REPLACEMENT. +# value returned in "$func_dirname_result" +# basename: Compute filename of FILE. +# value retuned in "$func_basename_result" +# Implementation must be kept synchronized with func_dirname +# and func_basename. For efficiency, we do not delegate to +# those functions but instead duplicate the functionality here. +func_dirname_and_basename () +{ + # Extract subdirectory from the argument. + func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` + if test "X$func_dirname_result" = "X${1}"; then + func_dirname_result="${3}" + else + func_dirname_result="$func_dirname_result${2}" + fi + func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` +} + +# Generated shell functions inserted here. + +# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh +# is ksh but when the shell is invoked as "sh" and the current value of +# the _XPG environment variable is not equal to 1 (one), the special +# positional parameter $0, within a function call, is the name of the +# function. +progpath="$0" + +# The name of this program: +# In the unlikely event $progname began with a '-', it would play havoc with +# func_echo (imagine progname=-n), so we prepend ./ in that case: +func_dirname_and_basename "$progpath" +progname=$func_basename_result +case $progname in + -*) progname=./$progname ;; +esac + +# Make sure we have an absolute path for reexecution: +case $progpath in + [\\/]*|[A-Za-z]:\\*) ;; + *[\\/]*) + progdir=$func_dirname_result + progdir=`cd "$progdir" && pwd` + progpath="$progdir/$progname" + ;; + *) + save_IFS="$IFS" + IFS=: + for progdir in $PATH; do + IFS="$save_IFS" + test -x "$progdir/$progname" && break + done + IFS="$save_IFS" + test -n "$progdir" || progdir=`pwd` + progpath="$progdir/$progname" + ;; +esac + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed="${SED}"' -e 1s/^X//' +sed_quote_subst='s/\([`"$\\]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\(["`\\]\)/\\\1/g' + +# Re-`\' parameter expansions in output of double_quote_subst that were +# `\'-ed in input to the same. If an odd number of `\' preceded a '$' +# in input to double_quote_subst, that '$' was protected from expansion. +# Since each input `\' is now two `\'s, look for any number of runs of +# four `\'s followed by two `\'s and then a '$'. `\' that '$'. +bs='\\' +bs2='\\\\' +bs4='\\\\\\\\' +dollar='\$' +sed_double_backslash="\ + s/$bs4/&\\ +/g + s/^$bs2$dollar/$bs&/ + s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g + s/\n//g" + +# Standard options: +opt_dry_run=false +opt_help=false +opt_quiet=false +opt_verbose=false +opt_warning=: + +# func_echo arg... +# Echo program name prefixed message, along with the current mode +# name if it has been set yet. +func_echo () +{ + $ECHO "$progname${mode+: }$mode: $*" +} + +# func_verbose arg... +# Echo program name prefixed message in verbose mode only. +func_verbose () +{ + $opt_verbose && func_echo ${1+"$@"} + + # A bug in bash halts the script if the last line of a function + # fails when set -e is in force, so we need another command to + # work around that: + : +} + +# func_error arg... +# Echo program name prefixed message to standard error. +func_error () +{ + $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2 +} + +# func_warning arg... +# Echo program name prefixed warning message to standard error. +func_warning () +{ + $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2 + + # bash bug again: + : +} + +# func_fatal_error arg... +# Echo program name prefixed message to standard error, and exit. +func_fatal_error () +{ + func_error ${1+"$@"} + exit $EXIT_FAILURE +} + +# func_fatal_help arg... +# Echo program name prefixed message to standard error, followed by +# a help hint, and exit. +func_fatal_help () +{ + func_error ${1+"$@"} + func_fatal_error "$help" +} +help="Try \`$progname --help' for more information." ## default + + +# func_grep expression filename +# Check whether EXPRESSION matches any line of FILENAME, without output. +func_grep () +{ + $GREP "$1" "$2" >/dev/null 2>&1 +} + + +# func_mkdir_p directory-path +# Make sure the entire path to DIRECTORY-PATH is available. +func_mkdir_p () +{ + my_directory_path="$1" + my_dir_list= + + if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then + + # Protect directory names starting with `-' + case $my_directory_path in + -*) my_directory_path="./$my_directory_path" ;; + esac + + # While some portion of DIR does not yet exist... + while test ! -d "$my_directory_path"; do + # ...make a list in topmost first order. Use a colon delimited + # list incase some portion of path contains whitespace. + my_dir_list="$my_directory_path:$my_dir_list" + + # If the last portion added has no slash in it, the list is done + case $my_directory_path in */*) ;; *) break ;; esac + + # ...otherwise throw away the child directory and loop + my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"` + done + my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'` + + save_mkdir_p_IFS="$IFS"; IFS=':' + for my_dir in $my_dir_list; do + IFS="$save_mkdir_p_IFS" + # mkdir can fail with a `File exist' error if two processes + # try to create one of the directories concurrently. Don't + # stop in that case! + $MKDIR "$my_dir" 2>/dev/null || : + done + IFS="$save_mkdir_p_IFS" + + # Bail out if we (or some other process) failed to create a directory. + test -d "$my_directory_path" || \ + func_fatal_error "Failed to create \`$1'" + fi +} + + +# func_mktempdir [string] +# Make a temporary directory that won't clash with other running +# libtool processes, and avoids race conditions if possible. If +# given, STRING is the basename for that directory. +func_mktempdir () +{ + my_template="${TMPDIR-/tmp}/${1-$progname}" + + if test "$opt_dry_run" = ":"; then + # Return a directory name, but don't create it in dry-run mode + my_tmpdir="${my_template}-$$" + else + + # If mktemp works, use that first and foremost + my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` + + if test ! -d "$my_tmpdir"; then + # Failing that, at least try and use $RANDOM to avoid a race + my_tmpdir="${my_template}-${RANDOM-0}$$" + + save_mktempdir_umask=`umask` + umask 0077 + $MKDIR "$my_tmpdir" + umask $save_mktempdir_umask + fi + + # If we're not in dry-run mode, bomb out on failure + test -d "$my_tmpdir" || \ + func_fatal_error "cannot create temporary directory \`$my_tmpdir'" + fi + + $ECHO "X$my_tmpdir" | $Xsed +} + + +# func_quote_for_eval arg +# Aesthetically quote ARG to be evaled later. +# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT +# is double-quoted, suitable for a subsequent eval, whereas +# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters +# which are still active within double quotes backslashified. +func_quote_for_eval () +{ + case $1 in + *[\\\`\"\$]*) + func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;; + *) + func_quote_for_eval_unquoted_result="$1" ;; + esac + + case $func_quote_for_eval_unquoted_result in + # Double-quote args containing shell metacharacters to delay + # word splitting, command substitution and and variable + # expansion for a subsequent eval. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" + ;; + *) + func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" + esac +} + + +# func_quote_for_expand arg +# Aesthetically quote ARG to be evaled later; same as above, +# but do not quote variable references. +func_quote_for_expand () +{ + case $1 in + *[\\\`\"]*) + my_arg=`$ECHO "X$1" | $Xsed \ + -e "$double_quote_subst" -e "$sed_double_backslash"` ;; + *) + my_arg="$1" ;; + esac + + case $my_arg in + # Double-quote args containing shell metacharacters to delay + # word splitting and command substitution for a subsequent eval. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + my_arg="\"$my_arg\"" + ;; + esac + + func_quote_for_expand_result="$my_arg" +} + + +# func_show_eval cmd [fail_exp] +# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is +# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP +# is given, then evaluate it. +func_show_eval () +{ + my_cmd="$1" + my_fail_exp="${2-:}" + + ${opt_silent-false} || { + func_quote_for_expand "$my_cmd" + eval "func_echo $func_quote_for_expand_result" + } + + if ${opt_dry_run-false}; then :; else + eval "$my_cmd" + my_status=$? + if test "$my_status" -eq 0; then :; else + eval "(exit $my_status); $my_fail_exp" + fi + fi +} + + +# func_show_eval_locale cmd [fail_exp] +# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is +# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP +# is given, then evaluate it. Use the saved locale for evaluation. +func_show_eval_locale () +{ + my_cmd="$1" + my_fail_exp="${2-:}" + + ${opt_silent-false} || { + func_quote_for_expand "$my_cmd" + eval "func_echo $func_quote_for_expand_result" + } + + if ${opt_dry_run-false}; then :; else + eval "$lt_user_locale + $my_cmd" + my_status=$? + eval "$lt_safe_locale" + if test "$my_status" -eq 0; then :; else + eval "(exit $my_status); $my_fail_exp" + fi + fi +} + + + + + +# func_version +# Echo version message to standard output and exit. +func_version () +{ + $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / { + s/^# // + s/^# *$// + s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ + p + }' < "$progpath" + exit $? +} + +# func_usage +# Echo short help message to standard output and exit. +func_usage () +{ + $SED -n '/^# Usage:/,/# -h/ { + s/^# // + s/^# *$// + s/\$progname/'$progname'/ + p + }' < "$progpath" + $ECHO + $ECHO "run \`$progname --help | more' for full usage" + exit $? +} + +# func_help +# Echo long help message to standard output and exit. +func_help () +{ + $SED -n '/^# Usage:/,/# Report bugs to/ { + s/^# // + s/^# *$// + s*\$progname*'$progname'* + s*\$host*'"$host"'* + s*\$SHELL*'"$SHELL"'* + s*\$LTCC*'"$LTCC"'* + s*\$LTCFLAGS*'"$LTCFLAGS"'* + s*\$LD*'"$LD"'* + s/\$with_gnu_ld/'"$with_gnu_ld"'/ + s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ + s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ + p + }' < "$progpath" + exit $? +} + +# func_missing_arg argname +# Echo program name prefixed message to standard error and set global +# exit_cmd. +func_missing_arg () +{ + func_error "missing argument for $1" + exit_cmd=exit +} + +exit_cmd=: + + + + + +# Check that we have a working $ECHO. +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then + # Yippee, $ECHO works! + : +else + # Restart under the correct shell, and then maybe $ECHO will work. + exec $SHELL "$progpath" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat </dev/null 2>&1; then + taglist="$taglist $tagname" + + # Evaluate the configuration. Be careful to quote the path + # and the sed script, to avoid splitting on whitespace, but + # also don't use non-portable quotes within backquotes within + # quotes we have to do it in 2 steps: + extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` + eval "$extractedcf" + else + func_error "ignoring unknown tag $tagname" + fi + ;; + esac +} + +# Parse options once, thoroughly. This comes as soon as possible in +# the script to make things like `libtool --version' happen quickly. +{ + + # Shorthand for --mode=foo, only valid as the first argument + case $1 in + clean|clea|cle|cl) + shift; set dummy --mode clean ${1+"$@"}; shift + ;; + compile|compil|compi|comp|com|co|c) + shift; set dummy --mode compile ${1+"$@"}; shift + ;; + execute|execut|execu|exec|exe|ex|e) + shift; set dummy --mode execute ${1+"$@"}; shift + ;; + finish|finis|fini|fin|fi|f) + shift; set dummy --mode finish ${1+"$@"}; shift + ;; + install|instal|insta|inst|ins|in|i) + shift; set dummy --mode install ${1+"$@"}; shift + ;; + link|lin|li|l) + shift; set dummy --mode link ${1+"$@"}; shift + ;; + uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) + shift; set dummy --mode uninstall ${1+"$@"}; shift + ;; + esac + + # Parse non-mode specific arguments: + while test "$#" -gt 0; do + opt="$1" + shift + + case $opt in + --config) func_config ;; + + --debug) preserve_args="$preserve_args $opt" + func_echo "enabling shell trace mode" + opt_debug='set -x' + $opt_debug + ;; + + -dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break + execute_dlfiles="$execute_dlfiles $1" + shift + ;; + + --dry-run | -n) opt_dry_run=: ;; + --features) func_features ;; + --finish) mode="finish" ;; + + --mode) test "$#" -eq 0 && func_missing_arg "$opt" && break + case $1 in + # Valid mode arguments: + clean) ;; + compile) ;; + execute) ;; + finish) ;; + install) ;; + link) ;; + relink) ;; + uninstall) ;; + + # Catch anything else as an error + *) func_error "invalid argument for $opt" + exit_cmd=exit + break + ;; + esac + + mode="$1" + shift + ;; + + --preserve-dup-deps) + opt_duplicate_deps=: ;; + + --quiet|--silent) preserve_args="$preserve_args $opt" + opt_silent=: + ;; + + --verbose| -v) preserve_args="$preserve_args $opt" + opt_silent=false + ;; + + --tag) test "$#" -eq 0 && func_missing_arg "$opt" && break + preserve_args="$preserve_args $opt $1" + func_enable_tag "$1" # tagname is set here + shift + ;; + + # Separate optargs to long options: + -dlopen=*|--mode=*|--tag=*) + func_opt_split "$opt" + set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"} + shift + ;; + + -\?|-h) func_usage ;; + --help) opt_help=: ;; + --version) func_version ;; + + -*) func_fatal_help "unrecognized option \`$opt'" ;; + + *) nonopt="$opt" + break + ;; + esac + done + + + case $host in + *cygwin* | *mingw* | *pw32* | *cegcc*) + # don't eliminate duplications in $postdeps and $predeps + opt_duplicate_compiler_generated_deps=: + ;; + *) + opt_duplicate_compiler_generated_deps=$opt_duplicate_deps + ;; + esac + + # Having warned about all mis-specified options, bail out if + # anything was wrong. + $exit_cmd $EXIT_FAILURE +} + +# func_check_version_match +# Ensure that we are using m4 macros, and libtool script from the same +# release of libtool. +func_check_version_match () +{ + if test "$package_revision" != "$macro_revision"; then + if test "$VERSION" != "$macro_version"; then + if test -z "$macro_version"; then + cat >&2 <<_LT_EOF +$progname: Version mismatch error. This is $PACKAGE $VERSION, but the +$progname: definition of this LT_INIT comes from an older release. +$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION +$progname: and run autoconf again. +_LT_EOF + else + cat >&2 <<_LT_EOF +$progname: Version mismatch error. This is $PACKAGE $VERSION, but the +$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. +$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION +$progname: and run autoconf again. +_LT_EOF + fi + else + cat >&2 <<_LT_EOF +$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, +$progname: but the definition of this LT_INIT comes from revision $macro_revision. +$progname: You should recreate aclocal.m4 with macros from revision $package_revision +$progname: of $PACKAGE $VERSION and run autoconf again. +_LT_EOF + fi + + exit $EXIT_MISMATCH + fi +} + + +## ----------- ## +## Main. ## +## ----------- ## + +$opt_help || { + # Sanity checks first: + func_check_version_match + + if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then + func_fatal_configuration "not configured to build any kind of library" + fi + + test -z "$mode" && func_fatal_error "error: you must specify a MODE." + + + # Darwin sucks + eval std_shrext=\"$shrext_cmds\" + + + # Only execute mode is allowed to have -dlopen flags. + if test -n "$execute_dlfiles" && test "$mode" != execute; then + func_error "unrecognized option \`-dlopen'" + $ECHO "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Change the help message to a mode-specific one. + generic_help="$help" + help="Try \`$progname --help --mode=$mode' for more information." +} + + +# func_lalib_p file +# True iff FILE is a libtool `.la' library or `.lo' object file. +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_lalib_p () +{ + test -f "$1" && + $SED -e 4q "$1" 2>/dev/null \ + | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 +} + +# func_lalib_unsafe_p file +# True iff FILE is a libtool `.la' library or `.lo' object file. +# This function implements the same check as func_lalib_p without +# resorting to external programs. To this end, it redirects stdin and +# closes it afterwards, without saving the original file descriptor. +# As a safety measure, use it only where a negative result would be +# fatal anyway. Works if `file' does not exist. +func_lalib_unsafe_p () +{ + lalib_p=no + if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then + for lalib_p_l in 1 2 3 4 + do + read lalib_p_line + case "$lalib_p_line" in + \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; + esac + done + exec 0<&5 5<&- + fi + test "$lalib_p" = yes +} + +# func_ltwrapper_script_p file +# True iff FILE is a libtool wrapper script +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_ltwrapper_script_p () +{ + func_lalib_p "$1" +} + +# func_ltwrapper_executable_p file +# True iff FILE is a libtool wrapper executable +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_ltwrapper_executable_p () +{ + func_ltwrapper_exec_suffix= + case $1 in + *.exe) ;; + *) func_ltwrapper_exec_suffix=.exe ;; + esac + $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 +} + +# func_ltwrapper_scriptname file +# Assumes file is an ltwrapper_executable +# uses $file to determine the appropriate filename for a +# temporary ltwrapper_script. +func_ltwrapper_scriptname () +{ + func_ltwrapper_scriptname_result="" + if func_ltwrapper_executable_p "$1"; then + func_dirname_and_basename "$1" "" "." + func_stripname '' '.exe' "$func_basename_result" + func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" + fi +} + +# func_ltwrapper_p file +# True iff FILE is a libtool wrapper script or wrapper executable +# This function is only a basic sanity check; it will hardly flush out +# determined imposters. +func_ltwrapper_p () +{ + func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" +} + + +# func_execute_cmds commands fail_cmd +# Execute tilde-delimited COMMANDS. +# If FAIL_CMD is given, eval that upon failure. +# FAIL_CMD may read-access the current command in variable CMD! +func_execute_cmds () +{ + $opt_debug + save_ifs=$IFS; IFS='~' + for cmd in $1; do + IFS=$save_ifs + eval cmd=\"$cmd\" + func_show_eval "$cmd" "${2-:}" + done + IFS=$save_ifs +} + + +# func_source file +# Source FILE, adding directory component if necessary. +# Note that it is not necessary on cygwin/mingw to append a dot to +# FILE even if both FILE and FILE.exe exist: automatic-append-.exe +# behavior happens only for exec(3), not for open(2)! Also, sourcing +# `FILE.' does not work on cygwin managed mounts. +func_source () +{ + $opt_debug + case $1 in + */* | *\\*) . "$1" ;; + *) . "./$1" ;; + esac +} + + +# func_infer_tag arg +# Infer tagged configuration to use if any are available and +# if one wasn't chosen via the "--tag" command line option. +# Only attempt this if the compiler in the base compile +# command doesn't match the default compiler. +# arg is usually of the form 'gcc ...' +func_infer_tag () +{ + $opt_debug + if test -n "$available_tags" && test -z "$tagname"; then + CC_quoted= + for arg in $CC; do + func_quote_for_eval "$arg" + CC_quoted="$CC_quoted $func_quote_for_eval_result" + done + case $@ in + # Blanks in the command may have been stripped by the calling shell, + # but not from the CC environment variable when configure was run. + " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;; + # Blanks at the start of $base_compile will cause this to fail + # if we don't check for them as well. + *) + for z in $available_tags; do + if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then + # Evaluate the configuration. + eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" + CC_quoted= + for arg in $CC; do + # Double-quote args containing other shell metacharacters. + func_quote_for_eval "$arg" + CC_quoted="$CC_quoted $func_quote_for_eval_result" + done + case "$@ " in + " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) + # The compiler in the base compile command matches + # the one in the tagged configuration. + # Assume this is the tagged configuration we want. + tagname=$z + break + ;; + esac + fi + done + # If $tagname still isn't set, then no tagged configuration + # was found and let the user know that the "--tag" command + # line option must be used. + if test -z "$tagname"; then + func_echo "unable to infer tagged configuration" + func_fatal_error "specify a tag with \`--tag'" +# else +# func_verbose "using $tagname tagged configuration" + fi + ;; + esac + fi +} + + + +# func_write_libtool_object output_name pic_name nonpic_name +# Create a libtool object file (analogous to a ".la" file), +# but don't create it if we're doing a dry run. +func_write_libtool_object () +{ + write_libobj=${1} + if test "$build_libtool_libs" = yes; then + write_lobj=\'${2}\' + else + write_lobj=none + fi + + if test "$build_old_libs" = yes; then + write_oldobj=\'${3}\' + else + write_oldobj=none + fi + + $opt_dry_run || { + cat >${write_libobj}T <?"'"'"' &()|`$[]' \ + && func_warning "libobj name \`$libobj' may not contain shell special characters." + func_dirname_and_basename "$obj" "/" "" + objname="$func_basename_result" + xdir="$func_dirname_result" + lobj=${xdir}$objdir/$objname + + test -z "$base_compile" && \ + func_fatal_help "you must specify a compilation command" + + # Delete any leftover library objects. + if test "$build_old_libs" = yes; then + removelist="$obj $lobj $libobj ${libobj}T" + else + removelist="$lobj $libobj ${libobj}T" + fi + + # On Cygwin there's no "real" PIC flag so we must build both object types + case $host_os in + cygwin* | mingw* | pw32* | os2* | cegcc*) + pic_mode=default + ;; + esac + if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then + # non-PIC code in shared libraries is not supported + pic_mode=default + fi + + # Calculate the filename of the output object if compiler does + # not support -o with -c + if test "$compiler_c_o" = no; then + output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} + lockfile="$output_obj.lock" + else + output_obj= + need_locks=no + lockfile= + fi + + # Lock this critical section if it is needed + # We use this script file to make the link, it avoids creating a new file + if test "$need_locks" = yes; then + until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do + func_echo "Waiting for $lockfile to be removed" + sleep 2 + done + elif test "$need_locks" = warn; then + if test -f "$lockfile"; then + $ECHO "\ +*** ERROR, $lockfile exists and contains: +`cat $lockfile 2>/dev/null` + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $opt_dry_run || $RM $removelist + exit $EXIT_FAILURE + fi + removelist="$removelist $output_obj" + $ECHO "$srcfile" > "$lockfile" + fi + + $opt_dry_run || $RM $removelist + removelist="$removelist $lockfile" + trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 + + if test -n "$fix_srcfile_path"; then + eval srcfile=\"$fix_srcfile_path\" + fi + func_quote_for_eval "$srcfile" + qsrcfile=$func_quote_for_eval_result + + # Only build a PIC object if we are building libtool libraries. + if test "$build_libtool_libs" = yes; then + # Without this assignment, base_compile gets emptied. + fbsd_hideous_sh_bug=$base_compile + + if test "$pic_mode" != no; then + command="$base_compile $qsrcfile $pic_flag" + else + # Don't build PIC code + command="$base_compile $qsrcfile" + fi + + func_mkdir_p "$xdir$objdir" + + if test -z "$output_obj"; then + # Place PIC objects in $objdir + command="$command -o $lobj" + fi + + func_show_eval_locale "$command" \ + 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' + + if test "$need_locks" = warn && + test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then + $ECHO "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $opt_dry_run || $RM $removelist + exit $EXIT_FAILURE + fi + + # Just move the object if needed, then go on to compile the next one + if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then + func_show_eval '$MV "$output_obj" "$lobj"' \ + 'error=$?; $opt_dry_run || $RM $removelist; exit $error' + fi + + # Allow error messages only from the first compilation. + if test "$suppress_opt" = yes; then + suppress_output=' >/dev/null 2>&1' + fi + fi + + # Only build a position-dependent object if we build old libraries. + if test "$build_old_libs" = yes; then + if test "$pic_mode" != yes; then + # Don't build PIC code + command="$base_compile $qsrcfile$pie_flag" + else + command="$base_compile $qsrcfile $pic_flag" + fi + if test "$compiler_c_o" = yes; then + command="$command -o $obj" + fi + + # Suppress compiler output if we already did a PIC compilation. + command="$command$suppress_output" + func_show_eval_locale "$command" \ + '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' + + if test "$need_locks" = warn && + test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then + $ECHO "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $opt_dry_run || $RM $removelist + exit $EXIT_FAILURE + fi + + # Just move the object if needed + if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then + func_show_eval '$MV "$output_obj" "$obj"' \ + 'error=$?; $opt_dry_run || $RM $removelist; exit $error' + fi + fi + + $opt_dry_run || { + func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" + + # Unlock the critical section if it was locked + if test "$need_locks" != no; then + removelist=$lockfile + $RM "$lockfile" + fi + } + + exit $EXIT_SUCCESS +} + +$opt_help || { +test "$mode" = compile && func_mode_compile ${1+"$@"} +} + +func_mode_help () +{ + # We need to display help for each of the modes. + case $mode in + "") + # Generic help is extracted from the usage comments + # at the start of this file. + func_help + ;; + + clean) + $ECHO \ +"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... + +Remove files from the build directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, object or program, all the files associated +with it are deleted. Otherwise, only FILE itself is deleted using RM." + ;; + + compile) + $ECHO \ +"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE + +Compile a source file into a libtool library object. + +This mode accepts the following additional options: + + -o OUTPUT-FILE set the output file name to OUTPUT-FILE + -no-suppress do not suppress compiler output for multiple passes + -prefer-pic try to building PIC objects only + -prefer-non-pic try to building non-PIC objects only + -shared do not build a \`.o' file suitable for static linking + -static only build a \`.o' file suitable for static linking + +COMPILE-COMMAND is a command to be used in creating a \`standard' object file +from the given SOURCEFILE. + +The output file name is determined by removing the directory component from +SOURCEFILE, then substituting the C source code suffix \`.c' with the +library object suffix, \`.lo'." + ;; + + execute) + $ECHO \ +"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... + +Automatically set library path, then run a program. + +This mode accepts the following additional options: + + -dlopen FILE add the directory containing FILE to the library path + +This mode sets the library path environment variable according to \`-dlopen' +flags. + +If any of the ARGS are libtool executable wrappers, then they are translated +into their corresponding uninstalled binary, and any of their required library +directories are added to the library path. + +Then, COMMAND is executed, with ARGS as arguments." + ;; + + finish) + $ECHO \ +"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... + +Complete the installation of libtool libraries. + +Each LIBDIR is a directory that contains libtool libraries. + +The commands that this mode executes may require superuser privileges. Use +the \`--dry-run' option if you just want to see what would be executed." + ;; + + install) + $ECHO \ +"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... + +Install executables or libraries. + +INSTALL-COMMAND is the installation command. The first component should be +either the \`install' or \`cp' program. + +The following components of INSTALL-COMMAND are treated specially: + + -inst-prefix PREFIX-DIR Use PREFIX-DIR as a staging area for installation + +The rest of the components are interpreted as arguments to that command (only +BSD-compatible install options are recognized)." + ;; + + link) + $ECHO \ +"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... + +Link object files or libraries together to form another library, or to +create an executable program. + +LINK-COMMAND is a command using the C compiler that you would use to create +a program from several object files. + +The following components of LINK-COMMAND are treated specially: + + -all-static do not do any dynamic linking at all + -avoid-version do not add a version suffix if possible + -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime + -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols + -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) + -export-symbols SYMFILE + try to export only the symbols listed in SYMFILE + -export-symbols-regex REGEX + try to export only the symbols matching REGEX + -LLIBDIR search LIBDIR for required installed libraries + -lNAME OUTPUT-FILE requires the installed library libNAME + -module build a library that can dlopened + -no-fast-install disable the fast-install mode + -no-install link a not-installable executable + -no-undefined declare that a library does not refer to external symbols + -o OUTPUT-FILE create OUTPUT-FILE from the specified objects + -objectlist FILE Use a list of object files found in FILE to specify objects + -precious-files-regex REGEX + don't remove output files matching REGEX + -release RELEASE specify package release information + -rpath LIBDIR the created library will eventually be installed in LIBDIR + -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries + -shared only do dynamic linking of libtool libraries + -shrext SUFFIX override the standard shared library file extension + -static do not do any dynamic linking of uninstalled libtool libraries + -static-libtool-libs + do not do any dynamic linking of libtool libraries + -version-info CURRENT[:REVISION[:AGE]] + specify library version info [each variable defaults to 0] + -weak LIBNAME declare that the target provides the LIBNAME interface + +All other options (arguments beginning with \`-') are ignored. + +Every other argument is treated as a filename. Files ending in \`.la' are +treated as uninstalled libtool libraries, other files are standard or library +object files. + +If the OUTPUT-FILE ends in \`.la', then a libtool library is created, +only library objects (\`.lo' files) may be specified, and \`-rpath' is +required, except when creating a convenience library. + +If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created +using \`ar' and \`ranlib', or on Windows using \`lib'. + +If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file +is created, otherwise an executable program is created." + ;; + + uninstall) + $ECHO \ +"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... + +Remove libraries from an installation directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, all the files associated with it are deleted. +Otherwise, only FILE itself is deleted using RM." + ;; + + *) + func_fatal_help "invalid operation mode \`$mode'" + ;; + esac + + $ECHO + $ECHO "Try \`$progname --help' for more information about other modes." + + exit $? +} + + # Now that we've collected a possible --mode arg, show help if necessary + $opt_help && func_mode_help + + +# func_mode_execute arg... +func_mode_execute () +{ + $opt_debug + # The first argument is the command name. + cmd="$nonopt" + test -z "$cmd" && \ + func_fatal_help "you must specify a COMMAND" + + # Handle -dlopen flags immediately. + for file in $execute_dlfiles; do + test -f "$file" \ + || func_fatal_help "\`$file' is not a file" + + dir= + case $file in + *.la) + # Check to see that this really is a libtool archive. + func_lalib_unsafe_p "$file" \ + || func_fatal_help "\`$lib' is not a valid libtool archive" + + # Read the libtool library. + dlname= + library_names= + func_source "$file" + + # Skip this library if it cannot be dlopened. + if test -z "$dlname"; then + # Warn if it was a shared library. + test -n "$library_names" && \ + func_warning "\`$file' was not linked with \`-export-dynamic'" + continue + fi + + func_dirname "$file" "" "." + dir="$func_dirname_result" + + if test -f "$dir/$objdir/$dlname"; then + dir="$dir/$objdir" + else + if test ! -f "$dir/$dlname"; then + func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" + fi + fi + ;; + + *.lo) + # Just add the directory containing the .lo file. + func_dirname "$file" "" "." + dir="$func_dirname_result" + ;; + + *) + func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" + continue + ;; + esac + + # Get the absolute pathname. + absdir=`cd "$dir" && pwd` + test -n "$absdir" && dir="$absdir" + + # Now add the directory to shlibpath_var. + if eval "test -z \"\$$shlibpath_var\""; then + eval "$shlibpath_var=\"\$dir\"" + else + eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" + fi + done + + # This variable tells wrapper scripts just to set shlibpath_var + # rather than running their programs. + libtool_execute_magic="$magic" + + # Check if any of the arguments is a wrapper script. + args= + for file + do + case $file in + -*) ;; + *) + # Do a test to see if this is really a libtool program. + if func_ltwrapper_script_p "$file"; then + func_source "$file" + # Transform arg to wrapped name. + file="$progdir/$program" + elif func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + func_source "$func_ltwrapper_scriptname_result" + # Transform arg to wrapped name. + file="$progdir/$program" + fi + ;; + esac + # Quote arguments (to preserve shell metacharacters). + func_quote_for_eval "$file" + args="$args $func_quote_for_eval_result" + done + + if test "X$opt_dry_run" = Xfalse; then + if test -n "$shlibpath_var"; then + # Export the shlibpath_var. + eval "export $shlibpath_var" + fi + + # Restore saved environment variables + for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES + do + eval "if test \"\${save_$lt_var+set}\" = set; then + $lt_var=\$save_$lt_var; export $lt_var + else + $lt_unset $lt_var + fi" + done + + # Now prepare to actually exec the command. + exec_cmd="\$cmd$args" + else + # Display what would be done. + if test -n "$shlibpath_var"; then + eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" + $ECHO "export $shlibpath_var" + fi + $ECHO "$cmd$args" + exit $EXIT_SUCCESS + fi +} + +test "$mode" = execute && func_mode_execute ${1+"$@"} + + +# func_mode_finish arg... +func_mode_finish () +{ + $opt_debug + libdirs="$nonopt" + admincmds= + + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + for dir + do + libdirs="$libdirs $dir" + done + + for libdir in $libdirs; do + if test -n "$finish_cmds"; then + # Do each command in the finish commands. + func_execute_cmds "$finish_cmds" 'admincmds="$admincmds +'"$cmd"'"' + fi + if test -n "$finish_eval"; then + # Do the single finish_eval. + eval cmds=\"$finish_eval\" + $opt_dry_run || eval "$cmds" || admincmds="$admincmds + $cmds" + fi + done + fi + + # Exit here if they wanted silent mode. + $opt_silent && exit $EXIT_SUCCESS + + $ECHO "X----------------------------------------------------------------------" | $Xsed + $ECHO "Libraries have been installed in:" + for libdir in $libdirs; do + $ECHO " $libdir" + done + $ECHO + $ECHO "If you ever happen to want to link against installed libraries" + $ECHO "in a given directory, LIBDIR, you must either use libtool, and" + $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'" + $ECHO "flag during linking and do at least one of the following:" + if test -n "$shlibpath_var"; then + $ECHO " - add LIBDIR to the \`$shlibpath_var' environment variable" + $ECHO " during execution" + fi + if test -n "$runpath_var"; then + $ECHO " - add LIBDIR to the \`$runpath_var' environment variable" + $ECHO " during linking" + fi + if test -n "$hardcode_libdir_flag_spec"; then + libdir=LIBDIR + eval flag=\"$hardcode_libdir_flag_spec\" + + $ECHO " - use the \`$flag' linker flag" + fi + if test -n "$admincmds"; then + $ECHO " - have your system administrator run these commands:$admincmds" + fi + if test -f /etc/ld.so.conf; then + $ECHO " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" + fi + $ECHO + + $ECHO "See any operating system documentation about shared libraries for" + case $host in + solaris2.[6789]|solaris2.1[0-9]) + $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual" + $ECHO "pages." + ;; + *) + $ECHO "more information, such as the ld(1) and ld.so(8) manual pages." + ;; + esac + $ECHO "X----------------------------------------------------------------------" | $Xsed + exit $EXIT_SUCCESS +} + +test "$mode" = finish && func_mode_finish ${1+"$@"} + + +# func_mode_install arg... +func_mode_install () +{ + $opt_debug + # There may be an optional sh(1) argument at the beginning of + # install_prog (especially on Windows NT). + if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || + # Allow the use of GNU shtool's install command. + $ECHO "X$nonopt" | $GREP shtool >/dev/null; then + # Aesthetically quote it. + func_quote_for_eval "$nonopt" + install_prog="$func_quote_for_eval_result " + arg=$1 + shift + else + install_prog= + arg=$nonopt + fi + + # The real first argument should be the name of the installation program. + # Aesthetically quote it. + func_quote_for_eval "$arg" + install_prog="$install_prog$func_quote_for_eval_result" + + # We need to accept at least all the BSD install flags. + dest= + files= + opts= + prev= + install_type= + isdir=no + stripme= + for arg + do + if test -n "$dest"; then + files="$files $dest" + dest=$arg + continue + fi + + case $arg in + -d) isdir=yes ;; + -f) + case " $install_prog " in + *[\\\ /]cp\ *) ;; + *) prev=$arg ;; + esac + ;; + -g | -m | -o) + prev=$arg + ;; + -s) + stripme=" -s" + continue + ;; + -*) + ;; + *) + # If the previous option needed an argument, then skip it. + if test -n "$prev"; then + prev= + else + dest=$arg + continue + fi + ;; + esac + + # Aesthetically quote the argument. + func_quote_for_eval "$arg" + install_prog="$install_prog $func_quote_for_eval_result" + done + + test -z "$install_prog" && \ + func_fatal_help "you must specify an install program" + + test -n "$prev" && \ + func_fatal_help "the \`$prev' option requires an argument" + + if test -z "$files"; then + if test -z "$dest"; then + func_fatal_help "no file or destination specified" + else + func_fatal_help "you must specify a destination" + fi + fi + + # Strip any trailing slash from the destination. + func_stripname '' '/' "$dest" + dest=$func_stripname_result + + # Check to see that the destination is a directory. + test -d "$dest" && isdir=yes + if test "$isdir" = yes; then + destdir="$dest" + destname= + else + func_dirname_and_basename "$dest" "" "." + destdir="$func_dirname_result" + destname="$func_basename_result" + + # Not a directory, so check to see that there is only one file specified. + set dummy $files; shift + test "$#" -gt 1 && \ + func_fatal_help "\`$dest' is not a directory" + fi + case $destdir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + for file in $files; do + case $file in + *.lo) ;; + *) + func_fatal_help "\`$destdir' must be an absolute directory name" + ;; + esac + done + ;; + esac + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + staticlibs= + future_libdirs= + current_libdirs= + for file in $files; do + + # Do each installation. + case $file in + *.$libext) + # Do the static libraries later. + staticlibs="$staticlibs $file" + ;; + + *.la) + # Check to see that this really is a libtool archive. + func_lalib_unsafe_p "$file" \ + || func_fatal_help "\`$file' is not a valid libtool archive" + + library_names= + old_library= + relink_command= + func_source "$file" + + # Add the libdir to current_libdirs if it is the destination. + if test "X$destdir" = "X$libdir"; then + case "$current_libdirs " in + *" $libdir "*) ;; + *) current_libdirs="$current_libdirs $libdir" ;; + esac + else + # Note the libdir as a future libdir. + case "$future_libdirs " in + *" $libdir "*) ;; + *) future_libdirs="$future_libdirs $libdir" ;; + esac + fi + + func_dirname "$file" "/" "" + dir="$func_dirname_result" + dir="$dir$objdir" + + if test -n "$relink_command"; then + # Determine the prefix the user has applied to our future dir. + inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"` + + # Don't allow the user to place us outside of our expected + # location b/c this prevents finding dependent libraries that + # are installed to the same prefix. + # At present, this check doesn't affect windows .dll's that + # are installed into $libdir/../bin (currently, that works fine) + # but it's something to keep an eye on. + test "$inst_prefix_dir" = "$destdir" && \ + func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" + + if test -n "$inst_prefix_dir"; then + # Stick the inst_prefix_dir data into the link command. + relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` + else + relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"` + fi + + func_warning "relinking \`$file'" + func_show_eval "$relink_command" \ + 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' + fi + + # See the names of the shared library. + set dummy $library_names; shift + if test -n "$1"; then + realname="$1" + shift + + srcname="$realname" + test -n "$relink_command" && srcname="$realname"T + + # Install the shared library and build the symlinks. + func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \ + 'exit $?' + tstripme="$stripme" + case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + case $realname in + *.dll.a) + tstripme="" + ;; + esac + ;; + esac + if test -n "$tstripme" && test -n "$striplib"; then + func_show_eval "$striplib $destdir/$realname" 'exit $?' + fi + + if test "$#" -gt 0; then + # Delete the old symlinks, and create new ones. + # Try `ln -sf' first, because the `ln' binary might depend on + # the symlink we replace! Solaris /bin/ln does not understand -f, + # so we also need to try rm && ln -s. + for linkname + do + test "$linkname" != "$realname" \ + && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" + done + fi + + # Do each command in the postinstall commands. + lib="$destdir/$realname" + func_execute_cmds "$postinstall_cmds" 'exit $?' + fi + + # Install the pseudo-library for information purposes. + func_basename "$file" + name="$func_basename_result" + instname="$dir/$name"i + func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' + + # Maybe install the static library, too. + test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" + ;; + + *.lo) + # Install (i.e. copy) a libtool object. + + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + func_basename "$file" + destfile="$func_basename_result" + destfile="$destdir/$destfile" + fi + + # Deduce the name of the destination old-style object file. + case $destfile in + *.lo) + func_lo2o "$destfile" + staticdest=$func_lo2o_result + ;; + *.$objext) + staticdest="$destfile" + destfile= + ;; + *) + func_fatal_help "cannot copy a libtool object to \`$destfile'" + ;; + esac + + # Install the libtool object if requested. + test -n "$destfile" && \ + func_show_eval "$install_prog $file $destfile" 'exit $?' + + # Install the old object if enabled. + if test "$build_old_libs" = yes; then + # Deduce the name of the old-style object file. + func_lo2o "$file" + staticobj=$func_lo2o_result + func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' + fi + exit $EXIT_SUCCESS + ;; + + *) + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + func_basename "$file" + destfile="$func_basename_result" + destfile="$destdir/$destfile" + fi + + # If the file is missing, and there is a .exe on the end, strip it + # because it is most likely a libtool script we actually want to + # install + stripped_ext="" + case $file in + *.exe) + if test ! -f "$file"; then + func_stripname '' '.exe' "$file" + file=$func_stripname_result + stripped_ext=".exe" + fi + ;; + esac + + # Do a test to see if this is really a libtool program. + case $host in + *cygwin* | *mingw*) + if func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + wrapper=$func_ltwrapper_scriptname_result + else + func_stripname '' '.exe' "$file" + wrapper=$func_stripname_result + fi + ;; + *) + wrapper=$file + ;; + esac + if func_ltwrapper_script_p "$wrapper"; then + notinst_deplibs= + relink_command= + + func_source "$wrapper" + + # Check the variables that should have been set. + test -z "$generated_by_libtool_version" && \ + func_fatal_error "invalid libtool wrapper script \`$wrapper'" + + finalize=yes + for lib in $notinst_deplibs; do + # Check to see that each library is installed. + libdir= + if test -f "$lib"; then + func_source "$lib" + fi + libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test + if test -n "$libdir" && test ! -f "$libfile"; then + func_warning "\`$lib' has not been installed in \`$libdir'" + finalize=no + fi + done + + relink_command= + func_source "$wrapper" + + outputname= + if test "$fast_install" = no && test -n "$relink_command"; then + $opt_dry_run || { + if test "$finalize" = yes; then + tmpdir=`func_mktempdir` + func_basename "$file$stripped_ext" + file="$func_basename_result" + outputname="$tmpdir/$file" + # Replace the output file specification. + relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` + + $opt_silent || { + func_quote_for_expand "$relink_command" + eval "func_echo $func_quote_for_expand_result" + } + if eval "$relink_command"; then : + else + func_error "error: relink \`$file' with the above command before installing it" + $opt_dry_run || ${RM}r "$tmpdir" + continue + fi + file="$outputname" + else + func_warning "cannot relink \`$file'" + fi + } + else + # Install the binary that we compiled earlier. + file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` + fi + fi + + # remove .exe since cygwin /usr/bin/install will append another + # one anyway + case $install_prog,$host in + */usr/bin/install*,*cygwin*) + case $file:$destfile in + *.exe:*.exe) + # this is ok + ;; + *.exe:*) + destfile=$destfile.exe + ;; + *:*.exe) + func_stripname '' '.exe' "$destfile" + destfile=$func_stripname_result + ;; + esac + ;; + esac + func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' + $opt_dry_run || if test -n "$outputname"; then + ${RM}r "$tmpdir" + fi + ;; + esac + done + + for file in $staticlibs; do + func_basename "$file" + name="$func_basename_result" + + # Set up the ranlib parameters. + oldlib="$destdir/$name" + + func_show_eval "$install_prog \$file \$oldlib" 'exit $?' + + if test -n "$stripme" && test -n "$old_striplib"; then + func_show_eval "$old_striplib $oldlib" 'exit $?' + fi + + # Do each command in the postinstall commands. + func_execute_cmds "$old_postinstall_cmds" 'exit $?' + done + + test -n "$future_libdirs" && \ + func_warning "remember to run \`$progname --finish$future_libdirs'" + + if test -n "$current_libdirs"; then + # Maybe just do a dry run. + $opt_dry_run && current_libdirs=" -n$current_libdirs" + exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' + else + exit $EXIT_SUCCESS + fi +} + +test "$mode" = install && func_mode_install ${1+"$@"} + + +# func_generate_dlsyms outputname originator pic_p +# Extract symbols from dlprefiles and create ${outputname}S.o with +# a dlpreopen symbol table. +func_generate_dlsyms () +{ + $opt_debug + my_outputname="$1" + my_originator="$2" + my_pic_p="${3-no}" + my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` + my_dlsyms= + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + if test -n "$NM" && test -n "$global_symbol_pipe"; then + my_dlsyms="${my_outputname}S.c" + else + func_error "not configured to extract global symbols from dlpreopened files" + fi + fi + + if test -n "$my_dlsyms"; then + case $my_dlsyms in + "") ;; + *.c) + # Discover the nlist of each of the dlfiles. + nlist="$output_objdir/${my_outputname}.nm" + + func_show_eval "$RM $nlist ${nlist}S ${nlist}T" + + # Parse the name list into a source file. + func_verbose "creating $output_objdir/$my_dlsyms" + + $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ +/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ +/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ + +#ifdef __cplusplus +extern \"C\" { +#endif + +/* External symbol declarations for the compiler. */\ +" + + if test "$dlself" = yes; then + func_verbose "generating symbol list for \`$output'" + + $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" + + # Add our own program objects to the symbol list. + progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + for progfile in $progfiles; do + func_verbose "extracting global C symbols from \`$progfile'" + $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'" + done + + if test -n "$exclude_expsyms"; then + $opt_dry_run || { + eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' + eval '$MV "$nlist"T "$nlist"' + } + fi + + if test -n "$export_symbols_regex"; then + $opt_dry_run || { + eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' + eval '$MV "$nlist"T "$nlist"' + } + fi + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + export_symbols="$output_objdir/$outputname.exp" + $opt_dry_run || { + $RM $export_symbols + eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' + case $host in + *cygwin* | *mingw* | *cegcc* ) + eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' + eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' + ;; + esac + } + else + $opt_dry_run || { + eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' + eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' + eval '$MV "$nlist"T "$nlist"' + case $host in + *cygwin | *mingw* | *cegcc* ) + eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' + eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' + ;; + esac + } + fi + fi + + for dlprefile in $dlprefiles; do + func_verbose "extracting global C symbols from \`$dlprefile'" + func_basename "$dlprefile" + name="$func_basename_result" + $opt_dry_run || { + eval '$ECHO ": $name " >> "$nlist"' + eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'" + } + done + + $opt_dry_run || { + # Make sure we have at least an empty file. + test -f "$nlist" || : > "$nlist" + + if test -n "$exclude_expsyms"; then + $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T + $MV "$nlist"T "$nlist" + fi + + # Try sorting and uniquifying the output. + if $GREP -v "^: " < "$nlist" | + if sort -k 3 /dev/null 2>&1; then + sort -k 3 + else + sort +2 + fi | + uniq > "$nlist"S; then + : + else + $GREP -v "^: " < "$nlist" > "$nlist"S + fi + + if test -f "$nlist"S; then + eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' + else + $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms" + fi + + $ECHO >> "$output_objdir/$my_dlsyms" "\ + +/* The mapping between symbol names and symbols. */ +typedef struct { + const char *name; + void *address; +} lt_dlsymlist; +" + case $host in + *cygwin* | *mingw* | *cegcc* ) + $ECHO >> "$output_objdir/$my_dlsyms" "\ +/* DATA imports from DLLs on WIN32 con't be const, because + runtime relocations are performed -- see ld's documentation + on pseudo-relocs. */" + lt_dlsym_const= ;; + *osf5*) + echo >> "$output_objdir/$my_dlsyms" "\ +/* This system does not cope well with relocations in const data */" + lt_dlsym_const= ;; + *) + lt_dlsym_const=const ;; + esac + + $ECHO >> "$output_objdir/$my_dlsyms" "\ +extern $lt_dlsym_const lt_dlsymlist +lt_${my_prefix}_LTX_preloaded_symbols[]; +$lt_dlsym_const lt_dlsymlist +lt_${my_prefix}_LTX_preloaded_symbols[] = +{\ + { \"$my_originator\", (void *) 0 }," + + case $need_lib_prefix in + no) + eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" + ;; + *) + eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" + ;; + esac + $ECHO >> "$output_objdir/$my_dlsyms" "\ + {0, (void *) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt_${my_prefix}_LTX_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif\ +" + } # !$opt_dry_run + + pic_flag_for_symtable= + case "$compile_command " in + *" -static "*) ;; + *) + case $host in + # compiling the symbol table file with pic_flag works around + # a FreeBSD bug that causes programs to crash when -lm is + # linked before any other PIC object. But we must not use + # pic_flag when linking with -static. The problem exists in + # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. + *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) + pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; + *-*-hpux*) + pic_flag_for_symtable=" $pic_flag" ;; + *) + if test "X$my_pic_p" != Xno; then + pic_flag_for_symtable=" $pic_flag" + fi + ;; + esac + ;; + esac + symtab_cflags= + for arg in $LTCFLAGS; do + case $arg in + -pie | -fpie | -fPIE) ;; + *) symtab_cflags="$symtab_cflags $arg" ;; + esac + done + + # Now compile the dynamic symbol file. + func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' + + # Clean up the generated files. + func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' + + # Transform the symbol file into the correct name. + symfileobj="$output_objdir/${my_outputname}S.$objext" + case $host in + *cygwin* | *mingw* | *cegcc* ) + if test -f "$output_objdir/$my_outputname.def"; then + compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` + finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` + else + compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` + finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` + fi + ;; + *) + compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` + finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` + ;; + esac + ;; + *) + func_fatal_error "unknown suffix for \`$my_dlsyms'" + ;; + esac + else + # We keep going just in case the user didn't refer to + # lt_preloaded_symbols. The linker will fail if global_symbol_pipe + # really was required. + + # Nullify the symbol file. + compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` + finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` + fi +} + +# func_win32_libid arg +# return the library type of file 'arg' +# +# Need a lot of goo to handle *both* DLLs and import libs +# Has to be a shell function in order to 'eat' the argument +# that is supplied when $file_magic_command is called. +func_win32_libid () +{ + $opt_debug + win32_libid_type="unknown" + win32_fileres=`file -L $1 2>/dev/null` + case $win32_fileres in + *ar\ archive\ import\ library*) # definitely import + win32_libid_type="x86 archive import" + ;; + *ar\ archive*) # could be an import, or static + if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | + $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then + win32_nmres=`eval $NM -f posix -A $1 | + $SED -n -e ' + 1,100{ + / I /{ + s,.*,import, + p + q + } + }'` + case $win32_nmres in + import*) win32_libid_type="x86 archive import";; + *) win32_libid_type="x86 archive static";; + esac + fi + ;; + *DLL*) + win32_libid_type="x86 DLL" + ;; + *executable*) # but shell scripts are "executable" too... + case $win32_fileres in + *MS\ Windows\ PE\ Intel*) + win32_libid_type="x86 DLL" + ;; + esac + ;; + esac + $ECHO "$win32_libid_type" +} + + + +# func_extract_an_archive dir oldlib +func_extract_an_archive () +{ + $opt_debug + f_ex_an_ar_dir="$1"; shift + f_ex_an_ar_oldlib="$1" + func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?' + if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then + : + else + func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" + fi +} + + +# func_extract_archives gentop oldlib ... +func_extract_archives () +{ + $opt_debug + my_gentop="$1"; shift + my_oldlibs=${1+"$@"} + my_oldobjs="" + my_xlib="" + my_xabs="" + my_xdir="" + + for my_xlib in $my_oldlibs; do + # Extract the objects. + case $my_xlib in + [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; + *) my_xabs=`pwd`"/$my_xlib" ;; + esac + func_basename "$my_xlib" + my_xlib="$func_basename_result" + my_xlib_u=$my_xlib + while :; do + case " $extracted_archives " in + *" $my_xlib_u "*) + func_arith $extracted_serial + 1 + extracted_serial=$func_arith_result + my_xlib_u=lt$extracted_serial-$my_xlib ;; + *) break ;; + esac + done + extracted_archives="$extracted_archives $my_xlib_u" + my_xdir="$my_gentop/$my_xlib_u" + + func_mkdir_p "$my_xdir" + + case $host in + *-darwin*) + func_verbose "Extracting $my_xabs" + # Do not bother doing anything if just a dry run + $opt_dry_run || { + darwin_orig_dir=`pwd` + cd $my_xdir || exit $? + darwin_archive=$my_xabs + darwin_curdir=`pwd` + darwin_base_archive=`basename "$darwin_archive"` + darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` + if test -n "$darwin_arches"; then + darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` + darwin_arch= + func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" + for darwin_arch in $darwin_arches ; do + func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" + $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" + cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" + func_extract_an_archive "`pwd`" "${darwin_base_archive}" + cd "$darwin_curdir" + $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" + done # $darwin_arches + ## Okay now we've a bunch of thin objects, gotta fatten them up :) + darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` + darwin_file= + darwin_files= + for darwin_file in $darwin_filelist; do + darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP` + $LIPO -create -output "$darwin_file" $darwin_files + done # $darwin_filelist + $RM -rf unfat-$$ + cd "$darwin_orig_dir" + else + cd $darwin_orig_dir + func_extract_an_archive "$my_xdir" "$my_xabs" + fi # $darwin_arches + } # !$opt_dry_run + ;; + *) + func_extract_an_archive "$my_xdir" "$my_xabs" + ;; + esac + my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` + done + + func_extract_archives_result="$my_oldobjs" +} + + + +# func_emit_wrapper_part1 [arg=no] +# +# Emit the first part of a libtool wrapper script on stdout. +# For more information, see the description associated with +# func_emit_wrapper(), below. +func_emit_wrapper_part1 () +{ + func_emit_wrapper_part1_arg1=no + if test -n "$1" ; then + func_emit_wrapper_part1_arg1=$1 + fi + + $ECHO "\ +#! $SHELL + +# $output - temporary wrapper script for $objdir/$outputname +# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION +# +# The $output program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='${SED} -e 1s/^X//' +sed_quote_subst='$sed_quote_subst' + +# Be Bourne compatible +if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command=\"$relink_command\" + +# This environment variable determines our operation mode. +if test \"\$libtool_install_magic\" = \"$magic\"; then + # install mode needs the following variables: + generated_by_libtool_version='$macro_version' + notinst_deplibs='$notinst_deplibs' +else + # When we are sourced in execute mode, \$file and \$ECHO are already set. + if test \"\$libtool_execute_magic\" != \"$magic\"; then + ECHO=\"$qecho\" + file=\"\$0\" + # Make sure echo works. + if test \"X\$1\" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then + # Yippee, \$ECHO works! + : + else + # Restart under the correct shell, and then maybe \$ECHO will work. + exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} + fi + fi\ +" + $ECHO "\ + + # Find the directory that this script lives in. + thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` + test \"x\$thisdir\" = \"x\$file\" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\` + while test -n \"\$file\"; do + destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` + + # If there was a directory component, then change thisdir. + if test \"x\$destdir\" != \"x\$file\"; then + case \"\$destdir\" in + [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; + *) thisdir=\"\$thisdir/\$destdir\" ;; + esac + fi + + file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\` + file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` + done +" +} +# end: func_emit_wrapper_part1 + +# func_emit_wrapper_part2 [arg=no] +# +# Emit the second part of a libtool wrapper script on stdout. +# For more information, see the description associated with +# func_emit_wrapper(), below. +func_emit_wrapper_part2 () +{ + func_emit_wrapper_part2_arg1=no + if test -n "$1" ; then + func_emit_wrapper_part2_arg1=$1 + fi + + $ECHO "\ + + # Usually 'no', except on cygwin/mingw when embedded into + # the cwrapper. + WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_part2_arg1 + if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then + # special case for '.' + if test \"\$thisdir\" = \".\"; then + thisdir=\`pwd\` + fi + # remove .libs from thisdir + case \"\$thisdir\" in + *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;; + $objdir ) thisdir=. ;; + esac + fi + + # Try to get the absolute directory name. + absdir=\`cd \"\$thisdir\" && pwd\` + test -n \"\$absdir\" && thisdir=\"\$absdir\" +" + + if test "$fast_install" = yes; then + $ECHO "\ + program=lt-'$outputname'$exeext + progdir=\"\$thisdir/$objdir\" + + if test ! -f \"\$progdir/\$program\" || + { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ + test \"X\$file\" != \"X\$progdir/\$program\"; }; then + + file=\"\$\$-\$program\" + + if test ! -d \"\$progdir\"; then + $MKDIR \"\$progdir\" + else + $RM \"\$progdir/\$file\" + fi" + + $ECHO "\ + + # relink executable if necessary + if test -n \"\$relink_command\"; then + if relink_command_output=\`eval \$relink_command 2>&1\`; then : + else + $ECHO \"\$relink_command_output\" >&2 + $RM \"\$progdir/\$file\" + exit 1 + fi + fi + + $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || + { $RM \"\$progdir/\$program\"; + $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } + $RM \"\$progdir/\$file\" + fi" + else + $ECHO "\ + program='$outputname' + progdir=\"\$thisdir/$objdir\" +" + fi + + $ECHO "\ + + if test -f \"\$progdir/\$program\"; then" + + # Export our shlibpath_var if we have one. + if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then + $ECHO "\ + # Add our own library path to $shlibpath_var + $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" + + # Some systems cannot cope with colon-terminated $shlibpath_var + # The second colon is a workaround for a bug in BeOS R4 sed + $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` + + export $shlibpath_var +" + fi + + # fixup the dll searchpath if we need to. + if test -n "$dllsearchpath"; then + $ECHO "\ + # Add the dll search path components to the executable PATH + PATH=$dllsearchpath:\$PATH +" + fi + + $ECHO "\ + if test \"\$libtool_execute_magic\" != \"$magic\"; then + # Run the actual program with our arguments. +" + case $host in + # Backslashes separate directories on plain windows + *-*-mingw | *-*-os2* | *-cegcc*) + $ECHO "\ + exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} +" + ;; + + *) + $ECHO "\ + exec \"\$progdir/\$program\" \${1+\"\$@\"} +" + ;; + esac + $ECHO "\ + \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 + exit 1 + fi + else + # The program doesn't exist. + \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 + \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 + $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 + exit 1 + fi +fi\ +" +} +# end: func_emit_wrapper_part2 + + +# func_emit_wrapper [arg=no] +# +# Emit a libtool wrapper script on stdout. +# Don't directly open a file because we may want to +# incorporate the script contents within a cygwin/mingw +# wrapper executable. Must ONLY be called from within +# func_mode_link because it depends on a number of variables +# set therein. +# +# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR +# variable will take. If 'yes', then the emitted script +# will assume that the directory in which it is stored is +# the $objdir directory. This is a cygwin/mingw-specific +# behavior. +func_emit_wrapper () +{ + func_emit_wrapper_arg1=no + if test -n "$1" ; then + func_emit_wrapper_arg1=$1 + fi + + # split this up so that func_emit_cwrapperexe_src + # can call each part independently. + func_emit_wrapper_part1 "${func_emit_wrapper_arg1}" + func_emit_wrapper_part2 "${func_emit_wrapper_arg1}" +} + + +# func_to_host_path arg +# +# Convert paths to host format when used with build tools. +# Intended for use with "native" mingw (where libtool itself +# is running under the msys shell), or in the following cross- +# build environments: +# $build $host +# mingw (msys) mingw [e.g. native] +# cygwin mingw +# *nix + wine mingw +# where wine is equipped with the `winepath' executable. +# In the native mingw case, the (msys) shell automatically +# converts paths for any non-msys applications it launches, +# but that facility isn't available from inside the cwrapper. +# Similar accommodations are necessary for $host mingw and +# $build cygwin. Calling this function does no harm for other +# $host/$build combinations not listed above. +# +# ARG is the path (on $build) that should be converted to +# the proper representation for $host. The result is stored +# in $func_to_host_path_result. +func_to_host_path () +{ + func_to_host_path_result="$1" + if test -n "$1" ; then + case $host in + *mingw* ) + lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' + case $build in + *mingw* ) # actually, msys + # awkward: cmd appends spaces to result + lt_sed_strip_trailing_spaces="s/[ ]*\$//" + func_to_host_path_tmp1=`( cmd //c echo "$1" |\ + $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""` + func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\ + $SED -e "$lt_sed_naive_backslashify"` + ;; + *cygwin* ) + func_to_host_path_tmp1=`cygpath -w "$1"` + func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\ + $SED -e "$lt_sed_naive_backslashify"` + ;; + * ) + # Unfortunately, winepath does not exit with a non-zero + # error code, so we are forced to check the contents of + # stdout. On the other hand, if the command is not + # found, the shell will set an exit code of 127 and print + # *an error message* to stdout. So we must check for both + # error code of zero AND non-empty stdout, which explains + # the odd construction: + func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null` + if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then + func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\ + $SED -e "$lt_sed_naive_backslashify"` + else + # Allow warning below. + func_to_host_path_result="" + fi + ;; + esac + if test -z "$func_to_host_path_result" ; then + func_error "Could not determine host path corresponding to" + func_error " '$1'" + func_error "Continuing, but uninstalled executables may not work." + # Fallback: + func_to_host_path_result="$1" + fi + ;; + esac + fi +} +# end: func_to_host_path + +# func_to_host_pathlist arg +# +# Convert pathlists to host format when used with build tools. +# See func_to_host_path(), above. This function supports the +# following $build/$host combinations (but does no harm for +# combinations not listed here): +# $build $host +# mingw (msys) mingw [e.g. native] +# cygwin mingw +# *nix + wine mingw +# +# Path separators are also converted from $build format to +# $host format. If ARG begins or ends with a path separator +# character, it is preserved (but converted to $host format) +# on output. +# +# ARG is a pathlist (on $build) that should be converted to +# the proper representation on $host. The result is stored +# in $func_to_host_pathlist_result. +func_to_host_pathlist () +{ + func_to_host_pathlist_result="$1" + if test -n "$1" ; then + case $host in + *mingw* ) + lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' + # Remove leading and trailing path separator characters from + # ARG. msys behavior is inconsistent here, cygpath turns them + # into '.;' and ';.', and winepath ignores them completely. + func_to_host_pathlist_tmp2="$1" + # Once set for this call, this variable should not be + # reassigned. It is used in tha fallback case. + func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\ + $SED -e 's|^:*||' -e 's|:*$||'` + case $build in + *mingw* ) # Actually, msys. + # Awkward: cmd appends spaces to result. + lt_sed_strip_trailing_spaces="s/[ ]*\$//" + func_to_host_pathlist_tmp2=`( cmd //c echo "$func_to_host_pathlist_tmp1" |\ + $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""` + func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\ + $SED -e "$lt_sed_naive_backslashify"` + ;; + *cygwin* ) + func_to_host_pathlist_tmp2=`cygpath -w -p "$func_to_host_pathlist_tmp1"` + func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\ + $SED -e "$lt_sed_naive_backslashify"` + ;; + * ) + # unfortunately, winepath doesn't convert pathlists + func_to_host_pathlist_result="" + func_to_host_pathlist_oldIFS=$IFS + IFS=: + for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do + IFS=$func_to_host_pathlist_oldIFS + if test -n "$func_to_host_pathlist_f" ; then + func_to_host_path "$func_to_host_pathlist_f" + if test -n "$func_to_host_path_result" ; then + if test -z "$func_to_host_pathlist_result" ; then + func_to_host_pathlist_result="$func_to_host_path_result" + else + func_to_host_pathlist_result="$func_to_host_pathlist_result;$func_to_host_path_result" + fi + fi + fi + IFS=: + done + IFS=$func_to_host_pathlist_oldIFS + ;; + esac + if test -z "$func_to_host_pathlist_result" ; then + func_error "Could not determine the host path(s) corresponding to" + func_error " '$1'" + func_error "Continuing, but uninstalled executables may not work." + # Fallback. This may break if $1 contains DOS-style drive + # specifications. The fix is not to complicate the expression + # below, but for the user to provide a working wine installation + # with winepath so that path translation in the cross-to-mingw + # case works properly. + lt_replace_pathsep_nix_to_dos="s|:|;|g" + func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\ + $SED -e "$lt_replace_pathsep_nix_to_dos"` + fi + # Now, add the leading and trailing path separators back + case "$1" in + :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result" + ;; + esac + case "$1" in + *: ) func_to_host_pathlist_result="$func_to_host_pathlist_result;" + ;; + esac + ;; + esac + fi +} +# end: func_to_host_pathlist + +# func_emit_cwrapperexe_src +# emit the source code for a wrapper executable on stdout +# Must ONLY be called from within func_mode_link because +# it depends on a number of variable set therein. +func_emit_cwrapperexe_src () +{ + cat < +#include +#ifdef _MSC_VER +# include +# include +# include +# define setmode _setmode +#else +# include +# include +# ifdef __CYGWIN__ +# include +# define HAVE_SETENV +# ifdef __STRICT_ANSI__ +char *realpath (const char *, char *); +int putenv (char *); +int setenv (const char *, const char *, int); +# endif +# endif +#endif +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(PATH_MAX) +# define LT_PATHMAX PATH_MAX +#elif defined(MAXPATHLEN) +# define LT_PATHMAX MAXPATHLEN +#else +# define LT_PATHMAX 1024 +#endif + +#ifndef S_IXOTH +# define S_IXOTH 0 +#endif +#ifndef S_IXGRP +# define S_IXGRP 0 +#endif + +#ifdef _MSC_VER +# define S_IXUSR _S_IEXEC +# define stat _stat +# ifndef _INTPTR_T_DEFINED +# define intptr_t int +# endif +#endif + +#ifndef DIR_SEPARATOR +# define DIR_SEPARATOR '/' +# define PATH_SEPARATOR ':' +#endif + +#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ + defined (__OS2__) +# define HAVE_DOS_BASED_FILE_SYSTEM +# define FOPEN_WB "wb" +# ifndef DIR_SEPARATOR_2 +# define DIR_SEPARATOR_2 '\\' +# endif +# ifndef PATH_SEPARATOR_2 +# define PATH_SEPARATOR_2 ';' +# endif +#endif + +#ifndef DIR_SEPARATOR_2 +# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) +#else /* DIR_SEPARATOR_2 */ +# define IS_DIR_SEPARATOR(ch) \ + (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) +#endif /* DIR_SEPARATOR_2 */ + +#ifndef PATH_SEPARATOR_2 +# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) +#else /* PATH_SEPARATOR_2 */ +# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) +#endif /* PATH_SEPARATOR_2 */ + +#ifdef __CYGWIN__ +# define FOPEN_WB "wb" +#endif + +#ifndef FOPEN_WB +# define FOPEN_WB "w" +#endif +#ifndef _O_BINARY +# define _O_BINARY 0 +#endif + +#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) +#define XFREE(stale) do { \ + if (stale) { free ((void *) stale); stale = 0; } \ +} while (0) + +#undef LTWRAPPER_DEBUGPRINTF +#if defined DEBUGWRAPPER +# define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args +static void +ltwrapper_debugprintf (const char *fmt, ...) +{ + va_list args; + va_start (args, fmt); + (void) vfprintf (stderr, fmt, args); + va_end (args); +} +#else +# define LTWRAPPER_DEBUGPRINTF(args) +#endif + +const char *program_name = NULL; + +void *xmalloc (size_t num); +char *xstrdup (const char *string); +const char *base_name (const char *name); +char *find_executable (const char *wrapper); +char *chase_symlinks (const char *pathspec); +int make_executable (const char *path); +int check_executable (const char *path); +char *strendzap (char *str, const char *pat); +void lt_fatal (const char *message, ...); +void lt_setenv (const char *name, const char *value); +char *lt_extend_str (const char *orig_value, const char *add, int to_end); +void lt_opt_process_env_set (const char *arg); +void lt_opt_process_env_prepend (const char *arg); +void lt_opt_process_env_append (const char *arg); +int lt_split_name_value (const char *arg, char** name, char** value); +void lt_update_exe_path (const char *name, const char *value); +void lt_update_lib_path (const char *name, const char *value); + +static const char *script_text_part1 = +EOF + + func_emit_wrapper_part1 yes | + $SED -e 's/\([\\"]\)/\\\1/g' \ + -e 's/^/ "/' -e 's/$/\\n"/' + echo ";" + cat <"))); + for (i = 0; i < newargc; i++) + { + LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d] : %s\n", i, (newargz[i] ? newargz[i] : ""))); + } + +EOF + + case $host_os in + mingw*) + cat <<"EOF" + /* execv doesn't actually work on mingw as expected on unix */ + rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); + if (rval == -1) + { + /* failed to start process */ + LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno)); + return 127; + } + return rval; +EOF + ;; + *) + cat <<"EOF" + execv (lt_argv_zero, newargz); + return rval; /* =127, but avoids unused variable warning */ +EOF + ;; + esac + + cat <<"EOF" +} + +void * +xmalloc (size_t num) +{ + void *p = (void *) malloc (num); + if (!p) + lt_fatal ("Memory exhausted"); + + return p; +} + +char * +xstrdup (const char *string) +{ + return string ? strcpy ((char *) xmalloc (strlen (string) + 1), + string) : NULL; +} + +const char * +base_name (const char *name) +{ + const char *base; + +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + /* Skip over the disk name in MSDOS pathnames. */ + if (isalpha ((unsigned char) name[0]) && name[1] == ':') + name += 2; +#endif + + for (base = name; *name; name++) + if (IS_DIR_SEPARATOR (*name)) + base = name + 1; + return base; +} + +int +check_executable (const char *path) +{ + struct stat st; + + LTWRAPPER_DEBUGPRINTF (("(check_executable) : %s\n", + path ? (*path ? path : "EMPTY!") : "NULL!")); + if ((!path) || (!*path)) + return 0; + + if ((stat (path, &st) >= 0) + && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) + return 1; + else + return 0; +} + +int +make_executable (const char *path) +{ + int rval = 0; + struct stat st; + + LTWRAPPER_DEBUGPRINTF (("(make_executable) : %s\n", + path ? (*path ? path : "EMPTY!") : "NULL!")); + if ((!path) || (!*path)) + return 0; + + if (stat (path, &st) >= 0) + { + rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); + } + return rval; +} + +/* Searches for the full path of the wrapper. Returns + newly allocated full path name if found, NULL otherwise + Does not chase symlinks, even on platforms that support them. +*/ +char * +find_executable (const char *wrapper) +{ + int has_slash = 0; + const char *p; + const char *p_next; + /* static buffer for getcwd */ + char tmp[LT_PATHMAX + 1]; + int tmp_len; + char *concat_name; + + LTWRAPPER_DEBUGPRINTF (("(find_executable) : %s\n", + wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!")); + + if ((wrapper == NULL) || (*wrapper == '\0')) + return NULL; + + /* Absolute path? */ +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') + { + concat_name = xstrdup (wrapper); + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + } + else + { +#endif + if (IS_DIR_SEPARATOR (wrapper[0])) + { + concat_name = xstrdup (wrapper); + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + } +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + } +#endif + + for (p = wrapper; *p; p++) + if (*p == '/') + { + has_slash = 1; + break; + } + if (!has_slash) + { + /* no slashes; search PATH */ + const char *path = getenv ("PATH"); + if (path != NULL) + { + for (p = path; *p; p = p_next) + { + const char *q; + size_t p_len; + for (q = p; *q; q++) + if (IS_PATH_SEPARATOR (*q)) + break; + p_len = q - p; + p_next = (*q == '\0' ? q : q + 1); + if (p_len == 0) + { + /* empty path: current directory */ + if (getcwd (tmp, LT_PATHMAX) == NULL) + lt_fatal ("getcwd failed"); + tmp_len = strlen (tmp); + concat_name = + XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); + memcpy (concat_name, tmp, tmp_len); + concat_name[tmp_len] = '/'; + strcpy (concat_name + tmp_len + 1, wrapper); + } + else + { + concat_name = + XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); + memcpy (concat_name, p, p_len); + concat_name[p_len] = '/'; + strcpy (concat_name + p_len + 1, wrapper); + } + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + } + } + /* not found in PATH; assume curdir */ + } + /* Relative path | not found in path: prepend cwd */ + if (getcwd (tmp, LT_PATHMAX) == NULL) + lt_fatal ("getcwd failed"); + tmp_len = strlen (tmp); + concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); + memcpy (concat_name, tmp, tmp_len); + concat_name[tmp_len] = '/'; + strcpy (concat_name + tmp_len + 1, wrapper); + + if (check_executable (concat_name)) + return concat_name; + XFREE (concat_name); + return NULL; +} + +char * +chase_symlinks (const char *pathspec) +{ +#ifndef S_ISLNK + return xstrdup (pathspec); +#else + char buf[LT_PATHMAX]; + struct stat s; + char *tmp_pathspec = xstrdup (pathspec); + char *p; + int has_symlinks = 0; + while (strlen (tmp_pathspec) && !has_symlinks) + { + LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n", + tmp_pathspec)); + if (lstat (tmp_pathspec, &s) == 0) + { + if (S_ISLNK (s.st_mode) != 0) + { + has_symlinks = 1; + break; + } + + /* search backwards for last DIR_SEPARATOR */ + p = tmp_pathspec + strlen (tmp_pathspec) - 1; + while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) + p--; + if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) + { + /* no more DIR_SEPARATORS left */ + break; + } + *p = '\0'; + } + else + { + char *errstr = strerror (errno); + lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr); + } + } + XFREE (tmp_pathspec); + + if (!has_symlinks) + { + return xstrdup (pathspec); + } + + tmp_pathspec = realpath (pathspec, buf); + if (tmp_pathspec == 0) + { + lt_fatal ("Could not follow symlinks for %s", pathspec); + } + return xstrdup (tmp_pathspec); +#endif +} + +char * +strendzap (char *str, const char *pat) +{ + size_t len, patlen; + + assert (str != NULL); + assert (pat != NULL); + + len = strlen (str); + patlen = strlen (pat); + + if (patlen <= len) + { + str += len - patlen; + if (strcmp (str, pat) == 0) + *str = '\0'; + } + return str; +} + +static void +lt_error_core (int exit_status, const char *mode, + const char *message, va_list ap) +{ + fprintf (stderr, "%s: %s: ", program_name, mode); + vfprintf (stderr, message, ap); + fprintf (stderr, ".\n"); + + if (exit_status >= 0) + exit (exit_status); +} + +void +lt_fatal (const char *message, ...) +{ + va_list ap; + va_start (ap, message); + lt_error_core (EXIT_FAILURE, "FATAL", message, ap); + va_end (ap); +} + +void +lt_setenv (const char *name, const char *value) +{ + LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n", + (name ? name : ""), + (value ? value : ""))); + { +#ifdef HAVE_SETENV + /* always make a copy, for consistency with !HAVE_SETENV */ + char *str = xstrdup (value); + setenv (name, str, 1); +#else + int len = strlen (name) + 1 + strlen (value) + 1; + char *str = XMALLOC (char, len); + sprintf (str, "%s=%s", name, value); + if (putenv (str) != EXIT_SUCCESS) + { + XFREE (str); + } +#endif + } +} + +char * +lt_extend_str (const char *orig_value, const char *add, int to_end) +{ + char *new_value; + if (orig_value && *orig_value) + { + int orig_value_len = strlen (orig_value); + int add_len = strlen (add); + new_value = XMALLOC (char, add_len + orig_value_len + 1); + if (to_end) + { + strcpy (new_value, orig_value); + strcpy (new_value + orig_value_len, add); + } + else + { + strcpy (new_value, add); + strcpy (new_value + add_len, orig_value); + } + } + else + { + new_value = xstrdup (add); + } + return new_value; +} + +int +lt_split_name_value (const char *arg, char** name, char** value) +{ + const char *p; + int len; + if (!arg || !*arg) + return 1; + + p = strchr (arg, (int)'='); + + if (!p) + return 1; + + *value = xstrdup (++p); + + len = strlen (arg) - strlen (*value); + *name = XMALLOC (char, len); + strncpy (*name, arg, len-1); + (*name)[len - 1] = '\0'; + + return 0; +} + +void +lt_opt_process_env_set (const char *arg) +{ + char *name = NULL; + char *value = NULL; + + if (lt_split_name_value (arg, &name, &value) != 0) + { + XFREE (name); + XFREE (value); + lt_fatal ("bad argument for %s: '%s'", env_set_opt, arg); + } + + lt_setenv (name, value); + XFREE (name); + XFREE (value); +} + +void +lt_opt_process_env_prepend (const char *arg) +{ + char *name = NULL; + char *value = NULL; + char *new_value = NULL; + + if (lt_split_name_value (arg, &name, &value) != 0) + { + XFREE (name); + XFREE (value); + lt_fatal ("bad argument for %s: '%s'", env_prepend_opt, arg); + } + + new_value = lt_extend_str (getenv (name), value, 0); + lt_setenv (name, new_value); + XFREE (new_value); + XFREE (name); + XFREE (value); +} + +void +lt_opt_process_env_append (const char *arg) +{ + char *name = NULL; + char *value = NULL; + char *new_value = NULL; + + if (lt_split_name_value (arg, &name, &value) != 0) + { + XFREE (name); + XFREE (value); + lt_fatal ("bad argument for %s: '%s'", env_append_opt, arg); + } + + new_value = lt_extend_str (getenv (name), value, 1); + lt_setenv (name, new_value); + XFREE (new_value); + XFREE (name); + XFREE (value); +} + +void +lt_update_exe_path (const char *name, const char *value) +{ + LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n", + (name ? name : ""), + (value ? value : ""))); + + if (name && *name && value && *value) + { + char *new_value = lt_extend_str (getenv (name), value, 0); + /* some systems can't cope with a ':'-terminated path #' */ + int len = strlen (new_value); + while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) + { + new_value[len-1] = '\0'; + } + lt_setenv (name, new_value); + XFREE (new_value); + } +} + +void +lt_update_lib_path (const char *name, const char *value) +{ + LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n", + (name ? name : ""), + (value ? value : ""))); + + if (name && *name && value && *value) + { + char *new_value = lt_extend_str (getenv (name), value, 0); + lt_setenv (name, new_value); + XFREE (new_value); + } +} + + +EOF +} +# end: func_emit_cwrapperexe_src + +# func_mode_link arg... +func_mode_link () +{ + $opt_debug + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + # It is impossible to link a dll without this setting, and + # we shouldn't force the makefile maintainer to figure out + # which system we are compiling for in order to pass an extra + # flag for every libtool invocation. + # allow_undefined=no + + # FIXME: Unfortunately, there are problems with the above when trying + # to make a dll which has undefined symbols, in which case not + # even a static library is built. For now, we need to specify + # -no-undefined on the libtool link line when we can be certain + # that all symbols are satisfied, otherwise we get a static library. + allow_undefined=yes + ;; + *) + allow_undefined=yes + ;; + esac + libtool_args=$nonopt + base_compile="$nonopt $@" + compile_command=$nonopt + finalize_command=$nonopt + + compile_rpath= + finalize_rpath= + compile_shlibpath= + finalize_shlibpath= + convenience= + old_convenience= + deplibs= + old_deplibs= + compiler_flags= + linker_flags= + dllsearchpath= + lib_search_path=`pwd` + inst_prefix_dir= + new_inherited_linker_flags= + + avoid_version=no + dlfiles= + dlprefiles= + dlself=no + export_dynamic=no + export_symbols= + export_symbols_regex= + generated= + libobjs= + ltlibs= + module=no + no_install=no + objs= + non_pic_objects= + precious_files_regex= + prefer_static_libs=no + preload=no + prev= + prevarg= + release= + rpath= + xrpath= + perm_rpath= + temp_rpath= + thread_safe=no + vinfo= + vinfo_number=no + weak_libs= + single_module="${wl}-single_module" + func_infer_tag $base_compile + + # We need to know -static, to get the right output filenames. + for arg + do + case $arg in + -shared) + test "$build_libtool_libs" != yes && \ + func_fatal_configuration "can not build a shared library" + build_old_libs=no + break + ;; + -all-static | -static | -static-libtool-libs) + case $arg in + -all-static) + if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then + func_warning "complete static linking is impossible in this configuration" + fi + if test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=yes + ;; + -static) + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=built + ;; + -static-libtool-libs) + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + prefer_static_libs=yes + ;; + esac + build_libtool_libs=no + build_old_libs=yes + break + ;; + esac + done + + # See if our shared archives depend on static archives. + test -n "$old_archive_from_new_cmds" && build_old_libs=yes + + # Go through the arguments, transforming them on the way. + while test "$#" -gt 0; do + arg="$1" + shift + func_quote_for_eval "$arg" + qarg=$func_quote_for_eval_unquoted_result + func_append libtool_args " $func_quote_for_eval_result" + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case $prev in + output) + func_append compile_command " @OUTPUT@" + func_append finalize_command " @OUTPUT@" + ;; + esac + + case $prev in + dlfiles|dlprefiles) + if test "$preload" = no; then + # Add the symbol object into the linking commands. + func_append compile_command " @SYMFILE@" + func_append finalize_command " @SYMFILE@" + preload=yes + fi + case $arg in + *.la | *.lo) ;; # We handle these cases below. + force) + if test "$dlself" = no; then + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + self) + if test "$prev" = dlprefiles; then + dlself=yes + elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then + dlself=yes + else + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + *) + if test "$prev" = dlfiles; then + dlfiles="$dlfiles $arg" + else + dlprefiles="$dlprefiles $arg" + fi + prev= + continue + ;; + esac + ;; + expsyms) + export_symbols="$arg" + test -f "$arg" \ + || func_fatal_error "symbol file \`$arg' does not exist" + prev= + continue + ;; + expsyms_regex) + export_symbols_regex="$arg" + prev= + continue + ;; + framework) + case $host in + *-*-darwin*) + case "$deplibs " in + *" $qarg.ltframework "*) ;; + *) deplibs="$deplibs $qarg.ltframework" # this is fixed later + ;; + esac + ;; + esac + prev= + continue + ;; + inst_prefix) + inst_prefix_dir="$arg" + prev= + continue + ;; + objectlist) + if test -f "$arg"; then + save_arg=$arg + moreargs= + for fil in `cat "$save_arg"` + do +# moreargs="$moreargs $fil" + arg=$fil + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if func_lalib_unsafe_p "$arg"; then + pic_object= + non_pic_object= + + # Read the .lo file + func_source "$arg" + + if test -z "$pic_object" || + test -z "$non_pic_object" || + test "$pic_object" = none && + test "$non_pic_object" = none; then + func_fatal_error "cannot find name of object for \`$arg'" + fi + + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir="$func_dirname_result" + + if test "$pic_object" != none; then + # Prepend the subdirectory the object is found in. + pic_object="$xdir$pic_object" + + if test "$prev" = dlfiles; then + if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then + dlfiles="$dlfiles $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test "$prev" = dlprefiles; then + # Preload the old-style object. + dlprefiles="$dlprefiles $pic_object" + prev= + fi + + # A PIC object. + func_append libobjs " $pic_object" + arg="$pic_object" + fi + + # Non-PIC object. + if test "$non_pic_object" != none; then + # Prepend the subdirectory the object is found in. + non_pic_object="$xdir$non_pic_object" + + # A standard non-PIC object + func_append non_pic_objects " $non_pic_object" + if test -z "$pic_object" || test "$pic_object" = none ; then + arg="$non_pic_object" + fi + else + # If the PIC object exists, use it instead. + # $xdir was prepended to $pic_object above. + non_pic_object="$pic_object" + func_append non_pic_objects " $non_pic_object" + fi + else + # Only an error if not doing a dry-run. + if $opt_dry_run; then + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir="$func_dirname_result" + + func_lo2o "$arg" + pic_object=$xdir$objdir/$func_lo2o_result + non_pic_object=$xdir$func_lo2o_result + func_append libobjs " $pic_object" + func_append non_pic_objects " $non_pic_object" + else + func_fatal_error "\`$arg' is not a valid libtool object" + fi + fi + done + else + func_fatal_error "link input file \`$arg' does not exist" + fi + arg=$save_arg + prev= + continue + ;; + precious_regex) + precious_files_regex="$arg" + prev= + continue + ;; + release) + release="-$arg" + prev= + continue + ;; + rpath | xrpath) + # We need an absolute path. + case $arg in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + func_fatal_error "only absolute run-paths are allowed" + ;; + esac + if test "$prev" = rpath; then + case "$rpath " in + *" $arg "*) ;; + *) rpath="$rpath $arg" ;; + esac + else + case "$xrpath " in + *" $arg "*) ;; + *) xrpath="$xrpath $arg" ;; + esac + fi + prev= + continue + ;; + shrext) + shrext_cmds="$arg" + prev= + continue + ;; + weak) + weak_libs="$weak_libs $arg" + prev= + continue + ;; + xcclinker) + linker_flags="$linker_flags $qarg" + compiler_flags="$compiler_flags $qarg" + prev= + func_append compile_command " $qarg" + func_append finalize_command " $qarg" + continue + ;; + xcompiler) + compiler_flags="$compiler_flags $qarg" + prev= + func_append compile_command " $qarg" + func_append finalize_command " $qarg" + continue + ;; + xlinker) + linker_flags="$linker_flags $qarg" + compiler_flags="$compiler_flags $wl$qarg" + prev= + func_append compile_command " $wl$qarg" + func_append finalize_command " $wl$qarg" + continue + ;; + *) + eval "$prev=\"\$arg\"" + prev= + continue + ;; + esac + fi # test -n "$prev" + + prevarg="$arg" + + case $arg in + -all-static) + if test -n "$link_static_flag"; then + # See comment for -static flag below, for more details. + func_append compile_command " $link_static_flag" + func_append finalize_command " $link_static_flag" + fi + continue + ;; + + -allow-undefined) + # FIXME: remove this flag sometime in the future. + func_fatal_error "\`-allow-undefined' must not be used because it is the default" + ;; + + -avoid-version) + avoid_version=yes + continue + ;; + + -dlopen) + prev=dlfiles + continue + ;; + + -dlpreopen) + prev=dlprefiles + continue + ;; + + -export-dynamic) + export_dynamic=yes + continue + ;; + + -export-symbols | -export-symbols-regex) + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + func_fatal_error "more than one -exported-symbols argument is not allowed" + fi + if test "X$arg" = "X-export-symbols"; then + prev=expsyms + else + prev=expsyms_regex + fi + continue + ;; + + -framework) + prev=framework + continue + ;; + + -inst-prefix-dir) + prev=inst_prefix + continue + ;; + + # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* + # so, if we see these flags be careful not to treat them like -L + -L[A-Z][A-Z]*:*) + case $with_gcc/$host in + no/*-*-irix* | /*-*-irix*) + func_append compile_command " $arg" + func_append finalize_command " $arg" + ;; + esac + continue + ;; + + -L*) + func_stripname '-L' '' "$arg" + dir=$func_stripname_result + if test -z "$dir"; then + if test "$#" -gt 0; then + func_fatal_error "require no space between \`-L' and \`$1'" + else + func_fatal_error "need path for \`-L' option" + fi + fi + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + absdir=`cd "$dir" && pwd` + test -z "$absdir" && \ + func_fatal_error "cannot determine absolute directory name of \`$dir'" + dir="$absdir" + ;; + esac + case "$deplibs " in + *" -L$dir "*) ;; + *) + deplibs="$deplibs -L$dir" + lib_search_path="$lib_search_path $dir" + ;; + esac + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'` + case :$dllsearchpath: in + *":$dir:"*) ;; + ::) dllsearchpath=$dir;; + *) dllsearchpath="$dllsearchpath:$dir";; + esac + case :$dllsearchpath: in + *":$testbindir:"*) ;; + ::) dllsearchpath=$testbindir;; + *) dllsearchpath="$dllsearchpath:$testbindir";; + esac + ;; + esac + continue + ;; + + -l*) + if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc*) + # These systems don't actually have a C or math library (as such) + continue + ;; + *-*-os2*) + # These systems don't actually have a C library (as such) + test "X$arg" = "X-lc" && continue + ;; + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) + # Do not include libc due to us having libc/libc_r. + test "X$arg" = "X-lc" && continue + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C and math libraries are in the System framework + deplibs="$deplibs System.ltframework" + continue + ;; + *-*-sco3.2v5* | *-*-sco5v6*) + # Causes problems with __ctype + test "X$arg" = "X-lc" && continue + ;; + *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) + # Compiler inserts libc in the correct place for threads to work + test "X$arg" = "X-lc" && continue + ;; + esac + elif test "X$arg" = "X-lc_r"; then + case $host in + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) + # Do not include libc_r directly, use -pthread flag. + continue + ;; + esac + fi + deplibs="$deplibs $arg" + continue + ;; + + -module) + module=yes + continue + ;; + + # Tru64 UNIX uses -model [arg] to determine the layout of C++ + # classes, name mangling, and exception handling. + # Darwin uses the -arch flag to determine output architecture. + -model|-arch|-isysroot) + compiler_flags="$compiler_flags $arg" + func_append compile_command " $arg" + func_append finalize_command " $arg" + prev=xcompiler + continue + ;; + + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) + compiler_flags="$compiler_flags $arg" + func_append compile_command " $arg" + func_append finalize_command " $arg" + case "$new_inherited_linker_flags " in + *" $arg "*) ;; + * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;; + esac + continue + ;; + + -multi_module) + single_module="${wl}-multi_module" + continue + ;; + + -no-fast-install) + fast_install=no + continue + ;; + + -no-install) + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) + # The PATH hackery in wrapper scripts is required on Windows + # and Darwin in order for the loader to find any dlls it needs. + func_warning "\`-no-install' is ignored for $host" + func_warning "assuming \`-no-fast-install' instead" + fast_install=no + ;; + *) no_install=yes ;; + esac + continue + ;; + + -no-undefined) + allow_undefined=no + continue + ;; + + -objectlist) + prev=objectlist + continue + ;; + + -o) prev=output ;; + + -precious-files-regex) + prev=precious_regex + continue + ;; + + -release) + prev=release + continue + ;; + + -rpath) + prev=rpath + continue + ;; + + -R) + prev=xrpath + continue + ;; + + -R*) + func_stripname '-R' '' "$arg" + dir=$func_stripname_result + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + func_fatal_error "only absolute run-paths are allowed" + ;; + esac + case "$xrpath " in + *" $dir "*) ;; + *) xrpath="$xrpath $dir" ;; + esac + continue + ;; + + -shared) + # The effects of -shared are defined in a previous loop. + continue + ;; + + -shrext) + prev=shrext + continue + ;; + + -static | -static-libtool-libs) + # The effects of -static are defined in a previous loop. + # We used to do the same as -all-static on platforms that + # didn't have a PIC flag, but the assumption that the effects + # would be equivalent was wrong. It would break on at least + # Digital Unix and AIX. + continue + ;; + + -thread-safe) + thread_safe=yes + continue + ;; + + -version-info) + prev=vinfo + continue + ;; + + -version-number) + prev=vinfo + vinfo_number=yes + continue + ;; + + -weak) + prev=weak + continue + ;; + + -Wc,*) + func_stripname '-Wc,' '' "$arg" + args=$func_stripname_result + arg= + save_ifs="$IFS"; IFS=',' + for flag in $args; do + IFS="$save_ifs" + func_quote_for_eval "$flag" + arg="$arg $wl$func_quote_for_eval_result" + compiler_flags="$compiler_flags $func_quote_for_eval_result" + done + IFS="$save_ifs" + func_stripname ' ' '' "$arg" + arg=$func_stripname_result + ;; + + -Wl,*) + func_stripname '-Wl,' '' "$arg" + args=$func_stripname_result + arg= + save_ifs="$IFS"; IFS=',' + for flag in $args; do + IFS="$save_ifs" + func_quote_for_eval "$flag" + arg="$arg $wl$func_quote_for_eval_result" + compiler_flags="$compiler_flags $wl$func_quote_for_eval_result" + linker_flags="$linker_flags $func_quote_for_eval_result" + done + IFS="$save_ifs" + func_stripname ' ' '' "$arg" + arg=$func_stripname_result + ;; + + -Xcompiler) + prev=xcompiler + continue + ;; + + -Xlinker) + prev=xlinker + continue + ;; + + -XCClinker) + prev=xcclinker + continue + ;; + + # -msg_* for osf cc + -msg_*) + func_quote_for_eval "$arg" + arg="$func_quote_for_eval_result" + ;; + + # -64, -mips[0-9] enable 64-bit mode on the SGI compiler + # -r[0-9][0-9]* specifies the processor on the SGI compiler + # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler + # +DA*, +DD* enable 64-bit mode on the HP compiler + # -q* pass through compiler args for the IBM compiler + # -m*, -t[45]*, -txscale* pass through architecture-specific + # compiler args for GCC + # -F/path gives path to uninstalled frameworks, gcc on darwin + # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC + # @file GCC response files + -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ + -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*) + func_quote_for_eval "$arg" + arg="$func_quote_for_eval_result" + func_append compile_command " $arg" + func_append finalize_command " $arg" + compiler_flags="$compiler_flags $arg" + continue + ;; + + # Some other compiler flag. + -* | +*) + func_quote_for_eval "$arg" + arg="$func_quote_for_eval_result" + ;; + + *.$objext) + # A standard object. + objs="$objs $arg" + ;; + + *.lo) + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if func_lalib_unsafe_p "$arg"; then + pic_object= + non_pic_object= + + # Read the .lo file + func_source "$arg" + + if test -z "$pic_object" || + test -z "$non_pic_object" || + test "$pic_object" = none && + test "$non_pic_object" = none; then + func_fatal_error "cannot find name of object for \`$arg'" + fi + + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir="$func_dirname_result" + + if test "$pic_object" != none; then + # Prepend the subdirectory the object is found in. + pic_object="$xdir$pic_object" + + if test "$prev" = dlfiles; then + if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then + dlfiles="$dlfiles $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test "$prev" = dlprefiles; then + # Preload the old-style object. + dlprefiles="$dlprefiles $pic_object" + prev= + fi + + # A PIC object. + func_append libobjs " $pic_object" + arg="$pic_object" + fi + + # Non-PIC object. + if test "$non_pic_object" != none; then + # Prepend the subdirectory the object is found in. + non_pic_object="$xdir$non_pic_object" + + # A standard non-PIC object + func_append non_pic_objects " $non_pic_object" + if test -z "$pic_object" || test "$pic_object" = none ; then + arg="$non_pic_object" + fi + else + # If the PIC object exists, use it instead. + # $xdir was prepended to $pic_object above. + non_pic_object="$pic_object" + func_append non_pic_objects " $non_pic_object" + fi + else + # Only an error if not doing a dry-run. + if $opt_dry_run; then + # Extract subdirectory from the argument. + func_dirname "$arg" "/" "" + xdir="$func_dirname_result" + + func_lo2o "$arg" + pic_object=$xdir$objdir/$func_lo2o_result + non_pic_object=$xdir$func_lo2o_result + func_append libobjs " $pic_object" + func_append non_pic_objects " $non_pic_object" + else + func_fatal_error "\`$arg' is not a valid libtool object" + fi + fi + ;; + + *.$libext) + # An archive. + deplibs="$deplibs $arg" + old_deplibs="$old_deplibs $arg" + continue + ;; + + *.la) + # A libtool-controlled library. + + if test "$prev" = dlfiles; then + # This library was specified with -dlopen. + dlfiles="$dlfiles $arg" + prev= + elif test "$prev" = dlprefiles; then + # The library was specified with -dlpreopen. + dlprefiles="$dlprefiles $arg" + prev= + else + deplibs="$deplibs $arg" + fi + continue + ;; + + # Some other compiler argument. + *) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + func_quote_for_eval "$arg" + arg="$func_quote_for_eval_result" + ;; + esac # arg + + # Now actually substitute the argument into the commands. + if test -n "$arg"; then + func_append compile_command " $arg" + func_append finalize_command " $arg" + fi + done # argument parsing loop + + test -n "$prev" && \ + func_fatal_help "the \`$prevarg' option requires an argument" + + if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then + eval arg=\"$export_dynamic_flag_spec\" + func_append compile_command " $arg" + func_append finalize_command " $arg" + fi + + oldlibs= + # calculate the name of the file, without its directory + func_basename "$output" + outputname="$func_basename_result" + libobjs_save="$libobjs" + + if test -n "$shlibpath_var"; then + # get the directories listed in $shlibpath_var + eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` + else + shlib_search_path= + fi + eval sys_lib_search_path=\"$sys_lib_search_path_spec\" + eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" + + func_dirname "$output" "/" "" + output_objdir="$func_dirname_result$objdir" + # Create the object directory. + func_mkdir_p "$output_objdir" + + # Determine the type of output + case $output in + "") + func_fatal_help "you must specify an output file" + ;; + *.$libext) linkmode=oldlib ;; + *.lo | *.$objext) linkmode=obj ;; + *.la) linkmode=lib ;; + *) linkmode=prog ;; # Anything else should be a program. + esac + + specialdeplibs= + + libs= + # Find all interdependent deplibs by searching for libraries + # that are linked more than once (e.g. -la -lb -la) + for deplib in $deplibs; do + if $opt_duplicate_deps ; then + case "$libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + libs="$libs $deplib" + done + + if test "$linkmode" = lib; then + libs="$predeps $libs $compiler_lib_search_path $postdeps" + + # Compute libraries that are listed more than once in $predeps + # $postdeps and mark them as special (i.e., whose duplicates are + # not to be eliminated). + pre_post_deps= + if $opt_duplicate_compiler_generated_deps; then + for pre_post_dep in $predeps $postdeps; do + case "$pre_post_deps " in + *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; + esac + pre_post_deps="$pre_post_deps $pre_post_dep" + done + fi + pre_post_deps= + fi + + deplibs= + newdependency_libs= + newlib_search_path= + need_relink=no # whether we're linking any uninstalled libtool libraries + notinst_deplibs= # not-installed libtool libraries + notinst_path= # paths that contain not-installed libtool libraries + + case $linkmode in + lib) + passes="conv dlpreopen link" + for file in $dlfiles $dlprefiles; do + case $file in + *.la) ;; + *) + func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" + ;; + esac + done + ;; + prog) + compile_deplibs= + finalize_deplibs= + alldeplibs=no + newdlfiles= + newdlprefiles= + passes="conv scan dlopen dlpreopen link" + ;; + *) passes="conv" + ;; + esac + + for pass in $passes; do + # The preopen pass in lib mode reverses $deplibs; put it back here + # so that -L comes before libs that need it for instance... + if test "$linkmode,$pass" = "lib,link"; then + ## FIXME: Find the place where the list is rebuilt in the wrong + ## order, and fix it there properly + tmp_deplibs= + for deplib in $deplibs; do + tmp_deplibs="$deplib $tmp_deplibs" + done + deplibs="$tmp_deplibs" + fi + + if test "$linkmode,$pass" = "lib,link" || + test "$linkmode,$pass" = "prog,scan"; then + libs="$deplibs" + deplibs= + fi + if test "$linkmode" = prog; then + case $pass in + dlopen) libs="$dlfiles" ;; + dlpreopen) libs="$dlprefiles" ;; + link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; + esac + fi + if test "$linkmode,$pass" = "lib,dlpreopen"; then + # Collect and forward deplibs of preopened libtool libs + for lib in $dlprefiles; do + # Ignore non-libtool-libs + dependency_libs= + case $lib in + *.la) func_source "$lib" ;; + esac + + # Collect preopened libtool deplibs, except any this library + # has declared as weak libs + for deplib in $dependency_libs; do + deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"` + case " $weak_libs " in + *" $deplib_base "*) ;; + *) deplibs="$deplibs $deplib" ;; + esac + done + done + libs="$dlprefiles" + fi + if test "$pass" = dlopen; then + # Collect dlpreopened libraries + save_deplibs="$deplibs" + deplibs= + fi + + for deplib in $libs; do + lib= + found=no + case $deplib in + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + compiler_flags="$compiler_flags $deplib" + if test "$linkmode" = lib ; then + case "$new_inherited_linker_flags " in + *" $deplib "*) ;; + * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; + esac + fi + fi + continue + ;; + -l*) + if test "$linkmode" != lib && test "$linkmode" != prog; then + func_warning "\`-l' is ignored for archives/objects" + continue + fi + func_stripname '-l' '' "$deplib" + name=$func_stripname_result + if test "$linkmode" = lib; then + searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" + else + searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" + fi + for searchdir in $searchdirs; do + for search_ext in .la $std_shrext .so .a; do + # Search the libtool library + lib="$searchdir/lib${name}${search_ext}" + if test -f "$lib"; then + if test "$search_ext" = ".la"; then + found=yes + else + found=no + fi + break 2 + fi + done + done + if test "$found" != yes; then + # deplib doesn't seem to be a libtool library + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" + fi + continue + else # deplib is a libtool library + # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, + # We need to do some special things here, and not later. + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $deplib "*) + if func_lalib_p "$lib"; then + library_names= + old_library= + func_source "$lib" + for l in $old_library $library_names; do + ll="$l" + done + if test "X$ll" = "X$old_library" ; then # only static version available + found=no + func_dirname "$lib" "" "." + ladir="$func_dirname_result" + lib=$ladir/$old_library + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" + fi + continue + fi + fi + ;; + *) ;; + esac + fi + fi + ;; # -l + *.ltframework) + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + if test "$linkmode" = lib ; then + case "$new_inherited_linker_flags " in + *" $deplib "*) ;; + * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; + esac + fi + fi + continue + ;; + -L*) + case $linkmode in + lib) + deplibs="$deplib $deplibs" + test "$pass" = conv && continue + newdependency_libs="$deplib $newdependency_libs" + func_stripname '-L' '' "$deplib" + newlib_search_path="$newlib_search_path $func_stripname_result" + ;; + prog) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + continue + fi + if test "$pass" = scan; then + deplibs="$deplib $deplibs" + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + func_stripname '-L' '' "$deplib" + newlib_search_path="$newlib_search_path $func_stripname_result" + ;; + *) + func_warning "\`-L' is ignored for archives/objects" + ;; + esac # linkmode + continue + ;; # -L + -R*) + if test "$pass" = link; then + func_stripname '-R' '' "$deplib" + dir=$func_stripname_result + # Make sure the xrpath contains only unique directories. + case "$xrpath " in + *" $dir "*) ;; + *) xrpath="$xrpath $dir" ;; + esac + fi + deplibs="$deplib $deplibs" + continue + ;; + *.la) lib="$deplib" ;; + *.$libext) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + continue + fi + case $linkmode in + lib) + # Linking convenience modules into shared libraries is allowed, + # but linking other static libraries is non-portable. + case " $dlpreconveniencelibs " in + *" $deplib "*) ;; + *) + valid_a_lib=no + case $deplibs_check_method in + match_pattern*) + set dummy $deplibs_check_method; shift + match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` + if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \ + | $EGREP "$match_pattern_regex" > /dev/null; then + valid_a_lib=yes + fi + ;; + pass_all) + valid_a_lib=yes + ;; + esac + if test "$valid_a_lib" != yes; then + $ECHO + $ECHO "*** Warning: Trying to link with static lib archive $deplib." + $ECHO "*** I have the capability to make that library automatically link in when" + $ECHO "*** you link to this library. But I can only do this if you have a" + $ECHO "*** shared version of the library, which you do not appear to have" + $ECHO "*** because the file extensions .$libext of this argument makes me believe" + $ECHO "*** that it is just a static archive that I should not use here." + else + $ECHO + $ECHO "*** Warning: Linking the shared library $output against the" + $ECHO "*** static library $deplib is not portable!" + deplibs="$deplib $deplibs" + fi + ;; + esac + continue + ;; + prog) + if test "$pass" != link; then + deplibs="$deplib $deplibs" + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + continue + ;; + esac # linkmode + ;; # *.$libext + *.lo | *.$objext) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + elif test "$linkmode" = prog; then + if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then + # If there is no dlopen support or we're linking statically, + # we need to preload. + newdlprefiles="$newdlprefiles $deplib" + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + newdlfiles="$newdlfiles $deplib" + fi + fi + continue + ;; + %DEPLIBS%) + alldeplibs=yes + continue + ;; + esac # case $deplib + + if test "$found" = yes || test -f "$lib"; then : + else + func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" + fi + + # Check to see that this really is a libtool archive. + func_lalib_unsafe_p "$lib" \ + || func_fatal_error "\`$lib' is not a valid libtool archive" + + func_dirname "$lib" "" "." + ladir="$func_dirname_result" + + dlname= + dlopen= + dlpreopen= + libdir= + library_names= + old_library= + inherited_linker_flags= + # If the library was installed with an old release of libtool, + # it will not redefine variables installed, or shouldnotlink + installed=yes + shouldnotlink=no + avoidtemprpath= + + + # Read the .la file + func_source "$lib" + + # Convert "-framework foo" to "foo.ltframework" + if test -n "$inherited_linker_flags"; then + tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'` + for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do + case " $new_inherited_linker_flags " in + *" $tmp_inherited_linker_flag "*) ;; + *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";; + esac + done + fi + dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` + if test "$linkmode,$pass" = "lib,link" || + test "$linkmode,$pass" = "prog,scan" || + { test "$linkmode" != prog && test "$linkmode" != lib; }; then + test -n "$dlopen" && dlfiles="$dlfiles $dlopen" + test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" + fi + + if test "$pass" = conv; then + # Only check for convenience libraries + deplibs="$lib $deplibs" + if test -z "$libdir"; then + if test -z "$old_library"; then + func_fatal_error "cannot find name of link library for \`$lib'" + fi + # It is a libtool convenience library, so add in its objects. + convenience="$convenience $ladir/$objdir/$old_library" + old_convenience="$old_convenience $ladir/$objdir/$old_library" + elif test "$linkmode" != prog && test "$linkmode" != lib; then + func_fatal_error "\`$lib' is not a convenience library" + fi + tmp_libs= + for deplib in $dependency_libs; do + deplibs="$deplib $deplibs" + if $opt_duplicate_deps ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done + continue + fi # $pass = conv + + + # Get the name of the library we link against. + linklib= + for l in $old_library $library_names; do + linklib="$l" + done + if test -z "$linklib"; then + func_fatal_error "cannot find name of link library for \`$lib'" + fi + + # This library was specified with -dlopen. + if test "$pass" = dlopen; then + if test -z "$libdir"; then + func_fatal_error "cannot -dlopen a convenience library: \`$lib'" + fi + if test -z "$dlname" || + test "$dlopen_support" != yes || + test "$build_libtool_libs" = no; then + # If there is no dlname, no dlopen support or we're linking + # statically, we need to preload. We also need to preload any + # dependent libraries so libltdl's deplib preloader doesn't + # bomb out in the load deplibs phase. + dlprefiles="$dlprefiles $lib $dependency_libs" + else + newdlfiles="$newdlfiles $lib" + fi + continue + fi # $pass = dlopen + + # We need an absolute path. + case $ladir in + [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; + *) + abs_ladir=`cd "$ladir" && pwd` + if test -z "$abs_ladir"; then + func_warning "cannot determine absolute directory name of \`$ladir'" + func_warning "passing it literally to the linker, although it might fail" + abs_ladir="$ladir" + fi + ;; + esac + func_basename "$lib" + laname="$func_basename_result" + + # Find the relevant object directory and library name. + if test "X$installed" = Xyes; then + if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then + func_warning "library \`$lib' was moved." + dir="$ladir" + absdir="$abs_ladir" + libdir="$abs_ladir" + else + dir="$libdir" + absdir="$libdir" + fi + test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes + else + if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then + dir="$ladir" + absdir="$abs_ladir" + # Remove this search path later + notinst_path="$notinst_path $abs_ladir" + else + dir="$ladir/$objdir" + absdir="$abs_ladir/$objdir" + # Remove this search path later + notinst_path="$notinst_path $abs_ladir" + fi + fi # $installed = yes + func_stripname 'lib' '.la' "$laname" + name=$func_stripname_result + + # This library was specified with -dlpreopen. + if test "$pass" = dlpreopen; then + if test -z "$libdir" && test "$linkmode" = prog; then + func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" + fi + # Prefer using a static library (so that no silly _DYNAMIC symbols + # are required to link). + if test -n "$old_library"; then + newdlprefiles="$newdlprefiles $dir/$old_library" + # Keep a list of preopened convenience libraries to check + # that they are being used correctly in the link pass. + test -z "$libdir" && \ + dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library" + # Otherwise, use the dlname, so that lt_dlopen finds it. + elif test -n "$dlname"; then + newdlprefiles="$newdlprefiles $dir/$dlname" + else + newdlprefiles="$newdlprefiles $dir/$linklib" + fi + fi # $pass = dlpreopen + + if test -z "$libdir"; then + # Link the convenience library + if test "$linkmode" = lib; then + deplibs="$dir/$old_library $deplibs" + elif test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$dir/$old_library $compile_deplibs" + finalize_deplibs="$dir/$old_library $finalize_deplibs" + else + deplibs="$lib $deplibs" # used for prog,scan pass + fi + continue + fi + + + if test "$linkmode" = prog && test "$pass" != link; then + newlib_search_path="$newlib_search_path $ladir" + deplibs="$lib $deplibs" + + linkalldeplibs=no + if test "$link_all_deplibs" != no || test -z "$library_names" || + test "$build_libtool_libs" = no; then + linkalldeplibs=yes + fi + + tmp_libs= + for deplib in $dependency_libs; do + case $deplib in + -L*) func_stripname '-L' '' "$deplib" + newlib_search_path="$newlib_search_path $func_stripname_result" + ;; + esac + # Need to link against all dependency_libs? + if test "$linkalldeplibs" = yes; then + deplibs="$deplib $deplibs" + else + # Need to hardcode shared library paths + # or/and link against static libraries + newdependency_libs="$deplib $newdependency_libs" + fi + if $opt_duplicate_deps ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done # for deplib + continue + fi # $linkmode = prog... + + if test "$linkmode,$pass" = "prog,link"; then + if test -n "$library_names" && + { { test "$prefer_static_libs" = no || + test "$prefer_static_libs,$installed" = "built,yes"; } || + test -z "$old_library"; }; then + # We need to hardcode the library path + if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then + # Make sure the rpath contains only unique directories. + case "$temp_rpath:" in + *"$absdir:"*) ;; + *) temp_rpath="$temp_rpath$absdir:" ;; + esac + fi + + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) compile_rpath="$compile_rpath $absdir" + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" + esac + ;; + esac + fi # $linkmode,$pass = prog,link... + + if test "$alldeplibs" = yes && + { test "$deplibs_check_method" = pass_all || + { test "$build_libtool_libs" = yes && + test -n "$library_names"; }; }; then + # We only need to search for static libraries + continue + fi + fi + + link_static=no # Whether the deplib will be linked statically + use_static_libs=$prefer_static_libs + if test "$use_static_libs" = built && test "$installed" = yes; then + use_static_libs=no + fi + if test -n "$library_names" && + { test "$use_static_libs" = no || test -z "$old_library"; }; then + case $host in + *cygwin* | *mingw* | *cegcc*) + # No point in relinking DLLs because paths are not encoded + notinst_deplibs="$notinst_deplibs $lib" + need_relink=no + ;; + *) + if test "$installed" = no; then + notinst_deplibs="$notinst_deplibs $lib" + need_relink=yes + fi + ;; + esac + # This is a shared library + + # Warn about portability, can't link against -module's on some + # systems (darwin). Don't bleat about dlopened modules though! + dlopenmodule="" + for dlpremoduletest in $dlprefiles; do + if test "X$dlpremoduletest" = "X$lib"; then + dlopenmodule="$dlpremoduletest" + break + fi + done + if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then + $ECHO + if test "$linkmode" = prog; then + $ECHO "*** Warning: Linking the executable $output against the loadable module" + else + $ECHO "*** Warning: Linking the shared library $output against the loadable module" + fi + $ECHO "*** $linklib is not portable!" + fi + if test "$linkmode" = lib && + test "$hardcode_into_libs" = yes; then + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) compile_rpath="$compile_rpath $absdir" + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" + esac + ;; + esac + fi + + if test -n "$old_archive_from_expsyms_cmds"; then + # figure out the soname + set dummy $library_names + shift + realname="$1" + shift + libname=`eval "\\$ECHO \"$libname_spec\""` + # use dlname if we got it. it's perfectly good, no? + if test -n "$dlname"; then + soname="$dlname" + elif test -n "$soname_spec"; then + # bleh windows + case $host in + *cygwin* | mingw* | *cegcc*) + func_arith $current - $age + major=$func_arith_result + versuffix="-$major" + ;; + esac + eval soname=\"$soname_spec\" + else + soname="$realname" + fi + + # Make a new name for the extract_expsyms_cmds to use + soroot="$soname" + func_basename "$soroot" + soname="$func_basename_result" + func_stripname 'lib' '.dll' "$soname" + newlib=libimp-$func_stripname_result.a + + # If the library has no export list, then create one now + if test -f "$output_objdir/$soname-def"; then : + else + func_verbose "extracting exported symbol list from \`$soname'" + func_execute_cmds "$extract_expsyms_cmds" 'exit $?' + fi + + # Create $newlib + if test -f "$output_objdir/$newlib"; then :; else + func_verbose "generating import library for \`$soname'" + func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' + fi + # make sure the library variables are pointing to the new library + dir=$output_objdir + linklib=$newlib + fi # test -n "$old_archive_from_expsyms_cmds" + + if test "$linkmode" = prog || test "$mode" != relink; then + add_shlibpath= + add_dir= + add= + lib_linked=yes + case $hardcode_action in + immediate | unsupported) + if test "$hardcode_direct" = no; then + add="$dir/$linklib" + case $host in + *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; + *-*-sysv4*uw2*) add_dir="-L$dir" ;; + *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ + *-*-unixware7*) add_dir="-L$dir" ;; + *-*-darwin* ) + # if the lib is a (non-dlopened) module then we can not + # link against it, someone is ignoring the earlier warnings + if /usr/bin/file -L $add 2> /dev/null | + $GREP ": [^:]* bundle" >/dev/null ; then + if test "X$dlopenmodule" != "X$lib"; then + $ECHO "*** Warning: lib $linklib is a module, not a shared library" + if test -z "$old_library" ; then + $ECHO + $ECHO "*** And there doesn't seem to be a static archive available" + $ECHO "*** The link will probably fail, sorry" + else + add="$dir/$old_library" + fi + elif test -n "$old_library"; then + add="$dir/$old_library" + fi + fi + esac + elif test "$hardcode_minus_L" = no; then + case $host in + *-*-sunos*) add_shlibpath="$dir" ;; + esac + add_dir="-L$dir" + add="-l$name" + elif test "$hardcode_shlibpath_var" = no; then + add_shlibpath="$dir" + add="-l$name" + else + lib_linked=no + fi + ;; + relink) + if test "$hardcode_direct" = yes && + test "$hardcode_direct_absolute" = no; then + add="$dir/$linklib" + elif test "$hardcode_minus_L" = yes; then + add_dir="-L$dir" + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case $libdir in + [\\/]*) + add_dir="$add_dir -L$inst_prefix_dir$libdir" + ;; + esac + fi + add="-l$name" + elif test "$hardcode_shlibpath_var" = yes; then + add_shlibpath="$dir" + add="-l$name" + else + lib_linked=no + fi + ;; + *) lib_linked=no ;; + esac + + if test "$lib_linked" != yes; then + func_fatal_configuration "unsupported hardcode properties" + fi + + if test -n "$add_shlibpath"; then + case :$compile_shlibpath: in + *":$add_shlibpath:"*) ;; + *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; + esac + fi + if test "$linkmode" = prog; then + test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" + test -n "$add" && compile_deplibs="$add $compile_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + if test "$hardcode_direct" != yes && + test "$hardcode_minus_L" != yes && + test "$hardcode_shlibpath_var" = yes; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; + esac + fi + fi + fi + + if test "$linkmode" = prog || test "$mode" = relink; then + add_shlibpath= + add_dir= + add= + # Finalize command for both is simple: just hardcode it. + if test "$hardcode_direct" = yes && + test "$hardcode_direct_absolute" = no; then + add="$libdir/$linklib" + elif test "$hardcode_minus_L" = yes; then + add_dir="-L$libdir" + add="-l$name" + elif test "$hardcode_shlibpath_var" = yes; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; + esac + add="-l$name" + elif test "$hardcode_automatic" = yes; then + if test -n "$inst_prefix_dir" && + test -f "$inst_prefix_dir$libdir/$linklib" ; then + add="$inst_prefix_dir$libdir/$linklib" + else + add="$libdir/$linklib" + fi + else + # We cannot seem to hardcode it, guess we'll fake it. + add_dir="-L$libdir" + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case $libdir in + [\\/]*) + add_dir="$add_dir -L$inst_prefix_dir$libdir" + ;; + esac + fi + add="-l$name" + fi + + if test "$linkmode" = prog; then + test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" + test -n "$add" && finalize_deplibs="$add $finalize_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + fi + fi + elif test "$linkmode" = prog; then + # Here we assume that one of hardcode_direct or hardcode_minus_L + # is not unsupported. This is valid on all known static and + # shared platforms. + if test "$hardcode_direct" != unsupported; then + test -n "$old_library" && linklib="$old_library" + compile_deplibs="$dir/$linklib $compile_deplibs" + finalize_deplibs="$dir/$linklib $finalize_deplibs" + else + compile_deplibs="-l$name -L$dir $compile_deplibs" + finalize_deplibs="-l$name -L$dir $finalize_deplibs" + fi + elif test "$build_libtool_libs" = yes; then + # Not a shared library + if test "$deplibs_check_method" != pass_all; then + # We're trying link a shared library against a static one + # but the system doesn't support it. + + # Just print a warning and add the library to dependency_libs so + # that the program can be linked against the static library. + $ECHO + $ECHO "*** Warning: This system can not link to static lib archive $lib." + $ECHO "*** I have the capability to make that library automatically link in when" + $ECHO "*** you link to this library. But I can only do this if you have a" + $ECHO "*** shared version of the library, which you do not appear to have." + if test "$module" = yes; then + $ECHO "*** But as you try to build a module library, libtool will still create " + $ECHO "*** a static module, that should work as long as the dlopening application" + $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime." + if test -z "$global_symbol_pipe"; then + $ECHO + $ECHO "*** However, this would only work if libtool was able to extract symbol" + $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could" + $ECHO "*** not find such a program. So, this module is probably useless." + $ECHO "*** \`nm' from GNU binutils and a full rebuild may help." + fi + if test "$build_old_libs" = no; then + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + else + deplibs="$dir/$old_library $deplibs" + link_static=yes + fi + fi # link shared/static library? + + if test "$linkmode" = lib; then + if test -n "$dependency_libs" && + { test "$hardcode_into_libs" != yes || + test "$build_old_libs" = yes || + test "$link_static" = yes; }; then + # Extract -R from dependency_libs + temp_deplibs= + for libdir in $dependency_libs; do + case $libdir in + -R*) func_stripname '-R' '' "$libdir" + temp_xrpath=$func_stripname_result + case " $xrpath " in + *" $temp_xrpath "*) ;; + *) xrpath="$xrpath $temp_xrpath";; + esac;; + *) temp_deplibs="$temp_deplibs $libdir";; + esac + done + dependency_libs="$temp_deplibs" + fi + + newlib_search_path="$newlib_search_path $absdir" + # Link against this library + test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" + # ... and its dependency_libs + tmp_libs= + for deplib in $dependency_libs; do + newdependency_libs="$deplib $newdependency_libs" + if $opt_duplicate_deps ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done + + if test "$link_all_deplibs" != no; then + # Add the search paths of all dependency libraries + for deplib in $dependency_libs; do + case $deplib in + -L*) path="$deplib" ;; + *.la) + func_dirname "$deplib" "" "." + dir="$func_dirname_result" + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + func_warning "cannot determine absolute directory name of \`$dir'" + absdir="$dir" + fi + ;; + esac + if $GREP "^installed=no" $deplib > /dev/null; then + case $host in + *-*-darwin*) + depdepl= + eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` + if test -n "$deplibrary_names" ; then + for tmp in $deplibrary_names ; do + depdepl=$tmp + done + if test -f "$absdir/$objdir/$depdepl" ; then + depdepl="$absdir/$objdir/$depdepl" + darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` + if test -z "$darwin_install_name"; then + darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` + fi + compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" + linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}" + path= + fi + fi + ;; + *) + path="-L$absdir/$objdir" + ;; + esac + else + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + test -z "$libdir" && \ + func_fatal_error "\`$deplib' is not a valid libtool archive" + test "$absdir" != "$libdir" && \ + func_warning "\`$deplib' seems to be moved" + + path="-L$absdir" + fi + ;; + esac + case " $deplibs " in + *" $path "*) ;; + *) deplibs="$path $deplibs" ;; + esac + done + fi # link_all_deplibs != no + fi # linkmode = lib + done # for deplib in $libs + if test "$pass" = link; then + if test "$linkmode" = "prog"; then + compile_deplibs="$new_inherited_linker_flags $compile_deplibs" + finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" + else + compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` + fi + fi + dependency_libs="$newdependency_libs" + if test "$pass" = dlpreopen; then + # Link the dlpreopened libraries before other libraries + for deplib in $save_deplibs; do + deplibs="$deplib $deplibs" + done + fi + if test "$pass" != dlopen; then + if test "$pass" != conv; then + # Make sure lib_search_path contains only unique directories. + lib_search_path= + for dir in $newlib_search_path; do + case "$lib_search_path " in + *" $dir "*) ;; + *) lib_search_path="$lib_search_path $dir" ;; + esac + done + newlib_search_path= + fi + + if test "$linkmode,$pass" != "prog,link"; then + vars="deplibs" + else + vars="compile_deplibs finalize_deplibs" + fi + for var in $vars dependency_libs; do + # Add libraries to $var in reverse order + eval tmp_libs=\"\$$var\" + new_libs= + for deplib in $tmp_libs; do + # FIXME: Pedantically, this is the right thing to do, so + # that some nasty dependency loop isn't accidentally + # broken: + #new_libs="$deplib $new_libs" + # Pragmatically, this seems to cause very few problems in + # practice: + case $deplib in + -L*) new_libs="$deplib $new_libs" ;; + -R*) ;; + *) + # And here is the reason: when a library appears more + # than once as an explicit dependence of a library, or + # is implicitly linked in more than once by the + # compiler, it is considered special, and multiple + # occurrences thereof are not removed. Compare this + # with having the same library being listed as a + # dependency of multiple other libraries: in this case, + # we know (pedantically, we assume) the library does not + # need to be listed more than once, so we keep only the + # last copy. This is not always right, but it is rare + # enough that we require users that really mean to play + # such unportable linking tricks to link the library + # using -Wl,-lname, so that libtool does not consider it + # for duplicate removal. + case " $specialdeplibs " in + *" $deplib "*) new_libs="$deplib $new_libs" ;; + *) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$deplib $new_libs" ;; + esac + ;; + esac + ;; + esac + done + tmp_libs= + for deplib in $new_libs; do + case $deplib in + -L*) + case " $tmp_libs " in + *" $deplib "*) ;; + *) tmp_libs="$tmp_libs $deplib" ;; + esac + ;; + *) tmp_libs="$tmp_libs $deplib" ;; + esac + done + eval $var=\"$tmp_libs\" + done # for var + fi + # Last step: remove runtime libs from dependency_libs + # (they stay in deplibs) + tmp_libs= + for i in $dependency_libs ; do + case " $predeps $postdeps $compiler_lib_search_path " in + *" $i "*) + i="" + ;; + esac + if test -n "$i" ; then + tmp_libs="$tmp_libs $i" + fi + done + dependency_libs=$tmp_libs + done # for pass + if test "$linkmode" = prog; then + dlfiles="$newdlfiles" + fi + if test "$linkmode" = prog || test "$linkmode" = lib; then + dlprefiles="$newdlprefiles" + fi + + case $linkmode in + oldlib) + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + func_warning "\`-dlopen' is ignored for archives" + fi + + case " $deplibs" in + *\ -l* | *\ -L*) + func_warning "\`-l' and \`-L' are ignored for archives" ;; + esac + + test -n "$rpath" && \ + func_warning "\`-rpath' is ignored for archives" + + test -n "$xrpath" && \ + func_warning "\`-R' is ignored for archives" + + test -n "$vinfo" && \ + func_warning "\`-version-info/-version-number' is ignored for archives" + + test -n "$release" && \ + func_warning "\`-release' is ignored for archives" + + test -n "$export_symbols$export_symbols_regex" && \ + func_warning "\`-export-symbols' is ignored for archives" + + # Now set the variables for building old libraries. + build_libtool_libs=no + oldlibs="$output" + objs="$objs$old_deplibs" + ;; + + lib) + # Make sure we only generate libraries of the form `libNAME.la'. + case $outputname in + lib*) + func_stripname 'lib' '.la' "$outputname" + name=$func_stripname_result + eval shared_ext=\"$shrext_cmds\" + eval libname=\"$libname_spec\" + ;; + *) + test "$module" = no && \ + func_fatal_help "libtool library \`$output' must begin with \`lib'" + + if test "$need_lib_prefix" != no; then + # Add the "lib" prefix for modules if required + func_stripname '' '.la' "$outputname" + name=$func_stripname_result + eval shared_ext=\"$shrext_cmds\" + eval libname=\"$libname_spec\" + else + func_stripname '' '.la' "$outputname" + libname=$func_stripname_result + fi + ;; + esac + + if test -n "$objs"; then + if test "$deplibs_check_method" != pass_all; then + func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" + else + $ECHO + $ECHO "*** Warning: Linking the shared library $output against the non-libtool" + $ECHO "*** objects $objs is not portable!" + libobjs="$libobjs $objs" + fi + fi + + test "$dlself" != no && \ + func_warning "\`-dlopen self' is ignored for libtool libraries" + + set dummy $rpath + shift + test "$#" -gt 1 && \ + func_warning "ignoring multiple \`-rpath's for a libtool library" + + install_libdir="$1" + + oldlibs= + if test -z "$rpath"; then + if test "$build_libtool_libs" = yes; then + # Building a libtool convenience library. + # Some compilers have problems with a `.al' extension so + # convenience libraries should have the same extension an + # archive normally would. + oldlibs="$output_objdir/$libname.$libext $oldlibs" + build_libtool_libs=convenience + build_old_libs=yes + fi + + test -n "$vinfo" && \ + func_warning "\`-version-info/-version-number' is ignored for convenience libraries" + + test -n "$release" && \ + func_warning "\`-release' is ignored for convenience libraries" + else + + # Parse the version information argument. + save_ifs="$IFS"; IFS=':' + set dummy $vinfo 0 0 0 + shift + IFS="$save_ifs" + + test -n "$7" && \ + func_fatal_help "too many parameters to \`-version-info'" + + # convert absolute version numbers to libtool ages + # this retains compatibility with .la files and attempts + # to make the code below a bit more comprehensible + + case $vinfo_number in + yes) + number_major="$1" + number_minor="$2" + number_revision="$3" + # + # There are really only two kinds -- those that + # use the current revision as the major version + # and those that subtract age and use age as + # a minor version. But, then there is irix + # which has an extra 1 added just for fun + # + case $version_type in + darwin|linux|osf|windows|none) + func_arith $number_major + $number_minor + current=$func_arith_result + age="$number_minor" + revision="$number_revision" + ;; + freebsd-aout|freebsd-elf|sunos) + current="$number_major" + revision="$number_minor" + age="0" + ;; + irix|nonstopux) + func_arith $number_major + $number_minor + current=$func_arith_result + age="$number_minor" + revision="$number_minor" + lt_irix_increment=no + ;; + esac + ;; + no) + current="$1" + revision="$2" + age="$3" + ;; + esac + + # Check that each of the things are valid numbers. + case $current in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + func_error "CURRENT \`$current' must be a nonnegative integer" + func_fatal_error "\`$vinfo' is not valid version information" + ;; + esac + + case $revision in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + func_error "REVISION \`$revision' must be a nonnegative integer" + func_fatal_error "\`$vinfo' is not valid version information" + ;; + esac + + case $age in + 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; + *) + func_error "AGE \`$age' must be a nonnegative integer" + func_fatal_error "\`$vinfo' is not valid version information" + ;; + esac + + if test "$age" -gt "$current"; then + func_error "AGE \`$age' is greater than the current interface number \`$current'" + func_fatal_error "\`$vinfo' is not valid version information" + fi + + # Calculate the version variables. + major= + versuffix= + verstring= + case $version_type in + none) ;; + + darwin) + # Like Linux, but with the current version available in + # verstring for coding it into the library header + func_arith $current - $age + major=.$func_arith_result + versuffix="$major.$age.$revision" + # Darwin ld doesn't like 0 for these options... + func_arith $current + 1 + minor_current=$func_arith_result + xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" + verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" + ;; + + freebsd-aout) + major=".$current" + versuffix=".$current.$revision"; + ;; + + freebsd-elf) + major=".$current" + versuffix=".$current" + ;; + + irix | nonstopux) + if test "X$lt_irix_increment" = "Xno"; then + func_arith $current - $age + else + func_arith $current - $age + 1 + fi + major=$func_arith_result + + case $version_type in + nonstopux) verstring_prefix=nonstopux ;; + *) verstring_prefix=sgi ;; + esac + verstring="$verstring_prefix$major.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$revision + while test "$loop" -ne 0; do + func_arith $revision - $loop + iface=$func_arith_result + func_arith $loop - 1 + loop=$func_arith_result + verstring="$verstring_prefix$major.$iface:$verstring" + done + + # Before this point, $major must not contain `.'. + major=.$major + versuffix="$major.$revision" + ;; + + linux) + func_arith $current - $age + major=.$func_arith_result + versuffix="$major.$age.$revision" + ;; + + osf) + func_arith $current - $age + major=.$func_arith_result + versuffix=".$current.$age.$revision" + verstring="$current.$age.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$age + while test "$loop" -ne 0; do + func_arith $current - $loop + iface=$func_arith_result + func_arith $loop - 1 + loop=$func_arith_result + verstring="$verstring:${iface}.0" + done + + # Make executables depend on our current version. + verstring="$verstring:${current}.0" + ;; + + qnx) + major=".$current" + versuffix=".$current" + ;; + + sunos) + major=".$current" + versuffix=".$current.$revision" + ;; + + windows) + # Use '-' rather than '.', since we only want one + # extension on DOS 8.3 filesystems. + func_arith $current - $age + major=$func_arith_result + versuffix="-$major" + ;; + + *) + func_fatal_configuration "unknown library version type \`$version_type'" + ;; + esac + + # Clear the version info if we defaulted, and they specified a release. + if test -z "$vinfo" && test -n "$release"; then + major= + case $version_type in + darwin) + # we can't check for "0.0" in archive_cmds due to quoting + # problems, so we reset it completely + verstring= + ;; + *) + verstring="0.0" + ;; + esac + if test "$need_version" = no; then + versuffix= + else + versuffix=".0.0" + fi + fi + + # Remove version info from name if versioning should be avoided + if test "$avoid_version" = yes && test "$need_version" = no; then + major= + versuffix= + verstring="" + fi + + # Check to see if the archive will have undefined symbols. + if test "$allow_undefined" = yes; then + if test "$allow_undefined_flag" = unsupported; then + func_warning "undefined symbols not allowed in $host shared libraries" + build_libtool_libs=no + build_old_libs=yes + fi + else + # Don't allow undefined symbols. + allow_undefined_flag="$no_undefined_flag" + fi + + fi + + func_generate_dlsyms "$libname" "$libname" "yes" + libobjs="$libobjs $symfileobj" + test "X$libobjs" = "X " && libobjs= + + if test "$mode" != relink; then + # Remove our outputs, but don't remove object files since they + # may have been created when compiling PIC objects. + removelist= + tempremovelist=`$ECHO "$output_objdir/*"` + for p in $tempremovelist; do + case $p in + *.$objext | *.gcno) + ;; + $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) + if test "X$precious_files_regex" != "X"; then + if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 + then + continue + fi + fi + removelist="$removelist $p" + ;; + *) ;; + esac + done + test -n "$removelist" && \ + func_show_eval "${RM}r \$removelist" + fi + + # Now set the variables for building old libraries. + if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then + oldlibs="$oldlibs $output_objdir/$libname.$libext" + + # Transform .lo files to .o files. + oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` + fi + + # Eliminate all temporary directories. + #for path in $notinst_path; do + # lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"` + # deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"` + # dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"` + #done + + if test -n "$xrpath"; then + # If the user specified any rpath flags, then add them. + temp_xrpath= + for libdir in $xrpath; do + temp_xrpath="$temp_xrpath -R$libdir" + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; + esac + done + if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then + dependency_libs="$temp_xrpath $dependency_libs" + fi + fi + + # Make sure dlfiles contains only unique files that won't be dlpreopened + old_dlfiles="$dlfiles" + dlfiles= + for lib in $old_dlfiles; do + case " $dlprefiles $dlfiles " in + *" $lib "*) ;; + *) dlfiles="$dlfiles $lib" ;; + esac + done + + # Make sure dlprefiles contains only unique files + old_dlprefiles="$dlprefiles" + dlprefiles= + for lib in $old_dlprefiles; do + case "$dlprefiles " in + *" $lib "*) ;; + *) dlprefiles="$dlprefiles $lib" ;; + esac + done + + if test "$build_libtool_libs" = yes; then + if test -n "$rpath"; then + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc*) + # these systems don't actually have a c library (as such)! + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C library is in the System framework + deplibs="$deplibs System.ltframework" + ;; + *-*-netbsd*) + # Don't link with libc until the a.out ld.so is fixed. + ;; + *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) + # Do not include libc due to us having libc/libc_r. + ;; + *-*-sco3.2v5* | *-*-sco5v6*) + # Causes problems with __ctype + ;; + *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) + # Compiler inserts libc in the correct place for threads to work + ;; + *) + # Add libc to deplibs on all other systems if necessary. + if test "$build_libtool_need_lc" = "yes"; then + deplibs="$deplibs -lc" + fi + ;; + esac + fi + + # Transform deplibs into only deplibs that can be linked in shared. + name_save=$name + libname_save=$libname + release_save=$release + versuffix_save=$versuffix + major_save=$major + # I'm not sure if I'm treating the release correctly. I think + # release should show up in the -l (ie -lgmp5) so we don't want to + # add it in twice. Is that correct? + release="" + versuffix="" + major="" + newdeplibs= + droppeddeps=no + case $deplibs_check_method in + pass_all) + # Don't check for shared/static. Everything works. + # This might be a little naive. We might want to check + # whether the library exists or not. But this is on + # osf3 & osf4 and I'm not really sure... Just + # implementing what was already the behavior. + newdeplibs=$deplibs + ;; + test_compile) + # This code stresses the "libraries are programs" paradigm to its + # limits. Maybe even breaks it. We compile a program, linking it + # against the deplibs as a proxy for the library. Then we can check + # whether they linked in statically or dynamically with ldd. + $opt_dry_run || $RM conftest.c + cat > conftest.c </dev/null` + for potent_lib in $potential_libs; do + # Follow soft links. + if ls -lLd "$potent_lib" 2>/dev/null | + $GREP " -> " >/dev/null; then + continue + fi + # The statement above tries to avoid entering an + # endless loop below, in case of cyclic links. + # We might still enter an endless loop, since a link + # loop can be closed while we follow links, + # but so what? + potlib="$potent_lib" + while test -h "$potlib" 2>/dev/null; do + potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` + case $potliblink in + [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; + *) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; + esac + done + if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | + $SED -e 10q | + $EGREP "$file_magic_regex" > /dev/null; then + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + break 2 + fi + done + done + fi + if test -n "$a_deplib" ; then + droppeddeps=yes + $ECHO + $ECHO "*** Warning: linker path does not have real file for library $a_deplib." + $ECHO "*** I have the capability to make that library automatically link in when" + $ECHO "*** you link to this library. But I can only do this if you have a" + $ECHO "*** shared version of the library, which you do not appear to have" + $ECHO "*** because I did check the linker path looking for a file starting" + if test -z "$potlib" ; then + $ECHO "*** with $libname but no candidates were found. (...for file magic test)" + else + $ECHO "*** with $libname and none of the candidates passed a file format test" + $ECHO "*** using a file magic. Last file checked: $potlib" + fi + fi + ;; + *) + # Add a -L argument. + newdeplibs="$newdeplibs $a_deplib" + ;; + esac + done # Gone through all deplibs. + ;; + match_pattern*) + set dummy $deplibs_check_method; shift + match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` + for a_deplib in $deplibs; do + case $a_deplib in + -l*) + func_stripname -l '' "$a_deplib" + name=$func_stripname_result + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $a_deplib "*) + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + ;; + esac + fi + if test -n "$a_deplib" ; then + libname=`eval "\\$ECHO \"$libname_spec\""` + for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do + potential_libs=`ls $i/$libname[.-]* 2>/dev/null` + for potent_lib in $potential_libs; do + potlib="$potent_lib" # see symlink-check above in file_magic test + if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \ + $EGREP "$match_pattern_regex" > /dev/null; then + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + break 2 + fi + done + done + fi + if test -n "$a_deplib" ; then + droppeddeps=yes + $ECHO + $ECHO "*** Warning: linker path does not have real file for library $a_deplib." + $ECHO "*** I have the capability to make that library automatically link in when" + $ECHO "*** you link to this library. But I can only do this if you have a" + $ECHO "*** shared version of the library, which you do not appear to have" + $ECHO "*** because I did check the linker path looking for a file starting" + if test -z "$potlib" ; then + $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" + else + $ECHO "*** with $libname and none of the candidates passed a file format test" + $ECHO "*** using a regex pattern. Last file checked: $potlib" + fi + fi + ;; + *) + # Add a -L argument. + newdeplibs="$newdeplibs $a_deplib" + ;; + esac + done # Gone through all deplibs. + ;; + none | unknown | *) + newdeplibs="" + tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \ + -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'` + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + for i in $predeps $postdeps ; do + # can't use Xsed below, because $i might contain '/' + tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"` + done + fi + if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' | + $GREP . >/dev/null; then + $ECHO + if test "X$deplibs_check_method" = "Xnone"; then + $ECHO "*** Warning: inter-library dependencies are not supported in this platform." + else + $ECHO "*** Warning: inter-library dependencies are not known to be supported." + fi + $ECHO "*** All declared inter-library dependencies are being dropped." + droppeddeps=yes + fi + ;; + esac + versuffix=$versuffix_save + major=$major_save + release=$release_save + libname=$libname_save + name=$name_save + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library with the System framework + newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'` + ;; + esac + + if test "$droppeddeps" = yes; then + if test "$module" = yes; then + $ECHO + $ECHO "*** Warning: libtool could not satisfy all declared inter-library" + $ECHO "*** dependencies of module $libname. Therefore, libtool will create" + $ECHO "*** a static module, that should work as long as the dlopening" + $ECHO "*** application is linked with the -dlopen flag." + if test -z "$global_symbol_pipe"; then + $ECHO + $ECHO "*** However, this would only work if libtool was able to extract symbol" + $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could" + $ECHO "*** not find such a program. So, this module is probably useless." + $ECHO "*** \`nm' from GNU binutils and a full rebuild may help." + fi + if test "$build_old_libs" = no; then + oldlibs="$output_objdir/$libname.$libext" + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + else + $ECHO "*** The inter-library dependencies that have been dropped here will be" + $ECHO "*** automatically added whenever a program is linked with this library" + $ECHO "*** or is declared to -dlopen it." + + if test "$allow_undefined" = no; then + $ECHO + $ECHO "*** Since this library must not contain undefined symbols," + $ECHO "*** because either the platform does not support them or" + $ECHO "*** it was explicitly requested with -no-undefined," + $ECHO "*** libtool will only create a static version of it." + if test "$build_old_libs" = no; then + oldlibs="$output_objdir/$libname.$libext" + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + fi + fi + # Done checking deplibs! + deplibs=$newdeplibs + fi + # Time to change all our "foo.ltframework" stuff back to "-framework foo" + case $host in + *-*-darwin*) + newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` + new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` + deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` + ;; + esac + + # move library search paths that coincide with paths to not yet + # installed libraries to the beginning of the library search list + new_libs= + for path in $notinst_path; do + case " $new_libs " in + *" -L$path/$objdir "*) ;; + *) + case " $deplibs " in + *" -L$path/$objdir "*) + new_libs="$new_libs -L$path/$objdir" ;; + esac + ;; + esac + done + for deplib in $deplibs; do + case $deplib in + -L*) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$new_libs $deplib" ;; + esac + ;; + *) new_libs="$new_libs $deplib" ;; + esac + done + deplibs="$new_libs" + + # All the library-specific variables (install_libdir is set above). + library_names= + old_library= + dlname= + + # Test again, we may have decided not to build it any more + if test "$build_libtool_libs" = yes; then + if test "$hardcode_into_libs" = yes; then + # Hardcode the library paths + hardcode_libdirs= + dep_rpath= + rpath="$finalize_rpath" + test "$mode" != relink && rpath="$compile_rpath$rpath" + for libdir in $rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + dep_rpath="$dep_rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + if test -n "$hardcode_libdir_flag_spec_ld"; then + eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" + else + eval dep_rpath=\"$hardcode_libdir_flag_spec\" + fi + fi + if test -n "$runpath_var" && test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" + fi + test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" + fi + + shlibpath="$finalize_shlibpath" + test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" + if test -n "$shlibpath"; then + eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" + fi + + # Get the real and link names of the library. + eval shared_ext=\"$shrext_cmds\" + eval library_names=\"$library_names_spec\" + set dummy $library_names + shift + realname="$1" + shift + + if test -n "$soname_spec"; then + eval soname=\"$soname_spec\" + else + soname="$realname" + fi + if test -z "$dlname"; then + dlname=$soname + fi + + lib="$output_objdir/$realname" + linknames= + for link + do + linknames="$linknames $link" + done + + # Use standard objects if they are pic + test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + test "X$libobjs" = "X " && libobjs= + + delfiles= + if test -n "$export_symbols" && test -n "$include_expsyms"; then + $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" + export_symbols="$output_objdir/$libname.uexp" + delfiles="$delfiles $export_symbols" + fi + + orig_export_symbols= + case $host_os in + cygwin* | mingw* | cegcc*) + if test -n "$export_symbols" && test -z "$export_symbols_regex"; then + # exporting using user supplied symfile + if test "x`$SED 1q $export_symbols`" != xEXPORTS; then + # and it's NOT already a .def file. Must figure out + # which of the given symbols are data symbols and tag + # them as such. So, trigger use of export_symbols_cmds. + # export_symbols gets reassigned inside the "prepare + # the list of exported symbols" if statement, so the + # include_expsyms logic still works. + orig_export_symbols="$export_symbols" + export_symbols= + always_export_symbols=yes + fi + fi + ;; + esac + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then + func_verbose "generating symbol list for \`$libname.la'" + export_symbols="$output_objdir/$libname.exp" + $opt_dry_run || $RM $export_symbols + cmds=$export_symbols_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + func_len " $cmd" + len=$func_len_result + if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then + func_show_eval "$cmd" 'exit $?' + skipped_export=false + else + # The command line is too long to execute in one step. + func_verbose "using reloadable object file for export list..." + skipped_export=: + # Break out early, otherwise skipped_export may be + # set to false by a later but shorter cmd. + break + fi + done + IFS="$save_ifs" + if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then + func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + func_show_eval '$MV "${export_symbols}T" "$export_symbols"' + fi + fi + fi + + if test -n "$export_symbols" && test -n "$include_expsyms"; then + tmp_export_symbols="$export_symbols" + test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" + $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"' + fi + + if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then + # The given exports_symbols file has to be filtered, so filter it. + func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" + # FIXME: $output_objdir/$libname.filter potentially contains lots of + # 's' commands which not all seds can handle. GNU sed should be fine + # though. Also, the filter scales superlinearly with the number of + # global variables. join(1) would be nice here, but unfortunately + # isn't a blessed tool. + $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter + delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" + export_symbols=$output_objdir/$libname.def + $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols + fi + + tmp_deplibs= + for test_deplib in $deplibs; do + case " $convenience " in + *" $test_deplib "*) ;; + *) + tmp_deplibs="$tmp_deplibs $test_deplib" + ;; + esac + done + deplibs="$tmp_deplibs" + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec" && + test "$compiler_needs_object" = yes && + test -z "$libobjs"; then + # extract the archives, so we have objects to list. + # TODO: could optimize this to just extract one archive. + whole_archive_flag_spec= + fi + if test -n "$whole_archive_flag_spec"; then + save_libobjs=$libobjs + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + test "X$libobjs" = "X " && libobjs= + else + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + + func_extract_archives $gentop $convenience + libobjs="$libobjs $func_extract_archives_result" + test "X$libobjs" = "X " && libobjs= + fi + fi + + if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then + eval flag=\"$thread_safe_flag_spec\" + linker_flags="$linker_flags $flag" + fi + + # Make a backup of the uninstalled library when relinking + if test "$mode" = relink; then + $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? + fi + + # Do each of the archive commands. + if test "$module" = yes && test -n "$module_cmds" ; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + eval test_cmds=\"$module_expsym_cmds\" + cmds=$module_expsym_cmds + else + eval test_cmds=\"$module_cmds\" + cmds=$module_cmds + fi + else + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + eval test_cmds=\"$archive_expsym_cmds\" + cmds=$archive_expsym_cmds + else + eval test_cmds=\"$archive_cmds\" + cmds=$archive_cmds + fi + fi + + if test "X$skipped_export" != "X:" && + func_len " $test_cmds" && + len=$func_len_result && + test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then + : + else + # The command line is too long to link in one step, link piecewise + # or, if using GNU ld and skipped_export is not :, use a linker + # script. + + # Save the value of $output and $libobjs because we want to + # use them later. If we have whole_archive_flag_spec, we + # want to use save_libobjs as it was before + # whole_archive_flag_spec was expanded, because we can't + # assume the linker understands whole_archive_flag_spec. + # This may have to be revisited, in case too many + # convenience libraries get linked in and end up exceeding + # the spec. + if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then + save_libobjs=$libobjs + fi + save_output=$output + output_la=`$ECHO "X$output" | $Xsed -e "$basename"` + + # Clear the reloadable object creation command queue and + # initialize k to one. + test_cmds= + concat_cmds= + objlist= + last_robj= + k=1 + + if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then + output=${output_objdir}/${output_la}.lnkscript + func_verbose "creating GNU ld script: $output" + $ECHO 'INPUT (' > $output + for obj in $save_libobjs + do + $ECHO "$obj" >> $output + done + $ECHO ')' >> $output + delfiles="$delfiles $output" + elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then + output=${output_objdir}/${output_la}.lnk + func_verbose "creating linker input file list: $output" + : > $output + set x $save_libobjs + shift + firstobj= + if test "$compiler_needs_object" = yes; then + firstobj="$1 " + shift + fi + for obj + do + $ECHO "$obj" >> $output + done + delfiles="$delfiles $output" + output=$firstobj\"$file_list_spec$output\" + else + if test -n "$save_libobjs"; then + func_verbose "creating reloadable object files..." + output=$output_objdir/$output_la-${k}.$objext + eval test_cmds=\"$reload_cmds\" + func_len " $test_cmds" + len0=$func_len_result + len=$len0 + + # Loop over the list of objects to be linked. + for obj in $save_libobjs + do + func_len " $obj" + func_arith $len + $func_len_result + len=$func_arith_result + if test "X$objlist" = X || + test "$len" -lt "$max_cmd_len"; then + func_append objlist " $obj" + else + # The command $test_cmds is almost too long, add a + # command to the queue. + if test "$k" -eq 1 ; then + # The first file doesn't have a previous command to add. + eval concat_cmds=\"$reload_cmds $objlist $last_robj\" + else + # All subsequent reloadable object files will link in + # the last one created. + eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\" + fi + last_robj=$output_objdir/$output_la-${k}.$objext + func_arith $k + 1 + k=$func_arith_result + output=$output_objdir/$output_la-${k}.$objext + objlist=$obj + func_len " $last_robj" + func_arith $len0 + $func_len_result + len=$func_arith_result + fi + done + # Handle the remaining objects by creating one last + # reloadable object file. All subsequent reloadable object + # files will link in the last one created. + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\" + if test -n "$last_robj"; then + eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" + fi + delfiles="$delfiles $output" + + else + output= + fi + + if ${skipped_export-false}; then + func_verbose "generating symbol list for \`$libname.la'" + export_symbols="$output_objdir/$libname.exp" + $opt_dry_run || $RM $export_symbols + libobjs=$output + # Append the command to create the export file. + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" + if test -n "$last_robj"; then + eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" + fi + fi + + test -n "$save_libobjs" && + func_verbose "creating a temporary reloadable object file: $output" + + # Loop through the commands generated above and execute them. + save_ifs="$IFS"; IFS='~' + for cmd in $concat_cmds; do + IFS="$save_ifs" + $opt_silent || { + func_quote_for_expand "$cmd" + eval "func_echo $func_quote_for_expand_result" + } + $opt_dry_run || eval "$cmd" || { + lt_exit=$? + + # Restore the uninstalled library and exit + if test "$mode" = relink; then + ( cd "$output_objdir" && \ + $RM "${realname}T" && \ + $MV "${realname}U" "$realname" ) + fi + + exit $lt_exit + } + done + IFS="$save_ifs" + + if test -n "$export_symbols_regex" && ${skipped_export-false}; then + func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + func_show_eval '$MV "${export_symbols}T" "$export_symbols"' + fi + fi + + if ${skipped_export-false}; then + if test -n "$export_symbols" && test -n "$include_expsyms"; then + tmp_export_symbols="$export_symbols" + test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" + $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"' + fi + + if test -n "$orig_export_symbols"; then + # The given exports_symbols file has to be filtered, so filter it. + func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" + # FIXME: $output_objdir/$libname.filter potentially contains lots of + # 's' commands which not all seds can handle. GNU sed should be fine + # though. Also, the filter scales superlinearly with the number of + # global variables. join(1) would be nice here, but unfortunately + # isn't a blessed tool. + $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter + delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" + export_symbols=$output_objdir/$libname.def + $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols + fi + fi + + libobjs=$output + # Restore the value of output. + output=$save_output + + if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + test "X$libobjs" = "X " && libobjs= + fi + # Expand the library linking commands again to reset the + # value of $libobjs for piecewise linking. + + # Do each of the archive commands. + if test "$module" = yes && test -n "$module_cmds" ; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + cmds=$module_expsym_cmds + else + cmds=$module_cmds + fi + else + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + cmds=$archive_expsym_cmds + else + cmds=$archive_cmds + fi + fi + fi + + if test -n "$delfiles"; then + # Append the command to remove temporary files to $cmds. + eval cmds=\"\$cmds~\$RM $delfiles\" + fi + + # Add any objects from preloaded convenience libraries + if test -n "$dlprefiles"; then + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + + func_extract_archives $gentop $dlprefiles + libobjs="$libobjs $func_extract_archives_result" + test "X$libobjs" = "X " && libobjs= + fi + + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $opt_silent || { + func_quote_for_expand "$cmd" + eval "func_echo $func_quote_for_expand_result" + } + $opt_dry_run || eval "$cmd" || { + lt_exit=$? + + # Restore the uninstalled library and exit + if test "$mode" = relink; then + ( cd "$output_objdir" && \ + $RM "${realname}T" && \ + $MV "${realname}U" "$realname" ) + fi + + exit $lt_exit + } + done + IFS="$save_ifs" + + # Restore the uninstalled library and exit + if test "$mode" = relink; then + $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? + + if test -n "$convenience"; then + if test -z "$whole_archive_flag_spec"; then + func_show_eval '${RM}r "$gentop"' + fi + fi + + exit $EXIT_SUCCESS + fi + + # Create links to the real library. + for linkname in $linknames; do + if test "$realname" != "$linkname"; then + func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' + fi + done + + # If -module or -export-dynamic was specified, set the dlname. + if test "$module" = yes || test "$export_dynamic" = yes; then + # On all known operating systems, these are identical. + dlname="$soname" + fi + fi + ;; + + obj) + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + func_warning "\`-dlopen' is ignored for objects" + fi + + case " $deplibs" in + *\ -l* | *\ -L*) + func_warning "\`-l' and \`-L' are ignored for objects" ;; + esac + + test -n "$rpath" && \ + func_warning "\`-rpath' is ignored for objects" + + test -n "$xrpath" && \ + func_warning "\`-R' is ignored for objects" + + test -n "$vinfo" && \ + func_warning "\`-version-info' is ignored for objects" + + test -n "$release" && \ + func_warning "\`-release' is ignored for objects" + + case $output in + *.lo) + test -n "$objs$old_deplibs" && \ + func_fatal_error "cannot build library object \`$output' from non-libtool objects" + + libobj=$output + func_lo2o "$libobj" + obj=$func_lo2o_result + ;; + *) + libobj= + obj="$output" + ;; + esac + + # Delete the old objects. + $opt_dry_run || $RM $obj $libobj + + # Objects from convenience libraries. This assumes + # single-version convenience libraries. Whenever we create + # different ones for PIC/non-PIC, this we'll have to duplicate + # the extraction. + reload_conv_objs= + gentop= + # reload_cmds runs $LD directly, so let us get rid of + # -Wl from whole_archive_flag_spec and hope we can get by with + # turning comma into space.. + wl= + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" + reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'` + else + gentop="$output_objdir/${obj}x" + generated="$generated $gentop" + + func_extract_archives $gentop $convenience + reload_conv_objs="$reload_objs $func_extract_archives_result" + fi + fi + + # Create the old-style object. + reload_objs="$objs$old_deplibs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test + + output="$obj" + func_execute_cmds "$reload_cmds" 'exit $?' + + # Exit if we aren't doing a library object file. + if test -z "$libobj"; then + if test -n "$gentop"; then + func_show_eval '${RM}r "$gentop"' + fi + + exit $EXIT_SUCCESS + fi + + if test "$build_libtool_libs" != yes; then + if test -n "$gentop"; then + func_show_eval '${RM}r "$gentop"' + fi + + # Create an invalid libtool object if no PIC, so that we don't + # accidentally link it into a program. + # $show "echo timestamp > $libobj" + # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? + exit $EXIT_SUCCESS + fi + + if test -n "$pic_flag" || test "$pic_mode" != default; then + # Only do commands if we really have different PIC objects. + reload_objs="$libobjs $reload_conv_objs" + output="$libobj" + func_execute_cmds "$reload_cmds" 'exit $?' + fi + + if test -n "$gentop"; then + func_show_eval '${RM}r "$gentop"' + fi + + exit $EXIT_SUCCESS + ;; + + prog) + case $host in + *cygwin*) func_stripname '' '.exe' "$output" + output=$func_stripname_result.exe;; + esac + test -n "$vinfo" && \ + func_warning "\`-version-info' is ignored for programs" + + test -n "$release" && \ + func_warning "\`-release' is ignored for programs" + + test "$preload" = yes \ + && test "$dlopen_support" = unknown \ + && test "$dlopen_self" = unknown \ + && test "$dlopen_self_static" = unknown && \ + func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library is the System framework + compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'` + finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'` + ;; + esac + + case $host in + *-*-darwin*) + # Don't allow lazy linking, it breaks C++ global constructors + # But is supposedly fixed on 10.4 or later (yay!). + if test "$tagname" = CXX ; then + case ${MACOSX_DEPLOYMENT_TARGET-10.0} in + 10.[0123]) + compile_command="$compile_command ${wl}-bind_at_load" + finalize_command="$finalize_command ${wl}-bind_at_load" + ;; + esac + fi + # Time to change all our "foo.ltframework" stuff back to "-framework foo" + compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` + finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` + ;; + esac + + + # move library search paths that coincide with paths to not yet + # installed libraries to the beginning of the library search list + new_libs= + for path in $notinst_path; do + case " $new_libs " in + *" -L$path/$objdir "*) ;; + *) + case " $compile_deplibs " in + *" -L$path/$objdir "*) + new_libs="$new_libs -L$path/$objdir" ;; + esac + ;; + esac + done + for deplib in $compile_deplibs; do + case $deplib in + -L*) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$new_libs $deplib" ;; + esac + ;; + *) new_libs="$new_libs $deplib" ;; + esac + done + compile_deplibs="$new_libs" + + + compile_command="$compile_command $compile_deplibs" + finalize_command="$finalize_command $finalize_deplibs" + + if test -n "$rpath$xrpath"; then + # If the user specified any rpath flags, then add them. + for libdir in $rpath $xrpath; do + # This is the magic to use -rpath. + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; + esac + done + fi + + # Now hardcode the library paths + rpath= + hardcode_libdirs= + for libdir in $compile_rpath $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` + case :$dllsearchpath: in + *":$libdir:"*) ;; + ::) dllsearchpath=$libdir;; + *) dllsearchpath="$dllsearchpath:$libdir";; + esac + case :$dllsearchpath: in + *":$testbindir:"*) ;; + ::) dllsearchpath=$testbindir;; + *) dllsearchpath="$dllsearchpath:$testbindir";; + esac + ;; + esac + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + compile_rpath="$rpath" + + rpath= + hardcode_libdirs= + for libdir in $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$finalize_perm_rpath " in + *" $libdir "*) ;; + *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + finalize_rpath="$rpath" + + if test -n "$libobjs" && test "$build_old_libs" = yes; then + # Transform all the library objects into standard objects. + compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + fi + + func_generate_dlsyms "$outputname" "@PROGRAM@" "no" + + # template prelinking step + if test -n "$prelink_cmds"; then + func_execute_cmds "$prelink_cmds" 'exit $?' + fi + + wrappers_required=yes + case $host in + *cygwin* | *mingw* ) + if test "$build_libtool_libs" != yes; then + wrappers_required=no + fi + ;; + *cegcc) + # Disable wrappers for cegcc, we are cross compiling anyway. + wrappers_required=no + ;; + *) + if test "$need_relink" = no || test "$build_libtool_libs" != yes; then + wrappers_required=no + fi + ;; + esac + if test "$wrappers_required" = no; then + # Replace the output file specification. + compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` + link_command="$compile_command$compile_rpath" + + # We have no uninstalled library dependencies, so finalize right now. + exit_status=0 + func_show_eval "$link_command" 'exit_status=$?' + + # Delete the generated files. + if test -f "$output_objdir/${outputname}S.${objext}"; then + func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' + fi + + exit $exit_status + fi + + if test -n "$compile_shlibpath$finalize_shlibpath"; then + compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" + fi + if test -n "$finalize_shlibpath"; then + finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" + fi + + compile_var= + finalize_var= + if test -n "$runpath_var"; then + if test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + compile_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + if test -n "$finalize_perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $finalize_perm_rpath; do + rpath="$rpath$dir:" + done + finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + fi + + if test "$no_install" = yes; then + # We don't need to create a wrapper script. + link_command="$compile_var$compile_command$compile_rpath" + # Replace the output file specification. + link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` + # Delete the old output file. + $opt_dry_run || $RM $output + # Link the executable and exit + func_show_eval "$link_command" 'exit $?' + exit $EXIT_SUCCESS + fi + + if test "$hardcode_action" = relink; then + # Fast installation is not supported + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + + func_warning "this platform does not like uninstalled shared libraries" + func_warning "\`$output' will be relinked during installation" + else + if test "$fast_install" != no; then + link_command="$finalize_var$compile_command$finalize_rpath" + if test "$fast_install" = yes; then + relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` + else + # fast_install is set to needless + relink_command= + fi + else + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + fi + fi + + # Replace the output file specification. + link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` + + # Delete the old output files. + $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname + + func_show_eval "$link_command" 'exit $?' + + # Now create the wrapper script. + func_verbose "creating $output" + + # Quote the relink command for shipping. + if test -n "$relink_command"; then + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + func_quote_for_eval "$var_value" + relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" + fi + done + relink_command="(cd `pwd`; $relink_command)" + relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"` + fi + + # Quote $ECHO for shipping. + if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then + case $progpath in + [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";; + *) qecho="$SHELL `pwd`/$progpath --fallback-echo";; + esac + qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"` + else + qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"` + fi + + # Only actually do things if not in dry run mode. + $opt_dry_run || { + # win32 will think the script is a binary if it has + # a .exe suffix, so we strip it off here. + case $output in + *.exe) func_stripname '' '.exe' "$output" + output=$func_stripname_result ;; + esac + # test for cygwin because mv fails w/o .exe extensions + case $host in + *cygwin*) + exeext=.exe + func_stripname '' '.exe' "$outputname" + outputname=$func_stripname_result ;; + *) exeext= ;; + esac + case $host in + *cygwin* | *mingw* ) + func_dirname_and_basename "$output" "" "." + output_name=$func_basename_result + output_path=$func_dirname_result + cwrappersource="$output_path/$objdir/lt-$output_name.c" + cwrapper="$output_path/$output_name.exe" + $RM $cwrappersource $cwrapper + trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 + + func_emit_cwrapperexe_src > $cwrappersource + + # The wrapper executable is built using the $host compiler, + # because it contains $host paths and files. If cross- + # compiling, it, like the target executable, must be + # executed on the $host or under an emulation environment. + $opt_dry_run || { + $LTCC $LTCFLAGS -o $cwrapper $cwrappersource + $STRIP $cwrapper + } + + # Now, create the wrapper script for func_source use: + func_ltwrapper_scriptname $cwrapper + $RM $func_ltwrapper_scriptname_result + trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 + $opt_dry_run || { + # note: this script will not be executed, so do not chmod. + if test "x$build" = "x$host" ; then + $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result + else + func_emit_wrapper no > $func_ltwrapper_scriptname_result + fi + } + ;; + * ) + $RM $output + trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 + + func_emit_wrapper no > $output + chmod +x $output + ;; + esac + } + exit $EXIT_SUCCESS + ;; + esac + + # See if we need to build an old-fashioned archive. + for oldlib in $oldlibs; do + + if test "$build_libtool_libs" = convenience; then + oldobjs="$libobjs_save $symfileobj" + addlibs="$convenience" + build_libtool_libs=no + else + if test "$build_libtool_libs" = module; then + oldobjs="$libobjs_save" + build_libtool_libs=no + else + oldobjs="$old_deplibs $non_pic_objects" + if test "$preload" = yes && test -f "$symfileobj"; then + oldobjs="$oldobjs $symfileobj" + fi + fi + addlibs="$old_convenience" + fi + + if test -n "$addlibs"; then + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + + func_extract_archives $gentop $addlibs + oldobjs="$oldobjs $func_extract_archives_result" + fi + + # Do each command in the archive commands. + if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then + cmds=$old_archive_from_new_cmds + else + + # Add any objects from preloaded convenience libraries + if test -n "$dlprefiles"; then + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + + func_extract_archives $gentop $dlprefiles + oldobjs="$oldobjs $func_extract_archives_result" + fi + + # POSIX demands no paths to be encoded in archives. We have + # to avoid creating archives with duplicate basenames if we + # might have to extract them afterwards, e.g., when creating a + # static archive out of a convenience library, or when linking + # the entirety of a libtool archive into another (currently + # not supported by libtool). + if (for obj in $oldobjs + do + func_basename "$obj" + $ECHO "$func_basename_result" + done | sort | sort -uc >/dev/null 2>&1); then + : + else + $ECHO "copying selected object files to avoid basename conflicts..." + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + func_mkdir_p "$gentop" + save_oldobjs=$oldobjs + oldobjs= + counter=1 + for obj in $save_oldobjs + do + func_basename "$obj" + objbase="$func_basename_result" + case " $oldobjs " in + " ") oldobjs=$obj ;; + *[\ /]"$objbase "*) + while :; do + # Make sure we don't pick an alternate name that also + # overlaps. + newobj=lt$counter-$objbase + func_arith $counter + 1 + counter=$func_arith_result + case " $oldobjs " in + *[\ /]"$newobj "*) ;; + *) if test ! -f "$gentop/$newobj"; then break; fi ;; + esac + done + func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" + oldobjs="$oldobjs $gentop/$newobj" + ;; + *) oldobjs="$oldobjs $obj" ;; + esac + done + fi + eval cmds=\"$old_archive_cmds\" + + func_len " $cmds" + len=$func_len_result + if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then + cmds=$old_archive_cmds + else + # the command line is too long to link in one step, link in parts + func_verbose "using piecewise archive linking..." + save_RANLIB=$RANLIB + RANLIB=: + objlist= + concat_cmds= + save_oldobjs=$oldobjs + oldobjs= + # Is there a better way of finding the last object in the list? + for obj in $save_oldobjs + do + last_oldobj=$obj + done + eval test_cmds=\"$old_archive_cmds\" + func_len " $test_cmds" + len0=$func_len_result + len=$len0 + for obj in $save_oldobjs + do + func_len " $obj" + func_arith $len + $func_len_result + len=$func_arith_result + func_append objlist " $obj" + if test "$len" -lt "$max_cmd_len"; then + : + else + # the above command should be used before it gets too long + oldobjs=$objlist + if test "$obj" = "$last_oldobj" ; then + RANLIB=$save_RANLIB + fi + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" + objlist= + len=$len0 + fi + done + RANLIB=$save_RANLIB + oldobjs=$objlist + if test "X$oldobjs" = "X" ; then + eval cmds=\"\$concat_cmds\" + else + eval cmds=\"\$concat_cmds~\$old_archive_cmds\" + fi + fi + fi + func_execute_cmds "$cmds" 'exit $?' + done + + test -n "$generated" && \ + func_show_eval "${RM}r$generated" + + # Now create the libtool archive. + case $output in + *.la) + old_library= + test "$build_old_libs" = yes && old_library="$libname.$libext" + func_verbose "creating $output" + + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + func_quote_for_eval "$var_value" + relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" + fi + done + # Quote the link command for shipping. + relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" + relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"` + if test "$hardcode_automatic" = yes ; then + relink_command= + fi + + # Only create the output if not a dry run. + $opt_dry_run || { + for installed in no yes; do + if test "$installed" = yes; then + if test -z "$install_libdir"; then + break + fi + output="$output_objdir/$outputname"i + # Replace all uninstalled libtool libraries with the installed ones + newdependency_libs= + for deplib in $dependency_libs; do + case $deplib in + *.la) + func_basename "$deplib" + name="$func_basename_result" + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + test -z "$libdir" && \ + func_fatal_error "\`$deplib' is not a valid libtool archive" + newdependency_libs="$newdependency_libs $libdir/$name" + ;; + *) newdependency_libs="$newdependency_libs $deplib" ;; + esac + done + dependency_libs="$newdependency_libs" + newdlfiles= + + for lib in $dlfiles; do + case $lib in + *.la) + func_basename "$lib" + name="$func_basename_result" + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + test -z "$libdir" && \ + func_fatal_error "\`$lib' is not a valid libtool archive" + newdlfiles="$newdlfiles $libdir/$name" + ;; + *) newdlfiles="$newdlfiles $lib" ;; + esac + done + dlfiles="$newdlfiles" + newdlprefiles= + for lib in $dlprefiles; do + case $lib in + *.la) + # Only pass preopened files to the pseudo-archive (for + # eventual linking with the app. that links it) if we + # didn't already link the preopened objects directly into + # the library: + func_basename "$lib" + name="$func_basename_result" + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + test -z "$libdir" && \ + func_fatal_error "\`$lib' is not a valid libtool archive" + newdlprefiles="$newdlprefiles $libdir/$name" + ;; + esac + done + dlprefiles="$newdlprefiles" + else + newdlfiles= + for lib in $dlfiles; do + case $lib in + [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; + *) abs=`pwd`"/$lib" ;; + esac + newdlfiles="$newdlfiles $abs" + done + dlfiles="$newdlfiles" + newdlprefiles= + for lib in $dlprefiles; do + case $lib in + [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; + *) abs=`pwd`"/$lib" ;; + esac + newdlprefiles="$newdlprefiles $abs" + done + dlprefiles="$newdlprefiles" + fi + $RM $output + # place dlname in correct position for cygwin + tdlname=$dlname + case $host,$output,$installed,$module,$dlname in + *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; + esac + $ECHO > $output "\ +# $outputname - a libtool library file +# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='$tdlname' + +# Names of this library. +library_names='$library_names' + +# The name of the static archive. +old_library='$old_library' + +# Linker flags that can not go in dependency_libs. +inherited_linker_flags='$new_inherited_linker_flags' + +# Libraries that this one depends upon. +dependency_libs='$dependency_libs' + +# Names of additional weak libraries provided by this library +weak_library_names='$weak_libs' + +# Version information for $libname. +current=$current +age=$age +revision=$revision + +# Is this an already installed library? +installed=$installed + +# Should we warn about portability when linking against -modules? +shouldnotlink=$module + +# Files to dlopen/dlpreopen +dlopen='$dlfiles' +dlpreopen='$dlprefiles' + +# Directory that this library needs to be installed in: +libdir='$install_libdir'" + if test "$installed" = no && test "$need_relink" = yes; then + $ECHO >> $output "\ +relink_command=\"$relink_command\"" + fi + done + } + + # Do a symbolic link so that the libtool archive can be found in + # LD_LIBRARY_PATH before the program is installed. + func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' + ;; + esac + exit $EXIT_SUCCESS +} + +{ test "$mode" = link || test "$mode" = relink; } && + func_mode_link ${1+"$@"} + + +# func_mode_uninstall arg... +func_mode_uninstall () +{ + $opt_debug + RM="$nonopt" + files= + rmforce= + exit_status=0 + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + for arg + do + case $arg in + -f) RM="$RM $arg"; rmforce=yes ;; + -*) RM="$RM $arg" ;; + *) files="$files $arg" ;; + esac + done + + test -z "$RM" && \ + func_fatal_help "you must specify an RM program" + + rmdirs= + + origobjdir="$objdir" + for file in $files; do + func_dirname "$file" "" "." + dir="$func_dirname_result" + if test "X$dir" = X.; then + objdir="$origobjdir" + else + objdir="$dir/$origobjdir" + fi + func_basename "$file" + name="$func_basename_result" + test "$mode" = uninstall && objdir="$dir" + + # Remember objdir for removal later, being careful to avoid duplicates + if test "$mode" = clean; then + case " $rmdirs " in + *" $objdir "*) ;; + *) rmdirs="$rmdirs $objdir" ;; + esac + fi + + # Don't error if the file doesn't exist and rm -f was used. + if { test -L "$file"; } >/dev/null 2>&1 || + { test -h "$file"; } >/dev/null 2>&1 || + test -f "$file"; then + : + elif test -d "$file"; then + exit_status=1 + continue + elif test "$rmforce" = yes; then + continue + fi + + rmfiles="$file" + + case $name in + *.la) + # Possibly a libtool archive, so verify it. + if func_lalib_p "$file"; then + func_source $dir/$name + + # Delete the libtool libraries and symlinks. + for n in $library_names; do + rmfiles="$rmfiles $objdir/$n" + done + test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" + + case "$mode" in + clean) + case " $library_names " in + # " " in the beginning catches empty $dlname + *" $dlname "*) ;; + *) rmfiles="$rmfiles $objdir/$dlname" ;; + esac + test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" + ;; + uninstall) + if test -n "$library_names"; then + # Do each command in the postuninstall commands. + func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' + fi + + if test -n "$old_library"; then + # Do each command in the old_postuninstall commands. + func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' + fi + # FIXME: should reinstall the best remaining shared library. + ;; + esac + fi + ;; + + *.lo) + # Possibly a libtool object, so verify it. + if func_lalib_p "$file"; then + + # Read the .lo file + func_source $dir/$name + + # Add PIC object to the list of files to remove. + if test -n "$pic_object" && + test "$pic_object" != none; then + rmfiles="$rmfiles $dir/$pic_object" + fi + + # Add non-PIC object to the list of files to remove. + if test -n "$non_pic_object" && + test "$non_pic_object" != none; then + rmfiles="$rmfiles $dir/$non_pic_object" + fi + fi + ;; + + *) + if test "$mode" = clean ; then + noexename=$name + case $file in + *.exe) + func_stripname '' '.exe' "$file" + file=$func_stripname_result + func_stripname '' '.exe' "$name" + noexename=$func_stripname_result + # $file with .exe has already been added to rmfiles, + # add $file without .exe + rmfiles="$rmfiles $file" + ;; + esac + # Do a test to see if this is a libtool program. + if func_ltwrapper_p "$file"; then + if func_ltwrapper_executable_p "$file"; then + func_ltwrapper_scriptname "$file" + relink_command= + func_source $func_ltwrapper_scriptname_result + rmfiles="$rmfiles $func_ltwrapper_scriptname_result" + else + relink_command= + func_source $dir/$noexename + fi + + # note $name still contains .exe if it was in $file originally + # as does the version of $file that was added into $rmfiles + rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" + if test "$fast_install" = yes && test -n "$relink_command"; then + rmfiles="$rmfiles $objdir/lt-$name" + fi + if test "X$noexename" != "X$name" ; then + rmfiles="$rmfiles $objdir/lt-${noexename}.c" + fi + fi + fi + ;; + esac + func_show_eval "$RM $rmfiles" 'exit_status=1' + done + objdir="$origobjdir" + + # Try to remove the ${objdir}s in the directories where we deleted files + for dir in $rmdirs; do + if test -d "$dir"; then + func_show_eval "rmdir $dir >/dev/null 2>&1" + fi + done + + exit $exit_status +} + +{ test "$mode" = uninstall || test "$mode" = clean; } && + func_mode_uninstall ${1+"$@"} + +test -z "$mode" && { + help="$generic_help" + func_fatal_help "you must specify a MODE" +} + +test -z "$exec_cmd" && \ + func_fatal_help "invalid operation mode \`$mode'" + +if test -n "$exec_cmd"; then + eval exec "$exec_cmd" + exit $EXIT_FAILURE +fi + +exit $exit_status + + +# The TAGs below are defined such that we never get into a situation +# in which we disable both kinds of libraries. Given conflicting +# choices, we go for a static library, that is the most portable, +# since we can't tell whether shared libraries were disabled because +# the user asked for that or because the platform doesn't support +# them. This is particularly important on AIX, because we don't +# support having both static and shared libraries enabled at the same +# time on that platform, so we default to a shared-only configuration. +# If a disable-shared tag is given, we'll fallback to a static-only +# configuration. But we'll never go from static-only to shared-only. + +# ### BEGIN LIBTOOL TAG CONFIG: disable-shared +build_libtool_libs=no +build_old_libs=yes +# ### END LIBTOOL TAG CONFIG: disable-shared + +# ### BEGIN LIBTOOL TAG CONFIG: disable-static +build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` +# ### END LIBTOOL TAG CONFIG: disable-static + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: +# vi:sw=2 + diff --git a/config/missing b/config/missing new file mode 100644 index 0000000..e7ef83a --- /dev/null +++ b/config/missing @@ -0,0 +1,360 @@ +#! /bin/sh +# Common stub for a few missing GNU programs while installing. + +scriptversion=2003-09-02.23 + +# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003 +# Free Software Foundation, Inc. +# Originally by Fran,cois Pinard , 1996. + +# 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 +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +if test $# -eq 0; then + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 +fi + +run=: + +# In the cases where this matters, `missing' is being run in the +# srcdir already. +if test -f configure.ac; then + configure_ac=configure.ac +else + configure_ac=configure.in +fi + +msg="missing on your system" + +case "$1" in +--run) + # Try to run requested program, and just exit if it succeeds. + run= + shift + "$@" && exit 0 + # Exit code 63 means version mismatch. This often happens + # when the user try to use an ancient version of a tool on + # a file that requires a minimum version. In this case we + # we should proceed has if the program had been absent, or + # if --run hadn't been passed. + if test $? = 63; then + run=: + msg="probably too old" + fi + ;; +esac + +# If it does not exist, or fails to run (possibly an outdated version), +# try to emulate it. +case "$1" in + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an +error status if there is no known handling for PROGRAM. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + --run try to run the given command, and emulate it if it fails + +Supported PROGRAM values: + aclocal touch file \`aclocal.m4' + autoconf touch file \`configure' + autoheader touch file \`config.h.in' + automake touch all \`Makefile.in' files + bison create \`y.tab.[ch]', if possible, from existing .[ch] + flex create \`lex.yy.c', if possible, from existing .c + help2man touch the output file + lex create \`lex.yy.c', if possible, from existing .c + makeinfo touch the output file + tar try tar, gnutar, gtar, then tar without non-portable flags + yacc create \`y.tab.[ch]', if possible, from existing .[ch] + +Send bug reports to ." + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing $scriptversion (GNU Automake)" + ;; + + -*) + echo 1>&2 "$0: Unknown \`$1' option" + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 + ;; + + aclocal*) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acinclude.m4' or \`${configure_ac}'. You might want + to install the \`Automake' and \`Perl' packages. Grab them from + any GNU archive site." + touch aclocal.m4 + ;; + + autoconf) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`${configure_ac}'. You might want to install the + \`Autoconf' and \`GNU m4' packages. Grab them from any GNU + archive site." + touch configure + ;; + + autoheader) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acconfig.h' or \`${configure_ac}'. You might want + to install the \`Autoconf' and \`GNU m4' packages. Grab them + from any GNU archive site." + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` + test -z "$files" && files="config.h" + touch_files= + for f in $files; do + case "$f" in + *:*) touch_files="$touch_files "`echo "$f" | + sed -e 's/^[^:]*://' -e 's/:.*//'`;; + *) touch_files="$touch_files $f.in";; + esac + done + touch $touch_files + ;; + + automake*) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. + You might want to install the \`Automake' and \`Perl' packages. + Grab them from any GNU archive site." + find . -type f -name Makefile.am -print | + sed 's/\.am$/.in/' | + while read f; do touch "$f"; done + ;; + + autom4te) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is needed, but is $msg. + You might have modified some files without having the + proper tools for further handling them. + You can get \`$1' as part of \`Autoconf' from any GNU + archive site." + + file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` + test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` + if test -f "$file"; then + touch $file + else + test -z "$file" || exec >$file + echo "#! /bin/sh" + echo "# Created by GNU Automake missing as a replacement of" + echo "# $ $@" + echo "exit 0" + chmod +x $file + exit 1 + fi + ;; + + bison|yacc) + echo 1>&2 "\ +WARNING: \`$1' $msg. You should only need it if + you modified a \`.y' file. You may need the \`Bison' package + in order for those modifications to take effect. You can get + \`Bison' from any GNU archive site." + rm -f y.tab.c y.tab.h + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.y) + SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.c + fi + SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.h + fi + ;; + esac + fi + if [ ! -f y.tab.h ]; then + echo >y.tab.h + fi + if [ ! -f y.tab.c ]; then + echo 'main() { return 0; }' >y.tab.c + fi + ;; + + lex|flex) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.l' file. You may need the \`Flex' package + in order for those modifications to take effect. You can get + \`Flex' from any GNU archive site." + rm -f lex.yy.c + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.l) + SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" lex.yy.c + fi + ;; + esac + fi + if [ ! -f lex.yy.c ]; then + echo 'main() { return 0; }' >lex.yy.c + fi + ;; + + help2man) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a dependency of a manual page. You may need the + \`Help2man' package in order for those modifications to take + effect. You can get \`Help2man' from any GNU archive site." + + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` + fi + if [ -f "$file" ]; then + touch $file + else + test -z "$file" || exec >$file + echo ".ab help2man is required to generate this page" + exit 1 + fi + ;; + + makeinfo) + if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then + # We have makeinfo, but it failed. + exit 1 + fi + + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.texi' or \`.texinfo' file, or any other file + indirectly affecting the aspect of the manual. The spurious + call might also be the consequence of using a buggy \`make' (AIX, + DU, IRIX). You might want to install the \`Texinfo' package or + the \`GNU make' package. Grab either from any GNU archive site." + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` + fi + touch $file + ;; + + tar) + shift + if test -n "$run"; then + echo 1>&2 "ERROR: \`tar' requires --run" + exit 1 + fi + + # We have already tried tar in the generic part. + # Look for gnutar/gtar before invocation to avoid ugly error + # messages. + if (gnutar --version > /dev/null 2>&1); then + gnutar "$@" && exit 0 + fi + if (gtar --version > /dev/null 2>&1); then + gtar "$@" && exit 0 + fi + firstarg="$1" + if shift; then + case "$firstarg" in + *o*) + firstarg=`echo "$firstarg" | sed s/o//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + case "$firstarg" in + *h*) + firstarg=`echo "$firstarg" | sed s/h//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + fi + + echo 1>&2 "\ +WARNING: I can't seem to be able to run \`tar' with the given arguments. + You may want to install GNU tar or Free paxutils, or check the + command line arguments." + exit 1 + ;; + + *) + echo 1>&2 "\ +WARNING: \`$1' is needed, and is $msg. + You might have modified some files without having the + proper tools for further handling them. Check the \`README' file, + it often tells you about the needed prerequisites for installing + this package. You may also peek at any GNU archive site, in case + some other package would contain this missing \`$1' program." + exit 1 + ;; +esac + +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/config/mkinstalldirs b/config/mkinstalldirs new file mode 100644 index 0000000..6fbe5e1 --- /dev/null +++ b/config/mkinstalldirs @@ -0,0 +1,150 @@ +#! /bin/sh +# mkinstalldirs --- make directory hierarchy + +scriptversion=2004-02-15.20 + +# Original author: Noah Friedman +# Created: 1993-05-16 +# Public domain. +# +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + +errstatus=0 +dirmode="" + +usage="\ +Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ... + +Create each directory DIR (with mode MODE, if specified), including all +leading file name components. + +Report bugs to ." + +# process command line arguments +while test $# -gt 0 ; do + case $1 in + -h | --help | --h*) # -h for help + echo "$usage" + exit 0 + ;; + -m) # -m PERM arg + shift + test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } + dirmode=$1 + shift + ;; + --version) + echo "$0 $scriptversion" + exit 0 + ;; + --) # stop option processing + shift + break + ;; + -*) # unknown option + echo "$usage" 1>&2 + exit 1 + ;; + *) # first non-opt arg + break + ;; + esac +done + +for file +do + if test -d "$file"; then + shift + else + break + fi +done + +case $# in + 0) exit 0 ;; +esac + +# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and +# mkdir -p a/c at the same time, both will detect that a is missing, +# one will create a, then the other will try to create a and die with +# a "File exists" error. This is a problem when calling mkinstalldirs +# from a parallel make. We use --version in the probe to restrict +# ourselves to GNU mkdir, which is thread-safe. +case $dirmode in + '') + if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then + echo "mkdir -p -- $*" + exec mkdir -p -- "$@" + else + # On NextStep and OpenStep, the `mkdir' command does not + # recognize any option. It will interpret all options as + # directories to create, and then abort because `.' already + # exists. + test -d ./-p && rmdir ./-p + test -d ./--version && rmdir ./--version + fi + ;; + *) + if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 && + test ! -d ./--version; then + echo "mkdir -m $dirmode -p -- $*" + exec mkdir -m "$dirmode" -p -- "$@" + else + # Clean up after NextStep and OpenStep mkdir. + for d in ./-m ./-p ./--version "./$dirmode"; + do + test -d $d && rmdir $d + done + fi + ;; +esac + +for file +do + set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` + shift + + pathcomp= + for d + do + pathcomp="$pathcomp$d" + case $pathcomp in + -*) pathcomp=./$pathcomp ;; + esac + + if test ! -d "$pathcomp"; then + echo "mkdir $pathcomp" + + mkdir "$pathcomp" || lasterr=$? + + if test ! -d "$pathcomp"; then + errstatus=$lasterr + else + if test ! -z "$dirmode"; then + echo "chmod $dirmode $pathcomp" + lasterr="" + chmod "$dirmode" "$pathcomp" || lasterr=$? + + if test ! -z "$lasterr"; then + errstatus=$lasterr + fi + fi + fi + fi + + pathcomp="$pathcomp/" + done +done + +exit $errstatus + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/configure b/configure new file mode 100644 index 0000000..a221f74 --- /dev/null +++ b/configure @@ -0,0 +1,23697 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.69. +# +# +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. +# +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, +$0: including any error possibly output before this +$0: message. Then install a modern shell, or manually run +$0: the script under such a shell if you do have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + + +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} + +case X$lt_ECHO in +X*--fallback-echo) + # Remove one level of quotation (which was required for Make). + ECHO=`echo "$lt_ECHO" | sed 's,\\\\\$\\$0,'$0','` + ;; +esac + +ECHO=${lt_ECHO-echo} +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then + # Yippee, $ECHO works! + : +else + # Restart under the correct shell. + exec $SHELL "$0" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat <<_LT_EOF +$* +_LT_EOF + exit 0 +fi + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +if test -z "$lt_ECHO"; then + if test "X${echo_test_string+set}" != Xset; then + # find a string as large as possible, as long as the shell can cope with it + for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do + # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... + if { echo_test_string=`eval $cmd`; } 2>/dev/null && + { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null + then + break + fi + done + fi + + if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + : + else + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for dir in $PATH /usr/ucb; do + IFS="$lt_save_ifs" + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + ECHO="$dir/echo" + break + fi + done + IFS="$lt_save_ifs" + + if test "X$ECHO" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # This shell has a builtin print -r that does the trick. + ECHO='print -r' + elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running configure again with it. + ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"} + else + # Try using printf. + ECHO='printf %s\n' + if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # Cool, printf works + : + elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + ECHO="$CONFIG_SHELL $0 --fallback-echo" + elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + ECHO="$CONFIG_SHELL $0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do + if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null + then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "$0"'; then + echo_test_string=`eval $prev` + export echo_test_string + exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"} + else + # Oops. We lost completely, so just stick with echo. + ECHO=echo + fi + fi + fi + fi + fi +fi + +# Copy echo and quote the copy suitably for passing to libtool from +# the Makefile, instead of quoting the original, which is used later. +lt_ECHO=$ECHO +if test "X$lt_ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then + lt_ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo" +fi + + + + +test -n "$DJDIR" || exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= + +# Identity of this package. +PACKAGE_NAME= +PACKAGE_TARNAME= +PACKAGE_VERSION= +PACKAGE_STRING= +PACKAGE_BUGREPORT= +PACKAGE_URL= + +ac_unique_file="tcpreplay" +ac_unique_file="src/tcpreplay.c" +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='am__EXEEXT_FALSE +am__EXEEXT_TRUE +LTLIBOBJS +LIBOPTS_CFLAGS +LIBOPTS_LDADD +NEED_LIBOPTS_FALSE +NEED_LIBOPTS_TRUE +INSTALL_LIBOPTS_FALSE +INSTALL_LIBOPTS_TRUE +LIBOPTS_DIR +nic2 +nic1 +ENABLE_OSX_FRAMEWORKS_FALSE +ENABLE_OSX_FRAMEWORKS_TRUE +ENABLE_TCPDUMP_FALSE +ENABLE_TCPDUMP_TRUE +tcpdump_path +LNAV_CFLAGS +LNAVLIB +pcncfg +PCAP_BPF_H_FILE +COMPILE_FRAGROUTE_FALSE +COMPILE_FRAGROUTE_TRUE +LDNETLIB +LDNETINC +COMPILE_TCPBRIDGE_FALSE +COMPILE_TCPBRIDGE_TRUE +LPCAPLIB +LPCAPINC +DMALLOC_LIB +debug_flag +WORDS_BIGENDIAN_FALSE +WORDS_BIGENDIAN_TRUE +SYSTEM_STRLCPY_FALSE +SYSTEM_STRLCPY_TRUE +LIBOBJS +GROFF +AUTOGEN +CUT +ECHO +PRINTF +CXXCPP +am__fastdepCXX_FALSE +am__fastdepCXX_TRUE +CXXDEPMODE +ac_ct_CXX +CXXFLAGS +CXX +CPP +OTOOL64 +OTOOL +LIPO +NMEDIT +DSYMUTIL +lt_ECHO +RANLIB +AR +OBJDUMP +LN_S +NM +ac_ct_DUMPBIN +DUMPBIN +LD +FGREP +EGREP +GREP +SED +am__fastdepCC_FALSE +am__fastdepCC_TRUE +CCDEPMODE +AMDEPBACKSLASH +AMDEP_FALSE +AMDEP_TRUE +am__quote +am__include +DEPDIR +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +LIBTOOL +am__untar +am__tar +AMTAR +am__leading_dot +SET_MAKE +AWK +mkdir_p +MKDIR_P +INSTALL_STRIP_PROGRAM +STRIP +install_sh +MAKEINFO +AUTOHEADER +AUTOMAKE +AUTOCONF +ACLOCAL +VERSION +PACKAGE +CYGPATH_W +am__isrc +INSTALL_DATA +INSTALL_SCRIPT +INSTALL_PROGRAM +target_os +target_vendor +target_cpu +target +host_os +host_vendor +host_cpu +host +build_os +build_vendor +build_cpu +build +TCPREPLAY_RELEASE +TCPREPLAY_VERSION +MAINT +MAINTAINER_MODE_FALSE +MAINTAINER_MODE_TRUE +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_URL +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +enable_maintainer_mode +with_dmalloc +enable_shared +enable_static +with_pic +enable_fast_install +enable_dependency_tracking +with_gnu_ld +enable_libtool_lock +enable_largefile +enable_debug +enable_dmalloc +enable_pedantic +enable_efence +enable_gprof +enable_64bits +enable_force_bpf +enable_force_pf +enable_force_libdnet +enable_force_inject +enable_force_sendpacket +enable_dynamic_link +with_libpcap +with_libdnet +with_pcapnav_config +with_tcpdump +with_testnic +with_testnic2 +enable_local_libopts +enable_libopts_install +with_autoopts_config +with_regex_header +with_libregex +with_libregex_cflags +with_libregex_libs +enable_optional_args +' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP +CXX +CXXFLAGS +CCC +CXXCPP' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + as_fn_error $? "missing argument to $ac_option" +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + as_fn_error $? "working directory cannot be determined" +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + as_fn_error $? "pwd does not report name of working directory" + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures this package to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking ...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF + +Program names: + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] + --target=TARGET configure for building compilers for TARGET [HOST] +_ACEOF +fi + +if test -n "$ac_init_help"; then + + cat <<\_ACEOF + +Optional Features: + --disable-option-checking ignore unrecognized --enable/--with options + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-maintainer-mode enable make rules and dependencies not useful + (and sometimes confusing) to the casual installer + --enable-shared[=PKGS] build shared libraries [default=yes] + --enable-static[=PKGS] build static libraries [default=yes] + --enable-fast-install[=PKGS] + optimize for fast installation [default=yes] + --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors + --disable-libtool-lock avoid locking (might break parallel builds) + --disable-largefile omit support for large files + --enable-debug Enable debugging code and support for the -d option + --enable-dmalloc Enable linking to dmalloc for better memory + debugging + --enable-pedantic Enable gcc's -pedantic option + --enable-efence Enable Electric Fence memory debugger + --enable-gprof Enable GNU Profiler + --disable-64bits Do not use 64bit packet counters + --enable-force-bpf Force using BPF for sending packets + --enable-force-pf Force using Linux's PF_PACKET for sending packets + --enable-force-libdnet Force using libdnet for sending packets + --enable-force-inject Force using libpcap's pcap_inject() for sending + packets + --enable-force-sendpacket + Force using libpcap's pcap_sendpacket() for sending + packets + --enable-dynamic-link Dynamically link libraries + --enable-local-libopts Force using the supplied libopts tearoff code + --disable-libopts-install + Do not install libopts with client installation + --disable-optional-args not wanting optional option args + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-dmalloc use dmalloc, as in + http://www.dmalloc.com/dmalloc.tar.gz + --with-pic try to use only PIC/non-PIC objects [default=use + both] + --with-gnu-ld assume the C compiler uses GNU ld [default=no] + --with-libpcap=DIR Use libpcap in DIR + --with-libdnet=DIR Use libdnet in DIR + --with-pcapnav-config=FILE + Use given pcapnav-config + --with-tcpdump=FILE Path to tcpdump binary + --with-testnic=NIC Select which network card to use for testing + --with-testnic2=NIC2 Select an optional 2nd network card to use for + testing + --with-autoopts-config specify the config-info script + --with-regex-header a reg expr header is specified + --with-libregex libregex installation prefix + --with-libregex-cflags libregex compile flags + --with-libregex-libs libregex link command arguments + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CPP C preprocessor + CXX C++ compiler command + CXXFLAGS C++ compiler flags + CXXCPP C++ preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to the package provider. +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +configure +generated by GNU Autoconf 2.69 + +Copyright (C) 2012 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_compile + +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + +# ac_fn_c_check_func LINENO FUNC VAR +# ---------------------------------- +# Tests whether FUNC exists, setting the cache variable VAR accordingly +ac_fn_c_check_func () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Define $2 to an innocuous variant, in case declares $2. + For example, HP-UX 11i declares gettimeofday. */ +#define $2 innocuous_$2 + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $2 (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $2 + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $2 (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$2 || defined __stub___$2 +choke me +#endif + +int +main () +{ +return $2 (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_func + +# ac_fn_cxx_try_compile LINENO +# ---------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_cxx_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_compile + +# ac_fn_cxx_try_cpp LINENO +# ------------------------ +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_cxx_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_cpp + +# ac_fn_cxx_try_link LINENO +# ------------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_cxx_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_link + +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_c_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if eval \${$3+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.i conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_mongrel + +# ac_fn_c_check_type LINENO TYPE VAR INCLUDES +# ------------------------------------------- +# Tests whether TYPE exists after having included INCLUDES, setting cache +# variable VAR accordingly. +ac_fn_c_check_type () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof ($2)) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof (($2))) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + eval "$3=yes" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_type + +# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES +# ---------------------------------------------------- +# Tries to find if the field MEMBER exists in type AGGR, after including +# INCLUDES, setting cache variable VAR accordingly. +ac_fn_c_check_member () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 +$as_echo_n "checking for $2.$3... " >&6; } +if eval \${$4+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$5 +int +main () +{ +static $2 ac_aggr; +if (ac_aggr.$3) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$4=yes" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$5 +int +main () +{ +static $2 ac_aggr; +if (sizeof ac_aggr.$3) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$4=yes" +else + eval "$4=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$4 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_member + +# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES +# -------------------------------------------- +# Tries to find the compile-time value of EXPR in a program that includes +# INCLUDES, setting VAR accordingly. Returns whether the value could be +# computed +ac_fn_c_compute_int () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= 0)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_lo=0 ac_mid=0 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=$ac_mid; break +else + as_fn_arith $ac_mid + 1 && ac_lo=$as_val + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) < 0)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=-1 ac_mid=-1 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_lo=$ac_mid; break +else + as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + ac_lo= ac_hi= +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=$ac_mid +else + as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in #(( +?*) eval "$3=\$ac_lo"; ac_retval=0 ;; +'') ac_retval=1 ;; +esac + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +static long int longval () { return $2; } +static unsigned long int ulongval () { return $2; } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (($2) < 0) + { + long int i = longval (); + if (i != ($2)) + return 1; + fprintf (f, "%ld", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ($2)) + return 1; + fprintf (f, "%lu", i); + } + /* Do not output a trailing newline, as this causes \r\n confusion + on some platforms. */ + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + echo >>conftest.val; read $3 config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by $as_me, which was +generated by GNU Autoconf 2.69. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" + done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; + 2) + as_fn_append ac_configure_args1 " '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + as_fn_append ac_configure_args " '$ac_arg'" + ;; + esac + done +done +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + $as_echo "## ---------------- ## +## Cache variables. ## +## ---------------- ##" + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + $as_echo "## ----------------- ## +## Output variables. ## +## ----------------- ##" + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + $as_echo "## ------------------- ## +## File substitutions. ## +## ------------------- ##" + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + $as_echo "## ----------- ## +## confdefs.h. ## +## ----------- ##" + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +$as_echo "/* confdefs.h */" > confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site +fi +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) as_fn_append ac_configure_args " '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 +fi +## -------------------- ## +## Main body of script. ## +## -------------------- ## + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +ac_config_headers="$ac_config_headers src/config.h" + +ac_aux_dir= +for ac_dir in config "$srcdir"/config; do + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + as_fn_error $? "cannot find install-sh, install.sh, or shtool in config \"$srcdir\"/config" "$LINENO" 5 +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5 +$as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; } + # Check whether --enable-maintainer-mode was given. +if test "${enable_maintainer_mode+set}" = set; then : + enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval +else + USE_MAINTAINER_MODE=no +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5 +$as_echo "$USE_MAINTAINER_MODE" >&6; } + if test $USE_MAINTAINER_MODE = yes; then + MAINTAINER_MODE_TRUE= + MAINTAINER_MODE_FALSE='#' +else + MAINTAINER_MODE_TRUE='#' + MAINTAINER_MODE_FALSE= +fi + + MAINT=$MAINTAINER_MODE_TRUE + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if malloc debugging is wanted" >&5 +$as_echo_n "checking if malloc debugging is wanted... " >&6; } + +# Check whether --with-dmalloc was given. +if test "${with_dmalloc+set}" = set; then : + withval=$with_dmalloc; if test "$withval" = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +$as_echo "#define WITH_DMALLOC 1" >>confdefs.h + + LIBS="$LIBS -ldmalloc" + LDFLAGS="$LDFLAGS -g" +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + +MAINTAINER_AUTOGEN_VERSION=5.9.7 + + + +MAJOR_VERSION=3 +MINOR_VERSION=4 +MICRO_VERSION=4 +TCPREPLAY_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION +PACKAGE_URL=http://tcpreplay.synfin.net/ + +TCPREPLAY_RELEASE=1 + + +$as_echo "#define PACKAGE tcpreplay" >>confdefs.h + + +cat >>confdefs.h <<_ACEOF +#define VERSION "$TCPREPLAY_VERSION" +_ACEOF + + + + +USER_CFLAGS=$CFLAGS +#CFLAGS="${CFLAGS} -Wall -O3 -std=gnu99" +CFLAGS="${CFLAGS} -Wall -g -O3 -std=gnu99 -DTCPBURST=1" +#CFLAGS="${CFLAGS} -Wall -g -O3 -std=gnu99 -DTCPBURST=1 -DMARSIO=1" + +# Make sure we can run config.sub. +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 +$as_echo_n "checking build system type... " >&6; } +if ${ac_cv_build+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 +$as_echo "$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 +$as_echo_n "checking host system type... " >&6; } +if ${ac_cv_host+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 +$as_echo "$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; +esac +host=$ac_cv_host +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 +$as_echo_n "checking target system type... " >&6; } +if ${ac_cv_target+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "x$target_alias" = x; then + ac_cv_target=$ac_cv_host +else + ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5 +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5 +$as_echo "$ac_cv_target" >&6; } +case $ac_cv_target in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;; +esac +target=$ac_cv_target +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_target +shift +target_cpu=$1 +target_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +target_os=$* +IFS=$ac_save_IFS +case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac + + +# The aliases save the names the user supplied, while $host etc. +# will get canonicalized. +test -n "$target_alias" && + test "$program_prefix$program_suffix$program_transform_name" = \ + NONENONEs,x,x, && + program_prefix=${target_alias}- + + + + +have_cygwin=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cygwin development environment" >&5 +$as_echo_n "checking for cygwin development environment... " >&6; } +if test `echo $target | grep -c cygwin` -gt 0 ; then + +$as_echo "#define HAVE_WIN32 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + have_cygwin=yes +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +am__api_version='1.11' + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +# Reject install programs that cannot install multiple files. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 +$as_echo_n "checking for a BSD-compatible install... " >&6; } +if test -z "$INSTALL"; then +if ${ac_cv_path_install+:} false; then : + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in #(( + ./ | .// | /[cC]/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + rm -rf conftest.one conftest.two conftest.dir + echo one > conftest.one + echo two > conftest.two + mkdir conftest.dir + if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && + test -s conftest.one && test -s conftest.two && + test -s conftest.dir/conftest.one && + test -s conftest.dir/conftest.two + then + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + fi + done + done + ;; +esac + + done +IFS=$as_save_IFS + +rm -rf conftest.one conftest.two conftest.dir + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 +$as_echo "$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 +$as_echo_n "checking whether build environment is sane... " >&6; } +# Just in case +sleep 1 +echo timestamp > conftest.file +# Reject unsafe characters in $srcdir or the absolute working directory +# name. Accept space and tab only in the latter. +am_lf=' +' +case `pwd` in + *[\\\"\#\$\&\'\`$am_lf]*) + as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; +esac +case $srcdir in + *[\\\"\#\$\&\'\`$am_lf\ \ ]*) + as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; +esac + +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + rm -f conftest.file + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + as_fn_error $? "ls -t appears to fail. Make sure there is not a broken +alias in your environment" "$LINENO" 5 + fi + + test "$2" = conftest.file + ) +then + # Ok. + : +else + as_fn_error $? "newly created file is older than distributed files! +Check your system clock" "$LINENO" 5 +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +test "$program_prefix" != NONE && + program_transform_name="s&^&$program_prefix&;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s&\$&$program_suffix&;$program_transform_name" +# Double any \ or $. +# By default was `s,x,x', remove it if useless. +ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' +program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` + +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` + +if test x"${MISSING+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; + *) + MISSING="\${SHELL} $am_aux_dir/missing" ;; + esac +fi +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 +$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} +fi + +if test x"${install_sh}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; + *) + install_sh="\${SHELL} $am_aux_dir/install-sh" + esac +fi + +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +if test "$cross_compiling" != no; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_STRIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 +$as_echo "$STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_STRIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_STRIP="strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 +$as_echo "$ac_ct_STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 +$as_echo_n "checking for a thread-safe mkdir -p... " >&6; } +if test -z "$MKDIR_P"; then + if ${ac_cv_path_mkdir+:} false; then : + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in mkdir gmkdir; do + for ac_exec_ext in '' $ac_executable_extensions; do + as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue + case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( + 'mkdir (GNU coreutils) '* | \ + 'mkdir (coreutils) '* | \ + 'mkdir (fileutils) '4.1*) + ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext + break 3;; + esac + done + done + done +IFS=$as_save_IFS + +fi + + test -d ./--version && rmdir ./--version + if test "${ac_cv_path_mkdir+set}" = set; then + MKDIR_P="$ac_cv_path_mkdir -p" + else + # As a last resort, use the slow shell script. Don't cache a + # value for MKDIR_P within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + MKDIR_P="$ac_install_sh -d" + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 +$as_echo "$MKDIR_P" >&6; } + +mkdir_p="$MKDIR_P" +case $mkdir_p in + [\\/$]* | ?:[\\/]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AWK+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AWK="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 +$as_echo "$AWK" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$AWK" && break +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +set x ${MAKE-make} +ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + SET_MAKE= +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + +rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null + +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + am__isrc=' -I$(srcdir)' + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi + + +# Define the identity of the package. + PACKAGE=tcpreplay + VERSION=$TCPREPLAY_VERSION + + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} + + +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} + + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} + + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +# Always define AMTAR for backward compatibility. + +AMTAR=${AMTAR-"${am_missing_run}tar"} + +am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' + + + + + + + +case `pwd` in + *\ * | *\ *) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 +$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; +esac + + + +macro_version='2.2.6b' +macro_revision='1.3017' + + + + + + + + + + + + + +ltmain="$ac_aux_dir/ltmain.sh" + +DEPDIR="${am__leading_dot}deps" + +ac_config_commands="$ac_config_commands depfiles" + + +am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo this is the am__doit target +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 +$as_echo_n "checking for style of include used by $am_make... " >&6; } +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# Ignore all kinds of additional output from `make'. +case `$am_make -s -f confmf 2> /dev/null` in #( +*the\ am__doit\ target*) + am__include=include + am__quote= + _am_result=GNU + ;; +esac +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + case `$am_make -s -f confmf 2> /dev/null` in #( + *the\ am__doit\ target*) + am__include=.include + am__quote="\"" + _am_result=BSD + ;; + esac +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 +$as_echo "$_am_result" >&6; } +rm -f confinc confmf + +# Check whether --enable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then : + enableval=$enable_dependency_tracking; +fi + +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi + if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +ac_exeext=$ac_cv_exeext + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if ${ac_cv_objext+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if ${ac_cv_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +struct stat; +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +depcc="$CC" am_compiler_list= + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 +$as_echo_n "checking dependency style of $depcc... " >&6; } +if ${am_cv_CC_dependencies_compiler_type+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + am__universal=false + case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvisualcpp | msvcmsys) + # This compiler won't grok `-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 +$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' +else + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 +$as_echo_n "checking for a sed that does not truncate output... " >&6; } +if ${ac_cv_path_SED+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ + for ac_i in 1 2 3 4 5 6 7; do + ac_script="$ac_script$as_nl$ac_script" + done + echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed + { ac_script=; unset ac_script;} + if test -z "$SED"; then + ac_path_SED_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_SED" || continue +# Check for GNU ac_path_SED and select it if it is found. + # Check for GNU $ac_path_SED +case `"$ac_path_SED" --version 2>&1` in +*GNU*) + ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo '' >> "conftest.nl" + "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_SED_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_SED="$ac_path_SED" + ac_path_SED_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_SED_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_SED"; then + as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 + fi +else + ac_cv_path_SED=$SED +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 +$as_echo "$ac_cv_path_SED" >&6; } + SED="$ac_cv_path_SED" + rm -f conftest.sed + +test -z "$SED" && SED=sed +Xsed="$SED -e 1s/^X//" + + + + + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if ${ac_cv_path_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_GREP" || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_EGREP" || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 +$as_echo_n "checking for fgrep... " >&6; } +if ${ac_cv_path_FGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 + then ac_cv_path_FGREP="$GREP -F" + else + if test -z "$FGREP"; then + ac_path_FGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in fgrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_FGREP" || continue +# Check for GNU ac_path_FGREP and select it if it is found. + # Check for GNU $ac_path_FGREP +case `"$ac_path_FGREP" --version 2>&1` in +*GNU*) + ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'FGREP' >> "conftest.nl" + "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_FGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_FGREP="$ac_path_FGREP" + ac_path_FGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_FGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_FGREP"; then + as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_FGREP=$FGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 +$as_echo "$ac_cv_path_FGREP" >&6; } + FGREP="$ac_cv_path_FGREP" + + +test -z "$GREP" && GREP=grep + + + + + + + + + + + + + + + + + + + +# Check whether --with-gnu-ld was given. +if test "${with_gnu_ld+set}" = set; then : + withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes +else + with_gnu_ld=no +fi + +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 +$as_echo_n "checking for ld used by $CC... " >&6; } + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [\\/]* | ?:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` + while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do + ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 +$as_echo_n "checking for GNU ld... " >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 +$as_echo_n "checking for non-GNU ld... " >&6; } +fi +if ${lt_cv_path_LD+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$LD"; then + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &5 +$as_echo "$LD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } +if ${lt_cv_prog_gnu_ld+:} false; then : + $as_echo_n "(cached) " >&6 +else + # I'd rather use --version here, but apparently some GNU lds only accept -v. +case `$LD -v 2>&1 &5 +$as_echo "$lt_cv_prog_gnu_ld" >&6; } +with_gnu_ld=$lt_cv_prog_gnu_ld + + + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 +$as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } +if ${lt_cv_path_NM+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM="$NM" +else + lt_nm_to_check="${ac_tool_prefix}nm" + if test -n "$ac_tool_prefix" && test "$build" = "$host"; then + lt_nm_to_check="$lt_nm_to_check nm" + fi + for lt_tmp_nm in $lt_nm_to_check; do + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + tmp_nm="$ac_dir/$lt_tmp_nm" + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in + */dev/null* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + ;; + esac + fi + done + IFS="$lt_save_ifs" + done + : ${lt_cv_path_NM=no} +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 +$as_echo "$lt_cv_path_NM" >&6; } +if test "$lt_cv_path_NM" != "no"; then + NM="$lt_cv_path_NM" +else + # Didn't find any BSD compatible name lister, look for dumpbin. + if test -n "$ac_tool_prefix"; then + for ac_prog in "dumpbin -symbols" "link -dump -symbols" + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_DUMPBIN+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$DUMPBIN"; then + ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +DUMPBIN=$ac_cv_prog_DUMPBIN +if test -n "$DUMPBIN"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 +$as_echo "$DUMPBIN" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$DUMPBIN" && break + done +fi +if test -z "$DUMPBIN"; then + ac_ct_DUMPBIN=$DUMPBIN + for ac_prog in "dumpbin -symbols" "link -dump -symbols" +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_DUMPBIN"; then + ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN +if test -n "$ac_ct_DUMPBIN"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 +$as_echo "$ac_ct_DUMPBIN" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_DUMPBIN" && break +done + + if test "x$ac_ct_DUMPBIN" = x; then + DUMPBIN=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DUMPBIN=$ac_ct_DUMPBIN + fi +fi + + + if test "$DUMPBIN" != ":"; then + NM="$DUMPBIN" + fi +fi +test -z "$NM" && NM=nm + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 +$as_echo_n "checking the name lister ($NM) interface... " >&6; } +if ${lt_cv_nm_interface+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_nm_interface="BSD nm" + echo "int some_variable = 0;" > conftest.$ac_ext + (eval echo "\"\$as_me:5159: $ac_compile\"" >&5) + (eval "$ac_compile" 2>conftest.err) + cat conftest.err >&5 + (eval echo "\"\$as_me:5162: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) + cat conftest.err >&5 + (eval echo "\"\$as_me:5165: output\"" >&5) + cat conftest.out >&5 + if $GREP 'External.*some_variable' conftest.out > /dev/null; then + lt_cv_nm_interface="MS dumpbin" + fi + rm -f conftest* +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 +$as_echo "$lt_cv_nm_interface" >&6; } + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 +$as_echo_n "checking whether ln -s works... " >&6; } +LN_S=$as_ln_s +if test "$LN_S" = "ln -s"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 +$as_echo "no, using $LN_S" >&6; } +fi + +# find the maximum length of command line arguments +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 +$as_echo_n "checking the maximum length of command line arguments... " >&6; } +if ${lt_cv_sys_max_cmd_len+:} false; then : + $as_echo_n "(cached) " >&6 +else + i=0 + teststring="ABCD" + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw* | cegcc*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` + elif test -x /usr/sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` + else + lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs + fi + # And add a safety zone + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + ;; + + interix*) + # We know the value 262144 and hardcode it with a safety zone (like BSD) + lt_cv_sys_max_cmd_len=196608 + ;; + + osf*) + # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure + # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not + # nice to cause kernel panics so lets avoid the loop below. + # First set a reasonable default. + lt_cv_sys_max_cmd_len=16384 + # + if test -x /sbin/sysconfig; then + case `/sbin/sysconfig -q proc exec_disable_arg_limit` in + *1*) lt_cv_sys_max_cmd_len=-1 ;; + esac + fi + ;; + sco3.2v5*) + lt_cv_sys_max_cmd_len=102400 + ;; + sysv5* | sco5v6* | sysv4.2uw2*) + kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` + if test -n "$kargmax"; then + lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` + else + lt_cv_sys_max_cmd_len=32768 + fi + ;; + *) + lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` + if test -n "$lt_cv_sys_max_cmd_len"; then + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + else + # Make teststring a little bigger before we do anything with it. + # a 1K string should be a reasonable start. + for i in 1 2 3 4 5 6 7 8 ; do + teststring=$teststring$teststring + done + SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} + # If test is not a shell built-in, we'll probably end up computing a + # maximum length that is only half of the actual maximum length, but + # we can't tell. + while { test "X"`$SHELL $0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \ + = "XX$teststring$teststring"; } >/dev/null 2>&1 && + test $i != 17 # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + # Only check the string length outside the loop. + lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` + teststring= + # Add a significant safety factor because C++ compilers can tack on + # massive amounts of additional arguments before passing them to the + # linker. It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + fi + ;; + esac + +fi + +if test -n $lt_cv_sys_max_cmd_len ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 +$as_echo "$lt_cv_sys_max_cmd_len" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 +$as_echo "none" >&6; } +fi +max_cmd_len=$lt_cv_sys_max_cmd_len + + + + + + +: ${CP="cp -f"} +: ${MV="mv -f"} +: ${RM="rm -f"} + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5 +$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; } +# Try some XSI features +xsi_shell=no +( _lt_dummy="a/b/c" + test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ + = c,a/b,, \ + && eval 'test $(( 1 + 1 )) -eq 2 \ + && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ + && xsi_shell=yes +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5 +$as_echo "$xsi_shell" >&6; } + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5 +$as_echo_n "checking whether the shell understands \"+=\"... " >&6; } +lt_shell_append=no +( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ + >/dev/null 2>&1 \ + && lt_shell_append=yes +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5 +$as_echo "$lt_shell_append" >&6; } + + +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + lt_unset=unset +else + lt_unset=false +fi + + + + + +# test EBCDIC or ASCII +case `echo X|tr X '\101'` in + A) # ASCII based system + # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr + lt_SP2NL='tr \040 \012' + lt_NL2SP='tr \015\012 \040\040' + ;; + *) # EBCDIC based system + lt_SP2NL='tr \100 \n' + lt_NL2SP='tr \r\n \100\100' + ;; +esac + + + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 +$as_echo_n "checking for $LD option to reload object files... " >&6; } +if ${lt_cv_ld_reload_flag+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_ld_reload_flag='-r' +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 +$as_echo "$lt_cv_ld_reload_flag" >&6; } +reload_flag=$lt_cv_ld_reload_flag +case $reload_flag in +"" | " "*) ;; +*) reload_flag=" $reload_flag" ;; +esac +reload_cmds='$LD$reload_flag -o $output$reload_objs' +case $host_os in + darwin*) + if test "$GCC" = yes; then + reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' + else + reload_cmds='$LD$reload_flag -o $output$reload_objs' + fi + ;; +esac + + + + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. +set dummy ${ac_tool_prefix}objdump; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_OBJDUMP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$OBJDUMP"; then + ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +OBJDUMP=$ac_cv_prog_OBJDUMP +if test -n "$OBJDUMP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 +$as_echo "$OBJDUMP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OBJDUMP"; then + ac_ct_OBJDUMP=$OBJDUMP + # Extract the first word of "objdump", so it can be a program name with args. +set dummy objdump; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_OBJDUMP"; then + ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_OBJDUMP="objdump" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP +if test -n "$ac_ct_OBJDUMP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 +$as_echo "$ac_ct_OBJDUMP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_OBJDUMP" = x; then + OBJDUMP="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OBJDUMP=$ac_ct_OBJDUMP + fi +else + OBJDUMP="$ac_cv_prog_OBJDUMP" +fi + +test -z "$OBJDUMP" && OBJDUMP=objdump + + + + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 +$as_echo_n "checking how to recognize dependent libraries... " >&6; } +if ${lt_cv_deplibs_check_method+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_file_magic_cmd='$MAGIC_CMD' +lt_cv_file_magic_test_file= +lt_cv_deplibs_check_method='unknown' +# Need to set the preceding variable on all platforms that support +# interlibrary dependencies. +# 'none' -- dependencies not supported. +# `unknown' -- same as none, but documents that we really don't know. +# 'pass_all' -- all dependencies passed with no checks. +# 'test_compile' -- check by making test program. +# 'file_magic [[regex]]' -- check by looking for files in library path +# which responds to the $file_magic_cmd with a given extended regex. +# If you have `file' or equivalent on your system and you're not sure +# whether `pass_all' will *always* work, you probably want this one. + +case $host_os in +aix[4-9]*) + lt_cv_deplibs_check_method=pass_all + ;; + +beos*) + lt_cv_deplibs_check_method=pass_all + ;; + +bsdi[45]*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' + lt_cv_file_magic_cmd='/usr/bin/file -L' + lt_cv_file_magic_test_file=/shlib/libc.so + ;; + +cygwin*) + # func_win32_libid is a shell function defined in ltmain.sh + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + ;; + +mingw* | pw32*) + # Base MSYS/MinGW do not provide the 'file' command needed by + # func_win32_libid shell function, so use a weaker test based on 'objdump', + # unless we find 'file', for example because we are cross-compiling. + if ( file / ) >/dev/null 2>&1; then + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + else + lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + fi + ;; + +cegcc) + # use the weaker test based on 'objdump'. See mingw*. + lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + ;; + +darwin* | rhapsody*) + lt_cv_deplibs_check_method=pass_all + ;; + +freebsd* | dragonfly*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case $host_cpu in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]' + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; + *) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +interix[3-9]*) + # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be Linux ELF. +linux* | k*bsd*-gnu) + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +*nto* | *qnx*) + lt_cv_deplibs_check_method=pass_all + ;; + +openbsd*) + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +rdos*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.3*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + pc) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +tpf*) + lt_cv_deplibs_check_method=pass_all + ;; +esac + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 +$as_echo "$lt_cv_deplibs_check_method" >&6; } +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown + + + + + + + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. +set dummy ${ac_tool_prefix}ar; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AR+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AR="${ac_tool_prefix}ar" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AR=$ac_cv_prog_AR +if test -n "$AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 +$as_echo "$AR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_AR"; then + ac_ct_AR=$AR + # Extract the first word of "ar", so it can be a program name with args. +set dummy ar; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_AR+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_AR"; then + ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_AR="ar" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_AR=$ac_cv_prog_ac_ct_AR +if test -n "$ac_ct_AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 +$as_echo "$ac_ct_AR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_AR" = x; then + AR="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + AR=$ac_ct_AR + fi +else + AR="$ac_cv_prog_AR" +fi + +test -z "$AR" && AR=ar +test -z "$AR_FLAGS" && AR_FLAGS=cru + + + + + + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_STRIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 +$as_echo "$STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_STRIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_STRIP="strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 +$as_echo "$ac_ct_STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + +test -z "$STRIP" && STRIP=: + + + + + + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 +$as_echo "$RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 +$as_echo "$ac_ct_RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_RANLIB" = x; then + RANLIB=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + RANLIB=$ac_ct_RANLIB + fi +else + RANLIB="$ac_cv_prog_RANLIB" +fi + +test -z "$RANLIB" && RANLIB=: + + + + + + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + openbsd*) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" + ;; + *) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" +fi + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# Check for command to grab the raw symbol name followed by C symbol from nm. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 +$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } +if ${lt_cv_sys_global_symbol_pipe+:} false; then : + $as_echo_n "(cached) " >&6 +else + +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[BCDEGRST]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([_A-Za-z][_A-Za-z0-9]*\)' + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[BCDT]' + ;; +cygwin* | mingw* | pw32* | cegcc*) + symcode='[ABCDGISTW]' + ;; +hpux*) + if test "$host_cpu" = ia64; then + symcode='[ABCDEGRST]' + fi + ;; +irix* | nonstopux*) + symcode='[BCDEGRST]' + ;; +osf*) + symcode='[BCDEGQRST]' + ;; +solaris*) + symcode='[BDRT]' + ;; +sco3.2v5*) + symcode='[DT]' + ;; +sysv4.2uw2*) + symcode='[DT]' + ;; +sysv5* | sco5v6* | unixware* | OpenUNIX*) + symcode='[ABDT]' + ;; +sysv4) + symcode='[DFNSTU]' + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[ABCDGIRSTW]' ;; +esac + +# Transform an extracted symbol line into a proper C declaration. +# Some systems (esp. on ia64) link data and code symbols differently, +# so use this general approach. +lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# Try without a prefix underscore, then with it. +for ac_symprfx in "" "_"; do + + # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. + symxfrm="\\1 $ac_symprfx\\2 \\2" + + # Write the raw and C identifiers. + if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Fake it for dumpbin and say T for any non-static function + # and D for any global variable. + # Also find C++ and __fastcall symbols from MSVC++, + # which start with @ or ?. + lt_cv_sys_global_symbol_pipe="$AWK '"\ +" {last_section=section; section=\$ 3};"\ +" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ +" \$ 0!~/External *\|/{next};"\ +" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ +" {if(hide[section]) next};"\ +" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ +" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ +" s[1]~/^[@?]/{print s[1], s[1]; next};"\ +" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ +" ' prfx=^$ac_symprfx" + else + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + fi + + # Check to see that the pipe works correctly. + pipe_works=no + + rm -f conftest* + cat > conftest.$ac_ext <<_LT_EOF +#ifdef __cplusplus +extern "C" { +#endif +char nm_test_var; +void nm_test_func(void); +void nm_test_func(void){} +#ifdef __cplusplus +} +#endif +int main(){nm_test_var='a';nm_test_func();return(0);} +_LT_EOF + + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + # Now try to grab the symbols. + nlist=conftest.nm + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\""; } >&5 + (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if $GREP ' nm_test_var$' "$nlist" >/dev/null; then + if $GREP ' nm_test_func$' "$nlist" >/dev/null; then + cat <<_LT_EOF > conftest.$ac_ext +#ifdef __cplusplus +extern "C" { +#endif + +_LT_EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' + + cat <<_LT_EOF >> conftest.$ac_ext + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + void *address; +} +lt__PROGRAM__LTX_preloaded_symbols[] = +{ + { "@PROGRAM@", (void *) 0 }, +_LT_EOF + $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext + cat <<\_LT_EOF >> conftest.$ac_ext + {0, (void *) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt__PROGRAM__LTX_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif +_LT_EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_save_LIBS="$LIBS" + lt_save_CFLAGS="$CFLAGS" + LIBS="conftstm.$ac_objext" + CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 + (eval $ac_link) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s conftest${ac_exeext}; then + pipe_works=yes + fi + LIBS="$lt_save_LIBS" + CFLAGS="$lt_save_CFLAGS" + else + echo "cannot find nm_test_func in $nlist" >&5 + fi + else + echo "cannot find nm_test_var in $nlist" >&5 + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 + fi + else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + fi + rm -rf conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done + +fi + +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 +$as_echo "failed" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; } +fi + + + + + + + + + + + + + + + + + + + + + + + +# Check whether --enable-libtool-lock was given. +if test "${enable_libtool_lock+set}" = set; then : + enableval=$enable_libtool_lock; +fi + +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE="32" + ;; + *ELF-64*) + HPUX_IA64_MODE="64" + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out which ABI we are using. + echo '#line 6371 "configure"' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + if test "$lt_cv_prog_gnu_ld" = yes; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ +s390*-*linux*|s390*-*tpf*|sparc*-*linux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + case `/usr/bin/file conftest.o` in + *32-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_i386_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_i386" + ;; + ppc64-*linux*|powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_x86_64_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + ppc*-*linux*|powerpc*-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*|s390*-*tpf*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 +$as_echo_n "checking whether the C compiler needs -belf... " >&6; } +if ${lt_cv_cc_needs_belf+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + lt_cv_cc_needs_belf=yes +else + lt_cv_cc_needs_belf=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 +$as_echo "$lt_cv_cc_needs_belf" >&6; } + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; +sparc*-*solaris*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + case `/usr/bin/file conftest.o` in + *64-bit*) + case $lt_cv_prog_gnu_ld in + yes*) LD="${LD-ld} -m elf64_sparc" ;; + *) + if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then + LD="${LD-ld} -64" + fi + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; +esac + +need_locks="$enable_libtool_lock" + + + case $host_os in + rhapsody* | darwin*) + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. +set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_DSYMUTIL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$DSYMUTIL"; then + ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +DSYMUTIL=$ac_cv_prog_DSYMUTIL +if test -n "$DSYMUTIL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 +$as_echo "$DSYMUTIL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_DSYMUTIL"; then + ac_ct_DSYMUTIL=$DSYMUTIL + # Extract the first word of "dsymutil", so it can be a program name with args. +set dummy dsymutil; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_DSYMUTIL"; then + ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL +if test -n "$ac_ct_DSYMUTIL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 +$as_echo "$ac_ct_DSYMUTIL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_DSYMUTIL" = x; then + DSYMUTIL=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + DSYMUTIL=$ac_ct_DSYMUTIL + fi +else + DSYMUTIL="$ac_cv_prog_DSYMUTIL" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. +set dummy ${ac_tool_prefix}nmedit; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_NMEDIT+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$NMEDIT"; then + ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +NMEDIT=$ac_cv_prog_NMEDIT +if test -n "$NMEDIT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 +$as_echo "$NMEDIT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_NMEDIT"; then + ac_ct_NMEDIT=$NMEDIT + # Extract the first word of "nmedit", so it can be a program name with args. +set dummy nmedit; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_NMEDIT"; then + ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_NMEDIT="nmedit" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT +if test -n "$ac_ct_NMEDIT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 +$as_echo "$ac_ct_NMEDIT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_NMEDIT" = x; then + NMEDIT=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + NMEDIT=$ac_ct_NMEDIT + fi +else + NMEDIT="$ac_cv_prog_NMEDIT" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. +set dummy ${ac_tool_prefix}lipo; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_LIPO+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$LIPO"; then + ac_cv_prog_LIPO="$LIPO" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_LIPO="${ac_tool_prefix}lipo" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +LIPO=$ac_cv_prog_LIPO +if test -n "$LIPO"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 +$as_echo "$LIPO" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_LIPO"; then + ac_ct_LIPO=$LIPO + # Extract the first word of "lipo", so it can be a program name with args. +set dummy lipo; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_LIPO+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_LIPO"; then + ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_LIPO="lipo" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO +if test -n "$ac_ct_LIPO"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 +$as_echo "$ac_ct_LIPO" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_LIPO" = x; then + LIPO=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + LIPO=$ac_ct_LIPO + fi +else + LIPO="$ac_cv_prog_LIPO" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. +set dummy ${ac_tool_prefix}otool; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_OTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$OTOOL"; then + ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_OTOOL="${ac_tool_prefix}otool" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +OTOOL=$ac_cv_prog_OTOOL +if test -n "$OTOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 +$as_echo "$OTOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OTOOL"; then + ac_ct_OTOOL=$OTOOL + # Extract the first word of "otool", so it can be a program name with args. +set dummy otool; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_OTOOL+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_OTOOL"; then + ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_OTOOL="otool" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL +if test -n "$ac_ct_OTOOL"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 +$as_echo "$ac_ct_OTOOL" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_OTOOL" = x; then + OTOOL=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OTOOL=$ac_ct_OTOOL + fi +else + OTOOL="$ac_cv_prog_OTOOL" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. +set dummy ${ac_tool_prefix}otool64; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_OTOOL64+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$OTOOL64"; then + ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +OTOOL64=$ac_cv_prog_OTOOL64 +if test -n "$OTOOL64"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 +$as_echo "$OTOOL64" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OTOOL64"; then + ac_ct_OTOOL64=$OTOOL64 + # Extract the first word of "otool64", so it can be a program name with args. +set dummy otool64; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_OTOOL64"; then + ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_OTOOL64="otool64" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 +if test -n "$ac_ct_OTOOL64"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 +$as_echo "$ac_ct_OTOOL64" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_OTOOL64" = x; then + OTOOL64=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + OTOOL64=$ac_ct_OTOOL64 + fi +else + OTOOL64="$ac_cv_prog_OTOOL64" +fi + + + + + + + + + + + + + + + + + + + + + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 +$as_echo_n "checking for -single_module linker flag... " >&6; } +if ${lt_cv_apple_cc_single_mod+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_apple_cc_single_mod=no + if test -z "${LT_MULTI_MODULE}"; then + # By default we will add the -single_module flag. You can override + # by either setting the environment variable LT_MULTI_MODULE + # non-empty at configure time, or by adding -multi_module to the + # link flags. + rm -rf libconftest.dylib* + echo "int foo(void){return 1;}" > conftest.c + echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ +-dynamiclib -Wl,-single_module conftest.c" >&5 + $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ + -dynamiclib -Wl,-single_module conftest.c 2>conftest.err + _lt_result=$? + if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then + lt_cv_apple_cc_single_mod=yes + else + cat conftest.err >&5 + fi + rm -rf libconftest.dylib* + rm -f conftest.* + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 +$as_echo "$lt_cv_apple_cc_single_mod" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 +$as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } +if ${lt_cv_ld_exported_symbols_list+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_ld_exported_symbols_list=no + save_LDFLAGS=$LDFLAGS + echo "_main" > conftest.sym + LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + lt_cv_ld_exported_symbols_list=yes +else + lt_cv_ld_exported_symbols_list=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS="$save_LDFLAGS" + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 +$as_echo "$lt_cv_ld_exported_symbols_list" >&6; } + case $host_os in + rhapsody* | darwin1.[012]) + _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; + darwin1.*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + darwin*) # darwin 5.x on + # if running on 10.5 or later, the deployment target defaults + # to the OS version, if on x86, and 10.4, the deployment + # target defaults to 10.4. Don't you love it? + case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in + 10.0,*86*-darwin8*|10.0,*-darwin[91]*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + 10.[012]*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + 10.*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + esac + ;; + esac + if test "$lt_cv_apple_cc_single_mod" = "yes"; then + _lt_dar_single_mod='$single_module' + fi + if test "$lt_cv_ld_exported_symbols_list" = "yes"; then + _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' + else + _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' + fi + if test "$DSYMUTIL" != ":"; then + _lt_dsymutil='~$DSYMUTIL $lib || :' + else + _lt_dsymutil= + fi + ;; + esac + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +for ac_header in dlfcn.h +do : + ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default +" +if test "x$ac_cv_header_dlfcn_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_DLFCN_H 1 +_ACEOF + +fi + +done + + + +# Set options + + + + enable_dlopen=no + + + enable_win32_dll=no + + + # Check whether --enable-shared was given. +if test "${enable_shared+set}" = set; then : + enableval=$enable_shared; p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + enable_shared=yes +fi + + + + + + + + + + # Check whether --enable-static was given. +if test "${enable_static+set}" = set; then : + enableval=$enable_static; p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + enable_static=yes +fi + + + + + + + + + + +# Check whether --with-pic was given. +if test "${with_pic+set}" = set; then : + withval=$with_pic; pic_mode="$withval" +else + pic_mode=default +fi + + +test -z "$pic_mode" && pic_mode=default + + + + + + + + # Check whether --enable-fast-install was given. +if test "${enable_fast_install+set}" = set; then : + enableval=$enable_fast_install; p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + enable_fast_install=yes +fi + + + + + + + + + + + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ltmain" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' + + + + + + + + + + + + + + + + + + + + + + + + + +test -z "$LN_S" && LN_S="ln -s" + + + + + + + + + + + + + + +if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 +$as_echo_n "checking for objdir... " >&6; } +if ${lt_cv_objdir+:} false; then : + $as_echo_n "(cached) " >&6 +else + rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 +$as_echo "$lt_cv_objdir" >&6; } +objdir=$lt_cv_objdir + + + + + +cat >>confdefs.h <<_ACEOF +#define LT_OBJDIR "$lt_cv_objdir/" +_ACEOF + + + + + + + + + + + + + + + + + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='s/\(["`$\\]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\(["`\\]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to delay expansion of an escaped single quote. +delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' + +# Global variables: +ofile=libtool +can_build_shared=yes + +# All known linkers require a `.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a + +with_gnu_ld="$lt_cv_prog_gnu_ld" + +old_CC="$CC" +old_CFLAGS="$CFLAGS" + +# Set sane defaults for various variables +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS +test -z "$LD" && LD=ld +test -z "$ac_objext" && ac_objext=o + +for cc_temp in $compiler""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` + + +# Only perform the check for file, if the check method requires it +test -z "$MAGIC_CMD" && MAGIC_CMD=file +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 +$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } +if ${lt_cv_path_MAGIC_CMD+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $MAGIC_CMD in +[\\/*] | ?:[\\/]*) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/${ac_tool_prefix}file; then + lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<_LT_EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +_LT_EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac +fi + +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 +$as_echo "$MAGIC_CMD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + + +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 +$as_echo_n "checking for file... " >&6; } +if ${lt_cv_path_MAGIC_CMD+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $MAGIC_CMD in +[\\/*] | ?:[\\/]*) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/file; then + lt_cv_path_MAGIC_CMD="$ac_dir/file" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<_LT_EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +_LT_EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac +fi + +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 +$as_echo "$MAGIC_CMD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + else + MAGIC_CMD=: + fi +fi + + fi + ;; +esac + +# Use C for the default configuration in the libtool script + +lt_save_CC="$CC" +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +objext=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}' + + + + + + + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + +# Save the default compiler, since it gets overwritten when the other +# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. +compiler_DEFAULT=$CC + +# save warnings/boilerplate of simple test code +ac_outfile=conftest.$ac_objext +echo "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$RM conftest* + +ac_outfile=conftest.$ac_objext +echo "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$RM -r conftest* + + +if test -n "$compiler"; then + +lt_prog_compiler_no_builtin_flag= + +if test "$GCC" = yes; then + lt_prog_compiler_no_builtin_flag=' -fno-builtin' + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 +$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } +if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_rtti_exceptions=no + ac_outfile=conftest.$ac_objext + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="-fno-rtti -fno-exceptions" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:7896: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:7900: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_rtti_exceptions=yes + fi + fi + $RM conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 +$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } + +if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then + lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" +else + : +fi + +fi + + + + + + + lt_prog_compiler_wl= +lt_prog_compiler_pic= +lt_prog_compiler_static= + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 +$as_echo_n "checking for $compiler option to produce PIC... " >&6; } + + if test "$GCC" = yes; then + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_static='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + lt_prog_compiler_pic='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + lt_prog_compiler_pic='-DDLL_EXPORT' + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic='-fno-common' + ;; + + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='-fPIC' + ;; + esac + ;; + + interix[3-9]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + lt_prog_compiler_can_build_shared=no + enable_shared=no + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + lt_prog_compiler_pic='-fPIC -shared' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic=-Kconform_pic + fi + ;; + + *) + lt_prog_compiler_pic='-fPIC' + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + lt_prog_compiler_wl='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + else + lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic='-DDLL_EXPORT' + ;; + + hpux9* | hpux10* | hpux11*) + lt_prog_compiler_wl='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + lt_prog_compiler_static='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + lt_prog_compiler_wl='-Wl,' + # PIC (with -KPIC) is the default. + lt_prog_compiler_static='-non_shared' + ;; + + linux* | k*bsd*-gnu) + case $cc_basename in + # old Intel for x86_64 which still supported -KPIC. + ecc*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-static' + ;; + # icc used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + icc* | ifort*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fPIC' + lt_prog_compiler_static='-static' + ;; + # Lahey Fortran 8.1. + lf95*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='--shared' + lt_prog_compiler_static='--static' + ;; + pgcc* | pgf77* | pgf90* | pgf95*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-fpic' + lt_prog_compiler_static='-Bstatic' + ;; + ccc*) + lt_prog_compiler_wl='-Wl,' + # All Alpha code is PIC. + lt_prog_compiler_static='-non_shared' + ;; + xl*) + # IBM XL C 8.0/Fortran 10.1 on PPC + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-qpic' + lt_prog_compiler_static='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C 5.9 + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='-Wl,' + ;; + *Sun\ F*) + # Sun Fortran 8.3 passes all unrecognized flags to the linker + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + lt_prog_compiler_wl='' + ;; + esac + ;; + esac + ;; + + newsos6) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + lt_prog_compiler_pic='-fPIC -shared' + ;; + + osf3* | osf4* | osf5*) + lt_prog_compiler_wl='-Wl,' + # All OSF/1 code is PIC. + lt_prog_compiler_static='-non_shared' + ;; + + rdos*) + lt_prog_compiler_static='-non_shared' + ;; + + solaris*) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + case $cc_basename in + f77* | f90* | f95*) + lt_prog_compiler_wl='-Qoption ld ';; + *) + lt_prog_compiler_wl='-Wl,';; + esac + ;; + + sunos4*) + lt_prog_compiler_wl='-Qoption ld ' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + lt_prog_compiler_pic='-Kconform_pic' + lt_prog_compiler_static='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + unicos*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_can_build_shared=no + ;; + + uts4*) + lt_prog_compiler_pic='-pic' + lt_prog_compiler_static='-Bstatic' + ;; + + *) + lt_prog_compiler_can_build_shared=no + ;; + esac + fi + +case $host_os in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic= + ;; + *) + lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" + ;; +esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic" >&5 +$as_echo "$lt_prog_compiler_pic" >&6; } + + + + + + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$lt_prog_compiler_pic"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 +$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } +if ${lt_cv_prog_compiler_pic_works+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_pic_works=no + ac_outfile=conftest.$ac_objext + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic -DPIC" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:8235: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:8239: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_pic_works=yes + fi + fi + $RM conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 +$as_echo "$lt_cv_prog_compiler_pic_works" >&6; } + +if test x"$lt_cv_prog_compiler_pic_works" = xyes; then + case $lt_prog_compiler_pic in + "" | " "*) ;; + *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; + esac +else + lt_prog_compiler_pic= + lt_prog_compiler_can_build_shared=no +fi + +fi + + + + + + +# +# Check to make sure the static flag actually works. +# +wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 +$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } +if ${lt_cv_prog_compiler_static_works+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_static_works=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $lt_tmp_static_flag" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_static_works=yes + fi + else + lt_cv_prog_compiler_static_works=yes + fi + fi + $RM -r conftest* + LDFLAGS="$save_LDFLAGS" + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 +$as_echo "$lt_cv_prog_compiler_static_works" >&6; } + +if test x"$lt_cv_prog_compiler_static_works" = xyes; then + : +else + lt_prog_compiler_static= +fi + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 +$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if ${lt_cv_prog_compiler_c_o+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_c_o=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:8340: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:8344: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o=yes + fi + fi + chmod u+w . 2>&5 + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 +$as_echo "$lt_cv_prog_compiler_c_o" >&6; } + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 +$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if ${lt_cv_prog_compiler_c_o+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_c_o=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:8395: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:8399: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o=yes + fi + fi + chmod u+w . 2>&5 + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 +$as_echo "$lt_cv_prog_compiler_c_o" >&6; } + + + + +hard_links="nottested" +if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 +$as_echo_n "checking if we can lock with hard links... " >&6; } + hard_links=yes + $RM conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 +$as_echo "$hard_links" >&6; } + if test "$hard_links" = no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 +$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} + need_locks=warn + fi +else + need_locks=no +fi + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } + + runpath_var= + allow_undefined_flag= + always_export_symbols=no + archive_cmds= + archive_expsym_cmds= + compiler_needs_object=no + enable_shared_with_static_runtimes=no + export_dynamic_flag_spec= + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + hardcode_automatic=no + hardcode_direct=no + hardcode_direct_absolute=no + hardcode_libdir_flag_spec= + hardcode_libdir_flag_spec_ld= + hardcode_libdir_separator= + hardcode_minus_L=no + hardcode_shlibpath_var=unsupported + inherit_rpath=no + link_all_deplibs=unknown + module_cmds= + module_expsym_cmds= + old_archive_from_new_cmds= + old_archive_from_expsyms_cmds= + thread_safe_flag_spec= + whole_archive_flag_spec= + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + include_expsyms= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + # Exclude shared library initialization/finalization symbols. + extract_expsyms_cmds= + + case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; + esac + + ld_shlibs=yes + if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + export_dynamic_flag_spec='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec= + fi + supports_anon_versioning=no + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + + # See if GNU ld supports shared libraries. + case $host_os in + aix[3-9]*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs=no + cat <<_LT_EOF 1>&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +_LT_EOF + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='' + ;; + m68k) + archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + esac + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs=no + fi + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + allow_undefined_flag=unsupported + always_export_symbols=no + enable_shared_with_static_runtimes=yes + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + ld_shlibs=no + fi + ;; + + interix[3-9]*) + hardcode_direct=no + hardcode_shlibpath_var=no + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + export_dynamic_flag_spec='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + gnu* | linux* | tpf* | k*bsd*-gnu) + tmp_diet=no + if test "$host_os" = linux-dietlibc; then + case $cc_basename in + diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) + esac + fi + if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ + && test "$tmp_diet" = no + then + tmp_addflag= + tmp_sharedflag='-shared' + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers + whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + lf95*) # Lahey Fortran 8.1 + whole_archive_flag_spec= + tmp_sharedflag='--shared' ;; + xl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) + tmp_sharedflag='-qmkshrobj' + tmp_addflag= ;; + esac + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) # Sun C 5.9 + whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + compiler_needs_object=yes + tmp_sharedflag='-G' ;; + *Sun\ F*) # Sun Fortran 8.3 + tmp_sharedflag='-G' ;; + esac + archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + + if test "x$supports_anon_versioning" = xyes; then + archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + fi + + case $cc_basename in + xlf*) + # IBM XL Fortran 10.1 on PPC cannot create shared libs itself + whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' + hardcode_libdir_flag_spec= + hardcode_libdir_flag_spec_ld='-rpath $libdir' + archive_cmds='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib' + if test "x$supports_anon_versioning" = xyes; then + archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' + fi + ;; + esac + else + ld_shlibs=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris*) + if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + cat <<_LT_EOF 1>&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) + ld_shlibs=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + ;; + *) + # For security reasons, it is highly recommended that you always + # use absolute paths for naming shared libraries, and exclude the + # DT_RUNPATH tag from executables and libraries. But doing so + # requires that you compile everything twice, which is a pain. + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + ;; + + sunos4*) + archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + *) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + + if test "$ld_shlibs" = no; then + runpath_var= + hardcode_libdir_flag_spec= + export_dynamic_flag_spec= + whole_archive_flag_spec= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + allow_undefined_flag=unsupported + always_export_symbols=yes + archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + + aix[4-9]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds='' + hardcode_direct=yes + hardcode_direct_absolute=yes + hardcode_libdir_separator=':' + link_all_deplibs=yes + file_list_spec='${wl}-f,' + + if test "$GCC" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + hardcode_direct=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + ;; + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + export_dynamic_flag_spec='${wl}-bexpall' + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + always_export_symbols=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag='-berok' + # Determine the default libpath from the value encoded in an + # empty executable. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + +lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\(.*\)$/\1/ + p + } + }' +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +fi +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' + allow_undefined_flag="-z nodefs" + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + +lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\(.*\)$/\1/ + p + } + }' +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +fi +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag=' ${wl}-bernotok' + allow_undefined_flag=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec='$convenience' + archive_cmds_need_lc=yes + # This is similar to how AIX traditionally builds its shared libraries. + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='' + ;; + m68k) + archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + esac + ;; + + bsdi[45]*) + export_dynamic_flag_spec=-rdynamic + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_from_new_cmds='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' + fix_srcfile_path='`cygpath -w "$srcfile"`' + enable_shared_with_static_runtimes=yes + ;; + + darwin* | rhapsody*) + + + archive_cmds_need_lc=no + hardcode_direct=no + hardcode_automatic=yes + hardcode_shlibpath_var=unsupported + whole_archive_flag_spec='' + link_all_deplibs=yes + allow_undefined_flag="$_lt_dar_allow_undefined" + case $cc_basename in + ifort*) _lt_dar_can_shared=yes ;; + *) _lt_dar_can_shared=$GCC ;; + esac + if test "$_lt_dar_can_shared" = "yes"; then + output_verbose_link_cmd=echo + archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" + module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" + archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" + module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" + + else + ld_shlibs=no + fi + + ;; + + dgux*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + freebsd1*) + ld_shlibs=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | dragonfly*) + archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + hpux9*) + if test "$GCC" = yes; then + archive_cmds='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + export_dynamic_flag_spec='${wl}-E' + ;; + + hpux10*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_flag_spec_ld='+b $libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + hardcode_direct_absolute=yes + export_dynamic_flag_spec='${wl}-E' + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + fi + ;; + + hpux11*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + case $host_cpu in + hppa*64*) + archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + fi + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + + case $host_cpu in + hppa*64*|ia64*) + hardcode_direct=no + hardcode_shlibpath_var=no + ;; + *) + hardcode_direct=yes + hardcode_direct_absolute=yes + export_dynamic_flag_spec='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + # Try to use the -exported_symbol ld option, if it does not + # work, assume that -exports_file does not work either and + # implicitly export all symbols. + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int foo(void) {} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS="$save_LDFLAGS" + else + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' + fi + archive_cmds_need_lc='no' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + inherit_rpath=yes + link_all_deplibs=yes + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + newsos6) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_shlibpath_var=no + ;; + + *nto* | *qnx*) + ;; + + openbsd*) + if test -f /usr/libexec/ld.so; then + hardcode_direct=yes + hardcode_shlibpath_var=no + hardcode_direct_absolute=yes + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + export_dynamic_flag_spec='${wl}-E' + else + case $host_os in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + esac + fi + else + ld_shlibs=no + fi + ;; + + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + fi + archive_cmds_need_lc='no' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ + $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' + + # Both c and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + archive_cmds_need_lc='no' + hardcode_libdir_separator=: + ;; + + solaris*) + no_undefined_flag=' -z defs' + if test "$GCC" = yes; then + wlarc='${wl}' + archive_cmds='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + else + case `$CC -V 2>&1` in + *"Compilers 5.0"*) + wlarc='' + archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' + ;; + *) + wlarc='${wl}' + archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + ;; + esac + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_shlibpath_var=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands `-z linker_flag'. GCC discards it without `$wl', + # but is careful enough not to reorder. + # Supported since Solaris 2.6 (maybe 2.5.1?) + if test "$GCC" = yes; then + whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + else + whole_archive_flag_spec='-z allextract$convenience -z defaultextract' + fi + ;; + esac + link_all_deplibs=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + sysv4) + case $host_vendor in + sni) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' + reload_cmds='$CC -r -o $output$reload_objs' + hardcode_direct=no + ;; + motorola) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + ;; + + sysv4.3*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + export_dynamic_flag_spec='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) + no_undefined_flag='${wl}-z,text' + archive_cmds_need_lc=no + hardcode_shlibpath_var=no + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + no_undefined_flag='${wl}-z,text' + allow_undefined_flag='${wl}-z,nodefs' + archive_cmds_need_lc=no + hardcode_shlibpath_var=no + hardcode_libdir_flag_spec='${wl}-R,$libdir' + hardcode_libdir_separator=':' + link_all_deplibs=yes + export_dynamic_flag_spec='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + *) + ld_shlibs=no + ;; + esac + + if test x$host_vendor = xsni; then + case $host in + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + export_dynamic_flag_spec='${wl}-Blargedynsym' + ;; + esac + fi + fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 +$as_echo "$ld_shlibs" >&6; } +test "$ld_shlibs" = no && can_build_shared=no + +with_gnu_ld=$with_gnu_ld + + + + + + + + + + + + + + + +# +# Do we need to explicitly link libc? +# +case "x$archive_cmds_need_lc" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $archive_cmds in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 +$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } + $RM conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl + pic_flag=$lt_prog_compiler_pic + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag + allow_undefined_flag= + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 + (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + then + archive_cmds_need_lc=no + else + archive_cmds_need_lc=yes + fi + allow_undefined_flag=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $RM conftest* + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $archive_cmds_need_lc" >&5 +$as_echo "$archive_cmds_need_lc" >&6; } + ;; + esac + fi + ;; +esac + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 +$as_echo_n "checking dynamic linker characteristics... " >&6; } + +if test "$GCC" = yes; then + case $host_os in + darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; + *) lt_awk_arg="/^libraries:/" ;; + esac + lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'` + else + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + # Ok, now we have the path, separated by spaces, we can step through it + # and add multilib dir if necessary. + lt_tmp_lt_search_path_spec= + lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + for lt_sys_path in $lt_search_path_spec; do + if test -d "$lt_sys_path/$lt_multi_os_dir"; then + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" + else + test -d "$lt_sys_path" && \ + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" + fi + done + lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk ' +BEGIN {RS=" "; FS="/|\n";} { + lt_foo=""; + lt_count=0; + for (lt_i = NF; lt_i > 0; lt_i--) { + if ($lt_i != "" && $lt_i != ".") { + if ($lt_i == "..") { + lt_count++; + } else { + if (lt_count == 0) { + lt_foo="/" $lt_i lt_foo; + } else { + lt_count--; + } + } + } + } + if (lt_foo != "") { lt_freq[lt_foo]++; } + if (lt_freq[lt_foo] == 1) { print lt_foo; } +}'` + sys_lib_search_path_spec=`$ECHO $lt_search_path_spec` +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix[4-9]*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + case $host_cpu in + powerpc) + # Since July 2007 AmigaOS4 officially supports .so libraries. + # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + ;; + m68k) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + esac + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[45]*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32* | cegcc*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw* | cegcc*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' + + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[123]*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ + freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + *) # from 4.6 on, and DragonFly + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +interix[3-9]*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux* | k*bsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # Some binutils ld are patched to set DT_RUNPATH + save_LDFLAGS=$LDFLAGS + save_libdir=$libdir + eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ + LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : + shlibpath_overrides_runpath=yes +fi +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$save_LDFLAGS + libdir=$save_libdir + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +*nto* | *qnx*) + version_type=qnx + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='ldqnx.so' + ;; + +openbsd*) + version_type=sunos + sys_lib_dlsearch_path_spec="/usr/lib" + need_lib_prefix=no + # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. + case $host_os in + openbsd3.3 | openbsd3.3.*) need_version=yes ;; + *) need_version=no ;; + esac + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[89] | openbsd2.[89].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +rdos*) + dynamic_linker=no + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=freebsd-elf + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + if test "$with_gnu_ld" = yes; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +tpf*) + # TPF is a cross-target only. Preferred cross-host = GNU/Linux. + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 +$as_echo "$dynamic_linker" >&6; } +test "$dynamic_linker" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then + sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" +fi +if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then + sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" +fi + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 +$as_echo_n "checking how to hardcode library paths into programs... " >&6; } +hardcode_action= +if test -n "$hardcode_libdir_flag_spec" || + test -n "$runpath_var" || + test "X$hardcode_automatic" = "Xyes" ; then + + # We can hardcode non-existent directories. + if test "$hardcode_direct" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no && + test "$hardcode_minus_L" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action=unsupported +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 +$as_echo "$hardcode_action" >&6; } + +if test "$hardcode_action" = relink || + test "$inherit_rpath" = yes; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + + + + + + + if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32* | cegcc*) + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen="dlopen" + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 +$as_echo_n "checking for dlopen in -ldl... " >&6; } +if ${ac_cv_lib_dl_dlopen+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_dl_dlopen=yes +else + ac_cv_lib_dl_dlopen=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 +$as_echo "$ac_cv_lib_dl_dlopen" >&6; } +if test "x$ac_cv_lib_dl_dlopen" = xyes; then : + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + + lt_cv_dlopen="dyld" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + +fi + + ;; + + *) + ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" +if test "x$ac_cv_func_shl_load" = xyes; then : + lt_cv_dlopen="shl_load" +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 +$as_echo_n "checking for shl_load in -ldld... " >&6; } +if ${ac_cv_lib_dld_shl_load+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char shl_load (); +int +main () +{ +return shl_load (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_dld_shl_load=yes +else + ac_cv_lib_dld_shl_load=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 +$as_echo "$ac_cv_lib_dld_shl_load" >&6; } +if test "x$ac_cv_lib_dld_shl_load" = xyes; then : + lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" +else + ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" +if test "x$ac_cv_func_dlopen" = xyes; then : + lt_cv_dlopen="dlopen" +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 +$as_echo_n "checking for dlopen in -ldl... " >&6; } +if ${ac_cv_lib_dl_dlopen+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_dl_dlopen=yes +else + ac_cv_lib_dl_dlopen=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 +$as_echo "$ac_cv_lib_dl_dlopen" >&6; } +if test "x$ac_cv_lib_dl_dlopen" = xyes; then : + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 +$as_echo_n "checking for dlopen in -lsvld... " >&6; } +if ${ac_cv_lib_svld_dlopen+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsvld $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_svld_dlopen=yes +else + ac_cv_lib_svld_dlopen=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 +$as_echo "$ac_cv_lib_svld_dlopen" >&6; } +if test "x$ac_cv_lib_svld_dlopen" = xyes; then : + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 +$as_echo_n "checking for dld_link in -ldld... " >&6; } +if ${ac_cv_lib_dld_dld_link+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dld_link (); +int +main () +{ +return dld_link (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_dld_dld_link=yes +else + ac_cv_lib_dld_dld_link=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 +$as_echo "$ac_cv_lib_dld_dld_link" >&6; } +if test "x$ac_cv_lib_dld_dld_link" = xyes; then : + lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" +fi + + +fi + + +fi + + +fi + + +fi + + +fi + + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS="$LDFLAGS" + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS="$LIBS" + LIBS="$lt_cv_dlopen_libs $LIBS" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 +$as_echo_n "checking whether a program can dlopen itself... " >&6; } +if ${lt_cv_dlopen_self+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + lt_cv_dlopen_self=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +#line 10762 "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + else + puts (dlerror ()); + + return status; +} +_LT_EOF + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 + (eval $ac_link) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) >&5 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; + x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self=no + fi +fi +rm -fr conftest* + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 +$as_echo "$lt_cv_dlopen_self" >&6; } + + if test "x$lt_cv_dlopen_self" = xyes; then + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 +$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } +if ${lt_cv_dlopen_self_static+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + lt_cv_dlopen_self_static=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +#line 10858 "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + else + puts (dlerror ()); + + return status; +} +_LT_EOF + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 + (eval $ac_link) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) >&5 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self_static=no + fi +fi +rm -fr conftest* + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 +$as_echo "$lt_cv_dlopen_self_static" >&6; } + fi + + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi + + + + + + + + + + + + + + + + + +striplib= +old_striplib= +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 +$as_echo_n "checking whether stripping libraries is possible... " >&6; } +if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP" ; then + striplib="$STRIP -x" + old_striplib="$STRIP -S" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + fi + ;; + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + ;; + esac +fi + + + + + + + + + + + + + # Report which library types will actually be built + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 +$as_echo_n "checking if libtool supports shared libraries... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 +$as_echo "$can_build_shared" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 +$as_echo_n "checking whether to build shared libraries... " >&6; } + test "$can_build_shared" = "no" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + + aix[4-9]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + esac + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 +$as_echo "$enable_shared" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 +$as_echo_n "checking whether to build static libraries... " >&6; } + # Make sure either enable_shared or enable_static is yes. + test "$enable_shared" = yes || enable_static=yes + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 +$as_echo "$enable_static" >&6; } + + + + +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +CC="$lt_save_CC" + + + + + + + + + + + + + + ac_config_commands="$ac_config_commands libtool" + + + + +# Only expand once: + + +if test "x$CC" != xcc; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC and cc understand -c and -o together" >&5 +$as_echo_n "checking whether $CC and cc understand -c and -o together... " >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc understands -c and -o together" >&5 +$as_echo_n "checking whether cc understands -c and -o together... " >&6; } +fi +set dummy $CC; ac_cc=`$as_echo "$2" | + sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` +if eval \${ac_cv_prog_cc_${ac_cc}_c_o+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +# Make sure it works both with $CC and with simple cc. +# We do the test twice because some compilers refuse to overwrite an +# existing .o file with -o, though they will create one. +ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5' +rm -f conftest2.* +if { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && + test -f conftest2.$ac_objext && { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; +then + eval ac_cv_prog_cc_${ac_cc}_c_o=yes + if test "x$CC" != xcc; then + # Test first that cc exists at all. + if { ac_try='cc -c conftest.$ac_ext >&5' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5' + rm -f conftest2.* + if { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && + test -f conftest2.$ac_objext && { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; + then + # cc works too. + : + else + # cc exists but doesn't like -o. + eval ac_cv_prog_cc_${ac_cc}_c_o=no + fi + fi + fi +else + eval ac_cv_prog_cc_${ac_cc}_c_o=no +fi +rm -f core conftest* + +fi +if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +$as_echo "#define NO_MINUS_C_MINUS_O 1" >>confdefs.h + +fi + +# FIXME: we rely on the cache variable name because +# there is no other way. +set dummy $CC +am_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` +eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o +if test "$am_t" != yes; then + # Losing compiler, so override with the script. + # FIXME: It is wrong to rewrite CC. + # But if we don't then we get into trouble of one sort or another. + # A longer-term fix would be to have automake use am__CC in this case, + # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" + CC="$am_aux_dir/compile $CC" +fi + + + case $ac_cv_prog_cc_stdc in #( + no) : + ac_cv_prog_cc_c99=no; ac_cv_prog_cc_c89=no ;; #( + *) : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C99" >&5 +$as_echo_n "checking for $CC option to accept ISO C99... " >&6; } +if ${ac_cv_prog_cc_c99+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c99=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include +#include + +// Check varargs macros. These examples are taken from C99 6.10.3.5. +#define debug(...) fprintf (stderr, __VA_ARGS__) +#define showlist(...) puts (#__VA_ARGS__) +#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__)) +static void +test_varargs_macros (void) +{ + int x = 1234; + int y = 5678; + debug ("Flag"); + debug ("X = %d\n", x); + showlist (The first, second, and third items.); + report (x>y, "x is %d but y is %d", x, y); +} + +// Check long long types. +#define BIG64 18446744073709551615ull +#define BIG32 4294967295ul +#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0) +#if !BIG_OK + your preprocessor is broken; +#endif +#if BIG_OK +#else + your preprocessor is broken; +#endif +static long long int bignum = -9223372036854775807LL; +static unsigned long long int ubignum = BIG64; + +struct incomplete_array +{ + int datasize; + double data[]; +}; + +struct named_init { + int number; + const wchar_t *name; + double average; +}; + +typedef const char *ccp; + +static inline int +test_restrict (ccp restrict text) +{ + // See if C++-style comments work. + // Iterate through items via the restricted pointer. + // Also check for declarations in for loops. + for (unsigned int i = 0; *(text+i) != '\0'; ++i) + continue; + return 0; +} + +// Check varargs and va_copy. +static void +test_varargs (const char *format, ...) +{ + va_list args; + va_start (args, format); + va_list args_copy; + va_copy (args_copy, args); + + const char *str; + int number; + float fnumber; + + while (*format) + { + switch (*format++) + { + case 's': // string + str = va_arg (args_copy, const char *); + break; + case 'd': // int + number = va_arg (args_copy, int); + break; + case 'f': // float + fnumber = va_arg (args_copy, double); + break; + default: + break; + } + } + va_end (args_copy); + va_end (args); +} + +int +main () +{ + + // Check bool. + _Bool success = false; + + // Check restrict. + if (test_restrict ("String literal") == 0) + success = true; + char *restrict newvar = "Another string"; + + // Check varargs. + test_varargs ("s, d' f .", "string", 65, 34.234); + test_varargs_macros (); + + // Check flexible array members. + struct incomplete_array *ia = + malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); + ia->datasize = 10; + for (int i = 0; i < ia->datasize; ++i) + ia->data[i] = i * 1.234; + + // Check named initializers. + struct named_init ni = { + .number = 34, + .name = L"Test wide string", + .average = 543.34343, + }; + + ni.number = 58; + + int dynamic_array[ni.number]; + dynamic_array[ni.number - 1] = 543; + + // work around unused variable warnings + return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x' + || dynamic_array[ni.number - 1] != 543); + + ; + return 0; +} +_ACEOF +for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc99 +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c99=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c99" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c99" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c99" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5 +$as_echo "$ac_cv_prog_cc_c99" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c99" != xno; then : + ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99 +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +struct stat; +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89 +else + ac_cv_prog_cc_stdc=no +fi + +fi + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO Standard C" >&5 +$as_echo_n "checking for $CC option to accept ISO Standard C... " >&6; } + if ${ac_cv_prog_cc_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +fi + + case $ac_cv_prog_cc_stdc in #( + no) : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; #( + '') : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; #( + *) : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_stdc" >&5 +$as_echo "$ac_cv_prog_cc_stdc" >&6; } ;; +esac + +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +if test -z "$CXX"; then + if test -n "$CCC"; then + CXX=$CCC + else + if test -n "$ac_tool_prefix"; then + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CXX=$ac_cv_prog_CXX +if test -n "$CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 +$as_echo "$CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CXX" && break + done +fi +if test -z "$CXX"; then + ac_ct_CXX=$CXX + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CXX"; then + ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CXX="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CXX=$ac_cv_prog_ac_ct_CXX +if test -n "$ac_ct_CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 +$as_echo "$ac_ct_CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CXX" && break +done + + if test "x$ac_ct_CXX" = x; then + CXX="g++" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CXX=$ac_ct_CXX + fi +fi + + fi +fi +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 +$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } +if ${ac_cv_cxx_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_cxx_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 +$as_echo "$ac_cv_cxx_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GXX=yes +else + GXX= +fi +ac_test_CXXFLAGS=${CXXFLAGS+set} +ac_save_CXXFLAGS=$CXXFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 +$as_echo_n "checking whether $CXX accepts -g... " >&6; } +if ${ac_cv_prog_cxx_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_cxx_werror_flag=$ac_cxx_werror_flag + ac_cxx_werror_flag=yes + ac_cv_prog_cxx_g=no + CXXFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_prog_cxx_g=yes +else + CXXFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + +else + ac_cxx_werror_flag=$ac_save_cxx_werror_flag + CXXFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_prog_cxx_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cxx_werror_flag=$ac_save_cxx_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 +$as_echo "$ac_cv_prog_cxx_g" >&6; } +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS=$ac_save_CXXFLAGS +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +depcc="$CXX" am_compiler_list= + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 +$as_echo_n "checking dependency style of $depcc... " >&6; } +if ${am_cv_CXX_dependencies_compiler_type+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CXX_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + am__universal=false + case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvisualcpp | msvcmsys) + # This compiler won't grok `-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CXX_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CXX_dependencies_compiler_type=none +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 +$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } +CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then + am__fastdepCXX_TRUE= + am__fastdepCXX_FALSE='#' +else + am__fastdepCXX_TRUE='#' + am__fastdepCXX_FALSE= +fi + + + +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +if test -z "$CXX"; then + if test -n "$CCC"; then + CXX=$CCC + else + if test -n "$ac_tool_prefix"; then + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CXX=$ac_cv_prog_CXX +if test -n "$CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 +$as_echo "$CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CXX" && break + done +fi +if test -z "$CXX"; then + ac_ct_CXX=$CXX + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CXX"; then + ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CXX="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CXX=$ac_cv_prog_ac_ct_CXX +if test -n "$ac_ct_CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 +$as_echo "$ac_ct_CXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CXX" && break +done + + if test "x$ac_ct_CXX" = x; then + CXX="g++" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CXX=$ac_ct_CXX + fi +fi + + fi +fi +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 +$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } +if ${ac_cv_cxx_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_cxx_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 +$as_echo "$ac_cv_cxx_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GXX=yes +else + GXX= +fi +ac_test_CXXFLAGS=${CXXFLAGS+set} +ac_save_CXXFLAGS=$CXXFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 +$as_echo_n "checking whether $CXX accepts -g... " >&6; } +if ${ac_cv_prog_cxx_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_cxx_werror_flag=$ac_cxx_werror_flag + ac_cxx_werror_flag=yes + ac_cv_prog_cxx_g=no + CXXFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_prog_cxx_g=yes +else + CXXFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + +else + ac_cxx_werror_flag=$ac_save_cxx_werror_flag + CXXFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_prog_cxx_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cxx_werror_flag=$ac_save_cxx_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 +$as_echo "$ac_cv_prog_cxx_g" >&6; } +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS=$ac_save_CXXFLAGS +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +depcc="$CXX" am_compiler_list= + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 +$as_echo_n "checking dependency style of $depcc... " >&6; } +if ${am_cv_CXX_dependencies_compiler_type+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CXX_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + am__universal=false + case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvisualcpp | msvcmsys) + # This compiler won't grok `-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CXX_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CXX_dependencies_compiler_type=none +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 +$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } +CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then + am__fastdepCXX_TRUE= + am__fastdepCXX_FALSE='#' +else + am__fastdepCXX_TRUE='#' + am__fastdepCXX_FALSE= +fi + + +if test -n "$CXX" && ( test "X$CXX" != "Xno" && + ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || + (test "X$CXX" != "Xg++"))) ; then + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5 +$as_echo_n "checking how to run the C++ preprocessor... " >&6; } +if test -z "$CXXCPP"; then + if ${ac_cv_prog_CXXCPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CXXCPP needs to be expanded + for CXXCPP in "$CXX -E" "/lib/cpp" + do + ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CXXCPP=$CXXCPP + +fi + CXXCPP=$ac_cv_prog_CXXCPP +else + ac_cv_prog_CXXCPP=$CXXCPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5 +$as_echo "$CXXCPP" >&6; } +ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_cxx_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +_lt_caught_CXX_error=yes; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +else + _lt_caught_CXX_error=yes +fi + + + + +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + +archive_cmds_need_lc_CXX=no +allow_undefined_flag_CXX= +always_export_symbols_CXX=no +archive_expsym_cmds_CXX= +compiler_needs_object_CXX=no +export_dynamic_flag_spec_CXX= +hardcode_direct_CXX=no +hardcode_direct_absolute_CXX=no +hardcode_libdir_flag_spec_CXX= +hardcode_libdir_flag_spec_ld_CXX= +hardcode_libdir_separator_CXX= +hardcode_minus_L_CXX=no +hardcode_shlibpath_var_CXX=unsupported +hardcode_automatic_CXX=no +inherit_rpath_CXX=no +module_cmds_CXX= +module_expsym_cmds_CXX= +link_all_deplibs_CXX=unknown +old_archive_cmds_CXX=$old_archive_cmds +no_undefined_flag_CXX= +whole_archive_flag_spec_CXX= +enable_shared_with_static_runtimes_CXX=no + +# Source file extension for C++ test sources. +ac_ext=cpp + +# Object file extension for compiled C++ test sources. +objext=o +objext_CXX=$objext + +# No sense in running all these tests if we already determined that +# the CXX compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test "$_lt_caught_CXX_error" != yes; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="int some_variable = 0;" + + # Code to be used in simple link tests + lt_simple_link_test_code='int main(int, char *[]) { return(0); }' + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + + + + + + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + + # save warnings/boilerplate of simple test code + ac_outfile=conftest.$ac_objext +echo "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$RM conftest* + + ac_outfile=conftest.$ac_objext +echo "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$RM -r conftest* + + + # Allow CC to be a program name with arguments. + lt_save_CC=$CC + lt_save_LD=$LD + lt_save_GCC=$GCC + GCC=$GXX + lt_save_with_gnu_ld=$with_gnu_ld + lt_save_path_LD=$lt_cv_path_LD + if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then + lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx + else + $as_unset lt_cv_prog_gnu_ld + fi + if test -n "${lt_cv_path_LDCXX+set}"; then + lt_cv_path_LD=$lt_cv_path_LDCXX + else + $as_unset lt_cv_path_LD + fi + test -z "${LDCXX+set}" || LD=$LDCXX + CC=${CXX-"c++"} + compiler=$CC + compiler_CXX=$CC + for cc_temp in $compiler""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` + + + if test -n "$compiler"; then + # We don't want -fno-exception when compiling C++ code, so set the + # no_builtin_flag separately + if test "$GXX" = yes; then + lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin' + else + lt_prog_compiler_no_builtin_flag_CXX= + fi + + if test "$GXX" = yes; then + # Set up default GNU C++ configuration + + + +# Check whether --with-gnu-ld was given. +if test "${with_gnu_ld+set}" = set; then : + withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes +else + with_gnu_ld=no +fi + +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 +$as_echo_n "checking for ld used by $CC... " >&6; } + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [\\/]* | ?:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` + while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do + ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 +$as_echo_n "checking for GNU ld... " >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 +$as_echo_n "checking for non-GNU ld... " >&6; } +fi +if ${lt_cv_path_LD+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$LD"; then + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &5 +$as_echo "$LD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } +if ${lt_cv_prog_gnu_ld+:} false; then : + $as_echo_n "(cached) " >&6 +else + # I'd rather use --version here, but apparently some GNU lds only accept -v. +case `$LD -v 2>&1 &5 +$as_echo "$lt_cv_prog_gnu_ld" >&6; } +with_gnu_ld=$lt_cv_prog_gnu_ld + + + + + + + + # Check if GNU C++ uses GNU ld as the underlying linker, since the + # archiving commands below assume that GNU ld is being used. + if test "$with_gnu_ld" = yes; then + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + export_dynamic_flag_spec_CXX='${wl}--export-dynamic' + + # If archive_cmds runs LD, not CC, wlarc should be empty + # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to + # investigate it a little bit more. (MM) + wlarc='${wl}' + + # ancient GNU ld didn't support --whole-archive et. al. + if eval "`$CC -print-prog-name=ld` --help 2>&1" | + $GREP 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec_CXX= + fi + else + with_gnu_ld=no + wlarc= + + # A generic and very simple default shared library creation + # command for GNU C++ for the case where it uses the native + # linker, instead of GNU ld. If possible, this setting should + # overridden to take advantage of the native linker features on + # the platform it is being used on. + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + fi + + # 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 "\-L"' + + else + GXX=no + with_gnu_ld=no + wlarc= + fi + + # PORTME: fill in a description of your system's C++ link characteristics + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } + ld_shlibs_CXX=yes + case $host_os in + aix3*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + aix[4-9]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) + for ld_flag in $LDFLAGS; do + case $ld_flag in + *-brtl*) + aix_use_runtimelinking=yes + break + ;; + esac + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds_CXX='' + hardcode_direct_CXX=yes + hardcode_direct_absolute_CXX=yes + hardcode_libdir_separator_CXX=':' + link_all_deplibs_CXX=yes + file_list_spec_CXX='${wl}-f,' + + if test "$GXX" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + hardcode_direct_CXX=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L_CXX=yes + hardcode_libdir_flag_spec_CXX='-L$libdir' + hardcode_libdir_separator_CXX= + fi + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + export_dynamic_flag_spec_CXX='${wl}-bexpall' + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to + # export. + always_export_symbols_CXX=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag_CXX='-berok' + # Determine the default libpath from the value encoded in an empty + # executable. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + +lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\(.*\)$/\1/ + p + } + }' +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +fi +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" + + archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib' + allow_undefined_flag_CXX="-z nodefs" + archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + +lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\(.*\)$/\1/ + p + } + }' +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +fi +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag_CXX=' ${wl}-bernotok' + allow_undefined_flag_CXX=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec_CXX='$convenience' + archive_cmds_need_lc_CXX=yes + # This is similar to how AIX traditionally builds its shared + # libraries. + archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag_CXX=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs_CXX=no + fi + ;; + + chorus*) + case $cc_basename in + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec_CXX='-L$libdir' + allow_undefined_flag_CXX=unsupported + always_export_symbols_CXX=no + enable_shared_with_static_runtimes_CXX=yes + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + ld_shlibs_CXX=no + fi + ;; + darwin* | rhapsody*) + + + archive_cmds_need_lc_CXX=no + hardcode_direct_CXX=no + hardcode_automatic_CXX=yes + hardcode_shlibpath_var_CXX=unsupported + whole_archive_flag_spec_CXX='' + link_all_deplibs_CXX=yes + allow_undefined_flag_CXX="$_lt_dar_allow_undefined" + case $cc_basename in + ifort*) _lt_dar_can_shared=yes ;; + *) _lt_dar_can_shared=$GCC ;; + esac + if test "$_lt_dar_can_shared" = "yes"; then + output_verbose_link_cmd=echo + archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" + module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" + archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" + module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" + if test "$lt_cv_apple_cc_single_mod" != "yes"; then + archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" + archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" + fi + + else + ld_shlibs_CXX=no + fi + + ;; + + dgux*) + case $cc_basename in + ec++*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + ghcx*) + # Green Hills C++ Compiler + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + + freebsd[12]*) + # C++ shared libraries reported to be fairly broken before + # switch to ELF + ld_shlibs_CXX=no + ;; + + freebsd-elf*) + archive_cmds_need_lc_CXX=no + ;; + + freebsd* | dragonfly*) + # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF + # conventions + ld_shlibs_CXX=yes + ;; + + gnu*) + ;; + + hpux9*) + hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_CXX=: + export_dynamic_flag_spec_CXX='${wl}-E' + hardcode_direct_CXX=yes + hardcode_minus_L_CXX=yes # Not in the search PATH, + # but as the default + # location of the library. + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + aCC*) + archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # 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; $ECHO "X$list" | $Xsed' + ;; + *) + if test "$GXX" = yes; then + archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + fi + ;; + esac + ;; + + hpux10*|hpux11*) + if test $with_gnu_ld = no; then + hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_CXX=: + + case $host_cpu in + hppa*64*|ia64*) + ;; + *) + export_dynamic_flag_spec_CXX='${wl}-E' + ;; + esac + fi + case $host_cpu in + hppa*64*|ia64*) + hardcode_direct_CXX=no + hardcode_shlibpath_var_CXX=no + ;; + *) + hardcode_direct_CXX=yes + hardcode_direct_absolute_CXX=yes + hardcode_minus_L_CXX=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + esac + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + aCC*) + case $host_cpu in + hppa*64*) + archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # 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; $ECHO "X$list" | $Xsed' + ;; + *) + if test "$GXX" = yes; then + if test $with_gnu_ld = no; then + case $host_cpu in + hppa*64*) + archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + fi + else + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + fi + ;; + esac + ;; + + interix[3-9]*) + hardcode_direct_CXX=no + hardcode_shlibpath_var_CXX=no + hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + export_dynamic_flag_spec_CXX='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + irix5* | irix6*) + case $cc_basename in + CC*) + # SGI C++ + archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + + # Archives containing C++ object files must be created using + # "CC -ar", where "CC" is the IRIX C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs' + ;; + *) + if test "$GXX" = yes; then + if test "$with_gnu_ld" = no; then + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib' + fi + fi + link_all_deplibs_CXX=yes + ;; + esac + hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_CXX=: + inherit_rpath_CXX=yes + ;; + + linux* | k*bsd*-gnu) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # 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 $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + export_dynamic_flag_spec_CXX='${wl}--export-dynamic' + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' + ;; + icpc* | ecpc* ) + # Intel C++ + with_gnu_ld=yes + # version 8.0 and above of icpc choke on multiply defined symbols + # if we add $predep_objects and $postdep_objects, however 7.1 and + # earlier do not add the objects themselves. + case `$CC -V 2>&1` in + *"Version 7."*) + archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + *) # Version 8.0 or newer + tmp_idyn= + case $host_cpu in + ia64*) tmp_idyn=' -i_dynamic';; + esac + archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + esac + archive_cmds_need_lc_CXX=no + hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + export_dynamic_flag_spec_CXX='${wl}--export-dynamic' + whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + case `$CC -V` in + *pgCC\ [1-5]* | *pgcpp\ [1-5]*) + prelink_cmds_CXX='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ + compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"' + old_archive_cmds_CXX='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ + $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~ + $RANLIB $oldlib' + archive_cmds_CXX='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' + archive_expsym_cmds_CXX='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' + ;; + *) # Version 6 will use weak symbols + archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' + ;; + esac + + hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec_CXX='${wl}--export-dynamic' + whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + ;; + cxx*) + # Compaq C++ + archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' + + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec_CXX='-rpath $libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # 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 -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + ;; + xl*) + # IBM XL 8.0 on PPC, with GNU ld + hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + export_dynamic_flag_spec_CXX='${wl}--export-dynamic' + archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + if test "x$supports_anon_versioning" = xyes; then + archive_expsym_cmds_CXX='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + fi + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + no_undefined_flag_CXX=' -zdefs' + archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + archive_expsym_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' + hardcode_libdir_flag_spec_CXX='-R$libdir' + whole_archive_flag_spec_CXX='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + compiler_needs_object_CXX=yes + + # Not sure whether something based on + # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 + # would be better. + output_verbose_link_cmd='echo' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' + ;; + esac + ;; + esac + ;; + + lynxos*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + + m88k*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + + mvs*) + case $cc_basename in + cxx*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' + wlarc= + hardcode_libdir_flag_spec_CXX='-R$libdir' + hardcode_direct_CXX=yes + hardcode_shlibpath_var_CXX=no + fi + # Workaround some broken pre-1.5 toolchains + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' + ;; + + *nto* | *qnx*) + ld_shlibs_CXX=yes + ;; + + openbsd2*) + # C++ shared libraries are fairly broken + ld_shlibs_CXX=no + ;; + + openbsd*) + if test -f /usr/libexec/ld.so; then + hardcode_direct_CXX=yes + hardcode_shlibpath_var_CXX=no + hardcode_direct_absolute_CXX=yes + archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' + export_dynamic_flag_spec_CXX='${wl}-E' + whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + fi + output_verbose_link_cmd=echo + else + ld_shlibs_CXX=no + fi + ;; + + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + hardcode_libdir_separator_CXX=: + + # Archives containing C++ object files must be created using + # the KAI C++ compiler. + case $host in + osf3*) old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;; + *) old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' ;; + esac + ;; + RCC*) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + cxx*) + case $host in + osf3*) + allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + ;; + *) + allow_undefined_flag_CXX=' -expect_unresolved \*' + archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ + echo "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~ + $RM $lib.exp' + hardcode_libdir_flag_spec_CXX='-rpath $libdir' + ;; + esac + + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # 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 -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' + case $host in + osf3*) + archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + ;; + *) + archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + ;; + esac + + hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_CXX=: + + # 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 "\-L"' + + else + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + fi + ;; + esac + ;; + + psos*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + lcc*) + # Lucid + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + + solaris*) + case $cc_basename in + CC*) + # Sun C++ 4.2, 5.x and Centerline C++ + archive_cmds_need_lc_CXX=yes + no_undefined_flag_CXX=' -zdefs' + archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + hardcode_libdir_flag_spec_CXX='-R$libdir' + hardcode_shlibpath_var_CXX=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands `-z linker_flag'. + # Supported since Solaris 2.6 (maybe 2.5.1?) + whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract' + ;; + esac + link_all_deplibs_CXX=yes + + output_verbose_link_cmd='echo' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' + ;; + gcx*) + # Green Hills C++ Compiler + archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + + # The C++ compiler must be used to create the archive. + old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs' + ;; + *) + # GNU C++ compiler with Solaris linker + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + no_undefined_flag_CXX=' ${wl}-z ${wl}defs' + if $CC --version | $GREP -v '^2\.7' > /dev/null; then + archive_cmds_CXX='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + # 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 "\-L"' + else + # g++ 2.7 appears to require `-G' NOT `-shared' on this + # platform. + archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + # 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 "\-L"' + fi + + hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir' + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) + whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + ;; + esac + fi + ;; + esac + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) + no_undefined_flag_CXX='${wl}-z,text' + archive_cmds_need_lc_CXX=no + hardcode_shlibpath_var_CXX=no + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + no_undefined_flag_CXX='${wl}-z,text' + allow_undefined_flag_CXX='${wl}-z,nodefs' + archive_cmds_need_lc_CXX=no + hardcode_shlibpath_var_CXX=no + hardcode_libdir_flag_spec_CXX='${wl}-R,$libdir' + hardcode_libdir_separator_CXX=':' + link_all_deplibs_CXX=yes + export_dynamic_flag_spec_CXX='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + + vxworks*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 +$as_echo "$ld_shlibs_CXX" >&6; } + test "$ld_shlibs_CXX" = no && can_build_shared=no + + GCC_CXX="$GXX" + LD_CXX="$LD" + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + # Dependencies to place before and after the object being linked: +predep_objects_CXX= +postdep_objects_CXX= +predeps_CXX= +postdeps_CXX= +compiler_lib_search_path_CXX= + +cat > conftest.$ac_ext <<_LT_EOF +class Foo +{ +public: + Foo (void) { a = 0; } +private: + int a; +}; +_LT_EOF + +if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + # Parse the compiler output and extract the necessary + # objects, libraries and library flags. + + # Sentinel used to keep track of whether or not we are before + # the conftest object file. + pre_test_object_deps_done=no + + for p in `eval "$output_verbose_link_cmd"`; do + case $p in + + -L* | -R* | -l*) + # Some compilers place space between "-{L,R}" and the path. + # Remove the space. + if test $p = "-L" || + test $p = "-R"; then + prev=$p + continue + else + prev= + fi + + if test "$pre_test_object_deps_done" = no; then + case $p in + -L* | -R*) + # Internal compiler library paths should come after those + # provided the user. The postdeps already come after the + # user supplied libs so there is no need to process them. + if test -z "$compiler_lib_search_path_CXX"; then + compiler_lib_search_path_CXX="${prev}${p}" + else + compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}" + fi + ;; + # The "-l" case would never come before the object being + # linked, so don't bother handling this case. + esac + else + if test -z "$postdeps_CXX"; then + postdeps_CXX="${prev}${p}" + else + postdeps_CXX="${postdeps_CXX} ${prev}${p}" + fi + fi + ;; + + *.$objext) + # This assumes that the test object file only shows up + # once in the compiler output. + if test "$p" = "conftest.$objext"; then + pre_test_object_deps_done=yes + continue + fi + + if test "$pre_test_object_deps_done" = no; then + if test -z "$predep_objects_CXX"; then + predep_objects_CXX="$p" + else + predep_objects_CXX="$predep_objects_CXX $p" + fi + else + if test -z "$postdep_objects_CXX"; then + postdep_objects_CXX="$p" + else + postdep_objects_CXX="$postdep_objects_CXX $p" + fi + fi + ;; + + *) ;; # Ignore the rest. + + esac + done + + # Clean up. + rm -f a.out a.exe +else + echo "libtool.m4: error: problem compiling CXX test program" +fi + +$RM -f confest.$objext + +# PORTME: override above test on systems where it is broken +case $host_os in +interix[3-9]*) + # Interix 3.5 installs completely hosed .la files for C++, so rather than + # hack all around it, let's just trust "g++" to DTRT. + predep_objects_CXX= + postdep_objects_CXX= + postdeps_CXX= + ;; + +linux*) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + + # The more standards-conforming stlport4 library is + # incompatible with the Cstd library. Avoid specifying + # it if it's in CXXFLAGS. Ignore libCrun as + # -library=stlport4 depends on it. + case " $CXX $CXXFLAGS " in + *" -library=stlport4 "*) + solaris_use_stlport4=yes + ;; + esac + + if test "$solaris_use_stlport4" != yes; then + postdeps_CXX='-library=Cstd -library=Crun' + fi + ;; + esac + ;; + +solaris*) + case $cc_basename in + CC*) + # The more standards-conforming stlport4 library is + # incompatible with the Cstd library. Avoid specifying + # it if it's in CXXFLAGS. Ignore libCrun as + # -library=stlport4 depends on it. + case " $CXX $CXXFLAGS " in + *" -library=stlport4 "*) + solaris_use_stlport4=yes + ;; + esac + + # Adding this requires a known-good setup of shared libraries for + # Sun compiler versions before 5.6, else PIC objects from an old + # archive will be linked into the output, leading to subtle bugs. + if test "$solaris_use_stlport4" != yes; then + postdeps_CXX='-library=Cstd -library=Crun' + fi + ;; + esac + ;; +esac + + +case " $postdeps_CXX " in +*" -lc "*) archive_cmds_need_lc_CXX=no ;; +esac + compiler_lib_search_dirs_CXX= +if test -n "${compiler_lib_search_path_CXX}"; then + compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` +fi + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + lt_prog_compiler_wl_CXX= +lt_prog_compiler_pic_CXX= +lt_prog_compiler_static_CXX= + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 +$as_echo_n "checking for $compiler option to produce PIC... " >&6; } + + # C++ specific cases for pic, static, wl, etc. + if test "$GXX" = yes; then + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_CXX='-Bstatic' + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + lt_prog_compiler_pic_CXX='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + mingw* | cygwin* | os2* | pw32* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + lt_prog_compiler_pic_CXX='-DDLL_EXPORT' + ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic_CXX='-fno-common' + ;; + *djgpp*) + # DJGPP does not support shared libraries at all + lt_prog_compiler_pic_CXX= + ;; + interix[3-9]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic_CXX=-Kconform_pic + fi + ;; + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + ;; + *) + lt_prog_compiler_pic_CXX='-fPIC' + ;; + esac + ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + lt_prog_compiler_pic_CXX='-fPIC -shared' + ;; + *) + lt_prog_compiler_pic_CXX='-fPIC' + ;; + esac + else + case $host_os in + aix[4-9]*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_CXX='-Bstatic' + else + lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp' + fi + ;; + chorus*) + case $cc_basename in + cxch68*) + # Green Hills C++ Compiler + # _LT_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" + ;; + esac + ;; + dgux*) + case $cc_basename in + ec++*) + lt_prog_compiler_pic_CXX='-KPIC' + ;; + ghcx*) + # Green Hills C++ Compiler + lt_prog_compiler_pic_CXX='-pic' + ;; + *) + ;; + esac + ;; + freebsd* | dragonfly*) + # FreeBSD uses GNU C++ + ;; + hpux9* | hpux10* | hpux11*) + case $cc_basename in + CC*) + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' + if test "$host_cpu" != ia64; then + lt_prog_compiler_pic_CXX='+Z' + fi + ;; + aCC*) + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX='${wl}-a ${wl}archive' + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic_CXX='+Z' + ;; + esac + ;; + *) + ;; + esac + ;; + interix*) + # This is c89, which is MS Visual C++ (no shared libs) + # Anyone wants to do a port? + ;; + irix5* | irix6* | nonstopux*) + case $cc_basename in + CC*) + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX='-non_shared' + # CC pic flag -KPIC is the default. + ;; + *) + ;; + esac + ;; + linux* | k*bsd*-gnu) + case $cc_basename in + KCC*) + # KAI C++ Compiler + lt_prog_compiler_wl_CXX='--backend -Wl,' + lt_prog_compiler_pic_CXX='-fPIC' + ;; + ecpc* ) + # old Intel C++ for x86_64 which still supported -KPIC. + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_pic_CXX='-KPIC' + lt_prog_compiler_static_CXX='-static' + ;; + icpc* ) + # Intel C++, used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_pic_CXX='-fPIC' + lt_prog_compiler_static_CXX='-static' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_pic_CXX='-fpic' + lt_prog_compiler_static_CXX='-Bstatic' + ;; + cxx*) + # Compaq C++ + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + lt_prog_compiler_pic_CXX= + lt_prog_compiler_static_CXX='-non_shared' + ;; + xlc* | xlC*) + # IBM XL 8.0 on PPC + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_pic_CXX='-qpic' + lt_prog_compiler_static_CXX='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + lt_prog_compiler_pic_CXX='-KPIC' + lt_prog_compiler_static_CXX='-Bstatic' + lt_prog_compiler_wl_CXX='-Qoption ld ' + ;; + esac + ;; + esac + ;; + lynxos*) + ;; + m88k*) + ;; + mvs*) + case $cc_basename in + cxx*) + lt_prog_compiler_pic_CXX='-W c,exportall' + ;; + *) + ;; + esac + ;; + netbsd*) + ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + lt_prog_compiler_pic_CXX='-fPIC -shared' + ;; + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + lt_prog_compiler_wl_CXX='--backend -Wl,' + ;; + RCC*) + # Rational C++ 2.4.1 + lt_prog_compiler_pic_CXX='-pic' + ;; + cxx*) + # Digital/Compaq C++ + lt_prog_compiler_wl_CXX='-Wl,' + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + lt_prog_compiler_pic_CXX= + lt_prog_compiler_static_CXX='-non_shared' + ;; + *) + ;; + esac + ;; + psos*) + ;; + solaris*) + case $cc_basename in + CC*) + # Sun C++ 4.2, 5.x and Centerline C++ + lt_prog_compiler_pic_CXX='-KPIC' + lt_prog_compiler_static_CXX='-Bstatic' + lt_prog_compiler_wl_CXX='-Qoption ld ' + ;; + gcx*) + # Green Hills C++ Compiler + lt_prog_compiler_pic_CXX='-PIC' + ;; + *) + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + lt_prog_compiler_pic_CXX='-pic' + lt_prog_compiler_static_CXX='-Bstatic' + ;; + lcc*) + # Lucid + lt_prog_compiler_pic_CXX='-pic' + ;; + *) + ;; + esac + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + case $cc_basename in + CC*) + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_pic_CXX='-KPIC' + lt_prog_compiler_static_CXX='-Bstatic' + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + lt_prog_compiler_pic_CXX='-KPIC' + ;; + *) + ;; + esac + ;; + vxworks*) + ;; + *) + lt_prog_compiler_can_build_shared_CXX=no + ;; + esac + fi + +case $host_os in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic_CXX= + ;; + *) + lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC" + ;; +esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic_CXX" >&5 +$as_echo "$lt_prog_compiler_pic_CXX" >&6; } + + + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$lt_prog_compiler_pic_CXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5 +$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... " >&6; } +if ${lt_cv_prog_compiler_pic_works_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_pic_works_CXX=no + ac_outfile=conftest.$ac_objext + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:14162: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:14166: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_pic_works_CXX=yes + fi + fi + $RM conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5 +$as_echo "$lt_cv_prog_compiler_pic_works_CXX" >&6; } + +if test x"$lt_cv_prog_compiler_pic_works_CXX" = xyes; then + case $lt_prog_compiler_pic_CXX in + "" | " "*) ;; + *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;; + esac +else + lt_prog_compiler_pic_CXX= + lt_prog_compiler_can_build_shared_CXX=no +fi + +fi + + + +# +# Check to make sure the static flag actually works. +# +wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\" +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 +$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } +if ${lt_cv_prog_compiler_static_works_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_static_works_CXX=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $lt_tmp_static_flag" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + lt_cv_prog_compiler_static_works_CXX=yes + fi + else + lt_cv_prog_compiler_static_works_CXX=yes + fi + fi + $RM -r conftest* + LDFLAGS="$save_LDFLAGS" + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5 +$as_echo "$lt_cv_prog_compiler_static_works_CXX" >&6; } + +if test x"$lt_cv_prog_compiler_static_works_CXX" = xyes; then + : +else + lt_prog_compiler_static_CXX= +fi + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 +$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if ${lt_cv_prog_compiler_c_o_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_c_o_CXX=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:14261: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:14265: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o_CXX=yes + fi + fi + chmod u+w . 2>&5 + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 +$as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; } + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 +$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } +if ${lt_cv_prog_compiler_c_o_CXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + lt_cv_prog_compiler_c_o_CXX=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:14313: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:14317: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + lt_cv_prog_compiler_c_o_CXX=yes + fi + fi + chmod u+w . 2>&5 + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5 +$as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; } + + + + +hard_links="nottested" +if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 +$as_echo_n "checking if we can lock with hard links... " >&6; } + hard_links=yes + $RM conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 +$as_echo "$hard_links" >&6; } + if test "$hard_links" = no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 +$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} + need_locks=warn + fi +else + need_locks=no +fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } + + export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + case $host_os in + aix[4-9]*) + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + fi + ;; + pw32*) + export_symbols_cmds_CXX="$ltdll_cmds" + ;; + cygwin* | mingw* | cegcc*) + export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;/^.*[ ]__nm__/s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' + ;; + *) + export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + ;; + esac + exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5 +$as_echo "$ld_shlibs_CXX" >&6; } +test "$ld_shlibs_CXX" = no && can_build_shared=no + +with_gnu_ld_CXX=$with_gnu_ld + + + + + + +# +# Do we need to explicitly link libc? +# +case "x$archive_cmds_need_lc_CXX" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc_CXX=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $archive_cmds_CXX in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 +$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } + $RM conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl_CXX + pic_flag=$lt_prog_compiler_pic_CXX + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag_CXX + allow_undefined_flag_CXX= + if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 + (eval $archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + then + archive_cmds_need_lc_CXX=no + else + archive_cmds_need_lc_CXX=yes + fi + allow_undefined_flag_CXX=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $RM conftest* + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $archive_cmds_need_lc_CXX" >&5 +$as_echo "$archive_cmds_need_lc_CXX" >&6; } + ;; + esac + fi + ;; +esac + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 +$as_echo_n "checking dynamic linker characteristics... " >&6; } + +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix[4-9]*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + case $host_cpu in + powerpc) + # Since July 2007 AmigaOS4 officially supports .so libraries. + # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + ;; + m68k) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + esac + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[45]*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32* | cegcc*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw* | cegcc*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' + + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[123]*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ + freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + *) # from 4.6 on, and DragonFly + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +interix[3-9]*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux* | k*bsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # Some binutils ld are patched to set DT_RUNPATH + save_LDFLAGS=$LDFLAGS + save_libdir=$libdir + eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_CXX\"; \ + LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_CXX\"" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : + shlibpath_overrides_runpath=yes +fi +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$save_LDFLAGS + libdir=$save_libdir + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +*nto* | *qnx*) + version_type=qnx + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='ldqnx.so' + ;; + +openbsd*) + version_type=sunos + sys_lib_dlsearch_path_spec="/usr/lib" + need_lib_prefix=no + # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. + case $host_os in + openbsd3.3 | openbsd3.3.*) need_version=yes ;; + *) need_version=no ;; + esac + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[89] | openbsd2.[89].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +rdos*) + dynamic_linker=no + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=freebsd-elf + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + if test "$with_gnu_ld" = yes; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +tpf*) + # TPF is a cross-target only. Preferred cross-host = GNU/Linux. + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 +$as_echo "$dynamic_linker" >&6; } +test "$dynamic_linker" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then + sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" +fi +if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then + sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" +fi + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 +$as_echo_n "checking how to hardcode library paths into programs... " >&6; } +hardcode_action_CXX= +if test -n "$hardcode_libdir_flag_spec_CXX" || + test -n "$runpath_var_CXX" || + test "X$hardcode_automatic_CXX" = "Xyes" ; then + + # We can hardcode non-existent directories. + if test "$hardcode_direct_CXX" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" != no && + test "$hardcode_minus_L_CXX" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action_CXX=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action_CXX=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action_CXX=unsupported +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5 +$as_echo "$hardcode_action_CXX" >&6; } + +if test "$hardcode_action_CXX" = relink || + test "$inherit_rpath_CXX" = yes; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + + + + + + + + fi # test -n "$compiler" + + CC=$lt_save_CC + LDCXX=$LD + LD=$lt_save_LD + GCC=$lt_save_GCC + with_gnu_ld=$lt_save_with_gnu_ld + lt_cv_path_LDCXX=$lt_cv_path_LD + lt_cv_path_LD=$lt_save_path_LD + lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld + lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld +fi # test "$_lt_caught_CXX_error" != yes + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 +$as_echo_n "checking whether ln -s works... " >&6; } +LN_S=$as_ln_s +if test "$LN_S" = "ln -s"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 +$as_echo "no, using $LN_S" >&6; } +fi + + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AWK+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AWK="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 +$as_echo "$AWK" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$AWK" && break +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 +$as_echo_n "checking for a sed that does not truncate output... " >&6; } +if ${ac_cv_path_SED+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ + for ac_i in 1 2 3 4 5 6 7; do + ac_script="$ac_script$as_nl$ac_script" + done + echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed + { ac_script=; unset ac_script;} + if test -z "$SED"; then + ac_path_SED_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_SED" || continue +# Check for GNU ac_path_SED and select it if it is found. + # Check for GNU $ac_path_SED +case `"$ac_path_SED" --version 2>&1` in +*GNU*) + ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo '' >> "conftest.nl" + "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_SED_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_SED="$ac_path_SED" + ac_path_SED_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_SED_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_SED"; then + as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 + fi +else + ac_cv_path_SED=$SED +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 +$as_echo "$ac_cv_path_SED" >&6; } + SED="$ac_cv_path_SED" + rm -f conftest.sed + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +set x ${MAKE-make} +ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + SET_MAKE= +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + + +# Extract the first word of "printf", so it can be a program name with args. +set dummy printf; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_PRINTF+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $PRINTF in + [\\/]* | ?:[\\/]*) + ac_cv_path_PRINTF="$PRINTF" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_PRINTF="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +PRINTF=$ac_cv_path_PRINTF +if test -n "$PRINTF"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PRINTF" >&5 +$as_echo "$PRINTF" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +# Extract the first word of "echo", so it can be a program name with args. +set dummy echo; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_ECHO+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $ECHO in + [\\/]* | ?:[\\/]*) + ac_cv_path_ECHO="$ECHO" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_ECHO="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +ECHO=$ac_cv_path_ECHO +if test -n "$ECHO"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ECHO" >&5 +$as_echo "$ECHO" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +# Extract the first word of "cut", so it can be a program name with args. +set dummy cut; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_CUT+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $CUT in + [\\/]* | ?:[\\/]*) + ac_cv_path_CUT="$CUT" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_CUT="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +CUT=$ac_cv_path_CUT +if test -n "$CUT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CUT" >&5 +$as_echo "$CUT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +# Extract the first word of "autogen", so it can be a program name with args. +set dummy autogen; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_AUTOGEN+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $AUTOGEN in + [\\/]* | ?:[\\/]*) + ac_cv_path_AUTOGEN="$AUTOGEN" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_AUTOGEN="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +AUTOGEN=$ac_cv_path_AUTOGEN +if test -n "$AUTOGEN"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AUTOGEN" >&5 +$as_echo "$AUTOGEN" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +# Extract the first word of "groff", so it can be a program name with args. +set dummy groff; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_GROFF+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $GROFF in + [\\/]* | ?:[\\/]*) + ac_cv_path_GROFF="$GROFF" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_GROFF="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +GROFF=$ac_cv_path_GROFF +if test -n "$GROFF"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GROFF" >&5 +$as_echo "$GROFF" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + +AUTOGEN_VERSION=unknown +if test -n "${AUTOGEN}" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for autogen version >= 5.9.x" >&5 +$as_echo_n "checking for autogen version >= 5.9.x... " >&6; } + ${AUTOGEN} -v >autogen.version + AUTOGEN_VERSION=`cat autogen.version | ${SED} 's|.*\([0-9\.]\{5,\}\).*|\1|'` + AUTOGEN_MAJOR=`echo ${AUTOGEN_VERSION} | ${CUT} -d '.' -f 1` + AUTOGEN_MINOR=`echo ${AUTOGEN_VERSION} | ${CUT} -d '.' -f 2` + if ( test ${AUTOGEN_MAJOR} -eq 5 && test ${AUTOGEN_MINOR} -lt 9 ) || test ${AUTOGEN_MAJOR} -lt 5 ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: ${AUTOGEN} is too old (${AUTOGEN_VERSION}) for building from SVN. Please upgrade to 5.9.x)" >&5 +$as_echo "$as_me: WARNING: ${AUTOGEN} is too old (${AUTOGEN_VERSION}) for building from SVN. Please upgrade to 5.9.x)" >&2;} + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + fi + rm -f autogen.version + + if test ! -f src/tcpreplay_opts.c && test "x$enable_local_libopts" = "xyes" ; then + if test $MAINTAINER_AUTOGEN_VERSION != $AUTOGEN_VERSION ; then + as_fn_error $? "Your version of autogen ($AUTOGEN_VERSION) != libopts tear off ($MAINTAINER_AUTOGEN_VERSION) Either install the correct version or specify --disable-local-libopts" "$LINENO" 5 + fi + fi +else + if test ! -f src/tcpreplay_opts.c ; then + as_fn_error $? "Please install GNU autogen >= 5.9.x if you are building from SVN" "$LINENO" 5 + fi +fi + +$as_echo "#define AUTOGEN_VERSION \${AUTOGEN_VERSION}" >>confdefs.h + + +if test "x$enable_local_libopts" = "xyes" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Using included libopts tearoff" >&5 +$as_echo "$as_me: Using included libopts tearoff" >&6;} +else + { $as_echo "$as_me:${as_lineno-$LINENO}: Using system libopts" >&5 +$as_echo "$as_me: Using system libopts" >&6;} +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether sys/types.h defines makedev" >&5 +$as_echo_n "checking whether sys/types.h defines makedev... " >&6; } +if ${ac_cv_header_sys_types_h_makedev+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +return makedev(0, 0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_header_sys_types_h_makedev=yes +else + ac_cv_header_sys_types_h_makedev=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_sys_types_h_makedev" >&5 +$as_echo "$ac_cv_header_sys_types_h_makedev" >&6; } + +if test $ac_cv_header_sys_types_h_makedev = no; then +ac_fn_c_check_header_mongrel "$LINENO" "sys/mkdev.h" "ac_cv_header_sys_mkdev_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_mkdev_h" = xyes; then : + +$as_echo "#define MAJOR_IN_MKDEV 1" >>confdefs.h + +fi + + + + if test $ac_cv_header_sys_mkdev_h = no; then + ac_fn_c_check_header_mongrel "$LINENO" "sys/sysmacros.h" "ac_cv_header_sys_sysmacros_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_sysmacros_h" = xyes; then : + +$as_echo "#define MAJOR_IN_SYSMACROS 1" >>confdefs.h + +fi + + + fi +fi + + +ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" +if test "x$ac_cv_type_size_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define size_t unsigned int +_ACEOF + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 +$as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } +if ${ac_cv_header_time+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include + +int +main () +{ +if ((struct tm *) 0) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_time=yes +else + ac_cv_header_time=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 +$as_echo "$ac_cv_header_time" >&6; } +if test $ac_cv_header_time = yes; then + +$as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 +$as_echo_n "checking for an ANSI C-conforming const... " >&6; } +if ${ac_cv_c_const+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + +#ifndef __cplusplus + /* Ultrix mips cc rejects this sort of thing. */ + typedef int charset[2]; + const charset cs = { 0, 0 }; + /* SunOS 4.1.1 cc rejects this. */ + char const *const *pcpcc; + char **ppc; + /* NEC SVR4.0.2 mips cc rejects this. */ + struct point {int x, y;}; + static struct point const zero = {0,0}; + /* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in + an arm of an if-expression whose if-part is not a constant + expression */ + const char *g = "string"; + pcpcc = &g + (g ? g-g : 0); + /* HPUX 7.0 cc rejects these. */ + ++pcpcc; + ppc = (char**) pcpcc; + pcpcc = (char const *const *) ppc; + { /* SCO 3.2v4 cc rejects this sort of thing. */ + char tx; + char *t = &tx; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; + if (s) return 0; + } + { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; + } + { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; + } + { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; } bx; + struct s *b = &bx; b->j = 5; + } + { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; + if (!foo) return 0; + } + return !cs[0] && !zero.x; +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_const=yes +else + ac_cv_c_const=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 +$as_echo "$ac_cv_c_const" >&6; } +if test $ac_cv_c_const = no; then + +$as_echo "#define const /**/" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 +$as_echo_n "checking for inline... " >&6; } +if ${ac_cv_c_inline+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_c_inline=no +for ac_kw in inline __inline__ __inline; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifndef __cplusplus +typedef int foo_t; +static $ac_kw foo_t static_foo () {return 0; } +$ac_kw foo_t foo () {return 0; } +#endif + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_inline=$ac_kw +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + test "$ac_cv_c_inline" != no && break +done + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 +$as_echo "$ac_cv_c_inline" >&6; } + +case $ac_cv_c_inline in + inline | yes) ;; + *) + case $ac_cv_c_inline in + no) ac_val=;; + *) ac_val=$ac_cv_c_inline;; + esac + cat >>confdefs.h <<_ACEOF +#ifndef __cplusplus +#define inline $ac_val +#endif +_ACEOF + ;; +esac + +# Check whether --enable-largefile was given. +if test "${enable_largefile+set}" = set; then : + enableval=$enable_largefile; +fi + +if test "$enable_largefile" != no; then + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5 +$as_echo_n "checking for special C compiler options needed for large files... " >&6; } +if ${ac_cv_sys_largefile_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_sys_largefile_CC=no + if test "$GCC" != yes; then + ac_save_CC=$CC + while :; do + # IRIX 6.2 and later do not support large files by default, + # so use the C compiler's -n32 option if that helps. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF + if ac_fn_c_try_compile "$LINENO"; then : + break +fi +rm -f core conftest.err conftest.$ac_objext + CC="$CC -n32" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_largefile_CC=' -n32'; break +fi +rm -f core conftest.err conftest.$ac_objext + break + done + CC=$ac_save_CC + rm -f conftest.$ac_ext + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5 +$as_echo "$ac_cv_sys_largefile_CC" >&6; } + if test "$ac_cv_sys_largefile_CC" != no; then + CC=$CC$ac_cv_sys_largefile_CC + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5 +$as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; } +if ${ac_cv_sys_file_offset_bits+:} false; then : + $as_echo_n "(cached) " >&6 +else + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_file_offset_bits=no; break +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#define _FILE_OFFSET_BITS 64 +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_file_offset_bits=64; break +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cv_sys_file_offset_bits=unknown + break +done +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5 +$as_echo "$ac_cv_sys_file_offset_bits" >&6; } +case $ac_cv_sys_file_offset_bits in #( + no | unknown) ;; + *) +cat >>confdefs.h <<_ACEOF +#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits +_ACEOF +;; +esac +rm -rf conftest* + if test $ac_cv_sys_file_offset_bits = unknown; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5 +$as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; } +if ${ac_cv_sys_large_files+:} false; then : + $as_echo_n "(cached) " >&6 +else + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_large_files=no; break +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#define _LARGE_FILES 1 +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_large_files=1; break +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cv_sys_large_files=unknown + break +done +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5 +$as_echo "$ac_cv_sys_large_files" >&6; } +case $ac_cv_sys_large_files in #( + no | unknown) ;; + *) +cat >>confdefs.h <<_ACEOF +#define _LARGE_FILES $ac_cv_sys_large_files +_ACEOF +;; +esac +rm -rf conftest* + fi + + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGEFILE_SOURCE value needed for large files" >&5 +$as_echo_n "checking for _LARGEFILE_SOURCE value needed for large files... " >&6; } +if ${ac_cv_sys_largefile_source+:} false; then : + $as_echo_n "(cached) " >&6 +else + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include /* for off_t */ + #include +int +main () +{ +int (*fp) (FILE *, off_t, int) = fseeko; + return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_sys_largefile_source=no; break +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#define _LARGEFILE_SOURCE 1 +#include /* for off_t */ + #include +int +main () +{ +int (*fp) (FILE *, off_t, int) = fseeko; + return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_sys_largefile_source=1; break +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + ac_cv_sys_largefile_source=unknown + break +done +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_source" >&5 +$as_echo "$ac_cv_sys_largefile_source" >&6; } +case $ac_cv_sys_largefile_source in #( + no | unknown) ;; + *) +cat >>confdefs.h <<_ACEOF +#define _LARGEFILE_SOURCE $ac_cv_sys_largefile_source +_ACEOF +;; +esac +rm -rf conftest* + +# We used to try defining _XOPEN_SOURCE=500 too, to work around a bug +# in glibc 2.1.3, but that breaks too many other things. +# If you want fseeko and ftello with glibc, upgrade to a fixed glibc. +if test $ac_cv_sys_largefile_source != unknown; then + +$as_echo "#define HAVE_FSEEKO 1" >>confdefs.h + +fi + + +ac_fn_c_check_type "$LINENO" "u_int8_t" "ac_cv_type_u_int8_t" "$ac_includes_default" +if test "x$ac_cv_type_u_int8_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define u_int8_t uint8_t +_ACEOF + +fi + +ac_fn_c_check_type "$LINENO" "u_int16_t" "ac_cv_type_u_int16_t" "$ac_includes_default" +if test "x$ac_cv_type_u_int16_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define u_int16_t uint16_t +_ACEOF + +fi + +ac_fn_c_check_type "$LINENO" "u_int32_t" "ac_cv_type_u_int32_t" "$ac_includes_default" +if test "x$ac_cv_type_u_int32_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define u_int32_t uint32_t +_ACEOF + +fi + +ac_fn_c_check_type "$LINENO" "u_int64_t" "ac_cv_type_u_int64_t" "$ac_includes_default" +if test "x$ac_cv_type_u_int64_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define u_int64_t uint64_t +_ACEOF + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC -Wextra support" >&5 +$as_echo_n "checking for $CC -Wextra support... " >&6; } +OLD_CFLAGS=$CFLAGS +CFLAGS="$CFLAGS -Wextra" +wextra="" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + int main(int argc, char *argv) { return(0); } +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + wextra="-Wextra" +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS="$OLD_CFLAGS $wextra" + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC -Wno-variadic-macros support" >&5 +$as_echo_n "checking for $CC -Wno-variadic-macros support... " >&6; } +OLD_CFLAGS=$CFLAGS +CFLAGS="$CFLAGS -Wno-variadic-macros" +wno_variadic_macros="" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + int main(int argc, char *argv) { return(0); } +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + wno_variadic_macros="-Wno-variadic-macros" +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS="$OLD_CFLAGS $wno_variadic_macros" + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC -Wfatal-errors support" >&5 +$as_echo_n "checking for $CC -Wfatal-errors support... " >&6; } +OLD_CFLAGS=$CFLAGS +CFLAGS="$CFLAGS -Wfatal-errors" +wfatal_errors="" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + int main(int argc, char *argv) { return(0); } +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + wfatal_errors="-Wfatal-errors" +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS="$OLD_CFLAGS $wfatal_errors" + + +for ac_header in fcntl.h stddef.h sys/socket.h arpa/inet.h sys/time.h signal.h string.h strings.h sys/types.h stdint.h sys/select.h netinet/in.h poll.h sys/poll.h unistd.h sys/param.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +for ac_header in sys/sysctl.h net/route.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" " +#if HAVE_SYS_PARAM_H +#include +#endif +#if HAVE_SYS_TYPES_H +#include +#endif +#if HAVE_SYS_SOCKET_H +#include +#endif + +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lsocket" >&5 +$as_echo_n "checking for socket in -lsocket... " >&6; } +if ${ac_cv_lib_socket_socket+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsocket $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char socket (); +int +main () +{ +return socket (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_socket_socket=yes +else + ac_cv_lib_socket_socket=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_socket" >&5 +$as_echo "$ac_cv_lib_socket_socket" >&6; } +if test "x$ac_cv_lib_socket_socket" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSOCKET 1 +_ACEOF + + LIBS="-lsocket $LIBS" + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lnsl" >&5 +$as_echo_n "checking for gethostbyname in -lnsl... " >&6; } +if ${ac_cv_lib_nsl_gethostbyname+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lnsl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char gethostbyname (); +int +main () +{ +return gethostbyname (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_nsl_gethostbyname=yes +else + ac_cv_lib_nsl_gethostbyname=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostbyname" >&5 +$as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; } +if test "x$ac_cv_lib_nsl_gethostbyname" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBNSL 1 +_ACEOF + + LIBS="-lnsl $LIBS" + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for nanosleep in -lrt" >&5 +$as_echo_n "checking for nanosleep in -lrt... " >&6; } +if ${ac_cv_lib_rt_nanosleep+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lrt $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char nanosleep (); +int +main () +{ +return nanosleep (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_rt_nanosleep=yes +else + ac_cv_lib_rt_nanosleep=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_nanosleep" >&5 +$as_echo "$ac_cv_lib_rt_nanosleep" >&6; } +if test "x$ac_cv_lib_rt_nanosleep" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBRT 1 +_ACEOF + + LIBS="-lrt $LIBS" + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for resolv in -lresolv" >&5 +$as_echo_n "checking for resolv in -lresolv... " >&6; } +if ${ac_cv_lib_resolv_resolv+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lresolv $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char resolv (); +int +main () +{ +return resolv (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_resolv_resolv=yes +else + ac_cv_lib_resolv_resolv=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_resolv_resolv" >&5 +$as_echo "$ac_cv_lib_resolv_resolv" >&6; } +if test "x$ac_cv_lib_resolv_resolv" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBRESOLV 1 +_ACEOF + + LIBS="-lresolv $LIBS" + +fi + + +for ac_header in stdlib.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" +if test "x$ac_cv_header_stdlib_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_STDLIB_H 1 +_ACEOF + +fi + +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible malloc" >&5 +$as_echo_n "checking for GNU libc compatible malloc... " >&6; } +if ${ac_cv_func_malloc_0_nonnull+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ac_cv_func_malloc_0_nonnull=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#if defined STDC_HEADERS || defined HAVE_STDLIB_H +# include +#else +char *malloc (); +#endif + +int +main () +{ +return ! malloc (0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_func_malloc_0_nonnull=yes +else + ac_cv_func_malloc_0_nonnull=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_malloc_0_nonnull" >&5 +$as_echo "$ac_cv_func_malloc_0_nonnull" >&6; } +if test $ac_cv_func_malloc_0_nonnull = yes; then : + +$as_echo "#define HAVE_MALLOC 1" >>confdefs.h + +else + $as_echo "#define HAVE_MALLOC 0" >>confdefs.h + + case " $LIBOBJS " in + *" malloc.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS malloc.$ac_objext" + ;; +esac + + +$as_echo "#define malloc rpl_malloc" >>confdefs.h + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working memcmp" >&5 +$as_echo_n "checking for working memcmp... " >&6; } +if ${ac_cv_func_memcmp_working+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ac_cv_func_memcmp_working=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ + + /* Some versions of memcmp are not 8-bit clean. */ + char c0 = '\100', c1 = '\200', c2 = '\201'; + if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0) + return 1; + + /* The Next x86 OpenStep bug shows up only when comparing 16 bytes + or more and with at least one buffer not starting on a 4-byte boundary. + William Lewis provided this test program. */ + { + char foo[21]; + char bar[21]; + int i; + for (i = 0; i < 4; i++) + { + char *a = foo + i; + char *b = bar + i; + strcpy (a, "--------01111111"); + strcpy (b, "--------10000000"); + if (memcmp (a, b, 16) >= 0) + return 1; + } + return 0; + } + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_func_memcmp_working=yes +else + ac_cv_func_memcmp_working=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_memcmp_working" >&5 +$as_echo "$ac_cv_func_memcmp_working" >&6; } +test $ac_cv_func_memcmp_working = no && case " $LIBOBJS " in + *" memcmp.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS memcmp.$ac_objext" + ;; +esac + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5 +$as_echo_n "checking return type of signal handlers... " >&6; } +if ${ac_cv_type_signal+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include + +int +main () +{ +return *(signal (0, 0)) (0) == 1; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_type_signal=int +else + ac_cv_type_signal=void +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5 +$as_echo "$ac_cv_type_signal" >&6; } + +cat >>confdefs.h <<_ACEOF +#define RETSIGTYPE $ac_cv_type_signal +_ACEOF + + +for ac_func in vprintf +do : + ac_fn_c_check_func "$LINENO" "vprintf" "ac_cv_func_vprintf" +if test "x$ac_cv_func_vprintf" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_VPRINTF 1 +_ACEOF + +ac_fn_c_check_func "$LINENO" "_doprnt" "ac_cv_func__doprnt" +if test "x$ac_cv_func__doprnt" = xyes; then : + +$as_echo "#define HAVE_DOPRNT 1" >>confdefs.h + +fi + +fi +done + + +ac_fn_c_check_member "$LINENO" "struct timeval" "tv_sec" "ac_cv_member_struct_timeval_tv_sec" "$ac_includes_default" +if test "x$ac_cv_member_struct_timeval_tv_sec" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_TIMEVAL_TV_SEC 1 +_ACEOF + + +fi + + +for ac_func in gettimeofday ctime memset regcomp strdup strchr strerror strtol strncpy strtoull poll ntohll mmap snprintf vsnprintf strsignal +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + +for ac_func in strlcpy +do : + ac_fn_c_check_func "$LINENO" "strlcpy" "ac_cv_func_strlcpy" +if test "x$ac_cv_func_strlcpy" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_STRLCPY 1 +_ACEOF + have_strlcpy=true +else + have_strlcpy=false +fi +done + + if test x$have_strlcpy = xtrue; then + SYSTEM_STRLCPY_TRUE= + SYSTEM_STRLCPY_FALSE='#' +else + SYSTEM_STRLCPY_TRUE='#' + SYSTEM_STRLCPY_FALSE= +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 +$as_echo_n "checking whether byte ordering is bigendian... " >&6; } +if ${ac_cv_c_bigendian+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_c_bigendian=unknown + # See if we're dealing with a universal compiler. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifndef __APPLE_CC__ + not a universal capable compiler + #endif + typedef int dummy; + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + # Check for potential -arch flags. It is not universal unless + # there are at least two -arch flags with different values. + ac_arch= + ac_prev= + for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do + if test -n "$ac_prev"; then + case $ac_word in + i?86 | x86_64 | ppc | ppc64) + if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then + ac_arch=$ac_word + else + ac_cv_c_bigendian=universal + break + fi + ;; + esac + ac_prev= + elif test "x$ac_word" = "x-arch"; then + ac_prev=arch + fi + done +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if test $ac_cv_c_bigendian = unknown; then + # See if sys/param.h defines the BYTE_ORDER macro. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + +int +main () +{ +#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ + && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ + && LITTLE_ENDIAN) + bogus endian macros + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + # It does; now see whether it defined to BIG_ENDIAN or not. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + +int +main () +{ +#if BYTE_ORDER != BIG_ENDIAN + not big endian + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_bigendian=yes +else + ac_cv_c_bigendian=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi + if test $ac_cv_c_bigendian = unknown; then + # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) + bogus endian macros + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + # It does; now see whether it defined to _BIG_ENDIAN or not. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +#ifndef _BIG_ENDIAN + not big endian + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_bigendian=yes +else + ac_cv_c_bigendian=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi + if test $ac_cv_c_bigendian = unknown; then + # Compile a test program. + if test "$cross_compiling" = yes; then : + # Try to guess by grepping values from an object file. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +short int ascii_mm[] = + { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; + short int ascii_ii[] = + { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; + int use_ascii (int i) { + return ascii_mm[i] + ascii_ii[i]; + } + short int ebcdic_ii[] = + { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; + short int ebcdic_mm[] = + { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; + int use_ebcdic (int i) { + return ebcdic_mm[i] + ebcdic_ii[i]; + } + extern int foo; + +int +main () +{ +return use_ascii (foo) == use_ebcdic (foo); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then + ac_cv_c_bigendian=yes + fi + if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then + if test "$ac_cv_c_bigendian" = unknown; then + ac_cv_c_bigendian=no + else + # finding both strings is unlikely to happen, but who knows? + ac_cv_c_bigendian=unknown + fi + fi +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ + + /* Are we little or big endian? From Harbison&Steele. */ + union + { + long int l; + char c[sizeof (long int)]; + } u; + u.l = 1; + return u.c[sizeof (long int) - 1] == 1; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_c_bigendian=no +else + ac_cv_c_bigendian=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 +$as_echo "$ac_cv_c_bigendian" >&6; } + case $ac_cv_c_bigendian in #( + yes) + $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h +;; #( + no) + ;; #( + universal) + +$as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h + + ;; #( + *) + as_fn_error $? "unknown endianness + presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; + esac + + if test x$ac_cv_c_bigendian = xyes ; then + WORDS_BIGENDIAN_TRUE= + WORDS_BIGENDIAN_FALSE='#' +else + WORDS_BIGENDIAN_TRUE='#' + WORDS_BIGENDIAN_FALSE= +fi + + + +debug=no +# Check whether --enable-debug was given. +if test "${enable_debug+set}" = set; then : + enableval=$enable_debug; if test x$enableval = xyes; then + debug=yes + CFLAGS="${USER_CFLAGS} -ggdb -std=gnu99 -Wall $wextra $wfatal_errors $wno_variadic_macros" +# We may also want to add: +# -Wformat-security -Wswitch-default -Wunused-paramter -Wpadded" + + +$as_echo "#define DEBUG 1" >>confdefs.h + + fi +fi + + + +# Check whether --enable-dmalloc was given. +if test "${enable_dmalloc+set}" = set; then : + enableval=$enable_dmalloc; if test x$enableval = xyes ; then + dmalloc=yes + +$as_echo "#define ENABLE_DMALLOC 1" >>confdefs.h + + +$as_echo "#define DMALLOC_FUNC_CHECK 1" >>confdefs.h + + CFLAGS="${CFLAGS} -I/opt/local/include" + DMALLOC_LIB="/opt/local/lib/libdmalloc.a" + + fi +fi + + + +# Check whether --enable-pedantic was given. +if test "${enable_pedantic+set}" = set; then : + enableval=$enable_pedantic; if test x$enableval = xyes; then + CFLAGS="$CFLAGS -pedantic" + fi +fi + + +# Check whether --enable-efence was given. +if test "${enable_efence+set}" = set; then : + enableval=$enable_efence; if test x$enableval = xyes; then + CFLAGS="$CFLAGS -lefence" + +$as_echo "#define EFENCE 1" >>confdefs.h + + fi +fi + + +# Check whether --enable-gprof was given. +if test "${enable_gprof+set}" = set; then : + enableval=$enable_gprof; if test x$enableval = xyes; then + if test $debug = yes; then + CFLAGS="$CFLAGS -pg" + else + # GPROF requires gdb + CFLAGS="$CFLAGS -ggdb -pg -fprofile-arcs" + fi + +$as_echo "#define GPROF 1" >>confdefs.h + + fi +fi + + +use64bit_counters=yes +# Check whether --enable-64bits was given. +if test "${enable_64bits+set}" = set; then : + enableval=$enable_64bits; + { $as_echo "$as_me:${as_lineno-$LINENO}: Using u_int32_t for packet counters" >&5 +$as_echo "$as_me: Using u_int32_t for packet counters" >&6;} + +else + + +$as_echo "#define ENABLE_64BITS 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: Using u_int64_t for packet counters" >&5 +$as_echo "$as_me: Using u_int64_t for packet counters" >&6;} + +fi + + + +# If we're running gcc add '-D_U_="__attribute__((unused))"' to CFLAGS as well, +# so we can use _U_ to flag unused function arguments and not get warnings +# about them. Otherwise, add '-D_U_=""', so that _U_ used to flag an unused +# function argument will compile with non-GCC compilers. +# +if test "x$GCC" = "xyes" ; then + CFLAGS="-D_U_=\"__attribute__((unused))\" $CFLAGS" +else + CFLAGS="-D_U_=\"\" $CFLAGS" +fi + + +# Check whether --enable-force-bpf was given. +if test "${enable_force_bpf+set}" = set; then : + enableval=$enable_force_bpf; +$as_echo "#define FORCE_INJECT_BPF 1" >>confdefs.h + +fi + + +# Check whether --enable-force-pf was given. +if test "${enable_force_pf+set}" = set; then : + enableval=$enable_force_pf; +$as_echo "#define FORCE_INJECT_PF 1" >>confdefs.h + +fi + + +# Check whether --enable-force-libdnet was given. +if test "${enable_force_libdnet+set}" = set; then : + enableval=$enable_force_libdnet; +$as_echo "#define FORCE_INJECT_LIBDNET 1" >>confdefs.h + +fi + + +# Check whether --enable-force-inject was given. +if test "${enable_force_inject+set}" = set; then : + enableval=$enable_force_inject; +$as_echo "#define FORCE_INJECT_PCAP_INJECT 1" >>confdefs.h + +fi + + +# Check whether --enable-force-sendpacket was given. +if test "${enable_force_sendpacket+set}" = set; then : + enableval=$enable_force_sendpacket; +$as_echo "#define FORCE_INJECT_PCAP_SENDPACKET 1" >>confdefs.h + +fi + + +dynamic_link=no +# Check whether --enable-dynamic-link was given. +if test "${enable_dynamic_link+set}" = set; then : + enableval=$enable_dynamic_link; if test x$enableval = xyes; then + +$as_echo "#define ENABLE_DYNAMIC_LINK 1" >>confdefs.h + + dynamic_link=yes + fi + +fi + + +ac_fn_c_check_func "$LINENO" "inet_aton" "ac_cv_func_inet_aton" +if test "x$ac_cv_func_inet_aton" = xyes; then : + +$as_echo "#define HAVE_INET_ATON 1" >>confdefs.h + + inet_aton=yes +else + inet_aton=no +fi + +ac_fn_c_check_func "$LINENO" "inet_pton" "ac_cv_func_inet_pton" +if test "x$ac_cv_func_inet_pton" = xyes; then : + +$as_echo "#define HAVE_INET_PTON 1" >>confdefs.h + + inet_pton=yes +else + inet_pton=no +fi + +ac_fn_c_check_func "$LINENO" "inet_ntop" "ac_cv_func_inet_ntop" +if test "x$ac_cv_func_inet_ntop" = xyes; then : + +$as_echo "#define HAVE_INET_NTOP 1" >>confdefs.h + + inet_ntop=yes +else + inet_ntop=no +fi + + +if test "$inet_ntop" = "no" -a "$inet_pton" = "no" ; then + as_fn_error $? "We need either inet_ntop or inet_pton" "$LINENO" 5 +fi + +ac_fn_c_check_func "$LINENO" "inet_addr" "ac_cv_func_inet_addr" +if test "x$ac_cv_func_inet_addr" = xyes; then : + +$as_echo "#define HAVE_INET_ADDR 1" >>confdefs.h + + inet_addr=yes +else + inet_addr=no +fi + + +if test x$inet_addr = no ; then + as_fn_error $? "We need inet_addr. See bug 26" "$LINENO" 5 +fi + +foundpcap=no +trypcapdir=/usr/local +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libpcap" >&5 +$as_echo_n "checking for libpcap... " >&6; } + +# Check whether --with-libpcap was given. +if test "${with_libpcap+set}" = set; then : + withval=$with_libpcap; trypcapdir=$withval +fi + + +for testdir in $trypcapdir /usr/local /opt/local /usr /wpdpack ; do + if test -f "${testdir}/include/pcap.h" -a $foundpcap = no ; then + LPCAPINC="${testdir}/include/pcap.h" + LPCAPINCDIR="${testdir}/include" + if test $dynamic_link = yes; then + if test -f "${testdir}/lib64/libpcap${shrext_cmds}" ; then + LPCAPLIB="-L${testdir}/lib64 -lpcap" + elif test -f "${testdir}/lib/libpcap${shrext_cmds}" ; then + LPCAPLIB="-L${testdir}/lib -lpcap" + else + as_fn_error $? "Unable to find libpcap in ${testdir}" "$LINENO" 5 + fi + elif test -f "${testdir}/lib64/libpcap.${libext}" ; then + LPCAPLIB="${testdir}/lib64/libpcap.${libext}" + elif test -f "${testdir}/lib/libpcap.${libext}" ; then + LPCAPLIB="${testdir}/lib/libpcap.${libext}" + elif test -f "${testdir}/lib/libwpcap.${libext}" ; then + LPCAPLIB="${testdir}/lib/libwpcap.${libext}" + +$as_echo "#define HAVE_WINPCAP 1" >>confdefs.h + + else + as_fn_error $? "Unable to find matching library for header file in ${testdir}" "$LINENO" 5 + fi + foundpcap=$testdir + fi +done + +if test $foundpcap = no ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + as_fn_error $? "libpcap not found" "$LINENO" 5 +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $foundpcap" >&5 +$as_echo "$foundpcap" >&6; } +fi + +OLDLIBS="$LIBS" +OLDCFLAGS="$CFLAGS -I$LPCAPINCDIR" +LIBS="$LPCAPLIB" +CFLAGS="$CFLAGS -I$LPCAPINCDIR" + +# Does libpcap require libnl? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pcap_close" >&5 +$as_echo_n "checking for library containing pcap_close... " >&6; } +if ${ac_cv_search_pcap_close+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pcap_close (); +int +main () +{ +return pcap_close (); + ; + return 0; +} +_ACEOF +for ac_lib in '' pcap; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib -lnl $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_pcap_close=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_pcap_close+:} false; then : + break +fi +done +if ${ac_cv_search_pcap_close+:} false; then : + +else + ac_cv_search_pcap_close=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_pcap_close" >&5 +$as_echo "$ac_cv_search_pcap_close" >&6; } +ac_res=$ac_cv_search_pcap_close +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + LPCAPLIB="$LIBS" +else + as_fn_error $? "Unable to link libpcap in ${foundpcap}" "$LINENO" 5 +fi + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libpcap version" >&5 +$as_echo_n "checking for libpcap version... " >&6; } + +libpcap_version_096=no +if test "$cross_compiling" = yes; then : + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run test program while cross compiling +See \`config.log' for more details" "$LINENO" 5; } +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include "$LPCAPINC" +#define PCAP_TEST "0.9.6" + +int +main () +{ + +/* + * simple proggy to test the version of libpcap + * returns zero if version >= 0.9.6 + * or one otherwise + */ + if (strncmp(pcap_lib_version(), PCAP_TEST, 5) >= 0) + exit(0); + + exit(1); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + + libpcap_version_096=yes + +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + +libpcap_ver8=no +if test "$cross_compiling" = yes; then : + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run test program while cross compiling +See \`config.log' for more details" "$LINENO" 5; } +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include "$LPCAPINC" +#define PCAP_TEST "0.8" + +int +main () +{ + +/* + * simple proggy to test the version of libpcap + * returns zero if version >= 0.8.0 + * or one otherwise + */ + if (strncmp(pcap_lib_version(), PCAP_TEST, 3) >= 0) + exit(0); + + /* winpcap? */ + if (strncmp(pcap_lib_version(), "WinPcap", 7) == 0) + exit(0); + + exit(1); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + + libpcap_ver8=yes + +else + + libpcap_ver8=no + +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + +libpcap_ver7=no +if test "$cross_compiling" = yes; then : + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run test program while cross compiling +See \`config.log' for more details" "$LINENO" 5; } +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include "$LPCAPINC" +#define PCAP_TEST "0.7.2" +extern const char pcap_version[]; /* double up since autoconf escapes things */ + +int +main () +{ + +/* + * simple proggy to test the version of libpcap + * returns zero if version >= 0.7.2 + * or one otherwise + */ + + if (strncmp(pcap_version, PCAP_TEST, 5) >= 0) + exit(0); + + exit(1); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + + libpcap_ver7=yes + +else + + libpcap_ver7=no + +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + +if test x$libpcap_ver8 = xyes ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: >= 0.8.0" >&5 +$as_echo ">= 0.8.0" >&6; } +elif test x$libpcap_ver7 = xyes ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: >= 0.7.2" >&5 +$as_echo ">= 0.7.2" >&6; } +else + as_fn_error $? "Libpcap versions < 0.7.2 are not supported + Please upgrade to version 0.7.2 or better" "$LINENO" 5 +fi + +libpcap_version=unknown +if test x$libpcap_version_096 = xyes ; then + libpcap_version=">= 0.9.6" +elif test x$libpcap_ver8 = xyes ; then + libpcap_version=">= 0.8.0" +elif test x$libcap_ver7 = xyes ; then + libpcap_version=">= 0.7.0" +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcap_setnonblock" >&5 +$as_echo_n "checking for pcap_setnonblock... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include "$LPCAPINC" + +int +main () +{ + + pcap_t *p; + char *errbuf; + + pcap_setnonblock(p, 1, errbuf); + exit(0); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + + have_pcap_setnonblock=yes + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +else + + have_pcap_setnonblock=no + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +if test $have_pcap_setnonblock = yes ; then + +$as_echo "#define HAVE_PCAP_SETNONBLOCK 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcap_datalink_val_to_description" >&5 +$as_echo_n "checking for pcap_datalink_val_to_description... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include "$LPCAPINC" + +int +main () +{ + + if (strcmp(pcap_datalink_val_to_description(1), "Ethernet (10Mb)") == 0) + exit(0); + exit(1); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + + have_dlt_to_desc=yes + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +else + + have_dlt_to_desc=no + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +if test $have_dlt_to_desc = yes ; then + +$as_echo "#define HAVE_DLT_VAL_TO_DESC 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcap_get_selectable_fd" >&5 +$as_echo_n "checking for pcap_get_selectable_fd... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include "$LPCAPINC" + +int +main () +{ + + int f; + pcap_t *p; + f = pcap_get_selectable_fd(p); + exit(0); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + + have_pcap_get_selectable_fd=yes + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +else + + have_pcap_get_selectable_fd=no + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +if test x$have_pcap_get_selectable_fd = xyes ; then + +$as_echo "#define HAVE_PCAP_GET_SELECTABLE_FD 1" >>confdefs.h + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcap_dump_fopen" >&5 +$as_echo_n "checking for pcap_dump_fopen... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include "$LPCAPINC" + +int +main () +{ + + pcap_dumper_t *dump; + pcap_t *pcap; + FILE *foo; + dump = pcap_dump_fopen(pcap, foo); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + + have_pcap_dump_fopen=yes + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +else + + have_pcap_dump_fopen=no + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +if test $have_pcap_dump_fopen = yes ; then + +$as_echo "#define HAVE_PCAP_DUMP_FOPEN 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: --verbose mode requires libpcap >= 0.9.0" >&5 +$as_echo "$as_me: --verbose mode requires libpcap >= 0.9.0" >&6;} +fi + +have_pcap_inject=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcap_inject sending support" >&5 +$as_echo_n "checking for pcap_inject sending support... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include "$LPCAPINC" + +int +main () +{ + + pcap_t *pcap; + char *buf; + pcap_inject(pcap, (void *)buf, 0); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + + have_pcap_inject=yes + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +else + + have_pcap_inject=no + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +if test $have_pcap_inject = yes ; then + +$as_echo "#define HAVE_PCAP_INJECT 1" >>confdefs.h + +fi + +have_pcap_sendpacket=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcap_sendpacket sending support" >&5 +$as_echo_n "checking for pcap_sendpacket sending support... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include "$LPCAPINC" + +int +main () +{ + + pcap_t *pcap; + u_char *buf; + pcap_sendpacket(pcap, buf, 0); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + + have_pcap_sendpacket=yes + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +else + + have_pcap_sendpacket=no + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +if test $have_pcap_sendpacket = yes ; then + +$as_echo "#define HAVE_PCAP_SENDPACKET 1" >>confdefs.h + +fi + +have_pcap_breakloop=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcap_breakloop" >&5 +$as_echo_n "checking for pcap_breakloop... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include "$LPCAPINC" + +int +main () +{ + + pcap_t *pcap; + pcap_sendpacket(pcap); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + + have_pcap_breakloop=yes + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +else + + have_pcap_breakloop=no + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +if test $have_pcap_breakloop = yes ; then + +$as_echo "#define HAVE_PCAP_BREAKLOOP 1" >>confdefs.h + +fi + + +have_pcap_version=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcap_version" >&5 +$as_echo_n "checking for pcap_version... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include "$LPCAPINC" +extern char pcap_version[]; + +int +main () +{ + + printf("%s", pcap_version); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + +$as_echo "#define HAVE_PCAP_VERSION 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +have_pcap_snapshot=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcap_snapshot" >&5 +$as_echo_n "checking for pcap_snapshot... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include "$LPCAPINC" + +int +main () +{ + + pcap_t *p; + int len; + + len = pcap_snapshot(p); + exit(0); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + + have_pcap_snapshot=yes + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +else + + have_pcap_snapshot=no + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +if test $have_pcap_snapshot = yes ; then + +$as_echo "#define HAVE_PCAP_SNAPSHOT 1" >>confdefs.h + +fi + + +# Tcpbridge requires libpcap and pcap_sendpacket() +enable_tcpbridge=no +if test x$foundpcap != xno -a x$have_pcap_sendpacket = xyes ; then + + # if we have pcap_sendpacket() then we can build tcpbridge on non-BPF systems + if test x$have_bpf = xno; then + +$as_echo "#define ENABLE_TCPBRIDGE 1" >>confdefs.h + + enable_tcpbridge=yes + { $as_echo "$as_me:${as_lineno-$LINENO}: Building tcpbridge" >&5 +$as_echo "$as_me: Building tcpbridge" >&6;} + + # BPF systems need to also have pcap_setnonblock() + elif test x$have_pcap_setnonblock = xyes ; then + +$as_echo "#define ENABLE_TCPBRIDGE 1" >>confdefs.h + + enable_tcpbridge=yes + { $as_echo "$as_me:${as_lineno-$LINENO}: Building tcpbridge" >&5 +$as_echo "$as_me: Building tcpbridge" >&6;} + else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to build tcpbridge. Try installing latest libpcap!" >&5 +$as_echo "$as_me: WARNING: Unable to build tcpbridge. Try installing latest libpcap!" >&2;} + fi +fi + if test x$enable_tcpbridge = xyes ; then + COMPILE_TCPBRIDGE_TRUE= + COMPILE_TCPBRIDGE_FALSE='#' +else + COMPILE_TCPBRIDGE_TRUE='#' + COMPILE_TCPBRIDGE_FALSE= +fi + + + + +have_pf=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PF_PACKET socket sending support" >&5 +$as_echo_n "checking for PF_PACKET socket sending support... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include /* the L2 protocols */ +#include /* htons */ + +int +main () +{ + + int pf_socket; + pf_socket = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + +$as_echo "#define HAVE_PF_PACKET 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + have_pf=yes + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +have_bpf=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BPF device sending support" >&5 +$as_echo_n "checking for BPF device sending support... " >&6; } +if test "$cross_compiling" = yes; then : + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run test program while cross compiling +See \`config.log' for more details" "$LINENO" 5; } +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int +main(int argc, char *argv[]) { + int fd; + + fd = open("/dev/bpf0", O_RDONLY, 0); + + /* if we opened it, we're good */ + if (fd > 1) + exit(0); + + /* if we got EBUSY or permission denied it exists, so we're good */ + if (fd < 0 && (errno == EBUSY || errno == 13)) + exit(0); + + /* else suck, no good */ + exit(-1); +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + + +$as_echo "#define HAVE_BPF 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + have_bpf=yes + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + + +founddnet=no +have_libdnet=no +libdnet_version= +enable_fragroute=no +trydnetdir=/usr/local + +if test $have_cygwin == no ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libdnet" >&5 +$as_echo_n "checking for libdnet... " >&6; } + +# Check whether --with-libdnet was given. +if test "${with_libdnet+set}" = set; then : + withval=$with_libdnet; trydnetdir=$withval +fi + + + for testdir in $trydnetdir /usr/local /opt/local /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 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libdnet not found, disabling fragroute feature" >&5 +$as_echo "$as_me: WARNING: libdnet not found, disabling fragroute feature" >&2;} + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $founddnet" >&5 +$as_echo "$founddnet" >&6; } + enable_fragroute=yes + have_libdnet=yes + +$as_echo "#define HAVE_LIBDNET 1" >>confdefs.h + + fi + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: Skipping libdnet check under Cygwin for compatibility reasons" >&5 +$as_echo "$as_me: Skipping libdnet check under Cygwin for compatibility reasons" >&6;} +fi + + + + + +cat >>confdefs.h <<_ACEOF +#define LIBDNET_VERSION "$libdnet_version" +_ACEOF + + + if test x$founddnet != xno; then + COMPILE_FRAGROUTE_TRUE= + COMPILE_FRAGROUTE_FALSE='#' +else + COMPILE_FRAGROUTE_TRUE='#' + COMPILE_FRAGROUTE_FALSE= +fi + +if test x$founddnet != xno ; then + +$as_echo "#define ENABLE_FRAGROUTE 1" >>confdefs.h + +fi + + +if test $have_bpf = no -a $have_pcap_inject = no -a $have_pcap_sendpacket = no \ + -a $have_libdnet = no -a $have_pf = no ; then + as_fn_error $? "Unable to find a supported method to send packets. Please upgrade your libpcap or enable libdnet" "$LINENO" 5 +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for DLT_LINUX_SLL in libpcap" >&5 +$as_echo_n "checking for DLT_LINUX_SLL in libpcap... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include "$LPCAPINC" +int +main () +{ + int foo; + foo = DLT_LINUX_SLL + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +$as_echo "#define HAVE_DLT_LINUX_SLL 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for DLT_C_HDLC in libpcap" >&5 +$as_echo_n "checking for DLT_C_HDLC in libpcap... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include "$LPCAPINC" +int +main () +{ + int foo; + foo = DLT_C_HDLC + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +$as_echo "#define HAVE_DLT_C_HDLC 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +PCAP_BPF_H_FILE="$LPCAPINCDIR/pcap-bpf.h" +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $PCAP_BPF_H_FILE" >&5 +$as_echo_n "checking for $PCAP_BPF_H_FILE... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + #include + #include "$PCAP_BPF_H_FILE" +int +main () +{ + int foo; + foo = BPF_MAJOR_VERSION; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +$as_echo "#define INCLUDE_PCAP_BPF_HEADER 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +foundbpfheader=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libpcap bpf header" >&5 +$as_echo_n "checking for libpcap bpf header... " >&6; } +for testfile in $LPCAPINCDIR/pcap/bpf.h $LPCAPINCDIR/pcap-bpf.h ; do + if test -f "${testfile}" -a $foundbpfheader = no ; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + #include + #include + #include "$testfile" +int +main () +{ + + int foo; + foo = BPF_MAJOR_VERSION; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + foundbpfheader=yes + PCAP_BPF_H_FILE=$testfile + + +$as_echo "#define INCLUDE_PCAP_BPF_HEADER 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $testfile" >&5 +$as_echo "$testfile" >&6; } + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi +done +LIBS="$OLDLIBS" +CFLAGS="$OLDCFLAGS" + + +pcapnav_ver=no +pcncfg=no + +# Check whether --with-pcapnav-config was given. +if test "${with_pcapnav_config+set}" = set; then : + withval=$with_pcapnav_config; { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcapnav-config" >&5 +$as_echo_n "checking for pcapnav-config... " >&6; } + if test -x $withval ; then + pcncfg=$withval + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $pcncfg" >&5 +$as_echo "$pcncfg" >&6; } + elif test x$withval = xno ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: Can't find pcapnav-config: disabling offset jump feature" >&5 +$as_echo "Can't find pcapnav-config: disabling offset jump feature" >&6; } + fi +else + # Extract the first word of "pcapnav-config", so it can be a program name with args. +set dummy pcapnav-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_pcncfg+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $pcncfg in + [\\/]* | ?:[\\/]*) + ac_cv_path_pcncfg="$pcncfg" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_pcncfg="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_path_pcncfg" && ac_cv_path_pcncfg="no " + ;; +esac +fi +pcncfg=$ac_cv_path_pcncfg +if test -n "$pcncfg"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $pcncfg" >&5 +$as_echo "$pcncfg" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + +fi + + +if test $pcncfg != no ; then + LNAVLIB=`$pcncfg --libs` + LNAV_CFLAGS=`$pcncfg --cflags` + PCAPNAV_VERSION=`$pcncfg --version` + + + +cat >>confdefs.h <<_ACEOF +#define PCAPNAV_VERSION "$PCAPNAV_VERSION" +_ACEOF + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libpcapnav version" >&5 +$as_echo_n "checking for libpcapnav version... " >&6; } + if test "$cross_compiling" = yes; then : + libpcapnav_ver=no + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#define PCAPNAV_TEST "0.4" +/* + * simple proggy to test the version of libpcapnav + * returns zero if version >= 0.4 + * or one otherwise + */ + +int +main (int argc, char *argv[]) +{ + if (strncmp(PCAPNAV_VERSION, PCAPNAV_TEST, 3) >= 0) + exit(0); + exit(1); +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + libpcapnav_ver=yes + { $as_echo "$as_me:${as_lineno-$LINENO}: result: >= 0.4" >&5 +$as_echo ">= 0.4" >&6; } +else + libpcapnav_ver=no + { $as_echo "$as_me:${as_lineno-$LINENO}: result: < 0.4" >&5 +$as_echo "< 0.4" >&6; } +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + + +if test x$libpcapnav_ver = xno ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libpcapnav versions < 0.4 are not supported. + Please upgrade to version 0.4 or better. + Disabling offset jump feature." >&5 +$as_echo "$as_me: WARNING: Libpcapnav versions < 0.4 are not supported. + Please upgrade to version 0.4 or better. + Disabling offset jump feature." >&2;} +else + +$as_echo "#define HAVE_PCAPNAV 1" >>confdefs.h + +fi + +fi # checking pcapnav version + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for requires strict byte alignment" >&5 +$as_echo_n "checking for requires strict byte alignment... " >&6; } +if ${unaligned_cv_fail+:} false; then : + $as_echo_n "(cached) " >&6 +else + case "$host_cpu" in + + # XXX: should also check that they don't do weird things (like on arm) + alpha*|arm*|hp*|mips*|sparc*|ia64) + unaligned_cv_fail=yes + ;; + + *) + cat >conftest.c < + #include + #include + unsigned char a[5] = { 1, 2, 3, 4, 5 }; + main() { + unsigned int i; + pid_t pid; + int status; + /* avoid "core dumped" message */ + pid = fork(); + if (pid < 0) + exit(2); + if (pid > 0) { + /* parent */ + pid = waitpid(pid, &status, 0); + if (pid < 0) + exit(3); + exit(!WIFEXITED(status)); + } + /* child */ + i = *(unsigned int *)&a[1]; + printf("%d\n", i); + exit(0); + } +EOF + ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \ + conftest.c $LIBS >/dev/null 2>&1 + if test ! -x conftest ; then + unaligned_cv_fail=yes + else + ./conftest >conftest.out + if test ! -s conftest.out ; then + unaligned_cv_fail=yes + else + unaligned_cv_fail=no + fi + fi + rm -f conftest* core core.conftest + ;; + + esac + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $unaligned_cv_fail" >&5 +$as_echo "$unaligned_cv_fail" >&6; } +if test $unaligned_cv_fail = yes ; then + +$as_echo "#define FORCE_ALIGN 1" >>confdefs.h + +fi + + +tcpdump_path=no + +# Check whether --with-tcpdump was given. +if test "${with_tcpdump+set}" = set; then : + withval=$with_tcpdump; if test -x $withval ; then + tcpdump_path=$withval + { $as_echo "$as_me:${as_lineno-$LINENO}: result: Using tcpdump in $tcpdump_path" >&5 +$as_echo "Using tcpdump in $tcpdump_path" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: Error: $withval does not exist or is not executable" >&5 +$as_echo "Error: $withval does not exist or is not executable" >&6; } + fi +else + # Extract the first word of "tcpdump", so it can be a program name with args. +set dummy tcpdump; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_tcpdump_path+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $tcpdump_path in + [\\/]* | ?:[\\/]*) + ac_cv_path_tcpdump_path="$tcpdump_path" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_dummy="$PATH:/usr/sbin:/sbin:/usr/local/sbin" +for as_dir in $as_dummy +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_tcpdump_path="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_path_tcpdump_path" && ac_cv_path_tcpdump_path=""no"" + ;; +esac +fi +tcpdump_path=$ac_cv_path_tcpdump_path +if test -n "$tcpdump_path"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcpdump_path" >&5 +$as_echo "$tcpdump_path" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi + + + +if test "$tcpdump_path" = "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to find tcpdump. Please specify --with-tcpdump. + Disabling --verbose" >&5 +$as_echo "$as_me: WARNING: Unable to find tcpdump. Please specify --with-tcpdump. + Disabling --verbose" >&2;} +else + +$as_echo "#define HAVE_TCPDUMP 1" >>confdefs.h + + +cat >>confdefs.h <<_ACEOF +#define TCPDUMP_BINARY "$tcpdump_path" +_ACEOF + +fi + + + if test "$tcpdump_path" != "no" -a x$have_pcap_dump_fopen = xyes; then + ENABLE_TCPDUMP_TRUE= + ENABLE_TCPDUMP_FALSE='#' +else + ENABLE_TCPDUMP_TRUE='#' + ENABLE_TCPDUMP_FALSE= +fi + +if test x$tcpdump_path != xno -a x$have_pcap_dump_fopen = xyes ; then + +$as_echo "#define ENABLE_VERBOSE 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Your version of libpcap is too old for --verbose support" >&5 +$as_echo "$as_me: WARNING: Your version of libpcap is too old for --verbose support" >&2;} +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for 'make test' profile" >&5 +$as_echo_n "checking for 'make test' profile... " >&6; } +if test "$host" != "$build" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to do tests when cross-compiling" >&5 +$as_echo "$as_me: WARNING: Unable to do tests when cross-compiling" >&2;} +fi + + +# Check whether --with-testnic was given. +if test "${with_testnic+set}" = set; then : + withval=$with_testnic; nic1=$withval + nic2=$withval + { $as_echo "$as_me:${as_lineno-$LINENO}: result: Using --with-testnic=$withval" >&5 +$as_echo "Using --with-testnic=$withval" >&6; } +else + + +disable_pcap_findalldevs=no + +osx_frameworks=no +case $host in + *-*-linux*) + nic1=eth0 + nic2=eth0 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: Linux" >&5 +$as_echo "Linux" >&6; } + ;; + + *-*-solaris*) + nic1=hme0 + nic2=hme0 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: Solaris" >&5 +$as_echo "Solaris" >&6; } + ;; + + *-*-sunos*) + nic1=hme0 + nic2=hme0 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: SunOS" >&5 +$as_echo "SunOS" >&6; } + ;; + + *-apple-darwin*) + nic1=en0 + nic2=en0 + if test x$libpcap_version_096 = xno ; then + disable_pcap_findalldevs=yes + fi + +$as_echo "#define HAVE_ABSOLUTE_TIME 1" >>confdefs.h + + osx_frameworks=yes + +$as_echo "#define HAVE_DARWIN 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: Apple OS X" >&5 +$as_echo "Apple OS X" >&6; } + ;; + + *-*-openbsd*) + nic1=xl0 + nic2=xl0 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: OpenBSD" >&5 +$as_echo "OpenBSD" >&6; } + ;; + + *-*-cygwin) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: Win32/Cygwin" >&5 +$as_echo "Win32/Cygwin" >&6; } + nic1=%0 + nic2=%0 + ;; + + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $host is unknown! Using first non-loopback interface" >&5 +$as_echo "$host is unknown! Using first non-loopback interface" >&6; } + nic1=%0 + nic2=%0 + ;; +esac +fi + + + if test "$osx_frameworks" == "yes"; then + ENABLE_OSX_FRAMEWORKS_TRUE= + ENABLE_OSX_FRAMEWORKS_FALSE='#' +else + ENABLE_OSX_FRAMEWORKS_TRUE='#' + ENABLE_OSX_FRAMEWORKS_FALSE= +fi + + + +# Check whether --with-testnic2 was given. +if test "${with_testnic2+set}" = set; then : + withval=$with_testnic2; nic2=$withval +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: Using $nic1 for 1st test network interface card" >&5 +$as_echo "$as_me: Using $nic1 for 1st test network interface card" >&6;} +{ $as_echo "$as_me:${as_lineno-$LINENO}: Using $nic2 for 2nd test network interface card" >&5 +$as_echo "$as_me: Using $nic2 for 2nd test network interface card" >&6;} + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if it's ok to use pcap_findalldevs()" >&5 +$as_echo_n "checking if it's ok to use pcap_findalldevs()... " >&6; } +if test x$disable_pcap_findalldevs = xno ; then + +$as_echo "#define ENABLE_PCAP_FINDALLDEVS 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + +case "${enable_local_libopts+set}" in + set) ;; + *) enable_local_libopts=yes ;; +esac + +case "${enable_libopts_install+set}" in + set) ;; + *) enable_libopts_install=no ;; +esac + + + NEED_LIBOPTS_DIR='' + + LIBOPTS_DIR=libopts + + # Check whether --enable-local-libopts was given. +if test "${enable_local_libopts+set}" = set; then : + enableval=$enable_local_libopts; + if test x$enableval = xyes ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Using supplied libopts tearoff" >&5 +$as_echo "$as_me: Using supplied libopts tearoff" >&6;} + LIBOPTS_LDADD='$(top_builddir)/libopts/libopts.la' + LIBOPTS_CFLAGS='-I$(top_srcdir)/libopts' + NEED_LIBOPTS_DIR=true + fi +fi + + + # Check whether --enable-libopts-install was given. +if test "${enable_libopts_install+set}" = set; then : + enableval=$enable_libopts_install; +fi + + if test "X${enable_libopts_install}" != Xno; then + INSTALL_LIBOPTS_TRUE= + INSTALL_LIBOPTS_FALSE='#' +else + INSTALL_LIBOPTS_TRUE='#' + INSTALL_LIBOPTS_FALSE= +fi + + + if test -z "${NEED_LIBOPTS_DIR}" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether autoopts-config can be found" >&5 +$as_echo_n "checking whether autoopts-config can be found... " >&6; } + +# Check whether --with-autoopts-config was given. +if test "${with_autoopts_config+set}" = set; then : + withval=$with_autoopts_config; lo_cv_with_autoopts_config=${with_autoopts_config} +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether autoopts-config is specified" >&5 +$as_echo_n "checking whether autoopts-config is specified... " >&6; } +if ${lo_cv_with_autoopts_config+:} false; then : + $as_echo_n "(cached) " >&6 +else + 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 +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lo_cv_with_autoopts_config" >&5 +$as_echo "$lo_cv_with_autoopts_config" >&6; } + +fi + # end of AC_ARG_WITH + + if ${lo_cv_test_autoopts+:} false; then : + $as_echo_n "(cached) " >&6 +else + + 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 + +fi + # end of CACHE_VAL + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lo_cv_test_autoopts}" >&5 +$as_echo "${lo_cv_test_autoopts}" >&6; } + + 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)/libopts/libopts.la' + LIBOPTS_CFLAGS='-I$(top_srcdir)/libopts' + NEED_LIBOPTS_DIR=true + fi + fi # end of if test -z "${NEED_LIBOPTS_DIR}" + + if test -n "${NEED_LIBOPTS_DIR}"; then + NEED_LIBOPTS_TRUE= + NEED_LIBOPTS_FALSE='#' +else + NEED_LIBOPTS_TRUE='#' + NEED_LIBOPTS_FALSE= +fi + + + + LIBOPTS_DIR=libopts + + ac_config_files="$ac_config_files libopts/Makefile" + + + + if test -n "${NEED_LIBOPTS_DIR}" ; then + + +if test X${INVOKE_LIBOPTS_MACROS_FIRST_done} != Xyes ; then + # ================= + # AC_HEADER_STDC + # ================= + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + + # ================= + # AC_HEADER_DIRENT + # ================= + ac_header_dirent=no +for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do + as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5 +$as_echo_n "checking for $ac_hdr that defines DIR... " >&6; } +if eval \${$as_ac_Header+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include <$ac_hdr> + +int +main () +{ +if ((DIR *) 0) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$as_ac_Header=yes" +else + eval "$as_ac_Header=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$as_ac_Header + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_hdr" | $as_tr_cpp` 1 +_ACEOF + +ac_header_dirent=$ac_hdr; break +fi + +done +# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. +if test $ac_header_dirent = dirent.h; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5 +$as_echo_n "checking for library containing opendir... " >&6; } +if ${ac_cv_search_opendir+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char opendir (); +int +main () +{ +return opendir (); + ; + return 0; +} +_ACEOF +for ac_lib in '' dir; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_opendir=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_opendir+:} false; then : + break +fi +done +if ${ac_cv_search_opendir+:} false; then : + +else + ac_cv_search_opendir=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5 +$as_echo "$ac_cv_search_opendir" >&6; } +ac_res=$ac_cv_search_opendir +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5 +$as_echo_n "checking for library containing opendir... " >&6; } +if ${ac_cv_search_opendir+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char opendir (); +int +main () +{ +return opendir (); + ; + return 0; +} +_ACEOF +for ac_lib in '' x; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_opendir=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_opendir+:} false; then : + break +fi +done +if ${ac_cv_search_opendir+:} false; then : + +else + ac_cv_search_opendir=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5 +$as_echo "$ac_cv_search_opendir" >&6; } +ac_res=$ac_cv_search_opendir +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + +fi + + + # ================= + # AC_CHECK_HEADERS + # ================= + for ac_header in dlfcn.h errno.h fcntl.h libgen.h memory.h netinet/in.h \ + setjmp.h sys/mman.h sys/param.h sys/poll.h sys/procset.h sys/select.h \ + sys/socket.h sys/stropts.h sys/time.h sys/un.h sys/wait.h unistd.h \ + utime.h sysexits.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + # -------------------------------------------- + # Verify certain entries from AC_CHECK_HEADERS + # -------------------------------------------- + for f in sys_types sys_mman sys_param sys_stat sys_wait \ + string errno stdlib memory setjmp + do eval as_ac_var=\${ac_cv_header_${f}_h+set} + test "${as_ac_var}" = set || \ + as_fn_error $? "You must have ${f}.h on your system" "$LINENO" 5 + done + + # ================================================ + # AC_CHECK_HEADERS: stdarg.h is present define HAVE_STDARG_H, otherwise + # if varargs.h is present define HAVE_VARARGS_H. + # ================================================ + for ac_header in stdarg.h varargs.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + break +fi + +done + + if test `eval echo '${'$as_ac_Header'}'` != yes; then + as_fn_error $? "You must have stdarg.h or varargs.h on your system" "$LINENO" 5 + fi + + # ================================================ + # Similarly for the string.h and strings.h headers + # ================================================ + for ac_header in string.h strings.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + break +fi + +done + + if test `eval echo '${'$as_ac_Header'}'` != yes; then + as_fn_error $? "You must have string.h or strings.h on your system" "$LINENO" 5 + fi + + # ===================== + # ...and limits headers + # ===================== + for ac_header in limits.h sys/limits.h values.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + break +fi + +done + + if test `eval echo '${'$as_ac_Header'}'` != yes; then + as_fn_error $? "You must have one of limits.h, sys/limits.h or values.h" "$LINENO" 5 + fi + + # ---------------------------------------------------------------------- + # check for various programs used during the build. + # On OS/X, "wchar.h" needs "runetype.h" to work properly. + # ---------------------------------------------------------------------- + for ac_header in runetype.h wchar.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" " + $ac_includes_default + #if HAVE_RUNETYPE_H + # include + #endif + +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + # ---------------------------------------------------------------------- + # Checks for typedefs + # ---------------------------------------------------------------------- + ac_fn_c_check_type "$LINENO" "wchar_t" "ac_cv_type_wchar_t" "$ac_includes_default" +if test "x$ac_cv_type_wchar_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_WCHAR_T 1 +_ACEOF + + +fi + + ac_fn_c_check_type "$LINENO" "wint_t" "ac_cv_type_wint_t" " + $ac_includes_default + #if HAVE_RUNETYPE_H + # include + #endif + #if HAVE_WCHAR_H + # include + #endif + +" +if test "x$ac_cv_type_wint_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_WINT_T 1 +_ACEOF + + +fi + + + # ======================== + # ...and int types headers + # ======================== + for ac_header in stdint.h inttypes.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + break +fi + +done + + ac_fn_c_check_type "$LINENO" "int8_t" "ac_cv_type_int8_t" "$ac_includes_default" +if test "x$ac_cv_type_int8_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_INT8_T 1 +_ACEOF + + +fi +ac_fn_c_check_type "$LINENO" "uint8_t" "ac_cv_type_uint8_t" "$ac_includes_default" +if test "x$ac_cv_type_uint8_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_UINT8_T 1 +_ACEOF + + +fi +ac_fn_c_check_type "$LINENO" "int16_t" "ac_cv_type_int16_t" "$ac_includes_default" +if test "x$ac_cv_type_int16_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_INT16_T 1 +_ACEOF + + +fi +ac_fn_c_check_type "$LINENO" "uint16_t" "ac_cv_type_uint16_t" "$ac_includes_default" +if test "x$ac_cv_type_uint16_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_UINT16_T 1 +_ACEOF + + +fi +ac_fn_c_check_type "$LINENO" "int32_t" "ac_cv_type_int32_t" "$ac_includes_default" +if test "x$ac_cv_type_int32_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_INT32_T 1 +_ACEOF + + +fi +ac_fn_c_check_type "$LINENO" "uint32_t" "ac_cv_type_uint32_t" "$ac_includes_default" +if test "x$ac_cv_type_uint32_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_UINT32_T 1 +_ACEOF + + +fi +ac_fn_c_check_type "$LINENO" "intptr_t" "ac_cv_type_intptr_t" "$ac_includes_default" +if test "x$ac_cv_type_intptr_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_INTPTR_T 1 +_ACEOF + + +fi +ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "$ac_includes_default" +if test "x$ac_cv_type_uintptr_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_UINTPTR_T 1 +_ACEOF + + +fi +ac_fn_c_check_type "$LINENO" "uint_t" "ac_cv_type_uint_t" "$ac_includes_default" +if test "x$ac_cv_type_uint_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_UINT_T 1 +_ACEOF + + +fi +ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default" +if test "x$ac_cv_type_pid_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_PID_T 1 +_ACEOF + + +fi +ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" +if test "x$ac_cv_type_size_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_SIZE_T 1 +_ACEOF + + +fi + + + # ===== + # sizes + # ===== + # The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of char*" >&5 +$as_echo_n "checking size of char*... " >&6; } +if ${ac_cv_sizeof_charp+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (char*))" "ac_cv_sizeof_charp" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_charp" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (char*) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_charp=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_charp" >&5 +$as_echo "$ac_cv_sizeof_charp" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_CHARP $ac_cv_sizeof_charp +_ACEOF + + + # The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5 +$as_echo_n "checking size of int... " >&6; } +if ${ac_cv_sizeof_int+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_int" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (int) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_int=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5 +$as_echo "$ac_cv_sizeof_int" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_INT $ac_cv_sizeof_int +_ACEOF + + + # The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5 +$as_echo_n "checking size of long... " >&6; } +if ${ac_cv_sizeof_long+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_long" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (long) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_long=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5 +$as_echo "$ac_cv_sizeof_long" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_LONG $ac_cv_sizeof_long +_ACEOF + + + # The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of short" >&5 +$as_echo_n "checking size of short... " >&6; } +if ${ac_cv_sizeof_short+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (short))" "ac_cv_sizeof_short" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_short" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (short) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_short=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_short" >&5 +$as_echo "$ac_cv_sizeof_short" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_SHORT $ac_cv_sizeof_short +_ACEOF + + + + # ---------------------------------------------------------------------- + # AC_CHECK_LIB for SVR4 libgen, and use it if it defines pathfind. + # ---------------------------------------------------------------------- + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pathfind in -lgen" >&5 +$as_echo_n "checking for pathfind in -lgen... " >&6; } +if ${ac_cv_lib_gen_pathfind+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lgen $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pathfind (); +int +main () +{ +return pathfind (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_gen_pathfind=yes +else + ac_cv_lib_gen_pathfind=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gen_pathfind" >&5 +$as_echo "$ac_cv_lib_gen_pathfind" >&6; } +if test "x$ac_cv_lib_gen_pathfind" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBGEN 1 +_ACEOF + + LIBS="-lgen $LIBS" + +fi + + for ac_func in vprintf +do : + ac_fn_c_check_func "$LINENO" "vprintf" "ac_cv_func_vprintf" +if test "x$ac_cv_func_vprintf" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_VPRINTF 1 +_ACEOF + +ac_fn_c_check_func "$LINENO" "_doprnt" "ac_cv_func__doprnt" +if test "x$ac_cv_func__doprnt" = xyes; then : + +$as_echo "#define HAVE_DOPRNT 1" >>confdefs.h + +fi + +fi +done + + + for ac_func in mmap canonicalize_file_name snprintf strdup strchr \ + strrchr strsignal +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + INVOKE_LIBOPTS_MACROS_FIRST_done=yes +fi + # Check to see if a reg expr header is specified. + + +# Check whether --with-regex-header was given. +if test "${with_regex_header+set}" = set; then : + withval=$with_regex_header; libopts_cv_with_regex_header=${with_regex_header} +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a reg expr header is specified" >&5 +$as_echo_n "checking whether a reg expr header is specified... " >&6; } +if ${libopts_cv_with_regex_header+:} false; then : + $as_echo_n "(cached) " >&6 +else + libopts_cv_with_regex_header=no +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libopts_cv_with_regex_header" >&5 +$as_echo "$libopts_cv_with_regex_header" >&6; } + +fi + # end of AC_ARG_WITH + + if test "X${libopts_cv_with_regex_header}" != Xno + then + cat >>confdefs.h <<_ACEOF +#define REGEX_HEADER <${libopts_cv_with_regex_header}> +_ACEOF + + else + +$as_echo "#define REGEX_HEADER " >>confdefs.h + + fi + + + + # Check to see if a working libregex can be found. + + +# Check whether --with-libregex was given. +if test "${with_libregex+set}" = set; then : + withval=$with_libregex; libopts_cv_with_libregex_root=${with_libregex} +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether with-libregex was specified" >&5 +$as_echo_n "checking whether with-libregex was specified... " >&6; } +if ${libopts_cv_with_libregex_root+:} false; then : + $as_echo_n "(cached) " >&6 +else + libopts_cv_with_libregex_root=no +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libopts_cv_with_libregex_root" >&5 +$as_echo "$libopts_cv_with_libregex_root" >&6; } + +fi + # end of AC_ARG_WITH libregex + + if test "${with_libguile+set}" = set && \ + test "${withval}" = no + then ## disabled by request + libopts_cv_with_libregex_root=no + libopts_cv_with_libregex_cflags=no + libopts_cv_with_libregex_libs=no + else + + +# Check whether --with-libregex-cflags was given. +if test "${with_libregex_cflags+set}" = set; then : + withval=$with_libregex_cflags; libopts_cv_with_libregex_cflags=${with_regex_cflags} +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether with-libregex-cflags was specified" >&5 +$as_echo_n "checking whether with-libregex-cflags was specified... " >&6; } +if ${libopts_cv_with_libregex_cflags+:} false; then : + $as_echo_n "(cached) " >&6 +else + libopts_cv_with_libregex_cflags=no +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libopts_cv_with_libregex_cflags" >&5 +$as_echo "$libopts_cv_with_libregex_cflags" >&6; } + +fi + # end of AC_ARG_WITH libregex-cflags + + +# Check whether --with-libregex-libs was given. +if test "${with_libregex_libs+set}" = set; then : + withval=$with_libregex_libs; libopts_cv_with_libregex_libs=${with_regex_libs} +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether with-libregex-libs was specified" >&5 +$as_echo_n "checking whether with-libregex-libs was specified... " >&6; } +if ${libopts_cv_with_libregex_libs+:} false; then : + $as_echo_n "(cached) " >&6 +else + libopts_cv_with_libregex_libs=no +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libopts_cv_with_libregex_libs" >&5 +$as_echo "$libopts_cv_with_libregex_libs" >&6; } + +fi + # 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}" + fi ## disabled by request + + 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="" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether libregex functions properly" >&5 +$as_echo_n "checking whether libregex functions properly... " >&6; } + if ${libopts_cv_with_libregex+:} false; then : + $as_echo_n "(cached) " >&6 +else + + if test "$cross_compiling" = yes; then : + libopts_cv_with_libregex=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#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( "^.*\$" ); + 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; } +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + libopts_cv_with_libregex=yes +else + libopts_cv_with_libregex=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + # end of AC_TRY_RUN + +fi + # end of AC_CACHE_VAL for libopts_cv_with_libregex + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_with_libregex}" >&5 +$as_echo "${libopts_cv_with_libregex}" >&6; } + + if test "X${libopts_cv_with_libregex}" != Xno + then + +$as_echo "#define WITH_LIBREGEX 1" >>confdefs.h + + else + CPPFLAGS="${libopts_save_CPPFLAGS}" + LIBS="${libopts_save_LIBS}" + fi + + + + # Check to see if pathfind(3) works. + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pathfind(3) works" >&5 +$as_echo_n "checking whether pathfind(3) works... " >&6; } + if ${libopts_cv_run_pathfind+:} false; then : + $as_echo_n "(cached) " >&6 +else + + if test "$cross_compiling" = yes; then : + libopts_cv_run_pathfind=no + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +int main (int argc, char** argv) { + char* pz = pathfind( getenv( "PATH" ), "sh", "x" ); + return (pz == 0) ? 1 : 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + libopts_cv_run_pathfind=yes +else + libopts_cv_run_pathfind=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + # end of TRY_RUN + +fi + # end of AC_CACHE_VAL for libopts_cv_run_pathfind + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_run_pathfind}" >&5 +$as_echo "${libopts_cv_run_pathfind}" >&6; } + + if test "X${libopts_cv_run_pathfind}" != Xno + then + +$as_echo "#define HAVE_PATHFIND 1" >>confdefs.h + + fi + + + + # Check to see if /dev/zero is readable device. + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether /dev/zero is readable device" >&5 +$as_echo_n "checking whether /dev/zero is readable device... " >&6; } + if ${libopts_cv_test_dev_zero+:} false; then : + $as_echo_n "(cached) " >&6 +else + + 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 + then libopts_cv_test_dev_zero=no + elif test -z "$libopts_cv_test_dev_zero" + then libopts_cv_test_dev_zero=no + fi + +fi + # end of CACHE_VAL of libopts_cv_test_dev_zero + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_test_dev_zero}" >&5 +$as_echo "${libopts_cv_test_dev_zero}" >&6; } + + if test "X${libopts_cv_test_dev_zero}" != Xno + then + +$as_echo "#define HAVE_DEV_ZERO 1" >>confdefs.h + + fi + + + + # Check to see if we have a functional realpath(3C). + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we have a functional realpath(3C)" >&5 +$as_echo_n "checking whether we have a functional realpath(3C)... " >&6; } + if ${libopts_cv_run_realpath+:} false; then : + $as_echo_n "(cached) " >&6 +else + + if test "$cross_compiling" = yes; then : + libopts_cv_run_realpath=no + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +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; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + libopts_cv_run_realpath=yes +else + libopts_cv_run_realpath=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + # end of TRY_RUN + +fi + # end of AC_CACHE_VAL for libopts_cv_run_realpath + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_run_realpath}" >&5 +$as_echo "${libopts_cv_run_realpath}" >&6; } + + if test "X${libopts_cv_run_realpath}" != Xno + then + +$as_echo "#define HAVE_REALPATH 1" >>confdefs.h + + fi + + + + # Check to see if strftime() works. + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strftime() works" >&5 +$as_echo_n "checking whether strftime() works... " >&6; } + if ${libopts_cv_run_strftime+:} false; then : + $as_echo_n "(cached) " >&6 +else + + if test "$cross_compiling" = yes; then : + libopts_cv_run_strftime=no + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +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); } +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + libopts_cv_run_strftime=yes +else + libopts_cv_run_strftime=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + # end of TRY_RUN + +fi + # end of AC_CACHE_VAL for libopts_cv_run_strftime + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_run_strftime}" >&5 +$as_echo "${libopts_cv_run_strftime}" >&6; } + + if test "X${libopts_cv_run_strftime}" != Xno + then + +$as_echo "#define HAVE_STRFTIME 1" >>confdefs.h + + fi + + + + # Check to see if fopen accepts "b" mode. + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fopen accepts \"b\" mode" >&5 +$as_echo_n "checking whether fopen accepts \"b\" mode... " >&6; } + if ${libopts_cv_run_fopen_binary+:} false; then : + $as_echo_n "(cached) " >&6 +else + + if test "$cross_compiling" = yes; then : + libopts_cv_run_fopen_binary=no + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int main (int argc, char** argv) { +FILE* fp = fopen("conftest.$ac_ext", "rb"); +return (fp == NULL) ? 1 : fclose(fp); } +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + libopts_cv_run_fopen_binary=yes +else + libopts_cv_run_fopen_binary=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + # end of TRY_RUN + +fi + # end of AC_CACHE_VAL for libopts_cv_run_fopen_binary + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_run_fopen_binary}" >&5 +$as_echo "${libopts_cv_run_fopen_binary}" >&6; } + + if test "X${libopts_cv_run_fopen_binary}" != Xno + then + +$as_echo "#define FOPEN_BINARY_FLAG \"b\"" >>confdefs.h + + else + +$as_echo "#define FOPEN_BINARY_FLAG \"\"" >>confdefs.h + + fi + + + + # Check to see if fopen accepts "t" mode. + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fopen accepts \"t\" mode" >&5 +$as_echo_n "checking whether fopen accepts \"t\" mode... " >&6; } + if ${libopts_cv_run_fopen_text+:} false; then : + $as_echo_n "(cached) " >&6 +else + + if test "$cross_compiling" = yes; then : + libopts_cv_run_fopen_text=no + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int main (int argc, char** argv) { +FILE* fp = fopen("conftest.$ac_ext", "rt"); +return (fp == NULL) ? 1 : fclose(fp); } +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + libopts_cv_run_fopen_text=yes +else + libopts_cv_run_fopen_text=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + # end of TRY_RUN + +fi + # end of AC_CACHE_VAL for libopts_cv_run_fopen_text + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_run_fopen_text}" >&5 +$as_echo "${libopts_cv_run_fopen_text}" >&6; } + + if test "X${libopts_cv_run_fopen_text}" != Xno + then + +$as_echo "#define FOPEN_TEXT_FLAG \"t\"" >>confdefs.h + + else + +$as_echo "#define FOPEN_TEXT_FLAG \"\"" >>confdefs.h + + fi + + + + # Check to see if not wanting optional option args. + + # Check whether --enable-optional-args was given. +if test "${enable_optional_args+set}" = set; then : + enableval=$enable_optional_args; libopts_cv_enable_optional_args=${enable_optional_args} +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether not wanting optional option args" >&5 +$as_echo_n "checking whether not wanting optional option args... " >&6; } +if ${libopts_cv_enable_optional_args+:} false; then : + $as_echo_n "(cached) " >&6 +else + libopts_cv_enable_optional_args=yes +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libopts_cv_enable_optional_args" >&5 +$as_echo "$libopts_cv_enable_optional_args" >&6; } + +fi + # end of AC_ARG_ENABLE + + if test "X${libopts_cv_enable_optional_args}" = Xno + then + +$as_echo "#define NO_OPTIONAL_OPT_ARGS 1" >>confdefs.h + + fi + + + + + else + +if test X${INVOKE_LIBOPTS_MACROS_FIRST_done} != Xyes ; then + # ================= + # AC_HEADER_STDC + # ================= + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + + # ================= + # AC_HEADER_DIRENT + # ================= + ac_header_dirent=no +for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do + as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5 +$as_echo_n "checking for $ac_hdr that defines DIR... " >&6; } +if eval \${$as_ac_Header+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include <$ac_hdr> + +int +main () +{ +if ((DIR *) 0) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$as_ac_Header=yes" +else + eval "$as_ac_Header=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$as_ac_Header + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_hdr" | $as_tr_cpp` 1 +_ACEOF + +ac_header_dirent=$ac_hdr; break +fi + +done +# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. +if test $ac_header_dirent = dirent.h; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5 +$as_echo_n "checking for library containing opendir... " >&6; } +if ${ac_cv_search_opendir+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char opendir (); +int +main () +{ +return opendir (); + ; + return 0; +} +_ACEOF +for ac_lib in '' dir; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_opendir=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_opendir+:} false; then : + break +fi +done +if ${ac_cv_search_opendir+:} false; then : + +else + ac_cv_search_opendir=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5 +$as_echo "$ac_cv_search_opendir" >&6; } +ac_res=$ac_cv_search_opendir +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5 +$as_echo_n "checking for library containing opendir... " >&6; } +if ${ac_cv_search_opendir+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char opendir (); +int +main () +{ +return opendir (); + ; + return 0; +} +_ACEOF +for ac_lib in '' x; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_opendir=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_opendir+:} false; then : + break +fi +done +if ${ac_cv_search_opendir+:} false; then : + +else + ac_cv_search_opendir=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5 +$as_echo "$ac_cv_search_opendir" >&6; } +ac_res=$ac_cv_search_opendir +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + +fi + + + # ================= + # AC_CHECK_HEADERS + # ================= + for ac_header in dlfcn.h errno.h fcntl.h libgen.h memory.h netinet/in.h \ + setjmp.h sys/mman.h sys/param.h sys/poll.h sys/procset.h sys/select.h \ + sys/socket.h sys/stropts.h sys/time.h sys/un.h sys/wait.h unistd.h \ + utime.h sysexits.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + # -------------------------------------------- + # Verify certain entries from AC_CHECK_HEADERS + # -------------------------------------------- + for f in sys_types sys_mman sys_param sys_stat sys_wait \ + string errno stdlib memory setjmp + do eval as_ac_var=\${ac_cv_header_${f}_h+set} + test "${as_ac_var}" = set || \ + as_fn_error $? "You must have ${f}.h on your system" "$LINENO" 5 + done + + # ================================================ + # AC_CHECK_HEADERS: stdarg.h is present define HAVE_STDARG_H, otherwise + # if varargs.h is present define HAVE_VARARGS_H. + # ================================================ + for ac_header in stdarg.h varargs.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + break +fi + +done + + if test `eval echo '${'$as_ac_Header'}'` != yes; then + as_fn_error $? "You must have stdarg.h or varargs.h on your system" "$LINENO" 5 + fi + + # ================================================ + # Similarly for the string.h and strings.h headers + # ================================================ + for ac_header in string.h strings.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + break +fi + +done + + if test `eval echo '${'$as_ac_Header'}'` != yes; then + as_fn_error $? "You must have string.h or strings.h on your system" "$LINENO" 5 + fi + + # ===================== + # ...and limits headers + # ===================== + for ac_header in limits.h sys/limits.h values.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + break +fi + +done + + if test `eval echo '${'$as_ac_Header'}'` != yes; then + as_fn_error $? "You must have one of limits.h, sys/limits.h or values.h" "$LINENO" 5 + fi + + # ---------------------------------------------------------------------- + # check for various programs used during the build. + # On OS/X, "wchar.h" needs "runetype.h" to work properly. + # ---------------------------------------------------------------------- + for ac_header in runetype.h wchar.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" " + $ac_includes_default + #if HAVE_RUNETYPE_H + # include + #endif + +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + # ---------------------------------------------------------------------- + # Checks for typedefs + # ---------------------------------------------------------------------- + ac_fn_c_check_type "$LINENO" "wchar_t" "ac_cv_type_wchar_t" "$ac_includes_default" +if test "x$ac_cv_type_wchar_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_WCHAR_T 1 +_ACEOF + + +fi + + ac_fn_c_check_type "$LINENO" "wint_t" "ac_cv_type_wint_t" " + $ac_includes_default + #if HAVE_RUNETYPE_H + # include + #endif + #if HAVE_WCHAR_H + # include + #endif + +" +if test "x$ac_cv_type_wint_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_WINT_T 1 +_ACEOF + + +fi + + + # ======================== + # ...and int types headers + # ======================== + for ac_header in stdint.h inttypes.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + break +fi + +done + + ac_fn_c_check_type "$LINENO" "int8_t" "ac_cv_type_int8_t" "$ac_includes_default" +if test "x$ac_cv_type_int8_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_INT8_T 1 +_ACEOF + + +fi +ac_fn_c_check_type "$LINENO" "uint8_t" "ac_cv_type_uint8_t" "$ac_includes_default" +if test "x$ac_cv_type_uint8_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_UINT8_T 1 +_ACEOF + + +fi +ac_fn_c_check_type "$LINENO" "int16_t" "ac_cv_type_int16_t" "$ac_includes_default" +if test "x$ac_cv_type_int16_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_INT16_T 1 +_ACEOF + + +fi +ac_fn_c_check_type "$LINENO" "uint16_t" "ac_cv_type_uint16_t" "$ac_includes_default" +if test "x$ac_cv_type_uint16_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_UINT16_T 1 +_ACEOF + + +fi +ac_fn_c_check_type "$LINENO" "int32_t" "ac_cv_type_int32_t" "$ac_includes_default" +if test "x$ac_cv_type_int32_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_INT32_T 1 +_ACEOF + + +fi +ac_fn_c_check_type "$LINENO" "uint32_t" "ac_cv_type_uint32_t" "$ac_includes_default" +if test "x$ac_cv_type_uint32_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_UINT32_T 1 +_ACEOF + + +fi +ac_fn_c_check_type "$LINENO" "intptr_t" "ac_cv_type_intptr_t" "$ac_includes_default" +if test "x$ac_cv_type_intptr_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_INTPTR_T 1 +_ACEOF + + +fi +ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "$ac_includes_default" +if test "x$ac_cv_type_uintptr_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_UINTPTR_T 1 +_ACEOF + + +fi +ac_fn_c_check_type "$LINENO" "uint_t" "ac_cv_type_uint_t" "$ac_includes_default" +if test "x$ac_cv_type_uint_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_UINT_T 1 +_ACEOF + + +fi +ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default" +if test "x$ac_cv_type_pid_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_PID_T 1 +_ACEOF + + +fi +ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" +if test "x$ac_cv_type_size_t" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_SIZE_T 1 +_ACEOF + + +fi + + + # ===== + # sizes + # ===== + # The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of char*" >&5 +$as_echo_n "checking size of char*... " >&6; } +if ${ac_cv_sizeof_charp+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (char*))" "ac_cv_sizeof_charp" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_charp" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (char*) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_charp=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_charp" >&5 +$as_echo "$ac_cv_sizeof_charp" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_CHARP $ac_cv_sizeof_charp +_ACEOF + + + # The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5 +$as_echo_n "checking size of int... " >&6; } +if ${ac_cv_sizeof_int+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_int" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (int) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_int=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5 +$as_echo "$ac_cv_sizeof_int" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_INT $ac_cv_sizeof_int +_ACEOF + + + # The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5 +$as_echo_n "checking size of long... " >&6; } +if ${ac_cv_sizeof_long+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_long" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (long) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_long=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5 +$as_echo "$ac_cv_sizeof_long" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_LONG $ac_cv_sizeof_long +_ACEOF + + + # The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of short" >&5 +$as_echo_n "checking size of short... " >&6; } +if ${ac_cv_sizeof_short+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (short))" "ac_cv_sizeof_short" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_short" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (short) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_short=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_short" >&5 +$as_echo "$ac_cv_sizeof_short" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_SHORT $ac_cv_sizeof_short +_ACEOF + + + + # ---------------------------------------------------------------------- + # AC_CHECK_LIB for SVR4 libgen, and use it if it defines pathfind. + # ---------------------------------------------------------------------- + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pathfind in -lgen" >&5 +$as_echo_n "checking for pathfind in -lgen... " >&6; } +if ${ac_cv_lib_gen_pathfind+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lgen $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pathfind (); +int +main () +{ +return pathfind (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_gen_pathfind=yes +else + ac_cv_lib_gen_pathfind=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gen_pathfind" >&5 +$as_echo "$ac_cv_lib_gen_pathfind" >&6; } +if test "x$ac_cv_lib_gen_pathfind" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBGEN 1 +_ACEOF + + LIBS="-lgen $LIBS" + +fi + + for ac_func in vprintf +do : + ac_fn_c_check_func "$LINENO" "vprintf" "ac_cv_func_vprintf" +if test "x$ac_cv_func_vprintf" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_VPRINTF 1 +_ACEOF + +ac_fn_c_check_func "$LINENO" "_doprnt" "ac_cv_func__doprnt" +if test "x$ac_cv_func__doprnt" = xyes; then : + +$as_echo "#define HAVE_DOPRNT 1" >>confdefs.h + +fi + +fi +done + + + for ac_func in mmap canonicalize_file_name snprintf strdup strchr \ + strrchr strsignal +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + INVOKE_LIBOPTS_MACROS_FIRST_done=yes +fi + fi +# end of AC_DEFUN of LIBOPTS_CHECK + + + +ac_config_files="$ac_config_files Makefile doxygen.cfg lib/Makefile docs/Makefile src/Makefile src/common/Makefile src/tcpedit/Makefile src/fragroute/Makefile src/defines.h test/Makefile test/config scripts/Makefile" + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + if test "x$cache_file" != "x/dev/null"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +U= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + +if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then + as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi + if test -n "$EXEEXT"; then + am__EXEEXT_TRUE= + am__EXEEXT_FALSE='#' +else + am__EXEEXT_TRUE='#' + am__EXEEXT_FALSE= +fi + +if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then + as_fn_error $? "conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then + as_fn_error $? "conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then + as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then + as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${SYSTEM_STRLCPY_TRUE}" && test -z "${SYSTEM_STRLCPY_FALSE}"; then + as_fn_error $? "conditional \"SYSTEM_STRLCPY\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi + +if test -z "${WORDS_BIGENDIAN_TRUE}" && test -z "${WORDS_BIGENDIAN_FALSE}"; then + as_fn_error $? "conditional \"WORDS_BIGENDIAN\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${COMPILE_TCPBRIDGE_TRUE}" && test -z "${COMPILE_TCPBRIDGE_FALSE}"; then + as_fn_error $? "conditional \"COMPILE_TCPBRIDGE\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${COMPILE_FRAGROUTE_TRUE}" && test -z "${COMPILE_FRAGROUTE_FALSE}"; then + as_fn_error $? "conditional \"COMPILE_FRAGROUTE\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${ENABLE_TCPDUMP_TRUE}" && test -z "${ENABLE_TCPDUMP_FALSE}"; then + as_fn_error $? "conditional \"ENABLE_TCPDUMP\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${ENABLE_OSX_FRAMEWORKS_TRUE}" && test -z "${ENABLE_OSX_FRAMEWORKS_FALSE}"; then + as_fn_error $? "conditional \"ENABLE_OSX_FRAMEWORKS\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${INSTALL_LIBOPTS_TRUE}" && test -z "${INSTALL_LIBOPTS_FALSE}"; then + as_fn_error $? "conditional \"INSTALL_LIBOPTS\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${NEED_LIBOPTS_TRUE}" && test -z "${NEED_LIBOPTS_FALSE}"; then + as_fn_error $? "conditional \"NEED_LIBOPTS\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi + +: "${CONFIG_STATUS=./config.status}" +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by $as_me, which was +generated by GNU Autoconf 2.69. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + +case $ac_config_headers in *" +"*) set x $ac_config_headers; shift; ac_config_headers=$*;; +esac + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" +config_commands="$ac_config_commands" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration commands: +$config_commands + +Report bugs to the package provider." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" +ac_cs_version="\\ +config.status +configured by $0, generated by GNU Autoconf 2.69, + with options \\"\$ac_cs_config\\" + +Copyright (C) 2012 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +INSTALL='$INSTALL' +MKDIR_P='$MKDIR_P' +AWK='$AWK' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# +# INIT-COMMANDS +# +AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" + + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +sed_quote_subst='$sed_quote_subst' +double_quote_subst='$double_quote_subst' +delay_variable_subst='$delay_variable_subst' +macro_version='`$ECHO "X$macro_version" | $Xsed -e "$delay_single_quote_subst"`' +macro_revision='`$ECHO "X$macro_revision" | $Xsed -e "$delay_single_quote_subst"`' +enable_shared='`$ECHO "X$enable_shared" | $Xsed -e "$delay_single_quote_subst"`' +enable_static='`$ECHO "X$enable_static" | $Xsed -e "$delay_single_quote_subst"`' +pic_mode='`$ECHO "X$pic_mode" | $Xsed -e "$delay_single_quote_subst"`' +enable_fast_install='`$ECHO "X$enable_fast_install" | $Xsed -e "$delay_single_quote_subst"`' +host_alias='`$ECHO "X$host_alias" | $Xsed -e "$delay_single_quote_subst"`' +host='`$ECHO "X$host" | $Xsed -e "$delay_single_quote_subst"`' +host_os='`$ECHO "X$host_os" | $Xsed -e "$delay_single_quote_subst"`' +build_alias='`$ECHO "X$build_alias" | $Xsed -e "$delay_single_quote_subst"`' +build='`$ECHO "X$build" | $Xsed -e "$delay_single_quote_subst"`' +build_os='`$ECHO "X$build_os" | $Xsed -e "$delay_single_quote_subst"`' +SED='`$ECHO "X$SED" | $Xsed -e "$delay_single_quote_subst"`' +Xsed='`$ECHO "X$Xsed" | $Xsed -e "$delay_single_quote_subst"`' +GREP='`$ECHO "X$GREP" | $Xsed -e "$delay_single_quote_subst"`' +EGREP='`$ECHO "X$EGREP" | $Xsed -e "$delay_single_quote_subst"`' +FGREP='`$ECHO "X$FGREP" | $Xsed -e "$delay_single_quote_subst"`' +LD='`$ECHO "X$LD" | $Xsed -e "$delay_single_quote_subst"`' +NM='`$ECHO "X$NM" | $Xsed -e "$delay_single_quote_subst"`' +LN_S='`$ECHO "X$LN_S" | $Xsed -e "$delay_single_quote_subst"`' +max_cmd_len='`$ECHO "X$max_cmd_len" | $Xsed -e "$delay_single_quote_subst"`' +ac_objext='`$ECHO "X$ac_objext" | $Xsed -e "$delay_single_quote_subst"`' +exeext='`$ECHO "X$exeext" | $Xsed -e "$delay_single_quote_subst"`' +lt_unset='`$ECHO "X$lt_unset" | $Xsed -e "$delay_single_quote_subst"`' +lt_SP2NL='`$ECHO "X$lt_SP2NL" | $Xsed -e "$delay_single_quote_subst"`' +lt_NL2SP='`$ECHO "X$lt_NL2SP" | $Xsed -e "$delay_single_quote_subst"`' +reload_flag='`$ECHO "X$reload_flag" | $Xsed -e "$delay_single_quote_subst"`' +reload_cmds='`$ECHO "X$reload_cmds" | $Xsed -e "$delay_single_quote_subst"`' +OBJDUMP='`$ECHO "X$OBJDUMP" | $Xsed -e "$delay_single_quote_subst"`' +deplibs_check_method='`$ECHO "X$deplibs_check_method" | $Xsed -e "$delay_single_quote_subst"`' +file_magic_cmd='`$ECHO "X$file_magic_cmd" | $Xsed -e "$delay_single_quote_subst"`' +AR='`$ECHO "X$AR" | $Xsed -e "$delay_single_quote_subst"`' +AR_FLAGS='`$ECHO "X$AR_FLAGS" | $Xsed -e "$delay_single_quote_subst"`' +STRIP='`$ECHO "X$STRIP" | $Xsed -e "$delay_single_quote_subst"`' +RANLIB='`$ECHO "X$RANLIB" | $Xsed -e "$delay_single_quote_subst"`' +old_postinstall_cmds='`$ECHO "X$old_postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' +old_postuninstall_cmds='`$ECHO "X$old_postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' +old_archive_cmds='`$ECHO "X$old_archive_cmds" | $Xsed -e "$delay_single_quote_subst"`' +CC='`$ECHO "X$CC" | $Xsed -e "$delay_single_quote_subst"`' +CFLAGS='`$ECHO "X$CFLAGS" | $Xsed -e "$delay_single_quote_subst"`' +compiler='`$ECHO "X$compiler" | $Xsed -e "$delay_single_quote_subst"`' +GCC='`$ECHO "X$GCC" | $Xsed -e "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_pipe='`$ECHO "X$lt_cv_sys_global_symbol_pipe" | $Xsed -e "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_cdecl='`$ECHO "X$lt_cv_sys_global_symbol_to_cdecl" | $Xsed -e "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address" | $Xsed -e "$delay_single_quote_subst"`' +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`' +objdir='`$ECHO "X$objdir" | $Xsed -e "$delay_single_quote_subst"`' +SHELL='`$ECHO "X$SHELL" | $Xsed -e "$delay_single_quote_subst"`' +ECHO='`$ECHO "X$ECHO" | $Xsed -e "$delay_single_quote_subst"`' +MAGIC_CMD='`$ECHO "X$MAGIC_CMD" | $Xsed -e "$delay_single_quote_subst"`' +lt_prog_compiler_no_builtin_flag='`$ECHO "X$lt_prog_compiler_no_builtin_flag" | $Xsed -e "$delay_single_quote_subst"`' +lt_prog_compiler_wl='`$ECHO "X$lt_prog_compiler_wl" | $Xsed -e "$delay_single_quote_subst"`' +lt_prog_compiler_pic='`$ECHO "X$lt_prog_compiler_pic" | $Xsed -e "$delay_single_quote_subst"`' +lt_prog_compiler_static='`$ECHO "X$lt_prog_compiler_static" | $Xsed -e "$delay_single_quote_subst"`' +lt_cv_prog_compiler_c_o='`$ECHO "X$lt_cv_prog_compiler_c_o" | $Xsed -e "$delay_single_quote_subst"`' +need_locks='`$ECHO "X$need_locks" | $Xsed -e "$delay_single_quote_subst"`' +DSYMUTIL='`$ECHO "X$DSYMUTIL" | $Xsed -e "$delay_single_quote_subst"`' +NMEDIT='`$ECHO "X$NMEDIT" | $Xsed -e "$delay_single_quote_subst"`' +LIPO='`$ECHO "X$LIPO" | $Xsed -e "$delay_single_quote_subst"`' +OTOOL='`$ECHO "X$OTOOL" | $Xsed -e "$delay_single_quote_subst"`' +OTOOL64='`$ECHO "X$OTOOL64" | $Xsed -e "$delay_single_quote_subst"`' +libext='`$ECHO "X$libext" | $Xsed -e "$delay_single_quote_subst"`' +shrext_cmds='`$ECHO "X$shrext_cmds" | $Xsed -e "$delay_single_quote_subst"`' +extract_expsyms_cmds='`$ECHO "X$extract_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`' +archive_cmds_need_lc='`$ECHO "X$archive_cmds_need_lc" | $Xsed -e "$delay_single_quote_subst"`' +enable_shared_with_static_runtimes='`$ECHO "X$enable_shared_with_static_runtimes" | $Xsed -e "$delay_single_quote_subst"`' +export_dynamic_flag_spec='`$ECHO "X$export_dynamic_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' +whole_archive_flag_spec='`$ECHO "X$whole_archive_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' +compiler_needs_object='`$ECHO "X$compiler_needs_object" | $Xsed -e "$delay_single_quote_subst"`' +old_archive_from_new_cmds='`$ECHO "X$old_archive_from_new_cmds" | $Xsed -e "$delay_single_quote_subst"`' +old_archive_from_expsyms_cmds='`$ECHO "X$old_archive_from_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`' +archive_cmds='`$ECHO "X$archive_cmds" | $Xsed -e "$delay_single_quote_subst"`' +archive_expsym_cmds='`$ECHO "X$archive_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`' +module_cmds='`$ECHO "X$module_cmds" | $Xsed -e "$delay_single_quote_subst"`' +module_expsym_cmds='`$ECHO "X$module_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`' +with_gnu_ld='`$ECHO "X$with_gnu_ld" | $Xsed -e "$delay_single_quote_subst"`' +allow_undefined_flag='`$ECHO "X$allow_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`' +no_undefined_flag='`$ECHO "X$no_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_libdir_flag_spec='`$ECHO "X$hardcode_libdir_flag_spec" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_libdir_flag_spec_ld='`$ECHO "X$hardcode_libdir_flag_spec_ld" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_libdir_separator='`$ECHO "X$hardcode_libdir_separator" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_direct='`$ECHO "X$hardcode_direct" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_direct_absolute='`$ECHO "X$hardcode_direct_absolute" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_minus_L='`$ECHO "X$hardcode_minus_L" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_shlibpath_var='`$ECHO "X$hardcode_shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_automatic='`$ECHO "X$hardcode_automatic" | $Xsed -e "$delay_single_quote_subst"`' +inherit_rpath='`$ECHO "X$inherit_rpath" | $Xsed -e "$delay_single_quote_subst"`' +link_all_deplibs='`$ECHO "X$link_all_deplibs" | $Xsed -e "$delay_single_quote_subst"`' +fix_srcfile_path='`$ECHO "X$fix_srcfile_path" | $Xsed -e "$delay_single_quote_subst"`' +always_export_symbols='`$ECHO "X$always_export_symbols" | $Xsed -e "$delay_single_quote_subst"`' +export_symbols_cmds='`$ECHO "X$export_symbols_cmds" | $Xsed -e "$delay_single_quote_subst"`' +exclude_expsyms='`$ECHO "X$exclude_expsyms" | $Xsed -e "$delay_single_quote_subst"`' +include_expsyms='`$ECHO "X$include_expsyms" | $Xsed -e "$delay_single_quote_subst"`' +prelink_cmds='`$ECHO "X$prelink_cmds" | $Xsed -e "$delay_single_quote_subst"`' +file_list_spec='`$ECHO "X$file_list_spec" | $Xsed -e "$delay_single_quote_subst"`' +variables_saved_for_relink='`$ECHO "X$variables_saved_for_relink" | $Xsed -e "$delay_single_quote_subst"`' +need_lib_prefix='`$ECHO "X$need_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`' +need_version='`$ECHO "X$need_version" | $Xsed -e "$delay_single_quote_subst"`' +version_type='`$ECHO "X$version_type" | $Xsed -e "$delay_single_quote_subst"`' +runpath_var='`$ECHO "X$runpath_var" | $Xsed -e "$delay_single_quote_subst"`' +shlibpath_var='`$ECHO "X$shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`' +shlibpath_overrides_runpath='`$ECHO "X$shlibpath_overrides_runpath" | $Xsed -e "$delay_single_quote_subst"`' +libname_spec='`$ECHO "X$libname_spec" | $Xsed -e "$delay_single_quote_subst"`' +library_names_spec='`$ECHO "X$library_names_spec" | $Xsed -e "$delay_single_quote_subst"`' +soname_spec='`$ECHO "X$soname_spec" | $Xsed -e "$delay_single_quote_subst"`' +postinstall_cmds='`$ECHO "X$postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' +postuninstall_cmds='`$ECHO "X$postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`' +finish_cmds='`$ECHO "X$finish_cmds" | $Xsed -e "$delay_single_quote_subst"`' +finish_eval='`$ECHO "X$finish_eval" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_into_libs='`$ECHO "X$hardcode_into_libs" | $Xsed -e "$delay_single_quote_subst"`' +sys_lib_search_path_spec='`$ECHO "X$sys_lib_search_path_spec" | $Xsed -e "$delay_single_quote_subst"`' +sys_lib_dlsearch_path_spec='`$ECHO "X$sys_lib_dlsearch_path_spec" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_action='`$ECHO "X$hardcode_action" | $Xsed -e "$delay_single_quote_subst"`' +enable_dlopen='`$ECHO "X$enable_dlopen" | $Xsed -e "$delay_single_quote_subst"`' +enable_dlopen_self='`$ECHO "X$enable_dlopen_self" | $Xsed -e "$delay_single_quote_subst"`' +enable_dlopen_self_static='`$ECHO "X$enable_dlopen_self_static" | $Xsed -e "$delay_single_quote_subst"`' +old_striplib='`$ECHO "X$old_striplib" | $Xsed -e "$delay_single_quote_subst"`' +striplib='`$ECHO "X$striplib" | $Xsed -e "$delay_single_quote_subst"`' +compiler_lib_search_dirs='`$ECHO "X$compiler_lib_search_dirs" | $Xsed -e "$delay_single_quote_subst"`' +predep_objects='`$ECHO "X$predep_objects" | $Xsed -e "$delay_single_quote_subst"`' +postdep_objects='`$ECHO "X$postdep_objects" | $Xsed -e "$delay_single_quote_subst"`' +predeps='`$ECHO "X$predeps" | $Xsed -e "$delay_single_quote_subst"`' +postdeps='`$ECHO "X$postdeps" | $Xsed -e "$delay_single_quote_subst"`' +compiler_lib_search_path='`$ECHO "X$compiler_lib_search_path" | $Xsed -e "$delay_single_quote_subst"`' +LD_CXX='`$ECHO "X$LD_CXX" | $Xsed -e "$delay_single_quote_subst"`' +old_archive_cmds_CXX='`$ECHO "X$old_archive_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`' +compiler_CXX='`$ECHO "X$compiler_CXX" | $Xsed -e "$delay_single_quote_subst"`' +GCC_CXX='`$ECHO "X$GCC_CXX" | $Xsed -e "$delay_single_quote_subst"`' +lt_prog_compiler_no_builtin_flag_CXX='`$ECHO "X$lt_prog_compiler_no_builtin_flag_CXX" | $Xsed -e "$delay_single_quote_subst"`' +lt_prog_compiler_wl_CXX='`$ECHO "X$lt_prog_compiler_wl_CXX" | $Xsed -e "$delay_single_quote_subst"`' +lt_prog_compiler_pic_CXX='`$ECHO "X$lt_prog_compiler_pic_CXX" | $Xsed -e "$delay_single_quote_subst"`' +lt_prog_compiler_static_CXX='`$ECHO "X$lt_prog_compiler_static_CXX" | $Xsed -e "$delay_single_quote_subst"`' +lt_cv_prog_compiler_c_o_CXX='`$ECHO "X$lt_cv_prog_compiler_c_o_CXX" | $Xsed -e "$delay_single_quote_subst"`' +archive_cmds_need_lc_CXX='`$ECHO "X$archive_cmds_need_lc_CXX" | $Xsed -e "$delay_single_quote_subst"`' +enable_shared_with_static_runtimes_CXX='`$ECHO "X$enable_shared_with_static_runtimes_CXX" | $Xsed -e "$delay_single_quote_subst"`' +export_dynamic_flag_spec_CXX='`$ECHO "X$export_dynamic_flag_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`' +whole_archive_flag_spec_CXX='`$ECHO "X$whole_archive_flag_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`' +compiler_needs_object_CXX='`$ECHO "X$compiler_needs_object_CXX" | $Xsed -e "$delay_single_quote_subst"`' +old_archive_from_new_cmds_CXX='`$ECHO "X$old_archive_from_new_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`' +old_archive_from_expsyms_cmds_CXX='`$ECHO "X$old_archive_from_expsyms_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`' +archive_cmds_CXX='`$ECHO "X$archive_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`' +archive_expsym_cmds_CXX='`$ECHO "X$archive_expsym_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`' +module_cmds_CXX='`$ECHO "X$module_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`' +module_expsym_cmds_CXX='`$ECHO "X$module_expsym_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`' +with_gnu_ld_CXX='`$ECHO "X$with_gnu_ld_CXX" | $Xsed -e "$delay_single_quote_subst"`' +allow_undefined_flag_CXX='`$ECHO "X$allow_undefined_flag_CXX" | $Xsed -e "$delay_single_quote_subst"`' +no_undefined_flag_CXX='`$ECHO "X$no_undefined_flag_CXX" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_libdir_flag_spec_CXX='`$ECHO "X$hardcode_libdir_flag_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_libdir_flag_spec_ld_CXX='`$ECHO "X$hardcode_libdir_flag_spec_ld_CXX" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_libdir_separator_CXX='`$ECHO "X$hardcode_libdir_separator_CXX" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_direct_CXX='`$ECHO "X$hardcode_direct_CXX" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_direct_absolute_CXX='`$ECHO "X$hardcode_direct_absolute_CXX" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_minus_L_CXX='`$ECHO "X$hardcode_minus_L_CXX" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_shlibpath_var_CXX='`$ECHO "X$hardcode_shlibpath_var_CXX" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_automatic_CXX='`$ECHO "X$hardcode_automatic_CXX" | $Xsed -e "$delay_single_quote_subst"`' +inherit_rpath_CXX='`$ECHO "X$inherit_rpath_CXX" | $Xsed -e "$delay_single_quote_subst"`' +link_all_deplibs_CXX='`$ECHO "X$link_all_deplibs_CXX" | $Xsed -e "$delay_single_quote_subst"`' +fix_srcfile_path_CXX='`$ECHO "X$fix_srcfile_path_CXX" | $Xsed -e "$delay_single_quote_subst"`' +always_export_symbols_CXX='`$ECHO "X$always_export_symbols_CXX" | $Xsed -e "$delay_single_quote_subst"`' +export_symbols_cmds_CXX='`$ECHO "X$export_symbols_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`' +exclude_expsyms_CXX='`$ECHO "X$exclude_expsyms_CXX" | $Xsed -e "$delay_single_quote_subst"`' +include_expsyms_CXX='`$ECHO "X$include_expsyms_CXX" | $Xsed -e "$delay_single_quote_subst"`' +prelink_cmds_CXX='`$ECHO "X$prelink_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`' +file_list_spec_CXX='`$ECHO "X$file_list_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`' +hardcode_action_CXX='`$ECHO "X$hardcode_action_CXX" | $Xsed -e "$delay_single_quote_subst"`' +compiler_lib_search_dirs_CXX='`$ECHO "X$compiler_lib_search_dirs_CXX" | $Xsed -e "$delay_single_quote_subst"`' +predep_objects_CXX='`$ECHO "X$predep_objects_CXX" | $Xsed -e "$delay_single_quote_subst"`' +postdep_objects_CXX='`$ECHO "X$postdep_objects_CXX" | $Xsed -e "$delay_single_quote_subst"`' +predeps_CXX='`$ECHO "X$predeps_CXX" | $Xsed -e "$delay_single_quote_subst"`' +postdeps_CXX='`$ECHO "X$postdeps_CXX" | $Xsed -e "$delay_single_quote_subst"`' +compiler_lib_search_path_CXX='`$ECHO "X$compiler_lib_search_path_CXX" | $Xsed -e "$delay_single_quote_subst"`' + +LTCC='$LTCC' +LTCFLAGS='$LTCFLAGS' +compiler='$compiler_DEFAULT' + +# Quote evaled strings. +for var in SED \ +GREP \ +EGREP \ +FGREP \ +LD \ +NM \ +LN_S \ +lt_SP2NL \ +lt_NL2SP \ +reload_flag \ +OBJDUMP \ +deplibs_check_method \ +file_magic_cmd \ +AR \ +AR_FLAGS \ +STRIP \ +RANLIB \ +CC \ +CFLAGS \ +compiler \ +lt_cv_sys_global_symbol_pipe \ +lt_cv_sys_global_symbol_to_cdecl \ +lt_cv_sys_global_symbol_to_c_name_address \ +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ +SHELL \ +ECHO \ +lt_prog_compiler_no_builtin_flag \ +lt_prog_compiler_wl \ +lt_prog_compiler_pic \ +lt_prog_compiler_static \ +lt_cv_prog_compiler_c_o \ +need_locks \ +DSYMUTIL \ +NMEDIT \ +LIPO \ +OTOOL \ +OTOOL64 \ +shrext_cmds \ +export_dynamic_flag_spec \ +whole_archive_flag_spec \ +compiler_needs_object \ +with_gnu_ld \ +allow_undefined_flag \ +no_undefined_flag \ +hardcode_libdir_flag_spec \ +hardcode_libdir_flag_spec_ld \ +hardcode_libdir_separator \ +fix_srcfile_path \ +exclude_expsyms \ +include_expsyms \ +file_list_spec \ +variables_saved_for_relink \ +libname_spec \ +library_names_spec \ +soname_spec \ +finish_eval \ +old_striplib \ +striplib \ +compiler_lib_search_dirs \ +predep_objects \ +postdep_objects \ +predeps \ +postdeps \ +compiler_lib_search_path \ +LD_CXX \ +compiler_CXX \ +lt_prog_compiler_no_builtin_flag_CXX \ +lt_prog_compiler_wl_CXX \ +lt_prog_compiler_pic_CXX \ +lt_prog_compiler_static_CXX \ +lt_cv_prog_compiler_c_o_CXX \ +export_dynamic_flag_spec_CXX \ +whole_archive_flag_spec_CXX \ +compiler_needs_object_CXX \ +with_gnu_ld_CXX \ +allow_undefined_flag_CXX \ +no_undefined_flag_CXX \ +hardcode_libdir_flag_spec_CXX \ +hardcode_libdir_flag_spec_ld_CXX \ +hardcode_libdir_separator_CXX \ +fix_srcfile_path_CXX \ +exclude_expsyms_CXX \ +include_expsyms_CXX \ +file_list_spec_CXX \ +compiler_lib_search_dirs_CXX \ +predep_objects_CXX \ +postdep_objects_CXX \ +predeps_CXX \ +postdeps_CXX \ +compiler_lib_search_path_CXX; do + case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in + *[\\\\\\\`\\"\\\$]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +# Double-quote double-evaled strings. +for var in reload_cmds \ +old_postinstall_cmds \ +old_postuninstall_cmds \ +old_archive_cmds \ +extract_expsyms_cmds \ +old_archive_from_new_cmds \ +old_archive_from_expsyms_cmds \ +archive_cmds \ +archive_expsym_cmds \ +module_cmds \ +module_expsym_cmds \ +export_symbols_cmds \ +prelink_cmds \ +postinstall_cmds \ +postuninstall_cmds \ +finish_cmds \ +sys_lib_search_path_spec \ +sys_lib_dlsearch_path_spec \ +old_archive_cmds_CXX \ +old_archive_from_new_cmds_CXX \ +old_archive_from_expsyms_cmds_CXX \ +archive_cmds_CXX \ +archive_expsym_cmds_CXX \ +module_cmds_CXX \ +module_expsym_cmds_CXX \ +export_symbols_cmds_CXX \ +prelink_cmds_CXX; do + case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in + *[\\\\\\\`\\"\\\$]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +# Fix-up fallback echo if it was mangled by the above quoting rules. +case \$lt_ECHO in +*'\\\$0 --fallback-echo"') lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\$0 --fallback-echo"\$/\$0 --fallback-echo"/'\` + ;; +esac + +ac_aux_dir='$ac_aux_dir' +xsi_shell='$xsi_shell' +lt_shell_append='$lt_shell_append' + +# See if we are running on zsh, and set the options which allow our +# commands through without removal of \ escapes INIT. +if test -n "\${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST +fi + + + PACKAGE='$PACKAGE' + VERSION='$VERSION' + TIMESTAMP='$TIMESTAMP' + RM='$RM' + ofile='$ofile' + + + + + + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "src/config.h") CONFIG_HEADERS="$CONFIG_HEADERS src/config.h" ;; + "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; + "libopts/Makefile") CONFIG_FILES="$CONFIG_FILES libopts/Makefile" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "doxygen.cfg") CONFIG_FILES="$CONFIG_FILES doxygen.cfg" ;; + "lib/Makefile") CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;; + "docs/Makefile") CONFIG_FILES="$CONFIG_FILES docs/Makefile" ;; + "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; + "src/common/Makefile") CONFIG_FILES="$CONFIG_FILES src/common/Makefile" ;; + "src/tcpedit/Makefile") CONFIG_FILES="$CONFIG_FILES src/tcpedit/Makefile" ;; + "src/fragroute/Makefile") CONFIG_FILES="$CONFIG_FILES src/fragroute/Makefile" ;; + "src/defines.h") CONFIG_FILES="$CONFIG_FILES src/defines.h" ;; + "test/Makefile") CONFIG_FILES="$CONFIG_FILES test/Makefile" ;; + "test/config") CONFIG_FILES="$CONFIG_FILES test/config" ;; + "scripts/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/Makefile" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= ac_tmp= + trap 'exit_status=$? + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\)..*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\)..*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 +_ACEOF + +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" + +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$ac_tmp/defines.awk" <<\_ACAWK || +BEGIN { +_ACEOF + +# Transform confdefs.h into an awk script `defines.awk', embedded as +# here-document in config.status, that substitutes the proper values into +# config.h.in to produce config.h. + +# Create a delimiter string that does not exist in confdefs.h, to ease +# handling of long lines. +ac_delim='%!_!# ' +for ac_last_try in false false :; do + ac_tt=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_tt"; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +# For the awk script, D is an array of macro values keyed by name, +# likewise P contains macro parameters if any. Preserve backslash +# newline sequences. + +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +sed -n ' +s/.\{148\}/&'"$ac_delim"'/g +t rset +:rset +s/^[ ]*#[ ]*define[ ][ ]*/ / +t def +d +:def +s/\\$// +t bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3"/p +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p +d +:bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3\\\\\\n"\\/p +t cont +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p +t cont +d +:cont +n +s/.\{148\}/&'"$ac_delim"'/g +t clear +:clear +s/\\$// +t bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/"/p +d +:bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p +b cont +' >$CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { + line = \$ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$ac_tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac + ac_MKDIR_P=$MKDIR_P + case $MKDIR_P in + [\\/$]* | ?:[\\/]* ) ;; + */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; + esac +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +s&@MKDIR_P@&$ac_MKDIR_P&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} + + rm -f "$ac_tmp/stdin" + case $ac_file in + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$ac_tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + fi + else + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 + fi +# Compute "$ac_file"'s index in $config_headers. +_am_arg="$ac_file" +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || +$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$_am_arg" : 'X\(//\)[^/]' \| \ + X"$_am_arg" : 'X\(//\)$' \| \ + X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$_am_arg" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'`/stamp-h$_am_stamp_count + ;; + + :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 +$as_echo "$as_me: executing $ac_file commands" >&6;} + ;; + esac + + + case $ac_file$ac_mode in + "depfiles":C) test x"$AMDEP_TRUE" != x"" || { + # Autoconf 2.62 quotes --file arguments for eval, but not when files + # are listed without --file. Let's play safe and only enable the eval + # if we detect the quoting. + case $CONFIG_FILES in + *\'*) eval set x "$CONFIG_FILES" ;; + *) set x $CONFIG_FILES ;; + esac + shift + for mf + do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # Grep'ing the whole file is not good either: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then + dirpart=`$as_dirname -- "$mf" || +$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$mf" : 'X\(//\)[^/]' \| \ + X"$mf" : 'X\(//\)$' \| \ + X"$mf" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`$as_dirname -- "$file" || +$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$file" : 'X\(//\)[^/]' \| \ + X"$file" : 'X\(//\)$' \| \ + X"$file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir=$dirpart/$fdir; as_fn_mkdir_p + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done + done +} + ;; + "libtool":C) + + # See if we are running on zsh, and set the options which allow our + # commands through without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + + cfgfile="${ofile}T" + trap "$RM \"$cfgfile\"; exit 1" 1 2 15 + $RM "$cfgfile" + + cat <<_LT_EOF >> "$cfgfile" +#! $SHELL + +# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# NOTE: Changes made to this file will be lost: look at ltmain.sh. +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, +# 2006, 2007, 2008 Free Software Foundation, Inc. +# Written by Gordon Matzigkeit, 1996 +# +# This file is part of GNU Libtool. +# +# GNU Libtool is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# As a special exception to the GNU General Public License, +# if you distribute this file as part of a program or library that +# is built using GNU Libtool, you may include this file under the +# same distribution terms that you use for the rest of that program. +# +# GNU Libtool is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Libtool; see the file COPYING. If not, a copy +# can be downloaded from http://www.gnu.org/licenses/gpl.html, or +# obtained by writing to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + +# The names of the tagged configurations supported by this script. +available_tags="CXX " + +# ### BEGIN LIBTOOL CONFIG + +# Which release of libtool.m4 was used? +macro_version=$macro_version +macro_revision=$macro_revision + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# What type of objects to build. +pic_mode=$pic_mode + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host +host_os=$host_os + +# The build system. +build_alias=$build_alias +build=$build +build_os=$build_os + +# A sed program that does not truncate output. +SED=$lt_SED + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="\$SED -e 1s/^X//" + +# A grep program that handles long lines. +GREP=$lt_GREP + +# An ERE matcher. +EGREP=$lt_EGREP + +# A literal string matcher. +FGREP=$lt_FGREP + +# A BSD- or MS-compatible name lister. +NM=$lt_NM + +# Whether we need soft or hard links. +LN_S=$lt_LN_S + +# What is the maximum length of a command? +max_cmd_len=$max_cmd_len + +# Object file suffix (normally "o"). +objext=$ac_objext + +# Executable file suffix (normally ""). +exeext=$exeext + +# whether the shell understands "unset". +lt_unset=$lt_unset + +# turn spaces into newlines. +SP2NL=$lt_lt_SP2NL + +# turn newlines into spaces. +NL2SP=$lt_lt_NL2SP + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# An object symbol dumper. +OBJDUMP=$lt_OBJDUMP + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == "file_magic". +file_magic_cmd=$lt_file_magic_cmd + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A symbol stripping program. +STRIP=$lt_STRIP + +# Commands used to install an old-style archive. +RANLIB=$lt_RANLIB +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# A C compiler. +LTCC=$lt_CC + +# LTCC compiler flags. +LTCFLAGS=$lt_CFLAGS + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration. +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair. +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# Transform the output of nm in a C name address pair when lib prefix is needed. +global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# An echo program that does not interpret backslashes. +ECHO=$lt_ECHO + +# Used to examine libraries when file_magic_cmd begins with "file". +MAGIC_CMD=$MAGIC_CMD + +# Must we lock files when doing compilation? +need_locks=$lt_need_locks + +# Tool to manipulate archived DWARF debug symbol files on Mac OS X. +DSYMUTIL=$lt_DSYMUTIL + +# Tool to change global to local symbols on Mac OS X. +NMEDIT=$lt_NMEDIT + +# Tool to manipulate fat objects and archives on Mac OS X. +LIPO=$lt_LIPO + +# ldd/readelf like tool for Mach-O binaries on Mac OS X. +OTOOL=$lt_OTOOL + +# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. +OTOOL64=$lt_OTOOL64 + +# Old archive suffix (normally "a"). +libext=$libext + +# Shared library suffix (normally ".so"). +shrext_cmds=$lt_shrext_cmds + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at link time. +variables_saved_for_relink=$lt_variables_saved_for_relink + +# Do we need the "lib" prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Library versioning type. +version_type=$version_type + +# Shared library runtime path variable. +runpath_var=$runpath_var + +# Shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Command to use after installation of a shared archive. +postinstall_cmds=$lt_postinstall_cmds + +# Command to use after uninstallation of a shared archive. +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# As "finish_cmds", except a single script fragment to be evaled but +# not shown. +finish_eval=$lt_finish_eval + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Compile-time system search path for libraries. +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries. +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + + +# The linker used to build libraries. +LD=$lt_LD + +# Commands used to build an old-style archive. +old_archive_cmds=$lt_old_archive_cmds + +# A language specific compiler. +CC=$lt_compiler + +# Is the compiler the GNU compiler? +with_gcc=$GCC + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc + +# Whether or not to disallow shared libs when runtime libs are static. +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec + +# Whether the compiler copes with passing no objects directly. +compiler_needs_object=$lt_compiler_needs_object + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds + +# Commands used to build a shared archive. +archive_cmds=$lt_archive_cmds +archive_expsym_cmds=$lt_archive_expsym_cmds + +# Commands used to build a loadable module if different from building +# a shared archive. +module_cmds=$lt_module_cmds +module_expsym_cmds=$lt_module_expsym_cmds + +# Whether we are building with GNU ld or not. +with_gnu_ld=$lt_with_gnu_ld + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag + +# Flag that enforces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec + +# If ld is used when linking, flag to hardcode \$libdir into a binary +# during linking. This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld + +# Whether we need a single "-rpath" flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator + +# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes +# DIR into the resulting binary. +hardcode_direct=$hardcode_direct + +# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes +# DIR into the resulting binary and the resulting library dependency is +# "absolute",i.e impossible to change by setting \${shlibpath_var} if the +# library is relocated. +hardcode_direct_absolute=$hardcode_direct_absolute + +# Set to "yes" if using the -LDIR flag during linking hardcodes DIR +# into the resulting binary. +hardcode_minus_L=$hardcode_minus_L + +# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR +# into the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var + +# Set to "yes" if building a shared library automatically hardcodes DIR +# into the library and all subsequent libraries and executables linked +# against it. +hardcode_automatic=$hardcode_automatic + +# Set to yes if linker adds runtime paths of dependent libraries +# to runtime path list. +inherit_rpath=$inherit_rpath + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path=$lt_fix_srcfile_path + +# Set to "yes" if exported symbols are required. +always_export_symbols=$always_export_symbols + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms + +# Commands necessary for linking programs (against libraries) with templates. +prelink_cmds=$lt_prelink_cmds + +# Specify filename containing input files. +file_list_spec=$lt_file_list_spec + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action + +# The directories searched by this compiler when creating a shared library. +compiler_lib_search_dirs=$lt_compiler_lib_search_dirs + +# Dependencies to place before and after the objects being linked to +# create a shared library. +predep_objects=$lt_predep_objects +postdep_objects=$lt_postdep_objects +predeps=$lt_predeps +postdeps=$lt_postdeps + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_compiler_lib_search_path + +# ### END LIBTOOL CONFIG + +_LT_EOF + + case $host_os in + aix3*) + cat <<\_LT_EOF >> "$cfgfile" +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +_LT_EOF + ;; + esac + + +ltmain="$ac_aux_dir/ltmain.sh" + + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + case $xsi_shell in + yes) + cat << \_LT_EOF >> "$cfgfile" + +# func_dirname file append nondir_replacement +# Compute the dirname of FILE. If nonempty, add APPEND to the result, +# otherwise set result to NONDIR_REPLACEMENT. +func_dirname () +{ + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac +} + +# func_basename file +func_basename () +{ + func_basename_result="${1##*/}" +} + +# func_dirname_and_basename file append nondir_replacement +# perform func_basename and func_dirname in a single function +# call: +# dirname: Compute the dirname of FILE. If nonempty, +# add APPEND to the result, otherwise set result +# to NONDIR_REPLACEMENT. +# value returned in "$func_dirname_result" +# basename: Compute filename of FILE. +# value retuned in "$func_basename_result" +# Implementation must be kept synchronized with func_dirname +# and func_basename. For efficiency, we do not delegate to +# those functions but instead duplicate the functionality here. +func_dirname_and_basename () +{ + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac + func_basename_result="${1##*/}" +} + +# func_stripname prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +func_stripname () +{ + # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are + # positional parameters, so assign one to ordinary parameter first. + func_stripname_result=${3} + func_stripname_result=${func_stripname_result#"${1}"} + func_stripname_result=${func_stripname_result%"${2}"} +} + +# func_opt_split +func_opt_split () +{ + func_opt_split_opt=${1%%=*} + func_opt_split_arg=${1#*=} +} + +# func_lo2o object +func_lo2o () +{ + case ${1} in + *.lo) func_lo2o_result=${1%.lo}.${objext} ;; + *) func_lo2o_result=${1} ;; + esac +} + +# func_xform libobj-or-source +func_xform () +{ + func_xform_result=${1%.*}.lo +} + +# func_arith arithmetic-term... +func_arith () +{ + func_arith_result=$(( $* )) +} + +# func_len string +# STRING may not start with a hyphen. +func_len () +{ + func_len_result=${#1} +} + +_LT_EOF + ;; + *) # Bourne compatible functions. + cat << \_LT_EOF >> "$cfgfile" + +# func_dirname file append nondir_replacement +# Compute the dirname of FILE. If nonempty, add APPEND to the result, +# otherwise set result to NONDIR_REPLACEMENT. +func_dirname () +{ + # Extract subdirectory from the argument. + func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` + if test "X$func_dirname_result" = "X${1}"; then + func_dirname_result="${3}" + else + func_dirname_result="$func_dirname_result${2}" + fi +} + +# func_basename file +func_basename () +{ + func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` +} + + +# func_stripname prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +# func_strip_suffix prefix name +func_stripname () +{ + case ${2} in + .*) func_stripname_result=`$ECHO "X${3}" \ + | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;; + *) func_stripname_result=`$ECHO "X${3}" \ + | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;; + esac +} + +# sed scripts: +my_sed_long_opt='1s/^\(-[^=]*\)=.*/\1/;q' +my_sed_long_arg='1s/^-[^=]*=//' + +# func_opt_split +func_opt_split () +{ + func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"` + func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"` +} + +# func_lo2o object +func_lo2o () +{ + func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"` +} + +# func_xform libobj-or-source +func_xform () +{ + func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[^.]*$/.lo/'` +} + +# func_arith arithmetic-term... +func_arith () +{ + func_arith_result=`expr "$@"` +} + +# func_len string +# STRING may not start with a hyphen. +func_len () +{ + func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` +} + +_LT_EOF +esac + +case $lt_shell_append in + yes) + cat << \_LT_EOF >> "$cfgfile" + +# func_append var value +# Append VALUE to the end of shell variable VAR. +func_append () +{ + eval "$1+=\$2" +} +_LT_EOF + ;; + *) + cat << \_LT_EOF >> "$cfgfile" + +# func_append var value +# Append VALUE to the end of shell variable VAR. +func_append () +{ + eval "$1=\$$1\$2" +} + +_LT_EOF + ;; + esac + + + sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" + + + cat <<_LT_EOF >> "$ofile" + +# ### BEGIN LIBTOOL TAG CONFIG: CXX + +# The linker used to build libraries. +LD=$lt_LD_CXX + +# Commands used to build an old-style archive. +old_archive_cmds=$lt_old_archive_cmds_CXX + +# A language specific compiler. +CC=$lt_compiler_CXX + +# Is the compiler the GNU compiler? +with_gcc=$GCC_CXX + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl_CXX + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic_CXX + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static_CXX + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc_CXX + +# Whether or not to disallow shared libs when runtime libs are static. +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX + +# Whether the compiler copes with passing no objects directly. +compiler_needs_object=$lt_compiler_needs_object_CXX + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX + +# Commands used to build a shared archive. +archive_cmds=$lt_archive_cmds_CXX +archive_expsym_cmds=$lt_archive_expsym_cmds_CXX + +# Commands used to build a loadable module if different from building +# a shared archive. +module_cmds=$lt_module_cmds_CXX +module_expsym_cmds=$lt_module_expsym_cmds_CXX + +# Whether we are building with GNU ld or not. +with_gnu_ld=$lt_with_gnu_ld_CXX + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag_CXX + +# Flag that enforces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag_CXX + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX + +# If ld is used when linking, flag to hardcode \$libdir into a binary +# during linking. This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_CXX + +# Whether we need a single "-rpath" flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX + +# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes +# DIR into the resulting binary. +hardcode_direct=$hardcode_direct_CXX + +# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes +# DIR into the resulting binary and the resulting library dependency is +# "absolute",i.e impossible to change by setting \${shlibpath_var} if the +# library is relocated. +hardcode_direct_absolute=$hardcode_direct_absolute_CXX + +# Set to "yes" if using the -LDIR flag during linking hardcodes DIR +# into the resulting binary. +hardcode_minus_L=$hardcode_minus_L_CXX + +# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR +# into the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX + +# Set to "yes" if building a shared library automatically hardcodes DIR +# into the library and all subsequent libraries and executables linked +# against it. +hardcode_automatic=$hardcode_automatic_CXX + +# Set to yes if linker adds runtime paths of dependent libraries +# to runtime path list. +inherit_rpath=$inherit_rpath_CXX + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs_CXX + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path=$lt_fix_srcfile_path_CXX + +# Set to "yes" if exported symbols are required. +always_export_symbols=$always_export_symbols_CXX + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds_CXX + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms_CXX + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms_CXX + +# Commands necessary for linking programs (against libraries) with templates. +prelink_cmds=$lt_prelink_cmds_CXX + +# Specify filename containing input files. +file_list_spec=$lt_file_list_spec_CXX + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action_CXX + +# The directories searched by this compiler when creating a shared library. +compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_CXX + +# Dependencies to place before and after the objects being linked to +# create a shared library. +predep_objects=$lt_predep_objects_CXX +postdep_objects=$lt_postdep_objects_CXX +predeps=$lt_predeps_CXX +postdeps=$lt_postdeps_CXX + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_compiler_lib_search_path_CXX + +# ### END LIBTOOL TAG CONFIG: CXX +_LT_EOF + + ;; + + esac +done # for ac_tag + + +as_fn_exit 0 +_ACEOF +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || as_fn_exit 1 +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + + +# Configuration results +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ########################################################################## + TCPREPLAY Suite Configuration Results (${TCPREPLAY_VERSION}) +########################################################################## +libpcap: ${foundpcap} (${libpcap_version}) +libdnet: ${founddnet} (${libdnet_version}) +autogen: ${AUTOGEN} (${AUTOGEN_VERSION}) +Use libopts tearoff: ${enable_local_libopts} +64bit counter support: ${use64bit_counters} +tcpdump binary path: ${tcpdump_path} +tcpreplay edit support: ${tcpreplay_edit} +fragroute support: ${enable_fragroute} +tcpbridge support: ${enable_tcpbridge} + +Supported Packet Injection Methods (*): +Linux PF_PACKET: ${have_pf} +BSD BPF: ${have_bpf} +libdnet: ${have_libdnet} +pcap_inject: ${have_pcap_inject} +pcap_sendpacket: ${have_pcap_sendpacket} ** + +* In order of preference; see configure --help to override +** Required for tcpbridge +" >&5 +$as_echo "########################################################################## + TCPREPLAY Suite Configuration Results (${TCPREPLAY_VERSION}) +########################################################################## +libpcap: ${foundpcap} (${libpcap_version}) +libdnet: ${founddnet} (${libdnet_version}) +autogen: ${AUTOGEN} (${AUTOGEN_VERSION}) +Use libopts tearoff: ${enable_local_libopts} +64bit counter support: ${use64bit_counters} +tcpdump binary path: ${tcpdump_path} +tcpreplay edit support: ${tcpreplay_edit} +fragroute support: ${enable_fragroute} +tcpbridge support: ${enable_tcpbridge} + +Supported Packet Injection Methods (*): +Linux PF_PACKET: ${have_pf} +BSD BPF: ${have_bpf} +libdnet: ${have_libdnet} +pcap_inject: ${have_pcap_inject} +pcap_sendpacket: ${have_pcap_sendpacket} ** + +* In order of preference; see configure --help to override +** Required for tcpbridge +" >&6; } + + +case $host in + *-apple-darwin*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Apple OS X versions prior to 10.5 (Leopard) has a serious problem! +Please see: http://tcpreplay.synfin.net/trac/ticket/142 for more details" >&5 +$as_echo "$as_me: WARNING: Apple OS X versions prior to 10.5 (Leopard) has a serious problem! +Please see: http://tcpreplay.synfin.net/trac/ticket/142 for more details" >&2;} + ;; + + *-*-cygwin) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Windows/Cygwin support is still somewhat experimental. +Please report any bugs! http://tcpreplay.synfin.net/trac/newticket" >&5 +$as_echo "$as_me: WARNING: Windows/Cygwin support is still somewhat experimental. +Please report any bugs! http://tcpreplay.synfin.net/trac/newticket" >&2;} + ;; +esac + diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..b321031 --- /dev/null +++ b/configure.ac @@ -0,0 +1,1255 @@ + +dnl $Id: configure.ac 2446 2010-03-30 04:58:36Z aturner $ + +AC_INIT(tcpreplay) +AC_CONFIG_SRCDIR(src/tcpreplay.c) +AM_CONFIG_HEADER(src/config.h) +AC_CONFIG_AUX_DIR(config) +AM_MAINTAINER_MODE +AM_WITH_DMALLOC + +dnl People building from SVN need the same version of Autogen as I'm using +dnl or specify --disable-local-libopts +MAINTAINER_AUTOGEN_VERSION=5.9.7 + +AC_CONFIG_MACRO_DIR([m4]) + +dnl Set version info here! +MAJOR_VERSION=3 +MINOR_VERSION=4 +MICRO_VERSION=4 +TCPREPLAY_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION +PACKAGE_URL=http://tcpreplay.synfin.net/ + +dnl Release is only used for the RPM spec file +TCPREPLAY_RELEASE=1 + +AC_DEFINE(PACKAGE, [tcpreplay], [This is our package name]) +AC_DEFINE_UNQUOTED(VERSION, "$TCPREPLAY_VERSION", [What is our version?]) +AC_SUBST(TCPREPLAY_VERSION) +AC_SUBST(TCPREPLAY_RELEASE) + +USER_CFLAGS=$CFLAGS +#CFLAGS="${CFLAGS} -Wall -O3 -std=gnu99" +CFLAGS="${CFLAGS} -Wall -g -O3 -std=gnu99 -DTCPBURST=1" +#CFLAGS="${CFLAGS} -Wall -g -O3 -std=gnu99 -DTCPBURST=1 -DMARSIO=1" + +dnl Determine OS +AC_CANONICAL_BUILD +AC_CANONICAL_HOST +AC_CANONICAL_TARGET +AC_SUBST(host) +AC_SUBST(build) +AC_SUBST(target) + +have_cygwin=no +AC_MSG_CHECKING([for cygwin development environment]) +if test `echo $target | grep -c cygwin` -gt 0 ; then + AC_DEFINE([HAVE_WIN32], [1], [Windows/Cygwin]) + AC_MSG_RESULT(yes) + have_cygwin=yes +else + AC_MSG_RESULT(no) +fi + + +AM_INIT_AUTOMAKE(tcpreplay, $TCPREPLAY_VERSION, nodefine) + +dnl Checks for programs. +AC_PROG_INSTALL +AC_PROG_LIBTOOL +AM_PROG_CC_C_O +AC_PROG_CC_STDC +AC_PROG_CXX +AC_PROG_CPP +AC_PROG_LN_S +LT_INIT +AC_PROG_AWK +AC_PROG_SED +AC_PROG_MAKE_SET +AC_EXEEXT +AC_PATH_PROG(PRINTF, printf) +AC_PATH_PROG(ECHO, echo) +AC_PATH_PROG(CUT, cut) +AC_PATH_PROG(AUTOGEN, autogen) +AC_PATH_PROG(GROFF, groff) + +dnl check autogen version +AUTOGEN_VERSION=unknown +if test -n "${AUTOGEN}" ; then + AC_MSG_CHECKING(for autogen version >= 5.9.x) + ${AUTOGEN} -v >autogen.version + AUTOGEN_VERSION=`cat autogen.version | ${SED} 's|.*\([[0-9\.]]\{5,\}\).*|\1|'` + AUTOGEN_MAJOR=`echo ${AUTOGEN_VERSION} | ${CUT} -d '.' -f 1` + AUTOGEN_MINOR=`echo ${AUTOGEN_VERSION} | ${CUT} -d '.' -f 2` + if ( test ${AUTOGEN_MAJOR} -eq 5 && test ${AUTOGEN_MINOR} -lt 9 ) || test ${AUTOGEN_MAJOR} -lt 5 ; then + AC_MSG_RESULT(no) + AC_MSG_WARN([${AUTOGEN} is too old (${AUTOGEN_VERSION}) for building from SVN. Please upgrade to 5.9.x)]) + else + AC_MSG_RESULT(yes) + fi + rm -f autogen.version + + dnl Compare the installed version with the maintainer version if building from SVN and not using system libopts + if test ! -f src/tcpreplay_opts.c && test "x$enable_local_libopts" = "xyes" ; then + if test $MAINTAINER_AUTOGEN_VERSION != $AUTOGEN_VERSION ; then + AC_MSG_ERROR([Your version of autogen ($AUTOGEN_VERSION) != libopts tear off ($MAINTAINER_AUTOGEN_VERSION) Either install the correct version or specify --disable-local-libopts]) + fi + fi +else + if test ! -f src/tcpreplay_opts.c ; then + AC_MSG_ERROR([Please install GNU autogen >= 5.9.x if you are building from SVN]) + fi +fi +AC_DEFINE([AUTOGEN_VERSION], [${AUTOGEN_VERSION}], [What version of autogen is installed on this system]) + +if test "x$enable_local_libopts" = "xyes" ; then + AC_MSG_NOTICE([Using included libopts tearoff]) +else + AC_MSG_NOTICE([Using system libopts]) +fi + +AC_HEADER_STDC +AC_HEADER_MAJOR + +dnl Checks for typedefs, structures, and compiler characteristics. +AC_TYPE_SIZE_T +AC_HEADER_TIME +AC_C_CONST +AC_C_INLINE +AC_SYS_LARGEFILE + +dnl Check for functions +AC_FUNC_FSEEKO + +dnl Check for types. +AC_CHECK_TYPE(u_int8_t, uint8_t) +AC_CHECK_TYPE(u_int16_t, uint16_t) +AC_CHECK_TYPE(u_int32_t, uint32_t) +AC_CHECK_TYPE(u_int64_t, uint64_t) + +dnl Older versions of GCC don't support these options +AC_MSG_CHECKING(for $CC -Wextra support) +OLD_CFLAGS=$CFLAGS +CFLAGS="$CFLAGS -Wextra" +wextra="" +AC_COMPILE_IFELSE([#include + int main(int argc, char *argv[]) { return(0); }], + [ AC_MSG_RESULT(yes) + wextra="-Wextra" ], + [ AC_MSG_RESULT(no) ]) +CFLAGS="$OLD_CFLAGS $wextra" + +AC_MSG_CHECKING(for $CC -Wno-variadic-macros support) +OLD_CFLAGS=$CFLAGS +CFLAGS="$CFLAGS -Wno-variadic-macros" +wno_variadic_macros="" +AC_COMPILE_IFELSE([#include + int main(int argc, char *argv[]) { return(0); }], + [ AC_MSG_RESULT(yes) + wno_variadic_macros="-Wno-variadic-macros" ], + [ AC_MSG_RESULT(no) ]) +CFLAGS="$OLD_CFLAGS $wno_variadic_macros" + +AC_MSG_CHECKING(for $CC -Wfatal-errors support) +OLD_CFLAGS=$CFLAGS +CFLAGS="$CFLAGS -Wfatal-errors" +wfatal_errors="" +AC_COMPILE_IFELSE([#include + int main(int argc, char *argv[]) { return(0); }], + [ AC_MSG_RESULT(yes) + wfatal_errors="-Wfatal-errors" ], + [ AC_MSG_RESULT(no) ]) +CFLAGS="$OLD_CFLAGS $wfatal_errors" + + +dnl Check for other header files +AC_CHECK_HEADERS([fcntl.h stddef.h sys/socket.h arpa/inet.h sys/time.h signal.h string.h strings.h sys/types.h stdint.h sys/select.h netinet/in.h poll.h sys/poll.h unistd.h sys/param.h]) + +dnl OpenBSD has special requirements +AC_CHECK_HEADERS([sys/sysctl.h net/route.h], [], [], [ +[#if HAVE_SYS_PARAM_H +#include +#endif +#if HAVE_SYS_TYPES_H +#include +#endif +#if HAVE_SYS_SOCKET_H +#include +#endif +]]) + + +dnl Checks for libraries. +AC_CHECK_LIB(socket, socket) +AC_CHECK_LIB(nsl, gethostbyname) +AC_CHECK_LIB(rt, nanosleep) +AC_CHECK_LIB(resolv, resolv) + +dnl Checks for library functions. +AC_FUNC_MALLOC +AC_FUNC_MEMCMP +AC_TYPE_SIGNAL +AC_FUNC_VPRINTF +AC_CHECK_MEMBERS([struct timeval.tv_sec]) + +AC_CHECK_FUNCS([gettimeofday ctime memset regcomp strdup strchr strerror strtol strncpy strtoull poll ntohll mmap snprintf vsnprintf strsignal]) + +dnl Look for strlcpy since some BSD's have it +AC_CHECK_FUNCS([strlcpy],have_strlcpy=true,have_strlcpy=false) +AM_CONDITIONAL(SYSTEM_STRLCPY, [test x$have_strlcpy = xtrue]) + +AC_C_BIGENDIAN +AM_CONDITIONAL([WORDS_BIGENDIAN], [ test x$ac_cv_c_bigendian = xyes ]) + + +dnl Enable debugging in code/compiler options +debug=no +AC_ARG_ENABLE(debug, + AC_HELP_STRING([--enable-debug], [Enable debugging code and support for the -d option]), + [ if test x$enableval = xyes; then + debug=yes + CFLAGS="${USER_CFLAGS} -ggdb -std=gnu99 -Wall $wextra $wfatal_errors $wno_variadic_macros" +# We may also want to add: +# -Wformat-security -Wswitch-default -Wunused-paramter -Wpadded" + AC_SUBST(debug_flag) + AC_DEFINE([DEBUG], [1], [Enable debuging code and support for the -d option]) + fi]) + + +AC_ARG_ENABLE(dmalloc, + AC_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]) + AC_DEFINE([DMALLOC_FUNC_CHECK], [1], [Enable dmalloc function arg checking]) + CFLAGS="${CFLAGS} -I/opt/local/include" + DMALLOC_LIB="/opt/local/lib/libdmalloc.a" + AC_SUBST(DMALLOC_LIB) + fi]) + + +AC_ARG_ENABLE(pedantic, + AC_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]), + [ if test x$enableval = xyes; then + CFLAGS="$CFLAGS -lefence" + AC_DEFINE([EFENCE], [1], [Enable Electric Fence memory debugger]) + fi]) + +dnl Enable Gprof +AC_ARG_ENABLE(gprof, + AC_HELP_STRING([--enable-gprof], [Enable GNU Profiler]), + [ if test x$enableval = xyes; then + if test $debug = yes; then + CFLAGS="$CFLAGS -pg" + else + # GPROF requires gdb + CFLAGS="$CFLAGS -ggdb -pg -fprofile-arcs" + fi + AC_DEFINE([GPROF], [1], [Enable GNU Profiler]) + fi]) + +dnl Use 64bits for packet counters +use64bit_counters=yes +AC_ARG_ENABLE(64bits, + AC_HELP_STRING([--disable-64bits], [Do not use 64bit packet counters]), + [ + AC_MSG_NOTICE([Using u_int32_t for packet counters]) + ], + [ + AC_DEFINE([ENABLE_64BITS], [1], [Use 64bit packet counters]) + AC_MSG_NOTICE([Using u_int64_t for packet counters]) + ]) + + +# If we're running gcc add '-D_U_="__attribute__((unused))"' to CFLAGS as well, +# so we can use _U_ to flag unused function arguments and not get warnings +# about them. Otherwise, add '-D_U_=""', so that _U_ used to flag an unused +# function argument will compile with non-GCC compilers. +# +if test "x$GCC" = "xyes" ; then + CFLAGS="-D_U_=\"__attribute__((unused))\" $CFLAGS" +else + CFLAGS="-D_U_=\"\" $CFLAGS" +fi + + +AC_ARG_ENABLE(force-bpf, + AC_HELP_STRING([--enable-force-bpf], [Force using BPF for sending packets]), + [ AC_DEFINE([FORCE_INJECT_BPF], [1], [Force using BPF for sending packet])]) + +AC_ARG_ENABLE(force-pf, + AC_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]), + [ 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]), + [ 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]), + [ AC_DEFINE([FORCE_INJECT_PCAP_SENDPACKET], [1], [Force using libpcap's pcap_sendpacket() for sending packets])]) + +dnl Dynamic link libraries +dynamic_link=no +AC_ARG_ENABLE(dynamic-link, + AC_HELP_STRING([--enable-dynamic-link], [Dynamically link libraries]), + [ if test x$enableval = xyes; then + AC_DEFINE([ENABLE_DYNAMIC_LINK], [1], [Enable dynamically linking libs]) + dynamic_link=yes + fi + ]) + +dnl Check for inet_aton and inet_pton +AC_CHECK_FUNC(inet_aton, + AC_DEFINE([HAVE_INET_ATON], [1], [Do we have inet_aton?]) + inet_aton=yes, + inet_aton=no) +AC_CHECK_FUNC(inet_pton, + AC_DEFINE([HAVE_INET_PTON], [1], [Do we have inet_pton?]) + inet_pton=yes, + inet_pton=no) +AC_CHECK_FUNC(inet_ntop, + AC_DEFINE([HAVE_INET_NTOP], [1], [Do we have inet_ntop?]) + inet_ntop=yes, + inet_ntop=no) + +if test "$inet_ntop" = "no" -a "$inet_pton" = "no" ; then + AC_MSG_ERROR([We need either inet_ntop or inet_pton]) +fi + +AC_CHECK_FUNC(inet_addr, + AC_DEFINE([HAVE_INET_ADDR], [1], [Do we have inet_addr?]) + inet_addr=yes, + inet_addr=no) + +if test x$inet_addr = no ; then + AC_MSG_ERROR([We need inet_addr. See bug 26]) +fi + +dnl ##################################################### +dnl Checks for libpcap +dnl ##################################################### +foundpcap=no +trypcapdir=/usr/local +AC_MSG_CHECKING(for libpcap) +AC_ARG_WITH(libpcap, + AC_HELP_STRING([--with-libpcap=DIR], [Use libpcap in DIR]), + [trypcapdir=$withval]) + +for testdir in $trypcapdir /usr/local /opt/local /usr /wpdpack ; do + if test -f "${testdir}/include/pcap.h" -a $foundpcap = no ; then + LPCAPINC="${testdir}/include/pcap.h" + LPCAPINCDIR="${testdir}/include" + if test $dynamic_link = yes; then + if test -f "${testdir}/lib64/libpcap${shrext_cmds}" ; then + LPCAPLIB="-L${testdir}/lib64 -lpcap" + elif test -f "${testdir}/lib/libpcap${shrext_cmds}" ; then + LPCAPLIB="-L${testdir}/lib -lpcap" + else + AC_ERROR([Unable to find libpcap in ${testdir}]) + fi + elif test -f "${testdir}/lib64/libpcap.${libext}" ; then + LPCAPLIB="${testdir}/lib64/libpcap.${libext}" + elif test -f "${testdir}/lib/libpcap.${libext}" ; then + LPCAPLIB="${testdir}/lib/libpcap.${libext}" + elif test -f "${testdir}/lib/libwpcap.${libext}" ; then + LPCAPLIB="${testdir}/lib/libwpcap.${libext}" + AC_DEFINE([HAVE_WINPCAP], [1], [Do we have WinPcap?]) + else + AC_ERROR([Unable to find matching library for header file in ${testdir}]) + fi + foundpcap=$testdir + fi +done + +if test $foundpcap = no ; then + AC_MSG_RESULT(no) + AC_ERROR(libpcap not found) +else + AC_MSG_RESULT($foundpcap) +fi + +dnl Checks to see what version of libpcap we've got +OLDLIBS="$LIBS" +OLDCFLAGS="$CFLAGS -I$LPCAPINCDIR" +LIBS="$LPCAPLIB" +CFLAGS="$CFLAGS -I$LPCAPINCDIR" + +# Does libpcap require libnl? +AC_SEARCH_LIBS([pcap_close], [pcap], + LPCAPLIB="$LIBS", + AC_ERROR([Unable to link libpcap in ${foundpcap}]), + -lnl) + +AC_SUBST(LPCAPINC) +AC_SUBST(LPCAPLIB) + + +dnl Check to see what version of libpcap +dnl this code has been reduced a lot, but probably still could be +dnl reduced quite a bit more if we chose too +AC_MSG_CHECKING(for libpcap version) + +dnl 0.9.6 (which is still thinks it is 0.9.5 due to a bug) introduces an important +dnl fix for OSX. See: http://tcpreplay.synfin.net/trac/ticket/167 +libpcap_version_096=no +AC_RUN_IFELSE(AC_LANG_PROGRAM([[ +#include +#include +#include +#include "$LPCAPINC" +#define PCAP_TEST "0.9.6" +]], [[ +/* + * simple proggy to test the version of libpcap + * returns zero if version >= 0.9.6 + * or one otherwise + */ + if (strncmp(pcap_lib_version(), PCAP_TEST, 5) >= 0) + exit(0); + + exit(1); +]]), [ + libpcap_version_096=yes +]) + +libpcap_ver8=no +AC_RUN_IFELSE(AC_LANG_PROGRAM([[ +#include +#include +#include +#include "$LPCAPINC" +#define PCAP_TEST "0.8" +]], [[ +/* + * simple proggy to test the version of libpcap + * returns zero if version >= 0.8.0 + * or one otherwise + */ + if (strncmp(pcap_lib_version(), PCAP_TEST, 3) >= 0) + exit(0); + + /* winpcap? */ + if (strncmp(pcap_lib_version(), "WinPcap", 7) == 0) + exit(0); + + exit(1); +]]), [ + libpcap_ver8=yes +], [ + libpcap_ver8=no +]) + +libpcap_ver7=no +AC_RUN_IFELSE(AC_LANG_PROGRAM([[ +#include +#include +#include +#include "$LPCAPINC" +#define PCAP_TEST "0.7.2" +extern const char pcap_version[[]]; /* double up since autoconf escapes things */ +]], [[ +/* + * simple proggy to test the version of libpcap + * returns zero if version >= 0.7.2 + * or one otherwise + */ + + if (strncmp(pcap_version, PCAP_TEST, 5) >= 0) + exit(0); + + exit(1); +]]), [ + libpcap_ver7=yes +], [ + libpcap_ver7=no +]) + +if test x$libpcap_ver8 = xyes ; then + AC_MSG_RESULT(>= 0.8.0) +elif test x$libpcap_ver7 = xyes ; then + AC_MSG_RESULT(>= 0.7.2) +else + AC_MSG_ERROR([Libpcap versions < 0.7.2 are not supported + Please upgrade to version 0.7.2 or better]) +fi + +libpcap_version=unknown +if test x$libpcap_version_096 = xyes ; then + libpcap_version=">= 0.9.6" +elif test x$libpcap_ver8 = xyes ; then + libpcap_version=">= 0.8.0" +elif test x$libcap_ver7 = xyes ; then + libpcap_version=">= 0.7.0" +fi + +dnl Check for pcap_setnonblock() +AC_MSG_CHECKING(for pcap_setnonblock) +AC_LINK_IFELSE(AC_LANG_PROGRAM([[ +#include +#include +#include +#include "$LPCAPINC" +]],[[ + pcap_t *p; + char *errbuf; + + pcap_setnonblock(p, 1, errbuf); + exit(0); +]]), [ + have_pcap_setnonblock=yes + AC_MSG_RESULT(yes) +], [ + have_pcap_setnonblock=no + AC_MSG_RESULT(no) +]) + +if test $have_pcap_setnonblock = yes ; then + AC_DEFINE([HAVE_PCAP_SETNONBLOCK], [1], + [Does libpcap have pcap_setnonblock?]) +fi + +dnl Check to see if we've got pcap_datalink_val_to_name() +AC_MSG_CHECKING(for pcap_datalink_val_to_description) +AC_LINK_IFELSE(AC_LANG_PROGRAM([[ +#include +#include +#include +#include "$LPCAPINC" +]],[[ + if (strcmp(pcap_datalink_val_to_description(1), "Ethernet (10Mb)") == 0) + exit(0); + exit(1); +]]),[ + have_dlt_to_desc=yes + AC_MSG_RESULT(yes) +], [ + have_dlt_to_desc=no + AC_MSG_RESULT(no) +]) + +if test $have_dlt_to_desc = yes ; then + AC_DEFINE([HAVE_DLT_VAL_TO_DESC], [1], + [Does libpcap have pcap_datalink_val_to_description?]) +fi + +dnl Check for pcap_get_selectable_fd() +AC_MSG_CHECKING(for pcap_get_selectable_fd) +AC_LINK_IFELSE(AC_LANG_PROGRAM([[ +#include +#include +#include +#include "$LPCAPINC" +]], [[ + int f; + pcap_t *p; + f = pcap_get_selectable_fd(p); + exit(0); +]]), [ + have_pcap_get_selectable_fd=yes + AC_MSG_RESULT(yes) +], [ + have_pcap_get_selectable_fd=no + AC_MSG_RESULT(no) +]) + +if test x$have_pcap_get_selectable_fd = xyes ; then + AC_DEFINE([HAVE_PCAP_GET_SELECTABLE_FD], [1], + [Does libpcap have pcap_get_selectable_fd?]) +fi + +dnl Important: winpcap apparently defines functions in it's header files +dnl which aren't actually in the library. Totally fucked up. Hence, we +dnl must actually LINK the code, not just compile it. + +dnl Check to see if we've got pcap_dump_fopen() +AC_MSG_CHECKING(for pcap_dump_fopen) +AC_LINK_IFELSE(AC_LANG_PROGRAM([[ +#include +#include +#include +#include "$LPCAPINC" +]],[[ + pcap_dumper_t *dump; + pcap_t *pcap; + FILE *foo; + dump = pcap_dump_fopen(pcap, foo); +]]),[ + have_pcap_dump_fopen=yes + AC_MSG_RESULT(yes) +], [ + have_pcap_dump_fopen=no + AC_MSG_RESULT(no) +]) + +if test $have_pcap_dump_fopen = yes ; then + AC_DEFINE([HAVE_PCAP_DUMP_FOPEN], [1], + [Does libpcap have pcap_dump_fopen?]) +else + AC_MSG_NOTICE([--verbose mode requires libpcap >= 0.9.0]) +fi + +have_pcap_inject=no +dnl Check to see if we've got pcap_inject() +AC_MSG_CHECKING(for pcap_inject sending support) +AC_LINK_IFELSE(AC_LANG_PROGRAM([[ +#include +#include +#include +#include "$LPCAPINC" +]],[[ + pcap_t *pcap; + char *buf; + pcap_inject(pcap, (void *)buf, 0); +]]),[ + have_pcap_inject=yes + AC_MSG_RESULT(yes) +], [ + have_pcap_inject=no + AC_MSG_RESULT(no) +]) + +if test $have_pcap_inject = yes ; then + AC_DEFINE([HAVE_PCAP_INJECT], [1], [Does libpcap have pcap_inject?]) +fi + +have_pcap_sendpacket=no +dnl Check to see if we've got pcap_sendpacket() +AC_MSG_CHECKING(for pcap_sendpacket sending support) +AC_LINK_IFELSE(AC_LANG_PROGRAM([[ +#include +#include +#include +#include "$LPCAPINC" +]],[[ + pcap_t *pcap; + u_char *buf; + pcap_sendpacket(pcap, buf, 0); +]]),[ + have_pcap_sendpacket=yes + AC_MSG_RESULT(yes) +], [ + have_pcap_sendpacket=no + AC_MSG_RESULT(no) +]) + +if test $have_pcap_sendpacket = yes ; then + AC_DEFINE([HAVE_PCAP_SENDPACKET], [1], [Does libpcap have pcap_sendpacket?]) +fi + +have_pcap_breakloop=no +AC_MSG_CHECKING(for pcap_breakloop) +AC_LINK_IFELSE(AC_LANG_PROGRAM([[ +#include +#include +#include +#include "$LPCAPINC" +]],[[ + pcap_t *pcap; + pcap_sendpacket(pcap); +]]),[ + have_pcap_breakloop=yes + AC_MSG_RESULT(yes) +], [ + have_pcap_breakloop=no + AC_MSG_RESULT(no) +]) + +if test $have_pcap_breakloop = yes ; then + AC_DEFINE([HAVE_PCAP_BREAKLOOP], [1], [Does libpcap have pcap_breakloop?]) +fi + + +have_pcap_version=no +dnl Check to see if we have pcap_version[] +AC_MSG_CHECKING(for pcap_version[]) +AC_TRY_COMPILE([ +#include +#include +#include +#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) +],[ + AC_MSG_RESULT(no) +]) + +have_pcap_snapshot=no +dnl Check for pcap_snapshot() +AC_MSG_CHECKING(for pcap_snapshot) +AC_LINK_IFELSE(AC_LANG_PROGRAM([[ +#include +#include +#include +#include "$LPCAPINC" +]],[[ + pcap_t *p; + int len; + + len = pcap_snapshot(p); + exit(0); +]]), [ + have_pcap_snapshot=yes + AC_MSG_RESULT(yes) +], [ + have_pcap_snapshot=no + AC_MSG_RESULT(no) +]) + +if test $have_pcap_snapshot = yes ; then + AC_DEFINE([HAVE_PCAP_SNAPSHOT], [1], + [Does libpcap have pcap_snapshot?]) +fi + + +# Tcpbridge requires libpcap and pcap_sendpacket() +enable_tcpbridge=no +if test x$foundpcap != xno -a x$have_pcap_sendpacket = xyes ; then + + # if we have pcap_sendpacket() then we can build tcpbridge on non-BPF systems + if test x$have_bpf = xno; then + AC_DEFINE(ENABLE_TCPBRIDGE, [1], [Compile tcpbridge]) + enable_tcpbridge=yes + AC_MSG_NOTICE([Building tcpbridge]) + + # BPF systems need to also have pcap_setnonblock() + elif test x$have_pcap_setnonblock = xyes ; then + AC_DEFINE(ENABLE_TCPBRIDGE, [1], [Compile tcpbridge]) + enable_tcpbridge=yes + AC_MSG_NOTICE([Building tcpbridge]) + else + AC_MSG_WARN([Unable to build tcpbridge. Try installing latest libpcap!]) + fi +fi +AM_CONDITIONAL(COMPILE_TCPBRIDGE, [test x$enable_tcpbridge = xyes ]) + + + +have_pf=no +dnl Check for linux PF_PACKET support +AC_MSG_CHECKING(for PF_PACKET socket sending support) +AC_TRY_COMPILE([ +#include +#include +#include /* the L2 protocols */ +#include /* 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) + have_pf=yes +],[ + AC_MSG_RESULT(no) +]) + +have_bpf=no +dnl Check for BSD's BPF +AC_MSG_CHECKING(for BPF device sending support) +AC_TRY_RUN([ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int +main(int argc, char *argv[]) { + int fd; + + fd = open("/dev/bpf0", O_RDONLY, 0); + + /* if we opened it, we're good */ + if (fd > 1) + exit(0); + + /* if we got EBUSY or permission denied it exists, so we're good */ + if (fd < 0 && (errno == EBUSY || errno == 13)) + exit(0); + + /* else suck, no good */ + exit(-1); +}], +[ + AC_DEFINE([HAVE_BPF], [1], + [Do we have BPF device support?]) + AC_MSG_RESULT(yes) + have_bpf=yes +],[ + AC_MSG_RESULT(no) +]) + + +dnl ################################################## +dnl # Check for libdnet, but only if not Cygwin! +dnl ################################################## +founddnet=no +have_libdnet=no +libdnet_version= +enable_fragroute=no +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]), + [trydnetdir=$withval]) + + for testdir in $trydnetdir /usr/local /opt/local /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 + AC_MSG_RESULT(no) + AC_MSG_WARN([libdnet not found, disabling fragroute feature]) + else + AC_MSG_RESULT($founddnet) + enable_fragroute=yes + have_libdnet=yes + AC_DEFINE([HAVE_LIBDNET], [1], [Do we have libdnet?]) + fi + +else + AC_MSG_NOTICE([Skipping libdnet check under Cygwin for compatibility reasons]) +fi + + +AC_SUBST(LDNETINC) +AC_SUBST(LDNETLIB) +AC_DEFINE_UNQUOTED([LIBDNET_VERSION], "$libdnet_version", [Version of libdnet]) + +AM_CONDITIONAL(COMPILE_FRAGROUTE, [test x$founddnet != xno]) +if test x$founddnet != xno ; then + AC_DEFINE(ENABLE_FRAGROUTE, [1], [Enable fragroute module]) +fi + + +dnl Make sure we have a valid packet injection mechanisim +if test $have_bpf = no -a $have_pcap_inject = no -a $have_pcap_sendpacket = no \ + -a $have_libdnet = no -a $have_pf = no ; then + AC_MSG_ERROR([Unable to find a supported method to send packets. Please upgrade your libpcap or enable libdnet]) +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; + foo = DLT_LINUX_SLL ], + [ AC_DEFINE([HAVE_DLT_LINUX_SLL], [1], + [Does pcap.h include a header with DLT_LINUX_SLL?]) + AC_MSG_RESULT(yes) + ], + AC_MSG_RESULT(no) + ) + +AC_MSG_CHECKING(for DLT_C_HDLC in libpcap) +AC_TRY_COMPILE([#include "$LPCAPINC"], + [ int foo; + foo = DLT_C_HDLC ], + [ AC_DEFINE([HAVE_DLT_C_HDLC], [1], + [Does pcap.h include a header with DLT_C_HDLC?]) + AC_MSG_RESULT(yes) + ], + AC_MSG_RESULT(no) + ) + +PCAP_BPF_H_FILE="$LPCAPINCDIR/pcap-bpf.h" +AC_MSG_CHECKING(for $PCAP_BPF_H_FILE) +AC_TRY_COMPILE([#include + #include + #include + #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) + ) + +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([ + #include + #include + #include + #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?]) + AC_MSG_RESULT($testfile) + ], + AC_MSG_RESULT(no) + ) + fi +done +dnl restore LIBS & CFLAGS +LIBS="$OLDLIBS" +CFLAGS="$OLDCFLAGS" + + +dnl ################################################## +dnl # Check for pcapnav +dnl ################################################## +pcapnav_ver=no +pcncfg=no +AC_ARG_WITH(pcapnav-config, + AC_HELP_STRING([--with-pcapnav-config=FILE], [Use given pcapnav-config]), + [ AC_MSG_CHECKING(for pcapnav-config) + if test -x $withval ; then + pcncfg=$withval + AC_MSG_RESULT($pcncfg) + elif test x$withval = xno ; then + AC_MSG_RESULT(no) + else + AC_MSG_RESULT([Can't find pcapnav-config: disabling offset jump feature]) + fi ], + [ AC_PATH_PROG(pcncfg,[pcapnav-config], [no] ) ] +) + +if test $pcncfg != no ; then + LNAVLIB=`$pcncfg --libs` + LNAV_CFLAGS=`$pcncfg --cflags` + PCAPNAV_VERSION=`$pcncfg --version` + AC_SUBST(LNAVLIB) + AC_SUBST(LNAV_CFLAGS) + AC_DEFINE_UNQUOTED(PCAPNAV_VERSION, "$PCAPNAV_VERSION", + [libpcapnav's version?]) + +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([ +#include +#define PCAPNAV_TEST "0.4" +/* + * simple proggy to test the version of libpcapnav + * returns zero if version >= 0.4 + * or one otherwise + */ + +int +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 + ) + + +if test x$libpcapnav_ver = xno ; then + AC_MSG_WARN([Libpcapnav versions < 0.4 are not supported. + Please upgrade to version 0.4 or better. + Disabling offset jump feature.]) +else + AC_DEFINE([HAVE_PCAPNAV], [1], [Do we have libpcapnav?]) +fi + +fi # checking pcapnav version + + +dnl (shamelessly ripped off from libpcap) +dnl Checks to see if unaligned memory accesses fail +dnl +dnl FORCE_ALIGN (DEFINED) +dnl +AC_MSG_CHECKING(for requires strict byte alignment) +AC_CACHE_VAL(unaligned_cv_fail, + [case "$host_cpu" in + + # XXX: should also check that they don't do weird things (like on arm) + alpha*|arm*|hp*|mips*|sparc*|ia64) + unaligned_cv_fail=yes + ;; + + *) + cat >conftest.c < + #include + #include + unsigned char a[[5]] = { 1, 2, 3, 4, 5 }; + main() { + unsigned int i; + pid_t pid; + int status; + /* avoid "core dumped" message */ + pid = fork(); + if (pid < 0) + exit(2); + if (pid > 0) { + /* parent */ + pid = waitpid(pid, &status, 0); + if (pid < 0) + exit(3); + exit(!WIFEXITED(status)); + } + /* child */ + i = *(unsigned int *)&a[[1]]; + printf("%d\n", i); + exit(0); + } +EOF + ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \ + conftest.c $LIBS >/dev/null 2>&1 + if test ! -x conftest ; then + dnl failed to compile for some reason + unaligned_cv_fail=yes + else + ./conftest >conftest.out + if test ! -s conftest.out ; then + unaligned_cv_fail=yes + else + unaligned_cv_fail=no + fi + fi + rm -f conftest* core core.conftest + ;; + + esac + ]) +AC_MSG_RESULT($unaligned_cv_fail) +if test $unaligned_cv_fail = yes ; then + AC_DEFINE([FORCE_ALIGN], [1], [Are we strictly aligned?]) +fi + +dnl ################################################## +dnl # Check for tcpdump. +dnl ################################################## + +tcpdump_path=no +AC_ARG_WITH(tcpdump, + AC_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]) + else + AC_MSG_RESULT([Error: $withval does not exist or is not executable]) + fi ], + [ AC_PATH_PROG(tcpdump_path, tcpdump, "no", [$PATH:/usr/sbin:/sbin:/usr/local/sbin]) ]) + + +if test "$tcpdump_path" = "no"; then + AC_MSG_WARN([Unable to find tcpdump. Please specify --with-tcpdump. + Disabling --verbose]) +else + AC_DEFINE([HAVE_TCPDUMP], [1], [Do we have tcpdump?]) + AC_DEFINE_UNQUOTED(TCPDUMP_BINARY, "$tcpdump_path", [The tcpdump binary initially used]) +fi + + +AM_CONDITIONAL([ENABLE_TCPDUMP], test "$tcpdump_path" != "no" -a x$have_pcap_dump_fopen = xyes) +if test x$tcpdump_path != xno -a x$have_pcap_dump_fopen = xyes ; then + AC_DEFINE([ENABLE_VERBOSE], [1], [Do we have tcpdump and pcap_dump_fopen()?]) +else + AC_MSG_WARN([Your version of libpcap is too old for --verbose support]) +fi + +dnl No 'make test' when cross compile + +AC_MSG_CHECKING(for 'make test' profile) +if test "$host" != "$build" ; then + AC_MSG_WARN(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]), + [ nic1=$withval + nic2=$withval + AC_MSG_RESULT([Using --with-testnic=$withval])], + [ + +dnl There's a bug in OS X which causes pcap_findalldevs() to make the wifi NIC to disassociate +dnl so under OSX we disable the interface list feature +disable_pcap_findalldevs=no + +osx_frameworks=no +dnl these need to be dynamic based on OS +case $host in + *-*-linux*) + nic1=eth0 + nic2=eth0 + AC_MSG_RESULT(Linux) + ;; + + *-*-solaris*) + nic1=hme0 + nic2=hme0 + AC_MSG_RESULT(Solaris) + ;; + + *-*-sunos*) + nic1=hme0 + nic2=hme0 + AC_MSG_RESULT(SunOS) + ;; + + *-apple-darwin*) + nic1=en0 + nic2=en0 + if test x$libpcap_version_096 = xno ; then + disable_pcap_findalldevs=yes + fi + AC_DEFINE([HAVE_ABSOLUTE_TIME], [1], [Have OS X UpTime()/AbsoluteTime high-precision timing]) + osx_frameworks=yes + AC_DEFINE([HAVE_DARWIN], [1], [Building Apple/Darwin]) + AC_MSG_RESULT(Apple OS X) + ;; + + *-*-openbsd*) + nic1=xl0 + nic2=xl0 + AC_MSG_RESULT(OpenBSD) + ;; + + *-*-cygwin) + AC_MSG_RESULT(Win32/Cygwin) + nic1=%0 + nic2=%0 + ;; + + *) + AC_MSG_RESULT([$host is unknown! Using first non-loopback interface]) + nic1=%0 + nic2=%0 + ;; +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]), + [ nic2=$withval ]) + +AC_MSG_NOTICE([Using $nic1 for 1st test network interface card]) +AC_MSG_NOTICE([Using $nic2 for 2nd test network interface card]) +AC_SUBST(nic1) +AC_SUBST(nic2) + + +AC_MSG_CHECKING([if it's ok to use pcap_findalldevs()]) +if test x$disable_pcap_findalldevs = xno ; then + AC_DEFINE([ENABLE_PCAP_FINDALLDEVS], [1], [Enable use of pcap_findalldevs()]) + AC_MSG_RESULT(yes) +else + AC_MSG_RESULT(no) +fi + +dnl tcpreplay has (so far) been relying on leading-edge autogen. +dnl Therefore, by default: +dnl - use the version we ship with +dnl - do not install it +dnl - build a static copy (AC_DISABLE_SHARED - implicitly done earlier) +case "${enable_local_libopts+set}" in + set) ;; + *) enable_local_libopts=yes ;; +esac + +case "${enable_libopts_install+set}" in + set) ;; + *) enable_libopts_install=no ;; +esac + +LIBOPTS_CHECK(libopts) + + +AC_OUTPUT([Makefile + doxygen.cfg + lib/Makefile + docs/Makefile + src/Makefile + src/common/Makefile + src/tcpedit/Makefile + src/fragroute/Makefile + src/defines.h + test/Makefile + test/config + scripts/Makefile]) + +# Configuration results +AC_MSG_RESULT( +########################################################################## + TCPREPLAY Suite Configuration Results (${TCPREPLAY_VERSION}) +########################################################################## +libpcap: ${foundpcap} (${libpcap_version}) +libdnet: ${founddnet} (${libdnet_version}) +autogen: ${AUTOGEN} (${AUTOGEN_VERSION}) +Use libopts tearoff: ${enable_local_libopts} +64bit counter support: ${use64bit_counters} +tcpdump binary path: ${tcpdump_path} +tcpreplay edit support: ${tcpreplay_edit} +fragroute support: ${enable_fragroute} +tcpbridge support: ${enable_tcpbridge} + +Supported Packet Injection Methods (*): +Linux PF_PACKET: ${have_pf} +BSD BPF: ${have_bpf} +libdnet: ${have_libdnet} +pcap_inject: ${have_pcap_inject} +pcap_sendpacket: ${have_pcap_sendpacket} ** + +* In order of preference; see configure --help to override +** Required for tcpbridge +) + + +case $host in + *-apple-darwin*) + AC_MSG_WARN([Apple OS X versions prior to 10.5 (Leopard) has a serious problem! +Please see: http://tcpreplay.synfin.net/trac/ticket/142 for more details]) + ;; + + *-*-cygwin) + AC_MSG_WARN([Windows/Cygwin support is still somewhat experimental. +Please report any bugs! http://tcpreplay.synfin.net/trac/newticket]) + ;; +esac + diff --git a/docs/CHANGELOG b/docs/CHANGELOG new file mode 100644 index 0000000..978ad02 --- /dev/null +++ b/docs/CHANGELOG @@ -0,0 +1,379 @@ +$Id: CHANGELOG 2449 2010-04-04 06:39:38Z aturner $ + +04/04/2010 Version 3.4.4 + - Set default timing method to either gtod or abstime (#404) + - Fix IPv6 parsing of CIDR's (#405) + - Add support for preloading the memory cache (#410) + - Generate more useful error when packets are too small (#411) + - Update to libopts/Autogen 5.9.9 (#412) + - Ship Win32Readme.txt file (#413) + - Update copyright notice to 2010 (#416) + - Dramatically enhance --portmap option (#417) + - Update autotools (#423) + - Add support for printing statistics periodically during the run (#424) + - Warn user when pcap snaplen < 65535 (#425) + - Add 802.1q processing support tcpprep (#428) + +06/25/2009: Version 3.4.3 + - Link libnl when newer versions of libpcap require it (#397) + - Ship m4 directory (#398) + - Upgrade to latest autotools scripts (#400) + - Fix error message when running autogen.sh (#401) + +05/20/2009: Version 3.4.2 + - Added extensive IPv6 support to tcprewrite & tcpreplay-edit (#11) + - Add IPv6 fragroute support (#388) + - Add IPv6 decoding support to tcpprep (#11) + - Fix compile time error in err.h (#390) + - Add --endpoints support in tcpreplay-edit (#393) + +02/18/2009: Version 3.4.1 + - Sendpacket method did not match documentation (#361) + - Fix compile issue on systems without err.h (#363) + - Fix tcpprep --mac not processing non-IPv4 packets (#369) + - Always build tcpreplay w/ editing features as tcpreplay-edit (#372) + - Fix potential tcpbridge issues under OS X & *BSD (#373) + - Fix crash on 4 byte strictly aligned systems (#377) + - Add MTU truncation to tcprewrite/tcpreplay-edit (#379) + +01/15/2009: Version 3.4.0 + - Add libdnet and remove libnet support for sending packets (#302) + - Fix numerous 802.11 decoder bugs (#325) + - Fix compile issue under Linux (#326) + - Fix Mbps/sec nonsense (#327) + - Fix tcprewrite crash when packets have no L3+ data (#328) + - Clean up err.c/err.h code and improve performance for non-debug builds (#331) + - Fix timesdiv() timer code (#332) + - Improve high-performance packet sending via multiple packets/interval (#334) + - Fix statistics report errors (#335) + - Fix BPF filters not being used in tcpbridge (#336) + - Improve tcpbridge performance (#337) + - Only use two libpcap handles for tcpbridge (#338) + - Fix autotools usage errors (#340) + - Clean up 'make test' results (#341) + - Update to AutoGen/AutoOpts 5.9.7 (#342) + - Fix compiler warnings from GCC 4.2 (#344) + - Fix numerous memory corruption bugs in libtcpedit DLT plugin code (#345) + - Add support for editing IPv4 TOS/DiffServ/ECN (#348) + - Update autotools to more recent versions (#349) + - Report injection method via -V (#352) + - Fix DLT_USER l2len check bug (#353) + - Replace man2html w/ groff (#354) + - Fix false pcap_inject() detection under Windows/Winpcap (#355) + - tcpbridge now builds under Win32/Cygwin + - libdnet is no longer an option for Win32/Cygwin (#57) + - tcpbridge now supports --listnics (#357) + +06/20/2008: Version 3.3.2 + - Fix (again) tcpbridge --unidir assert error (#308) + - Fix tcpbridge bug where all packets that were sent were all zeros + - Fix tcpbridge not honoring --include/exclude flags (#311) + - Fix ip_in_cidr() debug messages (#312) + - Report packets which have timestamps which go backwards in time (#315) + - Clean up --sleep-accel code to use options struct (#316) + - Remove really old and out of date RPM .spec file (#317) + - Warn when sending on non-Ethernet interface (#318) + - Re-enable tcpreplay --listnics (#319) + - Fix sendpacket always reporting using PF_PACKET, even when it doesn't (#322) + - Fix major packet timing issue under old versions of glibc (#324) + +05/17/2008: Version 3.3.1 + - Fix limitation of PF_PACKET only supporting Ethernet (#123) + - Fix (again) /dev/bpf detection in FreeBSD 8.0 (#292) + - Document building code from Subversion under Cygwin (#304) + - Fix --enable-force-* under Linux (#305) + - Fix tcpbridge --unidir assert error (#308) + +05/04/2008: Version 3.3.0 + - Improve tcpreplay timing accuracy between packets (#41) + - Add tcprewrite fragroute support (#42) + - Fix tcprewrite --efcs option (#277) + - Updated Win32/Cygwin documentation (#280) + - Add dmalloc support (#282) + - Fix tcpprep broken handling of VLAN tagged frames (#290) + - Fix tcprewrite crash when cache file has NO_SEND packets (#291) + - Fix /dev/bpf detection in FreeBSD 8.0 (#292) + - Add tcprewrite --ttl editing option (#294) + - Fix autoconf AM_PROG_CC_C_O warning (#295) + - Add tcpprep --reverse option to split by matching client addresses (#297) + - Update version of autoconf to 1.10.1 (#298) + - Improved GNU Autogen detection and warnings (#299) + - Track EAGAIN errors separately from ENOBUFS (#301) + - Automatically detect Winpcap on Cygwin (#303) + +01/23/2008: Version 3.2.5 + - Fix linker error with --enable-tcpreplay-edit and --enable-dynamic-link (#288) + - Fix compile errors with Sun Studio compiler (#286) + +01/16/2008: Version 3.2.4 + - Fix crash in tcpreplay when --enable-tcpreplay-edit (#281) + - Display if --enable-tcpreplay-edit in -V (#283) + +11/01/2007: Version 3.2.3 + - Fix compile issue under Linux and other OS's (#275) + +10/31/2007: Version 3.2.2 + - Enable source MAC spoofing for OS X (#142, #151) + * Tcpreplay now requires OS X 10.5 (Leopard) + - Fix crash/memory access error with tcpreplay -N (#273) + +10/25/2007: Version 3.2.1 + - Fix tcprewrite segfault in 'make test' under Linux (#200) + - Major performance improvement in tcpprep for large pcaps (#261) + - Fix strsignal already defined error under Cygwin/Windows (#199) + - Fix compile errors for older versions of GCC (#201) + - Remove flowreplay code (#262) + - Fix DLT rewrite code causing corrupted ethernet protocol type (#268) + - Try to fix inet_aton() issue under Solaris (#260) + +08/26/2007: Version 3.2 + - Return a more useful error message when tcpprep fails (#187) + - Add Tomahawk test tool client/server detection algorithm (#186) + - Improved AutoGen support (#191) + - Improved documentation (#164, #198) + - Added Doxygen markup (#176) + - configure now honors --with-tcpdump flag (#192) + - configure now defaults to --enable-64bits which breaks backwards + compatibility in certain situations. Use --disable-64bits if this + concerns you (#195) + - Use safe_free() to detect bugs earlier in development (#197) + +07/19/2007: Version 3.1.1 + - Upgrade libopts tearoff to 29:0:4 so that everyone else in the world can + compile tcpreplay (#189) + +07/18/2007: Version 3.1.0 + - Add tcprewrite --srcmap & --dstmap for rewriting only source or destination IP's (#185) + - ./configure now reports configuration at end (#155) + - Fix svn:keywords (#160) + - Optimize performance of dlt_en10mb plugin (#161) + - Performance improvements on strictly aligned systems (#162) + - Improve tcpprep error messages and handling (#163) + - Add support for warnings in libtcpedit (#165) + - Only use __attribute__((unused)) w/ GCC (#168) + - Fix compile issues under Solaris (#178) + - Gracefully handle systems w/o static libraries (#179) + - Fix segfault when using BPF filters (#182) + - Add additional DLT Plugins: + - 802.11 (#103) + - 802.11 w/ Radiotap (#177) + +05/01/2007: Version 3.0.1 + - Stop tcpreplay causing OS X WiFi from disassociating (#167) + - --pnat incorrectly matched all IP addresses (#170) + - Fix serious memory leak in core common library (#175) + - Fix tcprewrite --enet-vlan on little endian systems (#174) + - Bad pcap timestamps were causing excessive delays (#169) + - Code cleanup (#173) + +04/20/2007: Version 3.0 + - By default, no longer try to use libnet. You must now specify --enable-libnet (#148) + - Improve documentation (#30) + - General code cleanup (#47) + - Warn when GNU Autogen version < 5.9 (#153) + - Remove support for pcap_snapshot_override which was never added to libpcap (#140) + - Fix support for C99/GCC 4.3 "inline". Rely on -O3 for better performance. (#149) + - Prioritize 64 bit libraries over 32 bit counterparts (#150) + +04/14/2007: Version 3.0.RC1 + - Fix tcpbridge and make it compile by default (#15) + - Fix tcprewrite crash on little-endian systems (#127) + - Gracefully handle broken pcap files where the snaplen < caplen (#130) + - Note: Fix was made in libpcap and will be part of 0.9.6 + - Fix numerous bugs with the sendpacket code (#137) + - Add optional support for editing packets with tcpreplay (#61) + - Fix 'make test' on little endian systems (#64) + - tcprewrite -s is no longer endian dependent (#65) + - /docs cleaned up (#66) + - Fix detection/compile of libpcap. Now support versions >= 0.7.2 (#80, #144) + - Add official support Cygwin/Win32 support (#110) + - Clean up libpcap version code (#111) + - Add support for interface alias names for Win32 (#113) + - Warn user on DLT miss-match (#125) + - Fix tcprewrite segfault with --fixlen=pad (#134) + - Add loop/cache support for better performance (#136) + - inline debugging code for better performance (#138) + - configure now supports selecting injection method (#139) + - Fix configure/compile errors under OpenBSD (#146) + - Add tcpbridge --verbose mode (#28) + - Fix compile issues under HP-UX & strictly aligned systems (#141) + - --enable-dynamic-link supports 64bit libraries (#143) + + +03/22/2007: Version 3.0.beta13 + - Fixed detection of IPv4 packets in libtcpedit on little-endian boxes (#115, #116) + - Fixed TCP/UDP checksum calculation on little-endian boxes (#126) + - Added --quiet flag to tcpreplay for Lothar (#109) + - The --seed flag should now generate the same IPs on both little-endian & big-endian boxes (#65) + - The --skipl2broadcast flag now works as documented (#112) + - Adding L2 header for DLT_RAW encapsulated packets now works (#16) + - Clean up documentation (#66, #75) + - Start initial support for Win32 port (#110, #111) + - Finish DLT plugin rewrite (#82) + - Fix compile on systems without tcpdump installed + +02/22/2007: Version 3.0.beta12 + - Fix compile under RH ES 3.x (gcc 3.2.2) (#79) + - Fix compile on MIPS, ARM, HPPA, etc (#81, #88) + - Rewrite L2/DLT code in tcpedit/tcprewrite to be plugin based (#82) + - Create Ethernet Plugin (#99) + - Create User Plugin (#100) + - Create Cisco HDLC Plugin (#101) + - Create DLT_LINUX_SLL Plugin (#102) + - Create DLT_RAW Plugin (#104) + - Create DLT_NULL Plugin (#105) + - Create DLT_LOOP Plugin (#106) + - Properly decode ethernet frames when they are VLAN tagged (#84) + - Do not install man2html (#85) + - Add configure --disable-libopts-install option (#86) + - Enhance tcpreplay --oneatatime (#90) + - libtcpedit can now return warnings & errors (#92) + - Fix tcpprep --include/exclude (#96) + - Upgrade AutoGen tearoff (libopts) to latest version (5.9.0) (#97) + - Don't do L4 checksums for non-fragment offset == 0 (#107) + +08/07/2006: Version 3.0.beta11 + - Fix distribution to ship missing src/tcpr.h (#73) + - Add support to tcprewrite to alter output file DLT (#74) + - Fix errors in 'make test' (little endian still broken) (#77) + - Tweak Autogen .def files documentation (#78) + +08/05/2006: Version 3.0.beta10 + - tcpprep & tcprewrite no longer require root access (#3) + - Develop wrapper API for libnet, libpcap, BPF and PF_PACKET (#4, #24) + - Enhance do_sleep() to support looping for better accuracy (#6) + - Prefer inet_pton over older, deprecated routines (#26) + - Remove libnet as a requirement (#29) + - Optionally don't rewrite broadcast/multicast IP/MAC addresses (#38) + - Remove libnids dependancy for flowreplay (#55) + - Fix build issues when libpcapnav is installed (#56) + - Fix truncate feature not putting correct packet length in IP header (#59) + - Internal error reporting fixes in libtcpedit (#60) + - Support --enable-debug when building under gcc 3.x (#62) + - tcpedit_stub.h wasn't being generated automatically from SVN (#63) + - Fix 'make doxygen' (#67) + - Fix some Makefile issues (#68) + - tcprewrite --endpoints should require a cache file (#70) + - Improve IP randomizer code to be more random (#71) + +07/17/2006: Version 3.0.beta9 + - Fix compile issue for users not having AutoOpts installed (#54) + - Fix compile issue for users w/ AutoOpts 5.8.4 (upgrade to 5.8.4) + +07/16/2006: Version 3.0.beta8 + - Fix -M running in MBps rather then Mbps + - Fix tcpbridge segfault/bus error reported by Steven Z. (Gerry) + - Improve tcpbridge man page + - Massive tcprewrite fixes & cleanup (#50) + - Much improved README document + - Reorganize packet editing code into a standalone module (tcpedit) + which has been librarized. (#5) + - Strict code cleanup (#27) + - Fix tcpprep from generating bad cache files (#48) + - Add MAC split mode for tcpprep (#1) + - Improve dbg() to list file/line (#32) + - Add tcpprep statistical reports (#2) + - Reorganize flowreplay code (#46) + - Fix conflicting speed_t for Debian (#33) + - Too many other things to document + +08/07/2005: Version 3.0.beta7 + - New 'make doxygen' target builds pretty source code docs in + docs/web/doxygen/html + - Fix tcpprep auto/router mode which was sending all packets out the + secondary interface + - Fix endian issue on little-endian systems which made tcpprep think all + packets were not IP + - Improve debugability of tcpprep + - Fix UDP header offset bug in flowreplay + +06/28/2005: Version 3.0.beta6 + - Fix rpm .spec file which was still based on tcpreplay 2.x (untested) + - Detect and manually include pcap-bpf.h which fixes compile problem + - Fix tcprewrite -S crash with only one MAC + - Fix tcpreplay using 2nd NIC split mode + - Fix tcpreplay packet counter initialization + - Fix tcpprep to properly handle missing -i and -c with -I and -P + +06/14/2005: Version 3.0.beta5 + - Fix --decode flag + - Fix compile under AMD64/RHEL4 where libraries are in /usr/lib64 + - tarball now ships with a full test subdir + - Fix compile of src/common/get.c under strictly aligned architectures + - Fix ./configure --enable-64bits flag + - Fix bug on little endian systems which prevented tcprewrite from + editing packets + - Fix tcprewrite linktype checks + - Add --pktlen for when the pcap snaplen lies to us + - Add --enable-dynamic-link for those who want to dynamically link their + libs + +06/05/2005: Version 3.0.beta4 + - Really fix compile problems with dlt2desc with old versions of libpcap + - All libraries are now statically linked and full-path #includes. This + should fix problems with people who have different versions of + libraries installed in different locations. + - Fix problems compiling on systems with libpcapnav + - Add support for libpcap 0.5 such as on OpenBSD + - Fix tcpprep --verbose + - Close STDIN prior to re-opening it for certain OS's + +05/04/2005: Version 3.0.beta3 + - Fix autoconf problems with --with-libnet + - Fix compile problems with dlt2desc with old versions of libpcap + - Fix compile problem due to not shipping flowreplay_opts.h and + tcpbridge_opts.h + +04/19/2005: Version 3.0.beta2 + - Significant improvements to FAQ and manual + - Use autoopts for flowreplay + - Be more cautious about memcpy's + - Fix numerous warnings during compile + - Allow overriding L2 protocol field for DLT_RAW + - tcpprep -I & -P now take the cache filename + - Lots of cleanup + - Added tcpbridge utility + - Fix tcpreplay --mbps which was being interpreted as bps + - Add --no-arg-comment feature for tcpprep + - Improve auto-tests and fix old broken ones + - Fix Makefile errors in the docs directory + - Upgrade libopts tear off to v5.7pre12 which fixes problems with + loading config files + - Add support for forcing the use of the local libopts tearoff code + +02/27/2005: Version 3.0.beta1 + - Major code cleanups and rewriting + - Rip out all edit functions from tcpreplay and put into tcprewrite + - Improve tcpreplay performance by about 5% for raw sending + - Move around utility functions for greater code-reuse + - Move MAC Address funcs into mac.c + - Move global defines into defines.h + - Standardize use of structs and typedefs + - Start passing const's when we don't need to modify + - Start using GNU AutoOpts for arg/config file processing + - Start using automake and autoheader + - Major rewrite of configure.in + - Add support for printing which interface packets go out + - 64bit counters are optional via --enable-64bits + - Can now rewrite L2 data per outbound interface + - Add support for additional DLT types + + - Non-Code changes + - I now own the full copyright for tcpreplay + - Removed the evil 4th clause from the BSD license + - Start updating the FAQ and split some content to make a manual + - Automatically generate man pages based via autogen + + - New Applications: + - tcprewrite + + - Removed Applications: (Ethereal has better utilities) + - capinfo + - pcapmerge + + - Merge fixes from 2.x/stable branch: + - portmap.c endian bugs + - edit_packet.c handle corrupted pcap's where caplen < len + - configure now properly uses --with-libnet and --with-libpcap + +*** Fork 3.x Branch from v2.3.1 *** diff --git a/docs/CREDIT b/docs/CREDIT new file mode 100644 index 0000000..04a8744 --- /dev/null +++ b/docs/CREDIT @@ -0,0 +1,59 @@ +$Id: CREDIT 2308 2009-05-06 19:05:38Z aturner $ + +tcpreplay and it's associated utilities (tcpprep, tcprewrite and flowreplay) +were designed and written by Aaron Turner. + +This product includes software developed by the University of California, +Berkeley, Lawrence Berkeley Laboratory and its contributors. + +The following is a list of people in no particular order who have kindly +submitted patches or code snippets for me to use in tcpreplay. + +Matt Bing + - Matt helped write a lot of the 1.x code + +Branden Moore + - Patch to pad truncated packets + - Patch to allow specifying a destination MAC w/ only a single NIC + +Scott Mace + - Patch for tcpreplay to support CIDR mode + - Patch for ignoring martian IP packets + +Jeffrey Guttenfelder + - Code for pausing/restarting tcpreplay via signals. + +John Carlson + - Patch for improved timerdiv() accuracy + +Frey Kuo + - Patch to replace pause option with packets/sec + +Seth Robertson (seth at sysd dot com) + - Patch to allow replaying of live traffic + +Nick Mathewson + - Kindly giving me his BSD licensed implimentation of poll() + using select() so I don't have to worry about cross platform + issues. + +Denis McLaughlin + - Patch to allow TCP/UDP port translation + +Andrew Edgecombe + - Patch to support caching pcap files in memory when looping + which provides a significant performance improvement + - Patch to fix issue with -M option + +Joerg Mayer + - Patch for auto* to fix various warnings & errors + +Jim West + - Patch to fix Solaris compiling issues + +Bojan Smojver + - For maintaining the RPM package and helping with portability issues + +Stas Grabois + - For his efforts to add IPv6 support to tcpprep and the tcpedit engine + - For adding IPv6 support to fragroute diff --git a/docs/HACKING b/docs/HACKING new file mode 100644 index 0000000..0c02275 --- /dev/null +++ b/docs/HACKING @@ -0,0 +1,61 @@ +$Id: HACKING 1782 2007-04-02 04:21:30Z aturner $ + Guide to Hacking Tcpreplay + +[Note: Pay attention to the last update date at the top of this file. If it +was significantly long ago, this document may be out of date.] + +0. Contributing Code + +If you contribute code the following will happen: + a) You will be given credit in the CREDITS file + b) Your code will be licensed under the same license as that of tcpreplay + c) You will be assigning your copyright to me- Aaron Turner + +If you have any questions regarding any of the three above stipulations, +feel free to email the list at: tcpreplay-users@lists.sourceforge.net + + +1. Introduction + +If you're reading this to find out how to add a new feature or fix a bug in +tcpreplay or tcpprep, then you've come to the right place. This isn't the +place to find answers regarding how to use tcpreplay, the meaning of life, +etc. + +2. File Layout + +The file layout is pretty simple: + +/ - Base directory +/lib - 3rd party libraries stolen verbatim +/libopts - GNU AutoOpts tearoff +/src - Main code routines +/src/common - Common routines for all binaries +/src/tcpedit - libtcpedit +/docs - Where to find documentation +/test - Test scripts and stuff which is used during 'make test' + +3. Coding Standards +1) Indent 4 spaces using spaces, not tabs +2) Opening braces for control blocks (if, while, etc) should be on the same line +3) Opening braces for functions should be on next line +4) Use provided warnx, dbg, and errx functions provided in err.h +5) Use provided safe_strdup, safe_malloc and safe_realloc functions provided + in common/utils.h +6) Use provided strl* functions in lib/strlcat.c and lib/strlcpy.c + +4. Adding support for additional DLTs (Data Link Types) + +libtcpedit supports a plugin based architecture for handling different DLT +types. If you wish to add support for another DLT type, you should read: + +http://tcpreplay.synfin.net/trac/wiki/tcpeditDeveloper + +Which contains information on creating new DLT plugins. + +5. Hacking tcprewrite + +Tcprewrite is basically a front-end to libtcpedit. Hence any packet editing +improvements should be done there. However, please remember that tcprewrite +is not the only application which uses libtcpedit (tcpbridge is another +example) so make sure you test your code there too. diff --git a/docs/INSTALL b/docs/INSTALL new file mode 100644 index 0000000..8accca3 --- /dev/null +++ b/docs/INSTALL @@ -0,0 +1,6 @@ +$Id: INSTALL 1762 2007-03-24 20:42:05Z aturner $ + +NOTE: This information is out of date. Please see the tcpreplay wiki +for updated information: + +http://tcpreplay.synfin.net/trac/wiki/manual#GettingTcpreplayInstalled diff --git a/docs/LICENSE b/docs/LICENSE new file mode 100644 index 0000000..d8266cf --- /dev/null +++ b/docs/LICENSE @@ -0,0 +1,31 @@ +$Id: LICENSE 2441 2010-03-30 03:21:52Z aturner $ +Copyright (c) 2001-2010 Aaron Turner. aturner at synfin dot net +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. Neither the names of the copyright owners nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +This product includes software developed by the University of California, +Berkeley, Lawrence Berkeley Laboratory and its contributors. diff --git a/docs/Makefile.am b/docs/Makefile.am new file mode 100644 index 0000000..dfc5d73 --- /dev/null +++ b/docs/Makefile.am @@ -0,0 +1,41 @@ +MAKEFLAGS=-s + +.PHONY: manpages + +docs: clean-docs manpages + +web/tcpreplay.html: + @GROFF@ -Thtml -mman ../src/tcpreplay.1 > web/tcpreplay.html + +web/tcpprep.html: + @GROFF@ -Thtml -mman ../src/tcpprep.1 > web/tcpprep.html + +web/tcprewrite.html: + @GROFF@ -Thtml -mman ../src/tcprewrite.1 > web/tcprewrite.html + +web/tcpbridge.html: + @GROFF@ -Thtml -mman ../src/tcpbridge.1 > web/tcpbridge.html + +web/tcpreplay-edit.html: + @GROFF@ -Thtml -mman ../src/tcpreplay-edit.1 > web/tcpreplay-edit.html + +manpages: web/tcpreplay.html web/tcpprep.html web/tcprewrite.html \ + web/tcpbridge.html web/tcpreplay-edit.html + +postweb: manpages + rsync -qe ssh --exclude '.svn/' --exclude '/**/.svn/' --exclude '/**~' \ + --exclude '*~' -avz web/ \ + aturner@malbec.synfin.net:/var/vhosts/tcpreplay/ + scp CHANGELOG TODO aturner@malbec.synfin.net:/var/vhosts/tcpreplay/ + + +EXTRA_DIST = CHANGELOG CREDIT HACKING INSTALL LICENSE Win32Readme.txt + +clean-docs: clean + -rm -f web/*.html + +maintainer-clean-local: clean-docs + -rm -f web/*.html + +MAINTAINERCLEANFILES = Makefile.in + diff --git a/docs/Makefile.in b/docs/Makefile.in new file mode 100644 index 0000000..bc7a5d7 --- /dev/null +++ b/docs/Makefile.in @@ -0,0 +1,422 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = docs +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in INSTALL TODO +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/src/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +SOURCES = +DIST_SOURCES = +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOGEN = @AUTOGEN@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CUT = @CUT@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DMALLOC_LIB = @DMALLOC_LIB@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +GROFF = @GROFF@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LDNETINC = @LDNETINC@ +LDNETLIB = @LDNETLIB@ +LIBOBJS = @LIBOBJS@ +LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@ +LIBOPTS_DIR = @LIBOPTS_DIR@ +LIBOPTS_LDADD = @LIBOPTS_LDADD@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LNAVLIB = @LNAVLIB@ +LNAV_CFLAGS = @LNAV_CFLAGS@ +LN_S = @LN_S@ +LPCAPINC = @LPCAPINC@ +LPCAPLIB = @LPCAPLIB@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@ +PRINTF = @PRINTF@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TCPREPLAY_RELEASE = @TCPREPLAY_RELEASE@ +TCPREPLAY_VERSION = @TCPREPLAY_VERSION@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +debug_flag = @debug_flag@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +nic1 = @nic1@ +nic2 = @nic2@ +oldincludedir = @oldincludedir@ +pcncfg = @pcncfg@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +tcpdump_path = @tcpdump_path@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +MAKEFLAGS = -s +EXTRA_DIST = CHANGELOG CREDIT HACKING INSTALL LICENSE Win32Readme.txt +MAINTAINERCLEANFILES = Makefile.in +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu docs/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu docs/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *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);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic \ + maintainer-clean-local + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + distclean distclean-generic distclean-libtool 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 maintainer-clean-local mostlyclean \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + uninstall uninstall-am + + +.PHONY: manpages + +docs: clean-docs manpages + +web/tcpreplay.html: + @GROFF@ -Thtml -mman ../src/tcpreplay.1 > web/tcpreplay.html + +web/tcpprep.html: + @GROFF@ -Thtml -mman ../src/tcpprep.1 > web/tcpprep.html + +web/tcprewrite.html: + @GROFF@ -Thtml -mman ../src/tcprewrite.1 > web/tcprewrite.html + +web/tcpbridge.html: + @GROFF@ -Thtml -mman ../src/tcpbridge.1 > web/tcpbridge.html + +web/tcpreplay-edit.html: + @GROFF@ -Thtml -mman ../src/tcpreplay-edit.1 > web/tcpreplay-edit.html + +manpages: web/tcpreplay.html web/tcpprep.html web/tcprewrite.html \ + web/tcpbridge.html web/tcpreplay-edit.html + +postweb: manpages + rsync -qe ssh --exclude '.svn/' --exclude '/**/.svn/' --exclude '/**~' \ + --exclude '*~' -avz web/ \ + aturner@malbec.synfin.net:/var/vhosts/tcpreplay/ + scp CHANGELOG TODO aturner@malbec.synfin.net:/var/vhosts/tcpreplay/ + +clean-docs: clean + -rm -f web/*.html + +maintainer-clean-local: clean-docs + -rm -f web/*.html + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/docs/TODO b/docs/TODO new file mode 100644 index 0000000..dd06168 --- /dev/null +++ b/docs/TODO @@ -0,0 +1,151 @@ +This is a general list of things which should/could/may be done. +If any of these features interest you let me know- especially if you're +willing and able to help code it. In general, higher priority tasks are +tracked on the tcpreplay website: http://tcpreplay.synfin.net/ + +Legend: + - = Not started + + = Done + O = Mostly done + o = Started work + . = Canceled + ? = To think about + +GENERAL: + ++ Improve config file format + + better variable names + + use "var: value" format + + have tcpreplay, tcpprep, tcprewrite sections + + Being solved using GNU AutoOpts + ++ Improve autoconf detection of libraries + ++ Re-organize source tree + ++ tcpdump decoder should print packets syncronously w/ the main process + ++ Better use of GNU Autotools + ++ Improve CLI/config file parsing + ++ Only tcpreplay/tcpbridge should need to run as root. + ++ Tcpreplay should use raw sockets or BPF directly for writing rather then + libnet where applicable for theoretically higher performance. + +- Detect system version of libopts b/c we need a recent version + ++ Generalize packet editing and printing code so it can be shipped as a + seperate library and plugged into tcpreplay/tcprewrite/flowreplay/etc + ++ See about removing libnet_init() from all binaries other then tcprewrite + so we don't have to run as root: + . libnet_addr2name4 (ignore, doesn't require libnet_t context) + + libnet_name2addr4 + + libnet_get_hwaddr + + libnet_do_checksum + +TCPREPLAY: + +. Add support for dual-nic send on one intf, wait for packet, send next. + would be really useful for testing the effectiveness of how well an IPS + detects and blocks attacks. (TP's tomahawk does this even better then + described here, so why re-invent the wheel?) + +- Rewrite do_sleep() to handle sub sleep times by only nanosleep()'ing + once for multiple packets when the timestamps are close enough. We + also need to time nanosleep, since different architectures have lower + minimum sleep times (Linux/Alpha is 1ms vs. 10ms for Linux/x86) + ++ Tcpreplay should say which interface each packet is going out + +TCPBRIDGE: + +- Duplicate all tcprewrite functionality + +TCPREWRITE: + +- Support fragrouter like features + - basic IP fragmenation + - TCP fudging + - then more advanced stuff + - Can we integrate FR's code? + ++ Look at VLAN (802.1q) packets + - others non-vanilla types? + + Add tags? Remove tags? Change tags? + - Tag only one side of the connection + - Support Q-in-Q tags: + http://www.informit.com/articles/article.asp?p=101367&rl=1 + - Cisco's ISL trunking? + +- Add support for MPLS + +- Add support for GRE + http://www.linuxguruz.com/iptables/howto/2.4routing-5.html + Perhaps this should be done via the hardware interface rather then the GRE + virtual interface since libnet doesn't support the GRE virtual + ++ Add support for setting the ethernet protocol field so we can use + -I, -K to fill out an entire ethernet header w/o using -2 + ++ Add a secondary interface full layer two rewrite option + ++ Fix MAC rewriting to allow sending packets with a MAC of 00:00:00:00:00:00 + +- Add support for more linktypes (Prism Monitor, 802.11, FDDI, etc) + + Make it easier for others to add support for others + ++ Rip out packet munger from tcpreplay and put it into another tool so + that tcpreplay can be more optimized + ? perhaps use libnetdude? + ? make into a library? + + definately put it into a seperate binary (tcprewrite) + +- Add the ability to modify packet data via regex(es) in tcprewrite + - Should support pcre + - Support (foo) and $1, etc so new data can include old + - Limit matching which packets via BPF filter and tcpprep cache + (client/server) + - Step through packets ala tcpreplay and provide option to edit (Y/n) + +- Support connection tracking and generating 3way handshake for connections + missing them. + +- Bump Syn/Ack numbers by a pseudo random or given value so that running + the same pcap will behave as different streams. + +- IPv6 support? People ask for this every few months, but nobody actually + says they "need" or "really want" it; seems more of "gee, wouldn't it be + nice". What does that mean anyways??? + +- tcprewrite should be able to remove the two byte ethernet FCS (checksums) + at the end of the frame. + ++ Support randomization of IP addresses in ARP packets + +- Add support for rewriting MAC addresses in the ARP body for + tcprewrite/tcpbridge to allow proxy-arp like behaviour + +- Add support for IP fragmenting frames which are > MTU + + +TCPPREP: + ++ When splitting traffic via tcpprep print out each packet (tcpdump style) + so end users know where each packet is going + +FLOWREPLAY: + +- Improve flowreplay so it actually works + . Use libnids to read the pcaps. This seems DOA at this time since + libnids is GPL and the author is unwilling to make it support multiple + threads which flowreplay probably needs to be. The only other option is + a major rewrite which would break API compatibility. Doesn't seem worth + it. + - Allow handoff to a socket after user specified client/server exchanges + +- Perhaps integrate stick/snot/fpg logic into flowreplay: + http://www.geschke-online.de/FLoP/fpg.8.html + to do full 3way handshakes diff --git a/docs/Win32Readme.txt b/docs/Win32Readme.txt new file mode 100644 index 0000000..f4d1747 --- /dev/null +++ b/docs/Win32Readme.txt @@ -0,0 +1,106 @@ +$Id: Win32Readme.txt 2102 2009-01-04 22:52:51Z aturner $ +This document attempts to explain how to get tcpreplay compiled and running +under Windows. Please note that this document is a work in progress and +Windows support in general considered EXPERIMENTAL right now. + + +Background: + +Tcpreplay is not a native Win32 application right now. Hence it requires +Cygwin. (http://www.cygwin.com). Cygwin creates a Linux-like environment +on your Windows system which allows Linux/UNIX programs to run after a +recompile. + +Tcpreplay supports numerous API's for sending packets depending on the +operating system. Under Windows, the only supported method of sending +packets is with WinPcap 4.0. (http://www.winpcap.org) Please be sure to +install both the WinPcap driver AND the developer pack. + +Right now, I've only done testing under Windows XP. My guess is that 2000 +and 2003 should have no problems. Since WinPcap and Cygwin are EOL'ing +support for Win98/ME, I doubt that they'll ever be supported. Not sure +the story on Vista, but I assume WinPcap & Cygwin will support them sooner +or later if not already. Would love to hear if anyone has any luck one +way or another. + +What you will need: + +- Cygwin environment +- GCC compiler and system header files +- WinPcap 4.0 DLL +- WinPcap 4.0 Developer Pack aka WpdPack (headers, etc) + +Additional requirements if building from SVN: +- GNU build chain tools (Autoconf, Automake, Autoheader) +- GNU Autogen (*) + +* NOTE: The guile package which comes with Cygwin is broken and breaks +Autogen, so you'll need to compile guile from scratch to fix. Hence, I +strongly suggest you build Tcpreplay from the tarball and not SVN. See +below for how to "fix" this issue if you want to compile from SVN. + + + +******************************* IMPORTANT ****************************** +Note 1: +People have reported problems with WpdPack (the developer pack for +Winpcap) being installed outside of the Cygwin root directory. Hence, I +strongly recommend you install it under the Cygwin root as /WpdPack. + +Note 2: +There's a big problem with the Cygwin Guile package which breaks +GNU Autogen which Tcpreplay depends on when building from Subversion. + +What this means is that to build from Subversion you must do the following: +- Download GNU Guile from http://www.gnu.org/software/guile/guile.html + +- Extract the tarball and do the following: +libtoolize --copy --force +./configure +make +make install + +This will install guile in /usr/local. + +The other problem is that guile-config returns the linker flags in the wrong +order. To fix this, rename /usr/local/bin/guile-config to +/usr/local/bin/guile-config.original and create a new shell script in it's +place: + +---- BEGIN SHELL SCRIPT ---- +#!/bin/bash +# Replacement /usr/local/bin/guile-config script +if test -z "$1" ; then + guile-config.original +elif test "$1" == "link"; then + echo "-L/usr/local/lib -lguile -lltdl -lgmp -lcrypt -lm -lltdl" +else + guile-config.original $1 +fi +---- END SHELL SCRIPT ---- + +******************************* IMPORTANT ****************************** + +Directions: +- Install all the requirements + +- Enter into the Cygwin environment by clicking on the Cygwin icon + +- If you checked out the code from SVN, see Note 2 above and then run + the autogen.sh bootstrapper: + ./autogen.sh + +- Configure tcpreplay: + ./configure --enable-debug + +- Build tcpreplay: + make + +- Install: + make install + +- Try it out! + + + + diff --git a/doxygen.cfg.in b/doxygen.cfg.in new file mode 100644 index 0000000..4e69f38 --- /dev/null +++ b/doxygen.cfg.in @@ -0,0 +1,1230 @@ +# $Id$ +# Copyright 2005 +# Dorr H. Clark - Santa Clara University +# +# This software source is made available under the "THE BEER-WARE LICENSE" +# dclark@applmath.scu.edu wrote this file. As long as you +# retain this notice you can do whatever you want with this stuff. +# If we meet some day, and you think this stuff is worth it, +# you can buy me a beer in return. - Dorr H. Clark +# +# Doxyfile 1.4.1 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = TCPREPLAY + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = @TCPREPLAY_VERSION@ + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = docs/web/doxygen + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, +# Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, +# Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian, +# Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, +# Swedish, and Ukrainian. + +OUTPUT_LANGUAGE = English + +# This tag can be used to specify the encoding used in the generated output. +# The encoding is not always determined by the language that is chosen, +# but also whether or not the output is meant for Windows or non-Windows users. +# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES +# forces the Windows encoding (this is the default for the Windows binary), +# whereas setting the tag to NO uses a Unix-style encoding (the default for +# all platforms other than Windows). + +USE_WINDOWS_ENCODING = NO + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like the Qt-style comments (thus requiring an +# explicit @brief command for a brief description. + +JAVADOC_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the DETAILS_AT_TOP tag is set to YES then Doxygen +# will output the detailed description near the top, like JavaDoc. +# If set to NO, the detailed description appears after the member +# documentation. + +DETAILS_AT_TOP = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 4 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources +# only. Doxygen will then generate output that is more tailored for Java. +# For instance, namespaces will be presented as packages, qualified scopes +# will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = YES + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. + +SHOW_DIRECTORIES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from the +# version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the progam writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = \ +lib \ +libopts \ +libopts/compat \ +libopts/autoopts \ +src \ +src/common \ +src/tcpedit \ +src/flow + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm + +FILE_PATTERNS = + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. + +EXCLUDE_PATTERNS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER +# is applied to all files. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES (the default) +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES (the default) +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = YES + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 1 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be +# generated containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, +# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are +# probably better off using the HTML help feature. + +GENERATE_TREEVIEW = YES + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = NO + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = NO + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_PREDEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and will confuse +# the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option is superseded by the HAVE_DOT option below. This is only a +# fallback. It is recommended to install and use dot, since it yields more +# powerful graphs. + +CLASS_DIAGRAMS = YES + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = YES + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will +# generate a call dependency graph for every global function or class method. +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable call graphs for selected +# functions only using the \callgraph command. + +CALL_GRAPH = YES + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are png, jpg, or gif +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width +# (in pixels) of the graphs generated by dot. If a graph becomes larger than +# this value, doxygen will try to truncate the graph, so that it fits within +# the specified constraint. Beware that most browsers cannot cope with very +# large images. + +MAX_DOT_GRAPH_WIDTH = 1024 + +# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height +# (in pixels) of the graphs generated by dot. If a graph becomes larger than +# this value, doxygen will try to truncate the graph, so that it fits within +# the specified constraint. Beware that most browsers cannot cope with very +# large images. + +MAX_DOT_GRAPH_HEIGHT = 1024 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that a graph may be further truncated if the graph's +# image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH +# and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default), +# the graph is not depth-constrained. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, which results in a white background. +# Warning: Depending on the platform used, enabling this option may lead to +# badly anti-aliased labels on the edges of a graph (i.e. they become hard to +# read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- + +# The SEARCHENGINE tag specifies whether or not a search engine should be +# used. If set to NO the values of all tags below this one will be ignored. + +SEARCHENGINE = NO diff --git a/lib/Makefile.am b/lib/Makefile.am new file mode 100644 index 0000000..77ea82c --- /dev/null +++ b/lib/Makefile.am @@ -0,0 +1,9 @@ +noinst_LIBRARIES = libstrl.a + +libstrl_a_SOURCES = strlcat.c strlcpy.c + +noinst_HEADERS = strlcpy.h tree.h queue.h sll.h + +MOSTLYCLEANFILES = *~ *.o *.a + +MAINTAINERCLEANFILES = Makefile.in diff --git a/lib/Makefile.in b/lib/Makefile.in new file mode 100644 index 0000000..5e4a185 --- /dev/null +++ b/lib/Makefile.in @@ -0,0 +1,505 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = lib +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/src/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +LIBRARIES = $(noinst_LIBRARIES) +ARFLAGS = cru +libstrl_a_AR = $(AR) $(ARFLAGS) +libstrl_a_LIBADD = +am_libstrl_a_OBJECTS = strlcat.$(OBJEXT) strlcpy.$(OBJEXT) +libstrl_a_OBJECTS = $(am_libstrl_a_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src +depcomp = $(SHELL) $(top_srcdir)/config/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libstrl_a_SOURCES) +DIST_SOURCES = $(libstrl_a_SOURCES) +HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOGEN = @AUTOGEN@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CUT = @CUT@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DMALLOC_LIB = @DMALLOC_LIB@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +GROFF = @GROFF@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LDNETINC = @LDNETINC@ +LDNETLIB = @LDNETLIB@ +LIBOBJS = @LIBOBJS@ +LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@ +LIBOPTS_DIR = @LIBOPTS_DIR@ +LIBOPTS_LDADD = @LIBOPTS_LDADD@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LNAVLIB = @LNAVLIB@ +LNAV_CFLAGS = @LNAV_CFLAGS@ +LN_S = @LN_S@ +LPCAPINC = @LPCAPINC@ +LPCAPLIB = @LPCAPLIB@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@ +PRINTF = @PRINTF@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TCPREPLAY_RELEASE = @TCPREPLAY_RELEASE@ +TCPREPLAY_VERSION = @TCPREPLAY_VERSION@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +debug_flag = @debug_flag@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +nic1 = @nic1@ +nic2 = @nic2@ +oldincludedir = @oldincludedir@ +pcncfg = @pcncfg@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +tcpdump_path = @tcpdump_path@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +noinst_LIBRARIES = libstrl.a +libstrl_a_SOURCES = strlcat.c strlcpy.c +noinst_HEADERS = strlcpy.h tree.h queue.h sll.h +MOSTLYCLEANFILES = *~ *.o *.a +MAINTAINERCLEANFILES = Makefile.in +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu lib/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu lib/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *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);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libstrl.a: $(libstrl_a_OBJECTS) $(libstrl_a_DEPENDENCIES) + -rm -f libstrl.a + $(libstrl_a_AR) libstrl.a $(libstrl_a_OBJECTS) $(libstrl_a_LIBADD) + $(RANLIB) libstrl.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +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@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) $(HEADERS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLIBRARIES ctags 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 uninstall uninstall-am + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/lib/queue.h b/lib/queue.h new file mode 100644 index 0000000..3aef3c4 --- /dev/null +++ b/lib/queue.h @@ -0,0 +1,503 @@ +/* $OpenBSD: queue.h,v 1.22 2001/06/23 04:39:35 angelos Exp $ */ +/* $NetBSD: queue.h,v 1.11 1996/05/16 05:17:14 mycroft Exp $ */ + +/* + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)queue.h 8.5 (Berkeley) 8/20/94 + */ + +#ifndef _SYS_QUEUE_H_ +#define _SYS_QUEUE_H_ + +/* + * This file defines five types of data structures: singly-linked lists, + * lists, simple queues, tail queues, and circular queues. + * + * + * A singly-linked list is headed by a single forward pointer. The elements + * are singly linked for minimum space and pointer manipulation overhead at + * the expense of O(n) removal for arbitrary elements. New elements can be + * added to the list after an existing element or at the head of the list. + * Elements being removed from the head of the list should use the explicit + * macro for this purpose for optimum efficiency. A singly-linked list may + * only be traversed in the forward direction. Singly-linked lists are ideal + * for applications with large datasets and few or no removals or for + * implementing a LIFO queue. + * + * A list is headed by a single forward pointer (or an array of forward + * pointers for a hash table header). The elements are doubly linked + * so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before + * or after an existing element or at the head of the list. A list + * may only be traversed in the forward direction. + * + * A simple queue is headed by a pair of pointers, one the head of the + * list and the other to the tail of the list. The elements are singly + * linked to save space, so elements can only be removed from the + * head of the list. New elements can be added to the list before or after + * an existing element, at the head of the list, or at the end of the + * list. A simple queue may only be traversed in the forward direction. + * + * A tail queue is headed by a pair of pointers, one to the head of the + * list and the other to the tail of the list. The elements are doubly + * linked so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before or + * after an existing element, at the head of the list, or at the end of + * the list. A tail queue may be traversed in either direction. + * + * A circle queue is headed by a pair of pointers, one to the head of the + * list and the other to the tail of the list. The elements are doubly + * linked so that an arbitrary element can be removed without a need to + * traverse the list. New elements can be added to the list before or after + * an existing element, at the head of the list, or at the end of the list. + * A circle queue may be traversed in either direction, but has a more + * complex end of list detection. + * + * For details on the use of these macros, see the queue(3) manual page. + */ + +/* + * Singly-linked List definitions. + */ +#define SLIST_HEAD(name, type) \ +struct name { \ + struct type *slh_first; /* first element */ \ +} + +#define SLIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define SLIST_ENTRY(type) \ +struct { \ + struct type *sle_next; /* next element */ \ +} + +/* + * Singly-linked List access methods. + */ +#define SLIST_FIRST(head) ((head)->slh_first) +#define SLIST_END(head) NULL +#define SLIST_EMPTY(head) (SLIST_FIRST(head) == SLIST_END(head)) +#define SLIST_NEXT(elm, field) ((elm)->field.sle_next) + +#define SLIST_FOREACH(var, head, field) \ + for((var) = SLIST_FIRST(head); \ + (var) != SLIST_END(head); \ + (var) = SLIST_NEXT(var, field)) + +/* + * Singly-linked List functions. + */ +#define SLIST_INIT(head) { \ + SLIST_FIRST(head) = SLIST_END(head); \ +} + +#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \ + (elm)->field.sle_next = (slistelm)->field.sle_next; \ + (slistelm)->field.sle_next = (elm); \ +} while (0) + +#define SLIST_INSERT_HEAD(head, elm, field) do { \ + (elm)->field.sle_next = (head)->slh_first; \ + (head)->slh_first = (elm); \ +} while (0) + +#define SLIST_REMOVE_HEAD(head, field) do { \ + (head)->slh_first = (head)->slh_first->field.sle_next; \ +} while (0) + +#define SLIST_REMOVE(head, elm, type, field) do { \ + if ((head)->slh_first == (elm)) { \ + SLIST_REMOVE_HEAD((head), field); \ + } \ + else { \ + struct type *curelm = (head)->slh_first; \ + while( curelm->field.sle_next != (elm) ) \ + curelm = curelm->field.sle_next; \ + curelm->field.sle_next = \ + curelm->field.sle_next->field.sle_next; \ + } \ +} while (0) + +/* + * List definitions. + */ +#define LIST_HEAD(name, type) \ +struct name { \ + struct type *lh_first; /* first element */ \ +} + +#define LIST_HEAD_INITIALIZER(head) \ + { NULL } + +#define LIST_ENTRY(type) \ +struct { \ + struct type *le_next; /* next element */ \ + struct type **le_prev; /* address of previous next element */ \ +} + +/* + * List access methods + */ +#define LIST_FIRST(head) ((head)->lh_first) +#define LIST_END(head) NULL +#define LIST_EMPTY(head) (LIST_FIRST(head) == LIST_END(head)) +#define LIST_NEXT(elm, field) ((elm)->field.le_next) + +#define LIST_FOREACH(var, head, field) \ + for((var) = LIST_FIRST(head); \ + (var)!= LIST_END(head); \ + (var) = LIST_NEXT(var, field)) + +/* + * List functions. + */ +#define LIST_INIT(head) do { \ + LIST_FIRST(head) = LIST_END(head); \ +} while (0) + +#define LIST_INSERT_AFTER(listelm, elm, field) do { \ + if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ + (listelm)->field.le_next->field.le_prev = \ + &(elm)->field.le_next; \ + (listelm)->field.le_next = (elm); \ + (elm)->field.le_prev = &(listelm)->field.le_next; \ +} while (0) + +#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ + (elm)->field.le_prev = (listelm)->field.le_prev; \ + (elm)->field.le_next = (listelm); \ + *(listelm)->field.le_prev = (elm); \ + (listelm)->field.le_prev = &(elm)->field.le_next; \ +} while (0) + +#define LIST_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.le_next = (head)->lh_first) != NULL) \ + (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ + (head)->lh_first = (elm); \ + (elm)->field.le_prev = &(head)->lh_first; \ +} while (0) + +#define LIST_REMOVE(elm, field) do { \ + if ((elm)->field.le_next != NULL) \ + (elm)->field.le_next->field.le_prev = \ + (elm)->field.le_prev; \ + *(elm)->field.le_prev = (elm)->field.le_next; \ +} while (0) + +#define LIST_REPLACE(elm, elm2, field) do { \ + if (((elm2)->field.le_next = (elm)->field.le_next) != NULL) \ + (elm2)->field.le_next->field.le_prev = \ + &(elm2)->field.le_next; \ + (elm2)->field.le_prev = (elm)->field.le_prev; \ + *(elm2)->field.le_prev = (elm2); \ +} while (0) + +/* + * Simple queue definitions. + */ +#define SIMPLEQ_HEAD(name, type) \ +struct name { \ + struct type *sqh_first; /* first element */ \ + struct type **sqh_last; /* addr of last next element */ \ +} + +#define SIMPLEQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).sqh_first } + +#define SIMPLEQ_ENTRY(type) \ +struct { \ + struct type *sqe_next; /* next element */ \ +} + +/* + * Simple queue access methods. + */ +#define SIMPLEQ_FIRST(head) ((head)->sqh_first) +#define SIMPLEQ_END(head) NULL +#define SIMPLEQ_EMPTY(head) (SIMPLEQ_FIRST(head) == SIMPLEQ_END(head)) +#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) + +#define SIMPLEQ_FOREACH(var, head, field) \ + for((var) = SIMPLEQ_FIRST(head); \ + (var) != SIMPLEQ_END(head); \ + (var) = SIMPLEQ_NEXT(var, field)) + +/* + * Simple queue functions. + */ +#define SIMPLEQ_INIT(head) do { \ + (head)->sqh_first = NULL; \ + (head)->sqh_last = &(head)->sqh_first; \ +} while (0) + +#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (head)->sqh_first = (elm); \ +} while (0) + +#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.sqe_next = NULL; \ + *(head)->sqh_last = (elm); \ + (head)->sqh_last = &(elm)->field.sqe_next; \ +} while (0) + +#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\ + (head)->sqh_last = &(elm)->field.sqe_next; \ + (listelm)->field.sqe_next = (elm); \ +} while (0) + +#define SIMPLEQ_REMOVE_HEAD(head, elm, field) do { \ + if (((head)->sqh_first = (elm)->field.sqe_next) == NULL) \ + (head)->sqh_last = &(head)->sqh_first; \ +} while (0) + +/* + * Tail queue definitions. + */ +#define TAILQ_HEAD(name, type) \ +struct name { \ + struct type *tqh_first; /* first element */ \ + struct type **tqh_last; /* addr of last next element */ \ +} + +#define TAILQ_HEAD_INITIALIZER(head) \ + { NULL, &(head).tqh_first } + +#define TAILQ_ENTRY(type) \ +struct { \ + struct type *tqe_next; /* next element */ \ + struct type **tqe_prev; /* address of previous next element */ \ +} + +/* + * tail queue access methods + */ +#define TAILQ_FIRST(head) ((head)->tqh_first) +#define TAILQ_END(head) NULL +#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) +#define TAILQ_LAST(head, headname) \ + (*(((struct headname *)((head)->tqh_last))->tqh_last)) +/* XXX */ +#define TAILQ_PREV(elm, headname, field) \ + (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) +#define TAILQ_EMPTY(head) \ + (TAILQ_FIRST(head) == TAILQ_END(head)) + +#define TAILQ_FOREACH(var, head, field) \ + for((var) = TAILQ_FIRST(head); \ + (var) != TAILQ_END(head); \ + (var) = TAILQ_NEXT(var, field)) + +#define TAILQ_FOREACH_REVERSE(var, head, field, headname) \ + for((var) = TAILQ_LAST(head, headname); \ + (var) != TAILQ_END(head); \ + (var) = TAILQ_PREV(var, headname, field)) + +/* + * Tail queue functions. + */ +#define TAILQ_INIT(head) do { \ + (head)->tqh_first = NULL; \ + (head)->tqh_last = &(head)->tqh_first; \ +} while (0) + +#define TAILQ_INSERT_HEAD(head, elm, field) do { \ + if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ + (head)->tqh_first->field.tqe_prev = \ + &(elm)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm)->field.tqe_next; \ + (head)->tqh_first = (elm); \ + (elm)->field.tqe_prev = &(head)->tqh_first; \ +} while (0) + +#define TAILQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.tqe_next = NULL; \ + (elm)->field.tqe_prev = (head)->tqh_last; \ + *(head)->tqh_last = (elm); \ + (head)->tqh_last = &(elm)->field.tqe_next; \ +} while (0) + +#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ + if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ + (elm)->field.tqe_next->field.tqe_prev = \ + &(elm)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm)->field.tqe_next; \ + (listelm)->field.tqe_next = (elm); \ + (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ +} while (0) + +#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ + (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ + (elm)->field.tqe_next = (listelm); \ + *(listelm)->field.tqe_prev = (elm); \ + (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ +} while (0) + +#define TAILQ_REMOVE(head, elm, field) do { \ + if (((elm)->field.tqe_next) != NULL) \ + (elm)->field.tqe_next->field.tqe_prev = \ + (elm)->field.tqe_prev; \ + else \ + (head)->tqh_last = (elm)->field.tqe_prev; \ + *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ +} while (0) + +#define TAILQ_REPLACE(head, elm, elm2, field) do { \ + if (((elm2)->field.tqe_next = (elm)->field.tqe_next) != NULL) \ + (elm2)->field.tqe_next->field.tqe_prev = \ + &(elm2)->field.tqe_next; \ + else \ + (head)->tqh_last = &(elm2)->field.tqe_next; \ + (elm2)->field.tqe_prev = (elm)->field.tqe_prev; \ + *(elm2)->field.tqe_prev = (elm2); \ +} while (0) + +/* + * Circular queue definitions. + */ +#define CIRCLEQ_HEAD(name, type) \ +struct name { \ + struct type *cqh_first; /* first element */ \ + struct type *cqh_last; /* last element */ \ +} + +#define CIRCLEQ_HEAD_INITIALIZER(head) \ + { CIRCLEQ_END(&head), CIRCLEQ_END(&head) } + +#define CIRCLEQ_ENTRY(type) \ +struct { \ + struct type *cqe_next; /* next element */ \ + struct type *cqe_prev; /* previous element */ \ +} + +/* + * Circular queue access methods + */ +#define CIRCLEQ_FIRST(head) ((head)->cqh_first) +#define CIRCLEQ_LAST(head) ((head)->cqh_last) +#define CIRCLEQ_END(head) ((void *)(head)) +#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next) +#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev) +#define CIRCLEQ_EMPTY(head) \ + (CIRCLEQ_FIRST(head) == CIRCLEQ_END(head)) + +#define CIRCLEQ_FOREACH(var, head, field) \ + for((var) = CIRCLEQ_FIRST(head); \ + (var) != CIRCLEQ_END(head); \ + (var) = CIRCLEQ_NEXT(var, field)) + +#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \ + for((var) = CIRCLEQ_LAST(head); \ + (var) != CIRCLEQ_END(head); \ + (var) = CIRCLEQ_PREV(var, field)) + +/* + * Circular queue functions. + */ +#define CIRCLEQ_INIT(head) do { \ + (head)->cqh_first = CIRCLEQ_END(head); \ + (head)->cqh_last = CIRCLEQ_END(head); \ +} while (0) + +#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ + (elm)->field.cqe_next = (listelm)->field.cqe_next; \ + (elm)->field.cqe_prev = (listelm); \ + if ((listelm)->field.cqe_next == CIRCLEQ_END(head)) \ + (head)->cqh_last = (elm); \ + else \ + (listelm)->field.cqe_next->field.cqe_prev = (elm); \ + (listelm)->field.cqe_next = (elm); \ +} while (0) + +#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \ + (elm)->field.cqe_next = (listelm); \ + (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \ + if ((listelm)->field.cqe_prev == CIRCLEQ_END(head)) \ + (head)->cqh_first = (elm); \ + else \ + (listelm)->field.cqe_prev->field.cqe_next = (elm); \ + (listelm)->field.cqe_prev = (elm); \ +} while (0) + +#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \ + (elm)->field.cqe_next = (head)->cqh_first; \ + (elm)->field.cqe_prev = CIRCLEQ_END(head); \ + if ((head)->cqh_last == CIRCLEQ_END(head)) \ + (head)->cqh_last = (elm); \ + else \ + (head)->cqh_first->field.cqe_prev = (elm); \ + (head)->cqh_first = (elm); \ +} while (0) + +#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \ + (elm)->field.cqe_next = CIRCLEQ_END(head); \ + (elm)->field.cqe_prev = (head)->cqh_last; \ + if ((head)->cqh_first == CIRCLEQ_END(head)) \ + (head)->cqh_first = (elm); \ + else \ + (head)->cqh_last->field.cqe_next = (elm); \ + (head)->cqh_last = (elm); \ +} while (0) + +#define CIRCLEQ_REMOVE(head, elm, field) do { \ + if ((elm)->field.cqe_next == CIRCLEQ_END(head)) \ + (head)->cqh_last = (elm)->field.cqe_prev; \ + else \ + (elm)->field.cqe_next->field.cqe_prev = \ + (elm)->field.cqe_prev; \ + if ((elm)->field.cqe_prev == CIRCLEQ_END(head)) \ + (head)->cqh_first = (elm)->field.cqe_next; \ + else \ + (elm)->field.cqe_prev->field.cqe_next = \ + (elm)->field.cqe_next; \ +} while (0) + +#define CIRCLEQ_REPLACE(head, elm, elm2, field) do { \ + if (((elm2)->field.cqe_next = (elm)->field.cqe_next) == \ + CIRCLEQ_END(head)) \ + (head).cqh_last = (elm2); \ + else \ + (elm2)->field.cqe_next->field.cqe_prev = (elm2); \ + if (((elm2)->field.cqe_prev = (elm)->field.cqe_prev) == \ + CIRCLEQ_END(head)) \ + (head).cqh_first = (elm2); \ + else \ + (elm2)->field.cqe_prev->field.cqe_next = (elm2); \ +} while (0) + +#endif /* !_SYS_QUEUE_H_ */ diff --git a/lib/sll.h b/lib/sll.h new file mode 100644 index 0000000..2741f2b --- /dev/null +++ b/lib/sll.h @@ -0,0 +1,139 @@ +/*- + * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from the Stanford/CMU enet packet filter, + * (net/enet.c) distributed as part of 4.3BSD, and code contributed + * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence + * Berkeley Laboratory. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#) $Header: /home/cvs/tcpreplay/sll.h,v 1.2 2003/12/16 03:58:37 aturner Exp $ (LBL) + */ + +/* + * For captures on Linux cooked sockets, we construct a fake header + * that includes: + * + * a 2-byte "packet type" which is one of: + * + * LINUX_SLL_HOST packet was sent to us + * LINUX_SLL_BROADCAST packet was broadcast + * LINUX_SLL_MULTICAST packet was multicast + * LINUX_SLL_OTHERHOST packet was sent to somebody else + * LINUX_SLL_OUTGOING packet was sent *by* us; + * + * a 2-byte Ethernet protocol field; + * + * a 2-byte link-layer type; + * + * a 2-byte link-layer address length; + * + * an 8-byte source link-layer address, whose actual length is + * specified by the previous value. + * + * All fields except for the link-layer address are in network byte order. + * + * DO NOT change the layout of this structure, or change any of the + * LINUX_SLL_ values below. If you must change the link-layer header + * for a "cooked" Linux capture, introduce a new DLT_ type (ask + * "tcpdump-workers@tcpdump.org" for one, so that you don't give it a + * value that collides with a value already being used), and use the + * new header in captures of that type, so that programs that can + * handle DLT_LINUX_SLL captures will continue to handle them correctly + * without any change, and so that capture files with different headers + * can be told apart and programs that read them can dissect the + * packets in them. + */ + + +#ifndef _SLL_H_ +#define _SLL_H_ + +/* + * A DLT_LINUX_SLL fake link-layer header. + */ +#define SLL_HDR_LEN 16 /* total header length */ +#define SLL_ADDRLEN 8 /* length of address field */ + +struct sll_header { + u_int16_t sll_pkttype; /* packet type */ + u_int16_t sll_hatype; /* link-layer address type */ + u_int16_t sll_halen; /* link-layer address length */ + u_int8_t sll_addr[SLL_ADDRLEN]; /* link-layer address */ + u_int16_t sll_protocol; /* protocol */ +}; + +/* + * The LINUX_SLL_ values for "sll_pkttype"; these correspond to the + * PACKET_ values on Linux, but are defined here so that they're + * available even on systems other than Linux, and so that they + * don't change even if the PACKET_ values change. + */ +#define LINUX_SLL_HOST 0 +#define LINUX_SLL_BROADCAST 1 +#define LINUX_SLL_MULTICAST 2 +#define LINUX_SLL_OTHERHOST 3 +#define LINUX_SLL_OUTGOING 4 + +/* + * The LINUX_SLL_ values for "sll_protocol"; these correspond to the + * ETH_P_ values on Linux, but are defined here so that they're + * available even on systems other than Linux. We assume, for now, + * that the ETH_P_ values won't change in Linux; if they do, then: + * + * if we don't translate them in "pcap-linux.c", capture files + * won't necessarily be readable if captured on a system that + * defines ETH_P_ values that don't match these values; + * + * if we do translate them in "pcap-linux.c", that makes life + * unpleasant for the BPF code generator, as the values you test + * for in the kernel aren't the values that you test for when + * reading a capture file, so the fixup code run on BPF programs + * handed to the kernel ends up having to do more work. + * + * Add other values here as necessary, for handling packet types that + * might show up on non-Ethernet, non-802.x networks. (Not all the ones + * in the Linux "if_ether.h" will, I suspect, actually show up in + * captures.) + */ +#define LINUX_SLL_P_802_3 0x0001 /* Novell 802.3 frames without 802.2 LLC header */ +#define LINUX_SLL_P_802_2 0x0004 /* 802.2 frames (not D/I/X Ethernet) */ + +#endif + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + diff --git a/lib/strlcat.c b/lib/strlcat.c new file mode 100644 index 0000000..2b6f1ad --- /dev/null +++ b/lib/strlcat.c @@ -0,0 +1,59 @@ +/* $OpenBSD: strlcat.c,v 1.11 2003/06/17 21:56:24 millert Exp $ */ + +/* + * Copyright (c) 1998 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char *rcsid = "$OpenBSD: strlcat.c,v 1.11 2003/06/17 21:56:24 millert Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include + +/* + * Appends src to string dst of size siz (unlike strncat, siz is the + * full size of dst, not space left). At most siz-1 characters + * will be copied. Always NUL terminates (unless siz <= strlen(dst)). + * Returns strlen(src) + MIN(siz, strlen(initial dst)). + * If retval >= siz, truncation occurred. + */ +size_t +strlcat(char *dst, const char *src, size_t siz) +{ + register char *d = dst; + register const char *s = src; + register size_t n = siz; + size_t dlen; + + /* Find the end of dst and adjust bytes left but don't go past end */ + while (n-- != 0 && *d != '\0') + d++; + dlen = d - dst; + n = siz - dlen; + + if (n == 0) + return(dlen + strlen(s)); + while (*s != '\0') { + if (n != 1) { + *d++ = *s; + n--; + } + s++; + } + *d = '\0'; + + return(dlen + (s - src)); /* count does not include NUL */ +} diff --git a/lib/strlcpy.c b/lib/strlcpy.c new file mode 100644 index 0000000..82cbfac --- /dev/null +++ b/lib/strlcpy.c @@ -0,0 +1,55 @@ +/* $OpenBSD: strlcpy.c,v 1.8 2003/06/17 21:56:24 millert Exp $ */ + +/* + * Copyright (c) 1998 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char *rcsid = "$OpenBSD: strlcpy.c,v 1.8 2003/06/17 21:56:24 millert Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include + +/* + * Copy src to string dst of size siz. At most siz-1 characters + * will be copied. Always NUL terminates (unless siz == 0). + * Returns strlen(src); if retval >= siz, truncation occurred. + */ +size_t +strlcpy(char *dst, const char *src, size_t siz) +{ + register char *d = dst; + register const char *s = src; + register size_t n = siz; + + /* Copy as many bytes as will fit */ + if (n != 0 && --n != 0) { + do { + if ((*d++ = *s++) == 0) + break; + } while (--n != 0); + } + + /* Not enough room in dst, add NUL and traverse rest of src */ + if (n == 0) { + if (siz != 0) + *d = '\0'; /* NUL-terminate dst */ + while (*s++) + ; + } + + return(s - src - 1); /* count does not include NUL */ +} diff --git a/lib/strlcpy.h b/lib/strlcpy.h new file mode 100644 index 0000000..53aca8e --- /dev/null +++ b/lib/strlcpy.h @@ -0,0 +1,12 @@ +#ifndef _STRLCPY_H_ +#define _STRLCPY_H_ + +#include + +size_t +strlcpy(char *dst, const char *src, size_t size); + +size_t +strlcat(char *dst, const char *src, size_t size); + +#endif diff --git a/lib/tree.h b/lib/tree.h new file mode 100644 index 0000000..8f99ee9 --- /dev/null +++ b/lib/tree.h @@ -0,0 +1,675 @@ +/* $OpenBSD: tree.h,v 1.6 2002/06/11 22:09:52 provos Exp $ */ +/* + * Copyright 2002 Niels Provos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SYS_TREE_H_ +#define _SYS_TREE_H_ + +/* + * This file defines data structures for different types of trees: + * splay trees and red-black trees. + * + * A splay tree is a self-organizing data structure. Every operation + * on the tree causes a splay to happen. The splay moves the requested + * node to the root of the tree and partly rebalances it. + * + * This has the benefit that request locality causes faster lookups as + * the requested nodes move to the top of the tree. On the other hand, + * every lookup causes memory writes. + * + * The Balance Theorem bounds the total access time for m operations + * and n inserts on an initially empty tree as O((m + n)lg n). The + * amortized cost for a sequence of m accesses to a splay tree is O(lg n); + * + * A red-black tree is a binary search tree with the node color as an + * extra attribute. It fulfills a set of conditions: + * - every search path from the root to a leaf consists of the + * same number of black nodes, + * - each red node (except for the root) has a black parent, + * - each leaf node is black. + * + * Every operation on a red-black tree is bounded as O(lg n). + * The maximum height of a red-black tree is 2lg (n+1). + */ + +#define SPLAY_HEAD(name, type) \ +struct name { \ + struct type *sph_root; /* root of the tree */ \ +} + +#define SPLAY_INITIALIZER(root) \ + { NULL } + +#define SPLAY_INIT(root) do { \ + (root)->sph_root = NULL; \ +} while (0) + +#define SPLAY_ENTRY(type) \ +struct { \ + struct type *spe_left; /* left element */ \ + struct type *spe_right; /* right element */ \ +} + +#define SPLAY_LEFT(elm, field) (elm)->field.spe_left +#define SPLAY_RIGHT(elm, field) (elm)->field.spe_right +#define SPLAY_ROOT(head) (head)->sph_root +#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == NULL) + +/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */ +#define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \ + SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \ + SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ + (head)->sph_root = tmp; \ +} while (0) + +#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \ + SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \ + SPLAY_LEFT(tmp, field) = (head)->sph_root; \ + (head)->sph_root = tmp; \ +} while (0) + +#define SPLAY_LINKLEFT(head, tmp, field) do { \ + SPLAY_LEFT(tmp, field) = (head)->sph_root; \ + tmp = (head)->sph_root; \ + (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \ +} while (0) + +#define SPLAY_LINKRIGHT(head, tmp, field) do { \ + SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ + tmp = (head)->sph_root; \ + (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \ +} while (0) + +#define SPLAY_ASSEMBLE(head, node, left, right, field) do { \ + SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \ + SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field);\ + SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \ + SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \ +} while (0) + +/* Generates prototypes and inline functions */ + +#define SPLAY_PROTOTYPE(name, type, field, cmp) \ +void name##_SPLAY(struct name *, struct type *); \ +void name##_SPLAY_MINMAX(struct name *, int); \ +struct type *name##_SPLAY_INSERT(struct name *, struct type *); \ +struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \ + \ +/* Finds the node with the same key as elm */ \ +static __inline struct type * \ +name##_SPLAY_FIND(struct name *head, struct type *elm) \ +{ \ + if (SPLAY_EMPTY(head)) \ + return(NULL); \ + name##_SPLAY(head, elm); \ + if ((cmp)(elm, (head)->sph_root) == 0) \ + return (head->sph_root); \ + return (NULL); \ +} \ + \ +static __inline struct type * \ +name##_SPLAY_NEXT(struct name *head, struct type *elm) \ +{ \ + name##_SPLAY(head, elm); \ + if (SPLAY_RIGHT(elm, field) != NULL) { \ + elm = SPLAY_RIGHT(elm, field); \ + while (SPLAY_LEFT(elm, field) != NULL) { \ + elm = SPLAY_LEFT(elm, field); \ + } \ + } else \ + elm = NULL; \ + return (elm); \ +} \ + \ +static __inline struct type * \ +name##_SPLAY_MIN_MAX(struct name *head, int val) \ +{ \ + name##_SPLAY_MINMAX(head, val); \ + return (SPLAY_ROOT(head)); \ +} + +/* Main splay operation. + * Moves node close to the key of elm to top + */ +#define SPLAY_GENERATE(name, type, field, cmp) \ +struct type * \ +name##_SPLAY_INSERT(struct name *head, struct type *elm) \ +{ \ + if (SPLAY_EMPTY(head)) { \ + SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \ + } else { \ + int __comp; \ + name##_SPLAY(head, elm); \ + __comp = (cmp)(elm, (head)->sph_root); \ + if(__comp < 0) { \ + SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field);\ + SPLAY_RIGHT(elm, field) = (head)->sph_root; \ + SPLAY_LEFT((head)->sph_root, field) = NULL; \ + } else if (__comp > 0) { \ + SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field);\ + SPLAY_LEFT(elm, field) = (head)->sph_root; \ + SPLAY_RIGHT((head)->sph_root, field) = NULL; \ + } else \ + return ((head)->sph_root); \ + } \ + (head)->sph_root = (elm); \ + return (NULL); \ +} \ + \ +struct type * \ +name##_SPLAY_REMOVE(struct name *head, struct type *elm) \ +{ \ + struct type *__tmp; \ + if (SPLAY_EMPTY(head)) \ + return (NULL); \ + name##_SPLAY(head, elm); \ + if ((cmp)(elm, (head)->sph_root) == 0) { \ + if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \ + (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);\ + } else { \ + __tmp = SPLAY_RIGHT((head)->sph_root, field); \ + (head)->sph_root = SPLAY_LEFT((head)->sph_root, field);\ + name##_SPLAY(head, elm); \ + SPLAY_RIGHT((head)->sph_root, field) = __tmp; \ + } \ + return (elm); \ + } \ + return (NULL); \ +} \ + \ +void \ +name##_SPLAY(struct name *head, struct type *elm) \ +{ \ + struct type __node, *__left, *__right, *__tmp; \ + int __comp; \ +\ + SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\ + __left = __right = &__node; \ +\ + while ((__comp = (cmp)(elm, (head)->sph_root))) { \ + if (__comp < 0) { \ + __tmp = SPLAY_LEFT((head)->sph_root, field); \ + if (__tmp == NULL) \ + break; \ + if ((cmp)(elm, __tmp) < 0){ \ + SPLAY_ROTATE_RIGHT(head, __tmp, field); \ + if (SPLAY_LEFT((head)->sph_root, field) == NULL)\ + break; \ + } \ + SPLAY_LINKLEFT(head, __right, field); \ + } else if (__comp > 0) { \ + __tmp = SPLAY_RIGHT((head)->sph_root, field); \ + if (__tmp == NULL) \ + break; \ + if ((cmp)(elm, __tmp) > 0){ \ + SPLAY_ROTATE_LEFT(head, __tmp, field); \ + if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\ + break; \ + } \ + SPLAY_LINKRIGHT(head, __left, field); \ + } \ + } \ + SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ +} \ + \ +/* Splay with either the minimum or the maximum element \ + * Used to find minimum or maximum element in tree. \ + */ \ +void name##_SPLAY_MINMAX(struct name *head, int __comp) \ +{ \ + struct type __node, *__left, *__right, *__tmp; \ +\ + SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\ + __left = __right = &__node; \ +\ + while (1) { \ + if (__comp < 0) { \ + __tmp = SPLAY_LEFT((head)->sph_root, field); \ + if (__tmp == NULL) \ + break; \ + if (__comp < 0){ \ + SPLAY_ROTATE_RIGHT(head, __tmp, field); \ + if (SPLAY_LEFT((head)->sph_root, field) == NULL)\ + break; \ + } \ + SPLAY_LINKLEFT(head, __right, field); \ + } else if (__comp > 0) { \ + __tmp = SPLAY_RIGHT((head)->sph_root, field); \ + if (__tmp == NULL) \ + break; \ + if (__comp > 0) { \ + SPLAY_ROTATE_LEFT(head, __tmp, field); \ + if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\ + break; \ + } \ + SPLAY_LINKRIGHT(head, __left, field); \ + } \ + } \ + SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ +} + +#define SPLAY_NEGINF -1 +#define SPLAY_INF 1 + +#define SPLAY_INSERT(name, x, y) name##_SPLAY_INSERT(x, y) +#define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y) +#define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y) +#define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y) +#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? NULL \ + : name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF)) +#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? NULL \ + : name##_SPLAY_MIN_MAX(x, SPLAY_INF)) + +#define SPLAY_FOREACH(x, name, head) \ + for ((x) = SPLAY_MIN(name, head); \ + (x) != NULL; \ + (x) = SPLAY_NEXT(name, head, x)) + +/* Macros that define a red-back tree */ +#define RB_HEAD(name, type) \ +struct name { \ + struct type *rbh_root; /* root of the tree */ \ +} + +#define RB_INITIALIZER(root) \ + { NULL } + +#define RB_INIT(root) do { \ + (root)->rbh_root = NULL; \ +} while (0) + +#define RB_BLACK 0 +#define RB_RED 1 +#define RB_ENTRY(type) \ +struct { \ + struct type *rbe_left; /* left element */ \ + struct type *rbe_right; /* right element */ \ + struct type *rbe_parent; /* parent element */ \ + int rbe_color; /* node color */ \ +} + +#define RB_LEFT(elm, field) (elm)->field.rbe_left +#define RB_RIGHT(elm, field) (elm)->field.rbe_right +#define RB_PARENT(elm, field) (elm)->field.rbe_parent +#define RB_COLOR(elm, field) (elm)->field.rbe_color +#define RB_ROOT(head) (head)->rbh_root +#define RB_EMPTY(head) (RB_ROOT(head) == NULL) + +#define RB_SET(elm, parent, field) do { \ + RB_PARENT(elm, field) = parent; \ + RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL; \ + RB_COLOR(elm, field) = RB_RED; \ +} while (0) + +#define RB_SET_BLACKRED(black, red, field) do { \ + RB_COLOR(black, field) = RB_BLACK; \ + RB_COLOR(red, field) = RB_RED; \ +} while (0) + +#ifndef RB_AUGMENT +#define RB_AUGMENT(x) +#endif + +#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \ + (tmp) = RB_RIGHT(elm, field); \ + if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field))) { \ + RB_PARENT(RB_LEFT(tmp, field), field) = (elm); \ + } \ + RB_AUGMENT(elm); \ + if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field))) { \ + if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ + RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ + else \ + RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ + RB_AUGMENT(RB_PARENT(elm, field)); \ + } else \ + (head)->rbh_root = (tmp); \ + RB_LEFT(tmp, field) = (elm); \ + RB_PARENT(elm, field) = (tmp); \ + RB_AUGMENT(tmp); \ +} while (0) + +#define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \ + (tmp) = RB_LEFT(elm, field); \ + if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field))) { \ + RB_PARENT(RB_RIGHT(tmp, field), field) = (elm); \ + } \ + RB_AUGMENT(elm); \ + if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field))) { \ + if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ + RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ + else \ + RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ + RB_AUGMENT(RB_PARENT(elm, field)); \ + } else \ + (head)->rbh_root = (tmp); \ + RB_RIGHT(tmp, field) = (elm); \ + RB_PARENT(elm, field) = (tmp); \ + RB_AUGMENT(tmp); \ +} while (0) + +/* Generates prototypes and inline functions */ +#define RB_PROTOTYPE(name, type, field, cmp) \ +void name##_RB_INSERT_COLOR(struct name *, struct type *); \ +void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\ +struct type *name##_RB_REMOVE(struct name *, struct type *); \ +struct type *name##_RB_INSERT(struct name *, struct type *); \ +struct type *name##_RB_FIND(struct name *, struct type *); \ +struct type *name##_RB_NEXT(struct name *, struct type *); \ +struct type *name##_RB_MINMAX(struct name *, int); \ + \ + +/* Main rb operation. + * Moves node close to the key of elm to top + */ +#define RB_GENERATE(name, type, field, cmp) \ +void \ +name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ +{ \ + struct type *parent, *gparent, *tmp; \ + while ((parent = RB_PARENT(elm, field)) && \ + RB_COLOR(parent, field) == RB_RED) { \ + gparent = RB_PARENT(parent, field); \ + if (parent == RB_LEFT(gparent, field)) { \ + tmp = RB_RIGHT(gparent, field); \ + if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ + RB_COLOR(tmp, field) = RB_BLACK; \ + RB_SET_BLACKRED(parent, gparent, field);\ + elm = gparent; \ + continue; \ + } \ + if (RB_RIGHT(parent, field) == elm) { \ + RB_ROTATE_LEFT(head, parent, tmp, field);\ + tmp = parent; \ + parent = elm; \ + elm = tmp; \ + } \ + RB_SET_BLACKRED(parent, gparent, field); \ + RB_ROTATE_RIGHT(head, gparent, tmp, field); \ + } else { \ + tmp = RB_LEFT(gparent, field); \ + if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ + RB_COLOR(tmp, field) = RB_BLACK; \ + RB_SET_BLACKRED(parent, gparent, field);\ + elm = gparent; \ + continue; \ + } \ + if (RB_LEFT(parent, field) == elm) { \ + RB_ROTATE_RIGHT(head, parent, tmp, field);\ + tmp = parent; \ + parent = elm; \ + elm = tmp; \ + } \ + RB_SET_BLACKRED(parent, gparent, field); \ + RB_ROTATE_LEFT(head, gparent, tmp, field); \ + } \ + } \ + RB_COLOR(head->rbh_root, field) = RB_BLACK; \ +} \ + \ +void \ +name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, struct type *elm) \ +{ \ + struct type *tmp; \ + while ((elm == NULL || RB_COLOR(elm, field) == RB_BLACK) && \ + elm != RB_ROOT(head)) { \ + if (RB_LEFT(parent, field) == elm) { \ + tmp = RB_RIGHT(parent, field); \ + if (RB_COLOR(tmp, field) == RB_RED) { \ + RB_SET_BLACKRED(tmp, parent, field); \ + RB_ROTATE_LEFT(head, parent, tmp, field);\ + tmp = RB_RIGHT(parent, field); \ + } \ + if ((RB_LEFT(tmp, field) == NULL || \ + RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\ + (RB_RIGHT(tmp, field) == NULL || \ + RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\ + RB_COLOR(tmp, field) = RB_RED; \ + elm = parent; \ + parent = RB_PARENT(elm, field); \ + } else { \ + if (RB_RIGHT(tmp, field) == NULL || \ + RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK) {\ + struct type *oleft; \ + if ((oleft = RB_LEFT(tmp, field)))\ + RB_COLOR(oleft, field) = RB_BLACK;\ + RB_COLOR(tmp, field) = RB_RED; \ + RB_ROTATE_RIGHT(head, tmp, oleft, field);\ + tmp = RB_RIGHT(parent, field); \ + } \ + RB_COLOR(tmp, field) = RB_COLOR(parent, field);\ + RB_COLOR(parent, field) = RB_BLACK; \ + if (RB_RIGHT(tmp, field)) \ + RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK;\ + RB_ROTATE_LEFT(head, parent, tmp, field);\ + elm = RB_ROOT(head); \ + break; \ + } \ + } else { \ + tmp = RB_LEFT(parent, field); \ + if (RB_COLOR(tmp, field) == RB_RED) { \ + RB_SET_BLACKRED(tmp, parent, field); \ + RB_ROTATE_RIGHT(head, parent, tmp, field);\ + tmp = RB_LEFT(parent, field); \ + } \ + if ((RB_LEFT(tmp, field) == NULL || \ + RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\ + (RB_RIGHT(tmp, field) == NULL || \ + RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\ + RB_COLOR(tmp, field) = RB_RED; \ + elm = parent; \ + parent = RB_PARENT(elm, field); \ + } else { \ + if (RB_LEFT(tmp, field) == NULL || \ + RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) {\ + struct type *oright; \ + if ((oright = RB_RIGHT(tmp, field)))\ + RB_COLOR(oright, field) = RB_BLACK;\ + RB_COLOR(tmp, field) = RB_RED; \ + RB_ROTATE_LEFT(head, tmp, oright, field);\ + tmp = RB_LEFT(parent, field); \ + } \ + RB_COLOR(tmp, field) = RB_COLOR(parent, field);\ + RB_COLOR(parent, field) = RB_BLACK; \ + if (RB_LEFT(tmp, field)) \ + RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK;\ + RB_ROTATE_RIGHT(head, parent, tmp, field);\ + elm = RB_ROOT(head); \ + break; \ + } \ + } \ + } \ + if (elm) \ + RB_COLOR(elm, field) = RB_BLACK; \ +} \ + \ +struct type * \ +name##_RB_REMOVE(struct name *head, struct type *elm) \ +{ \ + struct type *child, *parent, *old = elm; \ + int color; \ + if (RB_LEFT(elm, field) == NULL) \ + child = RB_RIGHT(elm, field); \ + else if (RB_RIGHT(elm, field) == NULL) \ + child = RB_LEFT(elm, field); \ + else { \ + struct type *left; \ + elm = RB_RIGHT(elm, field); \ + while ((left = RB_LEFT(elm, field))) \ + elm = left; \ + child = RB_RIGHT(elm, field); \ + parent = RB_PARENT(elm, field); \ + color = RB_COLOR(elm, field); \ + if (child) \ + RB_PARENT(child, field) = parent; \ + if (parent) { \ + if (RB_LEFT(parent, field) == elm) \ + RB_LEFT(parent, field) = child; \ + else \ + RB_RIGHT(parent, field) = child; \ + RB_AUGMENT(parent); \ + } else \ + RB_ROOT(head) = child; \ + if (RB_PARENT(elm, field) == old) \ + parent = elm; \ + (elm)->field = (old)->field; \ + if (RB_PARENT(old, field)) { \ + if (RB_LEFT(RB_PARENT(old, field), field) == old)\ + RB_LEFT(RB_PARENT(old, field), field) = elm;\ + else \ + RB_RIGHT(RB_PARENT(old, field), field) = elm;\ + RB_AUGMENT(RB_PARENT(old, field)); \ + } else \ + RB_ROOT(head) = elm; \ + RB_PARENT(RB_LEFT(old, field), field) = elm; \ + if (RB_RIGHT(old, field)) \ + RB_PARENT(RB_RIGHT(old, field), field) = elm; \ + if (parent) { \ + left = parent; \ + do { \ + RB_AUGMENT(left); \ + } while ((left = RB_PARENT(left, field))); \ + } \ + goto color; \ + } \ + parent = RB_PARENT(elm, field); \ + color = RB_COLOR(elm, field); \ + if (child) \ + RB_PARENT(child, field) = parent; \ + if (parent) { \ + if (RB_LEFT(parent, field) == elm) \ + RB_LEFT(parent, field) = child; \ + else \ + RB_RIGHT(parent, field) = child; \ + RB_AUGMENT(parent); \ + } else \ + RB_ROOT(head) = child; \ +color: \ + if (color == RB_BLACK) \ + name##_RB_REMOVE_COLOR(head, parent, child); \ + return (old); \ +} \ + \ +/* Inserts a node into the RB tree */ \ +struct type * \ +name##_RB_INSERT(struct name *head, struct type *elm) \ +{ \ + struct type *tmp; \ + struct type *parent = NULL; \ + int comp = 0; \ + tmp = RB_ROOT(head); \ + while (tmp) { \ + parent = tmp; \ + comp = (cmp)(elm, parent); \ + if (comp < 0) \ + tmp = RB_LEFT(tmp, field); \ + else if (comp > 0) \ + tmp = RB_RIGHT(tmp, field); \ + else \ + return (tmp); \ + } \ + RB_SET(elm, parent, field); \ + if (parent != NULL) { \ + if (comp < 0) \ + RB_LEFT(parent, field) = elm; \ + else \ + RB_RIGHT(parent, field) = elm; \ + RB_AUGMENT(parent); \ + } else \ + RB_ROOT(head) = elm; \ + name##_RB_INSERT_COLOR(head, elm); \ + return (NULL); \ +} \ + \ +/* Finds the node with the same key as elm */ \ +struct type * \ +name##_RB_FIND(struct name *head, struct type *elm) \ +{ \ + struct type *tmp = RB_ROOT(head); \ + int comp; \ + while (tmp) { \ + comp = cmp(elm, tmp); \ + if (comp < 0) \ + tmp = RB_LEFT(tmp, field); \ + else if (comp > 0) \ + tmp = RB_RIGHT(tmp, field); \ + else \ + return (tmp); \ + } \ + return (NULL); \ +} \ + \ +struct type * \ +name##_RB_NEXT(_U_ struct name *head, struct type *elm) \ +{ \ + if (RB_RIGHT(elm, field)) { \ + elm = RB_RIGHT(elm, field); \ + while (RB_LEFT(elm, field)) \ + elm = RB_LEFT(elm, field); \ + } else { \ + if (RB_PARENT(elm, field) && \ + (elm == RB_LEFT(RB_PARENT(elm, field), field))) \ + elm = RB_PARENT(elm, field); \ + else { \ + while (RB_PARENT(elm, field) && \ + (elm == RB_RIGHT(RB_PARENT(elm, field), field)))\ + elm = RB_PARENT(elm, field); \ + elm = RB_PARENT(elm, field); \ + } \ + } \ + return (elm); \ +} \ + \ +struct type * \ +name##_RB_MINMAX(struct name *head, int val) \ +{ \ + struct type *tmp = RB_ROOT(head); \ + struct type *parent = NULL; \ + while (tmp) { \ + parent = tmp; \ + if (val < 0) \ + tmp = RB_LEFT(tmp, field); \ + else \ + tmp = RB_RIGHT(tmp, field); \ + } \ + return (parent); \ +} + +#define RB_NEGINF -1 +#define RB_INF 1 + +#define RB_INSERT(name, x, y) name##_RB_INSERT(x, y) +#define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y) +#define RB_FIND(name, x, y) name##_RB_FIND(x, y) +#define RB_NEXT(name, x, y) name##_RB_NEXT(x, y) +#define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF) +#define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF) + +#define RB_FOREACH(x, name, head) \ + for ((x) = RB_MIN(name, head); \ + (x) != NULL; \ + (x) = name##_RB_NEXT(head, x)) + +#endif /* _SYS_TREE_H_ */ diff --git a/libopts/COPYING.gplv3 b/libopts/COPYING.gplv3 new file mode 100644 index 0000000..2f9a4e9 --- /dev/null +++ b/libopts/COPYING.gplv3 @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + copyright (c) 2009 by Bruce Korb - all rights reserved + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + copyright (c) by Bruce Korb - all rights reserved + + 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 + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + 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 . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + copyright (c) by Bruce Korb - all rights reserved + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +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 +. + + 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 +. diff --git a/libopts/COPYING.lgplv3 b/libopts/COPYING.lgplv3 new file mode 100644 index 0000000..5b362d5 --- /dev/null +++ b/libopts/COPYING.lgplv3 @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + copyright (c) 2009 by Bruce Korb - all rights reserved + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/libopts/COPYING.mbsd b/libopts/COPYING.mbsd new file mode 100644 index 0000000..8a70427 --- /dev/null +++ b/libopts/COPYING.mbsd @@ -0,0 +1,26 @@ +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + + 3. The name of the author may not be used to endorse or promote + products derived from this software without specific prior + written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/libopts/MakeDefs.inc b/libopts/MakeDefs.inc new file mode 100644 index 0000000..e69de29 diff --git a/libopts/Makefile.am b/libopts/Makefile.am new file mode 100644 index 0000000..a3b3cbf --- /dev/null +++ b/libopts/Makefile.am @@ -0,0 +1,28 @@ +## LIBOPTS Makefile +MAINTAINERCLEANFILES = Makefile.in +if INSTALL_LIBOPTS +lib_LTLIBRARIES = libopts.la +else +noinst_LTLIBRARIES = libopts.la +endif +libopts_la_SOURCES = libopts.c +libopts_la_CPPFLAGS = -I$(top_srcdir) +libopts_la_LDFLAGS = -version-info 32:2:7 +EXTRA_DIST = \ + COPYING.gplv3 COPYING.lgplv3 COPYING.mbsd \ + MakeDefs.inc README ag-char-map.h \ + autoopts/options.h autoopts/usage-txt.h autoopts.c \ + autoopts.h boolean.c compat/compat.h \ + compat/pathfind.c compat/snprintf.c compat/strchr.c \ + compat/strdup.c compat/windows-config.h configfile.c \ + cook.c enumeration.c environment.c \ + file.c genshell.c genshell.h \ + load.c m4/libopts.m4 m4/liboptschk.m4 \ + makeshell.c nested.c numeric.c \ + parse-duration.c parse-duration.h pgusage.c \ + proto.h putshell.c reset.c \ + restore.c save.c sort.c \ + stack.c streqvcmp.c text_mmap.c \ + time.c tokenize.c usage.c \ + value-type.c value-type.h version.c \ + xat-attribute.c xat-attribute.h diff --git a/libopts/Makefile.in b/libopts/Makefile.in new file mode 100644 index 0000000..0cf353d --- /dev/null +++ b/libopts/Makefile.in @@ -0,0 +1,591 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = libopts +DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/src/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__installdirs = "$(DESTDIR)$(libdir)" +LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES) +libopts_la_LIBADD = +am_libopts_la_OBJECTS = libopts_la-libopts.lo +libopts_la_OBJECTS = $(am_libopts_la_OBJECTS) +libopts_la_LINK = $(LIBTOOL) --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) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src +depcomp = $(SHELL) $(top_srcdir)/config/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libopts_la_SOURCES) +DIST_SOURCES = $(libopts_la_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOGEN = @AUTOGEN@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CUT = @CUT@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DMALLOC_LIB = @DMALLOC_LIB@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +GROFF = @GROFF@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LDNETINC = @LDNETINC@ +LDNETLIB = @LDNETLIB@ +LIBOBJS = @LIBOBJS@ +LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@ +LIBOPTS_DIR = @LIBOPTS_DIR@ +LIBOPTS_LDADD = @LIBOPTS_LDADD@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LNAVLIB = @LNAVLIB@ +LNAV_CFLAGS = @LNAV_CFLAGS@ +LN_S = @LN_S@ +LPCAPINC = @LPCAPINC@ +LPCAPLIB = @LPCAPLIB@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@ +PRINTF = @PRINTF@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TCPREPLAY_RELEASE = @TCPREPLAY_RELEASE@ +TCPREPLAY_VERSION = @TCPREPLAY_VERSION@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +debug_flag = @debug_flag@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +nic1 = @nic1@ +nic2 = @nic2@ +oldincludedir = @oldincludedir@ +pcncfg = @pcncfg@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +tcpdump_path = @tcpdump_path@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +MAINTAINERCLEANFILES = Makefile.in +@INSTALL_LIBOPTS_TRUE@lib_LTLIBRARIES = libopts.la +@INSTALL_LIBOPTS_FALSE@noinst_LTLIBRARIES = libopts.la +libopts_la_SOURCES = libopts.c +libopts_la_CPPFLAGS = -I$(top_srcdir) +libopts_la_LDFLAGS = -version-info 32:2:7 +EXTRA_DIST = \ + COPYING.gplv3 COPYING.lgplv3 COPYING.mbsd \ + MakeDefs.inc README ag-char-map.h \ + autoopts/options.h autoopts/usage-txt.h autoopts.c \ + autoopts.h boolean.c compat/compat.h \ + compat/pathfind.c compat/snprintf.c compat/strchr.c \ + compat/strdup.c compat/windows-config.h configfile.c \ + cook.c enumeration.c environment.c \ + file.c genshell.c genshell.h \ + load.c m4/libopts.m4 m4/liboptschk.m4 \ + makeshell.c nested.c numeric.c \ + parse-duration.c parse-duration.h pgusage.c \ + proto.h putshell.c reset.c \ + restore.c save.c sort.c \ + stack.c streqvcmp.c text_mmap.c \ + time.c tokenize.c usage.c \ + value-type.c value-type.h version.c \ + xat-attribute.c xat-attribute.h + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libopts/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu libopts/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *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);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ + } + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libopts.la: $(libopts_la_OBJECTS) $(libopts_la_DEPENDENCIES) + $(libopts_la_LINK) $(am_libopts_la_rpath) $(libopts_la_OBJECTS) $(libopts_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libopts_la-libopts.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +libopts_la-libopts.lo: libopts.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libopts_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libopts_la-libopts.lo -MD -MP -MF $(DEPDIR)/libopts_la-libopts.Tpo -c -o libopts_la-libopts.lo `test -f 'libopts.c' || echo '$(srcdir)/'`libopts.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libopts_la-libopts.Tpo $(DEPDIR)/libopts_la-libopts.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='libopts.c' object='libopts_la-libopts.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libopts_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libopts_la-libopts.lo `test -f 'libopts.c' || echo '$(srcdir)/'`libopts.c + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) +installdirs: + for dir in "$(DESTDIR)$(libdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-am + +clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ + clean-noinstLTLIBRARIES mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-libLTLIBRARIES + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-libLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libLTLIBRARIES clean-libtool clean-noinstLTLIBRARIES \ + ctags 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 uninstall uninstall-am uninstall-libLTLIBRARIES + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libopts/README b/libopts/README new file mode 100644 index 0000000..03c529d --- /dev/null +++ b/libopts/README @@ -0,0 +1,93 @@ + THIS TARBALL IS NOT A FULL DISTRIBUTION. + +The contents of this tarball is designed to be incorporated into +software packages that utilize the AutoOpts option automation +package and are intended to be installed on systems that may not +have libopts installed. It is redistributable under the terms +of either the LGPL (see COPYING.lgpl) or under the terms of +the advertising clause free BSD license (see COPYING.mbsd). + +Usage Instructions for autoconf/automake/libtoolized projects: + +1. Install the unrolled tarball into your package source tree, + copying ``libopts.m4'' to your autoconf macro directory. + + In your bootstrap (pre-configure) script, you can do this: + + rm -rf libopts libopts-* + gunzip -c `autoopts-config libsrc` | tar -xvf - + mv -f libopts-*.*.* libopts + cp -fp libopts/m4/*.m4 m4/. + + I tend to put my configure auxiliary files in "m4". + Whatever directory you choose, if it is not ".", then + be sure to tell autoconf about it with: + + AC_CONFIG_AUX_DIR(m4) + + This is one macro where you *MUST* remember to *NOT* quote + the argument. If you do, automake will get lost. + +2. Add the following to your ``configure.ac'' file: + + LIBOPTS_CHECK + + or: + + LIBOPTS_CHECK([relative/path/to/libopts]) + + This macro will automatically invoke + + AC_CONFIG_FILES( [relative/path/to/libopts/Makefile] ) + + The default ``relative/path/to/libopts'' is simply + ``libopts''. + +3. Add the following to your top level ``Makefile.am'' file: + + if NEED_LIBOPTS + SUBDIRS += $(LIBOPTS_DIR) + endif + + where ``<...>'' can be whatever other files or directories + you may need. The SUBDIRS must be properly ordered. + *PLEASE NOTE* it is crucial that the SUBDIRS be set under the + control of an automake conditional. To work correctly, + automake has to know the range of possible values of SUBDIRS. + It's a magical name with magical properties. ``NEED_LIBOPTS'' + will be correctly set by the ``LIBOPTS_CHECK'' macro, above. + +4. Add ``$(LIBOPTS_CFLAGS)'' to relevant compiler flags and + ``$(LIBOPTS_LDADD)'' to relevant link options whereever + you need them in your build tree. + +5. Make sure your object files explicitly depend upon the + generated options header file. e.g.: + + $(prog_OBJECTS) : prog-opts.h + prog-opts.h : prog-opts.c + prog-opts.c : prog-opts.def + autogen prog-opts.def + +6. *OPTIONAL* -- + If you are creating man pages and texi documentation from + the program options, you will need these rules somewhere, too: + + man_MANS = prog.1 + prog.1 : prog-opts.def + autogen -Tagman1.tpl -bprog prog-opts.def + + prog-invoke.texi : prog-opts.def + autogen -Taginfo.tpl -bprog-invoke prog-opts.def + +If your package does not utilize the auto* tools, then you +will need to hand craft the rules for building the library. + +LICENSING: + +This material is copyright (c) 1993-2009 by Bruce Korb. +You are licensed to use this under the terms of either +the GNU Lesser General Public License (see: COPYING.lgpl), or, +at your option, the modified Berkeley Software Distribution +License (see: COPYING.mbsd). Both of these files should be +included with this tarball. diff --git a/libopts/ag-char-map.h b/libopts/ag-char-map.h new file mode 100644 index 0000000..744c001 --- /dev/null +++ b/libopts/ag-char-map.h @@ -0,0 +1,160 @@ +/* + * Character mapping generated 08/08/09 10:14:55 + * + * This file contains the character classifications + * used by AutoGen and AutoOpts for identifying tokens. + */ +#ifndef AG_CHAR_MAP_H_GUARD +#define AG_CHAR_MAP_H_GUARD 1 + +#ifdef HAVE_CONFIG_H +# if defined(HAVE_INTTYPES_H) +# include +# elif defined(HAVE_STDINT_H) +# include + +# else +# ifndef HAVE_INT8_T + typedef signed char int8_t; +# endif +# ifndef HAVE_UINT8_T + typedef unsigned char uint8_t; +# endif +# ifndef HAVE_INT16_T + typedef signed short int16_t; +# endif +# ifndef HAVE_UINT16_T + typedef unsigned short uint16_t; +# endif +# ifndef HAVE_UINT_T + typedef unsigned int uint_t; +# endif + +# ifndef HAVE_INT32_T +# if SIZEOF_INT == 4 + typedef signed int int32_t; +# elif SIZEOF_LONG == 4 + typedef signed long int32_t; +# endif +# endif + +# ifndef HAVE_UINT32_T +# if SIZEOF_INT == 4 + typedef unsigned int uint32_t; +# elif SIZEOF_LONG == 4 + typedef unsigned long uint32_t; +# endif +# endif +# endif /* HAVE_*INT*_H header */ + +#else /* not HAVE_CONFIG_H -- */ +# ifdef __sun +# include +# else +# include +# endif +#endif /* HAVE_CONFIG_H */ + +#if 0 /* mapping specification source (from autogen.map) */ +// +// %guard autoopts_internal +// %file ag-char-map.h +// %table opt-char-cat +// +// %comment +// This file contains the character classifications +// used by AutoGen and AutoOpts for identifying tokens. +// % +// +// lower-case "a-z" +// upper-case "A-Z" +// alphabetic +lower-case +upper-case +// oct-digit "0-7" +// dec-digit "89" +oct-digit +// hex-digit "a-fA-F" +dec-digit +// alphanumeric +alphabetic +dec-digit +// var-first "_" +alphabetic +// variable-name +var-first +dec-digit +// option-name "^-" +variable-name +// value-name ":" +option-name +// horiz-white "\t " +// compound-name "[.]" +value-name +horiz-white +// whitespace "\v\f\r\n\b" +horiz-white +// unquotable "!-~" -"\"#(),;<=>[\\]`{}?*'" +// end-xml-token "/>" +whitespace +// graphic "!-~" +// plus-n-space "+" +whitespace +// punctuation "!-~" -alphanumeric -"_" +// suffix "-._" +alphanumeric +// suffix-fmt "%/" +suffix +// false-type "nNfF0\x00" +// +#endif /* 0 -- mapping spec. source */ + +typedef uint32_t opt_char_cat_mask_t; +extern opt_char_cat_mask_t const opt_char_cat[128]; + +static inline int is_opt_char_cat_char(char ch, opt_char_cat_mask_t mask) { + unsigned int ix = (unsigned char)ch; + return ((ix < 0x7F) && ((opt_char_cat[ix] & mask) != 0)); } + +#define IS_LOWER_CASE_CHAR(_c) is_opt_char_cat_char((_c), 0x00001) +#define IS_UPPER_CASE_CHAR(_c) is_opt_char_cat_char((_c), 0x00002) +#define IS_ALPHABETIC_CHAR(_c) is_opt_char_cat_char((_c), 0x00003) +#define IS_OCT_DIGIT_CHAR(_c) is_opt_char_cat_char((_c), 0x00004) +#define IS_DEC_DIGIT_CHAR(_c) is_opt_char_cat_char((_c), 0x0000C) +#define IS_HEX_DIGIT_CHAR(_c) is_opt_char_cat_char((_c), 0x0001C) +#define IS_ALPHANUMERIC_CHAR(_c) is_opt_char_cat_char((_c), 0x0000F) +#define IS_VAR_FIRST_CHAR(_c) is_opt_char_cat_char((_c), 0x00023) +#define IS_VARIABLE_NAME_CHAR(_c) is_opt_char_cat_char((_c), 0x0002F) +#define IS_OPTION_NAME_CHAR(_c) is_opt_char_cat_char((_c), 0x0006F) +#define IS_VALUE_NAME_CHAR(_c) is_opt_char_cat_char((_c), 0x000EF) +#define IS_HORIZ_WHITE_CHAR(_c) is_opt_char_cat_char((_c), 0x00100) +#define IS_COMPOUND_NAME_CHAR(_c) is_opt_char_cat_char((_c), 0x003EF) +#define IS_WHITESPACE_CHAR(_c) is_opt_char_cat_char((_c), 0x00500) +#define IS_UNQUOTABLE_CHAR(_c) is_opt_char_cat_char((_c), 0x00800) +#define IS_END_XML_TOKEN_CHAR(_c) is_opt_char_cat_char((_c), 0x01500) +#define IS_GRAPHIC_CHAR(_c) is_opt_char_cat_char((_c), 0x02000) +#define IS_PLUS_N_SPACE_CHAR(_c) is_opt_char_cat_char((_c), 0x04500) +#define IS_PUNCTUATION_CHAR(_c) is_opt_char_cat_char((_c), 0x08000) +#define IS_SUFFIX_CHAR(_c) is_opt_char_cat_char((_c), 0x1000F) +#define IS_SUFFIX_FMT_CHAR(_c) is_opt_char_cat_char((_c), 0x3000F) +#define IS_FALSE_TYPE_CHAR(_c) is_opt_char_cat_char((_c), 0x40000) + +#ifdef AUTOOPTS_INTERNAL +opt_char_cat_mask_t const opt_char_cat[128] = { + /*x00*/ 0x40000, /*x01*/ 0x00000, /*x02*/ 0x00000, /*x03*/ 0x00000, + /*x04*/ 0x00000, /*x05*/ 0x00000, /*x06*/ 0x00000, /*\a */ 0x00000, + /*\b */ 0x00400, /*\t */ 0x00100, /*\n */ 0x00400, /*\v */ 0x00400, + /*\f */ 0x00400, /*\r */ 0x00400, /*x0E*/ 0x00000, /*x0F*/ 0x00000, + /*x10*/ 0x00000, /*x11*/ 0x00000, /*x12*/ 0x00000, /*x13*/ 0x00000, + /*x14*/ 0x00000, /*x15*/ 0x00000, /*x16*/ 0x00000, /*x17*/ 0x00000, + /*x18*/ 0x00000, /*x19*/ 0x00000, /*x1A*/ 0x00000, /*x1B*/ 0x00000, + /*x1C*/ 0x00000, /*x1D*/ 0x00000, /*x1E*/ 0x00000, /*x1F*/ 0x00000, + /* */ 0x00100, /* ! */ 0x0A800, /* " */ 0x0A000, /* # */ 0x0A000, + /* $ */ 0x0A800, /* % */ 0x2A800, /* & */ 0x0A800, /* ' */ 0x0A000, + /* ( */ 0x0A000, /* ) */ 0x0A000, /* * */ 0x0A000, /* + */ 0x0E800, + /* , */ 0x0A000, /* - */ 0x1A840, /* . */ 0x1AA00, /* / */ 0x2B800, + /* 0 */ 0x42804, /* 1 */ 0x02804, /* 2 */ 0x02804, /* 3 */ 0x02804, + /* 4 */ 0x02804, /* 5 */ 0x02804, /* 6 */ 0x02804, /* 7 */ 0x02804, + /* 8 */ 0x02808, /* 9 */ 0x02808, /* : */ 0x0A880, /* ; */ 0x0A000, + /* < */ 0x0A000, /* = */ 0x0A000, /* > */ 0x0B000, /* ? */ 0x0A000, + /* @ */ 0x0A800, /* A */ 0x02812, /* B */ 0x02812, /* C */ 0x02812, + /* D */ 0x02812, /* E */ 0x02812, /* F */ 0x42812, /* G */ 0x02802, + /* H */ 0x02802, /* I */ 0x02802, /* J */ 0x02802, /* K */ 0x02802, + /* L */ 0x02802, /* M */ 0x02802, /* N */ 0x42802, /* O */ 0x02802, + /* P */ 0x02802, /* Q */ 0x02802, /* R */ 0x02802, /* S */ 0x02802, + /* T */ 0x02802, /* U */ 0x02802, /* V */ 0x02802, /* W */ 0x02802, + /* X */ 0x02802, /* Y */ 0x02802, /* Z */ 0x02802, /* [ */ 0x0A200, + /* \ */ 0x0A000, /* ] */ 0x0A200, /* ^ */ 0x0A840, /* _ */ 0x12820, + /* ` */ 0x0A000, /* a */ 0x02811, /* b */ 0x02811, /* c */ 0x02811, + /* d */ 0x02811, /* e */ 0x02811, /* f */ 0x42811, /* g */ 0x02801, + /* h */ 0x02801, /* i */ 0x02801, /* j */ 0x02801, /* k */ 0x02801, + /* l */ 0x02801, /* m */ 0x02801, /* n */ 0x42801, /* o */ 0x02801, + /* p */ 0x02801, /* q */ 0x02801, /* r */ 0x02801, /* s */ 0x02801, + /* t */ 0x02801, /* u */ 0x02801, /* v */ 0x02801, /* w */ 0x02801, + /* x */ 0x02801, /* y */ 0x02801, /* z */ 0x02801, /* { */ 0x0A000, + /* | */ 0x0A800, /* } */ 0x0A000, /* ~ */ 0x0A800, /*x7F*/ 0x00000 +}; +#endif /* AUTOOPTS_INTERNAL */ +#endif /* AG_CHAR_MAP_H_GUARD */ diff --git a/libopts/autoopts.c b/libopts/autoopts.c new file mode 100644 index 0000000..07e75e9 --- /dev/null +++ b/libopts/autoopts.c @@ -0,0 +1,1164 @@ + +/* + * $Id: autoopts.c,v 4.45 2009/08/01 17:43:05 bkorb Exp $ + * Time-stamp: "2009-01-12 02:49:49 bkorb" + * + * This file contains all of the routines that must be linked into + * an executable to use the generated option processing. The optional + * routines are in separately compiled modules so that they will not + * necessarily be linked in. + * + * This file is part of AutoOpts, a companion to AutoGen. + * AutoOpts is free software. + * AutoOpts is copyright (c) 1992-2009 by Bruce Korb - all rights reserved + * + * AutoOpts is available under any one of two licenses. The license + * in use must be one of these two and the choice is under the control + * of the user of the license. + * + * The GNU Lesser General Public License, version 3 or later + * See the files "COPYING.lgplv3" and "COPYING.gplv3" + * + * The Modified Berkeley Software Distribution License + * See the file "COPYING.mbsd" + * + * These files have the following md5sums: + * + * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 + * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 + * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + */ + +static char const zNil[] = ""; + +/* = = = START-STATIC-FORWARD = = = */ +/* static forward declarations maintained by mk-fwd */ +static tSuccess +findOptDesc( tOptions* pOpts, tOptState* pOptState ); + +static tSuccess +next_opt_arg_must(tOptions* pOpts, tOptState* pOptState); + +static tSuccess +next_opt_arg_may(tOptions* pOpts, tOptState* pOptState); + +static tSuccess +next_opt_arg_none(tOptions* pOpts, tOptState* pOptState); + +static tSuccess +nextOption(tOptions* pOpts, tOptState* pOptState); + +static tSuccess +doPresets( tOptions* pOpts ); + +static int +checkConsistency( tOptions* pOpts ); +/* = = = END-STATIC-FORWARD = = = */ + +LOCAL void * +ao_malloc( size_t sz ) +{ + void * res = malloc(sz); + if (res == NULL) { + fprintf( stderr, "malloc of %d bytes failed\n", (int)sz ); + exit( EXIT_FAILURE ); + } + return res; +} +#undef malloc +#define malloc(_s) ao_malloc(_s) + +LOCAL void * +ao_realloc( void *p, size_t sz ) +{ + void * res = realloc(p, sz); + if (res == NULL) { + fprintf( stderr, "realloc of %d bytes at 0x%p failed\n", (int)sz, p ); + exit( EXIT_FAILURE ); + } + return res; +} +#undef realloc +#define realloc(_p,_s) ao_realloc(_p,_s) + + +LOCAL void +ao_free( void *p ) +{ + if (p != NULL) + free(p); +} +#undef free +#define free(_p) ao_free(_p) + + +LOCAL char * +ao_strdup( char const *str ) +{ + char * res = strdup(str); + if (res == NULL) { + fprintf(stderr, "strdup of %d byte string failed\n", (int)strlen(str)); + exit( EXIT_FAILURE ); + } + return res; +} +#undef strdup +#define strdup(_p) ao_strdup(_p) + +#ifndef HAVE_PATHFIND +# include "compat/pathfind.c" +#endif + +#ifndef HAVE_SNPRINTF +# include "compat/snprintf.c" +#endif + +#ifndef HAVE_STRDUP +# include "compat/strdup.c" +#endif + +#ifndef HAVE_STRCHR +# include "compat/strchr.c" +#endif + +/* + * handleOption + * + * This routine handles equivalencing, sets the option state flags and + * invokes the handler procedure, if any. + */ +LOCAL tSuccess +handleOption( tOptions* pOpts, tOptState* pOptState ) +{ + /* + * Save a copy of the option procedure pointer. + * If this is an equivalence class option, we still want this proc. + */ + tOptDesc* pOD = pOptState->pOD; + tOptProc* pOP = pOD->pOptProc; + if (pOD->fOptState & OPTST_ALLOC_ARG) + AGFREE(pOD->optArg.argString); + + pOD->optArg.argString = pOptState->pzOptArg; + + /* + * IF we are presetting options, then we will ignore any un-presettable + * options. They are the ones either marked as such. + */ + if ( ((pOpts->fOptSet & OPTPROC_PRESETTING) != 0) + && ((pOD->fOptState & OPTST_NO_INIT) != 0) + ) + return PROBLEM; + + /* + * IF this is an equivalence class option, + * THEN + * Save the option value that got us to this option + * entry. (It may not be pOD->optChar[0], if this is an + * equivalence entry.) + * set the pointer to the equivalence class base + */ + if (pOD->optEquivIndex != NO_EQUIVALENT) { + tOptDesc* p = pOpts->pOptDesc + pOD->optEquivIndex; + + /* + * IF the current option state has not been defined (set on the + * command line), THEN we will allow continued resetting of + * the value. Once "defined", then it must not change. + */ + if ((pOD->fOptState & OPTST_DEFINED) != 0) { + /* + * The equivalenced-to option has been found on the command + * line before. Make sure new occurrences are the same type. + * + * IF this option has been previously equivalenced and + * it was not the same equivalenced-to option, + * THEN we have a usage problem. + */ + if (p->optActualIndex != pOD->optIndex) { + fprintf( stderr, (char*)zMultiEquiv, p->pz_Name, pOD->pz_Name, + (pOpts->pOptDesc + p->optActualIndex)->pz_Name); + return FAILURE; + } + } else { + /* + * Set the equivalenced-to actual option index to no-equivalent + * so that we set all the entries below. This option may either + * never have been selected before, or else it was selected by + * some sort of "presetting" mechanism. + */ + p->optActualIndex = NO_EQUIVALENT; + } + + if (p->optActualIndex != pOD->optIndex) { + /* + * First time through, copy over the state + * and add in the equivalence flag + */ + p->optActualValue = pOD->optValue; + p->optActualIndex = pOD->optIndex; + pOptState->flags |= OPTST_EQUIVALENCE; + } + + /* + * Copy the most recent option argument. set membership state + * is kept in ``p->optCookie''. Do not overwrite. + */ + p->optArg.argString = pOD->optArg.argString; + pOD = p; + + } else { + pOD->optActualValue = pOD->optValue; + pOD->optActualIndex = pOD->optIndex; + } + + pOD->fOptState &= OPTST_PERSISTENT_MASK; + pOD->fOptState |= (pOptState->flags & ~OPTST_PERSISTENT_MASK); + + /* + * Keep track of count only for DEFINED (command line) options. + * IF we have too many, build up an error message and bail. + */ + if ( (pOD->fOptState & OPTST_DEFINED) + && (++pOD->optOccCt > pOD->optMaxCt) ) { + + if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0) { + char const * pzEqv = + (pOD->optEquivIndex != NO_EQUIVALENT) ? zEquiv : zNil; + + fputs( zErrOnly, stderr ); + + if (pOD->optMaxCt > 1) + fprintf(stderr, zAtMost, pOD->optMaxCt, pOD->pz_Name, pzEqv); + else + fprintf(stderr, zOnlyOne, pOD->pz_Name, pzEqv); + } + + return FAILURE; + } + + /* + * If provided a procedure to call, call it + */ + if (pOP != (tpOptProc)NULL) + (*pOP)( pOpts, pOD ); + + return SUCCESS; +} + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * HUNT FOR OPTIONS IN THE ARGUMENT LIST + * + * The next four procedures are "private" to nextOption(). + * nextOption() uses findOptDesc() to find the next descriptor and it, in + * turn, uses longOptionFind() and shortOptionFind() to actually do the hunt. + * + * longOptionFind + * + * Find the long option descriptor for the current option + */ +LOCAL tSuccess +longOptionFind( tOptions* pOpts, char* pzOptName, tOptState* pOptState ) +{ + ag_bool disable = AG_FALSE; + char* pzEq = strchr( pzOptName, '=' ); + tOptDesc* pOD = pOpts->pOptDesc; + int idx = 0; + int idxLim = pOpts->optCt; + int matchCt = 0; + int matchIdx = 0; + int nameLen; + char opt_name_buf[128]; + + /* + * IF the value is attached to the name, + * copy it off so we can NUL terminate. + */ + if (pzEq != NULL) { + nameLen = (int)(pzEq - pzOptName); + if (nameLen >= sizeof(opt_name_buf)) + return FAILURE; + memcpy(opt_name_buf, pzOptName, nameLen); + opt_name_buf[nameLen] = NUL; + pzOptName = opt_name_buf; + pzEq++; + + } else nameLen = strlen( pzOptName ); + + do { + if (SKIP_OPT(pOD)) + continue; + + if (strneqvcmp( pzOptName, pOD->pz_Name, nameLen ) == 0) { + /* + * IF we have a complete match + * THEN it takes priority over any already located partial + */ + if (pOD->pz_Name[ nameLen ] == NUL) { + matchCt = 1; + matchIdx = idx; + break; + } + } + + /* + * IF there is a disable name + * *AND* no argument value has been supplied + * (disabled options may have no argument) + * *AND* the option name matches the disable name + * THEN ... + */ + else if ( (pOD->pz_DisableName != NULL) + && (strneqvcmp(pzOptName, pOD->pz_DisableName, nameLen) == 0) + ) { + disable = AG_TRUE; + + /* + * IF we have a complete match + * THEN it takes priority over any already located partial + */ + if (pOD->pz_DisableName[ nameLen ] == NUL) { + matchCt = 1; + matchIdx = idx; + break; + } + } + + else + continue; + + /* + * We found a partial match, either regular or disabling. + * Remember the index for later. + */ + matchIdx = idx; + + if (++matchCt > 1) + break; + + } while (pOD++, (++idx < idxLim)); + + /* + * Make sure we either found an exact match or found only one partial + */ + if (matchCt == 1) { + /* + * IF we found a disablement name, + * THEN set the bit in the callers' flag word + */ + if (disable) + pOptState->flags |= OPTST_DISABLED; + + pOptState->pOD = pOpts->pOptDesc + matchIdx; + pOptState->pzOptArg = pzEq; + pOptState->optType = TOPT_LONG; + return SUCCESS; + } + + /* + * IF there is no equal sign + * *AND* we are using named arguments + * *AND* there is a default named option, + * THEN return that option. + */ + if ( (pzEq == NULL) + && NAMED_OPTS(pOpts) + && (pOpts->specOptIdx.default_opt != NO_EQUIVALENT)) { + pOptState->pOD = pOpts->pOptDesc + pOpts->specOptIdx.default_opt; + + pOptState->pzOptArg = pzOptName; + pOptState->optType = TOPT_DEFAULT; + return SUCCESS; + } + + /* + * IF we are to stop on errors (the default, actually) + * THEN call the usage procedure. + */ + if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0) { + fprintf(stderr, (matchCt == 0) ? zIllOptStr : zAmbigOptStr, + pOpts->pzProgPath, pzOptName); + (*pOpts->pUsageProc)( pOpts, EXIT_FAILURE ); + } + + return FAILURE; +} + + +/* + * shortOptionFind + * + * Find the short option descriptor for the current option + */ +LOCAL tSuccess +shortOptionFind( tOptions* pOpts, uint_t optValue, tOptState* pOptState ) +{ + tOptDesc* pRes = pOpts->pOptDesc; + int ct = pOpts->optCt; + + /* + * Search the option list + */ + for (;;) { + /* + * IF the values match, + * THEN we stop here + */ + if ((! SKIP_OPT(pRes)) && (optValue == pRes->optValue)) { + pOptState->pOD = pRes; + pOptState->optType = TOPT_SHORT; + return SUCCESS; + } + + /* + * Advance to next option description + */ + pRes++; + + /* + * IF we have searched everything, ... + */ + if (--ct <= 0) + break; + } + + /* + * IF the character value is a digit + * AND there is a special number option ("-n") + * THEN the result is the "option" itself and the + * option is the specially marked "number" option. + */ + if ( IS_DEC_DIGIT_CHAR(optValue) + && (pOpts->specOptIdx.number_option != NO_EQUIVALENT) ) { + pOptState->pOD = \ + pRes = pOpts->pOptDesc + pOpts->specOptIdx.number_option; + (pOpts->pzCurOpt)--; + pOptState->optType = TOPT_SHORT; + return SUCCESS; + } + + /* + * IF we are to stop on errors (the default, actually) + * THEN call the usage procedure. + */ + if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0) { + fprintf( stderr, zIllOptChr, pOpts->pzProgPath, optValue ); + (*pOpts->pUsageProc)( pOpts, EXIT_FAILURE ); + } + + return FAILURE; +} + + +/* + * findOptDesc + * + * Find the option descriptor for the current option + */ +static tSuccess +findOptDesc( tOptions* pOpts, tOptState* pOptState ) +{ + /* + * IF we are continuing a short option list (e.g. -xyz...) + * THEN continue a single flag option. + * OTHERWISE see if there is room to advance and then do so. + */ + if ((pOpts->pzCurOpt != NULL) && (*pOpts->pzCurOpt != NUL)) + return shortOptionFind( pOpts, (tAoUC)*(pOpts->pzCurOpt), pOptState ); + + if (pOpts->curOptIdx >= pOpts->origArgCt) + return PROBLEM; /* NORMAL COMPLETION */ + + pOpts->pzCurOpt = pOpts->origArgVect[ pOpts->curOptIdx ]; + + /* + * IF all arguments must be named options, ... + */ + if (NAMED_OPTS(pOpts)) { + char * pz = pOpts->pzCurOpt; + int def; + tSuccess res; + tAoUS * def_opt; + + pOpts->curOptIdx++; + + if (*pz != '-') + return longOptionFind(pOpts, pz, pOptState); + + /* + * The name is prefixed with one or more hyphens. Strip them off + * and disable the "default_opt" setting. Use heavy recasting to + * strip off the "const" quality of the "default_opt" field. + */ + while (*(++pz) == '-') ; + def_opt = (void *)&(pOpts->specOptIdx.default_opt); + def = *def_opt; + *def_opt = NO_EQUIVALENT; + res = longOptionFind(pOpts, pz, pOptState); + *def_opt = def; + return res; + } + + /* + * Note the kind of flag/option marker + */ + if (*((pOpts->pzCurOpt)++) != '-') + return PROBLEM; /* NORMAL COMPLETION - this + rest are operands */ + + /* + * Special hack for a hyphen by itself + */ + if (*(pOpts->pzCurOpt) == NUL) + return PROBLEM; /* NORMAL COMPLETION - this + rest are operands */ + + /* + * The current argument is to be processed as an option argument + */ + pOpts->curOptIdx++; + + /* + * We have an option marker. + * Test the next character for long option indication + */ + if (pOpts->pzCurOpt[0] == '-') { + if (*++(pOpts->pzCurOpt) == NUL) + /* + * NORMAL COMPLETION - NOT this arg, but rest are operands + */ + return PROBLEM; + + /* + * We do not allow the hyphen to be used as a flag value. + * Therefore, if long options are not to be accepted, we punt. + */ + if ((pOpts->fOptSet & OPTPROC_LONGOPT) == 0) { + fprintf( stderr, zIllOptStr, pOpts->pzProgPath, + zIllegal, pOpts->pzCurOpt-2 ); + return FAILURE; + } + + return longOptionFind( pOpts, pOpts->pzCurOpt, pOptState ); + } + + /* + * If short options are not allowed, then do long + * option processing. Otherwise the character must be a + * short (i.e. single character) option. + */ + if ((pOpts->fOptSet & OPTPROC_SHORTOPT) != 0) + return shortOptionFind( pOpts, (tAoUC)*(pOpts->pzCurOpt), pOptState ); + + return longOptionFind( pOpts, pOpts->pzCurOpt, pOptState ); +} + + +static tSuccess +next_opt_arg_must(tOptions* pOpts, tOptState* pOptState) +{ + /* + * An option argument is required. Long options can either have + * a separate command line argument, or an argument attached by + * the '=' character. Figure out which. + */ + switch (pOptState->optType) { + case TOPT_SHORT: + /* + * See if an arg string follows the flag character + */ + if (*++(pOpts->pzCurOpt) == NUL) + pOpts->pzCurOpt = pOpts->origArgVect[ pOpts->curOptIdx++ ]; + pOptState->pzOptArg = pOpts->pzCurOpt; + break; + + case TOPT_LONG: + /* + * See if an arg string has already been assigned (glued on + * with an `=' character) + */ + if (pOptState->pzOptArg == NULL) + pOptState->pzOptArg = pOpts->origArgVect[ pOpts->curOptIdx++ ]; + break; + + default: +#ifdef DEBUG + fputs( "AutoOpts lib error: option type not selected\n", + stderr ); + exit( EXIT_FAILURE ); +#endif + + case TOPT_DEFAULT: + /* + * The option was selected by default. The current token is + * the option argument. + */ + break; + } + + /* + * Make sure we did not overflow the argument list. + */ + if (pOpts->curOptIdx > pOpts->origArgCt) { + fprintf( stderr, zMisArg, pOpts->pzProgPath, + pOptState->pOD->pz_Name ); + return FAILURE; + } + + pOpts->pzCurOpt = NULL; /* next time advance to next arg */ + return SUCCESS; +} + + +static tSuccess +next_opt_arg_may(tOptions* pOpts, tOptState* pOptState) +{ + /* + * An option argument is optional. + */ + switch (pOptState->optType) { + case TOPT_SHORT: + if (*++pOpts->pzCurOpt != NUL) + pOptState->pzOptArg = pOpts->pzCurOpt; + else { + char* pzLA = pOpts->origArgVect[ pOpts->curOptIdx ]; + + /* + * BECAUSE it is optional, we must make sure + * we did not find another flag and that there + * is such an argument. + */ + if ((pzLA == NULL) || (*pzLA == '-')) + pOptState->pzOptArg = NULL; + else { + pOpts->curOptIdx++; /* argument found */ + pOptState->pzOptArg = pzLA; + } + } + break; + + case TOPT_LONG: + /* + * Look for an argument if we don't already have one (glued on + * with a `=' character) *AND* we are not in named argument mode + */ + if ( (pOptState->pzOptArg == NULL) + && (! NAMED_OPTS(pOpts))) { + char* pzLA = pOpts->origArgVect[ pOpts->curOptIdx ]; + + /* + * BECAUSE it is optional, we must make sure + * we did not find another flag and that there + * is such an argument. + */ + if ((pzLA == NULL) || (*pzLA == '-')) + pOptState->pzOptArg = NULL; + else { + pOpts->curOptIdx++; /* argument found */ + pOptState->pzOptArg = pzLA; + } + } + break; + + default: + case TOPT_DEFAULT: + fputs(zAO_Woops, stderr ); + exit( EX_SOFTWARE ); + } + + /* + * After an option with an optional argument, we will + * *always* start with the next option because if there + * were any characters following the option name/flag, + * they would be interpreted as the argument. + */ + pOpts->pzCurOpt = NULL; + return SUCCESS; +} + + +static tSuccess +next_opt_arg_none(tOptions* pOpts, tOptState* pOptState) +{ + /* + * No option argument. Make sure next time around we find + * the correct option flag character for short options + */ + if (pOptState->optType == TOPT_SHORT) + (pOpts->pzCurOpt)++; + + /* + * It is a long option. Make sure there was no ``=xxx'' argument + */ + else if (pOptState->pzOptArg != NULL) { + fprintf(stderr, zNoArg, pOpts->pzProgPath, pOptState->pOD->pz_Name); + return FAILURE; + } + + /* + * It is a long option. Advance to next command line argument. + */ + else + pOpts->pzCurOpt = NULL; + return SUCCESS; +} + +/* + * nextOption + * + * Find the option descriptor and option argument (if any) for the + * next command line argument. DO NOT modify the descriptor. Put + * all the state in the state argument so that the option can be skipped + * without consequence (side effect). + */ +static tSuccess +nextOption(tOptions* pOpts, tOptState* pOptState) +{ + { + tSuccess res; + res = findOptDesc( pOpts, pOptState ); + if (! SUCCESSFUL( res )) + return res; + } + + if ( ((pOptState->flags & OPTST_DEFINED) != 0) + && ((pOptState->pOD->fOptState & OPTST_NO_COMMAND) != 0)) { + fprintf(stderr, zNotCmdOpt, pOptState->pOD->pz_Name); + return FAILURE; + } + + pOptState->flags |= (pOptState->pOD->fOptState & OPTST_PERSISTENT_MASK); + + /* + * Figure out what to do about option arguments. An argument may be + * required, not associated with the option, or be optional. We detect the + * latter by examining for an option marker on the next possible argument. + * Disabled mode option selection also disables option arguments. + */ + { + enum { ARG_NONE, ARG_MAY, ARG_MUST } arg_type = ARG_NONE; + tSuccess res; + + if ((pOptState->flags & OPTST_DISABLED) != 0) + arg_type = ARG_NONE; + + else if (OPTST_GET_ARGTYPE(pOptState->flags) == OPARG_TYPE_NONE) + arg_type = ARG_NONE; + + else if (pOptState->flags & OPTST_ARG_OPTIONAL) + arg_type = ARG_MAY; + + else + arg_type = ARG_MUST; + + switch (arg_type) { + case ARG_MUST: res = next_opt_arg_must(pOpts, pOptState); break; + case ARG_MAY: res = next_opt_arg_may( pOpts, pOptState); break; + case ARG_NONE: res = next_opt_arg_none(pOpts, pOptState); break; + } + + return res; + } +} + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * DO PRESETS + * + * The next several routines do the immediate action pass on the command + * line options, then the environment variables, then the config files in + * reverse order. Once done with that, the order is reversed and all + * the config files and environment variables are processed again, this + * time only processing the non-immediate action options. doPresets() + * will then return for optionProcess() to do the final pass on the command + * line arguments. + */ + +/* + * doImmediateOpts - scan the command line for immediate action options + */ +LOCAL tSuccess +doImmediateOpts( tOptions* pOpts ) +{ + pOpts->curOptIdx = 1; /* start by skipping program name */ + pOpts->pzCurOpt = NULL; + + /* + * Examine all the options from the start. We process any options that + * are marked for immediate processing. + */ + for (;;) { + tOptState optState = OPTSTATE_INITIALIZER(PRESET); + + switch (nextOption( pOpts, &optState )) { + case FAILURE: goto optionsDone; + case PROBLEM: return SUCCESS; /* no more args */ + case SUCCESS: break; + } + + /* + * IF this *is* an immediate-attribute option, then do it. + */ + if (! DO_IMMEDIATELY(optState.flags)) + continue; + + if (! SUCCESSFUL( handleOption( pOpts, &optState ))) + break; + } optionsDone:; + + if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0) + (*pOpts->pUsageProc)( pOpts, EXIT_FAILURE ); + return FAILURE; +} + + +LOCAL tSuccess +doRegularOpts( tOptions* pOpts ) +{ + /* + * Now, process all the options from our current position onward. + * (This allows interspersed options and arguments for the few + * non-standard programs that require it.) + */ + for (;;) { + tOptState optState = OPTSTATE_INITIALIZER(DEFINED); + + switch (nextOption( pOpts, &optState )) { + case FAILURE: goto optionsDone; + case PROBLEM: return SUCCESS; /* no more args */ + case SUCCESS: break; + } + + /* + * IF this is not being processed normally (i.e. is immediate action) + * THEN skip it (unless we are supposed to do it a second time). + */ + if (! DO_NORMALLY(optState.flags)) { + if (! DO_SECOND_TIME(optState.flags)) + continue; + optState.pOD->optOccCt--; /* don't count last time */ + } + + if (! SUCCESSFUL( handleOption( pOpts, &optState ))) + break; + } optionsDone:; + if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0) + (*pOpts->pUsageProc)( pOpts, EXIT_FAILURE ); + return FAILURE; +} + + +/* + * doPresets - check for preset values from a config file or the envrionment + */ +static tSuccess +doPresets( tOptions* pOpts ) +{ + tOptDesc * pOD = NULL; + + if (! SUCCESSFUL( doImmediateOpts( pOpts ))) + return FAILURE; + + /* + * IF this option set has a --save-opts option, then it also + * has a --load-opts option. See if a command line option has disabled + * option presetting. + */ + if ( (pOpts->specOptIdx.save_opts != NO_EQUIVALENT) + && (pOpts->specOptIdx.save_opts != 0)) { + pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts + 1; + if (DISABLED_OPT(pOD)) + return SUCCESS; + } + + /* + * Until we return from this procedure, disable non-presettable opts + */ + pOpts->fOptSet |= OPTPROC_PRESETTING; + /* + * IF there are no config files, + * THEN do any environment presets and leave. + */ + if (pOpts->papzHomeList == NULL) { + doEnvPresets( pOpts, ENV_ALL ); + } + else { + doEnvPresets( pOpts, ENV_IMM ); + + /* + * Check to see if environment variables have disabled presetting. + */ + if ((pOD != NULL) && ! DISABLED_OPT(pOD)) + internalFileLoad( pOpts ); + + /* + * ${PROGRAM_LOAD_OPTS} value of "no" cannot disable other environment + * variable options. Only the loading of .rc files. + */ + doEnvPresets( pOpts, ENV_NON_IMM ); + } + pOpts->fOptSet &= ~OPTPROC_PRESETTING; + + return SUCCESS; +} + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * VERIFY OPTION CONSISTENCY + * + * Make sure that the argument list passes our consistency tests. + */ +static int +checkConsistency( tOptions* pOpts ) +{ + int errCt = 0; + tOptDesc* pOD = pOpts->pOptDesc; + int oCt = pOpts->presetOptCt; + + /* + * FOR each of "oCt" options, ... + */ + for (;;) { + const int* pMust = pOD->pOptMust; + const int* pCant = pOD->pOptCant; + + /* + * IF the current option was provided on the command line + * THEN ensure that any "MUST" requirements are not + * "DEFAULT" (unspecified) *AND* ensure that any + * "CANT" options have not been SET or DEFINED. + */ + if (SELECTED_OPT(pOD)) { + if (pMust != NULL) for (;;) { + tOptDesc* p = pOpts->pOptDesc + *(pMust++); + if (UNUSED_OPT(p)) { + const tOptDesc* pN = pOpts->pOptDesc + pMust[-1]; + errCt++; + fprintf( stderr, zReqFmt, pOD->pz_Name, pN->pz_Name ); + } + + if (*pMust == NO_EQUIVALENT) + break; + } + + if (pCant != NULL) for (;;) { + tOptDesc* p = pOpts->pOptDesc + *(pCant++); + if (SELECTED_OPT(p)) { + const tOptDesc* pN = pOpts->pOptDesc + pCant[-1]; + errCt++; + fprintf( stderr, zCantFmt, pOD->pz_Name, pN->pz_Name ); + } + + if (*pCant == NO_EQUIVALENT) + break; + } + } + + /* + * IF this option is not equivalenced to another, + * OR it is equivalenced to itself (is the equiv. root) + * THEN we need to make sure it occurs often enough. + */ + if ( (pOD->optEquivIndex == NO_EQUIVALENT) + || (pOD->optEquivIndex == pOD->optIndex) ) do { + /* + * IF the occurrence counts have been satisfied, + * THEN there is no problem. + */ + if (pOD->optOccCt >= pOD->optMinCt) + break; + + /* + * IF MUST_SET means SET and PRESET are okay, + * so min occurrence count doesn't count + */ + if ( (pOD->fOptState & OPTST_MUST_SET) + && (pOD->fOptState & (OPTST_PRESET | OPTST_SET)) ) + break; + + errCt++; + if (pOD->optMinCt > 1) + fprintf( stderr, zNotEnough, pOD->pz_Name, pOD->optMinCt ); + else fprintf( stderr, zNeedOne, pOD->pz_Name ); + } while (0); + + if (--oCt <= 0) + break; + pOD++; + } + + /* + * IF we are stopping on errors, check to see if any remaining + * arguments are required to be there or prohibited from being there. + */ + if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0) { + + /* + * Check for prohibition + */ + if ((pOpts->fOptSet & OPTPROC_NO_ARGS) != 0) { + if (pOpts->origArgCt > pOpts->curOptIdx) { + fprintf( stderr, zNoArgs, pOpts->pzProgName ); + ++errCt; + } + } + + /* + * ELSE not prohibited, check for being required + */ + else if ((pOpts->fOptSet & OPTPROC_ARGS_REQ) != 0) { + if (pOpts->origArgCt <= pOpts->curOptIdx) { + fprintf( stderr, zArgsMust, pOpts->pzProgName ); + ++errCt; + } + } + } + + return errCt; +} + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * THESE ROUTINES ARE CALLABLE FROM THE GENERATED OPTION PROCESSING CODE + */ +/*=--subblock=arg=arg_type,arg_name,arg_desc =*/ +/*=* + * library: opts + * header: your-opts.h + * + * lib_description: + * + * These are the routines that libopts users may call directly from their + * code. There are several other routines that can be called by code + * generated by the libopts option templates, but they are not to be + * called from any other user code. The @file{options.h} header is + * fairly clear about this, too. +=*/ + +/*=export_func optionProcess + * + * what: this is the main option processing routine + * + * arg: + tOptions* + pOpts + program options descriptor + + * arg: + int + argc + program arg count + + * arg: + char** + argv + program arg vector + + * + * ret_type: int + * ret_desc: the count of the arguments processed + * + * doc: + * + * This is the main entry point for processing options. It is intended + * that this procedure be called once at the beginning of the execution of + * a program. Depending on options selected earlier, it is sometimes + * necessary to stop and restart option processing, or to select completely + * different sets of options. This can be done easily, but you generally + * do not want to do this. + * + * The number of arguments processed always includes the program name. + * If one of the arguments is "--", then it is counted and the processing + * stops. If an error was encountered and errors are to be tolerated, then + * the returned value is the index of the argument causing the error. + * A hyphen by itself ("-") will also cause processing to stop and will + * @emph{not} be counted among the processed arguments. A hyphen by itself + * is treated as an operand. Encountering an operand stops option + * processing. + * + * err: Errors will cause diagnostics to be printed. @code{exit(3)} may + * or may not be called. It depends upon whether or not the options + * were generated with the "allow-errors" attribute, or if the + * ERRSKIP_OPTERR or ERRSTOP_OPTERR macros were invoked. +=*/ +int +optionProcess( + tOptions* pOpts, + int argCt, + char** argVect ) +{ + if (! SUCCESSFUL( validateOptionsStruct( pOpts, argVect[0] ))) + exit( EX_SOFTWARE ); + + /* + * Establish the real program name, the program full path, + * and do all the presetting the first time thru only. + */ + if ((pOpts->fOptSet & OPTPROC_INITDONE) == 0) { + pOpts->origArgCt = argCt; + pOpts->origArgVect = argVect; + pOpts->fOptSet |= OPTPROC_INITDONE; + + if (! SUCCESSFUL( doPresets( pOpts ))) + return 0; + + /* + * IF option name conversion was suppressed but it is not suppressed + * for the command line, then it's time to translate option names. + * Usage text will not get retranslated. + */ + if ( ((pOpts->fOptSet & OPTPROC_TRANSLATE) != 0) + && (pOpts->pTransProc != NULL) + && ((pOpts->fOptSet & OPTPROC_NO_XLAT_MASK) + == OPTPROC_NXLAT_OPT_CFG) ) { + + pOpts->fOptSet &= ~OPTPROC_NXLAT_OPT_CFG; + (*pOpts->pTransProc)(); + } + + if ((pOpts->fOptSet & OPTPROC_REORDER) != 0) + optionSort( pOpts ); + + pOpts->curOptIdx = 1; + pOpts->pzCurOpt = NULL; + } + + /* + * IF we are (re)starting, + * THEN reset option location + */ + else if (pOpts->curOptIdx <= 0) { + pOpts->curOptIdx = 1; + pOpts->pzCurOpt = NULL; + } + + if (! SUCCESSFUL( doRegularOpts( pOpts ))) + return pOpts->origArgCt; + + /* + * IF there were no errors + * AND we have RC/INI files + * AND there is a request to save the files + * THEN do that now before testing for conflicts. + * (conflicts are ignored in preset options) + */ + if ( (pOpts->specOptIdx.save_opts != NO_EQUIVALENT) + && (pOpts->specOptIdx.save_opts != 0)) { + tOptDesc* pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts; + + if (SELECTED_OPT( pOD )) { + optionSaveFile( pOpts ); + exit( EXIT_SUCCESS ); + } + } + + /* + * IF we are checking for errors, + * THEN look for too few occurrences of required options + */ + if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0) { + if (checkConsistency( pOpts ) != 0) + (*pOpts->pUsageProc)( pOpts, EXIT_FAILURE ); + } + + return pOpts->curOptIdx; +} + +/* + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of autoopts/autoopts.c */ diff --git a/libopts/autoopts.h b/libopts/autoopts.h new file mode 100644 index 0000000..d5e3033 --- /dev/null +++ b/libopts/autoopts.h @@ -0,0 +1,364 @@ + +/* + * Time-stamp: "2008-11-01 20:08:06 bkorb" + * + * autoopts.h $Id: autoopts.h,v 4.42 2009/08/01 17:43:05 bkorb Exp $ + * + * This file defines all the global structures and special values + * used in the automated option processing library. + * + * This file is part of AutoOpts, a companion to AutoGen. + * AutoOpts is free software. + * AutoOpts is copyright (c) 1992-2009 by Bruce Korb - all rights reserved + * + * AutoOpts is available under any one of two licenses. The license + * in use must be one of these two and the choice is under the control + * of the user of the license. + * + * The GNU Lesser General Public License, version 3 or later + * See the files "COPYING.lgplv3" and "COPYING.gplv3" + * + * The Modified Berkeley Software Distribution License + * See the file "COPYING.mbsd" + * + * These files have the following md5sums: + * + * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 + * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 + * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + */ + +#ifndef AUTOGEN_AUTOOPTS_H +#define AUTOGEN_AUTOOPTS_H + +#include "compat/compat.h" +#include "ag-char-map.h" + +#define AO_NAME_LIMIT 127 +#define AO_NAME_SIZE ((size_t)(AO_NAME_LIMIT + 1)) + +#ifndef AG_PATH_MAX +# ifdef PATH_MAX +# define AG_PATH_MAX ((size_t)PATH_MAX) +# else +# define AG_PATH_MAX ((size_t)4096) +# endif +#else +# if defined(PATH_MAX) && (PATH_MAX > MAXPATHLEN) +# undef AG_PATH_MAX +# define AG_PATH_MAX ((size_t)PATH_MAX) +# endif +#endif + +#undef EXPORT +#define EXPORT + +#if defined(_WIN32) && !defined(__CYGWIN__) +# define DIRCH '\\' +#else +# define DIRCH '/' +#endif + +#ifndef EX_NOINPUT +# define EX_NOINPUT 66 +#endif +#ifndef EX_SOFTWARE +# define EX_SOFTWARE 70 +#endif +#ifndef EX_CONFIG +# define EX_CONFIG 78 +#endif + +/* + * Convert the number to a list usable in a printf call + */ +#define NUM_TO_VER(n) ((n) >> 12), ((n) >> 7) & 0x001F, (n) & 0x007F + +#define NAMED_OPTS(po) \ + (((po)->fOptSet & (OPTPROC_SHORTOPT | OPTPROC_LONGOPT)) == 0) + +#define SKIP_OPT(p) (((p)->fOptState & (OPTST_DOCUMENT|OPTST_OMITTED)) != 0) + +typedef int tDirection; +#define DIRECTION_PRESET -1 +#define DIRECTION_PROCESS 1 +#define DIRECTION_CALLED 0 + +#define PROCESSING(d) ((d)>0) +#define PRESETTING(d) ((d)<0) + +/* + * Procedure success codes + * + * USAGE: define procedures to return "tSuccess". Test their results + * with the SUCCEEDED, FAILED and HADGLITCH macros. + * + * Microsoft sticks its nose into user space here, so for Windows' sake, + * make sure all of these are undefined. + */ +#undef SUCCESS +#undef FAILURE +#undef PROBLEM +#undef SUCCEEDED +#undef SUCCESSFUL +#undef FAILED +#undef HADGLITCH + +#define SUCCESS ((tSuccess) 0) +#define FAILURE ((tSuccess)-1) +#define PROBLEM ((tSuccess) 1) + +typedef int tSuccess; + +#define SUCCEEDED( p ) ((p) == SUCCESS) +#define SUCCESSFUL( p ) SUCCEEDED( p ) +#define FAILED( p ) ((p) < SUCCESS) +#define HADGLITCH( p ) ((p) > SUCCESS) + +/* + * When loading a line (or block) of text as an option, the value can + * be processed in any of several modes: + * + * @table @samp + * @item keep + * Every part of the value between the delimiters is saved. + * + * @item uncooked + * Even if the value begins with quote characters, do not do quote processing. + * + * @item cooked + * If the value looks like a quoted string, then process it. + * Double quoted strings are processed the way strings are in "C" programs, + * except they are treated as regular characters if the following character + * is not a well-established escape sequence. + * Single quoted strings (quoted with apostrophies) are handled the way + * strings are handled in shell scripts, *except* that backslash escapes + * are honored before backslash escapes and apostrophies. + * @end table + */ +typedef enum { + OPTION_LOAD_COOKED, + OPTION_LOAD_UNCOOKED, + OPTION_LOAD_KEEP +} tOptionLoadMode; + +extern tOptionLoadMode option_load_mode; + +/* + * The pager state is used by optionPagedUsage() procedure. + * When it runs, it sets itself up to be called again on exit. + * If, however, a routine needs a child process to do some work + * before it is done, then 'pagerState' must be set to + * 'PAGER_STATE_CHILD' so that optionPagedUsage() will not try + * to run the pager program before its time. + */ +typedef enum { + PAGER_STATE_INITIAL, + PAGER_STATE_READY, + PAGER_STATE_CHILD +} tePagerState; + +extern tePagerState pagerState; + +typedef enum { + ENV_ALL, + ENV_IMM, + ENV_NON_IMM +} teEnvPresetType; + +typedef enum { + TOPT_UNDEFINED = 0, + TOPT_SHORT, + TOPT_LONG, + TOPT_DEFAULT +} teOptType; + +typedef struct { + tOptDesc* pOD; + tCC* pzOptArg; + tAoUL flags; + teOptType optType; +} tOptState; +#define OPTSTATE_INITIALIZER(st) \ + { NULL, NULL, OPTST_ ## st, TOPT_UNDEFINED } + +#define TEXTTO_TABLE \ + _TT_( LONGUSAGE ) \ + _TT_( USAGE ) \ + _TT_( VERSION ) +#define _TT_(n) \ + TT_ ## n , + +typedef enum { TEXTTO_TABLE COUNT_TT } teTextTo; + +#undef _TT_ + +typedef struct { + tCC* pzStr; + tCC* pzReq; + tCC* pzNum; + tCC* pzFile; + tCC* pzKey; + tCC* pzKeyL; + tCC* pzBool; + tCC* pzNest; + tCC* pzOpt; + tCC* pzNo; + tCC* pzBrk; + tCC* pzNoF; + tCC* pzSpc; + tCC* pzOptFmt; + tCC* pzTime; +} arg_types_t; + +#define AGALOC( c, w ) ao_malloc((size_t)c) +#define AGREALOC( p, c, w ) ao_realloc((void*)p, (size_t)c) +#define AGFREE(_p) do{void*X=(void*)_p;ao_free(X);}while(0) +#define AGDUPSTR( p, s, w ) (p = ao_strdup(s)) + +static void * +ao_malloc( size_t sz ); + +static void * +ao_realloc( void *p, size_t sz ); + +static void +ao_free( void *p ); + +static char * +ao_strdup( char const *str ); + +#define TAGMEM( m, t ) + +/* + * DO option handling? + * + * Options are examined at two times: at immediate handling time and at + * normal handling time. If an option is disabled, the timing may be + * different from the handling of the undisabled option. The OPTST_DIABLED + * bit indicates the state of the currently discovered option. + * So, here's how it works: + * + * A) handling at "immediate" time, either 1 or 2: + * + * 1. OPTST_DISABLED is not set: + * IMM must be set + * DISABLE_IMM don't care + * TWICE don't care + * DISABLE_TWICE don't care + * 0 -and- 1 x x x + * + * 2. OPTST_DISABLED is set: + * IMM don't care + * DISABLE_IMM must be set + * TWICE don't care + * DISABLE_TWICE don't care + * 1 -and- x 1 x x + */ +#define DO_IMMEDIATELY(_flg) \ + ( (((_flg) & (OPTST_DISABLED|OPTST_IMM)) == OPTST_IMM) \ + || ( ((_flg) & (OPTST_DISABLED|OPTST_DISABLE_IMM)) \ + == (OPTST_DISABLED|OPTST_DISABLE_IMM) )) + +/* B) handling at "regular" time because it was not immediate + * + * 1. OPTST_DISABLED is not set: + * IMM must *NOT* be set + * DISABLE_IMM don't care + * TWICE don't care + * DISABLE_TWICE don't care + * 0 -and- 0 x x x + * + * 2. OPTST_DISABLED is set: + * IMM don't care + * DISABLE_IMM don't care + * TWICE must be set + * DISABLE_TWICE don't care + * 1 -and- x x 1 x + */ +#define DO_NORMALLY(_flg) ( \ + (((_flg) & (OPTST_DISABLED|OPTST_IMM)) == 0) \ + || (((_flg) & (OPTST_DISABLED|OPTST_DISABLE_IMM)) == \ + OPTST_DISABLED) ) + +/* C) handling at "regular" time because it is to be handled twice. + * The immediate bit was already tested and found to be set: + * + * 3. OPTST_DISABLED is not set: + * IMM is set (but don't care) + * DISABLE_IMM don't care + * TWICE must be set + * DISABLE_TWICE don't care + * 0 -and- ? x 1 x + * + * 4. OPTST_DISABLED is set: + * IMM don't care + * DISABLE_IMM is set (but don't care) + * TWICE don't care + * DISABLE_TWICE must be set + * 1 -and- x ? x 1 + */ +#define DO_SECOND_TIME(_flg) ( \ + (((_flg) & (OPTST_DISABLED|OPTST_TWICE)) == \ + OPTST_TWICE) \ + || (((_flg) & (OPTST_DISABLED|OPTST_DISABLE_TWICE)) == \ + (OPTST_DISABLED|OPTST_DISABLE_TWICE) )) + +/* + * text_mmap structure. Only active on platforms with mmap(2). + */ +#ifdef HAVE_SYS_MMAN_H +# include +#else +# ifndef PROT_READ +# define PROT_READ 0x01 +# endif +# ifndef PROT_WRITE +# define PROT_WRITE 0x02 +# endif +# ifndef MAP_SHARED +# define MAP_SHARED 0x01 +# endif +# ifndef MAP_PRIVATE +# define MAP_PRIVATE 0x02 +# endif +#endif + +#ifndef MAP_FAILED +# define MAP_FAILED ((void*)-1) +#endif + +#ifndef _SC_PAGESIZE +# ifdef _SC_PAGE_SIZE +# define _SC_PAGESIZE _SC_PAGE_SIZE +# endif +#endif + +#ifndef HAVE_STRCHR +extern char* strchr( char const *s, int c); +extern char* strrchr( char const *s, int c); +#endif + +/* + * Define and initialize all the user visible strings. + * We do not do translations. If translations are to be done, then + * the client will provide a callback for that purpose. + */ +#undef DO_TRANSLATIONS +#include "autoopts/usage-txt.h" + +/* + * File pointer for usage output + */ +extern FILE* option_usage_fp; + +extern tOptProc optionPrintVersion, optionPagedUsage, optionLoadOpt; + +#endif /* AUTOGEN_AUTOOPTS_H */ +/* + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of autoopts/autoopts.h */ diff --git a/libopts/autoopts/options.h b/libopts/autoopts/options.h new file mode 100644 index 0000000..4fc8079 --- /dev/null +++ b/libopts/autoopts/options.h @@ -0,0 +1,1049 @@ +/* -*- buffer-read-only: t -*- vi: set ro: + * + * DO NOT EDIT THIS FILE (options.h) + * + * It has been AutoGen-ed August 8, 2009 at 10:14:44 AM by AutoGen 5.9.9 + * From the definitions funcs.def + * and the template file options_h + * + * This file defines all the global structures and special values + * used in the automated option processing library. + * + * Automated Options copyright (c) 1992-Y by Bruce Korb + * + * AutoOpts is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AutoOpts is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +#ifndef AUTOOPTS_OPTIONS_H_GUARD +#define AUTOOPTS_OPTIONS_H_GUARD 1 +#include +#include + +#if defined(HAVE_STDINT_H) +# include +#elif defined(HAVE_INTTYPES_H) +# include +#endif /* HAVE_STDINT/INTTYPES_H */ + +#if defined(HAVE_LIMITS_H) +# include +#elif defined(HAVE_SYS_LIMITS_H) +# include +#endif /* HAVE_LIMITS/SYS_LIMITS_H */ + +#if defined(HAVE_SYSEXITS_H) +# include +#endif /* HAVE_SYSEXITS_H */ + +#ifndef EX_USAGE +# define EX_USAGE 64 +#endif + +/* + * PUBLIC DEFINES + * + * The following defines may be used in applications that need to test the + * state of an option. To test against these masks and values, a pointer + * to an option descriptor must be obtained. There are two ways: + * + * 1. inside an option processing procedure, it is the second argument, + * conventionally "tOptDesc* pOD". + * + * 2. Outside of an option procedure (or to reference a different option + * descriptor), use either "&DESC( opt_name )" or "&pfx_DESC( opt_name )". + * + * See the relevant generated header file to determine which and what + * values for "opt_name" are available. + */ + +#define OPTIONS_STRUCT_VERSION 131074 +#define OPTIONS_VERSION_STRING "32:2:7" +#define OPTIONS_MINIMUM_VERSION 102400 +#define OPTIONS_MIN_VER_STRING "25:0:0" + +typedef enum { + OPARG_TYPE_NONE = 0, + OPARG_TYPE_STRING = 1, /* default type/ vanilla string */ + OPARG_TYPE_ENUMERATION = 2, /* opt arg is an enum (keyword list) */ + OPARG_TYPE_BOOLEAN = 3, /* opt arg is boolean-valued */ + OPARG_TYPE_MEMBERSHIP = 4, /* opt arg sets set membership bits */ + OPARG_TYPE_NUMERIC = 5, /* opt arg has numeric value */ + OPARG_TYPE_HIERARCHY = 6, /* option arg is hierarchical value */ + OPARG_TYPE_FILE = 7, /* option arg names a file */ + OPARG_TYPE_TIME = 8 /* opt arg is a time duration */ +} teOptArgType; + +typedef struct optionValue { + teOptArgType valType; + char* pzName; + union { + char strVal[1]; /* OPARG_TYPE_STRING */ + unsigned int enumVal; /* OPARG_TYPE_ENUMERATION */ + unsigned int boolVal; /* OPARG_TYPE_BOOLEAN */ + unsigned long setVal; /* OPARG_TYPE_MEMBERSHIP */ + long longVal; /* OPARG_TYPE_NUMERIC */ + void* nestVal; /* OPARG_TYPE_HIERARCHY */ + } v; +} tOptionValue; + +typedef enum { + FTYPE_MODE_MAY_EXIST = 0x00, + FTYPE_MODE_MUST_EXIST = 0x01, + FTYPE_MODE_MUST_NOT_EXIST = 0x02, + FTYPE_MODE_EXIST_MASK = 0x03, + FTYPE_MODE_NO_OPEN = 0x00, + FTYPE_MODE_OPEN_FD = 0x10, + FTYPE_MODE_FOPEN_FP = 0x20, + FTYPE_MODE_OPEN_MASK = 0x30 +} teOptFileType; + +typedef union { + int file_flags; + char const * file_mode; +} tuFileMode; + +/* + * Bits in the fOptState option descriptor field. + */ +typedef enum { + OPTST_SET_ID = 0, /* Set via the "SET_OPT()" macro */ + OPTST_PRESET_ID = 1, /* Set via an RC/INI file */ + OPTST_DEFINED_ID = 2, /* Set via a command line option */ + OPTST_RESET_ID = 3, /* Reset via command line option */ + OPTST_EQUIVALENCE_ID = 4, /* selected by equiv'ed option */ + OPTST_DISABLED_ID = 5, /* option is in disabled state */ + OPTST_ALLOC_ARG_ID = 6, /* pzOptArg was allocated */ + OPTST_NO_INIT_ID = 8, /* option cannot be preset */ + OPTST_NUMBER_OPT_ID = 9, /* opt value (flag) is any digit */ + OPTST_STACKED_ID = 10, /* opt uses optionStackArg proc */ + OPTST_INITENABLED_ID = 11, /* option defaults to enabled */ + OPTST_ARG_TYPE_1_ID = 12, /* bit 1 of arg type enum */ + OPTST_ARG_TYPE_2_ID = 13, /* bit 2 of arg type enum */ + OPTST_ARG_TYPE_3_ID = 14, /* bit 3 of arg type enum */ + OPTST_ARG_TYPE_4_ID = 15, /* bit 4 of arg type enum */ + OPTST_ARG_OPTIONAL_ID = 16, /* the option arg not required */ + OPTST_IMM_ID = 17, /* process opt on first pass */ + OPTST_DISABLE_IMM_ID = 18, /* process disablement immed. */ + OPTST_OMITTED_ID = 19, /* compiled out of program */ + OPTST_MUST_SET_ID = 20, /* must be set or pre-set */ + OPTST_DOCUMENT_ID = 21, /* opt is for doc only */ + OPTST_TWICE_ID = 22, /* process opt twice - imm + reg */ + OPTST_DISABLE_TWICE_ID = 23, /* process disabled option twice */ + OPTST_SCALED_NUM_ID = 24, /* scaled integer value */ + OPTST_NO_COMMAND_ID = 25, /* disable from cmd line */ + OPTST_DEPRECATED_ID = 26 /* support is being removed */ +} opt_state_enum_t; + +#define OPTST_INIT 0U +#define OPTST_SET (1U << OPTST_SET_ID) +#define OPTST_PRESET (1U << OPTST_PRESET_ID) +#define OPTST_DEFINED (1U << OPTST_DEFINED_ID) +#define OPTST_RESET (1U << OPTST_RESET_ID) +#define OPTST_EQUIVALENCE (1U << OPTST_EQUIVALENCE_ID) +#define OPTST_DISABLED (1U << OPTST_DISABLED_ID) +#define OPTST_ALLOC_ARG (1U << OPTST_ALLOC_ARG_ID) +#define OPTST_NO_INIT (1U << OPTST_NO_INIT_ID) +#define OPTST_NUMBER_OPT (1U << OPTST_NUMBER_OPT_ID) +#define OPTST_STACKED (1U << OPTST_STACKED_ID) +#define OPTST_INITENABLED (1U << OPTST_INITENABLED_ID) +#define OPTST_ARG_TYPE_1 (1U << OPTST_ARG_TYPE_1_ID) +#define OPTST_ARG_TYPE_2 (1U << OPTST_ARG_TYPE_2_ID) +#define OPTST_ARG_TYPE_3 (1U << OPTST_ARG_TYPE_3_ID) +#define OPTST_ARG_TYPE_4 (1U << OPTST_ARG_TYPE_4_ID) +#define OPTST_ARG_OPTIONAL (1U << OPTST_ARG_OPTIONAL_ID) +#define OPTST_IMM (1U << OPTST_IMM_ID) +#define OPTST_DISABLE_IMM (1U << OPTST_DISABLE_IMM_ID) +#define OPTST_OMITTED (1U << OPTST_OMITTED_ID) +#define OPTST_MUST_SET (1U << OPTST_MUST_SET_ID) +#define OPTST_DOCUMENT (1U << OPTST_DOCUMENT_ID) +#define OPTST_TWICE (1U << OPTST_TWICE_ID) +#define OPTST_DISABLE_TWICE (1U << OPTST_DISABLE_TWICE_ID) +#define OPTST_SCALED_NUM (1U << OPTST_SCALED_NUM_ID) +#define OPTST_NO_COMMAND (1U << OPTST_NO_COMMAND_ID) +#define OPTST_DEPRECATED (1U << OPTST_DEPRECATED_ID) +#define OPT_STATE_MASK 0x07FFFF7FU + +#define OPTST_SET_MASK ( \ + OPTST_DEFINED | OPTST_PRESET | OPTST_RESET | \ + OPTST_SET \ + /* 0x0000000FU */ ) + +#define OPTST_MUTABLE_MASK ( \ + OPTST_ALLOC_ARG | OPTST_DEFINED | \ + OPTST_DISABLED | OPTST_EQUIVALENCE | \ + OPTST_PRESET | OPTST_RESET | \ + OPTST_SET \ + /* 0x0000007FU */ ) + +#define OPTST_SELECTED_MASK ( \ + OPTST_DEFINED | OPTST_SET \ + /* 0x00000005U */ ) + +#define OPTST_ARG_TYPE_MASK ( \ + OPTST_ARG_TYPE_1 | OPTST_ARG_TYPE_2 | OPTST_ARG_TYPE_3 | \ + OPTST_ARG_TYPE_4 \ + /* 0x0000F000U */ ) + +#define OPTST_DO_NOT_SAVE_MASK ( \ + OPTST_DOCUMENT | OPTST_NO_INIT | OPTST_OMITTED \ + /* 0x00280100U */ ) + +#define OPTST_NO_USAGE_MASK ( \ + OPTST_DEPRECATED | OPTST_NO_COMMAND | OPTST_OMITTED \ + /* 0x06080000U */ ) + +#ifdef NO_OPTIONAL_OPT_ARGS +# undef OPTST_ARG_OPTIONAL +# define OPTST_ARG_OPTIONAL 0 +#endif + +#define OPTST_PERSISTENT_MASK (~OPTST_MUTABLE_MASK) + +#define SELECTED_OPT(_od) ((_od)->fOptState & OPTST_SELECTED_MASK) +#define UNUSED_OPT( _od) (((_od)->fOptState & OPTST_SET_MASK) == 0) +#define DISABLED_OPT(_od) ((_od)->fOptState & OPTST_DISABLED) +#define OPTION_STATE(_od) ((_od)->fOptState) +#define OPTST_SET_ARGTYPE(_n) ((_n) << OPTST_ARG_TYPE_1_ID) +#define OPTST_GET_ARGTYPE(_f) (((_f)&OPTST_ARG_TYPE_MASK)>>OPTST_ARG_TYPE_1_ID) + +/* + * PRIVATE INTERFACES + * + * The following values are used in the generated code to communicate + * with the option library procedures. They are not for public use + * and may be subject to change. + */ + +/* + * Define the processing state flags + */ +typedef enum { + OPTPROC_LONGOPT_ID = 0, /* Process long style options */ + OPTPROC_SHORTOPT_ID = 1, /* Process short style "flags" */ + OPTPROC_ERRSTOP_ID = 2, /* Stop on argument errors */ + OPTPROC_DISABLEDOPT_ID = 3, /* Current option is disabled */ + OPTPROC_NO_REQ_OPT_ID = 4, /* no options are required */ + OPTPROC_NUM_OPT_ID = 5, /* there is a number option */ + OPTPROC_INITDONE_ID = 6, /* have inits been done? */ + OPTPROC_NEGATIONS_ID = 7, /* any negation options? */ + OPTPROC_ENVIRON_ID = 8, /* check environment? */ + OPTPROC_NO_ARGS_ID = 9, /* Disallow remaining arguments */ + OPTPROC_ARGS_REQ_ID = 10, /* Require args after options */ + OPTPROC_REORDER_ID = 11, /* reorder operands after opts */ + OPTPROC_GNUUSAGE_ID = 12, /* emit usage in GNU style */ + OPTPROC_TRANSLATE_ID = 13, /* Translate strings in tOptions */ + OPTPROC_NXLAT_OPT_CFG_ID = 16, /* suppress for config only */ + OPTPROC_NXLAT_OPT_ID = 17, /* suppress xlation always */ + OPTPROC_PRESETTING_ID = 19 /* opt processing in preset state */ +} optproc_state_enum_t; + +#define OPTPROC_NONE 0U +#define OPTPROC_LONGOPT (1U << OPTPROC_LONGOPT_ID) +#define OPTPROC_SHORTOPT (1U << OPTPROC_SHORTOPT_ID) +#define OPTPROC_ERRSTOP (1U << OPTPROC_ERRSTOP_ID) +#define OPTPROC_DISABLEDOPT (1U << OPTPROC_DISABLEDOPT_ID) +#define OPTPROC_NO_REQ_OPT (1U << OPTPROC_NO_REQ_OPT_ID) +#define OPTPROC_NUM_OPT (1U << OPTPROC_NUM_OPT_ID) +#define OPTPROC_INITDONE (1U << OPTPROC_INITDONE_ID) +#define OPTPROC_NEGATIONS (1U << OPTPROC_NEGATIONS_ID) +#define OPTPROC_ENVIRON (1U << OPTPROC_ENVIRON_ID) +#define OPTPROC_NO_ARGS (1U << OPTPROC_NO_ARGS_ID) +#define OPTPROC_ARGS_REQ (1U << OPTPROC_ARGS_REQ_ID) +#define OPTPROC_REORDER (1U << OPTPROC_REORDER_ID) +#define OPTPROC_GNUUSAGE (1U << OPTPROC_GNUUSAGE_ID) +#define OPTPROC_TRANSLATE (1U << OPTPROC_TRANSLATE_ID) +#define OPTPROC_NXLAT_OPT_CFG (1U << OPTPROC_NXLAT_OPT_CFG_ID) +#define OPTPROC_NXLAT_OPT (1U << OPTPROC_NXLAT_OPT_ID) +#define OPTPROC_PRESETTING (1U << OPTPROC_PRESETTING_ID) +#define OPTPROC_STATE_MASK 0x000B3FFFU + +#define OPTPROC_NO_XLAT_MASK ( \ + OPTPROC_NXLAT_OPT | OPTPROC_NXLAT_OPT_CFG \ + /* 0x00030000U */ ) + +#define STMTS(s) do { s; } while (0) + +/* + * The following must be #defined instead of typedef-ed + * because "static const" cannot both be applied to a type, + * tho each individually can...so they all are + */ +#define tSCC static char const +#define tCC char const +#define tAoSC static char +#define tAoUC unsigned char +#define tAoUI unsigned int +#define tAoUL unsigned long +#define tAoUS unsigned short + +/* + * It is so disgusting that there must be so many ways + * of specifying TRUE and FALSE. + */ +typedef enum { AG_FALSE = 0, AG_TRUE } ag_bool; + +/* + * Define a structure that describes each option and + * a pointer to the procedure that handles it. + * The argument is the count of this flag previously seen. + */ +typedef struct options tOptions; +typedef struct optDesc tOptDesc; +typedef struct optNames tOptNames; +#define OPTPROC_EMIT_USAGE ((tOptions *)0x01UL) +#define OPTPROC_EMIT_SHELL ((tOptions *)0x02UL) +#define OPTPROC_RETURN_VALNAME ((tOptions *)0x03UL) +#define OPTPROC_EMIT_LIMIT ((tOptions *)0x0FUL) + +/* + * The option procedures do the special processing for each + * option flag that needs it. + */ +typedef void (tOptProc)(tOptions* pOpts, tOptDesc* pOptDesc); +typedef tOptProc* tpOptProc; + +/* + * The usage procedure will never return. It calls "exit(2)" + * with the "exitCode" argument passed to it. + */ +typedef void (tUsageProc)(tOptions* pOpts, int exitCode); +typedef tUsageProc* tpUsageProc; + +/* + * Special definitions. "NOLIMIT" is the 'max' value to use when + * a flag may appear multiple times without limit. "NO_EQUIVALENT" + * is an illegal value for 'optIndex' (option description index). + */ +#define NOLIMIT USHRT_MAX +#define OPTION_LIMIT SHRT_MAX +#define NO_EQUIVALENT (OPTION_LIMIT+1) + +/* + * Special values for optValue. It must not be generatable from the + * computation "optIndex +96". Since "optIndex" is limited to 100, ... + */ +#define NUMBER_OPTION '#' + +typedef struct argList tArgList; +#define MIN_ARG_ALLOC_CT 6 +#define INCR_ARG_ALLOC_CT 8 +struct argList { + int useCt; + int allocCt; + tCC* apzArgs[ MIN_ARG_ALLOC_CT ]; +}; + +typedef union { + char const * argString; + uintptr_t argEnum; + uintptr_t argIntptr; + long argInt; + unsigned long argUint; + unsigned int argBool; + FILE* argFp; + int argFd; +} optArgBucket_t; + +/* + * Descriptor structure for each option. + * Only the fields marked "PUBLIC" are for public use. + */ +struct optDesc { + tAoUS const optIndex; /* PUBLIC */ + tAoUS const optValue; /* PUBLIC */ + tAoUS optActualIndex; /* PUBLIC */ + tAoUS optActualValue; /* PUBLIC */ + + tAoUS const optEquivIndex; /* PUBLIC */ + tAoUS const optMinCt; + tAoUS const optMaxCt; + tAoUS optOccCt; /* PUBLIC */ + + tAoUI fOptState; /* PUBLIC */ + tAoUI reserved; + optArgBucket_t optArg; /* PUBLIC */ +# define pzLastArg optArg.argString + void* optCookie; /* PUBLIC */ + + int const * const pOptMust; + int const * const pOptCant; + tpOptProc const pOptProc; + char const* const pzText; + + char const* const pz_NAME; + char const* const pz_Name; + char const* const pz_DisableName; + char const* const pz_DisablePfx; +}; + +/* + * Some options need special processing, so we store their + * indexes in a known place: + */ +typedef struct optSpecIndex tOptSpecIndex; +struct optSpecIndex { + const tAoUS more_help; + const tAoUS save_opts; + const tAoUS number_option; + const tAoUS default_opt; +}; + +/* + * The procedure generated for translating option text + */ +typedef void (tOptionXlateProc)(void); + +struct options { + int const structVersion; + int origArgCt; + char** origArgVect; + unsigned int fOptSet; + unsigned int curOptIdx; + char* pzCurOpt; + + char const* pzProgPath; /* PUBLIC */ + char const* pzProgName; /* PUBLIC */ + char const* const pzPROGNAME; /* PUBLIC */ + char const* const pzRcName; /* PUBLIC */ + char const* const pzCopyright; /* PUBLIC */ + char const* const pzCopyNotice; /* PUBLIC */ + char const* const pzFullVersion; /* PUBLIC */ + char const* const* const papzHomeList; + char const* const pzUsageTitle; + char const* const pzExplain; + char const* const pzDetail; + tOptDesc* const pOptDesc; /* PUBLIC */ + char const* const pzBugAddr; /* PUBLIC */ + + void* pExtensions; + void* pSavedState; + + tpUsageProc pUsageProc; + tOptionXlateProc* pTransProc; + + tOptSpecIndex specOptIdx; + int const optCt; + int const presetOptCt; + char const * pzFullUsage; + char const * pzShortUsage; + /* PUBLIC: */ + optArgBucket_t const * const originalOptArgArray; + void * const * const originalOptArgCookie; +}; + +/* + * Versions where in various fields first appear: + * ($AO_CURRENT * 4096 + $AO_REVISION, but $AO_REVISION must be zero) + */ +#define originalOptArgArray_STRUCT_VERSION 131072 /* AO_CURRENT = 32 */ +#define HAS_originalOptArgArray(_opt) \ + ((_opt)->structVersion >= originalOptArgArray_STRUCT_VERSION) + +/* + * "token list" structure returned by "string_tokenize()" + */ +typedef struct { + unsigned long tkn_ct; + unsigned char* tkn_list[1]; +} token_list_t; + +/* + * Hide the interface - it pollutes a POSIX claim, but leave it for + * anyone #include-ing this header + */ +#define strneqvcmp option_strneqvcmp +#define streqvcmp option_streqvcmp +#define streqvmap option_streqvmap +#define strequate option_strequate +#define strtransform option_strtransform + +/* + * This is an output only structure used by text_mmap and text_munmap. + * Clients must not alter the contents and must provide it to both + * the text_mmap and text_munmap procedures. BE ADVISED: if you are + * mapping the file with PROT_WRITE the NUL byte at the end MIGHT NOT + * BE WRITABLE. In any event, that byte is not be written back + * to the source file. ALSO: if "txt_data" is valid and "txt_errno" + * is not zero, then there *may* not be a terminating NUL. + */ +typedef struct { + void* txt_data; /* text file data */ + size_t txt_size; /* actual file size */ + size_t txt_full_size; /* mmaped mem size */ + int txt_fd; /* file descriptor */ + int txt_zero_fd; /* fd for /dev/zero */ + int txt_errno; /* warning code */ + int txt_prot; /* "prot" flags */ + int txt_flags; /* mapping type */ + int txt_alloc; /* if we malloced memory */ +} tmap_info_t; + +#define TEXT_MMAP_FAILED_ADDR(a) ((void*)(a) == (void*)MAP_FAILED) + +#ifdef __cplusplus +extern "C" { +#define CPLUSPLUS_CLOSER } +#else +#define CPLUSPLUS_CLOSER +#endif + +/* + * The following routines may be coded into AutoOpts client code: + */ + +/* From: tokenize.c line 117 + * + * ao_string_tokenize - tokenize an input string + * + * Arguments: + * string string to be tokenized + * + * Returns: token_list_t* - pointer to a structure that lists each token + * + * This function will convert one input string into a list of strings. + * The list of strings is derived by separating the input based on + * white space separation. However, if the input contains either single + * or double quote characters, then the text after that character up to + * a matching quote will become the string in the list. + * + * The returned pointer should be deallocated with @code{free(3C)} when + * are done using the data. The data are placed in a single block of + * allocated memory. Do not deallocate individual token/strings. + * + * The structure pointed to will contain at least these two fields: + * @table @samp + * @item tkn_ct + * The number of tokens found in the input string. + * @item tok_list + * An array of @code{tkn_ct + 1} pointers to substring tokens, with + * the last pointer set to NULL. + * @end table + * + * There are two types of quoted strings: single quoted (@code{'}) and + * double quoted (@code{"}). Singly quoted strings are fairly raw in that + * escape characters (@code{\\}) are simply another character, except when + * preceding the following characters: + * @example + * @code{\\} double backslashes reduce to one + * @code{'} incorporates the single quote into the string + * @code{\n} suppresses both the backslash and newline character + * @end example + * + * Double quote strings are formed according to the rules of string + * constants in ANSI-C programs. + */ +extern token_list_t* ao_string_tokenize(char const*); + + +/* From: configfile.c line 85 + * + * configFileLoad - parse a configuration file + * + * Arguments: + * pzFile the file to load + * + * Returns: const tOptionValue* - An allocated, compound value structure + * + * This routine will load a named configuration file and parse the + * text as a hierarchically valued option. The option descriptor + * created from an option definition file is not used via this interface. + * The returned value is "named" with the input file name and is of + * type "@code{OPARG_TYPE_HIERARCHY}". It may be used in calls to + * @code{optionGetValue()}, @code{optionNextValue()} and + * @code{optionUnloadNested()}. + */ +extern const tOptionValue* configFileLoad(char const*); + + +/* From: configfile.c line 897 + * + * optionFileLoad - Load the locatable config files, in order + * + * Arguments: + * pOpts program options descriptor + * pzProg program name + * + * Returns: int - 0 -> SUCCESS, -1 -> FAILURE + * + * This function looks in all the specified directories for a configuration + * file ("rc" file or "ini" file) and processes any found twice. The first + * time through, they are processed in reverse order (last file first). At + * that time, only "immediate action" configurables are processed. For + * example, if the last named file specifies not processing any more + * configuration files, then no more configuration files will be processed. + * Such an option in the @strong{first} named directory will have no effect. + * + * Once the immediate action configurables have been handled, then the + * directories are handled in normal, forward order. In that way, later + * config files can override the settings of earlier config files. + * + * See the AutoOpts documentation for a thorough discussion of the + * config file format. + * + * Configuration files not found or not decipherable are simply ignored. + */ +extern int optionFileLoad(tOptions*, char const*); + + +/* From: configfile.c line 217 + * + * optionFindNextValue - find a hierarcicaly valued option instance + * + * Arguments: + * pOptDesc an option with a nested arg type + * pPrevVal the last entry + * name name of value to find + * value the matching value + * + * Returns: const tOptionValue* - a compound value structure + * + * 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 + * that matches the criteria. + */ +extern const tOptionValue* optionFindNextValue(const tOptDesc*, const tOptionValue*, char const*, char const*); + + +/* From: configfile.c line 143 + * + * optionFindValue - find a hierarcicaly valued option instance + * + * Arguments: + * pOptDesc an option with a nested arg type + * name name of value to find + * value the matching value + * + * Returns: const tOptionValue* - a compound value structure + * + * This routine will find an entry in a nested value option or configurable. + * It will search through the list and return a matching entry. + */ +extern const tOptionValue* optionFindValue(const tOptDesc*, char const*, char const*); + + +/* From: restore.c line 165 + * + * optionFree - free allocated option processing memory + * + * Arguments: + * pOpts program options descriptor + * + * AutoOpts sometimes allocates memory and puts pointers to it in the + * option state structures. This routine deallocates all such memory. + */ +extern void optionFree(tOptions*); + + +/* From: configfile.c line 286 + * + * optionGetValue - get a specific value from a hierarcical list + * + * Arguments: + * pOptValue a hierarchcal value + * valueName name of value to get + * + * Returns: const tOptionValue* - a compound value structure + * + * This routine will find an entry in a nested value option or configurable. + * If "valueName" is NULL, then the first entry is returned. Otherwise, + * the first entry with a name that exactly matches the argument will be + * returned. + */ +extern const tOptionValue* optionGetValue(const tOptionValue*, char const*); + + +/* From: load.c line 498 + * + * optionLoadLine - process a string for an option name and value + * + * Arguments: + * pOpts program options descriptor + * pzLine NUL-terminated text + * + * This is a client program callable routine for setting options from, for + * example, the contents of a file that they read in. Only one option may + * appear in the text. It will be treated as a normal (non-preset) option. + * + * When passed a pointer to the option struct and a string, it will find + * the option named by the first token on the string and set the option + * argument to the remainder of the string. The caller must NUL terminate + * the string. Any embedded new lines will be included in the option + * argument. If the input looks like one or more quoted strings, then the + * input will be "cooked". The "cooking" is identical to the string + * formation used in AutoGen definition files (@pxref{basic expression}), + * except that you may not use backquotes. + */ +extern void optionLoadLine(tOptions*, char const*); + + +/* From: configfile.c line 345 + * + * optionNextValue - get the next value from a hierarchical list + * + * Arguments: + * pOptValue a hierarchcal list value + * pOldValue a value from this list + * + * Returns: const tOptionValue* - a compound value structure + * + * This routine will return the next entry after the entry passed in. At the + * end of the list, NULL will be returned. If the entry is not found on the + * list, NULL will be returned and "@var{errno}" will be set to EINVAL. + * The "@var{pOldValue}" must have been gotten from a prior call to this + * routine or to "@code{opitonGetValue()}". + */ +extern const tOptionValue* optionNextValue(const tOptionValue*, const tOptionValue*); + + +/* From: usage.c line 107 + * + * optionOnlyUsage - Print usage text for just the options + * + * Arguments: + * pOpts program options descriptor + * ex_code exit code for calling exit(3) + * + * This routine will print only the usage for each option. + * This function may be used when the emitted usage must incorporate + * information not available to AutoOpts. + */ +extern void optionOnlyUsage(tOptions*, int); + + +/* From: autoopts.c line 1041 + * + * optionProcess - this is the main option processing routine + * + * Arguments: + * pOpts program options descriptor + * argc program arg count + * argv program arg vector + * + * Returns: int - the count of the arguments processed + * + * This is the main entry point for processing options. It is intended + * that this procedure be called once at the beginning of the execution of + * a program. Depending on options selected earlier, it is sometimes + * necessary to stop and restart option processing, or to select completely + * different sets of options. This can be done easily, but you generally + * do not want to do this. + * + * The number of arguments processed always includes the program name. + * If one of the arguments is "--", then it is counted and the processing + * stops. If an error was encountered and errors are to be tolerated, then + * the returned value is the index of the argument causing the error. + * A hyphen by itself ("-") will also cause processing to stop and will + * @emph{not} be counted among the processed arguments. A hyphen by itself + * is treated as an operand. Encountering an operand stops option + * processing. + */ +extern int optionProcess(tOptions*, int, char**); + + +/* From: restore.c line 122 + * + * optionRestore - restore option state from memory copy + * + * Arguments: + * pOpts program options descriptor + * + * Copy back the option state from saved memory. + * The allocated memory is left intact, so this routine can be + * called repeatedly without having to call optionSaveState again. + * If you are restoring a state that was saved before the first call + * to optionProcess(3AO), then you may change the contents of the + * argc/argv parameters to optionProcess. + */ +extern void optionRestore(tOptions*); + + +/* From: save.c line 671 + * + * optionSaveFile - saves the option state to a file + * + * Arguments: + * pOpts program options descriptor + * + * This routine will save the state of option processing to a file. The name + * of that file can be specified with the argument to the @code{--save-opts} + * option, or by appending the @code{rcfile} attribute to the last + * @code{homerc} attribute. If no @code{rcfile} attribute was specified, it + * will default to @code{.@i{programname}rc}. If you wish to specify another + * file, you should invoke the @code{SET_OPT_SAVE_OPTS( @i{filename} )} macro. + * + * The recommend usage is as follows: + * @example + * optionProcess(&progOptions, argc, argv); + * if (i_want_a_non_standard_place_for_this) + * SET_OPT_SAVE_OPTS("myfilename"); + * optionSaveFile(&progOptions); + * @end example + */ +extern void optionSaveFile(tOptions*); + + +/* From: restore.c line 70 + * + * optionSaveState - saves the option state to memory + * + * Arguments: + * pOpts program options descriptor + * + * This routine will allocate enough memory to save the current option + * processing state. If this routine has been called before, that memory + * will be reused. You may only save one copy of the option state. This + * routine may be called before optionProcess(3AO). If you do call it + * before the first call to optionProcess, then you may also change the + * contents of argc/argv after you call optionRestore(3AO) + * + * In fact, more strongly put: it is safest to only use this function + * before having processed any options. In particular, the saving and + * restoring of stacked string arguments and hierarchical values is + * disabled. The values are not saved. + */ +extern void optionSaveState(tOptions*); + + +/* From: nested.c line 569 + * + * optionUnloadNested - Deallocate the memory for a nested value + * + * Arguments: + * pOptVal the hierarchical value + * + * A nested value needs to be deallocated. The pointer passed in should + * have been gotten from a call to @code{configFileLoad()} (See + * @pxref{libopts-configFileLoad}). + */ +extern void optionUnloadNested(tOptionValue const *); + + +/* From: version.c line 37 + * + * optionVersion - return the compiled AutoOpts version number + * + * Returns: char const* - the version string in constant memory + * + * Returns the full version string compiled into the library. + * The returned string cannot be modified. + */ +extern char const* optionVersion(void); + + +/* From: ../compat/pathfind.c line 33 + * + * pathfind - fild a file in a list of directories + * + * Arguments: + * path colon separated list of search directories + * file the name of the file to look for + * mode the mode bits that must be set to match + * + * Returns: char* - the path to the located file + * + * the pathfind function is available only if HAVE_PATHFIND is not defined + * + * pathfind looks for a a file with name "FILE" and "MODE" access + * along colon delimited "PATH", and returns the full pathname as a + * string, or NULL if not found. If "FILE" contains a slash, then + * it is treated as a relative or absolute path and "PATH" is ignored. + * + * @strong{NOTE}: this function is compiled into @file{libopts} only if + * it is not natively supplied. + * + * The "MODE" argument is a string of option letters chosen from the + * list below: + * @example + * Letter Meaning + * r readable + * w writable + * x executable + * f normal file (NOT IMPLEMENTED) + * b block special (NOT IMPLEMENTED) + * c character special (NOT IMPLEMENTED) + * d directory (NOT IMPLEMENTED) + * p FIFO (pipe) (NOT IMPLEMENTED) + * u set user ID bit (NOT IMPLEMENTED) + * g set group ID bit (NOT IMPLEMENTED) + * k sticky bit (NOT IMPLEMENTED) + * s size nonzero (NOT IMPLEMENTED) + * @end example + */ +#ifndef HAVE_PATHFIND +extern char* pathfind(char const*, char const*, char const*); +#endif /* HAVE_PATHFIND */ + + +/* From: streqvcmp.c line 208 + * + * strequate - map a list of characters to the same value + * + * Arguments: + * ch_list characters to equivalence + * + * Each character in the input string get mapped to the first character + * in the string. + * This function name is mapped to option_strequate so as to not conflict + * with the POSIX name space. + */ +extern void strequate(char const*); + + +/* From: streqvcmp.c line 118 + * + * streqvcmp - compare two strings with an equivalence mapping + * + * Arguments: + * str1 first string + * str2 second string + * + * Returns: int - the difference between two differing characters + * + * Using a character mapping, two strings are compared for "equivalence". + * Each input character is mapped to a comparison character and the + * mapped-to characters are compared for the two NUL terminated input strings. + * This function name is mapped to option_streqvcmp so as to not conflict + * with the POSIX name space. + */ +extern int streqvcmp(char const*, char const*); + + +/* From: streqvcmp.c line 155 + * + * streqvmap - Set the character mappings for the streqv functions + * + * Arguments: + * From Input character + * To Mapped-to character + * ct compare length + * + * Set the character mapping. If the count (@code{ct}) is set to zero, then + * the map is cleared by setting all entries in the map to their index + * value. Otherwise, the "@code{From}" character is mapped to the "@code{To}" + * character. If @code{ct} is greater than 1, then @code{From} and @code{To} + * are incremented and the process repeated until @code{ct} entries have been + * set. For example, + * @example + * streqvmap( 'a', 'A', 26 ); + * @end example + * @noindent + * will alter the mapping so that all English lower case letters + * will map to upper case. + * + * This function name is mapped to option_streqvmap so as to not conflict + * with the POSIX name space. + */ +extern void streqvmap(char, char, int); + + +/* From: streqvcmp.c line 77 + * + * strneqvcmp - compare two strings with an equivalence mapping + * + * Arguments: + * str1 first string + * str2 second string + * ct compare length + * + * Returns: int - the difference between two differing characters + * + * Using a character mapping, two strings are compared for "equivalence". + * Each input character is mapped to a comparison character and the + * mapped-to characters are compared for the two NUL terminated input strings. + * The comparison is limited to @code{ct} bytes. + * This function name is mapped to option_strneqvcmp so as to not conflict + * with the POSIX name space. + */ +extern int strneqvcmp(char const*, char const*, int); + + +/* From: streqvcmp.c line 234 + * + * strtransform - convert a string into its mapped-to value + * + * Arguments: + * dest output string + * src input string + * + * Each character in the input string is mapped and the mapped-to + * character is put into the output. + * This function name is mapped to option_strtransform so as to not conflict + * with the POSIX name space. + * + * The source and destination may be the same. + */ +extern void strtransform(char*, char const*); + +/* AutoOpts PRIVATE FUNCTIONS: */ +tOptProc optionStackArg, optionUnstackArg, optionBooleanVal, optionNumericVal; + +extern char* ao_string_cook(char*, int*); + +extern unsigned int ao_string_cook_escape_char(char const*, char*, unsigned int); + +extern void export_options_to_guile(tOptions*); + +extern void genshelloptUsage(tOptions*, int); + +extern void optionBooleanVal(tOptions*, tOptDesc*); + +extern uintptr_t optionEnumerationVal(tOptions*, tOptDesc*, char const * const *, unsigned int); + +extern void optionFileCheck(tOptions*, tOptDesc*, teOptFileType, tuFileMode); + +extern char const* optionKeywordName(tOptDesc*, unsigned int); + +extern void optionLoadOpt(tOptions*, tOptDesc*); + +extern ag_bool optionMakePath(char*, int, char const*, char const*); + +extern void optionNestedVal(tOptions*, tOptDesc*); + +extern void optionNumericVal(tOptions*, tOptDesc*); + +extern void optionPagedUsage(tOptions*, tOptDesc*); + +extern void optionParseShell(tOptions*); + +extern void optionPrintVersion(tOptions*, tOptDesc*); + +extern void optionPutShell(tOptions*); + +extern void optionResetOpt(tOptions*, tOptDesc*); + +extern void optionSetMembers(tOptions*, tOptDesc*, char const * const *, unsigned int); + +extern void optionShowRange(tOptions*, tOptDesc*, void *, int); + +extern void optionStackArg(tOptions*, tOptDesc*); + +extern void optionTimeVal(tOptions*, tOptDesc*); + +extern void optionUnstackArg(tOptions*, tOptDesc*); + +extern void optionUsage(tOptions*, int); + +extern void optionVersionStderr(tOptions*, tOptDesc*); + +extern void* text_mmap(char const*, int, int, tmap_info_t*); + +extern int text_munmap(tmap_info_t*); + +CPLUSPLUS_CLOSER +#endif /* AUTOOPTS_OPTIONS_H_GUARD */ +/* + * Local Variables: + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * options.h ends here */ diff --git a/libopts/autoopts/usage-txt.h b/libopts/autoopts/usage-txt.h new file mode 100644 index 0000000..aa973e5 --- /dev/null +++ b/libopts/autoopts/usage-txt.h @@ -0,0 +1,393 @@ +/* -*- buffer-read-only: t -*- vi: set ro: + * + * DO NOT EDIT THIS FILE (usage-txt.h) + * + * It has been AutoGen-ed August 8, 2009 at 10:14:43 AM by AutoGen 5.9.9 + * From the definitions usage-txt.def + * and the template file usage-txt.tpl + * + * This file handles all the bookkeeping required for tracking all the little + * tiny strings used by the AutoOpts library. There are 130 + * of them. This is not versioned because it is entirely internal to the + * library and accessed by client code only in a very well-controlled way: + * they may substitute translated strings using a procedure that steps through + * all the string pointers. + * + * AutoOpts is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AutoOpts is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +#ifndef AUTOOPTS_USAGE_TXT_H_GUARD +#define AUTOOPTS_USAGE_TXT_H_GUARD 1 + +#undef cch_t +#define cch_t char const + +/* + * One structure to hold all the pointers to all the stringlets. + */ +typedef struct { + int field_ct; + char* utpz_GnuBoolArg; + char* utpz_GnuKeyArg; + char* utpz_GnuFileArg; + char* utpz_GnuKeyLArg; + char* utpz_GnuTimeArg; + char* utpz_GnuNumArg; + char* utpz_GnuStrArg; + cch_t* apz_str[ 123 ]; +} usage_text_t; + +/* + * Declare the global structure with all the pointers to translated + * strings. This is then used by the usage generation procedure. + */ +extern usage_text_t option_usage_text; + +#if defined(AUTOOPTS_INTERNAL) /* DEFINE ALL THE STRINGS = = = = = */ +/* + * Provide a mapping from a short name to fields in this structure. + */ +#define zAO_Bad (option_usage_text.apz_str[ 0]) +#define zAO_Big (option_usage_text.apz_str[ 1]) +#define zAO_Err (option_usage_text.apz_str[ 2]) +#define zAO_Sml (option_usage_text.apz_str[ 3]) +#define zAO_Ver (option_usage_text.apz_str[ 4]) +#define zAO_Woops (option_usage_text.apz_str[ 5]) +#define zAll (option_usage_text.apz_str[ 6]) +#define zAlt (option_usage_text.apz_str[ 7]) +#define zAmbigKey (option_usage_text.apz_str[ 8]) +#define zAmbigOptStr (option_usage_text.apz_str[ 9]) +#define zArgsMust (option_usage_text.apz_str[ 10]) +#define zAtMost (option_usage_text.apz_str[ 11]) +#define zAuto (option_usage_text.apz_str[ 12]) +#define zBadPipe (option_usage_text.apz_str[ 13]) +#define zBadVerArg (option_usage_text.apz_str[ 14]) +#define zCantFmt (option_usage_text.apz_str[ 15]) +#define zCantSave (option_usage_text.apz_str[ 16]) +#define zDefaultOpt (option_usage_text.apz_str[ 17]) +#define zDis (option_usage_text.apz_str[ 18]) +#define zEnab (option_usage_text.apz_str[ 19]) +#define zEquiv (option_usage_text.apz_str[ 20]) +#define zErrOnly (option_usage_text.apz_str[ 21]) +#define zExamineFmt (option_usage_text.apz_str[ 22]) +#define zFiveSpaces (option_usage_text.apz_str[ 23]) +#define zFlagOkay (option_usage_text.apz_str[ 24]) +#define zFmtFmt (option_usage_text.apz_str[ 25]) +#define zForkFail (option_usage_text.apz_str[ 26]) +#define zFSErrOptLoad (option_usage_text.apz_str[ 27]) +#define zFSErrReadFile (option_usage_text.apz_str[ 28]) +#define zFSOptError (option_usage_text.apz_str[ 29]) +#define zFSOptErrMayExist (option_usage_text.apz_str[ 30]) +#define zFSOptErrMustExist (option_usage_text.apz_str[ 31]) +#define zFSOptErrNoExist (option_usage_text.apz_str[ 32]) +#define zFSOptErrOpen (option_usage_text.apz_str[ 33]) +#define zFSOptErrFopen (option_usage_text.apz_str[ 34]) +#define zFileCannotExist (option_usage_text.apz_str[ 35]) +#define zFileMustExist (option_usage_text.apz_str[ 36]) +#define zGenshell (option_usage_text.apz_str[ 37]) +#define zGnuBoolArg (option_usage_text.utpz_GnuBoolArg) +#define zGnuBreak (option_usage_text.apz_str[ 38]) +#define zGnuKeyArg (option_usage_text.utpz_GnuKeyArg) +#define zGnuFileArg (option_usage_text.utpz_GnuFileArg) +#define zGnuKeyLArg (option_usage_text.utpz_GnuKeyLArg) +#define zGnuTimeArg (option_usage_text.utpz_GnuTimeArg) +#define zGnuNestArg (option_usage_text.apz_str[ 39]) +#define zGnuNumArg (option_usage_text.utpz_GnuNumArg) +#define zGnuOptArg (option_usage_text.apz_str[ 40]) +#define zGnuOptFmt (option_usage_text.apz_str[ 41]) +#define zGnuStrArg (option_usage_text.utpz_GnuStrArg) +#define zIllOptChr (option_usage_text.apz_str[ 42]) +#define zIllOptStr (option_usage_text.apz_str[ 43]) +#define zIllegal (option_usage_text.apz_str[ 44]) +#define zIntRange (option_usage_text.apz_str[ 45]) +#define zInvalOptDesc (option_usage_text.apz_str[ 46]) +#define zLowerBits (option_usage_text.apz_str[ 47]) +#define zMembers (option_usage_text.apz_str[ 48]) +#define zMisArg (option_usage_text.apz_str[ 49]) +#define zMultiEquiv (option_usage_text.apz_str[ 50]) +#define zMust (option_usage_text.apz_str[ 51]) +#define zNeedOne (option_usage_text.apz_str[ 52]) +#define zNoArg (option_usage_text.apz_str[ 53]) +#define zNoArgs (option_usage_text.apz_str[ 54]) +#define zNoCreat (option_usage_text.apz_str[ 55]) +#define zNoFlags (option_usage_text.apz_str[ 56]) +#define zNoKey (option_usage_text.apz_str[ 57]) +#define zNoLim (option_usage_text.apz_str[ 58]) +#define zNoPreset (option_usage_text.apz_str[ 59]) +#define zNoResetArg (option_usage_text.apz_str[ 60]) +#define zNoRq_NoShrtTtl (option_usage_text.apz_str[ 61]) +#define zNoRq_ShrtTtl (option_usage_text.apz_str[ 62]) +#define zNoStat (option_usage_text.apz_str[ 63]) +#define zNoState (option_usage_text.apz_str[ 64]) +#define zNone (option_usage_text.apz_str[ 65]) +#define zNotDef (option_usage_text.apz_str[ 66]) +#define zNotCmdOpt (option_usage_text.apz_str[ 67]) +#define zNotEnough (option_usage_text.apz_str[ 68]) +#define zNotFile (option_usage_text.apz_str[ 69]) +#define zNotNumber (option_usage_text.apz_str[ 70]) +#define zNrmOptFmt (option_usage_text.apz_str[ 71]) +#define zNumberOpt (option_usage_text.apz_str[ 72]) +#define zOneSpace (option_usage_text.apz_str[ 73]) +#define zOnlyOne (option_usage_text.apz_str[ 74]) +#define zOptsOnly (option_usage_text.apz_str[ 75]) +#define zPathFmt (option_usage_text.apz_str[ 76]) +#define zPlsSendBugs (option_usage_text.apz_str[ 77]) +#define zPreset (option_usage_text.apz_str[ 78]) +#define zPresetFile (option_usage_text.apz_str[ 79]) +#define zPresetIntro (option_usage_text.apz_str[ 80]) +#define zProg (option_usage_text.apz_str[ 81]) +#define zProhib (option_usage_text.apz_str[ 82]) +#define zReorder (option_usage_text.apz_str[ 83]) +#define zRange (option_usage_text.apz_str[ 84]) +#define zRangeAbove (option_usage_text.apz_str[ 85]) +#define zRangeLie (option_usage_text.apz_str[ 86]) +#define zRangeBadLie (option_usage_text.apz_str[ 87]) +#define zRangeOnly (option_usage_text.apz_str[ 88]) +#define zRangeOr (option_usage_text.apz_str[ 89]) +#define zRangeErr (option_usage_text.apz_str[ 90]) +#define zRangeExact (option_usage_text.apz_str[ 91]) +#define zRangeScaled (option_usage_text.apz_str[ 92]) +#define zRangeUpto (option_usage_text.apz_str[ 93]) +#define zResetNotConfig (option_usage_text.apz_str[ 94]) +#define zReqFmt (option_usage_text.apz_str[ 95]) +#define zReqOptFmt (option_usage_text.apz_str[ 96]) +#define zReqThese (option_usage_text.apz_str[ 97]) +#define zReq_NoShrtTtl (option_usage_text.apz_str[ 98]) +#define zReq_ShrtTtl (option_usage_text.apz_str[ 99]) +#define zSepChars (option_usage_text.apz_str[100]) +#define zSetMemberSettings (option_usage_text.apz_str[101]) +#define zShrtGnuOptFmt (option_usage_text.apz_str[102]) +#define zSixSpaces (option_usage_text.apz_str[103]) +#define zStdBoolArg (option_usage_text.apz_str[104]) +#define zStdBreak (option_usage_text.apz_str[105]) +#define zStdFileArg (option_usage_text.apz_str[106]) +#define zStdKeyArg (option_usage_text.apz_str[107]) +#define zStdKeyLArg (option_usage_text.apz_str[108]) +#define zStdTimeArg (option_usage_text.apz_str[109]) +#define zStdNestArg (option_usage_text.apz_str[110]) +#define zStdNoArg (option_usage_text.apz_str[111]) +#define zStdNumArg (option_usage_text.apz_str[112]) +#define zStdOptArg (option_usage_text.apz_str[113]) +#define zStdReqArg (option_usage_text.apz_str[114]) +#define zStdStrArg (option_usage_text.apz_str[115]) +#define zTabHyp (option_usage_text.apz_str[116]) +#define zTabHypAnd (option_usage_text.apz_str[117]) +#define zTabout (option_usage_text.apz_str[118]) +#define zThreeSpaces (option_usage_text.apz_str[119]) +#define zTwoSpaces (option_usage_text.apz_str[120]) +#define zUpTo (option_usage_text.apz_str[121]) +#define zValidKeys (option_usage_text.apz_str[122]) + + /* + * First, set up the strings. Some of these are writable. These are all in + * English. This gets compiled into libopts and is distributed here so that + * xgettext (or equivalents) can extract these strings for translation. + */ + + static char eng_zGnuBoolArg[] = "=T/F"; + static char eng_zGnuKeyArg[] = "=KWd"; + static char eng_zGnuFileArg[] = "=file"; + static char eng_zGnuKeyLArg[] = "=Mbr"; + static char eng_zGnuTimeArg[] = "=Tim"; + static char eng_zGnuNumArg[] = "=num"; + static char eng_zGnuStrArg[] = "=str"; +static char const usage_txt[4024] = + "AutoOpts function called without option descriptor\n\0" + "\tThis exceeds the compiled library version: \0" + "Automated Options Processing Error!\n" + "\t%s called AutoOpts function with structure version %d:%d:%d.\n\0" + "\tThis is less than the minimum library version: \0" + "Automated Options version %s\n" + "\tcopyright (c) 1999-2009 by Bruce Korb - all rights reserved\n\0" + "AutoOpts lib error: defaulted to option with optional arg\n\0" + "all\0" + "\t\t\t\t- an alternate for %s\n\0" + "%s error: the keyword `%s' is ambiguous for %s\n\0" + "%s: ambiguous option -- %s\n\0" + "%s: Command line arguments required\n\0" + "%d %s%s options allowed\n\0" + "version and help options:\0" + "Error %d (%s) from the pipe(2) syscall\n\0" + "ERROR: version option argument '%c' invalid. Use:\n" + "\t'v' - version only\n" + "\t'c' - version and copyright\n" + "\t'n' - version and copyright notice\n\0" + "ERROR: %s option conflicts with the %s option\n\0" + "%s(optionSaveState): error: cannot allocate %d bytes\n\0" + "\t\t\t\t- default option for unnamed options\n\0" + "\t\t\t\t- disabled as --%s\n\0" + "\t\t\t\t- enabled by default\n\0" + "-equivalence\0" + "ERROR: only \0" + " - examining environment variables named %s_*\n\0" + " \0" + "Options are specified by doubled hyphens and their name\n" + "or by a single hyphen and the flag character.\n\0" + "%%-%ds %%s\n\0" + "fs error %d (%s) on fork - cannot obtain %s usage\n\0" + "File error %d (%s) opening %s for loading options\n\0" + "fs error %d (%s) reading file %s\n\0" + "fs error %d (%s) on %s %s for option %s\n\0" + "stat-ing for directory\0" + "stat-ing for regular file\0" + "stat-ing for non-existant file\0" + "open-ing file\0" + "fopen-ing file\0" + "\t\t\t\t- file must not pre-exist\n\0" + "\t\t\t\t- file must pre-exist\n\0" + "\n" + "= = = = = = = =\n\n" + "This incarnation of genshell will produce\n" + "a shell script to parse the options for %s:\n\n\0" + "\n" + "%s\n\n\0" + "=Cplx\0" + "[=arg]\0" + "--%2$s%1$s\0" + "%s: illegal option -- %c\n\0" + "%s: illegal option -- %s\n\0" + "illegal\0" + " or an integer from %d through %d\n\0" + "AutoOpts ERROR: invalid option descriptor for %s\n\0" + " or an integer mask with any of the lower %d bits set\n\0" + "\t\t\t\t- is a set membership option\n\0" + "%s: option `%s' requires an argument\n\0" + "Equivalenced option '%s' was equivalenced to both\n" + "\t'%s' and '%s'\0" + "\t\t\t\t- must appear between %d and %d times\n\0" + "ERROR: The %s option is required\n\0" + "%s: option `%s' cannot have an argument\n\0" + "%s: Command line arguments not allowed\n\0" + "error %d (%s) creating %s\n\0" + "Options are specified by single or double hyphens and their name.\n\0" + "%s error: `%s' does not match any %s keywords\n\0" + "\t\t\t\t- may appear multiple times\n\0" + "\t\t\t\t- may not be preset\n\0" + "The 'reset-option' option requires an argument\n\0" + " Arg Option-Name Description\n\0" + " Flg Arg Option-Name Description\n\0" + "error %d (%s) stat-ing %s\n\0" + "%s(optionRestore): error: no saved option state\n\0" + "none\0" + "'%s' not defined\n\0" + "'%s' is not a command line option\n\0" + "ERROR: The %s option must appear %d times\n\0" + "error: cannot load options from non-regular file %s\n\0" + "%s error: `%s' is not a recognizable number\n\0" + " %3s %s\0" + "The '-#' option may omit the hash char\n\0" + " \0" + "one %s%s option allowed\n\0" + "All arguments are named options.\n\0" + " - reading file %s\0" + "\n" + "please send bug reports to: %s\n\0" + "\t\t\t\t- may NOT appear - preset only\n\0" + "# preset/initialization file\n" + "# %s#\n\0" + "\n" + "The following option preset mechanisms are supported:\n\0" + "program\0" + "prohibits these options:\n\0" + "Operands and options may be intermixed. They will be reordered.\n\0" + "%s%ld to %ld\0" + "%sgreater than or equal to %ld\0" + "%sIt must lie in one of the ranges:\n\0" + "%sThis option must lie in one of the ranges:\n\0" + "%sit must be: \0" + ", or\n\0" + "%s error: %s option value ``%s'' is out of range.\n\0" + "%s%ld exactly\0" + "%sis scalable with a suffix: k/K/m/M/g/G/t/T\n\0" + "%sless than or equal to %ld\0" + "The --reset-option has not been configured.\n\0" + "ERROR: %s option requires the %s option\n\0" + " %3s %-14s %s\0" + "requires these options:\n\0" + " Arg Option-Name Req? Description\n\0" + " Flg Arg Option-Name Req? Description\n\0" + "-_^\0" + "or you may use a numeric representation. Preceding these with a '!' will\n" + "clear the bits, specifying 'none' will clear all bits, and 'all' will set them\n" + "all. Multiple entries may be passed as an option argument list.\n\0" + "%s\0" + " \0" + "T/F\0" + "\n" + "%s\n\n" + "%s\0" + "Fil\0" + "KWd\0" + "Mbr\0" + "Tim\0" + "Cpx\0" + "no \0" + "Num\0" + "opt\0" + "YES\0" + "Str\0" + "\t\t\t\t- \0" + "\t\t\t\t-- and \0" + "\t\t\t\t%s\n\0" + " \0" + " \0" + "\t\t\t\t- may appear up to %d times\n\0" + "The valid \"%s\" option keywords are:\n\0"; + + + /* + * Now, define (and initialize) the structure that contains + * the pointers to all these strings. + * Aren't you glad you don't maintain this by hand? + */ + usage_text_t option_usage_text = { + 130, + eng_zGnuBoolArg, eng_zGnuKeyArg, eng_zGnuFileArg, eng_zGnuKeyLArg, + eng_zGnuTimeArg, eng_zGnuNumArg, eng_zGnuStrArg, + { + usage_txt + 0, usage_txt + 52, usage_txt + 98, usage_txt + 197, + usage_txt + 247, usage_txt + 338, usage_txt + 397, usage_txt + 401, + usage_txt + 428, usage_txt + 477, usage_txt + 505, usage_txt + 542, + usage_txt + 567, usage_txt + 593, usage_txt + 633, usage_txt + 770, + usage_txt + 818, usage_txt + 872, usage_txt + 914, usage_txt + 938, + usage_txt + 964, usage_txt + 977, usage_txt + 991, usage_txt +1038, + usage_txt +1044, usage_txt +1147, usage_txt +1159, usage_txt +1210, + usage_txt +1261, usage_txt +1295, usage_txt +1336, usage_txt +1359, + usage_txt +1385, usage_txt +1416, usage_txt +1430, usage_txt +1445, + usage_txt +1476, usage_txt +1503, usage_txt +1609, usage_txt +1615, + usage_txt +1621, usage_txt +1628, usage_txt +1639, usage_txt +1665, + usage_txt +1691, usage_txt +1699, usage_txt +1735, usage_txt +1786, + usage_txt +1842, usage_txt +1876, usage_txt +1914, usage_txt +1979, + usage_txt +2022, usage_txt +2057, usage_txt +2098, usage_txt +2138, + usage_txt +2165, usage_txt +2232, usage_txt +2280, usage_txt +2313, + usage_txt +2338, usage_txt +2386, usage_txt +2421, usage_txt +2459, + usage_txt +2486, usage_txt +2535, usage_txt +2540, usage_txt +2558, + usage_txt +2593, usage_txt +2637, usage_txt +2691, usage_txt +2737, + usage_txt +2745, usage_txt +2793, usage_txt +2795, usage_txt +2820, + usage_txt +2854, usage_txt +2873, usage_txt +2907, usage_txt +2943, + usage_txt +2981, usage_txt +3037, usage_txt +3045, usage_txt +3071, + usage_txt +3137, usage_txt +3150, usage_txt +3181, usage_txt +3218, + usage_txt +3264, usage_txt +3280, usage_txt +3286, usage_txt +3338, + usage_txt +3352, usage_txt +3398, usage_txt +3426, usage_txt +3471, + usage_txt +3513, usage_txt +3527, usage_txt +3552, usage_txt +3592, + usage_txt +3635, usage_txt +3639, usage_txt +3858, usage_txt +3861, + usage_txt +3868, usage_txt +3872, usage_txt +3880, usage_txt +3884, + usage_txt +3888, usage_txt +3892, usage_txt +3896, usage_txt +3900, + usage_txt +3904, usage_txt +3908, usage_txt +3912, usage_txt +3916, + usage_txt +3920, usage_txt +3927, usage_txt +3939, usage_txt +3947, + usage_txt +3951, usage_txt +3954, usage_txt +3987 + } + }; + +#endif /* DO_TRANSLATIONS */ +#endif /* AUTOOPTS_USAGE_TXT_H_GUARD */ diff --git a/libopts/boolean.c b/libopts/boolean.c new file mode 100644 index 0000000..329b431 --- /dev/null +++ b/libopts/boolean.c @@ -0,0 +1,91 @@ + +/* + * $Id: boolean.c,v 4.16 2009/08/01 17:43:05 bkorb Exp $ + * Time-stamp: "2008-08-03 13:06:02 bkorb" + * + * Automated Options Paged Usage module. + * + * This routine will run run-on options through a pager so the + * user may examine, print or edit them at their leisure. + * + * This file is part of AutoOpts, a companion to AutoGen. + * AutoOpts is free software. + * AutoOpts is copyright (c) 1992-2009 by Bruce Korb - all rights reserved + * + * AutoOpts is available under any one of two licenses. The license + * in use must be one of these two and the choice is under the control + * of the user of the license. + * + * The GNU Lesser General Public License, version 3 or later + * See the files "COPYING.lgplv3" and "COPYING.gplv3" + * + * The Modified Berkeley Software Distribution License + * See the file "COPYING.mbsd" + * + * These files have the following md5sums: + * + * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 + * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 + * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + */ + +/*=export_func optionBooleanVal + * private: + * + * what: Decipher a boolean value + * arg: + tOptions* + pOpts + program options descriptor + + * arg: + tOptDesc* + pOptDesc + the descriptor for this arg + + * + * doc: + * Decipher a true or false value for a boolean valued option argument. + * The value is true, unless it starts with 'n' or 'f' or "#f" or + * it is an empty string or it is a number that evaluates to zero. +=*/ +void +optionBooleanVal( tOptions* pOpts, tOptDesc* pOD ) +{ + char* pz; + ag_bool res = AG_TRUE; + + if ((pOD->fOptState & OPTST_RESET) != 0) + return; + + if (pOD->optArg.argString == NULL) { + pOD->optArg.argBool = AG_FALSE; + return; + } + + switch (*(pOD->optArg.argString)) { + case '0': + { + long val = strtol( pOD->optArg.argString, &pz, 0 ); + if ((val != 0) || (*pz != NUL)) + break; + /* FALLTHROUGH */ + } + case 'N': + case 'n': + case 'F': + case 'f': + case NUL: + res = AG_FALSE; + break; + case '#': + if (pOD->optArg.argString[1] != 'f') + break; + res = AG_FALSE; + } + + if (pOD->fOptState & OPTST_ALLOC_ARG) { + AGFREE(pOD->optArg.argString); + pOD->fOptState &= ~OPTST_ALLOC_ARG; + } + pOD->optArg.argBool = res; +} +/* + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of autoopts/boolean.c */ diff --git a/libopts/compat/compat.h b/libopts/compat/compat.h new file mode 100644 index 0000000..27c1eb4 --- /dev/null +++ b/libopts/compat/compat.h @@ -0,0 +1,366 @@ +/* -*- Mode: C -*- */ + +/* compat.h --- fake the preprocessor into handlng portability + * + * Time-stamp: "2008-06-14 09:36:25 bkorb" + * + * $Id: compat.h,v 4.22 2009/01/01 16:49:26 bkorb Exp $ + * + * compat.h is free software. + * This file is part of AutoGen. + * + * AutoGen copyright (c) 1992-2009 by Bruce Korb - all rights reserved + * + * AutoGen is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AutoGen is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the 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 . + * + * As a special exception, Bruce Korb gives permission for additional + * uses of the text contained in the release of compat.h. + * + * The exception is that, if you link the compat.h library with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the compat.h library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by Bruce Korb under + * the name compat.h. If you copy code from other sources under the + * General Public License into a copy of compat.h, as the General Public + * License permits, the exception does not apply to the code that you add + * in this way. To avoid misleading anyone as to the status of such + * modified files, you must delete this exception notice from them. + * + * If you write modifications of your own for compat.h, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + */ +#ifndef COMPAT_H_GUARD +#define COMPAT_H_GUARD 1 + +#if defined(HAVE_CONFIG_H) +# include + +#elif defined(_WIN32) && !defined(__CYGWIN__) +# include "windows-config.h" + +#else +# error "compat.h" requires "config.h" + choke me. +#endif + + +#ifndef HAVE_STRSIGNAL + char * strsignal( int signo ); +#endif + +#define _GNU_SOURCE 1 /* for strsignal in GNU's libc */ +#define __USE_GNU 1 /* exact same thing as above */ +#define __EXTENSIONS__ 1 /* and another way to call for it */ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * SYSTEM HEADERS: + */ +#include +#ifdef HAVE_SYS_MMAN_H +# include +#endif +#include +#if HAVE_SYS_PROCSET_H +# include +#endif +#include +#include + +#if defined( HAVE_SOLARIS_SYSINFO ) +# include +#elif defined( HAVE_UNAME_SYSCALL ) +# include +#endif + +#ifdef DAEMON_ENABLED +# if HAVE_SYS_STROPTS_H +# include +# endif + +# if HAVE_SYS_SOCKET_H +# include +# endif + +# if ! defined(HAVE_SYS_POLL_H) && ! defined(HAVE_SYS_SELECT_H) +# error This system cannot support daemon processing + Choke Me. +# endif + +# if HAVE_SYS_POLL_H +# include +# endif + +# if HAVE_SYS_SELECT_H +# include +# endif + +# if HAVE_NETINET_IN_H +# include +# endif + +# if HAVE_SYS_UN_H +# include +# endif +#endif + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * USER HEADERS: + */ +#include +#include +#include + +/* + * Directory opening stuff: + */ +# if defined (_POSIX_SOURCE) +/* Posix does not require that the d_ino field be present, and some + systems do not provide it. */ +# define REAL_DIR_ENTRY(dp) 1 +# else /* !_POSIX_SOURCE */ +# define REAL_DIR_ENTRY(dp) (dp->d_ino != 0) +# endif /* !_POSIX_SOURCE */ + +# if defined (HAVE_DIRENT_H) +# include +# define D_NAMLEN(dirent) strlen((dirent)->d_name) +# else /* !HAVE_DIRENT_H */ +# define dirent direct +# define D_NAMLEN(dirent) (dirent)->d_namlen +# if defined (HAVE_SYS_NDIR_H) +# include +# endif /* HAVE_SYS_NDIR_H */ +# if defined (HAVE_SYS_DIR_H) +# include +# endif /* HAVE_SYS_DIR_H */ +# if defined (HAVE_NDIR_H) +# include +# endif /* HAVE_NDIR_H */ +# endif /* !HAVE_DIRENT_H */ + +#include +#ifdef HAVE_FCNTL_H +# include +#endif +#ifndef O_NONBLOCK +# define O_NONBLOCK FNDELAY +#endif + +#if defined(HAVE_LIBGEN) && defined(HAVE_LIBGEN_H) +# include +#endif + +#if defined(HAVE_LIMITS_H) /* this is also in options.h */ +# include +#elif defined(HAVE_SYS_LIMITS_H) +# include +#endif /* HAVE_LIMITS/SYS_LIMITS_H */ + +#include +#include +#include + +#if defined( HAVE_STDINT_H ) +# include +#elif defined( HAVE_INTTYPES_H ) +# include +#endif + +#include +#include + +#include + +#ifdef HAVE_UTIME_H +# include +#endif + +#ifdef HAVE_UNISTD_H +# include +#endif + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * FIXUPS and CONVIENCE STUFF: + */ +#ifdef __cplusplus +# define EXTERN extern "C" +#else +# define EXTERN extern +#endif + +/* some systems #def errno! and others do not declare it!! */ +#ifndef errno + extern int errno; +#endif + +/* Some machines forget this! */ + +# ifndef EXIT_FAILURE +# define EXIT_SUCCESS 0 +# define EXIT_FAILURE 1 +# endif + +#ifndef NUL +# define NUL '\0' +#endif + +#ifndef NULL +# define NULL 0 +#endif + +#if !defined (MAXPATHLEN) && defined (HAVE_SYS_PARAM_H) +# include +#endif /* !MAXPATHLEN && HAVE_SYS_PARAM_H */ + +#if !defined (MAXPATHLEN) && defined (PATH_MAX) +# define MAXPATHLEN PATH_MAX +#endif /* !MAXPATHLEN && PATH_MAX */ + +#if !defined (MAXPATHLEN) && defined(_MAX_PATH) +# define PATH_MAX _MAX_PATH +# define MAXPATHLEN _MAX_PATH +#endif + +#if !defined (MAXPATHLEN) +# define MAXPATHLEN ((size_t)4096) +#endif /* MAXPATHLEN */ + +#define AG_PATH_MAX ((size_t)MAXPATHLEN) + +#ifndef LONG_MAX +# define LONG_MAX ~(1L << (8*sizeof(long) -1)) +# define INT_MAX ~(1 << (8*sizeof(int) -1)) +#endif + +#ifndef ULONG_MAX +# define ULONG_MAX ~(OUL) +# define UINT_MAX ~(OU) +#endif + +#ifndef SHORT_MAX +# define SHORT_MAX ~(1 << (8*sizeof(short) -1)) +#else +# define USHORT_MAX ~(OUS) +#endif + +#ifndef HAVE_INT8_T + typedef signed char int8_t; +#endif +#ifndef HAVE_UINT8_T + typedef unsigned char uint8_t; +#endif +#ifndef HAVE_INT16_T + typedef signed short int16_t; +#endif +#ifndef HAVE_UINT16_T + typedef unsigned short uint16_t; +#endif +#ifndef HAVE_UINT_T + typedef unsigned int uint_t; +#endif + +#ifndef HAVE_INT32_T +# if SIZEOF_INT == 4 + typedef signed int int32_t; +# elif SIZEOF_LONG == 4 + typedef signed long int32_t; +# endif +#endif + +#ifndef HAVE_UINT32_T +# if SIZEOF_INT == 4 + typedef unsigned int uint32_t; +# elif SIZEOF_LONG == 4 + typedef unsigned long uint32_t; +# else +# error Cannot create a uint32_t type. + Choke Me. +# endif +#endif + +#ifndef HAVE_INTPTR_T + typedef signed long intptr_t; +#endif +#ifndef HAVE_UINTPTR_T + typedef unsigned long uintptr_t; +#endif +#ifndef HAVE_SIZE_T + typedef unsigned int size_t; +#endif +#ifndef HAVE_WINT_T + typedef unsigned int wint_t; +#endif +#ifndef HAVE_PID_T + typedef signed int pid_t; +#endif + +/* redefine these for BSD style string libraries */ +#ifndef HAVE_STRCHR +# define strchr index +# define strrchr rindex +#endif + +#ifdef USE_FOPEN_BINARY +# ifndef FOPEN_BINARY_FLAG +# define FOPEN_BINARY_FLAG "b" +# endif +# ifndef FOPEN_TEXT_FLAG +# define FOPEN_TEXT_FLAG "t" +# endif +#else +# ifndef FOPEN_BINARY_FLAG +# define FOPEN_BINARY_FLAG +# endif +# ifndef FOPEN_TEXT_FLAG +# define FOPEN_TEXT_FLAG +# endif +#endif + +#ifndef STR +# define _STR(s) #s +# define STR(s) _STR(s) +#endif + +/* ##### Pointer sized word ##### */ + +/* FIXME: the MAX stuff in here is broken! */ +#if SIZEOF_CHARP > SIZEOF_INT + typedef long t_word; + #define WORD_MAX LONG_MAX + #define WORD_MIN LONG_MIN +#else /* SIZEOF_CHARP <= SIZEOF_INT */ + typedef int t_word; + #define WORD_MAX INT_MAX + #define WORD_MIN INT_MIN +#endif + +#endif /* COMPAT_H_GUARD */ + +/* + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of compat/compat.h */ diff --git a/libopts/compat/pathfind.c b/libopts/compat/pathfind.c new file mode 100644 index 0000000..d87bada --- /dev/null +++ b/libopts/compat/pathfind.c @@ -0,0 +1,338 @@ +/* -*- Mode: C -*- */ + +/* pathfind.c --- find a FILE MODE along PATH */ + +/* + * Author: Gary V Vaughan + * Time-stamp: "2006-09-23 19:46:16 bkorb" + * Last Modified: $Date: 2007/10/07 16:54:54 $ + * by: bkorb + * + * $Id: pathfind.c,v 4.12 2007/10/07 16:54:54 bkorb Exp $ + */ + +/* Code: */ + +#include "compat.h" +#ifndef HAVE_PATHFIND +#if defined(__windows__) && !defined(__CYGWIN__) +char* +pathfind( char const* path, + char const* fileName, + char const* mode ) +{ + return NULL; +} +#else + +static char* make_absolute( char const *string, char const *dot_path ); +static char* canonicalize_pathname( char *path ); +static char* extract_colon_unit( char* dir, char const *string, int *p_index ); + + +/*=export_func pathfind + * + * what: fild a file in a list of directories + * + * ifndef: HAVE_PATHFIND + * + * arg: + char const* + path + colon separated list of search directories + + * arg: + char const* + file + the name of the file to look for + + * arg: + char const* + mode + the mode bits that must be set to match + + * + * ret_type: char* + * ret_desc: the path to the located file + * + * doc: + * + * pathfind looks for a a file with name "FILE" and "MODE" access + * along colon delimited "PATH", and returns the full pathname as a + * string, or NULL if not found. If "FILE" contains a slash, then + * it is treated as a relative or absolute path and "PATH" is ignored. + * + * @strong{NOTE}: this function is compiled into @file{libopts} only if + * it is not natively supplied. + * + * The "MODE" argument is a string of option letters chosen from the + * list below: + * @example + * Letter Meaning + * r readable + * w writable + * x executable + * f normal file (NOT IMPLEMENTED) + * b block special (NOT IMPLEMENTED) + * c character special (NOT IMPLEMENTED) + * d directory (NOT IMPLEMENTED) + * p FIFO (pipe) (NOT IMPLEMENTED) + * u set user ID bit (NOT IMPLEMENTED) + * g set group ID bit (NOT IMPLEMENTED) + * k sticky bit (NOT IMPLEMENTED) + * s size nonzero (NOT IMPLEMENTED) + * @end example + * + * example: + * To find the "ls" command using the "PATH" environment variable: + * @example + * #include + * char* pz_ls = pathfind( getenv("PATH"), "ls", "rx" ); + * <> + * free( pz_ls ); + * @end example + * The path is allocated with @code{malloc(3C)}, so you must @code{free(3C)} + * the result. Also, do not use unimplemented file modes. :-) + * + * err: returns NULL if the file is not found. +=*/ +char* +pathfind( char const* path, + char const* fileName, + char const* mode ) +{ + int p_index = 0; + int mode_bits = 0; + char* pathName = NULL; + char zPath[ AG_PATH_MAX + 1 ]; + + if (strchr( mode, 'r' )) mode_bits |= R_OK; + if (strchr( mode, 'w' )) mode_bits |= W_OK; + if (strchr( mode, 'x' )) mode_bits |= X_OK; + + /* + * FOR each non-null entry in the colon-separated path, DO ... + */ + for (;;) { + DIR* dirP; + char* colon_unit = extract_colon_unit( zPath, path, &p_index ); + + /* + * IF no more entries, THEN quit + */ + if (colon_unit == NULL) + break; + + dirP = opendir( colon_unit ); + + /* + * IF the directory is inaccessable, THEN next directory + */ + if (dirP == NULL) + continue; + + /* + * FOR every entry in the given directory, ... + */ + for (;;) { + struct dirent *entP = readdir( dirP ); + + if (entP == (struct dirent*)NULL) + break; + + /* + * IF the file name matches the one we are looking for, ... + */ + if (strcmp( entP->d_name, fileName ) == 0) { + char* pzFullName = make_absolute( fileName, colon_unit); + + /* + * Make sure we can access it in the way we want + */ + if (access( pzFullName, mode_bits ) >= 0) { + /* + * We can, so normalize the name and return it below + */ + pathName = canonicalize_pathname( pzFullName ); + } + + free( (void*)pzFullName ); + break; + } + } + + closedir( dirP ); + + if (pathName != NULL) + break; + } + + return pathName; +} + +/* + * Turn STRING (a pathname) into an absolute pathname, assuming that + * DOT_PATH contains the symbolic location of `.'. This always returns + * a new string, even if STRING was an absolute pathname to begin with. + */ +static char* +make_absolute( char const *string, char const *dot_path ) +{ + char *result; + int result_len; + + if (!dot_path || *string == '/') { + result = strdup( string ); + } else { + if (dot_path && dot_path[0]) { + result = malloc( 2 + strlen( dot_path ) + strlen( string ) ); + strcpy( result, dot_path ); + result_len = strlen( result ); + if (result[result_len - 1] != '/') { + result[result_len++] = '/'; + result[result_len] = '\0'; + } + } else { + result = malloc( 3 + strlen( string ) ); + result[0] = '.'; result[1] = '/'; result[2] = '\0'; + result_len = 2; + } + + strcpy( result + result_len, string ); + } + + return result; +} + +/* + * Canonicalize PATH, and return a new path. The new path differs from + * PATH in that: + * + * Multiple `/'s are collapsed to a single `/'. + * Leading `./'s are removed. + * Trailing `/.'s are removed. + * Trailing `/'s are removed. + * Non-leading `../'s and trailing `..'s are handled by removing + * portions of the path. + */ +static char* +canonicalize_pathname( char *path ) +{ + int i, start; + char stub_char, *result; + + /* The result cannot be larger than the input PATH. */ + result = strdup( path ); + + stub_char = (*path == '/') ? '/' : '.'; + + /* Walk along RESULT looking for things to compact. */ + i = 0; + while (result[i]) { + while (result[i] != '\0' && result[i] != '/') + i++; + + start = i++; + + /* If we didn't find any slashes, then there is nothing left to + * do. + */ + if (!result[start]) + break; + + /* Handle multiple `/'s in a row. */ + while (result[i] == '/') + i++; + +#if !defined (apollo) + if ((start + 1) != i) +#else + if ((start + 1) != i && (start != 0 || i != 2)) +#endif /* apollo */ + { + strcpy( result + start + 1, result + i ); + i = start + 1; + } + + /* Handle backquoted `/'. */ + if (start > 0 && result[start - 1] == '\\') + continue; + + /* Check for trailing `/', and `.' by itself. */ + if ((start && !result[i]) + || (result[i] == '.' && !result[i+1])) { + result[--i] = '\0'; + break; + } + + /* Check for `../', `./' or trailing `.' by itself. */ + if (result[i] == '.') { + /* Handle `./'. */ + if (result[i + 1] == '/') { + strcpy( result + i, result + i + 1 ); + i = (start < 0) ? 0 : start; + continue; + } + + /* Handle `../' or trailing `..' by itself. */ + if (result[i + 1] == '.' && + (result[i + 2] == '/' || !result[i + 2])) { + while (--start > -1 && result[start] != '/') + ; + strcpy( result + start + 1, result + i + 2 ); + i = (start < 0) ? 0 : start; + continue; + } + } + } + + if (!*result) { + *result = stub_char; + result[1] = '\0'; + } + + return result; +} + +/* + * Given a string containing units of information separated by colons, + * return the next one pointed to by (P_INDEX), or NULL if there are no + * more. Advance (P_INDEX) to the character after the colon. + */ +static char* +extract_colon_unit( char* pzDir, char const *string, int *p_index ) +{ + char* pzDest = pzDir; + int ix = *p_index; + + if (string == NULL) + return NULL; + + if ((unsigned)ix >= strlen( string )) + return NULL; + + { + char const* pzSrc = string + ix; + + while (*pzSrc == ':') pzSrc++; + + for (;;) { + char ch = (*(pzDest++) = *(pzSrc++)); + switch (ch) { + case ':': + pzDest[-1] = NUL; + case NUL: + goto copy_done; + } + + if ((pzDest - pzDir) >= AG_PATH_MAX) + break; + } copy_done:; + + ix = pzSrc - string; + } + + if (*pzDir == NUL) + return NULL; + + *p_index = ix; + return pzDir; +} +#endif /* __windows__ / __CYGWIN__ */ +#endif /* HAVE_PATHFIND */ + +/* + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of compat/pathfind.c */ diff --git a/libopts/compat/snprintf.c b/libopts/compat/snprintf.c new file mode 100644 index 0000000..fc91d63 --- /dev/null +++ b/libopts/compat/snprintf.c @@ -0,0 +1,60 @@ + +#ifndef HAVE_VPRINTF +#include "choke-me: no vprintf and no snprintf" +#endif + +#if defined(HAVE_STDARG_H) +# include +# ifndef VA_START +# define VA_START(a, f) va_start(a, f) +# define VA_END(a) va_end(a) +# endif /* VA_START */ +# define SNV_USING_STDARG_H + +#elif defined(HAVE_VARARGS_H) +# include +# ifndef VA_START +# define VA_START(a, f) va_start(a) +# define VA_END(a) va_end(a) +# endif /* VA_START */ +# undef SNV_USING_STDARG_H + +#else +# include "must-have-stdarg-or-varargs" +#endif + +static int +snprintf(char *str, size_t n, char const *fmt, ...) +{ + va_list ap; + int rval; + +#ifdef VSPRINTF_CHARSTAR + char *rp; + VA_START(ap, fmt); + rp = vsprintf(str, fmt, ap); + VA_END(ap); + rval = strlen(rp); + +#else + VA_START(ap, fmt); + rval = vsprintf(str, fmt, ap); + VA_END(ap); +#endif + + if (rval > n) { + fprintf(stderr, "snprintf buffer overrun %d > %d\n", rval, (int)n); + abort(); + } + return rval; +} + +static int +vsnprintf( char *str, size_t n, char const *fmt, va_list ap ) +{ +#ifdef VSPRINTF_CHARSTAR + return (strlen(vsprintf(str, fmt, ap))); +#else + return (vsprintf(str, fmt, ap)); +#endif +} diff --git a/libopts/compat/strchr.c b/libopts/compat/strchr.c new file mode 100644 index 0000000..413f999 --- /dev/null +++ b/libopts/compat/strchr.c @@ -0,0 +1,60 @@ +/* + SYNOPSIS + #include + + char *strchr(char const *s, int c); + + char *strrchr(char const *s, int c); + + DESCRIPTION + The strchr() function returns a pointer to the first occurrence of the + character c in the string s. + + The strrchr() function returns a pointer to the last occurrence of the + character c in the string s. + + Here "character" means "byte" - these functions do not work with wide + or multi-byte characters. + + RETURN VALUE + The strchr() and strrchr() functions return a pointer to the matched + character or NULL if the character is not found. + + CONFORMING TO + SVID 3, POSIX, BSD 4.3, ISO 9899 +*/ + +char* +strchr( char const *s, int c) +{ + do { + if ((unsigned)*s == (unsigned)c) + return s; + + } while (*(++s) != NUL); + + return NULL; +} + +char* +strrchr( char const *s, int c) +{ + char const *e = s + strlen(s); + + for (;;) { + if (--e < s) + break; + + if ((unsigned)*e == (unsigned)c) + return e; + } + return NULL; +} + +/* + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of compat/strsignal.c */ diff --git a/libopts/compat/strdup.c b/libopts/compat/strdup.c new file mode 100644 index 0000000..e2933a8 --- /dev/null +++ b/libopts/compat/strdup.c @@ -0,0 +1,19 @@ +/* + * Platforms without strdup ?!?!?! + */ + +static char * +strdup( char const *s ) +{ + char *cp; + + if (s == NULL) + return NULL; + + cp = (char *) AGALOC((unsigned) (strlen(s)+1), "strdup"); + + if (cp != NULL) + (void) strcpy(cp, s); + + return cp; +} diff --git a/libopts/compat/windows-config.h b/libopts/compat/windows-config.h new file mode 100644 index 0000000..1594f28 --- /dev/null +++ b/libopts/compat/windows-config.h @@ -0,0 +1,147 @@ + +/* + * Time-stamp: "2009-07-22 18:53:59 bkorb" + * by: bkorb + * Last Committed: $Date: 2009/07/23 02:05:55 $ + * + * This file is part of AutoGen. + * + * AutoGen copyright (c) 1992-2009 by Bruce Korb - all rights reserved + * + * AutoGen is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * AutoGen is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the 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 . + */ +#ifndef WINDOWS_CONFIG_HACKERY +#define WINDOWS_CONFIG_HACKERY 1 + +/* + * The definitions below have been stolen from NTP's config.h for Windows. + * However, they may be kept here in order to keep libopts independent from + * the NTP project. + */ +#ifndef __windows__ +# define __windows__ 4 +#endif + +/* + * Miscellaneous functions that Microsoft maps + * to other names + * + * #define inline __inline + * #define vsnprintf _vsnprintf + */ +#define snprintf _snprintf +/* + * #define stricmp _stricmp + * #define strcasecmp _stricmp + * #define isascii __isascii + * #define finite _finite + * #define random rand + * #define srandom srand + */ + +#define SIZEOF_INT 4 +#define SIZEOF_CHARP 4 +#define SIZEOF_LONG 4 +#define SIZEOF_SHORT 2 + +typedef unsigned long uintptr_t; + +/* + * # define HAVE_NET_IF_H + * # define QSORT_USES_VOID_P + * # define HAVE_SETVBUF + * # define HAVE_VSPRINTF + * # define HAVE_SNPRINTF + * # define HAVE_VSNPRINTF + * # define HAVE_PROTOTYPES /* from ntpq.mak * / + * # define HAVE_MEMMOVE + * # define HAVE_TERMIOS_H + * # define HAVE_ERRNO_H + * # define HAVE_STDARG_H + * # define HAVE_NO_NICE + * # define HAVE_MKTIME + * # define TIME_WITH_SYS_TIME + * # define HAVE_IO_COMPLETION_PORT + * # define ISC_PLATFORM_NEEDNTOP + * # define ISC_PLATFORM_NEEDPTON + * # define NEED_S_CHAR_TYPEDEF + * # define USE_PROTOTYPES /* for ntp_types.h * / + * + * #define ULONG_CONST(a) a ## UL + */ + +#define HAVE_LIMITS_H 1 +#define HAVE_STRDUP 1 +#define HAVE_STRCHR 1 +#define HAVE_FCNTL_H 1 + +/* + * VS.NET's version of wspiapi.h has a bug in it + * where it assigns a value to a variable inside + * an if statement. It should be comparing them. + * We prevent inclusion since we are not using this + * code so we don't have to see the warning messages + */ +#ifndef _WSPIAPI_H_ +#define _WSPIAPI_H_ +#endif + +/* Prevent inclusion of winsock.h in windows.h */ +#ifndef _WINSOCKAPI_ +#define _WINSOCKAPI_ +#endif + +#ifndef __RPCASYNC_H__ +#define __RPCASYNC_H__ +#endif + +/* Include Windows headers */ +#include +#include +#include + +/* + * Compatibility declarations for Windows, assuming SYS_WINNT + * has been defined. + */ +#define strdup _strdup +#define stat _stat /* struct stat from */ +#define unlink _unlink +#define fchmod( _x, _y ); +#define ssize_t SSIZE_T + +#include +#define open _open +#define close _close +#define read _read +#define write _write +#define lseek _lseek +#define pipe _pipe +#define dup2 _dup2 + +#define O_RDWR _O_RDWR +#define O_RDONLY _O_RDONLY +#define O_EXCL _O_EXCL + +#ifndef S_ISREG +# define S_IFREG _S_IFREG +# define S_ISREG(mode) (((mode) & S_IFREG) == S_IFREG) +#endif + +#ifndef S_ISDIR +# define S_IFDIR _S_IFDIR +# define S_ISDIR(mode) (((mode) & S_IFDIR) == S_IFDIR) +#endif + +#endif /* WINDOWS_CONFIG_HACKERY */ diff --git a/libopts/configfile.c b/libopts/configfile.c new file mode 100644 index 0000000..f1650b4 --- /dev/null +++ b/libopts/configfile.c @@ -0,0 +1,1251 @@ +/* + * $Id: configfile.c,v 4.47 2009/08/01 17:43:05 bkorb Exp $ + * Time-stamp: "2009-01-18 10:21:58 bkorb" + * + * configuration/rc/ini file handling. + * + * This file is part of AutoOpts, a companion to AutoGen. + * AutoOpts is free software. + * AutoOpts is copyright (c) 1992-2009 by Bruce Korb - all rights reserved + * + * AutoOpts is available under any one of two licenses. The license + * in use must be one of these two and the choice is under the control + * of the user of the license. + * + * The GNU Lesser General Public License, version 3 or later + * See the files "COPYING.lgplv3" and "COPYING.gplv3" + * + * The Modified Berkeley Software Distribution License + * See the file "COPYING.mbsd" + * + * These files have the following md5sums: + * + * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 + * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 + * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + */ + +/* = = = START-STATIC-FORWARD = = = */ +/* static forward declarations maintained by mk-fwd */ +static void +filePreset( + tOptions* pOpts, + char const* pzFileName, + int direction ); + +static char* +handleComment( char* pzText ); + +static char* +handleConfig( + tOptions* pOpts, + tOptState* pOS, + char* pzText, + int direction ); + +static char* +handleDirective( + tOptions* pOpts, + char* pzText ); + +static char* +handleProgramSection( + tOptions* pOpts, + char* pzText ); + +static char* +handleStructure( + tOptions* pOpts, + tOptState* pOS, + char* pzText, + int direction ); + +static char* +parseKeyWordType( + tOptions* pOpts, + char* pzText, + tOptionValue* pType ); + +static char* +parseSetMemType( + tOptions* pOpts, + char* pzText, + tOptionValue* pType ); + +static char* +parseValueType( + char* pzText, + tOptionValue* pType ); + +static char* +skipUnknown( char* pzText ); +/* = = = END-STATIC-FORWARD = = = */ + + +/*=export_func configFileLoad + * + * what: parse a configuration file + * arg: + char const* + pzFile + the file to load + + * + * ret_type: const tOptionValue* + * ret_desc: An allocated, compound value structure + * + * doc: + * This routine will load a named configuration file and parse the + * text as a hierarchically valued option. The option descriptor + * created from an option definition file is not used via this interface. + * The returned value is "named" with the input file name and is of + * type "@code{OPARG_TYPE_HIERARCHY}". It may be used in calls to + * @code{optionGetValue()}, @code{optionNextValue()} and + * @code{optionUnloadNested()}. + * + * err: + * If the file cannot be loaded or processed, @code{NULL} is returned and + * @var{errno} is set. It may be set by a call to either @code{open(2)} + * @code{mmap(2)} or other file system calls, or it may be: + * @itemize @bullet + * @item + * @code{ENOENT} - the file was empty. + * @item + * @code{EINVAL} - the file contents are invalid -- not properly formed. + * @item + * @code{ENOMEM} - not enough memory to allocate the needed structures. + * @end itemize +=*/ +const tOptionValue* +configFileLoad( char const* pzFile ) +{ + tmap_info_t cfgfile; + tOptionValue* pRes = NULL; + tOptionLoadMode save_mode = option_load_mode; + + char* pzText = + text_mmap( pzFile, PROT_READ, MAP_PRIVATE, &cfgfile ); + + if (TEXT_MMAP_FAILED_ADDR(pzText)) + return NULL; /* errno is set */ + + option_load_mode = OPTION_LOAD_COOKED; + pRes = optionLoadNested(pzText, pzFile, strlen(pzFile)); + + if (pRes == NULL) { + int err = errno; + text_munmap( &cfgfile ); + errno = err; + } else + text_munmap( &cfgfile ); + + option_load_mode = save_mode; + return pRes; +} + + +/*=export_func optionFindValue + * + * what: find a hierarcicaly valued option instance + * arg: + const tOptDesc* + pOptDesc + an option with a nested arg type + + * arg: + char const* + name + name of value to find + + * arg: + char const* + value + the matching value + + * + * ret_type: const tOptionValue* + * ret_desc: a compound value structure + * + * doc: + * This routine will find an entry in a nested value option or configurable. + * It will search through the list and return a matching entry. + * + * err: + * The returned result is NULL and errno is set: + * @itemize @bullet + * @item + * @code{EINVAL} - the @code{pOptValue} does not point to a valid + * hierarchical option value. + * @item + * @code{ENOENT} - no entry matched the given name. + * @end itemize +=*/ +const tOptionValue* +optionFindValue( const tOptDesc* pOptDesc, + char const* pzName, char const* pzVal ) +{ + const tOptionValue* pRes = NULL; + + if ( (pOptDesc == NULL) + || (OPTST_GET_ARGTYPE(pOptDesc->fOptState) != OPARG_TYPE_HIERARCHY)) { + errno = EINVAL; + } + + else if (pOptDesc->optCookie == NULL) { + errno = ENOENT; + } + + else do { + tArgList* pAL = pOptDesc->optCookie; + int ct = pAL->useCt; + void** ppOV = (void**)(pAL->apzArgs); + + if (ct == 0) { + errno = ENOENT; + break; + } + + if (pzName == NULL) { + pRes = (tOptionValue*)*ppOV; + break; + } + + while (--ct >= 0) { + const tOptionValue* pOV = *(ppOV++); + const tOptionValue* pRV = optionGetValue( pOV, pzName ); + + if (pRV == NULL) + continue; + + if (pzVal == NULL) { + pRes = pOV; + break; + } + } + if (pRes == NULL) + errno = ENOENT; + } while (0); + + return pRes; +} + + +/*=export_func optionFindNextValue + * + * what: find a hierarcicaly valued option instance + * arg: + const tOptDesc* + pOptDesc + an option with a nested arg type + + * arg: + const tOptionValue* + pPrevVal + the last entry + + * arg: + char const* + name + name of value to find + + * arg: + char const* + value + the matching value + + * + * ret_type: const tOptionValue* + * ret_desc: a compound value structure + * + * doc: + * 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 + * that matches the criteria. + * + * err: + * The returned result is NULL and errno is set: + * @itemize @bullet + * @item + * @code{EINVAL} - the @code{pOptValue} does not point to a valid + * hierarchical option value. + * @item + * @code{ENOENT} - no entry matched the given name. + * @end itemize +=*/ +const tOptionValue* +optionFindNextValue( const tOptDesc* pOptDesc, const tOptionValue* pPrevVal, + char const* pzName, char const* pzVal ) +{ + int foundOldVal = 0; + tOptionValue* pRes = NULL; + + if ( (pOptDesc == NULL) + || (OPTST_GET_ARGTYPE(pOptDesc->fOptState) != OPARG_TYPE_HIERARCHY)) { + errno = EINVAL; + } + + else if (pOptDesc->optCookie == NULL) { + errno = ENOENT; + } + + else do { + tArgList* pAL = pOptDesc->optCookie; + int ct = pAL->useCt; + void** ppOV = (void**)pAL->apzArgs; + + if (ct == 0) { + errno = ENOENT; + break; + } + + while (--ct >= 0) { + tOptionValue* pOV = *(ppOV++); + if (foundOldVal) { + pRes = pOV; + break; + } + if (pOV == pPrevVal) + foundOldVal = 1; + } + if (pRes == NULL) + errno = ENOENT; + } while (0); + + return pRes; +} + + +/*=export_func optionGetValue + * + * what: get a specific value from a hierarcical list + * arg: + const tOptionValue* + pOptValue + a hierarchcal value + + * arg: + char const* + valueName + name of value to get + + * + * ret_type: const tOptionValue* + * ret_desc: a compound value structure + * + * doc: + * This routine will find an entry in a nested value option or configurable. + * If "valueName" is NULL, then the first entry is returned. Otherwise, + * the first entry with a name that exactly matches the argument will be + * returned. + * + * err: + * The returned result is NULL and errno is set: + * @itemize @bullet + * @item + * @code{EINVAL} - the @code{pOptValue} does not point to a valid + * hierarchical option value. + * @item + * @code{ENOENT} - no entry matched the given name. + * @end itemize +=*/ +const tOptionValue* +optionGetValue( const tOptionValue* pOld, char const* pzValName ) +{ + tArgList* pAL; + tOptionValue* pRes = NULL; + + if ((pOld == NULL) || (pOld->valType != OPARG_TYPE_HIERARCHY)) { + errno = EINVAL; + return NULL; + } + pAL = pOld->v.nestVal; + + if (pAL->useCt > 0) { + int ct = pAL->useCt; + void** papOV = (void**)(pAL->apzArgs); + + if (pzValName == NULL) { + pRes = (tOptionValue*)*papOV; + } + + else do { + tOptionValue* pOV = *(papOV++); + if (strcmp( pOV->pzName, pzValName ) == 0) { + pRes = pOV; + break; + } + } while (--ct > 0); + } + if (pRes == NULL) + errno = ENOENT; + return pRes; +} + + +/*=export_func optionNextValue + * + * what: get the next value from a hierarchical list + * arg: + const tOptionValue* + pOptValue + a hierarchcal list value + + * arg: + const tOptionValue* + pOldValue + a value from this list + + * + * ret_type: const tOptionValue* + * ret_desc: a compound value structure + * + * doc: + * This routine will return the next entry after the entry passed in. At the + * end of the list, NULL will be returned. If the entry is not found on the + * list, NULL will be returned and "@var{errno}" will be set to EINVAL. + * The "@var{pOldValue}" must have been gotten from a prior call to this + * routine or to "@code{opitonGetValue()}". + * + * err: + * The returned result is NULL and errno is set: + * @itemize @bullet + * @item + * @code{EINVAL} - the @code{pOptValue} does not point to a valid + * hierarchical option value or @code{pOldValue} does not point to a + * member of that option value. + * @item + * @code{ENOENT} - the supplied @code{pOldValue} pointed to the last entry. + * @end itemize +=*/ +tOptionValue const * +optionNextValue(tOptionValue const * pOVList,tOptionValue const * pOldOV ) +{ + tArgList* pAL; + tOptionValue* pRes = NULL; + int err = EINVAL; + + if ((pOVList == NULL) || (pOVList->valType != OPARG_TYPE_HIERARCHY)) { + errno = EINVAL; + return NULL; + } + pAL = pOVList->v.nestVal; + { + int ct = pAL->useCt; + void** papNV = (void**)(pAL->apzArgs); + + while (ct-- > 0) { + tOptionValue* pNV = *(papNV++); + if (pNV == pOldOV) { + if (ct == 0) { + err = ENOENT; + + } else { + err = 0; + pRes = (tOptionValue*)*papNV; + } + break; + } + } + } + if (err != 0) + errno = err; + return pRes; +} + + +/* filePreset + * + * Load a file containing presetting information (a configuration file). + */ +static void +filePreset( + tOptions* pOpts, + char const* pzFileName, + int direction ) +{ + tmap_info_t cfgfile; + tOptState optst = OPTSTATE_INITIALIZER(PRESET); + char* pzFileText = + text_mmap( pzFileName, PROT_READ|PROT_WRITE, MAP_PRIVATE, &cfgfile ); + + if (TEXT_MMAP_FAILED_ADDR(pzFileText)) + return; + + if (direction == DIRECTION_CALLED) { + optst.flags = OPTST_DEFINED; + direction = DIRECTION_PROCESS; + } + + /* + * IF this is called via "optionProcess", then we are presetting. + * This is the default and the PRESETTING bit will be set. + * If this is called via "optionFileLoad", then the bit is not set + * and we consider stuff set herein to be "set" by the client program. + */ + if ((pOpts->fOptSet & OPTPROC_PRESETTING) == 0) + optst.flags = OPTST_SET; + + do { + while (IS_WHITESPACE_CHAR(*pzFileText)) pzFileText++; + + if (IS_VAR_FIRST_CHAR(*pzFileText)) { + pzFileText = handleConfig(pOpts, &optst, pzFileText, direction); + + } else switch (*pzFileText) { + case '<': + if (IS_VAR_FIRST_CHAR(pzFileText[1])) + pzFileText = + handleStructure(pOpts, &optst, pzFileText, direction); + + else switch (pzFileText[1]) { + case '?': + pzFileText = handleDirective( pOpts, pzFileText ); + break; + + case '!': + pzFileText = handleComment( pzFileText ); + break; + + case '/': + pzFileText = strchr( pzFileText+2, '>' ); + if (pzFileText++ != NULL) + break; + + default: + goto all_done; + } + break; + + case '[': + pzFileText = handleProgramSection( pOpts, pzFileText ); + break; + + case '#': + pzFileText = strchr( pzFileText+1, '\n' ); + break; + + default: + goto all_done; /* invalid format */ + } + } while (pzFileText != NULL); + + all_done: + text_munmap( &cfgfile ); +} + + +/* handleComment + * + * "pzText" points to a "". + */ +static char* +handleComment( char* pzText ) +{ + char* pz = strstr( pzText, "-->" ); + if (pz != NULL) + pz += 3; + return pz; +} + + +/* handleConfig + * + * "pzText" points to the start of some value name. + * The end of the entry is the end of the line that is not preceded by + * a backslash escape character. The string value is always processed + * in "cooked" mode. + */ +static char* +handleConfig( + tOptions* pOpts, + tOptState* pOS, + char* pzText, + int direction ) +{ + char* pzName = pzText++; + char* pzEnd = strchr( pzText, '\n' ); + + if (pzEnd == NULL) + return pzText + strlen(pzText); + + while (IS_VALUE_NAME_CHAR(*pzText)) pzText++; + while (IS_WHITESPACE_CHAR(*pzText)) pzText++; + if (pzText > pzEnd) { + name_only: + *pzEnd++ = NUL; + loadOptionLine( pOpts, pOS, pzName, direction, OPTION_LOAD_UNCOOKED ); + return pzEnd; + } + + /* + * Either the first character after the name is a ':' or '=', + * or else we must have skipped over white space. Anything else + * is an invalid format and we give up parsing the text. + */ + if ((*pzText == '=') || (*pzText == ':')) { + while (IS_WHITESPACE_CHAR(*++pzText)) ; + if (pzText > pzEnd) + goto name_only; + } else if (! IS_WHITESPACE_CHAR(pzText[-1])) + return NULL; + + /* + * IF the value is continued, remove the backslash escape and push "pzEnd" + * on to a newline *not* preceded by a backslash. + */ + if (pzEnd[-1] == '\\') { + char* pcD = pzEnd-1; + char* pcS = pzEnd; + + for (;;) { + char ch = *(pcS++); + switch (ch) { + case NUL: + pcS = NULL; + + case '\n': + *pcD = NUL; + pzEnd = pcS; + goto copy_done; + + case '\\': + if (*pcS == '\n') { + ch = *(pcS++); + } + /* FALLTHROUGH */ + default: + *(pcD++) = ch; + } + } copy_done:; + + } else { + /* + * The newline was not preceded by a backslash. NUL it out + */ + *(pzEnd++) = NUL; + } + + /* + * "pzName" points to what looks like text for one option/configurable. + * It is NUL terminated. Process it. + */ + loadOptionLine( pOpts, pOS, pzName, direction, OPTION_LOAD_UNCOOKED ); + + return pzEnd; +} + + +/* handleDirective + * + * "pzText" points to a "' ); + if (pzText != NULL) + pzText++; + return pzText; + } + + name_len = strlen( pOpts->pzProgName ); + strcpy( ztitle+2, zProg ); + title_len += 2; + + do { + pzText += title_len; + + if (IS_WHITESPACE_CHAR(*pzText)) { + while (IS_WHITESPACE_CHAR(*++pzText)) ; + if ( (strneqvcmp( pzText, pOpts->pzProgName, (int)name_len) == 0) + && (pzText[name_len] == '>')) { + pzText += name_len + 1; + break; + } + } + + pzText = strstr( pzText, ztitle ); + } while (pzText != NULL); + + return pzText; +} + + +/* handleProgramSection + * + * "pzText" points to a '[' character. + * The "traditional" [PROG_NAME] segmentation of the config file. + * Do not ever mix with the "" variation. + */ +static char* +handleProgramSection( + tOptions* pOpts, + char* pzText ) +{ + size_t len = strlen( pOpts->pzPROGNAME ); + if ( (strncmp( pzText+1, pOpts->pzPROGNAME, len ) == 0) + && (pzText[len+1] == ']')) + return strchr( pzText + len + 2, '\n' ); + + if (len > 16) + return NULL; + + { + char z[24]; + sprintf( z, "[%s]", pOpts->pzPROGNAME ); + pzText = strstr( pzText, z ); + } + + if (pzText != NULL) + pzText = strchr( pzText, '\n' ); + return pzText; +} + + +/* handleStructure + * + * "pzText" points to a '<' character, followed by an alpha. + * The end of the entry is either the "/>" following the name, or else a + * "" string. + */ +static char* +handleStructure( + tOptions* pOpts, + tOptState* pOS, + char* pzText, + int direction ) +{ + tOptionLoadMode mode = option_load_mode; + tOptionValue valu; + + char* pzName = ++pzText; + char* pzData; + char* pcNulPoint; + + while (IS_VALUE_NAME_CHAR(*pzText)) pzText++; + pcNulPoint = pzText; + valu.valType = OPARG_TYPE_STRING; + + switch (*pzText) { + case ' ': + case '\t': + pzText = parseAttributes( pOpts, pzText, &mode, &valu ); + if (*pzText == '>') + break; + if (*pzText != '/') + return NULL; + /* FALLTHROUGH */ + + case '/': + if (pzText[1] != '>') + return NULL; + *pzText = NUL; + pzText += 2; + loadOptionLine( pOpts, pOS, pzName, direction, mode ); + return pzText; + + case '>': + break; + + default: + pzText = strchr( pzText, '>'); + if (pzText != NULL) + pzText++; + return pzText; + } + + /* + * If we are here, we have a value. "pzText" points to a closing angle + * bracket. Separate the name from the value for a moment. + */ + *pcNulPoint = NUL; + pzData = ++pzText; + + /* + * Find the end of the option text and NUL terminate it + */ + { + char z[64], *pz = z; + size_t len = strlen(pzName) + 4; + if (len > sizeof(z)) + pz = AGALOC(len, "scan name"); + + sprintf( pz, "", pzName ); + *pzText = ' '; + pzText = strstr( pzText, pz ); + if (pz != z) AGFREE(pz); + + if (pzText == NULL) + return pzText; + + *pzText = NUL; + + pzText += len-1; + } + + /* + * Rejoin the name and value for parsing by "loadOptionLine()". + * Erase any attributes parsed by "parseAttributes()". + */ + memset(pcNulPoint, ' ', pzData - pcNulPoint); + + /* + * If we are getting a "string" value, the process the XML-ish + * %XX hex characters. + */ + if (valu.valType == OPARG_TYPE_STRING) { + char * pzSrc = pzData; + char * pzDst = pzData; + char bf[4]; + bf[2] = NUL; + + for (;;) { + int ch = ((int)*(pzSrc++)) & 0xFF; + switch (ch) { + case NUL: goto string_fixup_done; + + case '%': + bf[0] = *(pzSrc++); + bf[1] = *(pzSrc++); + if ((bf[0] == NUL) || (bf[1] == NUL)) + goto string_fixup_done; + ch = strtoul(bf, NULL, 16); + /* FALLTHROUGH */ + + default: + *(pzDst++) = ch; + } + } string_fixup_done:; + *pzDst = NUL; + } + + /* + * "pzName" points to what looks like text for one option/configurable. + * It is NUL terminated. Process it. + */ + loadOptionLine( pOpts, pOS, pzName, direction, mode ); + + return pzText; +} + + +/* internalFileLoad + * + * Load a configuration file. This may be invoked either from + * scanning the "homerc" list, or from a specific file request. + * (see "optionFileLoad()", the implementation for --load-opts) + */ +LOCAL void +internalFileLoad( tOptions* pOpts ) +{ + uint32_t svfl; + int idx; + int inc; + char zFileName[ AG_PATH_MAX+1 ]; + + if (pOpts->papzHomeList == NULL) + return; + + svfl = pOpts->fOptSet; + inc = DIRECTION_PRESET; + + /* + * Never stop on errors in config files. + */ + pOpts->fOptSet &= ~OPTPROC_ERRSTOP; + + /* + * Find the last RC entry (highest priority entry) + */ + for (idx = 0; pOpts->papzHomeList[ idx+1 ] != NULL; ++idx) ; + + /* + * For every path in the home list, ... *TWICE* We start at the last + * (highest priority) entry, work our way down to the lowest priority, + * handling the immediate options. + * Then we go back up, doing the normal options. + */ + for (;;) { + struct stat StatBuf; + cch_t* pzPath; + + /* + * IF we've reached the bottom end, change direction + */ + if (idx < 0) { + inc = DIRECTION_PROCESS; + idx = 0; + } + + pzPath = pOpts->papzHomeList[ idx ]; + + /* + * IF we've reached the top end, bail out + */ + if (pzPath == NULL) + break; + + idx += inc; + + if (! optionMakePath( zFileName, (int)sizeof(zFileName), + pzPath, pOpts->pzProgPath )) + continue; + + /* + * IF the file name we constructed is a directory, + * THEN append the Resource Configuration file name + * ELSE we must have the complete file name + */ + if (stat( zFileName, &StatBuf ) != 0) + continue; /* bogus name - skip the home list entry */ + + if (S_ISDIR( StatBuf.st_mode )) { + size_t len = strlen( zFileName ); + char* pz; + + if (len + 1 + strlen( pOpts->pzRcName ) >= sizeof( zFileName )) + continue; + + pz = zFileName + len; + if (pz[-1] != DIRCH) + *(pz++) = DIRCH; + strcpy( pz, pOpts->pzRcName ); + } + + filePreset( pOpts, zFileName, inc ); + + /* + * IF we are now to skip config files AND we are presetting, + * THEN change direction. We must go the other way. + */ + { + tOptDesc * pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts+1; + if (DISABLED_OPT(pOD) && PRESETTING(inc)) { + idx -= inc; /* go back and reprocess current file */ + inc = DIRECTION_PROCESS; + } + } + } /* twice for every path in the home list, ... */ + + pOpts->fOptSet = svfl; +} + + +/*=export_func optionFileLoad + * + * what: Load the locatable config files, in order + * + * arg: + tOptions* + pOpts + program options descriptor + + * arg: + char const* + pzProg + program name + + * + * ret_type: int + * ret_desc: 0 -> SUCCESS, -1 -> FAILURE + * + * doc: + * + * This function looks in all the specified directories for a configuration + * file ("rc" file or "ini" file) and processes any found twice. The first + * time through, they are processed in reverse order (last file first). At + * that time, only "immediate action" configurables are processed. For + * example, if the last named file specifies not processing any more + * configuration files, then no more configuration files will be processed. + * Such an option in the @strong{first} named directory will have no effect. + * + * Once the immediate action configurables have been handled, then the + * directories are handled in normal, forward order. In that way, later + * config files can override the settings of earlier config files. + * + * See the AutoOpts documentation for a thorough discussion of the + * config file format. + * + * Configuration files not found or not decipherable are simply ignored. + * + * err: Returns the value, "-1" if the program options descriptor + * is out of date or indecipherable. Otherwise, the value "0" will + * always be returned. +=*/ +int +optionFileLoad( tOptions* pOpts, char const* pzProgram ) +{ + if (! SUCCESSFUL( validateOptionsStruct( pOpts, pzProgram ))) + return -1; + + pOpts->pzProgName = pzProgram; + internalFileLoad( pOpts ); + return 0; +} + + +/*=export_func optionLoadOpt + * private: + * + * what: Load an option rc/ini file + * arg: + tOptions* + pOpts + program options descriptor + + * arg: + tOptDesc* + pOptDesc + the descriptor for this arg + + * + * doc: + * Processes the options found in the file named with + * pOptDesc->optArg.argString. +=*/ +void +optionLoadOpt( tOptions* pOpts, tOptDesc* pOptDesc ) +{ + struct stat sb; + + /* + * IF the option is not being disabled, THEN load the file. There must + * be a file. (If it is being disabled, then the disablement processing + * already took place. It must be done to suppress preloading of ini/rc + * files.) + */ + if ( DISABLED_OPT(pOptDesc) + || ((pOptDesc->fOptState & OPTST_RESET) != 0)) + return; + + if (stat( pOptDesc->optArg.argString, &sb ) != 0) { + if ((pOpts->fOptSet & OPTPROC_ERRSTOP) == 0) + return; + + fprintf( stderr, zFSErrOptLoad, errno, strerror( errno ), + pOptDesc->optArg.argString ); + exit(EX_NOINPUT); + /* NOT REACHED */ + } + + if (! S_ISREG( sb.st_mode )) { + if ((pOpts->fOptSet & OPTPROC_ERRSTOP) == 0) + return; + + fprintf( stderr, zNotFile, pOptDesc->optArg.argString ); + exit(EX_NOINPUT); + /* NOT REACHED */ + } + + filePreset(pOpts, pOptDesc->optArg.argString, DIRECTION_CALLED); +} + + +/* parseAttributes + * + * Parse the various attributes of an XML-styled config file entry + */ +LOCAL char* +parseAttributes( + tOptions* pOpts, + char* pzText, + tOptionLoadMode* pMode, + tOptionValue* pType ) +{ + size_t len; + + do { + if (! IS_WHITESPACE_CHAR(*pzText)) + switch (*pzText) { + case '/': pType->valType = OPARG_TYPE_NONE; + case '>': return pzText; + + default: + case NUL: return NULL; + } + + while (IS_WHITESPACE_CHAR(*++pzText)) ; + len = 0; + while (IS_LOWER_CASE_CHAR(pzText[len])) len++; + + switch (find_xat_attribute_id(pzText, len)) { + case XAT_KWD_TYPE: + pzText = parseValueType( pzText+len, pType ); + break; + + case XAT_KWD_WORDS: + pzText = parseKeyWordType( pOpts, pzText+len, pType ); + break; + + case XAT_KWD_MEMBERS: + pzText = parseSetMemType( pOpts, pzText+len, pType ); + break; + + case XAT_KWD_COOKED: + pzText += len; + if (! IS_END_XML_TOKEN_CHAR(*pzText)) + goto invalid_kwd; + + *pMode = OPTION_LOAD_COOKED; + break; + + case XAT_KWD_UNCOOKED: + pzText += len; + if (! IS_END_XML_TOKEN_CHAR(*pzText)) + goto invalid_kwd; + + *pMode = OPTION_LOAD_UNCOOKED; + break; + + case XAT_KWD_KEEP: + pzText += len; + if (! IS_END_XML_TOKEN_CHAR(*pzText)) + goto invalid_kwd; + + *pMode = OPTION_LOAD_KEEP; + break; + + default: + case XAT_KWD_INVALID: + invalid_kwd: + pType->valType = OPARG_TYPE_NONE; + return skipUnknown( pzText ); + } + } while (pzText != NULL); + + return pzText; +} + + +/* parseKeyWordType + * + * "pzText" points to the character after "words=". + * What should follow is a name of a keyword (enumeration) list. + */ +static char* +parseKeyWordType( + tOptions* pOpts, + char* pzText, + tOptionValue* pType ) +{ + return skipUnknown( pzText ); +} + + +/* parseSetMemType + * + * "pzText" points to the character after "members=" + * What should follow is a name of a "set membership". + * A collection of bit flags. + */ +static char* +parseSetMemType( + tOptions* pOpts, + char* pzText, + tOptionValue* pType ) +{ + return skipUnknown( pzText ); +} + + +/* parseValueType + * + * "pzText" points to the character after "type=" + */ +static char* +parseValueType( + char* pzText, + tOptionValue* pType ) +{ + size_t len = 0; + + if (*(pzText++) != '=') + goto woops; + + while (IS_OPTION_NAME_CHAR(pzText[len])) len++; + pzText += len; + + if ((len == 0) || (! IS_END_XML_TOKEN_CHAR(*pzText))) { + woops: + pType->valType = OPARG_TYPE_NONE; + return skipUnknown( pzText ); + } + + switch (find_value_type_id(pzText - len, len)) { + default: + case VTP_KWD_INVALID: goto woops; + + case VTP_KWD_STRING: + pType->valType = OPARG_TYPE_STRING; + break; + + case VTP_KWD_INTEGER: + pType->valType = OPARG_TYPE_NUMERIC; + break; + + case VTP_KWD_BOOL: + case VTP_KWD_BOOLEAN: + pType->valType = OPARG_TYPE_BOOLEAN; + break; + + case VTP_KWD_KEYWORD: + pType->valType = OPARG_TYPE_ENUMERATION; + break; + + case VTP_KWD_SET: + case VTP_KWD_SET_MEMBERSHIP: + pType->valType = OPARG_TYPE_MEMBERSHIP; + break; + + case VTP_KWD_NESTED: + case VTP_KWD_HIERARCHY: + pType->valType = OPARG_TYPE_HIERARCHY; + } + + return pzText; +} + + +/* skipUnknown + * + * Skip over some unknown attribute + */ +static char* +skipUnknown( char* pzText ) +{ + for (;; pzText++) { + if (IS_END_XML_TOKEN_CHAR(*pzText)) return pzText; + if (*pzText == NUL) return NULL; + } +} + + +/* validateOptionsStruct + * + * Make sure the option descriptor is there and that we understand it. + * This should be called from any user entry point where one needs to + * worry about validity. (Some entry points are free to assume that + * the call is not the first to the library and, thus, that this has + * already been called.) + */ +LOCAL tSuccess +validateOptionsStruct( tOptions* pOpts, char const* pzProgram ) +{ + if (pOpts == NULL) { + fputs( zAO_Bad, stderr ); + exit( EX_CONFIG ); + } + + /* + * IF the client has enabled translation and the translation procedure + * is available, then go do it. + */ + if ( ((pOpts->fOptSet & OPTPROC_TRANSLATE) != 0) + && (pOpts->pTransProc != NULL) ) { + /* + * If option names are not to be translated at all, then do not do + * it for configuration parsing either. (That is the bit that really + * gets tested anyway.) + */ + if ((pOpts->fOptSet & OPTPROC_NO_XLAT_MASK) == OPTPROC_NXLAT_OPT) + pOpts->fOptSet |= OPTPROC_NXLAT_OPT_CFG; + (*pOpts->pTransProc)(); + pOpts->fOptSet &= ~OPTPROC_TRANSLATE; + } + + /* + * IF the struct version is not the current, and also + * either too large (?!) or too small, + * THEN emit error message and fail-exit + */ + if ( ( pOpts->structVersion != OPTIONS_STRUCT_VERSION ) + && ( (pOpts->structVersion > OPTIONS_STRUCT_VERSION ) + || (pOpts->structVersion < OPTIONS_MINIMUM_VERSION ) + ) ) { + + fprintf(stderr, zAO_Err, pzProgram, NUM_TO_VER(pOpts->structVersion)); + if (pOpts->structVersion > OPTIONS_STRUCT_VERSION ) + fputs( zAO_Big, stderr ); + else + fputs( zAO_Sml, stderr ); + + return FAILURE; + } + + /* + * If the program name hasn't been set, then set the name and the path + * and the set of equivalent characters. + */ + if (pOpts->pzProgName == NULL) { + char const* pz = strrchr( pzProgram, DIRCH ); + + if (pz == NULL) + pOpts->pzProgName = pzProgram; + else pOpts->pzProgName = pz+1; + + pOpts->pzProgPath = pzProgram; + + /* + * when comparing long names, these are equivalent + */ + strequate( zSepChars ); + } + + return SUCCESS; +} + + +/** + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of autoopts/configfile.c */ diff --git a/libopts/cook.c b/libopts/cook.c new file mode 100644 index 0000000..3da9a5f --- /dev/null +++ b/libopts/cook.c @@ -0,0 +1,293 @@ +/* + * $Id: cook.c,v 4.17 2009/08/01 17:43:06 bkorb Exp $ + * Time-stamp: "2007-11-16 22:49:11 bkorb" + * + * This file contains the routines that deal with processing quoted strings + * into an internal format. + * + * This file is part of AutoOpts, a companion to AutoGen. + * AutoOpts is free software. + * AutoOpts is copyright (c) 1992-2009 by Bruce Korb - all rights reserved + * + * AutoOpts is available under any one of two licenses. The license + * in use must be one of these two and the choice is under the control + * of the user of the license. + * + * The GNU Lesser General Public License, version 3 or later + * See the files "COPYING.lgplv3" and "COPYING.gplv3" + * + * The Modified Berkeley Software Distribution License + * See the file "COPYING.mbsd" + * + * These files have the following md5sums: + * + * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 + * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 + * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + */ + +/* = = = START-STATIC-FORWARD = = = */ +/* static forward declarations maintained by mk-fwd */ +/* = = = END-STATIC-FORWARD = = = */ + +/*=export_func ao_string_cook_escape_char + * private: + * + * what: escape-process a string fragment + * arg: + char const* + pzScan + points to character after the escape + + * arg: + char* + pRes + Where to put the result byte + + * arg: + unsigned int + nl_ch + replacement char if scanned char is \n + + * + * ret-type: unsigned int + * ret-desc: The number of bytes consumed processing the escaped character. + * + * doc: + * + * This function converts "t" into "\t" and all your other favorite + * escapes, including numeric ones: hex and ocatal, too. + * The returned result tells the caller how far to advance the + * scan pointer (passed in). The default is to just pass through the + * escaped character and advance the scan by one. + * + * Some applications need to keep an escaped newline, others need to + * suppress it. This is accomplished by supplying a '\n' replacement + * character that is different from \n, if need be. For example, use + * 0x7F and never emit a 0x7F. + * + * err: @code{NULL} is returned if the string is mal-formed. +=*/ +unsigned int +ao_string_cook_escape_char( char const* pzIn, char* pRes, u_int nl ) +{ + unsigned int res = 1; + + switch (*pRes = *pzIn++) { + case NUL: /* NUL - end of input string */ + return 0; + case '\r': + if (*pzIn != '\n') + return 1; + res++; + /* FALLTHROUGH */ + case '\n': /* NL - emit newline */ + *pRes = (char)nl; + return res; + + case 'a': *pRes = '\a'; break; + case 'b': *pRes = '\b'; break; + case 'f': *pRes = '\f'; break; + case 'n': *pRes = '\n'; break; + case 'r': *pRes = '\r'; break; + case 't': *pRes = '\t'; break; + case 'v': *pRes = '\v'; break; + + case 'x': + case 'X': /* HEX Escape */ + if (IS_HEX_DIGIT_CHAR(*pzIn)) { + char z[4], *pz = z; + + do *(pz++) = *(pzIn++); + while (IS_HEX_DIGIT_CHAR(*pzIn) && (pz < z + 2)); + *pz = NUL; + *pRes = (unsigned char)strtoul(z, NULL, 16); + res += pz - z; + } + break; + + case '0': case '1': case '2': case '3': + case '4': case '5': case '6': case '7': + { + /* + * IF the character copied was an octal digit, + * THEN set the output character to an octal value + */ + char z[4], *pz = z + 1; + unsigned long val; + z[0] = *pRes; + + while (IS_OCT_DIGIT_CHAR(*pzIn) && (pz < z + 3)) + *(pz++) = *(pzIn++); + *pz = NUL; + val = strtoul(z, NULL, 8); + if (val > 0xFF) + val = 0xFF; + *pRes = (unsigned char)val; + res = pz - z; + break; + } + + default: ; + } + + return res; +} + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * A quoted string has been found. + * Find the end of it and compress any escape sequences. + */ +/*=export_func ao_string_cook + * private: + * + * what: concatenate and escape-process strings + * arg: + char* + pzScan + The *MODIFIABLE* input buffer + + * arg: + int* + pLineCt + The (possibly NULL) pointer to a line count + + * + * ret-type: char* + * ret-desc: The address of the text following the processed strings. + * The return value is NULL if the strings are ill-formed. + * + * doc: + * + * A series of one or more quoted strings are concatenated together. + * If they are quoted with double quotes (@code{"}), then backslash + * escapes are processed per the C programming language. If they are + * single quote strings, then the backslashes are honored only when they + * precede another backslash or a single quote character. + * + * err: @code{NULL} is returned if the string(s) is/are mal-formed. +=*/ +char* +ao_string_cook( char* pzScan, int* pLineCt ) +{ + int l = 0; + char q = *pzScan; + + /* + * It is a quoted string. Process the escape sequence characters + * (in the set "abfnrtv") and make sure we find a closing quote. + */ + char* pzD = pzScan++; + char* pzS = pzScan; + + if (pLineCt == NULL) + pLineCt = &l; + + for (;;) { + /* + * IF the next character is the quote character, THEN we may end the + * string. We end it unless the next non-blank character *after* the + * string happens to also be a quote. If it is, then we will change + * our quote character to the new quote character and continue + * condensing text. + */ + while (*pzS == q) { + *pzD = NUL; /* This is probably the end of the line */ + pzS++; + + scan_for_quote: + while (IS_WHITESPACE_CHAR(*pzS)) + if (*(pzS++) == '\n') + (*pLineCt)++; + + /* + * IF the next character is a quote character, + * THEN we will concatenate the strings. + */ + switch (*pzS) { + case '"': + case '\'': + break; + + case '/': + /* + * Allow for a comment embedded in the concatenated string. + */ + switch (pzS[1]) { + default: return NULL; + case '/': + /* + * Skip to end of line + */ + pzS = strchr( pzS, '\n' ); + if (pzS == NULL) + return NULL; + (*pLineCt)++; + break; + + case '*': + { + char* p = strstr( pzS+2, "*/" ); + /* + * Skip to terminating star slash + */ + if (p == NULL) + return NULL; + while (pzS < p) { + if (*(pzS++) == '\n') + (*pLineCt)++; + } + + pzS = p + 2; + } + } + goto scan_for_quote; + + default: + /* + * The next non-whitespace character is not a quote. + * The series of quoted strings has come to an end. + */ + return pzS; + } + + q = *(pzS++); /* assign new quote character and advance scan */ + } + + /* + * We are inside a quoted string. Copy text. + */ + switch (*(pzD++) = *(pzS++)) { + case NUL: + return NULL; + + case '\n': + (*pLineCt)++; + break; + + case '\\': + /* + * IF we are escaping a new line, + * THEN drop both the escape and the newline from + * the result string. + */ + if (*pzS == '\n') { + pzS++; + pzD--; + (*pLineCt)++; + } + + /* + * ELSE IF the quote character is '"' or '`', + * THEN we do the full escape character processing + */ + else if (q != '\'') { + int ct = ao_string_cook_escape_char( pzS, pzD-1, (u_int)'\n' ); + if (ct == 0) + return NULL; + + pzS += ct; + } /* if (q != '\'') */ + + /* + * OTHERWISE, we only process "\\", "\'" and "\#" sequences. + * The latter only to easily hide preprocessing directives. + */ + else switch (*pzS) { + case '\\': + case '\'': + case '#': + pzD[-1] = *pzS++; + } + } /* switch (*(pzD++) = *(pzS++)) */ + } /* for (;;) */ +} +/* + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of autoopts/cook.c */ diff --git a/libopts/enumeration.c b/libopts/enumeration.c new file mode 100644 index 0000000..2759504 --- /dev/null +++ b/libopts/enumeration.c @@ -0,0 +1,512 @@ + +/* + * $Id: enumeration.c,v 4.26 2009/08/01 17:43:06 bkorb Exp $ + * Time-stamp: "2008-07-27 12:28:01 bkorb" + * + * Automated Options Paged Usage module. + * + * This routine will run run-on options through a pager so the + * user may examine, print or edit them at their leisure. + * + * This file is part of AutoOpts, a companion to AutoGen. + * AutoOpts is free software. + * AutoOpts is copyright (c) 1992-2009 by Bruce Korb - all rights reserved + * + * AutoOpts is available under any one of two licenses. The license + * in use must be one of these two and the choice is under the control + * of the user of the license. + * + * The GNU Lesser General Public License, version 3 or later + * See the files "COPYING.lgplv3" and "COPYING.gplv3" + * + * The Modified Berkeley Software Distribution License + * See the file "COPYING.mbsd" + * + * These files have the following md5sums: + * + * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 + * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 + * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + */ + +tSCC* pz_enum_err_fmt; + +/* = = = START-STATIC-FORWARD = = = */ +/* static forward declarations maintained by mk-fwd */ +static void +enumError( + tOptions* pOpts, + tOptDesc* pOD, + tCC* const * paz_names, + int name_ct ); + +static uintptr_t +findName( + tCC* pzName, + tOptions* pOpts, + tOptDesc* pOD, + tCC* const * paz_names, + unsigned int name_ct ); +/* = = = END-STATIC-FORWARD = = = */ + +static void +enumError( + tOptions* pOpts, + tOptDesc* pOD, + tCC* const * paz_names, + int name_ct ) +{ + size_t max_len = 0; + size_t ttl_len = 0; + int ct_down = name_ct; + int hidden = 0; + + /* + * A real "pOpts" pointer means someone messed up. Give a real error. + */ + if (pOpts > OPTPROC_EMIT_LIMIT) + fprintf(option_usage_fp, pz_enum_err_fmt, pOpts->pzProgName, + pOD->optArg.argString, pOD->pz_Name); + + fprintf(option_usage_fp, zValidKeys, pOD->pz_Name); + + /* + * If the first name starts with this funny character, then we have + * a first value with an unspellable name. You cannot specify it. + * So, we don't list it either. + */ + if (**paz_names == 0x7F) { + paz_names++; + hidden = 1; + ct_down = --name_ct; + } + + /* + * Figure out the maximum length of any name, plus the total length + * of all the names. + */ + { + tCC * const * paz = paz_names; + + do { + size_t len = strlen( *(paz++) ) + 1; + if (len > max_len) + max_len = len; + ttl_len += len; + } while (--ct_down > 0); + + ct_down = name_ct; + } + + /* + * IF any one entry is about 1/2 line or longer, print one per line + */ + if (max_len > 35) { + do { + fprintf( option_usage_fp, " %s\n", *(paz_names++) ); + } while (--ct_down > 0); + } + + /* + * ELSE IF they all fit on one line, then do so. + */ + else if (ttl_len < 76) { + fputc( ' ', option_usage_fp ); + do { + fputc( ' ', option_usage_fp ); + fputs( *(paz_names++), option_usage_fp ); + } while (--ct_down > 0); + fputc( '\n', option_usage_fp ); + } + + /* + * Otherwise, columnize the output + */ + else { + int ent_no = 0; + char zFmt[16]; /* format for all-but-last entries on a line */ + + sprintf( zFmt, "%%-%ds", (int)max_len ); + max_len = 78 / max_len; /* max_len is now max entries on a line */ + fputs( " ", option_usage_fp ); + + /* + * Loop through all but the last entry + */ + ct_down = name_ct; + while (--ct_down > 0) { + if (++ent_no == max_len) { + /* + * Last entry on a line. Start next line, too. + */ + fprintf( option_usage_fp, "%s\n ", *(paz_names++) ); + ent_no = 0; + } + + else + fprintf(option_usage_fp, zFmt, *(paz_names++) ); + } + fprintf(option_usage_fp, "%s\n", *paz_names); + } + + if (pOpts > OPTPROC_EMIT_LIMIT) { + fprintf(option_usage_fp, zIntRange, hidden, name_ct - 1 + hidden); + + (*(pOpts->pUsageProc))( pOpts, EXIT_FAILURE ); + /* NOTREACHED */ + } + + + if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_MEMBERSHIP) { + fprintf(option_usage_fp, zLowerBits, name_ct); + fputs(zSetMemberSettings, option_usage_fp); + } else { + fprintf(option_usage_fp, zIntRange, hidden, name_ct - 1 + hidden); + } +} + + +static uintptr_t +findName( + tCC* pzName, + tOptions* pOpts, + tOptDesc* pOD, + tCC* const * paz_names, + unsigned int name_ct ) +{ + /* + * Return the matching index as a pointer sized integer. + * The result gets stashed in a char* pointer. + */ + uintptr_t res = name_ct; + size_t len = strlen( (char*)pzName ); + uintptr_t idx; + + if (IS_DEC_DIGIT_CHAR(*pzName)) { + char * pz = (char *)(void *)pzName; + unsigned long val = strtoul(pz, &pz, 0); + if ((*pz == NUL) && (val < name_ct)) + return (uintptr_t)val; + enumError(pOpts, pOD, paz_names, (int)name_ct); + return name_ct; + } + + /* + * Look for an exact match, but remember any partial matches. + * Multiple partial matches means we have an ambiguous match. + */ + for (idx = 0; idx < name_ct; idx++) { + if (strncmp( (char*)paz_names[idx], (char*)pzName, len) == 0) { + if (paz_names[idx][len] == NUL) + return idx; /* full match */ + + res = (res != name_ct) ? ~0 : idx; /* save partial match */ + } + } + + if (res < name_ct) + return res; /* partial match */ + + pz_enum_err_fmt = (res == name_ct) ? zNoKey : zAmbigKey; + option_usage_fp = stderr; + enumError(pOpts, pOD, paz_names, (int)name_ct); + return name_ct; +} + + +/*=export_func optionKeywordName + * what: Convert between enumeration values and strings + * private: + * + * arg: tOptDesc*, pOD, enumeration option description + * arg: unsigned int, enum_val, the enumeration value to map + * + * ret_type: char const* + * ret_desc: the enumeration name from const memory + * + * doc: This converts an enumeration value into the matching string. +=*/ +char const* +optionKeywordName( + tOptDesc* pOD, + unsigned int enum_val ) +{ + tOptDesc od; + + od.optArg.argEnum = enum_val; + (*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, &od ); + return od.optArg.argString; +} + + +/*=export_func optionEnumerationVal + * what: Convert from a string to an enumeration value + * private: + * + * arg: tOptions*, pOpts, the program options descriptor + * arg: tOptDesc*, pOD, enumeration option description + * arg: char const * const *, paz_names, list of enumeration names + * arg: unsigned int, name_ct, number of names in list + * + * ret_type: uintptr_t + * ret_desc: the enumeration value + * + * doc: This converts the optArg.argString string from the option description + * into the index corresponding to an entry in the name list. + * This will match the generated enumeration value. + * Full matches are always accepted. Partial matches are accepted + * if there is only one partial match. +=*/ +uintptr_t +optionEnumerationVal( + tOptions* pOpts, + tOptDesc* pOD, + tCC * const * paz_names, + unsigned int name_ct ) +{ + uintptr_t res = 0UL; + + /* + * IF the program option descriptor pointer is invalid, + * then it is some sort of special request. + */ + switch ((uintptr_t)pOpts) { + case (uintptr_t)OPTPROC_EMIT_USAGE: + /* + * print the list of enumeration names. + */ + enumError(pOpts, pOD, paz_names, (int)name_ct); + break; + + case (uintptr_t)OPTPROC_EMIT_SHELL: + { + unsigned int ix = pOD->optArg.argEnum; + /* + * print the name string. + */ + if (ix >= name_ct) + printf( "INVALID-%d", ix ); + else + fputs( paz_names[ ix ], stdout ); + + break; + } + + case (uintptr_t)OPTPROC_RETURN_VALNAME: + { + tSCC zInval[] = "*INVALID*"; + unsigned int ix = pOD->optArg.argEnum; + /* + * Replace the enumeration value with the name string. + */ + if (ix >= name_ct) + return (uintptr_t)zInval; + + pOD->optArg.argString = paz_names[ix]; + break; + } + + default: + res = findName(pOD->optArg.argString, pOpts, pOD, paz_names, name_ct); + + if (pOD->fOptState & OPTST_ALLOC_ARG) { + AGFREE(pOD->optArg.argString); + pOD->fOptState &= ~OPTST_ALLOC_ARG; + pOD->optArg.argString = NULL; + } + } + + return res; +} + + +/*=export_func optionSetMembers + * what: Convert between bit flag values and strings + * private: + * + * arg: tOptions*, pOpts, the program options descriptor + * arg: tOptDesc*, pOD, enumeration option description + * arg: char const * const *, + * paz_names, list of enumeration names + * arg: unsigned int, name_ct, number of names in list + * + * doc: This converts the optArg.argString string from the option description + * into the index corresponding to an entry in the name list. + * This will match the generated enumeration value. + * Full matches are always accepted. Partial matches are accepted + * if there is only one partial match. +=*/ +void +optionSetMembers( + tOptions* pOpts, + tOptDesc* pOD, + tCC* const * paz_names, + unsigned int name_ct ) +{ + /* + * IF the program option descriptor pointer is invalid, + * then it is some sort of special request. + */ + switch ((uintptr_t)pOpts) { + case (uintptr_t)OPTPROC_EMIT_USAGE: + /* + * print the list of enumeration names. + */ + enumError(OPTPROC_EMIT_USAGE, pOD, paz_names, (int)name_ct ); + return; + + case (uintptr_t)OPTPROC_EMIT_SHELL: + { + /* + * print the name string. + */ + int ix = 0; + uintptr_t bits = (uintptr_t)pOD->optCookie; + size_t len = 0; + + bits &= ((uintptr_t)1 << (uintptr_t)name_ct) - (uintptr_t)1; + + while (bits != 0) { + if (bits & 1) { + if (len++ > 0) fputs( " | ", stdout ); + fputs(paz_names[ix], stdout); + } + if (++ix >= name_ct) break; + bits >>= 1; + } + return; + } + + case (uintptr_t)OPTPROC_RETURN_VALNAME: + { + char* pz; + uintptr_t bits = (uintptr_t)pOD->optCookie; + int ix = 0; + size_t len = 5; + + bits &= ((uintptr_t)1 << (uintptr_t)name_ct) - (uintptr_t)1; + + /* + * Replace the enumeration value with the name string. + * First, determine the needed length, then allocate and fill in. + */ + while (bits != 0) { + if (bits & 1) + len += strlen( paz_names[ix]) + 8; + if (++ix >= name_ct) break; + bits >>= 1; + } + + pOD->optArg.argString = pz = AGALOC(len, "enum name"); + + /* + * Start by clearing all the bits. We want to turn off any defaults + * because we will be restoring to current state, not adding to + * the default set of bits. + */ + strcpy( pz, "none" ); + pz += 4; + bits = (uintptr_t)pOD->optCookie; + bits &= ((uintptr_t)1 << (uintptr_t)name_ct) - (uintptr_t)1; + ix = 0; + + while (bits != 0) { + if (bits & 1) { + strcpy( pz, " + " ); + strcpy( pz+3, paz_names[ix]); + pz += strlen( paz_names[ix]) + 3; + } + if (++ix >= name_ct) break; + bits >>= 1; + } + return; + } + + default: + break; + } + + if ((pOD->fOptState & OPTST_RESET) != 0) + return; + + { + tCC* pzArg = pOD->optArg.argString; + uintptr_t res; + if ((pzArg == NULL) || (*pzArg == NUL)) { + pOD->optCookie = (void*)0; + return; + } + + res = (uintptr_t)pOD->optCookie; + for (;;) { + tSCC zSpn[] = " ,|+\t\r\f\n"; + int iv, len; + + pzArg += strspn( pzArg, zSpn ); + iv = (*pzArg == '!'); + if (iv) + pzArg += strspn( pzArg+1, zSpn ) + 1; + + len = strcspn( pzArg, zSpn ); + if (len == 0) + break; + + if ((len == 3) && (strncmp(pzArg, zAll, (size_t)3) == 0)) { + if (iv) + res = 0; + else res = ~0UL; + } + else if ((len == 4) && (strncmp(pzArg, zNone, (size_t)4) == 0)) { + if (! iv) + res = 0; + } + else do { + char* pz; + uintptr_t bit = strtoul( pzArg, &pz, 0 ); + + if (pz != pzArg + len) { + char z[ AO_NAME_SIZE ]; + tCC* p; + int shift_ct; + + if (*pz != NUL) { + if (len >= AO_NAME_LIMIT) + break; + strncpy( z, pzArg, (size_t)len ); + z[len] = NUL; + p = z; + } else { + p = pzArg; + } + + shift_ct = findName(p, pOpts, pOD, paz_names, name_ct); + if (shift_ct >= name_ct) { + pOD->optCookie = (void*)0; + return; + } + bit = 1UL << shift_ct; + } + if (iv) + res &= ~bit; + else res |= bit; + } while (0); + + if (pzArg[len] == NUL) + break; + pzArg += len + 1; + } + if (name_ct < (8 * sizeof( uintptr_t ))) { + res &= (1UL << name_ct) - 1UL; + } + + pOD->optCookie = (void*)res; + } +} + +/* + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of autoopts/enumeration.c */ diff --git a/libopts/environment.c b/libopts/environment.c new file mode 100644 index 0000000..8700c8e --- /dev/null +++ b/libopts/environment.c @@ -0,0 +1,241 @@ + +/* + * $Id: environment.c,v 4.21 2009/08/01 17:43:06 bkorb Exp $ + * Time-stamp: "2009-07-20 20:12:24 bkorb" + * + * This file contains all of the routines that must be linked into + * an executable to use the generated option processing. The optional + * routines are in separately compiled modules so that they will not + * necessarily be linked in. + * + * This file is part of AutoOpts, a companion to AutoGen. + * AutoOpts is free software. + * AutoOpts is copyright (c) 1992-2009 by Bruce Korb - all rights reserved + * + * AutoOpts is available under any one of two licenses. The license + * in use must be one of these two and the choice is under the control + * of the user of the license. + * + * The GNU Lesser General Public License, version 3 or later + * See the files "COPYING.lgplv3" and "COPYING.gplv3" + * + * The Modified Berkeley Software Distribution License + * See the file "COPYING.mbsd" + * + * These files have the following md5sums: + * + * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 + * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 + * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + */ + +/* = = = START-STATIC-FORWARD = = = */ +/* static forward declarations maintained by mk-fwd */ +static void +checkEnvOpt(tOptState * os, char * env_name, + tOptions* pOpts, teEnvPresetType type); +/* = = = END-STATIC-FORWARD = = = */ + +/* + * doPrognameEnv - check for preset values from the ${PROGNAME} + * environment variable. This is accomplished by parsing the text into + * tokens, temporarily replacing the arg vector and calling + * doImmediateOpts and/or doRegularOpts. + */ +LOCAL void +doPrognameEnv( tOptions* pOpts, teEnvPresetType type ) +{ + char const* pczOptStr = getenv( pOpts->pzPROGNAME ); + token_list_t* pTL; + int sv_argc; + tAoUI sv_flag; + char** sv_argv; + + /* + * No such beast? Then bail now. + */ + if (pczOptStr == NULL) + return; + + /* + * Tokenize the string. If there's nothing of interest, we'll bail + * here immediately. + */ + pTL = ao_string_tokenize( pczOptStr ); + if (pTL == NULL) + return; + + /* + * Substitute our $PROGNAME argument list for the real one + */ + sv_argc = pOpts->origArgCt; + sv_argv = pOpts->origArgVect; + sv_flag = pOpts->fOptSet; + + /* + * We add a bogus pointer to the start of the list. The program name + * has already been pulled from "argv", so it won't get dereferenced. + * The option scanning code will skip the "program name" at the start + * of this list of tokens, so we accommodate this way .... + */ + pOpts->origArgVect = (char**)(pTL->tkn_list - 1); + pOpts->origArgCt = pTL->tkn_ct + 1; + pOpts->fOptSet &= ~OPTPROC_ERRSTOP; + + pOpts->curOptIdx = 1; + pOpts->pzCurOpt = NULL; + + switch (type) { + case ENV_IMM: + (void)doImmediateOpts( pOpts ); + break; + + case ENV_ALL: + (void)doImmediateOpts( pOpts ); + pOpts->curOptIdx = 1; + pOpts->pzCurOpt = NULL; + /* FALLTHROUGH */ + + case ENV_NON_IMM: + (void)doRegularOpts( pOpts ); + } + + /* + * Free up the temporary arg vector and restore the original program args. + */ + free( pTL ); + pOpts->origArgVect = sv_argv; + pOpts->origArgCt = sv_argc; + pOpts->fOptSet = sv_flag; +} + +static void +checkEnvOpt(tOptState * os, char * env_name, + tOptions* pOpts, teEnvPresetType type) +{ + os->pzOptArg = getenv( env_name ); + if (os->pzOptArg == NULL) + return; + + os->flags = OPTST_PRESET | OPTST_ALLOC_ARG | os->pOD->fOptState; + os->optType = TOPT_UNDEFINED; + + if ( (os->pOD->pz_DisablePfx != NULL) + && (streqvcmp( os->pzOptArg, os->pOD->pz_DisablePfx ) == 0)) { + os->flags |= OPTST_DISABLED; + os->pzOptArg = NULL; + } + + switch (type) { + case ENV_IMM: + /* + * Process only immediate actions + */ + if (DO_IMMEDIATELY(os->flags)) + break; + return; + + case ENV_NON_IMM: + /* + * Process only NON immediate actions + */ + if (DO_NORMALLY(os->flags) || DO_SECOND_TIME(os->flags)) + break; + return; + + default: /* process everything */ + break; + } + + /* + * Make sure the option value string is persistent and consistent. + * + * The interpretation of the option value depends + * on the type of value argument the option takes + */ + if (os->pzOptArg != NULL) { + if (OPTST_GET_ARGTYPE(os->pOD->fOptState) == OPARG_TYPE_NONE) { + os->pzOptArg = NULL; + } else if ( (os->pOD->fOptState & OPTST_ARG_OPTIONAL) + && (*os->pzOptArg == NUL)) { + os->pzOptArg = NULL; + } else if (*os->pzOptArg == NUL) { + os->pzOptArg = zNil; + } else { + AGDUPSTR( os->pzOptArg, os->pzOptArg, "option argument" ); + os->flags |= OPTST_ALLOC_ARG; + } + } + + handleOption( pOpts, os ); +} + +/* + * doEnvPresets - check for preset values from the envrionment + * This routine should process in all, immediate or normal modes.... + */ +LOCAL void +doEnvPresets( tOptions* pOpts, teEnvPresetType type ) +{ + int ct; + tOptState st; + char* pzFlagName; + size_t spaceLeft; + char zEnvName[ AO_NAME_SIZE ]; + + /* + * Finally, see if we are to look at the environment + * variables for initial values. + */ + if ((pOpts->fOptSet & OPTPROC_ENVIRON) == 0) + return; + + doPrognameEnv( pOpts, type ); + + ct = pOpts->presetOptCt; + st.pOD = pOpts->pOptDesc; + + pzFlagName = zEnvName + + snprintf( zEnvName, sizeof( zEnvName ), "%s_", pOpts->pzPROGNAME ); + spaceLeft = AO_NAME_SIZE - (pzFlagName - zEnvName) - 1; + + for (;ct-- > 0; st.pOD++) { + /* + * If presetting is disallowed, then skip this entry + */ + if ( ((st.pOD->fOptState & OPTST_NO_INIT) != 0) + || (st.pOD->optEquivIndex != NO_EQUIVALENT) ) + continue; + + /* + * IF there is no such environment variable, + * THEN skip this entry, too. + */ + if (strlen( st.pOD->pz_NAME ) >= spaceLeft) + continue; + + /* + * Set up the option state + */ + strcpy( pzFlagName, st.pOD->pz_NAME ); + checkEnvOpt(&st, zEnvName, pOpts, type); + } + + /* + * Special handling for ${PROGNAME_LOAD_OPTS} + */ + if ( (pOpts->specOptIdx.save_opts != NO_EQUIVALENT) + && (pOpts->specOptIdx.save_opts != 0)) { + st.pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts + 1; + strcpy( pzFlagName, st.pOD->pz_NAME ); + checkEnvOpt(&st, zEnvName, pOpts, type); + } +} + +/* + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of autoopts/environment.c */ diff --git a/libopts/file.c b/libopts/file.c new file mode 100644 index 0000000..1410aaa --- /dev/null +++ b/libopts/file.c @@ -0,0 +1,170 @@ + +/* + * $Id: file.c,v 4.9 2009/08/01 17:43:06 bkorb Exp $ + * Time-stamp: "2009-07-23 17:23:46 bkorb" + * + * This file is part of AutoOpts, a companion to AutoGen. + * AutoOpts is free software. + * AutoOpts is copyright (c) 1992-2009 by Bruce Korb - all rights reserved + * + * AutoOpts is available under any one of two licenses. The license + * in use must be one of these two and the choice is under the control + * of the user of the license. + * + * The GNU Lesser General Public License, version 3 or later + * See the files "COPYING.lgplv3" and "COPYING.gplv3" + * + * The Modified Berkeley Software Distribution License + * See the file "COPYING.mbsd" + * + * These files have the following md5sums: + * + * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 + * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 + * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + */ + +/*=export_func optionFileCheck + * private: + * + * what: Decipher a boolean value + * arg: + tOptions* + pOpts + program options descriptor + + * arg: + tOptDesc* + pOptDesc + the descriptor for this arg + + * arg: + teOptFileType + ftype + File handling type + + * arg: + tuFileMode + mode + file open mode (if needed) + + * + * doc: + * Make sure the named file conforms with the file type mode. + * The mode specifies if the file must exist, must not exist or may + * (or may not) exist. The mode may also specify opening the + * file: don't, open just the descriptor (fd), or open as a stream + * (FILE* pointer). +=*/ +void +optionFileCheck(tOptions* pOpts, tOptDesc* pOD, + teOptFileType ftype, tuFileMode mode) +{ + if (pOpts <= OPTPROC_EMIT_LIMIT) { + if (pOpts != OPTPROC_EMIT_USAGE) + return; + + switch (ftype & FTYPE_MODE_EXIST_MASK) { + case FTYPE_MODE_MUST_NOT_EXIST: + fputs(zFileCannotExist, option_usage_fp); + break; + + case FTYPE_MODE_MUST_EXIST: + fputs(zFileMustExist, option_usage_fp); + break; + } + return; + } + + if ((pOD->fOptState & OPTST_RESET) != 0) { + if (pOD->optCookie != NULL) + AGFREE(pOD->optCookie); + return; + } + + { + struct stat sb; + + errno = 0; + + switch (ftype & FTYPE_MODE_EXIST_MASK) { + case FTYPE_MODE_MUST_NOT_EXIST: + if ( (stat(pOD->optArg.argString, &sb) == 0) + || (errno != ENOENT) ){ + if (errno == 0) + errno = EINVAL; + fprintf(stderr, zFSOptError, errno, strerror(errno), + zFSOptErrNoExist, pOD->optArg.argString, pOD->pz_Name); + pOpts->pUsageProc(pOpts, EXIT_FAILURE); + /* NOTREACHED */ + } + /* FALLTHROUGH */ + + default: + case FTYPE_MODE_MAY_EXIST: + { + char * p = strrchr(pOD->optArg.argString, DIRCH); + if (p != NULL) + *p = NUL; + if ( (stat(pOD->optArg.argString, &sb) != 0) + || (errno = EINVAL, ! S_ISDIR(sb.st_mode)) ){ + fprintf(stderr, zFSOptError, errno, strerror(errno), + zFSOptErrMayExist, pOD->optArg.argString, pOD->pz_Name); + pOpts->pUsageProc(pOpts, EXIT_FAILURE); + /* NOTREACHED */ + } + if (p != NULL) + *p = DIRCH; + break; + } + + case FTYPE_MODE_MUST_EXIST: + if ( (stat(pOD->optArg.argString, &sb) != 0) + || (errno = EINVAL, ! S_ISREG(sb.st_mode)) ){ + fprintf(stderr, zFSOptError, errno, strerror(errno), + zFSOptErrMustExist, pOD->optArg.argString, + pOD->pz_Name); + pOpts->pUsageProc(pOpts, EXIT_FAILURE); + /* NOTREACHED */ + } + break; + } + } + + switch (ftype & FTYPE_MODE_OPEN_MASK) { + default: + case FTYPE_MODE_NO_OPEN: + break; + + case FTYPE_MODE_OPEN_FD: + { + int fd = open(pOD->optArg.argString, mode.file_flags); + if (fd < 0) { + fprintf(stderr, zFSOptError, errno, strerror(errno), + zFSOptErrOpen, pOD->optArg.argString, pOD->pz_Name); + pOpts->pUsageProc(pOpts, EXIT_FAILURE); + /* NOTREACHED */ + } + + if ((pOD->fOptState & OPTST_ALLOC_ARG) != 0) + pOD->optCookie = (void *)pOD->optArg.argString; + else + AGDUPSTR(pOD->optCookie, pOD->optArg.argString, "file name"); + + pOD->optArg.argFd = fd; + pOD->fOptState &= ~OPTST_ALLOC_ARG; + break; + } + + case FTYPE_MODE_FOPEN_FP: + { + FILE* fp = fopen(pOD->optArg.argString, mode.file_mode); + if (fp == NULL) { + fprintf(stderr, zFSOptError, errno, strerror(errno), + zFSOptErrFopen, pOD->optArg.argString, pOD->pz_Name); + pOpts->pUsageProc(pOpts, EXIT_FAILURE); + /* NOTREACHED */ + } + + if ((pOD->fOptState & OPTST_ALLOC_ARG) != 0) + pOD->optCookie = (void *)pOD->optArg.argString; + else + AGDUPSTR(pOD->optCookie, pOD->optArg.argString, "file name"); + + pOD->optArg.argFp = fp; + pOD->fOptState &= ~OPTST_ALLOC_ARG; + break; + } + } +} +/* + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of autoopts/file.c */ diff --git a/libopts/genshell.c b/libopts/genshell.c new file mode 100644 index 0000000..75c621c --- /dev/null +++ b/libopts/genshell.c @@ -0,0 +1,358 @@ +/* -*- buffer-read-only: t -*- vi: set ro: + * + * DO NOT EDIT THIS FILE (genshell.c) + * + * It has been AutoGen-ed August 8, 2009 at 10:14:45 AM by AutoGen 5.9.9 + * From the definitions genshell.def + * and the template file options + * + * Generated from AutoOpts @AO_CURRENT@:@AO_REVISION@:@AO_AGE@ templates. + */ + +/* + * This file was produced by an AutoOpts template. AutoOpts is a + * copyrighted work. This source file is not encumbered by AutoOpts + * licensing, but is provided under the licensing terms chosen by the + * genshellopt author or copyright holder. AutoOpts is licensed under + * the terms of the LGPL. The redistributable library (``libopts'') is + * licensed under the terms of either the LGPL or, at the users discretion, + * the BSD license. See the AutoOpts and/or libopts sources for details. + * + * This source file is copyrighted and licensed under the following terms: + * + * genshellopt copyright (c) 1999-2009 Bruce Korb - all rights reserved + * + * genshellopt is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * genshellopt is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the 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 . + */ + +#include +#include +#include +#include + +#define OPTION_CODE_COMPILE 1 +#include "genshell.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* TRANSLATORS: choose the translation for option names wisely because you + cannot ever change your mind. */ +tSCC zCopyright[] = + "genshellopt copyright (c) 1999-2009 Bruce Korb, all rights reserved"; +tSCC zCopyrightNotice[610] = +"genshellopt is free software: you can redistribute it and/or modify it under\n\ +the terms of the GNU General Public License as published by the Free Software\n\ +Foundation, either version 3 of the License, or (at your option) any later\n\ +version.\n\n\ +genshellopt is distributed in the hope that it will be useful, but WITHOUT ANY\n\ +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A\n\ +PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\n\ +You should have received a copy of the GNU General Public License along with\n\ +this program. If not, see ."; + +extern tUsageProc genshelloptUsage; + +#ifndef NULL +# define NULL 0 +#endif +#ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +#endif +#ifndef EXIT_FAILURE +# define EXIT_FAILURE 1 +#endif +/* + * Script option description: + */ +tSCC zScriptText[] = + "Output Script File"; +tSCC zScript_NAME[] = "SCRIPT"; +tSCC zScript_Name[] = "script"; +#define SCRIPT_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Shell option description: + */ +tSCC zShellText[] = + "Shell name (follows \"#!\" magic)"; +tSCC zShell_NAME[] = "SHELL"; +tSCC zNotShell_Name[] = "no-shell"; +tSCC zNotShell_Pfx[] = "no"; +#define zShell_Name (zNotShell_Name + 3) +#define SHELL_FLAGS (OPTST_INITENABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Help/More_Help/Version option descriptions: + */ +tSCC zHelpText[] = "Display usage information and exit"; +tSCC zHelp_Name[] = "help"; +tSCC zMore_HelpText[] = "Extended usage information passed thru pager"; +tSCC zMore_Help_Name[] = "more-help"; +tSCC zVersionText[] = "Output version information and exit"; +tSCC zVersion_Name[] = "version"; +/* + * Declare option callback procedures + */ +extern tOptProc + optionPagedUsage, optionPrintVersion; +static tOptProc + doUsageOpt; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Define the Genshellopt Option Descriptions. + */ +static tOptDesc optDesc[ OPTION_CT ] = { + { /* entry idx, value */ 0, VALUE_OPT_SCRIPT, + /* equiv idx, value */ 0, VALUE_OPT_SCRIPT, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ SCRIPT_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zScriptText, zScript_NAME, zScript_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 1, VALUE_OPT_SHELL, + /* equiv idx, value */ 1, VALUE_OPT_SHELL, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ SHELL_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zShellText, zShell_NAME, zShell_Name, + /* disablement strs */ zNotShell_Name, zNotShell_Pfx }, + +#ifdef NO_OPTIONAL_OPT_ARGS +# define VERSION_OPT_FLAGS OPTST_IMM | OPTST_NO_INIT +#else +# define VERSION_OPT_FLAGS OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \ + OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT +#endif + + { /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ VERSION_OPT_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionPrintVersion, + /* desc, NAME, name */ zVersionText, NULL, zVersion_Name, + /* disablement strs */ NULL, NULL }, + +#undef VERSION_OPT_FLAGS + + + { /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doUsageOpt, + /* desc, NAME, name */ zHelpText, NULL, zHelp_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionPagedUsage, + /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name, + /* disablement strs */ NULL, NULL } +}; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Define the Genshellopt Option Environment + */ +tSCC zPROGNAME[] = "GENSHELLOPT"; +tSCC zUsageTitle[] = +"genshellopt - Generate Shell Option Processing Script - Ver. 1\n\ +USAGE: %s [ - [] | --[{=| }] ]...\n"; +#define zRcName NULL +#define apzHomeList NULL + +tSCC zBugsAddr[] = "autogen-users@lists.sourceforge.net"; +tSCC zExplain[] = "\n\ +Note that `shell' is only useful if the output file does not already\n\ +exist. If it does, then the shell name and optional first argument\n\ +will be extracted from the script file.\n"; +tSCC zDetail[] = "\n\ +If the script file already exists and contains Automated Option Processing\n\ +text, the second line of the file through the ending tag will be replaced\n\ +by the newly generated text. The first `#!' line will be regenerated.\n"; +tSCC zFullVersion[] = GENSHELLOPT_FULL_VERSION; +/* extracted from optcode.tpl near line 501 */ + +#if defined(ENABLE_NLS) +# define OPTPROC_BASE OPTPROC_TRANSLATE + static tOptionXlateProc translate_option_strings; +#else +# define OPTPROC_BASE OPTPROC_NONE +# define translate_option_strings NULL +#endif /* ENABLE_NLS */ + + +#define genshellopt_full_usage NULL +#define genshellopt_short_usage NULL +tOptions genshelloptOptions = { + OPTIONS_STRUCT_VERSION, + 0, NULL, /* original argc + argv */ + ( OPTPROC_BASE + + OPTPROC_ERRSTOP + + OPTPROC_SHORTOPT + + OPTPROC_LONGOPT + + OPTPROC_NO_REQ_OPT + + OPTPROC_NEGATIONS + + OPTPROC_NO_ARGS ), + 0, NULL, /* current option index, current option */ + NULL, NULL, zPROGNAME, + zRcName, zCopyright, zCopyrightNotice, + zFullVersion, apzHomeList, zUsageTitle, + zExplain, zDetail, optDesc, + zBugsAddr, /* address to send bugs to */ + NULL, NULL, /* extensions/saved state */ + genshelloptUsage, /* usage procedure */ + translate_option_strings, /* translation procedure */ + /* + * Indexes to special options + */ + { INDEX_OPT_MORE_HELP, /* more-help option index */ + NO_EQUIVALENT, /* save option index */ + NO_EQUIVALENT, /* '-#' option index */ + NO_EQUIVALENT /* index of default opt */ + }, + 5 /* full option count */, 2 /* user option count */, + genshellopt_full_usage, genshellopt_short_usage, + NULL, NULL +}; + +/* + * Create the static procedure(s) declared above. + */ +static void +doUsageOpt( + tOptions* pOptions, + tOptDesc* pOptDesc ) +{ + (void)pOptions; + USAGE( EXIT_SUCCESS ); +} +/* extracted from optcode.tpl near line 633 */ + +#if ENABLE_NLS +#include +#include +#include +#include +#include + +static char* AO_gettext( char const* pz ); +static void coerce_it(void** s); + +static char* +AO_gettext( char const* pz ) +{ + char* pzRes; + if (pz == NULL) + return NULL; + pzRes = _(pz); + if (pzRes == pz) + return pzRes; + pzRes = strdup( pzRes ); + if (pzRes == NULL) { + fputs( _("No memory for duping translated strings\n"), stderr ); + exit( EXIT_FAILURE ); + } + return pzRes; +} + +static void coerce_it(void** s) { *s = AO_gettext(*s); } +#define COERSION(_f) \ + coerce_it((void*)&(genshelloptOptions._f)) + +/* + * This invokes the translation code (e.g. gettext(3)). + */ +static void +translate_option_strings( void ) +{ + /* + * Guard against re-translation. It won't work. The strings will have + * been changed by the first pass through this code. One shot only. + */ + if (option_usage_text.field_ct != 0) { + + /* + * Do the translations. The first pointer follows the field count + * field. The field count field is the size of a pointer. + */ + tOptDesc* pOD = genshelloptOptions.pOptDesc; + char** ppz = (char**)(void*)&(option_usage_text); + int ix = option_usage_text.field_ct; + + do { + ppz++; + *ppz = AO_gettext(*ppz); + } while (--ix > 0); + + COERSION(pzCopyright); + COERSION(pzCopyNotice); + COERSION(pzFullVersion); + COERSION(pzUsageTitle); + COERSION(pzExplain); + COERSION(pzDetail); + option_usage_text.field_ct = 0; + + for (ix = genshelloptOptions.optCt; ix > 0; ix--, pOD++) + coerce_it((void*)&(pOD->pzText)); + } + + if ((genshelloptOptions.fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) { + tOptDesc* pOD = genshelloptOptions.pOptDesc; + int ix; + + for (ix = genshelloptOptions.optCt; ix > 0; ix--, pOD++) { + coerce_it((void*)&(pOD->pz_Name)); + coerce_it((void*)&(pOD->pz_DisableName)); + coerce_it((void*)&(pOD->pz_DisablePfx)); + } + /* prevent re-translation */ + genshelloptOptions.fOptSet |= OPTPROC_NXLAT_OPT_CFG | OPTPROC_NXLAT_OPT; + } +} + +#endif /* ENABLE_NLS */ + +#ifdef __cplusplus +} +#endif +/* genshell.c ends here */ diff --git a/libopts/genshell.h b/libopts/genshell.h new file mode 100644 index 0000000..4c35ffc --- /dev/null +++ b/libopts/genshell.h @@ -0,0 +1,165 @@ +/* -*- buffer-read-only: t -*- vi: set ro: + * + * DO NOT EDIT THIS FILE (genshell.h) + * + * It has been AutoGen-ed August 8, 2009 at 10:14:45 AM by AutoGen 5.9.9 + * From the definitions genshell.def + * and the template file options + * + * Generated from AutoOpts @AO_CURRENT@:@AO_REVISION@:@AO_AGE@ templates. + */ + +/* + * This file was produced by an AutoOpts template. AutoOpts is a + * copyrighted work. This header file is not encumbered by AutoOpts + * licensing, but is provided under the licensing terms chosen by the + * genshellopt author or copyright holder. AutoOpts is licensed under + * the terms of the LGPL. The redistributable library (``libopts'') is + * licensed under the terms of either the LGPL or, at the users discretion, + * the BSD license. See the AutoOpts and/or libopts sources for details. + * + * This source file is copyrighted and licensed under the following terms: + * + * genshellopt copyright (c) 1999-2009 Bruce Korb - all rights reserved + * + * genshellopt is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * genshellopt is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the 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 . + */ +/* + * This file contains the programmatic interface to the Automated + * Options generated for the genshellopt program. + * These macros are documented in the AutoGen info file in the + * "AutoOpts" chapter. Please refer to that doc for usage help. + */ +#ifndef AUTOOPTS_GENSHELL_H_GUARD +#define AUTOOPTS_GENSHELL_H_GUARD 1 +#include + +/* + * Ensure that the library used for compiling this generated header is at + * least as new as the version current when the header template was released + * (not counting patch version increments). Also ensure that the oldest + * tolerable version is at least as old as what was current when the header + * template was released. + */ +#define AO_TEMPLATE_VERSION 131074 +#if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \ + || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION) +# error option template version mismatches autoopts/options.h header + Choke Me. +#endif + +/* + * Enumeration of each option: + */ +typedef enum { + INDEX_OPT_SCRIPT = 0, + INDEX_OPT_SHELL = 1, + INDEX_OPT_VERSION = 2, + INDEX_OPT_HELP = 3, + INDEX_OPT_MORE_HELP = 4 +} teOptIndex; + +#define OPTION_CT 5 +#define GENSHELLOPT_VERSION "1" +#define GENSHELLOPT_FULL_VERSION "genshellopt - Generate Shell Option Processing Script - Ver. 1" + +/* + * Interface defines for all options. Replace "n" with the UPPER_CASED + * option name (as in the teOptIndex enumeration above). + * e.g. HAVE_OPT( SCRIPT ) + */ +#define DESC(n) (genshelloptOptions.pOptDesc[INDEX_OPT_## n]) +#define HAVE_OPT(n) (! UNUSED_OPT(& DESC(n))) +#define OPT_ARG(n) (DESC(n).optArg.argString) +#define STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK) +#define COUNT_OPT(n) (DESC(n).optOccCt) +#define ISSEL_OPT(n) (SELECTED_OPT(&DESC(n))) +#define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n))) +#define ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n))) +#define STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt) +#define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs) +#define CLEAR_OPT(n) STMTS( \ + DESC(n).fOptState &= OPTST_PERSISTENT_MASK; \ + if ( (DESC(n).fOptState & OPTST_INITENABLED) == 0) \ + DESC(n).fOptState |= OPTST_DISABLED; \ + DESC(n).optCookie = NULL ) + +/* * * * * * + * + * Interface defines for specific options. + */ +#define VALUE_OPT_SCRIPT 'o' +#define VALUE_OPT_SHELL 's' +#define VALUE_OPT_HELP '?' +#define VALUE_OPT_MORE_HELP '!' +#define VALUE_OPT_VERSION 'v' +/* + * Interface defines not associated with particular options + */ +#define ERRSKIP_OPTERR STMTS( genshelloptOptions.fOptSet &= ~OPTPROC_ERRSTOP ) +#define ERRSTOP_OPTERR STMTS( genshelloptOptions.fOptSet |= OPTPROC_ERRSTOP ) +#define RESTART_OPT(n) STMTS( \ + genshelloptOptions.curOptIdx = (n); \ + genshelloptOptions.pzCurOpt = NULL ) +#define START_OPT RESTART_OPT(1) +#define USAGE(c) (*genshelloptOptions.pUsageProc)( &genshelloptOptions, c ) +/* extracted from opthead.tpl near line 409 */ + +/* * * * * * + * + * Declare the genshellopt option descriptor. + */ +#ifdef __cplusplus +extern "C" { +#endif + +extern tOptions genshelloptOptions; + +#if defined(ENABLE_NLS) +# ifndef _ +# include + static inline char* aoGetsText( char const* pz ) { + if (pz == NULL) return NULL; + return (char*)gettext( pz ); + } +# define _(s) aoGetsText(s) +# endif /* _() */ + +# define OPT_NO_XLAT_CFG_NAMES STMTS(genshelloptOptions.fOptSet |= \ + OPTPROC_NXLAT_OPT_CFG;) +# define OPT_NO_XLAT_OPT_NAMES STMTS(genshelloptOptions.fOptSet |= \ + OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;) + +# define OPT_XLAT_CFG_NAMES STMTS(genshelloptOptions.fOptSet &= \ + ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);) +# define OPT_XLAT_OPT_NAMES STMTS(genshelloptOptions.fOptSet &= \ + ~OPTPROC_NXLAT_OPT;) + +#else /* ENABLE_NLS */ +# define OPT_NO_XLAT_CFG_NAMES +# define OPT_NO_XLAT_OPT_NAMES + +# define OPT_XLAT_CFG_NAMES +# define OPT_XLAT_OPT_NAMES + +# ifndef _ +# define _(_s) _s +# endif +#endif /* ENABLE_NLS */ + +#ifdef __cplusplus +} +#endif +#endif /* AUTOOPTS_GENSHELL_H_GUARD */ +/* genshell.h ends here */ diff --git a/libopts/libopts.c b/libopts/libopts.c new file mode 100644 index 0000000..2ca83e3 --- /dev/null +++ b/libopts/libopts.c @@ -0,0 +1,38 @@ +#define AUTOOPTS_INTERNAL +#include "compat/compat.h" +#define LOCAL static +#include "autoopts/options.h" +#include "autoopts/usage-txt.h" +#include "genshell.h" +#include "xat-attribute.h" +#include "value-type.h" +#include "ag-char-map.h" +#include "autoopts.h" +#include "proto.h" +#include "value-type.c" +#include "xat-attribute.c" +#include "autoopts.c" +#include "boolean.c" +#include "configfile.c" +#include "cook.c" +#include "enumeration.c" +#include "environment.c" +#include "file.c" +#include "genshell.c" +#include "load.c" +#include "makeshell.c" +#include "nested.c" +#include "numeric.c" +#include "pgusage.c" +#include "putshell.c" +#include "reset.c" +#include "restore.c" +#include "save.c" +#include "sort.c" +#include "stack.c" +#include "streqvcmp.c" +#include "text_mmap.c" +#include "tokenize.c" +#include "time.c" +#include "usage.c" +#include "version.c" diff --git a/libopts/load.c b/libopts/load.c new file mode 100644 index 0000000..f0ececd --- /dev/null +++ b/libopts/load.c @@ -0,0 +1,540 @@ + +/* + * $Id: load.c,v 4.38 2009/08/01 17:43:06 bkorb Exp $ + * Time-stamp: "2008-12-06 10:16:05 bkorb" + * + * This file contains the routines that deal with processing text strings + * for options, either from a NUL-terminated string passed in or from an + * rc/ini file. + * + * This file is part of AutoOpts, a companion to AutoGen. + * AutoOpts is free software. + * AutoOpts is copyright (c) 1992-2009 by Bruce Korb - all rights reserved + * + * AutoOpts is available under any one of two licenses. The license + * in use must be one of these two and the choice is under the control + * of the user of the license. + * + * The GNU Lesser General Public License, version 3 or later + * See the files "COPYING.lgplv3" and "COPYING.gplv3" + * + * The Modified Berkeley Software Distribution License + * See the file "COPYING.mbsd" + * + * These files have the following md5sums: + * + * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 + * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 + * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + */ + +tOptionLoadMode option_load_mode = OPTION_LOAD_UNCOOKED; + +/* = = = START-STATIC-FORWARD = = = */ +/* static forward declarations maintained by mk-fwd */ +static ag_bool +insertProgramPath( + char* pzBuf, + int bufSize, + tCC* pzName, + tCC* pzProgPath ); + +static ag_bool +insertEnvVal( + char* pzBuf, + int bufSize, + tCC* pzName, + tCC* pzProgPath ); + +static char* +assembleArgValue( char* pzTxt, tOptionLoadMode mode ); +/* = = = END-STATIC-FORWARD = = = */ + +/*=export_func optionMakePath + * private: + * + * what: translate and construct a path + * arg: + char* + pzBuf + The result buffer + + * arg: + int + bufSize + The size of this buffer + + * arg: + char const* + pzName + The input name + + * arg: + char const* + pzProgPath + The full path of the current program + + * + * ret-type: ag_bool + * ret-desc: AG_TRUE if the name was handled, otherwise AG_FALSE. + * If the name does not start with ``$'', then it is handled + * simply by copying the input name to the output buffer and + * resolving the name with either + * @code{canonicalize_file_name(3GLIBC)} or @code{realpath(3C)}. + * + * doc: + * + * This routine will copy the @code{pzName} input name into the @code{pzBuf} + * output buffer, carefully not exceeding @code{bufSize} bytes. If the + * first character of the input name is a @code{'$'} character, then there + * is special handling: + * @* + * @code{$$} is replaced with the directory name of the @code{pzProgPath}, + * searching @code{$PATH} if necessary. + * @* + * @code{$@} is replaced with the AutoGen package data installation directory + * (aka @code{pkgdatadir}). + * @* + * @code{$NAME} is replaced by the contents of the @code{NAME} environment + * variable. If not found, the search fails. + * + * Please note: both @code{$$} and @code{$NAME} must be at the start of the + * @code{pzName} string and must either be the entire string or be followed + * by the @code{'/'} (backslash on windows) character. + * + * err: @code{AG_FALSE} is returned if: + * @* + * @bullet{} The input name exceeds @code{bufSize} bytes. + * @* + * @bullet{} @code{$$}, @code{$@@} or @code{$NAME} is not the full string + * and the next character is not '/'. + * @* + * @bullet{} libopts was built without PKGDATADIR defined and @code{$@@} + * was specified. + * @* + * @bullet{} @code{NAME} is not a known environment variable + * @* + * @bullet{} @code{canonicalize_file_name} or @code{realpath} return + * errors (cannot resolve the resulting path). +=*/ +ag_bool +optionMakePath( + char* pzBuf, + int bufSize, + tCC* pzName, + tCC* pzProgPath ) +{ + size_t name_len = strlen( pzName ); + +# ifndef PKGDATADIR +# define PKGDATADIR "" +# endif + + tSCC pkgdatadir[] = PKGDATADIR; + + ag_bool res = AG_TRUE; + + if (bufSize <= name_len) + return AG_FALSE; + + /* + * IF not an environment variable, just copy the data + */ + if (*pzName != '$') { + tCC* pzS = pzName; + char* pzD = pzBuf; + int ct = bufSize; + + for (;;) { + if ( (*(pzD++) = *(pzS++)) == NUL) + break; + if (--ct <= 0) + return AG_FALSE; + } + } + + /* + * IF the name starts with "$$", then it must be "$$" or + * it must start with "$$/". In either event, replace the "$$" + * with the path to the executable and append a "/" character. + */ + else switch (pzName[1]) { + case NUL: + return AG_FALSE; + + case '$': + res = insertProgramPath( pzBuf, bufSize, pzName, pzProgPath ); + break; + + case '@': + if (pkgdatadir[0] == NUL) + return AG_FALSE; + + if (name_len + sizeof (pkgdatadir) > bufSize) + return AG_FALSE; + + strcpy(pzBuf, pkgdatadir); + strcpy(pzBuf + sizeof(pkgdatadir) - 1, pzName + 2); + break; + + default: + res = insertEnvVal( pzBuf, bufSize, pzName, pzProgPath ); + } + + if (! res) + return AG_FALSE; + +#if defined(HAVE_CANONICALIZE_FILE_NAME) + { + char* pz = canonicalize_file_name(pzBuf); + if (pz == NULL) + return AG_FALSE; + if (strlen(pz) < bufSize) + strcpy(pzBuf, pz); + free(pz); + } + +#elif defined(HAVE_REALPATH) + { + char z[ PATH_MAX+1 ]; + + if (realpath( pzBuf, z ) == NULL) + return AG_FALSE; + + if (strlen(z) < bufSize) + strcpy( pzBuf, z ); + } +#endif + + return AG_TRUE; +} + + +static ag_bool +insertProgramPath( + char* pzBuf, + int bufSize, + tCC* pzName, + tCC* pzProgPath ) +{ + tCC* pzPath; + tCC* pz; + int skip = 2; + + switch (pzName[2]) { + case DIRCH: + skip = 3; + case NUL: + break; + default: + return AG_FALSE; + } + + /* + * See if the path is included in the program name. + * If it is, we're done. Otherwise, we have to hunt + * for the program using "pathfind". + */ + if (strchr( pzProgPath, DIRCH ) != NULL) + pzPath = pzProgPath; + else { + pzPath = pathfind( getenv( "PATH" ), (char*)pzProgPath, "rx" ); + + if (pzPath == NULL) + return AG_FALSE; + } + + pz = strrchr( pzPath, DIRCH ); + + /* + * IF we cannot find a directory name separator, + * THEN we do not have a path name to our executable file. + */ + if (pz == NULL) + return AG_FALSE; + + pzName += skip; + + /* + * Concatenate the file name to the end of the executable path. + * The result may be either a file or a directory. + */ + if ((pz - pzPath)+1 + strlen(pzName) >= bufSize) + return AG_FALSE; + + memcpy( pzBuf, pzPath, (size_t)((pz - pzPath)+1) ); + strcpy( pzBuf + (pz - pzPath) + 1, pzName ); + + /* + * If the "pzPath" path was gotten from "pathfind()", then it was + * allocated and we need to deallocate it. + */ + if (pzPath != pzProgPath) + AGFREE(pzPath); + return AG_TRUE; +} + + +static ag_bool +insertEnvVal( + char* pzBuf, + int bufSize, + tCC* pzName, + tCC* pzProgPath ) +{ + char* pzDir = pzBuf; + + for (;;) { + int ch = (int)*++pzName; + if (! IS_VALUE_NAME_CHAR(ch)) + break; + *(pzDir++) = (char)ch; + } + + if (pzDir == pzBuf) + return AG_FALSE; + + *pzDir = NUL; + + pzDir = getenv( pzBuf ); + + /* + * Environment value not found -- skip the home list entry + */ + if (pzDir == NULL) + return AG_FALSE; + + if (strlen( pzDir ) + 1 + strlen( pzName ) >= bufSize) + return AG_FALSE; + + sprintf( pzBuf, "%s%s", pzDir, pzName ); + return AG_TRUE; +} + + +LOCAL void +mungeString( char* pzTxt, tOptionLoadMode mode ) +{ + char* pzE; + + if (mode == OPTION_LOAD_KEEP) + return; + + if (IS_WHITESPACE_CHAR(*pzTxt)) { + char* pzS = pzTxt; + char* pzD = pzTxt; + while (IS_WHITESPACE_CHAR(*++pzS)) ; + while ((*(pzD++) = *(pzS++)) != NUL) ; + pzE = pzD-1; + } else + pzE = pzTxt + strlen( pzTxt ); + + while ((pzE > pzTxt) && IS_WHITESPACE_CHAR(pzE[-1])) pzE--; + *pzE = NUL; + + if (mode == OPTION_LOAD_UNCOOKED) + return; + + switch (*pzTxt) { + default: return; + case '"': + case '\'': break; + } + + switch (pzE[-1]) { + default: return; + case '"': + case '\'': break; + } + + (void)ao_string_cook( pzTxt, NULL ); +} + + +static char* +assembleArgValue( char* pzTxt, tOptionLoadMode mode ) +{ + tSCC zBrk[] = " \t\n:="; + char* pzEnd = strpbrk( pzTxt, zBrk ); + int space_break; + + /* + * Not having an argument to a configurable name is okay. + */ + if (pzEnd == NULL) + return pzTxt + strlen(pzTxt); + + /* + * If we are keeping all whitespace, then the modevalue starts with the + * character that follows the end of the configurable name, regardless + * of which character caused it. + */ + if (mode == OPTION_LOAD_KEEP) { + *(pzEnd++) = NUL; + return pzEnd; + } + + /* + * If the name ended on a white space character, remember that + * because we'll have to skip over an immediately following ':' or '=' + * (and the white space following *that*). + */ + space_break = IS_WHITESPACE_CHAR(*pzEnd); + *(pzEnd++) = NUL; + while (IS_WHITESPACE_CHAR(*pzEnd)) pzEnd++; + if (space_break && ((*pzEnd == ':') || (*pzEnd == '='))) + while (IS_WHITESPACE_CHAR(*++pzEnd)) ; + + return pzEnd; +} + + +/* + * Load an option from a block of text. The text must start with the + * configurable/option name and be followed by its associated value. + * That value may be processed in any of several ways. See "tOptionLoadMode" + * in autoopts.h. + */ +LOCAL void +loadOptionLine( + tOptions* pOpts, + tOptState* pOS, + char* pzLine, + tDirection direction, + tOptionLoadMode load_mode ) +{ + while (IS_WHITESPACE_CHAR(*pzLine)) pzLine++; + + { + char* pzArg = assembleArgValue( pzLine, load_mode ); + + if (! SUCCESSFUL( longOptionFind( pOpts, pzLine, pOS ))) + return; + if (pOS->flags & OPTST_NO_INIT) + return; + pOS->pzOptArg = pzArg; + } + + switch (pOS->flags & (OPTST_IMM|OPTST_DISABLE_IMM)) { + case 0: + /* + * The selected option has no immediate action. + * THEREFORE, if the direction is PRESETTING + * THEN we skip this option. + */ + if (PRESETTING(direction)) + return; + break; + + case OPTST_IMM: + if (PRESETTING(direction)) { + /* + * We are in the presetting direction with an option we handle + * immediately for enablement, but normally for disablement. + * Therefore, skip if disabled. + */ + if ((pOS->flags & OPTST_DISABLED) == 0) + return; + } else { + /* + * We are in the processing direction with an option we handle + * immediately for enablement, but normally for disablement. + * Therefore, skip if NOT disabled. + */ + if ((pOS->flags & OPTST_DISABLED) != 0) + return; + } + break; + + case OPTST_DISABLE_IMM: + if (PRESETTING(direction)) { + /* + * We are in the presetting direction with an option we handle + * immediately for disablement, but normally for disablement. + * Therefore, skip if NOT disabled. + */ + if ((pOS->flags & OPTST_DISABLED) != 0) + return; + } else { + /* + * We are in the processing direction with an option we handle + * immediately for disablement, but normally for disablement. + * Therefore, skip if disabled. + */ + if ((pOS->flags & OPTST_DISABLED) == 0) + return; + } + break; + + case OPTST_IMM|OPTST_DISABLE_IMM: + /* + * The selected option is always for immediate action. + * THEREFORE, if the direction is PROCESSING + * THEN we skip this option. + */ + if (PROCESSING(direction)) + return; + break; + } + + /* + * Fix up the args. + */ + if (OPTST_GET_ARGTYPE(pOS->pOD->fOptState) == OPARG_TYPE_NONE) { + if (*pOS->pzOptArg != NUL) + return; + pOS->pzOptArg = NULL; + + } else if (pOS->pOD->fOptState & OPTST_ARG_OPTIONAL) { + if (*pOS->pzOptArg == NUL) + pOS->pzOptArg = NULL; + else { + AGDUPSTR( pOS->pzOptArg, pOS->pzOptArg, "option argument" ); + pOS->flags |= OPTST_ALLOC_ARG; + } + + } else { + if (*pOS->pzOptArg == NUL) + pOS->pzOptArg = zNil; + else { + AGDUPSTR( pOS->pzOptArg, pOS->pzOptArg, "option argument" ); + pOS->flags |= OPTST_ALLOC_ARG; + } + } + + { + tOptionLoadMode sv = option_load_mode; + option_load_mode = load_mode; + handleOption( pOpts, pOS ); + option_load_mode = sv; + } +} + + +/*=export_func optionLoadLine + * + * what: process a string for an option name and value + * + * arg: tOptions*, pOpts, program options descriptor + * arg: char const*, pzLine, NUL-terminated text + * + * doc: + * + * This is a client program callable routine for setting options from, for + * example, the contents of a file that they read in. Only one option may + * appear in the text. It will be treated as a normal (non-preset) option. + * + * When passed a pointer to the option struct and a string, it will find + * the option named by the first token on the string and set the option + * argument to the remainder of the string. The caller must NUL terminate + * the string. Any embedded new lines will be included in the option + * argument. If the input looks like one or more quoted strings, then the + * input will be "cooked". The "cooking" is identical to the string + * formation used in AutoGen definition files (@pxref{basic expression}), + * except that you may not use backquotes. + * + * err: Invalid options are silently ignored. Invalid option arguments + * will cause a warning to print, but the function should return. +=*/ +void +optionLoadLine( + tOptions* pOpts, + tCC* pzLine ) +{ + tOptState st = OPTSTATE_INITIALIZER(SET); + char* pz; + AGDUPSTR( pz, pzLine, "user option line" ); + loadOptionLine( pOpts, &st, pz, DIRECTION_PROCESS, OPTION_LOAD_COOKED ); + AGFREE( pz ); +} +/* + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of autoopts/load.c */ diff --git a/libopts/m4/libopts.m4 b/libopts/m4/libopts.m4 new file mode 100644 index 0000000..3916c6a --- /dev/null +++ b/libopts/m4/libopts.m4 @@ -0,0 +1,548 @@ +dnl -*- buffer-read-only: t -*- vi: set ro: +dnl +dnl DO NOT EDIT THIS FILE (libopts.m4) +dnl +dnl It has been AutoGen-ed August 8, 2009 at 10:14:46 AM by AutoGen 5.9.9 +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],[ +[if test X${INVOKE_LIBOPTS_MACROS_FIRST_done} != Xyes ; then] + # ================= + # AC_HEADER_STDC + # ================= + AC_HEADER_STDC + # ================= + # AC_HEADER_DIRENT + # ================= + AC_HEADER_DIRENT + + # ================= + # AC_CHECK_HEADERS + # ================= + AC_CHECK_HEADERS(dlfcn.h errno.h fcntl.h libgen.h memory.h netinet/in.h \ + setjmp.h sys/mman.h sys/param.h sys/poll.h sys/procset.h sys/select.h \ + sys/socket.h sys/stropts.h sys/time.h sys/un.h sys/wait.h unistd.h \ + utime.h sysexits.h) + + # -------------------------------------------- + # Verify certain entries from AC_CHECK_HEADERS + # -------------------------------------------- + [for f in sys_types sys_mman sys_param sys_stat sys_wait \ + string errno stdlib memory setjmp + do eval as_ac_var=\${ac_cv_header_${f}_h+set} + test "${as_ac_var}" = set] || \ + AC_MSG_ERROR([You must have ${f}.h on your system]) + done + + # ================================================ + # AC_CHECK_HEADERS: stdarg.h is present define HAVE_STDARG_H, otherwise + # if varargs.h is present define HAVE_VARARGS_H. + # ================================================ + AC_CHECK_HEADERS(stdarg.h varargs.h, break) + [if test `eval echo '${'$as_ac_Header'}'` != yes; then] + AC_MSG_ERROR([You must have stdarg.h or varargs.h on your system]) + fi + + # ================================================ + # Similarly for the string.h and strings.h headers + # ================================================ + AC_CHECK_HEADERS(string.h strings.h, break) + [if test `eval echo '${'$as_ac_Header'}'` != yes; then] + AC_MSG_ERROR([You must have string.h or strings.h on your system]) + fi + + # ===================== + # ...and limits headers + # ===================== + AC_CHECK_HEADERS(limits.h sys/limits.h values.h, break) + [if test `eval echo '${'$as_ac_Header'}'` != yes; then] + AC_MSG_ERROR([You must have one of limits.h, sys/limits.h or values.h]) + fi + + # ---------------------------------------------------------------------- + # 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 + #endif + ]) + + # ---------------------------------------------------------------------- + # Checks for typedefs + # ---------------------------------------------------------------------- + AC_CHECK_TYPES(wchar_t) + AC_CHECK_TYPES(wint_t, [], [], [ + AC_INCLUDES_DEFAULT + #if HAVE_RUNETYPE_H + # include + #endif + #if HAVE_WCHAR_H + # include + #endif + ]) + + # ======================== + # ...and int types headers + # ======================== + AC_CHECK_HEADERS(stdint.h inttypes.h, break) + 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]) + + # ===== + # sizes + # ===== + AC_CHECK_SIZEOF(char*, 4) + AC_CHECK_SIZEOF(int, 4) + AC_CHECK_SIZEOF(long, 4) + AC_CHECK_SIZEOF(short, 2) + + # ---------------------------------------------------------------------- + # AC_CHECK_LIB for SVR4 libgen, and use it if it defines pathfind. + # ---------------------------------------------------------------------- + AC_CHECK_LIB(gen, pathfind) + AC_FUNC_VPRINTF + AC_CHECK_FUNCS([mmap canonicalize_file_name snprintf strdup strchr \ + strrchr strsignal]) +[ INVOKE_LIBOPTS_MACROS_FIRST_done=yes +fi]]) + +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], + AC_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],[],[name of regex header file]) + fi + +]) # end of AC_DEFUN of LIBOPTS_WITH_REGEX_HEADER + + +AC_DEFUN([LIBOPTS_WITHLIB_REGEX],[ + AC_ARG_WITH([libregex], + AC_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_libguile+set}" = set && \ + test "${withval}" = no + 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], + AC_HELP_STRING([--with-libregex-cflags], [libregex compile flags]), + [libopts_cv_with_libregex_cflags=${with_regex_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], + AC_HELP_STRING([--with-libregex-libs], [libregex link command arguments]), + [libopts_cv_with_libregex_libs=${with_regex_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}" + fi ## disabled by request + + 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_TRY_RUN([@%:@include +@%:@include +@%:@include +@%:@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_TRY_RUN + ]) # end of AC_CACHE_VAL for libopts_cv_with_libregex + 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}" + 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_TRY_RUN([@%:@include +@%:@include +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 TRY_RUN + ]) # 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 + then libopts_cv_test_dev_zero=no + elif 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_TRY_RUN([@%:@include +@%:@include +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 TRY_RUN + ]) # 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_TRY_RUN([@%:@include +@%:@include +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 TRY_RUN + ]) # 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_TRY_RUN([@%:@include +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 TRY_RUN + ]) # 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_TRY_RUN([@%:@include +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 TRY_RUN + ]) # 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], + AC_HELP_STRING([--disable-optional-args], [not wanting optional option args]), + [libopts_cv_enable_optional_args=${enable_optional_args}], + AC_CACHE_CHECK([whether not wanting optional option args], libopts_cv_enable_optional_args, + libopts_cv_enable_optional_args=yes) + ) # end of AC_ARG_ENABLE + + if test "X${libopts_cv_enable_optional_args}" = Xno + then + AC_DEFINE([NO_OPTIONAL_OPT_ARGS], [1], + [Define this if optional arguments are disallowed]) + fi + +]) # end of AC_DEFUN of LIBOPTS_DISABLE_OPTIONAL_ARGS + + +AC_DEFUN([INVOKE_LIBOPTS_MACROS],[ + INVOKE_LIBOPTS_MACROS_FIRST + # Check to see if a reg expr header is specified. + 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 Time-stamp: "2009-07-22 18:50:49 bkorb" +dnl Last Committed: $Date: 2009/07/23 02:05:55 $ +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-2009 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 . +dnl +dnl Default to system libopts +dnl +AC_DEFUN([LIBOPTS_CHECK],[ + [NEED_LIBOPTS_DIR=''] + m4_pushdef([AO_Libopts_Dir], + [ifelse($1, , [libopts], [$1])]) + AC_SUBST(LIBOPTS_DIR, AO_Libopts_Dir) + AC_ARG_ENABLE([local-libopts], + AC_HELP_STRING([--enable-local-libopts], + [Force using the supplied libopts tearoff code]),[ + if test x$enableval = xyes ; then + AC_MSG_NOTICE([Using supplied libopts tearoff]) + LIBOPTS_LDADD='$(top_builddir)/AO_Libopts_Dir/libopts.la' + LIBOPTS_CFLAGS='-I$(top_srcdir)/AO_Libopts_Dir' + NEED_LIBOPTS_DIR=true + fi]) + + AC_ARG_ENABLE([libopts-install], + AC_HELP_STRING([--disable-libopts-install], + [Do not install libopts with client installation])) + AM_CONDITIONAL([INSTALL_LIBOPTS],[test "X${enable_libopts_install}" != Xno]) + + [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}"] + + AM_CONDITIONAL([NEED_LIBOPTS], [test -n "${NEED_LIBOPTS_DIR}"]) + AC_SUBST(LIBOPTS_LDADD) + AC_SUBST(LIBOPTS_CFLAGS) + AC_SUBST(LIBOPTS_DIR, AO_Libopts_Dir) + AC_CONFIG_FILES(AO_Libopts_Dir/Makefile) + m4_popdef([AO_Libopts_Dir]) + + [if test -n "${NEED_LIBOPTS_DIR}" ; then] + INVOKE_LIBOPTS_MACROS + else + INVOKE_LIBOPTS_MACROS_FIRST + [fi +# end of AC_DEFUN of LIBOPTS_CHECK] +]) diff --git a/libopts/m4/liboptschk.m4 b/libopts/m4/liboptschk.m4 new file mode 100644 index 0000000..a2df33c --- /dev/null +++ b/libopts/m4/liboptschk.m4 @@ -0,0 +1,43 @@ +# liboptschk.m4 serial 1 (autogen - 5.7.3) +dnl copyright (c) 2005-2009 by Bruce Korb - all rights reserved +dnl +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. + +dnl Time-stamp: "2009-07-22 18:53:27 bkorb" +dnl Last Committed: $Date: 2009/07/23 02:05:55 $ + +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1995-2000. +dnl Bruno Haible , 2000-2003. + +AC_PREREQ(2.50) + +AC_DEFUN([ag_FIND_LIBOPTS], + [if test "X${ac_cv_header_autoopts_options_h}" == Xno + then + : + else + f=`autoopts-config cflags` 2>/dev/null + test X"${f}" = X && f=`libopts-config cflags` 2>/dev/null + if test X"${f}" = X + then + : + else + AC_DEFINE([HAVE_LIBOPTS],[1],[define if we can find libopts]) + CFLAGS="${CFLAGS} ${f}" + f=`autoopts-config ldflags` 2>/dev/null + test X"${f}" = X && f=`libopts-config ldflags` 2>/dev/null + LIBS="${LIBS} ${f}" + fi + fi]) diff --git a/libopts/makeshell.c b/libopts/makeshell.c new file mode 100644 index 0000000..b82515d --- /dev/null +++ b/libopts/makeshell.c @@ -0,0 +1,1099 @@ + +/* + * $Id: makeshell.c,v 4.30 2009/08/01 17:43:06 bkorb Exp $ + * Time-stamp: "2008-07-26 16:10:51 bkorb" + * + * This module will interpret the options set in the tOptions + * structure and create a Bourne shell script capable of parsing them. + * + * This file is part of AutoOpts, a companion to AutoGen. + * AutoOpts is free software. + * AutoOpts is copyright (c) 1992-2009 by Bruce Korb - all rights reserved + * + * AutoOpts is available under any one of two licenses. The license + * in use must be one of these two and the choice is under the control + * of the user of the license. + * + * The GNU Lesser General Public License, version 3 or later + * See the files "COPYING.lgplv3" and "COPYING.gplv3" + * + * The Modified Berkeley Software Distribution License + * See the file "COPYING.mbsd" + * + * These files have the following md5sums: + * + * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 + * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 + * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + */ + +tOptions* pShellParseOptions = NULL; + +/* * * * * * * * * * * * * * * * * * * * * + * + * Setup Format Strings + */ +tSCC zStartMarker[] = +"# # # # # # # # # # -- do not modify this marker --\n#\n" +"# DO NOT EDIT THIS SECTION"; + +tSCC zPreamble[] = +"%s OF %s\n#\n" +"# From here to the next `-- do not modify this marker --',\n" +"# the text has been generated %s\n"; + +tSCC zEndPreamble[] = +"# From the %s option definitions\n#\n"; + +tSCC zMultiDef[] = "\n" +"if test -z \"${%1$s_%2$s}\"\n" +"then\n" +" %1$s_%2$s_CT=0\n" +"else\n" +" %1$s_%2$s_CT=1\n" +" %1$s_%2$s_1=\"${%1$s_%2$s}\"\n" +"fi\n" +"export %1$s_%2$s_CT"; + +tSCC zSingleDef[] = "\n" +"%1$s_%2$s=\"${%1$s_%2$s-'%3$s'}\"\n" +"%1$s_%2$s_set=false\n" +"export %1$s_%2$s\n"; + +tSCC zSingleNoDef[] = "\n" +"%1$s_%2$s=\"${%1$s_%2$s}\"\n" +"%1$s_%2$s_set=false\n" +"export %1$s_%2$s\n"; + +/* * * * * * * * * * * * * * * * * * * * * + * + * LOOP START + * + * The loop may run in either of two modes: + * all options are named options (loop only) + * regular, marked option processing. + */ +tSCC zLoopCase[] = "\n" +"OPT_PROCESS=true\n" +"OPT_ARG=\"$1\"\n\n" +"while ${OPT_PROCESS} && [ $# -gt 0 ]\ndo\n" +" OPT_ELEMENT=''\n" +" OPT_ARG_VAL=''\n\n" + /* + * 'OPT_ARG' may or may not match the current $1 + */ +" case \"${OPT_ARG}\" in\n" +" -- )\n" +" OPT_PROCESS=false\n" +" shift\n" +" ;;\n\n"; + +tSCC zLoopOnly[] = "\n" +"OPT_ARG=\"$1\"\n\n" +"while [ $# -gt 0 ]\ndo\n" +" OPT_ELEMENT=''\n" +" OPT_ARG_VAL=''\n\n" +" OPT_ARG=\"${1}\"\n"; + +/* * * * * * * * * * * * * * * * + * + * CASE SELECTORS + * + * If the loop runs as a regular option loop, + * then we must have selectors for each acceptable option + * type (long option, flag character and non-option) + */ +tSCC zLongSelection[] = +" --* )\n"; + +tSCC zFlagSelection[] = +" -* )\n"; + +tSCC zEndSelection[] = +" ;;\n\n"; + +tSCC zNoSelection[] = +" * )\n" +" OPT_PROCESS=false\n" +" ;;\n" +" esac\n\n"; + +/* * * * * * * * * * * * * * * * + * + * LOOP END + */ +tSCC zLoopEnd[] = +" if [ -n \"${OPT_ARG_VAL}\" ]\n" +" then\n" +" eval %1$s_${OPT_NAME}${OPT_ELEMENT}=\"'${OPT_ARG_VAL}'\"\n" +" export %1$s_${OPT_NAME}${OPT_ELEMENT}\n" +" fi\n" +"done\n\n" +"unset OPT_PROCESS || :\n" +"unset OPT_ELEMENT || :\n" +"unset OPT_ARG || :\n" +"unset OPT_ARG_NEEDED || :\n" +"unset OPT_NAME || :\n" +"unset OPT_CODE || :\n" +"unset OPT_ARG_VAL || :\n%2$s"; + +tSCC zTrailerMarker[] = "\n" +"# # # # # # # # # #\n#\n" +"# END OF AUTOMATED OPTION PROCESSING\n" +"#\n# # # # # # # # # # -- do not modify this marker --\n"; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * OPTION SELECTION + */ +tSCC zOptionCase[] = +" case \"${OPT_CODE}\" in\n"; + +tSCC zOptionPartName[] = +" '%s' | \\\n"; + +tSCC zOptionFullName[] = +" '%s' )\n"; + +tSCC zOptionFlag[] = +" '%c' )\n"; + +tSCC zOptionEndSelect[] = +" ;;\n\n"; + +tSCC zOptionUnknown[] = +" * )\n" +" echo Unknown %s: \"${OPT_CODE}\" >&2\n" +" echo \"$%s_USAGE_TEXT\"\n" +" exit 1\n" +" ;;\n" +" esac\n\n"; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * OPTION PROCESSING + * + * Formats for emitting the text for handling particular options + */ +tSCC zTextExit[] = +" echo \"$%s_%s_TEXT\"\n" +" exit 0\n"; + +tSCC zPagedUsageExit[] = +" echo \"$%s_LONGUSAGE_TEXT\" | ${PAGER-more}\n" +" exit 0\n"; + +tSCC zCmdFmt[] = +" %s\n"; + +tSCC zCountTest[] = +" if [ $%1$s_%2$s_CT -ge %3$d ] ; then\n" +" echo Error: more than %3$d %2$s options >&2\n" +" echo \"$%1$s_USAGE_TEXT\"\n" +" exit 1 ; fi\n"; + +tSCC zMultiArg[] = +" %1$s_%2$s_CT=`expr ${%1$s_%2$s_CT} + 1`\n" +" OPT_ELEMENT=\"_${%1$s_%2$s_CT}\"\n" +" OPT_NAME='%2$s'\n"; + +tSCC zSingleArg[] = +" if [ -n \"${%1$s_%2$s}\" ] && ${%1$s_%2$s_set} ; then\n" +" echo Error: duplicate %2$s option >&2\n" +" echo \"$%1$s_USAGE_TEXT\"\n" +" exit 1 ; fi\n" +" %1$s_%2$s_set=true\n" +" OPT_NAME='%2$s'\n"; + +tSCC zNoMultiArg[] = +" %1$s_%2$s_CT=0\n" +" OPT_ELEMENT=''\n" +" %1$s_%2$s='%3$s'\n" +" export %1$s_%2$s\n" +" OPT_NAME='%2$s'\n"; + +tSCC zNoSingleArg[] = +" if [ -n \"${%1$s_%2$s}\" ] && ${%1$s_%2$s_set} ; then\n" +" echo Error: duplicate %2$s option >&2\n" +" echo \"$%1$s_USAGE_TEXT\"\n" +" exit 1 ; fi\n" +" %1$s_%2$s_set=true\n" +" %1$s_%2$s='%3$s'\n" +" export %1$s_%2$s\n" +" OPT_NAME='%2$s'\n"; + +tSCC zMayArg[] = +" eval %1$s_%2$s${OPT_ELEMENT}=true\n" +" export %1$s_%2$s${OPT_ELEMENT}\n" +" OPT_ARG_NEEDED=OK\n"; + +tSCC zMustArg[] = +" OPT_ARG_NEEDED=YES\n"; + +tSCC zCantArg[] = +" eval %1$s_%2$s${OPT_ELEMENT}=true\n" +" export %1$s_%2$s${OPT_ELEMENT}\n" +" OPT_ARG_NEEDED=NO\n"; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * LONG OPTION PROCESSING + * + * Formats for emitting the text for handling long option types + */ +tSCC zLongOptInit[] = +" OPT_CODE=`echo \"X${OPT_ARG}\"|sed 's/^X-*//'`\n" +" shift\n" +" OPT_ARG=\"$1\"\n\n" +" case \"${OPT_CODE}\" in *=* )\n" +" OPT_ARG_VAL=`echo \"${OPT_CODE}\"|sed 's/^[^=]*=//'`\n" +" OPT_CODE=`echo \"${OPT_CODE}\"|sed 's/=.*$//'` ;; esac\n\n"; + +tSCC zLongOptArg[] = +" case \"${OPT_ARG_NEEDED}\" in\n" +" NO )\n" +" OPT_ARG_VAL=''\n" +" ;;\n\n" +" YES )\n" +" if [ -z \"${OPT_ARG_VAL}\" ]\n" +" then\n" +" if [ $# -eq 0 ]\n" +" then\n" +" echo No argument provided for ${OPT_NAME} option >&2\n" +" echo \"$%s_USAGE_TEXT\"\n" +" exit 1\n" +" fi\n\n" +" OPT_ARG_VAL=\"${OPT_ARG}\"\n" +" shift\n" +" OPT_ARG=\"$1\"\n" +" fi\n" +" ;;\n\n" +" OK )\n" +" if [ -z \"${OPT_ARG_VAL}\" ] && [ $# -gt 0 ]\n" +" then\n" +" case \"${OPT_ARG}\" in -* ) ;; * )\n" +" OPT_ARG_VAL=\"${OPT_ARG}\"\n" +" shift\n" +" OPT_ARG=\"$1\" ;; esac\n" +" fi\n" +" ;;\n" +" esac\n"; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * FLAG OPTION PROCESSING + * + * Formats for emitting the text for handling flag option types + */ +tSCC zFlagOptInit[] = +" OPT_CODE=`echo \"X${OPT_ARG}\" | sed 's/X-\\(.\\).*/\\1/'`\n" +" OPT_ARG=` echo \"X${OPT_ARG}\" | sed 's/X-.//'`\n\n"; + +tSCC zFlagOptArg[] = +" case \"${OPT_ARG_NEEDED}\" in\n" +" NO )\n" +" if [ -n \"${OPT_ARG}\" ]\n" +" then\n" +" OPT_ARG=-\"${OPT_ARG}\"\n" +" else\n" +" shift\n" +" OPT_ARG=\"$1\"\n" +" fi\n" +" ;;\n\n" +" YES )\n" +" if [ -n \"${OPT_ARG}\" ]\n" +" then\n" +" OPT_ARG_VAL=\"${OPT_ARG}\"\n\n" +" else\n" +" if [ $# -eq 0 ]\n" +" then\n" +" echo No argument provided for ${OPT_NAME} option >&2\n" +" echo \"$%s_USAGE_TEXT\"\n" +" exit 1\n" +" fi\n" +" shift\n" +" OPT_ARG_VAL=\"$1\"\n" +" fi\n\n" +" shift\n" +" OPT_ARG=\"$1\"\n" +" ;;\n\n" +" OK )\n" +" if [ -n \"${OPT_ARG}\" ]\n" +" then\n" +" OPT_ARG_VAL=\"${OPT_ARG}\"\n" +" shift\n" +" OPT_ARG=\"$1\"\n\n" +" else\n" +" shift\n" +" if [ $# -gt 0 ]\n" +" then\n" +" case \"$1\" in -* ) ;; * )\n" +" OPT_ARG_VAL=\"$1\"\n" +" shift ;; esac\n" +" OPT_ARG=\"$1\"\n" +" fi\n" +" fi\n" +" ;;\n" +" esac\n"; + +tSCC* pzShell = NULL; +static char* pzLeader = NULL; +static char* pzTrailer = NULL; + +/* = = = START-STATIC-FORWARD = = = */ +/* static forward declarations maintained by mk-fwd */ +static void +textToVariable( tOptions* pOpts, teTextTo whichVar, tOptDesc* pOD ); + +static void +emitUsage( tOptions* pOpts ); + +static void +emitSetup( tOptions* pOpts ); + +static void +printOptionAction( tOptions* pOpts, tOptDesc* pOptDesc ); + +static void +printOptionInaction( tOptions* pOpts, tOptDesc* pOptDesc ); + +static void +emitFlag( tOptions* pOpts ); + +static void +emitMatchExpr( tCC* pzMatchName, tOptDesc* pCurOpt, tOptions* pOpts ); + +static void +emitLong( tOptions* pOpts ); + +static void +openOutput( char const* pzFile ); +/* = = = END-STATIC-FORWARD = = = */ + +/*=export_func optionParseShell + * private: + * + * what: Decipher a boolean value + * arg: + tOptions* + pOpts + program options descriptor + + * + * doc: + * Emit a shell script that will parse the command line options. +=*/ +void +optionParseShell( tOptions* pOpts ) +{ + /* + * Check for our SHELL option now. + * IF the output file contains the "#!" magic marker, + * it will override anything we do here. + */ + if (HAVE_OPT( SHELL )) + pzShell = OPT_ARG( SHELL ); + + else if (! ENABLED_OPT( SHELL )) + pzShell = NULL; + + else if ((pzShell = getenv( "SHELL" )), + pzShell == NULL) + + pzShell = "/bin/sh"; + + /* + * Check for a specified output file + */ + if (HAVE_OPT( SCRIPT )) + openOutput( OPT_ARG( SCRIPT )); + + emitUsage( pOpts ); + emitSetup( pOpts ); + + /* + * There are four modes of option processing. + */ + switch (pOpts->fOptSet & (OPTPROC_LONGOPT|OPTPROC_SHORTOPT)) { + case OPTPROC_LONGOPT: + fputs( zLoopCase, stdout ); + + fputs( zLongSelection, stdout ); + fputs( zLongOptInit, stdout ); + emitLong( pOpts ); + printf( zLongOptArg, pOpts->pzPROGNAME ); + fputs( zEndSelection, stdout ); + + fputs( zNoSelection, stdout ); + break; + + case 0: + fputs( zLoopOnly, stdout ); + fputs( zLongOptInit, stdout ); + emitLong( pOpts ); + printf( zLongOptArg, pOpts->pzPROGNAME ); + break; + + case OPTPROC_SHORTOPT: + fputs( zLoopCase, stdout ); + + fputs( zFlagSelection, stdout ); + fputs( zFlagOptInit, stdout ); + emitFlag( pOpts ); + printf( zFlagOptArg, pOpts->pzPROGNAME ); + fputs( zEndSelection, stdout ); + + fputs( zNoSelection, stdout ); + break; + + case OPTPROC_LONGOPT|OPTPROC_SHORTOPT: + fputs( zLoopCase, stdout ); + + fputs( zLongSelection, stdout ); + fputs( zLongOptInit, stdout ); + emitLong( pOpts ); + printf( zLongOptArg, pOpts->pzPROGNAME ); + fputs( zEndSelection, stdout ); + + fputs( zFlagSelection, stdout ); + fputs( zFlagOptInit, stdout ); + emitFlag( pOpts ); + printf( zFlagOptArg, pOpts->pzPROGNAME ); + fputs( zEndSelection, stdout ); + + fputs( zNoSelection, stdout ); + break; + } + + printf( zLoopEnd, pOpts->pzPROGNAME, zTrailerMarker ); + if ((pzTrailer != NULL) && (*pzTrailer != '\0')) + fputs( pzTrailer, stdout ); + else if (ENABLED_OPT( SHELL )) + printf( "\nenv | grep '^%s_'\n", pOpts->pzPROGNAME ); + + fflush( stdout ); + fchmod( STDOUT_FILENO, 0755 ); + fclose( stdout ); +} + + +static void +textToVariable( tOptions* pOpts, teTextTo whichVar, tOptDesc* pOD ) +{ +# define _TT_(n) tSCC z ## n [] = #n; + TEXTTO_TABLE +# undef _TT_ +# define _TT_(n) z ## n , + static char const* apzTTNames[] = { TEXTTO_TABLE }; +# undef _TT_ + +#if defined(__windows__) && !defined(__CYGWIN__) + printf( "%1$s_%2$s_TEXT='no %2$s text'\n", + pOpts->pzPROGNAME, apzTTNames[ whichVar ]); +#else + int nlHoldCt = 0; + int pipeFd[2]; + FILE* fp; + + printf( "%s_%s_TEXT='", pOpts->pzPROGNAME, apzTTNames[ whichVar ]); + fflush( stdout ); + + if (pipe( pipeFd ) != 0) { + fprintf( stderr, zBadPipe, errno, strerror( errno )); + exit( EXIT_FAILURE ); + } + + switch (fork()) { + case -1: + fprintf( stderr, zForkFail, errno, strerror(errno), pOpts->pzProgName); + exit( EXIT_FAILURE ); + break; + + case 0: + dup2( pipeFd[1], STDERR_FILENO ); + dup2( pipeFd[1], STDOUT_FILENO ); + close( pipeFd[0] ); + + switch (whichVar) { + case TT_LONGUSAGE: + (*(pOpts->pUsageProc))( pOpts, EXIT_SUCCESS ); + /* NOTREACHED */ + exit( EXIT_FAILURE ); + + case TT_USAGE: + (*(pOpts->pUsageProc))( pOpts, EXIT_FAILURE ); + /* NOTREACHED */ + exit( EXIT_FAILURE ); + + case TT_VERSION: + if (pOD->fOptState & OPTST_ALLOC_ARG) { + AGFREE(pOD->optArg.argString); + pOD->fOptState &= ~OPTST_ALLOC_ARG; + } + pOD->optArg.argString = "c"; + optionPrintVersion( pOpts, pOD ); + /* NOTREACHED */ + + default: + exit( EXIT_FAILURE ); + } + + default: + close( pipeFd[1] ); + fp = fdopen( pipeFd[0], "r" FOPEN_BINARY_FLAG ); + } + + for (;;) { + int ch = fgetc( fp ); + switch (ch) { + + case '\n': + nlHoldCt++; + break; + + case '\'': + while (nlHoldCt > 0) { + fputc( '\n', stdout ); + nlHoldCt--; + } + fputs( "'\\''", stdout ); + break; + + case EOF: + goto endCharLoop; + + default: + while (nlHoldCt > 0) { + fputc( '\n', stdout ); + nlHoldCt--; + } + fputc( ch, stdout ); + break; + } + } endCharLoop:; + + fputs( "'\n\n", stdout ); + close( pipeFd[0] ); +#endif +} + + +static void +emitUsage( tOptions* pOpts ) +{ + char zTimeBuf[ AO_NAME_SIZE ]; + + /* + * First, switch stdout to the output file name. + * Then, change the program name to the one defined + * by the definitions (rather than the current + * executable name). Down case the upper cased name. + */ + if (pzLeader != NULL) + fputs( pzLeader, stdout ); + + { + tSCC zStdout[] = "stdout"; + tCC* pzOutName; + + { + time_t curTime = time( NULL ); + struct tm* pTime = localtime( &curTime ); + strftime(zTimeBuf, AO_NAME_SIZE, "%A %B %e, %Y at %r %Z", pTime ); + } + + if (HAVE_OPT( SCRIPT )) + pzOutName = OPT_ARG( SCRIPT ); + else pzOutName = zStdout; + + if ((pzLeader == NULL) && (pzShell != NULL)) + printf( "#! %s\n", pzShell ); + + printf( zPreamble, zStartMarker, pzOutName, zTimeBuf ); + } + + /* + * Get a copy of the original program name in lower case + */ + { + char* pzPN = zTimeBuf; + tCC* pz = pOpts->pzPROGNAME; + for (;;) { + if ((*pzPN++ = tolower( *pz++ )) == '\0') + break; + } + } + + printf( zEndPreamble, pOpts->pzPROGNAME ); + + pOpts->pzProgPath = pOpts->pzProgName = zTimeBuf; + textToVariable( pOpts, TT_LONGUSAGE, NULL ); + textToVariable( pOpts, TT_USAGE, NULL ); + + { + tOptDesc* pOptDesc = pOpts->pOptDesc; + int optionCt = pOpts->optCt; + + for (;;) { + if (pOptDesc->pOptProc == optionPrintVersion) { + textToVariable( pOpts, TT_VERSION, pOptDesc ); + break; + } + + if (--optionCt <= 0) + break; + pOptDesc++; + } + } +} + + +static void +emitSetup( tOptions* pOpts ) +{ + tOptDesc* pOptDesc = pOpts->pOptDesc; + int optionCt = pOpts->presetOptCt; + char const* pzFmt; + char const* pzDefault; + + for (;optionCt > 0; pOptDesc++, --optionCt) { + char zVal[16]; + + /* + * Options that are either usage documentation or are compiled out + * are not to be processed. + */ + if (SKIP_OPT(pOptDesc) || (pOptDesc->pz_NAME == NULL)) + continue; + + if (pOptDesc->optMaxCt > 1) + pzFmt = zMultiDef; + else pzFmt = zSingleDef; + + /* + * IF this is an enumeration/bitmask option, then convert the value + * to a string before printing the default value. + */ + switch (OPTST_GET_ARGTYPE(pOptDesc->fOptState)) { + case OPARG_TYPE_ENUMERATION: + (*(pOptDesc->pOptProc))(OPTPROC_EMIT_SHELL, pOptDesc ); + pzDefault = pOptDesc->optArg.argString; + break; + + /* + * Numeric and membership bit options are just printed as a number. + */ + case OPARG_TYPE_NUMERIC: + snprintf( zVal, sizeof( zVal ), "%d", + (int)pOptDesc->optArg.argInt ); + pzDefault = zVal; + break; + + case OPARG_TYPE_MEMBERSHIP: + snprintf( zVal, sizeof( zVal ), "%lu", + (unsigned long)pOptDesc->optArg.argIntptr ); + pzDefault = zVal; + break; + + case OPARG_TYPE_BOOLEAN: + pzDefault = (pOptDesc->optArg.argBool) ? "true" : "false"; + break; + + default: + if (pOptDesc->optArg.argString == NULL) { + if (pzFmt == zSingleDef) + pzFmt = zSingleNoDef; + pzDefault = NULL; + } + else + pzDefault = pOptDesc->optArg.argString; + } + + printf( pzFmt, pOpts->pzPROGNAME, pOptDesc->pz_NAME, pzDefault ); + } +} + + +static void +printOptionAction( tOptions* pOpts, tOptDesc* pOptDesc ) +{ + if (pOptDesc->pOptProc == optionPrintVersion) + printf( zTextExit, pOpts->pzPROGNAME, "VERSION" ); + + else if (pOptDesc->pOptProc == optionPagedUsage) + printf( zPagedUsageExit, pOpts->pzPROGNAME ); + + else if (pOptDesc->pOptProc == optionLoadOpt) { + printf( zCmdFmt, "echo 'Warning: Cannot load options files' >&2" ); + printf( zCmdFmt, "OPT_ARG_NEEDED=YES" ); + + } else if (pOptDesc->pz_NAME == NULL) { + + if (pOptDesc->pOptProc == NULL) { + printf( zCmdFmt, "echo 'Warning: Cannot save options files' " + ">&2" ); + printf( zCmdFmt, "OPT_ARG_NEEDED=OK" ); + } else + printf( zTextExit, pOpts->pzPROGNAME, "LONGUSAGE" ); + + } else { + if (pOptDesc->optMaxCt == 1) + printf( zSingleArg, pOpts->pzPROGNAME, pOptDesc->pz_NAME ); + else { + if ((unsigned)pOptDesc->optMaxCt < NOLIMIT) + printf( zCountTest, pOpts->pzPROGNAME, + pOptDesc->pz_NAME, pOptDesc->optMaxCt ); + + printf( zMultiArg, pOpts->pzPROGNAME, pOptDesc->pz_NAME ); + } + + /* + * Fix up the args. + */ + if (OPTST_GET_ARGTYPE(pOptDesc->fOptState) == OPARG_TYPE_NONE) { + printf( zCantArg, pOpts->pzPROGNAME, pOptDesc->pz_NAME ); + + } else if (pOptDesc->fOptState & OPTST_ARG_OPTIONAL) { + printf( zMayArg, pOpts->pzPROGNAME, pOptDesc->pz_NAME ); + + } else { + fputs( zMustArg, stdout ); + } + } + fputs( zOptionEndSelect, stdout ); +} + + +static void +printOptionInaction( tOptions* pOpts, tOptDesc* pOptDesc ) +{ + if (pOptDesc->pOptProc == optionLoadOpt) { + printf( zCmdFmt, "echo 'Warning: Cannot suppress the loading of " + "options files' >&2" ); + + } else if (pOptDesc->optMaxCt == 1) + printf( zNoSingleArg, pOpts->pzPROGNAME, + pOptDesc->pz_NAME, pOptDesc->pz_DisablePfx ); + else + printf( zNoMultiArg, pOpts->pzPROGNAME, + pOptDesc->pz_NAME, pOptDesc->pz_DisablePfx ); + + printf( zCmdFmt, "OPT_ARG_NEEDED=NO" ); + fputs( zOptionEndSelect, stdout ); +} + + +static void +emitFlag( tOptions* pOpts ) +{ + tOptDesc* pOptDesc = pOpts->pOptDesc; + int optionCt = pOpts->optCt; + + fputs( zOptionCase, stdout ); + + for (;optionCt > 0; pOptDesc++, --optionCt) { + + if (SKIP_OPT(pOptDesc)) + continue; + + if (IS_GRAPHIC_CHAR(pOptDesc->optValue)) { + printf( zOptionFlag, pOptDesc->optValue ); + printOptionAction( pOpts, pOptDesc ); + } + } + printf( zOptionUnknown, "flag", pOpts->pzPROGNAME ); +} + + +/* + * Emit the match text for a long option + */ +static void +emitMatchExpr( tCC* pzMatchName, tOptDesc* pCurOpt, tOptions* pOpts ) +{ + tOptDesc* pOD = pOpts->pOptDesc; + int oCt = pOpts->optCt; + int min = 1; + char zName[ 256 ]; + char* pz = zName; + + for (;;) { + int matchCt = 0; + + /* + * Omit the current option, Documentation opts and compiled out opts. + */ + if ((pOD == pCurOpt) || SKIP_OPT(pOD)){ + if (--oCt <= 0) + break; + pOD++; + continue; + } + + /* + * Check each character of the name case insensitively. + * They must not be the same. They cannot be, because it would + * not compile correctly if they were. + */ + while ( toupper( pOD->pz_Name[matchCt] ) + == toupper( pzMatchName[matchCt] )) + matchCt++; + + if (matchCt > min) + min = matchCt; + + /* + * Check the disablement name, too. + */ + if (pOD->pz_DisableName != NULL) { + matchCt = 0; + while ( toupper( pOD->pz_DisableName[matchCt] ) + == toupper( pzMatchName[matchCt] )) + matchCt++; + if (matchCt > min) + min = matchCt; + } + if (--oCt <= 0) + break; + pOD++; + } + + /* + * IF the 'min' is all or one short of the name length, + * THEN the entire string must be matched. + */ + if ( (pzMatchName[min ] == NUL) + || (pzMatchName[min+1] == NUL) ) + printf( zOptionFullName, pzMatchName ); + + else { + int matchCt = 0; + for (; matchCt <= min; matchCt++) + *pz++ = pzMatchName[matchCt]; + + for (;;) { + *pz = NUL; + printf( zOptionPartName, zName ); + *pz++ = pzMatchName[matchCt++]; + if (pzMatchName[matchCt] == NUL) { + *pz = NUL; + printf( zOptionFullName, zName ); + break; + } + } + } +} + + +/* + * Emit GNU-standard long option handling code + */ +static void +emitLong( tOptions* pOpts ) +{ + tOptDesc* pOD = pOpts->pOptDesc; + int ct = pOpts->optCt; + + fputs( zOptionCase, stdout ); + + /* + * do each option, ... + */ + do { + /* + * Documentation & compiled-out options + */ + if (SKIP_OPT(pOD)) + continue; + + emitMatchExpr( pOD->pz_Name, pOD, pOpts ); + printOptionAction( pOpts, pOD ); + + /* + * Now, do the same thing for the disablement version of the option. + */ + if (pOD->pz_DisableName != NULL) { + emitMatchExpr( pOD->pz_DisableName, pOD, pOpts ); + printOptionInaction( pOpts, pOD ); + } + } while (pOD++, --ct > 0); + + printf( zOptionUnknown, "option", pOpts->pzPROGNAME ); +} + + +static void +openOutput( char const* pzFile ) +{ + FILE* fp; + char* pzData = NULL; + struct stat stbf; + + do { + char* pzScan; + size_t sizeLeft; + + /* + * IF we cannot stat the file, + * THEN assume we are creating a new file. + * Skip the loading of the old data. + */ + if (stat( pzFile, &stbf ) != 0) + break; + + /* + * The file must be a regular file + */ + if (! S_ISREG( stbf.st_mode )) { + fprintf( stderr, zNotFile, pzFile ); + exit( EXIT_FAILURE ); + } + + pzData = AGALOC(stbf.st_size + 1, "file data"); + fp = fopen( pzFile, "r" FOPEN_BINARY_FLAG ); + + sizeLeft = (unsigned)stbf.st_size; + pzScan = pzData; + + /* + * Read in all the data as fast as our OS will let us. + */ + for (;;) { + int inct = fread( (void*)pzScan, (size_t)1, sizeLeft, fp); + if (inct == 0) + break; + + pzScan += inct; + sizeLeft -= inct; + + if (sizeLeft == 0) + break; + } + + /* + * NUL-terminate the leader and look for the trailer + */ + *pzScan = '\0'; + fclose( fp ); + pzScan = strstr( pzData, zStartMarker ); + if (pzScan == NULL) { + pzTrailer = pzData; + break; + } + + *(pzScan++) = NUL; + pzScan = strstr( pzScan, zTrailerMarker ); + if (pzScan == NULL) { + pzTrailer = pzData; + break; + } + + /* + * Check to see if the data contains + * our marker. If it does, then we will skip over it + */ + pzTrailer = pzScan + sizeof( zTrailerMarker ) - 1; + pzLeader = pzData; + } while (AG_FALSE); + + freopen( pzFile, "w" FOPEN_BINARY_FLAG, stdout ); +} + + +/*=export_func genshelloptUsage + * private: + * what: The usage function for the genshellopt generated program + * + * arg: + tOptions* + pOpts + program options descriptor + + * arg: + int + exitCode + usage text type to produce + + * + * doc: + * This function is used to create the usage strings for the option + * processing shell script code. Two child processes are spawned + * each emitting the usage text in either the short (error exit) + * style or the long style. The generated program will capture this + * and create shell script variables containing the two types of text. +=*/ +void +genshelloptUsage( tOptions* pOpts, int exitCode ) +{ +#if defined(__windows__) && !defined(__CYGWIN__) + optionUsage( pOpts, exitCode ); +#else + /* + * IF not EXIT_SUCCESS, + * THEN emit the short form of usage. + */ + if (exitCode != EXIT_SUCCESS) + optionUsage( pOpts, exitCode ); + fflush( stderr ); + fflush( stdout ); + + option_usage_fp = stdout; + + /* + * First, print our usage + */ + switch (fork()) { + case -1: + optionUsage( pOpts, EXIT_FAILURE ); + /*NOTREACHED*/ + _exit( EXIT_FAILURE ); + + case 0: + pagerState = PAGER_STATE_CHILD; + optionUsage( pOpts, EXIT_SUCCESS ); + /*NOTREACHED*/ + _exit( EXIT_FAILURE ); + + default: + { + int sts; + wait( &sts ); + } + } + + /* + * Generate the pzProgName, since optionProcess() normally + * gets it from the command line + */ + { + char* pz; + AGDUPSTR( pz, pShellParseOptions->pzPROGNAME, "program name" ); + pShellParseOptions->pzProgName = pz; + while (*pz != NUL) { + *pz = tolower( *pz ); + pz++; + } + } + + /* + * Separate the makeshell usage from the client usage + */ + fprintf( option_usage_fp, zGenshell, pShellParseOptions->pzProgName ); + fflush( option_usage_fp ); + + /* + * Now, print the client usage. + */ + switch (fork()) { + case 0: + pagerState = PAGER_STATE_CHILD; + /*FALLTHROUGH*/ + case -1: + optionUsage( pShellParseOptions, EXIT_FAILURE ); + + default: + { + int sts; + wait( &sts ); + } + } + + exit( EXIT_SUCCESS ); +#endif +} + +/* + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of autoopts/makeshell.c */ diff --git a/libopts/nested.c b/libopts/nested.c new file mode 100644 index 0000000..43877d3 --- /dev/null +++ b/libopts/nested.c @@ -0,0 +1,843 @@ + +/* + * $Id: nested.c,v 4.32 2009/08/01 17:43:06 bkorb Exp $ + * Time-stamp: "2008-07-28 19:18:28 bkorb" + * + * Automated Options Nested Values module. + * + * This file is part of AutoOpts, a companion to AutoGen. + * AutoOpts is free software. + * AutoOpts is copyright (c) 1992-2009 by Bruce Korb - all rights reserved + * + * AutoOpts is available under any one of two licenses. The license + * in use must be one of these two and the choice is under the control + * of the user of the license. + * + * The GNU Lesser General Public License, version 3 or later + * See the files "COPYING.lgplv3" and "COPYING.gplv3" + * + * The Modified Berkeley Software Distribution License + * See the file "COPYING.mbsd" + * + * These files have the following md5sums: + * + * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 + * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 + * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + */ + +typedef struct { + int xml_ch; + int xml_len; + char xml_txt[8]; +} xml_xlate_t; + +static xml_xlate_t const xml_xlate[] = { + { '&', 4, "amp;" }, + { '<', 3, "lt;" }, + { '>', 3, "gt;" }, + { '"', 5, "quot;" }, + { '\'',5, "apos;" } +}; + +/* = = = START-STATIC-FORWARD = = = */ +/* static forward declarations maintained by mk-fwd */ +static void +removeLineContinue( char* pzSrc ); + +static char const* +scanQuotedString( char const* pzTxt ); + +static tOptionValue* +addStringValue( void** pp, char const* pzName, size_t nameLen, + char const* pzValue, size_t dataLen ); + +static tOptionValue* +addBoolValue( void** pp, char const* pzName, size_t nameLen, + char const* pzValue, size_t dataLen ); + +static tOptionValue* +addNumberValue( void** pp, char const* pzName, size_t nameLen, + char const* pzValue, size_t dataLen ); + +static tOptionValue* +addNestedValue( void** pp, char const* pzName, size_t nameLen, + char* pzValue, size_t dataLen ); + +static char const* +scanNameEntry(char const* pzName, tOptionValue* pRes); + +static char const* +scanXmlEntry( char const* pzName, tOptionValue* pRes ); + +static void +unloadNestedArglist( tArgList* pAL ); + +static void +sortNestedList( tArgList* pAL ); +/* = = = END-STATIC-FORWARD = = = */ + +/* removeLineContinue + * + * Backslashes are used for line continuations. We keep the newline + * characters, but trim out the backslash: + */ +static void +removeLineContinue( char* pzSrc ) +{ + char* pzD; + + do { + while (*pzSrc == '\n') pzSrc++; + pzD = strchr(pzSrc, '\n'); + if (pzD == NULL) + return; + + /* + * pzD has skipped at least one non-newline character and now + * points to a newline character. It now becomes the source and + * pzD goes to the previous character. + */ + pzSrc = pzD--; + if (*pzD != '\\') + pzD++; + } while (pzD == pzSrc); + + /* + * Start shifting text. + */ + for (;;) { + char ch = ((*pzD++) = *(pzSrc++)); + switch (ch) { + case NUL: return; + case '\\': + if (*pzSrc == '\n') + --pzD; /* rewrite on next iteration */ + } + } +} + + +/* scanQuotedString + * + * Find the end of a quoted string, skipping escaped quote characters. + */ +static char const* +scanQuotedString( char const* pzTxt ) +{ + char q = *(pzTxt++); /* remember the type of quote */ + + for (;;) { + char ch = *(pzTxt++); + if (ch == NUL) + return pzTxt-1; + + if (ch == q) + return pzTxt; + + if (ch == '\\') { + ch = *(pzTxt++); + /* + * IF the next character is NUL, drop the backslash, too. + */ + if (ch == NUL) + return pzTxt - 2; + + /* + * IF the quote character or the escape character were escaped, + * then skip both, as long as the string does not end. + */ + if ((ch == q) || (ch == '\\')) { + if (*(pzTxt++) == NUL) + return pzTxt-1; + } + } + } +} + + +/* addStringValue + * + * Associate a name with either a string or no value. + */ +static tOptionValue* +addStringValue( void** pp, char const* pzName, size_t nameLen, + char const* pzValue, size_t dataLen ) +{ + tOptionValue* pNV; + size_t sz = nameLen + dataLen + sizeof(*pNV); + + pNV = AGALOC( sz, "option name/str value pair" ); + if (pNV == NULL) + return NULL; + + if (pzValue == NULL) { + pNV->valType = OPARG_TYPE_NONE; + pNV->pzName = pNV->v.strVal; + + } else { + pNV->valType = OPARG_TYPE_STRING; + if (dataLen > 0) { + char const * pzSrc = pzValue; + char * pzDst = pNV->v.strVal; + int ct = dataLen; + do { + int ch = *(pzSrc++) & 0xFF; + if (ch == NUL) goto data_copy_done; + if (ch == '&') + ch = get_special_char(&pzSrc, &ct); + *(pzDst++) = ch; + } while (--ct > 0); + data_copy_done: + *pzDst = NUL; + + } else { + pNV->v.strVal[0] = NUL; + } + + pNV->pzName = pNV->v.strVal + dataLen + 1; + } + + memcpy( pNV->pzName, pzName, nameLen ); + pNV->pzName[ nameLen ] = NUL; + addArgListEntry( pp, pNV ); + return pNV; +} + + +/* addBoolValue + * + * Associate a name with either a string or no value. + */ +static tOptionValue* +addBoolValue( void** pp, char const* pzName, size_t nameLen, + char const* pzValue, size_t dataLen ) +{ + tOptionValue* pNV; + size_t sz = nameLen + sizeof(*pNV) + 1; + + pNV = AGALOC( sz, "option name/bool value pair" ); + if (pNV == NULL) + return NULL; + while (IS_WHITESPACE_CHAR(*pzValue) && (dataLen > 0)) { + dataLen--; pzValue++; + } + if (dataLen == 0) + pNV->v.boolVal = 0; + + else if (IS_DEC_DIGIT_CHAR(*pzValue)) + pNV->v.boolVal = atoi(pzValue); + + else pNV->v.boolVal = ! IS_FALSE_TYPE_CHAR(*pzValue); + + pNV->valType = OPARG_TYPE_BOOLEAN; + pNV->pzName = (char*)(pNV + 1); + memcpy( pNV->pzName, pzName, nameLen ); + pNV->pzName[ nameLen ] = NUL; + addArgListEntry( pp, pNV ); + return pNV; +} + + +/* addNumberValue + * + * Associate a name with either a string or no value. + */ +static tOptionValue* +addNumberValue( void** pp, char const* pzName, size_t nameLen, + char const* pzValue, size_t dataLen ) +{ + tOptionValue* pNV; + size_t sz = nameLen + sizeof(*pNV) + 1; + + pNV = AGALOC( sz, "option name/bool value pair" ); + if (pNV == NULL) + return NULL; + while (IS_WHITESPACE_CHAR(*pzValue) && (dataLen > 0)) { + dataLen--; pzValue++; + } + if (dataLen == 0) + pNV->v.longVal = 0; + else + pNV->v.longVal = strtol(pzValue, 0, 0); + + pNV->valType = OPARG_TYPE_NUMERIC; + pNV->pzName = (char*)(pNV + 1); + memcpy( pNV->pzName, pzName, nameLen ); + pNV->pzName[ nameLen ] = NUL; + addArgListEntry( pp, pNV ); + return pNV; +} + + +/* addNestedValue + * + * Associate a name with either a string or no value. + */ +static tOptionValue* +addNestedValue( void** pp, char const* pzName, size_t nameLen, + char* pzValue, size_t dataLen ) +{ + tOptionValue* pNV; + + if (dataLen == 0) { + size_t sz = nameLen + sizeof(*pNV) + 1; + pNV = AGALOC( sz, "empty nested value pair" ); + if (pNV == NULL) + return NULL; + pNV->v.nestVal = NULL; + pNV->valType = OPARG_TYPE_HIERARCHY; + pNV->pzName = (char*)(pNV + 1); + memcpy( pNV->pzName, pzName, nameLen ); + pNV->pzName[ nameLen ] = NUL; + + } else { + pNV = optionLoadNested( pzValue, pzName, nameLen ); + } + + if (pNV != NULL) + addArgListEntry( pp, pNV ); + + return pNV; +} + + +/* scanNameEntry + * + * We have an entry that starts with a name. Find the end of it, cook it + * (if called for) and create the name/value association. + */ +static char const* +scanNameEntry(char const* pzName, tOptionValue* pRes) +{ + tOptionValue* pNV; + char const * pzScan = pzName+1; /* we know first char is a name char */ + char const * pzVal; + size_t nameLen = 1; + size_t dataLen = 0; + + /* + * Scan over characters that name a value. These names may not end + * with a colon, but they may contain colons. + */ + while (IS_VALUE_NAME_CHAR(*pzScan)) { pzScan++; nameLen++; } + if (pzScan[-1] == ':') { pzScan--; nameLen--; } + while (IS_HORIZ_WHITE_CHAR(*pzScan)) pzScan++; + +re_switch: + switch (*pzScan) { + case '=': + case ':': + while (IS_HORIZ_WHITE_CHAR( (int)*++pzScan )) ; + if ((*pzScan == '=') || (*pzScan == ':')) + goto default_char; + goto re_switch; + + case '\n': + case ',': + pzScan++; + /* FALLTHROUGH */ + + case NUL: + addStringValue(&(pRes->v.nestVal), pzName, nameLen, NULL, (size_t)0); + break; + + case '"': + case '\'': + pzVal = pzScan; + pzScan = scanQuotedString( pzScan ); + dataLen = pzScan - pzVal; + pNV = addStringValue( &(pRes->v.nestVal), pzName, nameLen, pzVal, + dataLen ); + if ((pNV != NULL) && (option_load_mode == OPTION_LOAD_COOKED)) + ao_string_cook( pNV->v.strVal, NULL ); + break; + + default: + default_char: + /* + * We have found some strange text value. It ends with a newline + * or a comma. + */ + pzVal = pzScan; + for (;;) { + char ch = *(pzScan++); + switch (ch) { + case NUL: + pzScan--; + dataLen = pzScan - pzVal; + goto string_done; + /* FALLTHROUGH */ + + case '\n': + if ( (pzScan > pzVal + 2) + && (pzScan[-2] == '\\') + && (pzScan[ 0] != NUL)) + continue; + /* FALLTHROUGH */ + + case ',': + dataLen = (pzScan - pzVal) - 1; + string_done: + pNV = addStringValue( &(pRes->v.nestVal), pzName, nameLen, + pzVal, dataLen ); + if (pNV != NULL) + removeLineContinue( pNV->v.strVal ); + goto leave_scan_name; + } + } + break; + } leave_scan_name:; + + return pzScan; +} + + +/* scanXmlEntry + * + * We've found a '<' character. We ignore this if it is a comment or a + * directive. If it is something else, then whatever it is we are looking + * at is bogus. Returning NULL stops processing. + */ +static char const* +scanXmlEntry( char const* pzName, tOptionValue* pRes ) +{ + size_t nameLen = 1, valLen = 0; + char const* pzScan = ++pzName; + char const* pzVal; + tOptionValue valu; + tOptionValue* pNewVal; + tOptionLoadMode save_mode = option_load_mode; + + if (! IS_VAR_FIRST_CHAR(*pzName)) { + switch (*pzName) { + default: + pzName = NULL; + break; + + case '!': + pzName = strstr( pzName, "-->" ); + if (pzName != NULL) + pzName += 3; + break; + + case '?': + pzName = strchr( pzName, '>' ); + if (pzName != NULL) + pzName++; + break; + } + return pzName; + } + + pzScan++; + while (IS_VALUE_NAME_CHAR( (int)*pzScan )) { pzScan++; nameLen++; } + if (nameLen > 64) + return NULL; + valu.valType = OPARG_TYPE_STRING; + + switch (*pzScan) { + case ' ': + case '\t': + pzScan = parseAttributes( + NULL, (char*)pzScan, &option_load_mode, &valu ); + if (*pzScan == '>') { + pzScan++; + break; + } + + if (*pzScan != '/') { + option_load_mode = save_mode; + return NULL; + } + /* FALLTHROUGH */ + + case '/': + if (*++pzScan != '>') { + option_load_mode = save_mode; + return NULL; + } + addStringValue(&(pRes->v.nestVal), pzName, nameLen, NULL, (size_t)0); + option_load_mode = save_mode; + return pzScan+1; + + default: + option_load_mode = save_mode; + return NULL; + + case '>': + pzScan++; + break; + } + + pzVal = pzScan; + + { + char z[68]; + char* pzD = z; + int ct = nameLen; + char const* pzS = pzName; + + *(pzD++) = '<'; + *(pzD++) = '/'; + + do { + *(pzD++) = *(pzS++); + } while (--ct > 0); + *(pzD++) = '>'; + *pzD = NUL; + + pzScan = strstr( pzScan, z ); + if (pzScan == NULL) { + option_load_mode = save_mode; + return NULL; + } + valLen = (pzScan - pzVal); + pzScan += nameLen + 3; + while (IS_WHITESPACE_CHAR(*pzScan)) pzScan++; + } + + switch (valu.valType) { + case OPARG_TYPE_NONE: + addStringValue( &(pRes->v.nestVal), pzName, nameLen, NULL, (size_t)0); + break; + + case OPARG_TYPE_STRING: + pNewVal = addStringValue( + &(pRes->v.nestVal), pzName, nameLen, pzVal, valLen); + + if (option_load_mode == OPTION_LOAD_KEEP) + break; + mungeString( pNewVal->v.strVal, option_load_mode ); + break; + + case OPARG_TYPE_BOOLEAN: + addBoolValue( &(pRes->v.nestVal), pzName, nameLen, pzVal, valLen ); + break; + + case OPARG_TYPE_NUMERIC: + addNumberValue( &(pRes->v.nestVal), pzName, nameLen, pzVal, valLen ); + break; + + case OPARG_TYPE_HIERARCHY: + { + char* pz = AGALOC( valLen+1, "hierarchical scan" ); + if (pz == NULL) + break; + memcpy( pz, pzVal, valLen ); + pz[valLen] = NUL; + addNestedValue( &(pRes->v.nestVal), pzName, nameLen, pz, valLen ); + AGFREE(pz); + break; + } + + case OPARG_TYPE_ENUMERATION: + case OPARG_TYPE_MEMBERSHIP: + default: + break; + } + + option_load_mode = save_mode; + return pzScan; +} + + +/* unloadNestedArglist + * + * Deallocate a list of option arguments. This must have been gotten from + * a hierarchical option argument, not a stacked list of strings. It is + * an internal call, so it is not validated. The caller is responsible for + * knowing what they are doing. + */ +static void +unloadNestedArglist( tArgList* pAL ) +{ + int ct = pAL->useCt; + tCC** ppNV = pAL->apzArgs; + + while (ct-- > 0) { + tOptionValue* pNV = (tOptionValue*)(void*)*(ppNV++); + if (pNV->valType == OPARG_TYPE_HIERARCHY) + unloadNestedArglist( pNV->v.nestVal ); + AGFREE( pNV ); + } + + AGFREE( (void*)pAL ); +} + + +/*=export_func optionUnloadNested + * + * what: Deallocate the memory for a nested value + * arg: + tOptionValue const * + pOptVal + the hierarchical value + + * + * doc: + * A nested value needs to be deallocated. The pointer passed in should + * have been gotten from a call to @code{configFileLoad()} (See + * @pxref{libopts-configFileLoad}). +=*/ +void +optionUnloadNested( tOptionValue const * pOV ) +{ + if (pOV == NULL) return; + if (pOV->valType != OPARG_TYPE_HIERARCHY) { + errno = EINVAL; + return; + } + + unloadNestedArglist( pOV->v.nestVal ); + + AGFREE( (void*)pOV ); +} + + +/* sortNestedList + * + * This is a _stable_ sort. The entries are sorted alphabetically, + * but within entries of the same name the ordering is unchanged. + * Typically, we also hope the input is sorted. + */ +static void +sortNestedList( tArgList* pAL ) +{ + int ix; + int lm = pAL->useCt; + + /* + * This loop iterates "useCt" - 1 times. + */ + for (ix = 0; ++ix < lm;) { + int iy = ix-1; + tOptionValue* pNewNV = (tOptionValue*)(void*)(pAL->apzArgs[ix]); + tOptionValue* pOldNV = (tOptionValue*)(void*)(pAL->apzArgs[iy]); + + /* + * For as long as the new entry precedes the "old" entry, + * move the old pointer. Stop before trying to extract the + * "-1" entry. + */ + while (strcmp( pOldNV->pzName, pNewNV->pzName ) > 0) { + pAL->apzArgs[iy+1] = (void*)pOldNV; + pOldNV = (tOptionValue*)(void*)(pAL->apzArgs[--iy]); + if (iy < 0) + break; + } + + /* + * Always store the pointer. Sometimes it is redundant, + * but the redundancy is cheaper than a test and branch sequence. + */ + pAL->apzArgs[iy+1] = (void*)pNewNV; + } +} + + +/* optionLoadNested + * private: + * + * what: parse a hierarchical option argument + * arg: + char const* + pzTxt + the text to scan + + * arg: + char const* + pzName + the name for the text + + * arg: + size_t + nameLen + the length of "name" + + * + * ret_type: tOptionValue* + * ret_desc: An allocated, compound value structure + * + * doc: + * A block of text represents a series of values. It may be an + * entire configuration file, or it may be an argument to an + * option that takes a hierarchical value. + */ +LOCAL tOptionValue* +optionLoadNested(char const* pzTxt, char const* pzName, size_t nameLen) +{ + tOptionValue* pRes; + tArgList* pAL; + + /* + * Make sure we have some data and we have space to put what we find. + */ + if (pzTxt == NULL) { + errno = EINVAL; + return NULL; + } + while (IS_WHITESPACE_CHAR(*pzTxt)) pzTxt++; + if (*pzTxt == NUL) { + errno = ENOENT; + return NULL; + } + pRes = AGALOC( sizeof(*pRes) + nameLen + 1, "nested args" ); + if (pRes == NULL) { + errno = ENOMEM; + return NULL; + } + pRes->valType = OPARG_TYPE_HIERARCHY; + pRes->pzName = (char*)(pRes + 1); + memcpy( pRes->pzName, pzName, nameLen ); + pRes->pzName[ nameLen ] = NUL; + + pAL = AGALOC( sizeof(*pAL), "nested arg list" ); + if (pAL == NULL) { + AGFREE( pRes ); + return NULL; + } + pRes->v.nestVal = pAL; + pAL->useCt = 0; + pAL->allocCt = MIN_ARG_ALLOC_CT; + + /* + * Scan until we hit a NUL. + */ + do { + while (IS_WHITESPACE_CHAR( (int)*pzTxt )) pzTxt++; + if (IS_VAR_FIRST_CHAR( (int)*pzTxt )) { + pzTxt = scanNameEntry( pzTxt, pRes ); + } + else switch (*pzTxt) { + case NUL: goto scan_done; + case '<': pzTxt = scanXmlEntry( pzTxt, pRes ); + if (pzTxt == NULL) goto woops; + if (*pzTxt == ',') pzTxt++; break; + case '#': pzTxt = strchr( pzTxt, '\n' ); break; + default: goto woops; + } + } while (pzTxt != NULL); scan_done:; + + pAL = pRes->v.nestVal; + if (pAL->useCt != 0) { + sortNestedList( pAL ); + return pRes; + } + + woops: + AGFREE( pRes->v.nestVal ); + AGFREE( pRes ); + return NULL; +} + + +/*=export_func optionNestedVal + * private: + * + * what: parse a hierarchical option argument + * arg: + tOptions* + pOpts + program options descriptor + + * arg: + tOptDesc* + pOptDesc + the descriptor for this arg + + * + * doc: + * Nested value was found on the command line +=*/ +void +optionNestedVal(tOptions* pOpts, tOptDesc* pOD) +{ + if (pOpts < OPTPROC_EMIT_LIMIT) + return; + + if (pOD->fOptState & OPTST_RESET) { + tArgList* pAL = pOD->optCookie; + int ct; + tCC ** av; + + if (pAL == NULL) + return; + ct = pAL->useCt; + av = pAL->apzArgs; + + while (--ct >= 0) { + void * p = (void *)*(av++); + optionUnloadNested((tOptionValue const *)p); + } + + AGFREE(pOD->optCookie); + + } else { + tOptionValue* pOV = optionLoadNested( + pOD->optArg.argString, pOD->pz_Name, strlen(pOD->pz_Name)); + + if (pOV != NULL) + addArgListEntry( &(pOD->optCookie), (void*)pOV ); + } +} + + +/* + * get_special_char + */ +LOCAL int +get_special_char(char const ** ppz, int * ct) +{ + char const * pz = *ppz; + + if (*ct < 3) + return '&'; + + if (*pz == '#') { + int base = 10; + int retch; + + pz++; + if (*pz == 'x') { + base = 16; + pz++; + } + retch = (int)strtoul(pz, (char **)&pz, base); + if (*pz != ';') + return '&'; + base = ++pz - *ppz; + if (base > *ct) + return '&'; + + *ct -= base; + *ppz = pz; + return retch; + } + + { + int ctr = sizeof(xml_xlate) / sizeof(xml_xlate[0]); + xml_xlate_t const * xlatp = xml_xlate; + + for (;;) { + if ( (*ct >= xlatp->xml_len) + && (strncmp(pz, xlatp->xml_txt, xlatp->xml_len) == 0)) { + *ppz += xlatp->xml_len; + *ct -= xlatp->xml_len; + return xlatp->xml_ch; + } + + if (--ctr <= 0) + break; + xlatp++; + } + } + return '&'; +} + + +/* + * emit_special_char + */ +LOCAL void +emit_special_char(FILE * fp, int ch) +{ + int ctr = sizeof(xml_xlate) / sizeof(xml_xlate[0]); + xml_xlate_t const * xlatp = xml_xlate; + + putc('&', fp); + for (;;) { + if (ch == xlatp->xml_ch) { + fputs(xlatp->xml_txt, fp); + return; + } + if (--ctr <= 0) + break; + xlatp++; + } + fprintf(fp, "#x%02X;", (ch & 0xFF)); +} + +/* + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of autoopts/nested.c */ diff --git a/libopts/numeric.c b/libopts/numeric.c new file mode 100644 index 0000000..52d772d --- /dev/null +++ b/libopts/numeric.c @@ -0,0 +1,176 @@ + +/* + * $Id: numeric.c,v 4.22 2009/08/01 17:43:06 bkorb Exp $ + * Time-stamp: "2009-07-23 17:25:39 bkorb" + * + * This file is part of AutoOpts, a companion to AutoGen. + * AutoOpts is free software. + * AutoOpts is copyright (c) 1992-2009 by Bruce Korb - all rights reserved + * + * AutoOpts is available under any one of two licenses. The license + * in use must be one of these two and the choice is under the control + * of the user of the license. + * + * The GNU Lesser General Public License, version 3 or later + * See the files "COPYING.lgplv3" and "COPYING.gplv3" + * + * The Modified Berkeley Software Distribution License + * See the file "COPYING.mbsd" + * + * These files have the following md5sums: + * + * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 + * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 + * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + */ + +/*=export_func optionShowRange + * private: + * + * what: + * arg: + tOptions* + pOpts + program options descriptor + + * arg: + tOptDesc* + pOptDesc + the descriptor for this arg + + * arg: + void * + rng_table + the value range tables + + * arg: + int + rng_count + the number of entries + + * + * doc: + * Show information about a numeric option with range constraints. +=*/ +void +optionShowRange(tOptions* pOpts, tOptDesc* pOD, void * rng_table, int rng_ct) +{ + static char const bullet[] = "\t\t\t\t- "; + static char const deepin[] = "\t\t\t\t "; + static char const onetab[] = "\t"; + + const struct {long const rmin, rmax;} * rng = rng_table; + + char const * pz_indent = + (pOpts != OPTPROC_EMIT_USAGE) ? onetab : bullet; + + if ((pOpts == OPTPROC_EMIT_USAGE) || (pOpts > OPTPROC_EMIT_LIMIT)) { + char const * lie_in_range = zRangeLie; + + if (pOpts > OPTPROC_EMIT_LIMIT) { + fprintf(option_usage_fp, zRangeErr, + pOpts->pzProgName, pOD->pz_Name, pOD->optArg.argString); + fprintf(option_usage_fp, "The %s option:\n", pOD->pz_Name); + lie_in_range = zRangeBadLie; + pz_indent = ""; + } + + if (pOD->fOptState & OPTST_SCALED_NUM) + fprintf(option_usage_fp, zRangeScaled, pz_indent); + + if (rng_ct > 1) { + fprintf(option_usage_fp, lie_in_range, pz_indent); + pz_indent = + (pOpts != OPTPROC_EMIT_USAGE) ? onetab : deepin; + + } else { + fprintf(option_usage_fp, zRangeOnly, pz_indent); + pz_indent = onetab + 1; /* empty string */ + } + + for (;;) { + if (rng->rmax == LONG_MIN) + fprintf(option_usage_fp, zRangeExact, pz_indent, rng->rmin); + else if (rng->rmin == LONG_MIN) + fprintf(option_usage_fp, zRangeUpto, pz_indent, rng->rmax); + else if (rng->rmax == LONG_MAX) + fprintf(option_usage_fp, zRangeAbove, pz_indent, rng->rmin); + else + fprintf(option_usage_fp, zRange, pz_indent, rng->rmin, + rng->rmax); + + if (--rng_ct <= 0) { + fputc('\n', option_usage_fp); + break; + } + fputs(zRangeOr, option_usage_fp); + rng++; + pz_indent = + (pOpts != OPTPROC_EMIT_USAGE) ? onetab : deepin; + } + + if (pOpts > OPTPROC_EMIT_LIMIT) + pOpts->pUsageProc(pOpts, EXIT_FAILURE); + } +} + + +/*=export_func optionNumericVal + * private: + * + * what: process an option with a numeric value. + * arg: + tOptions* + pOpts + program options descriptor + + * arg: + tOptDesc* + pOptDesc + the descriptor for this arg + + * + * doc: + * Decipher a numeric value. +=*/ +void +optionNumericVal(tOptions* pOpts, tOptDesc* pOD ) +{ + char* pz; + long val; + + /* + * Numeric options may have a range associated with it. + * If it does, the usage procedure requests that it be + * emitted by passing a NULL pOD pointer. Also bail out + * if there is no option argument or if we are being reset. + */ + if ( (pOD == NULL) + || (pOD->optArg.argString == NULL) + || ((pOD->fOptState & OPTST_RESET) != 0)) + return; + + errno = 0; + val = strtol(pOD->optArg.argString, &pz, 0); + if ((pz == pOD->optArg.argString) || (errno != 0)) + goto bad_number; + + if ((pOD->fOptState & OPTST_SCALED_NUM) != 0) + switch (*(pz++)) { + case '\0': pz--; break; + case 't': val *= 1000; + case 'g': val *= 1000; + case 'm': val *= 1000; + case 'k': val *= 1000; break; + + case 'T': val *= 1024; + case 'G': val *= 1024; + case 'M': val *= 1024; + case 'K': val *= 1024; break; + + default: goto bad_number; + } + + if (*pz != NUL) + goto bad_number; + + if (pOD->fOptState & OPTST_ALLOC_ARG) { + AGFREE(pOD->optArg.argString); + pOD->fOptState &= ~OPTST_ALLOC_ARG; + } + + pOD->optArg.argInt = val; + return; + + bad_number: + + fprintf( stderr, zNotNumber, pOpts->pzProgName, pOD->optArg.argString ); + if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0) + (*(pOpts->pUsageProc))(pOpts, EXIT_FAILURE); + + pOD->optArg.argInt = ~0; +} + +/* + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of autoopts/numeric.c */ diff --git a/libopts/parse-duration.c b/libopts/parse-duration.c new file mode 100644 index 0000000..6487ba0 --- /dev/null +++ b/libopts/parse-duration.c @@ -0,0 +1,582 @@ +/* Parse a time duration and return a seconds count + Copyright (C) 2008 Free Software Foundation, Inc. + Written by Bruce Korb , 2008. + + 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 + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + 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 . */ + +#include + +#include +#include +#include +#include +#include +#include + +#include "parse-duration.h" + +#ifndef _ +#define _(_s) _s +#endif + +#ifndef NUL +#define NUL '\0' +#endif + +#define cch_t char const + +typedef enum { + NOTHING_IS_DONE, + YEAR_IS_DONE, + MONTH_IS_DONE, + WEEK_IS_DONE, + DAY_IS_DONE, + HOUR_IS_DONE, + MINUTE_IS_DONE, + SECOND_IS_DONE +} whats_done_t; + +#define SEC_PER_MIN 60 +#define SEC_PER_HR (SEC_PER_MIN * 60) +#define SEC_PER_DAY (SEC_PER_HR * 24) +#define SEC_PER_WEEK (SEC_PER_DAY * 7) +#define SEC_PER_MONTH (SEC_PER_DAY * 30) +#define SEC_PER_YEAR (SEC_PER_DAY * 365) + +#define TIME_MAX 0x7FFFFFFF + +static unsigned long inline +str_const_to_ul (cch_t * str, cch_t ** ppz, int base) +{ + return strtoul (str, (char **)ppz, base); +} + +static long inline +str_const_to_l (cch_t * str, cch_t ** ppz, int base) +{ + return strtol (str, (char **)ppz, base); +} + +static time_t inline +scale_n_add (time_t base, time_t val, int scale) +{ + if (base == BAD_TIME) + { + if (errno == 0) + errno = EINVAL; + return BAD_TIME; + } + + if (val > TIME_MAX / scale) + { + errno = ERANGE; + return BAD_TIME; + } + + val *= scale; + if (base > TIME_MAX - val) + { + errno = ERANGE; + return BAD_TIME; + } + + return base + val; +} + +static time_t +parse_hr_min_sec (time_t start, cch_t * pz) +{ + int lpct = 0; + + errno = 0; + + /* For as long as our scanner pointer points to a colon *AND* + we've not looped before, then keep looping. (two iterations max) */ + while ((*pz == ':') && (lpct++ <= 1)) + { + unsigned long v = str_const_to_ul (pz+1, &pz, 10); + + if (errno != 0) + return BAD_TIME; + + start = scale_n_add (v, start, 60); + + if (errno != 0) + return BAD_TIME; + } + + /* allow for trailing spaces */ + while (isspace ((unsigned char)*pz)) pz++; + if (*pz != NUL) + { + errno = EINVAL; + return BAD_TIME; + } + + return start; +} + +static time_t +parse_scaled_value (time_t base, cch_t ** ppz, cch_t * endp, int scale) +{ + cch_t * pz = *ppz; + time_t val; + + if (base == BAD_TIME) + return base; + + errno = 0; + val = str_const_to_ul (pz, &pz, 10); + if (errno != 0) + return BAD_TIME; + while (isspace ((unsigned char)*pz)) pz++; + if (pz != endp) + { + errno = EINVAL; + return BAD_TIME; + } + + *ppz = pz; + return scale_n_add (base, val, scale); +} + +static time_t +parse_year_month_day (cch_t * pz, cch_t * ps) +{ + time_t res = 0; + + res = parse_scaled_value (0, &pz, ps, SEC_PER_YEAR); + + ps = strchr (++pz, '-'); + if (ps == NULL) + { + errno = EINVAL; + return BAD_TIME; + } + res = parse_scaled_value (res, &pz, ps, SEC_PER_MONTH); + + pz++; + ps = pz + strlen (pz); + return parse_scaled_value (res, &pz, ps, SEC_PER_DAY); +} + +static time_t +parse_yearmonthday (cch_t * in_pz) +{ + time_t res = 0; + char buf[8]; + cch_t * pz; + + if (strlen (in_pz) != 8) + { + errno = EINVAL; + return BAD_TIME; + } + + memcpy (buf, in_pz, 4); + buf[4] = NUL; + pz = buf; + res = parse_scaled_value (0, &pz, buf + 4, SEC_PER_YEAR); + + memcpy (buf, in_pz + 4, 2); + buf[2] = NUL; + pz = buf; + res = parse_scaled_value (res, &pz, buf + 2, SEC_PER_MONTH); + + memcpy (buf, in_pz + 6, 2); + buf[2] = NUL; + pz = buf; + return parse_scaled_value (res, &pz, buf + 2, SEC_PER_DAY); +} + +static time_t +parse_YMWD (cch_t * pz) +{ + time_t res = 0; + cch_t * ps = strchr (pz, 'Y'); + if (ps != NULL) + { + res = parse_scaled_value (0, &pz, ps, SEC_PER_YEAR); + pz++; + } + + ps = strchr (pz, 'M'); + if (ps != NULL) + { + res = parse_scaled_value (res, &pz, ps, SEC_PER_MONTH); + pz++; + } + + ps = strchr (pz, 'W'); + if (ps != NULL) + { + res = parse_scaled_value (res, &pz, ps, SEC_PER_WEEK); + pz++; + } + + ps = strchr (pz, 'D'); + if (ps != NULL) + { + res = parse_scaled_value (res, &pz, ps, SEC_PER_DAY); + pz++; + } + + while (isspace ((unsigned char)*pz)) pz++; + if (*pz != NUL) + { + errno = EINVAL; + return BAD_TIME; + } + + return res; +} + +static time_t +parse_hour_minute_second (cch_t * pz, cch_t * ps) +{ + time_t res = 0; + + res = parse_scaled_value (0, &pz, ps, SEC_PER_HR); + + ps = strchr (++pz, ':'); + if (ps == NULL) + { + errno = EINVAL; + return BAD_TIME; + } + + res = parse_scaled_value (res, &pz, ps, SEC_PER_MIN); + + pz++; + ps = pz + strlen (pz); + return parse_scaled_value (res, &pz, ps, 1); +} + +static time_t +parse_hourminutesecond (cch_t * in_pz) +{ + time_t res = 0; + char buf[4]; + cch_t * pz; + + if (strlen (in_pz) != 6) + { + errno = EINVAL; + return BAD_TIME; + } + + memcpy (buf, in_pz, 2); + buf[2] = NUL; + pz = buf; + res = parse_scaled_value (0, &pz, buf + 2, SEC_PER_HR); + + memcpy (buf, in_pz + 2, 2); + buf[2] = NUL; + pz = buf; + res = parse_scaled_value (res, &pz, buf + 2, SEC_PER_MIN); + + memcpy (buf, in_pz + 4, 2); + buf[2] = NUL; + pz = buf; + return parse_scaled_value (res, &pz, buf + 2, 1); +} + +static time_t +parse_HMS (cch_t * pz) +{ + time_t res = 0; + cch_t * ps = strchr (pz, 'H'); + if (ps != NULL) + { + res = parse_scaled_value (0, &pz, ps, SEC_PER_HR); + pz++; + } + + ps = strchr (pz, 'M'); + if (ps != NULL) + { + res = parse_scaled_value (res, &pz, ps, SEC_PER_MIN); + pz++; + } + + ps = strchr (pz, 'S'); + if (ps != NULL) + { + res = parse_scaled_value (res, &pz, ps, 1); + pz++; + } + + while (isspace ((unsigned char)*pz)) pz++; + if (*pz != NUL) + { + errno = EINVAL; + return BAD_TIME; + } + + return res; +} + +static time_t +parse_time (cch_t * pz) +{ + cch_t * ps; + time_t res = 0; + + /* + * Scan for a hyphen + */ + ps = strchr (pz, ':'); + if (ps != NULL) + { + res = parse_hour_minute_second (pz, ps); + } + + /* + * Try for a 'H', 'M' or 'S' suffix + */ + else if (ps = strpbrk (pz, "HMS"), + ps == NULL) + { + /* Its a YYYYMMDD format: */ + res = parse_hourminutesecond (pz); + } + + else + res = parse_HMS (pz); + + return res; +} + +static char * +trim(char * pz) +{ + /* trim leading white space */ + while (isspace ((unsigned char)*pz)) pz++; + + /* trim trailing white space */ + { + char * pe = pz + strlen (pz); + while ((pe > pz) && isspace ((unsigned char)pe[-1])) pe--; + *pe = NUL; + } + + return pz; +} + +/* + * Parse the year/months/days of a time period + */ +static time_t +parse_period (cch_t * in_pz) +{ + char * pz = xstrdup (in_pz); + char * pT = strchr (pz, 'T'); + char * ps; + void * fptr = pz; + time_t res = 0; + + if (pT != NUL) + { + *(pT++) = NUL; + pz = trim (pz); + pT = trim (pT); + } + + /* + * Scan for a hyphen + */ + ps = strchr (pz, '-'); + if (ps != NULL) + { + res = parse_year_month_day (pz, ps); + } + + /* + * Try for a 'Y', 'M' or 'D' suffix + */ + else if (ps = strpbrk (pz, "YMWD"), + ps == NULL) + { + /* Its a YYYYMMDD format: */ + res = parse_yearmonthday (pz); + } + + else + res = parse_YMWD (pz); + + if ((errno == 0) && (pT != NULL)) + { + time_t val = parse_time (pT); + res = scale_n_add (res, val, 1); + } + + free (fptr); + return res; +} + +static time_t +parse_non_iso8601(cch_t * pz) +{ + whats_done_t whatd_we_do = NOTHING_IS_DONE; + + time_t res = 0; + + do { + time_t val; + + errno = 0; + val = str_const_to_l (pz, &pz, 10); + if (errno != 0) + goto bad_time; + + /* IF we find a colon, then we're going to have a seconds value. + We will not loop here any more. We cannot already have parsed + a minute value and if we've parsed an hour value, then the result + value has to be less than an hour. */ + if (*pz == ':') + { + if (whatd_we_do >= MINUTE_IS_DONE) + break; + + val = parse_hr_min_sec (val, pz); + + if ((whatd_we_do == HOUR_IS_DONE) && (val >= SEC_PER_HR)) + break; + + return scale_n_add (res, val, 1); + } + + { + unsigned int mult; + + /* Skip over white space following the number we just parsed. */ + while (isspace ((unsigned char)*pz)) pz++; + + switch (*pz) + { + default: goto bad_time; + case NUL: + return scale_n_add (res, val, 1); + + case 'y': case 'Y': + if (whatd_we_do >= YEAR_IS_DONE) + goto bad_time; + mult = SEC_PER_YEAR; + whatd_we_do = YEAR_IS_DONE; + break; + + case 'M': + if (whatd_we_do >= MONTH_IS_DONE) + goto bad_time; + mult = SEC_PER_MONTH; + whatd_we_do = MONTH_IS_DONE; + break; + + case 'W': + if (whatd_we_do >= WEEK_IS_DONE) + goto bad_time; + mult = SEC_PER_WEEK; + whatd_we_do = WEEK_IS_DONE; + break; + + case 'd': case 'D': + if (whatd_we_do >= DAY_IS_DONE) + goto bad_time; + mult = SEC_PER_DAY; + whatd_we_do = DAY_IS_DONE; + break; + + case 'h': + if (whatd_we_do >= HOUR_IS_DONE) + goto bad_time; + mult = SEC_PER_HR; + whatd_we_do = HOUR_IS_DONE; + break; + + case 'm': + if (whatd_we_do >= MINUTE_IS_DONE) + goto bad_time; + mult = SEC_PER_MIN; + whatd_we_do = MINUTE_IS_DONE; + break; + + case 's': + mult = 1; + whatd_we_do = SECOND_IS_DONE; + break; + } + + res = scale_n_add (res, val, mult); + + while (isspace ((unsigned char)*++pz)) ; + if (*pz == NUL) + return res; + + if (! isdigit ((unsigned char)*pz)) + break; + } + + } while (whatd_we_do < SECOND_IS_DONE); + + bad_time: + errno = EINVAL; + return BAD_TIME; +} + +time_t +parse_duration (char const * pz) +{ + time_t res = 0; + + while (isspace ((unsigned char)*pz)) pz++; + + do { + if (*pz == 'P') + { + res = parse_period (pz + 1); + if ((errno != 0) || (res == BAD_TIME)) + break; + return res; + } + + if (*pz == 'T') + { + res = parse_time (pz + 1); + if ((errno != 0) || (res == BAD_TIME)) + break; + return res; + } + + if (! isdigit ((unsigned char)*pz)) + break; + + res = parse_non_iso8601 (pz); + if ((errno == 0) && (res != BAD_TIME)) + return res; + + } while (0); + + fprintf (stderr, _("Invalid time duration: %s\n"), pz); + if (errno == 0) + errno = EINVAL; + return BAD_TIME; +} + +/* + * Local Variables: + * mode: C + * c-file-style: "gnu" + * indent-tabs-mode: nil + * End: + * end of parse-duration.c */ diff --git a/libopts/parse-duration.h b/libopts/parse-duration.h new file mode 100644 index 0000000..7ecc7db --- /dev/null +++ b/libopts/parse-duration.h @@ -0,0 +1,82 @@ +/* Parse a time duration and return a seconds count + Copyright (C) 2008 Free Software Foundation, Inc. + Written by Bruce Korb , 2008. + + 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 + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + 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 . */ + +/* + + Readers and users of this function are referred to the ISO-8601 + specification, with particular attention to "Durations". + + At the time of writing, this worked: + + http://en.wikipedia.org/wiki/ISO_8601#Durations + + The string must start with a 'P', 'T' or a digit. + + ==== if it is a digit + + the string may contain: NNN d NNN h NNN m NNN s + This represents NNN days, NNN hours, NNN minutes and NNN seconds. + The embeded white space is optional. + These terms must appear in this order. + The final "s" is optional. + All of the terms ("NNN" plus designator) are optional. + Minutes and seconds may optionally be represented as NNN:NNN. + Also, hours, minute and seconds may be represented as NNN:NNN:NNN. + There is no limitation on the value of any of the terms, except + that the final result must fit in a time_t value. + + ==== if it is a 'P' or 'T', please see ISO-8601 for a rigorous definition. + + The 'P' term may be followed by any of three formats: + yyyymmdd + yy-mm-dd + yy Y mm M ww W dd D + + or it may be empty and followed by a 'T'. The "yyyymmdd" must be eight + digits long. Note: months are always 30 days and years are always 365 + days long. 5 years is always 1825, not 1826 or 1827 depending on leap + year considerations. 3 months is always 90 days. There is no consideration + for how many days are in the current, next or previous months. + + For the final format: + * Embedded white space is allowed, but it is optional. + * All of the terms are optional. Any or all-but-one may be omitted. + * The meanings are yy years, mm months, ww weeks and dd days. + * The terms must appear in this order. + + ==== The 'T' term may be followed by any of these formats: + + hhmmss + hh:mm:ss + hh H mm M ss S + + For the final format: + * Embedded white space is allowed, but it is optional. + * All of the terms are optional. Any or all-but-one may be omitted. + * The terms must appear in this order. + + */ +#ifndef GNULIB_PARSE_DURATION_H +#define GNULIB_PARSE_DURATION_H + +#include + +#define BAD_TIME ((time_t)~0) + +extern time_t parse_duration(char const * in_pz); + +#endif /* GNULIB_PARSE_DURATION_H */ diff --git a/libopts/pgusage.c b/libopts/pgusage.c new file mode 100644 index 0000000..d19a529 --- /dev/null +++ b/libopts/pgusage.c @@ -0,0 +1,140 @@ + +/* + * $Id: pgusage.c,v 4.18 2009/08/01 17:43:06 bkorb Exp $ + * Time-stamp: "2008-07-27 21:08:42 bkorb" + * + * Automated Options Paged Usage module. + * + * This routine will run run-on options through a pager so the + * user may examine, print or edit them at their leisure. + * + * This file is part of AutoOpts, a companion to AutoGen. + * AutoOpts is free software. + * AutoOpts is copyright (c) 1992-2009 by Bruce Korb - all rights reserved + * + * AutoOpts is available under any one of two licenses. The license + * in use must be one of these two and the choice is under the control + * of the user of the license. + * + * The GNU Lesser General Public License, version 3 or later + * See the files "COPYING.lgplv3" and "COPYING.gplv3" + * + * The Modified Berkeley Software Distribution License + * See the file "COPYING.mbsd" + * + * These files have the following md5sums: + * + * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 + * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 + * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + */ + +tePagerState pagerState = PAGER_STATE_INITIAL; + +/*=export_func optionPagedUsage + * private: + * + * what: Decipher a boolean value + * arg: + tOptions* + pOpts + program options descriptor + + * arg: + tOptDesc* + pOptDesc + the descriptor for this arg + + * + * doc: + * Run the usage output through a pager. + * This is very handy if it is very long. +=*/ +void +optionPagedUsage( tOptions* pOptions, tOptDesc* pOD ) +{ +#if defined(__windows__) && !defined(__CYGWIN__) + if ((pOD->fOptState & OPTST_RESET) != 0) + return; + + (*pOptions->pUsageProc)( pOptions, EXIT_SUCCESS ); +#else + static pid_t my_pid; + char zPageUsage[ 1024 ]; + + /* + * IF we are being called after the usage proc is done + * (and thus has called "exit(2)") + * THEN invoke the pager to page through the usage file we created. + */ + switch (pagerState) { + case PAGER_STATE_INITIAL: + { + if ((pOD->fOptState & OPTST_RESET) != 0) + return; + + my_pid = getpid(); +#ifdef HAVE_SNPRINTF + snprintf(zPageUsage, sizeof(zPageUsage), "/tmp/use.%lu", (tAoUL)my_pid); +#else + sprintf( zPageUsage, "/tmp/use.%lu", (tAoUL)my_pid ); +#endif + unlink( zPageUsage ); + + /* + * Set usage output to this temporary file + */ + option_usage_fp = fopen( zPageUsage, "w" FOPEN_BINARY_FLAG ); + if (option_usage_fp == NULL) + _exit( EXIT_FAILURE ); + + pagerState = PAGER_STATE_READY; + + /* + * Set up so this routine gets called during the exit logic + */ + atexit( (void(*)(void))optionPagedUsage ); + + /* + * The usage procedure will now put the usage information into + * the temporary file we created above. + */ + (*pOptions->pUsageProc)( pOptions, EXIT_SUCCESS ); + + /*NOTREACHED*/ + _exit( EXIT_FAILURE ); + } + + case PAGER_STATE_READY: + { + tSCC zPage[] = "%1$s /tmp/use.%2$lu ; rm -f /tmp/use.%2$lu"; + tCC* pzPager = (tCC*)getenv( "PAGER" ); + + /* + * Use the "more(1)" program if "PAGER" has not been defined + */ + if (pzPager == NULL) + pzPager = "more"; + + /* + * Page the file and remove it when done. + */ +#ifdef HAVE_SNPRINTF + snprintf(zPageUsage, sizeof(zPageUsage), zPage, pzPager, (tAoUL)my_pid); +#else + sprintf( zPageUsage, zPage, pzPager, (tAoUL)my_pid ); +#endif + fclose( stderr ); + dup2( STDOUT_FILENO, STDERR_FILENO ); + + (void)system( zPageUsage ); + } + + case PAGER_STATE_CHILD: + /* + * This is a child process used in creating shell script usage. + */ + break; + } +#endif +} + +/* + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of autoopts/pgusage.c */ diff --git a/libopts/proto.h b/libopts/proto.h new file mode 100644 index 0000000..e8c4804 --- /dev/null +++ b/libopts/proto.h @@ -0,0 +1,112 @@ +/* -*- buffer-read-only: t -*- vi: set ro: + * + * Prototypes for autoopts + * Generated Sat Aug 8 10:14:45 PDT 2009 + */ +#ifndef AUTOOPTS_PROTO_H_GUARD +#define AUTOOPTS_PROTO_H_GUARD 1 + +#ifndef LOCAL +# define LOCAL extern +# define REDEF_LOCAL 1 +#else +# undef REDEF_LOCAL +#endif +/* + * Extracted from autoopts.c + */ +LOCAL void * +ao_malloc( size_t sz ); + +LOCAL void * +ao_realloc( void *p, size_t sz ); + +LOCAL void +ao_free( void *p ); + +LOCAL char * +ao_strdup( char const *str ); + +LOCAL tSuccess +handleOption( tOptions* pOpts, tOptState* pOptState ); + +LOCAL tSuccess +longOptionFind( tOptions* pOpts, char* pzOptName, tOptState* pOptState ); + +LOCAL tSuccess +shortOptionFind( tOptions* pOpts, uint_t optValue, tOptState* pOptState ); + +LOCAL tSuccess +doImmediateOpts( tOptions* pOpts ); + +LOCAL tSuccess +doRegularOpts( tOptions* pOpts ); + +/* + * Extracted from configfile.c + */ +LOCAL void +internalFileLoad( tOptions* pOpts ); + +LOCAL char* +parseAttributes( + tOptions* pOpts, + char* pzText, + tOptionLoadMode* pMode, + tOptionValue* pType ); + +LOCAL tSuccess +validateOptionsStruct( tOptions* pOpts, char const* pzProgram ); + +/* + * Extracted from environment.c + */ +LOCAL void +doPrognameEnv( tOptions* pOpts, teEnvPresetType type ); + +LOCAL void +doEnvPresets( tOptions* pOpts, teEnvPresetType type ); + +/* + * Extracted from load.c + */ +LOCAL void +mungeString( char* pzTxt, tOptionLoadMode mode ); + +LOCAL void +loadOptionLine( + tOptions* pOpts, + tOptState* pOS, + char* pzLine, + tDirection direction, + tOptionLoadMode load_mode ); + +/* + * Extracted from nested.c + */ +LOCAL tOptionValue* +optionLoadNested(char const* pzTxt, char const* pzName, size_t nameLen); + +LOCAL int +get_special_char(char const ** ppz, int * ct); + +LOCAL void +emit_special_char(FILE * fp, int ch); + +/* + * Extracted from sort.c + */ +LOCAL void +optionSort( tOptions* pOpts ); + +/* + * Extracted from stack.c + */ +LOCAL void +addArgListEntry( void** ppAL, void* entry ); + +#ifdef REDEF_LOCAL +# undef LOCAL +# define LOCAL +#endif +#endif /* AUTOOPTS_PROTO_H_GUARD */ diff --git a/libopts/putshell.c b/libopts/putshell.c new file mode 100644 index 0000000..5d14243 --- /dev/null +++ b/libopts/putshell.c @@ -0,0 +1,320 @@ + +/* + * $Id: putshell.c,v 4.27 2009/08/01 17:43:06 bkorb Exp $ + * Time-stamp: "2008-07-27 12:14:38 bkorb" + * + * This module will interpret the options set in the tOptions + * structure and print them to standard out in a fashion that + * will allow them to be interpreted by the Bourne or Korn shells. + * + * This file is part of AutoOpts, a companion to AutoGen. + * AutoOpts is free software. + * AutoOpts is copyright (c) 1992-2009 by Bruce Korb - all rights reserved + * + * AutoOpts is available under any one of two licenses. The license + * in use must be one of these two and the choice is under the control + * of the user of the license. + * + * The GNU Lesser General Public License, version 3 or later + * See the files "COPYING.lgplv3" and "COPYING.gplv3" + * + * The Modified Berkeley Software Distribution License + * See the file "COPYING.mbsd" + * + * These files have the following md5sums: + * + * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 + * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 + * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + */ + +/* = = = START-STATIC-FORWARD = = = */ +/* static forward declarations maintained by mk-fwd */ +static void +putQuotedStr( tCC* pzStr ); +/* = = = END-STATIC-FORWARD = = = */ + +/* + * Make sure embedded single quotes come out okay. The initial quote has + * been emitted and the closing quote will be upon return. + */ +static void +putQuotedStr( tCC* pzStr ) +{ + /* + * Handle empty strings to make the rest of the logic simpler. + */ + if ((pzStr == NULL) || (*pzStr == NUL)) { + fputs( "''", stdout ); + return; + } + + /* + * Emit any single quotes/apostrophes at the start of the string and + * bail if that is all we need to do. + */ + while (*pzStr == '\'') { + fputs( "\\'", stdout ); + pzStr++; + } + if (*pzStr == NUL) + return; + + /* + * Start the single quote string + */ + fputc( '\'', stdout ); + for (;;) { + tCC* pz = strchr( pzStr, '\'' ); + if (pz == NULL) + break; + + /* + * Emit the string up to the single quote (apostrophe) we just found. + */ + (void)fwrite( pzStr, (size_t)(pz - pzStr), (size_t)1, stdout ); + fputc( '\'', stdout ); + pzStr = pz; + + /* + * Emit an escaped apostrophe for every one we find. + * If that ends the string, do not re-open the single quotes. + */ + while (*++pzStr == '\'') fputs( "\\'", stdout ); + if (*pzStr == NUL) + return; + + fputc( '\'', stdout ); + } + + /* + * If we broke out of the loop, we must still emit the remaining text + * and then close the single quote string. + */ + fputs( pzStr, stdout ); + fputc( '\'', stdout ); +} + + +/*=export_func optionPutShell + * what: write a portable shell script to parse options + * private: + * arg: tOptions*, pOpts, the program options descriptor + * doc: This routine will emit portable shell script text for parsing + * the options described in the option definitions. +=*/ +void +optionPutShell( tOptions* pOpts ) +{ + int optIx = 0; + tSCC zOptCtFmt[] = "OPTION_CT=%d\nexport OPTION_CT\n"; + tSCC zOptNumFmt[] = "%1$s_%2$s=%3$d # 0x%3$X\nexport %1$s_%2$s\n"; + tSCC zOptDisabl[] = "%1$s_%2$s=%3$s\nexport %1$s_%2$s\n"; + tSCC zOptValFmt[] = "%s_%s="; + tSCC zOptEnd[] = "\nexport %s_%s\n"; + tSCC zFullOptFmt[]= "%1$s_%2$s='%3$s'\nexport %1$s_%2$s\n"; + tSCC zEquivMode[] = "%1$s_%2$s_MODE='%3$s'\nexport %1$s_%2$s_MODE\n"; + + printf( zOptCtFmt, pOpts->curOptIdx-1 ); + + do { + tOptDesc* pOD = pOpts->pOptDesc + optIx; + + if (SKIP_OPT(pOD)) + continue; + + /* + * Equivalence classes are hard to deal with. Where the + * option data wind up kind of squishes around. For the purposes + * of emitting shell state, they are not recommended, but we'll + * do something. I guess we'll emit the equivalenced-to option + * at the point in time when the base option is found. + */ + if (pOD->optEquivIndex != NO_EQUIVALENT) + continue; /* equivalence to a different option */ + + /* + * Equivalenced to a different option. Process the current option + * as the equivalenced-to option. Keep the persistent state bits, + * but copy over the set-state bits. + */ + if (pOD->optActualIndex != optIx) { + tOptDesc* p = pOpts->pOptDesc + pOD->optActualIndex; + p->optArg = pOD->optArg; + p->fOptState &= OPTST_PERSISTENT_MASK; + p->fOptState |= pOD->fOptState & ~OPTST_PERSISTENT_MASK; + printf( zEquivMode, pOpts->pzPROGNAME, pOD->pz_NAME, p->pz_NAME ); + pOD = p; + } + + /* + * If the argument type is a set membership bitmask, then we always + * emit the thing. We do this because it will always have some sort + * of bitmask value and we need to emit the bit values. + */ + if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_MEMBERSHIP) { + char const * pz; + uintptr_t val = 1; + printf( zOptNumFmt, pOpts->pzPROGNAME, pOD->pz_NAME, + (int)(uintptr_t)(pOD->optCookie) ); + pOD->optCookie = (void*)(uintptr_t)~0UL; + (*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, pOD); + + /* + * We are building the typeset list. The list returned starts with + * 'none + ' for use by option saving stuff. We must ignore that. + */ + pz = pOD->optArg.argString + 7; + while (*pz != NUL) { + printf( "typeset -x -i %s_", pOD->pz_NAME ); + while (IS_PLUS_N_SPACE_CHAR(*pz)) pz++; + + for (;;) { + int ch = *(pz++); + if (IS_LOWER_CASE_CHAR(ch)) fputc(toupper(ch), stdout); + else if (IS_UPPER_CASE_CHAR(ch)) fputc(ch, stdout); + else if (IS_PLUS_N_SPACE_CHAR(ch)) goto name_done; + else if (ch == NUL) { pz--; goto name_done; } + else fputc( '_', stdout ); + } name_done:; + printf( "=%1$lu # 0x%1$lX\n", (unsigned long)val ); + val <<= 1; + } + + AGFREE(pOD->optArg.argString); + pOD->optArg.argString = NULL; + pOD->fOptState &= ~OPTST_ALLOC_ARG; + continue; + } + + /* + * IF the option was either specified or it wakes up enabled, + * then we will emit information. Otherwise, skip it. + * The idea is that if someone defines an option to initialize + * enabled, we should tell our shell script that it is enabled. + */ + if (UNUSED_OPT( pOD ) && DISABLED_OPT( pOD )) + continue; + + /* + * Handle stacked arguments + */ + if ( (pOD->fOptState & OPTST_STACKED) + && (pOD->optCookie != NULL) ) { + tSCC zOptCookieCt[] = "%1$s_%2$s_CT=%3$d\nexport %1$s_%2$s_CT\n"; + + tArgList* pAL = (tArgList*)pOD->optCookie; + tCC** ppz = pAL->apzArgs; + int ct = pAL->useCt; + + printf( zOptCookieCt, pOpts->pzPROGNAME, pOD->pz_NAME, ct ); + + while (--ct >= 0) { + tSCC numarg_z[] = "%s_%s_%d="; + tSCC end_z[] = "\nexport %s_%s_%d\n"; + + printf( numarg_z, pOpts->pzPROGNAME, pOD->pz_NAME, + pAL->useCt - ct ); + putQuotedStr( *(ppz++) ); + printf( end_z, pOpts->pzPROGNAME, pOD->pz_NAME, + pAL->useCt - ct ); + } + } + + /* + * If the argument has been disabled, + * Then set its value to the disablement string + */ + else if ((pOD->fOptState & OPTST_DISABLED) != 0) + printf( zOptDisabl, pOpts->pzPROGNAME, pOD->pz_NAME, + (pOD->pz_DisablePfx != NULL) + ? pOD->pz_DisablePfx : "false" ); + + /* + * If the argument type is numeric, the last arg pointer + * is really the VALUE of the string that was pointed to. + */ + else if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_NUMERIC) + printf( zOptNumFmt, pOpts->pzPROGNAME, pOD->pz_NAME, + (int)pOD->optArg.argInt ); + + /* + * If the argument type is an enumeration, then it is much + * like a text value, except we call the callback function + * to emit the value corresponding to the "optArg" number. + */ + else if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_ENUMERATION) { + uintptr_t e_val = pOD->optArg.argEnum; + printf( zOptValFmt, pOpts->pzPROGNAME, pOD->pz_NAME ); + + /* + * Convert value to string, print that and restore numeric value. + */ + (*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, pOD); + printf("'%s'", pOD->optArg.argString); + if (pOD->fOptState & OPTST_ALLOC_ARG) + AGFREE(pOD->optArg.argString); + pOD->optArg.argEnum = e_val; + + printf(zOptEnd, pOpts->pzPROGNAME, pOD->pz_NAME); + } + + /* + * If the argument type is numeric, the last arg pointer + * is really the VALUE of the string that was pointed to. + */ + else if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_BOOLEAN) + printf( zFullOptFmt, pOpts->pzPROGNAME, pOD->pz_NAME, + (pOD->optArg.argBool == 0) ? "false" : "true" ); + + /* + * IF the option has an empty value, + * THEN we set the argument to the occurrence count. + */ + else if ( (pOD->optArg.argString == NULL) + || (pOD->optArg.argString[0] == NUL) ) + + printf( zOptNumFmt, pOpts->pzPROGNAME, pOD->pz_NAME, + pOD->optOccCt ); + + /* + * This option has a text value + */ + else { + printf( zOptValFmt, pOpts->pzPROGNAME, pOD->pz_NAME ); + putQuotedStr( pOD->optArg.argString ); + printf( zOptEnd, pOpts->pzPROGNAME, pOD->pz_NAME ); + } + } while (++optIx < pOpts->presetOptCt ); + + if ( ((pOpts->fOptSet & OPTPROC_REORDER) != 0) + && (pOpts->curOptIdx < pOpts->origArgCt)) { + fputs( "set --", stdout ); + for (optIx = pOpts->curOptIdx; optIx < pOpts->origArgCt; optIx++) { + char* pzArg = pOpts->origArgVect[ optIx ]; + if (strchr( pzArg, '\'' ) == NULL) + printf( " '%s'", pzArg ); + else { + fputs( " '", stdout ); + for (;;) { + char ch = *(pzArg++); + switch (ch) { + case '\'': fputs( "'\\''", stdout ); break; + case NUL: goto arg_done; + default: fputc( ch, stdout ); break; + } + } arg_done:; + fputc( '\'', stdout ); + } + } + fputs( "\nOPTION_CT=0\n", stdout ); + } +} + +/* + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of autoopts/putshell.c */ diff --git a/libopts/reset.c b/libopts/reset.c new file mode 100644 index 0000000..808e536 --- /dev/null +++ b/libopts/reset.c @@ -0,0 +1,128 @@ + +/* + * $Id: reset.c,v 4.7 2009/08/01 17:43:06 bkorb Exp $ + * Time-stamp: "2008-08-02 12:25:18 bkorb" + * + * This file is part of AutoOpts, a companion to AutoGen. + * AutoOpts is free software. + * AutoOpts is copyright (c) 1992-2009 by Bruce Korb - all rights reserved + * + * AutoOpts is available under any one of two licenses. The license + * in use must be one of these two and the choice is under the control + * of the user of the license. + * + * The GNU Lesser General Public License, version 3 or later + * See the files "COPYING.lgplv3" and "COPYING.gplv3" + * + * The Modified Berkeley Software Distribution License + * See the file "COPYING.mbsd" + * + * These files have the following md5sums: + * + * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 + * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 + * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + */ + +static void +optionReset( tOptions* pOpts, tOptDesc* pOD ) +{ + pOD->fOptState &= OPTST_PERSISTENT_MASK; + pOD->fOptState |= OPTST_RESET; + if (pOD->pOptProc != NULL) + pOD->pOptProc(pOpts, pOD); + pOD->optArg.argString = + pOpts->originalOptArgArray[ pOD->optIndex ].argString; + pOD->optCookie = pOpts->originalOptArgCookie[ pOD->optIndex ]; + pOD->fOptState &= OPTST_PERSISTENT_MASK; +} + + +static void +optionResetEverything(tOptions * pOpts) +{ + tOptDesc * pOD = pOpts->pOptDesc; + int ct = pOpts->presetOptCt; + + for (;;) { + optionReset(pOpts, pOD); + + if (--ct <= 0) + break; + pOD++; + } +} + + +/*=export_func optionResetOpt + * private: + * + * what: Reset the value of an option + * arg: + tOptions* + pOpts + program options descriptor + + * arg: + tOptDesc* + pOptDesc + the descriptor for this arg + + * + * doc: + * This code will cause another option to be reset to its initial state. + * For example, --reset=foo will cause the --foo option to be reset. +=*/ +void +optionResetOpt( tOptions* pOpts, tOptDesc* pOD ) +{ + static ag_bool reset_active = AG_FALSE; + + tOptState opt_state = OPTSTATE_INITIALIZER(DEFINED); + char const * pzArg = pOD->optArg.argString; + tSuccess succ; + + if (reset_active) + return; + + if ( (! HAS_originalOptArgArray(pOpts)) + || (pOpts->originalOptArgCookie == NULL)) { + fputs(zResetNotConfig, stderr); + _exit(EX_SOFTWARE); + } + + if ((pzArg == NULL) || (*pzArg == NUL)) { + fputs(zNoResetArg, stderr); + pOpts->pUsageProc(pOpts, EXIT_FAILURE); + } + + reset_active = AG_TRUE; + + if (pzArg[1] == NUL) { + if (*pzArg == '*') { + optionResetEverything(pOpts); + reset_active = AG_FALSE; + return; + } + + succ = shortOptionFind(pOpts, (tAoUC)*pzArg, &opt_state); + if (! SUCCESSFUL(succ)) { + fprintf(stderr, zIllOptChr, pOpts->pzProgPath, *pzArg); + pOpts->pUsageProc(pOpts, EXIT_FAILURE); + } + } else { + succ = longOptionFind(pOpts, (char *)pzArg, &opt_state); + if (! SUCCESSFUL(succ)) { + fprintf(stderr, zIllOptStr, pOpts->pzProgPath, pzArg); + pOpts->pUsageProc(pOpts, EXIT_FAILURE); + } + } + + /* + * We've found the indicated option. Turn off all non-persistent + * flags because we're forcing the option back to its initialized state. + * Call any callout procedure to handle whatever it needs to. + * Finally, clear the reset flag, too. + */ + optionReset(pOpts, opt_state.pOD); + reset_active = AG_FALSE; +} +/* + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of autoopts/reset.c */ diff --git a/libopts/restore.c b/libopts/restore.c new file mode 100644 index 0000000..6f5237b --- /dev/null +++ b/libopts/restore.c @@ -0,0 +1,227 @@ + +/* + * restore.c $Id: restore.c,v 4.14 2009/08/01 17:43:06 bkorb Exp $ + * Time-stamp: "2007-07-04 11:34:40 bkorb" + * + * This module's routines will save the current option state to memory + * and restore it. If saved prior to the initial optionProcess call, + * then the initial state will be restored. + * + * This file is part of AutoOpts, a companion to AutoGen. + * AutoOpts is free software. + * AutoOpts is copyright (c) 1992-2009 by Bruce Korb - all rights reserved + * + * AutoOpts is available under any one of two licenses. The license + * in use must be one of these two and the choice is under the control + * of the user of the license. + * + * The GNU Lesser General Public License, version 3 or later + * See the files "COPYING.lgplv3" and "COPYING.gplv3" + * + * The Modified Berkeley Software Distribution License + * See the file "COPYING.mbsd" + * + * These files have the following md5sums: + * + * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 + * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 + * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + */ + +/* + * 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 + * have been marked as allocated though. + */ +static void +fixupSavedOptionArgs(tOptions* pOpts) +{ + tOptions* p = pOpts->pSavedState; + tOptDesc* pOD = pOpts->pOptDesc; + int ct = pOpts->optCt; + + /* + * Make sure that allocated stuff is only referenced in the + * archived copy of the data. + */ + for (; ct-- > 0; pOD++) { + switch (OPTST_GET_ARGTYPE(pOD->fOptState)) { + case OPARG_TYPE_STRING: + if (pOD->fOptState & OPTST_STACKED) { + tOptDesc* q = p->pOptDesc + (pOD - pOpts->pOptDesc); + q->optCookie = NULL; + } + if (pOD->fOptState & OPTST_ALLOC_ARG) { + tOptDesc* q = p->pOptDesc + (pOD - pOpts->pOptDesc); + AGDUPSTR(q->optArg.argString, pOD->optArg.argString, "arg"); + } + break; + + case OPARG_TYPE_HIERARCHY: + { + tOptDesc* q = p->pOptDesc + (pOD - pOpts->pOptDesc); + q->optCookie = NULL; + } + } + } +} + +/*=export_func optionSaveState + * + * what: saves the option state to memory + * arg: tOptions*, pOpts, program options descriptor + * + * doc: + * + * This routine will allocate enough memory to save the current option + * processing state. If this routine has been called before, that memory + * will be reused. You may only save one copy of the option state. This + * routine may be called before optionProcess(3AO). If you do call it + * before the first call to optionProcess, then you may also change the + * contents of argc/argv after you call optionRestore(3AO) + * + * In fact, more strongly put: it is safest to only use this function + * before having processed any options. In particular, the saving and + * restoring of stacked string arguments and hierarchical values is + * disabled. The values are not saved. + * + * err: If it fails to allocate the memory, + * it will print a message to stderr and exit. + * Otherwise, it will always succeed. +=*/ +void +optionSaveState(tOptions* pOpts) +{ + tOptions* p = (tOptions*)pOpts->pSavedState; + + if (p == NULL) { + size_t sz = sizeof( *pOpts ) + (pOpts->optCt * sizeof( tOptDesc )); + p = AGALOC( sz, "saved option state" ); + if (p == NULL) { + tCC* pzName = pOpts->pzProgName; + if (pzName == NULL) { + pzName = pOpts->pzPROGNAME; + if (pzName == NULL) + pzName = zNil; + } + fprintf( stderr, zCantSave, pzName, sz ); + exit( EXIT_FAILURE ); + } + + pOpts->pSavedState = p; + } + + memcpy( p, pOpts, sizeof( *p )); + memcpy( p + 1, pOpts->pOptDesc, p->optCt * sizeof( tOptDesc )); + + fixupSavedOptionArgs(pOpts); +} + + +/*=export_func optionRestore + * + * what: restore option state from memory copy + * arg: tOptions*, pOpts, program options descriptor + * + * doc: Copy back the option state from saved memory. + * The allocated memory is left intact, so this routine can be + * called repeatedly without having to call optionSaveState again. + * If you are restoring a state that was saved before the first call + * to optionProcess(3AO), then you may change the contents of the + * argc/argv parameters to optionProcess. + * + * err: If you have not called @code{optionSaveState} before, a diagnostic is + * printed to @code{stderr} and exit is called. +=*/ +void +optionRestore( tOptions* pOpts ) +{ + tOptions* p = (tOptions*)pOpts->pSavedState; + + if (p == NULL) { + tCC* pzName = pOpts->pzProgName; + if (pzName == NULL) { + pzName = pOpts->pzPROGNAME; + if (pzName == NULL) + pzName = zNil; + } + fprintf( stderr, zNoState, pzName ); + exit( EXIT_FAILURE ); + } + + pOpts->pSavedState = NULL; + optionFree(pOpts); + + memcpy( pOpts, p, sizeof( *p )); + memcpy( pOpts->pOptDesc, p+1, p->optCt * sizeof( tOptDesc )); + pOpts->pSavedState = p; + + fixupSavedOptionArgs(pOpts); +} + +/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ + +/*=export_func optionFree + * + * what: free allocated option processing memory + * arg: tOptions*, pOpts, program options descriptor + * + * doc: AutoOpts sometimes allocates memory and puts pointers to it in the + * option state structures. This routine deallocates all such memory. + * + * err: As long as memory has not been corrupted, + * this routine is always successful. +=*/ +void +optionFree( tOptions* pOpts ) +{ + free_saved_state: + { + tOptDesc* p = pOpts->pOptDesc; + int ct = pOpts->optCt; + do { + if (p->fOptState & OPTST_ALLOC_ARG) { + AGFREE(p->optArg.argString); + p->optArg.argString = NULL; + p->fOptState &= ~OPTST_ALLOC_ARG; + } + + switch (OPTST_GET_ARGTYPE(p->fOptState)) { + case OPARG_TYPE_STRING: +#ifdef WITH_LIBREGEX + if ( (p->fOptState & OPTST_STACKED) + && (p->optCookie != NULL)) { + p->optArg.argString = ".*"; + optionUnstackArg(pOpts, p); + } +#else + /* leak memory */; +#endif + break; + + case OPARG_TYPE_HIERARCHY: + if (p->optCookie != NULL) + unloadNestedArglist(p->optCookie); + break; + } + + p->optCookie = NULL; + } while (p++, --ct > 0); + } + if (pOpts->pSavedState != NULL) { + tOptions * p = (tOptions*)pOpts->pSavedState; + memcpy( pOpts, p, sizeof( *p )); + memcpy( pOpts->pOptDesc, p+1, p->optCt * sizeof( tOptDesc )); + AGFREE( pOpts->pSavedState ); + pOpts->pSavedState = NULL; + goto free_saved_state; + } +} +/* + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of autoopts/restore.c */ diff --git a/libopts/save.c b/libopts/save.c new file mode 100644 index 0000000..5a69234 --- /dev/null +++ b/libopts/save.c @@ -0,0 +1,791 @@ + +/* + * save.c $Id: save.c,v 4.36 2009/08/01 17:43:06 bkorb Exp $ + * Time-stamp: "2009-07-20 20:40:28 bkorb" + * + * This module's routines will take the currently set options and + * store them into an ".rc" file for re-interpretation the next + * time the invoking program is run. + * + * This file is part of AutoOpts, a companion to AutoGen. + * AutoOpts is free software. + * AutoOpts is copyright (c) 1992-2009 by Bruce Korb - all rights reserved + * + * AutoOpts is available under any one of two licenses. The license + * in use must be one of these two and the choice is under the control + * of the user of the license. + * + * The GNU Lesser General Public License, version 3 or later + * See the files "COPYING.lgplv3" and "COPYING.gplv3" + * + * The Modified Berkeley Software Distribution License + * See the file "COPYING.mbsd" + * + * These files have the following md5sums: + * + * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 + * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 + * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + */ + +static char const zWarn[] = "%s WARNING: cannot save options - "; +static char const close_xml[] = "\n"; + +/* = = = START-STATIC-FORWARD = = = */ +/* static forward declarations maintained by mk-fwd */ +static tCC* +findDirName( tOptions* pOpts, int* p_free ); + +static tCC* +findFileName( tOptions* pOpts, int* p_free_name ); + +static void +printEntry( + FILE * fp, + tOptDesc * p, + tCC* pzLA ); + +static void +print_a_value(FILE * fp, int depth, tOptDesc * pOD, tOptionValue const * ovp); + +static void +print_a_string(FILE * fp, char const * name, char const * pz); + +static void +printValueList(FILE * fp, char const * name, tArgList * al); + +static void +printHierarchy(FILE * fp, tOptDesc * p); + +static FILE * +openSaveFile( tOptions* pOpts ); + +static void +printNoArgOpt(FILE * fp, tOptDesc * p, tOptDesc * pOD); + +static void +printStringArg(FILE * fp, tOptDesc * pOD); + +static void +printEnumArg(FILE * fp, tOptDesc * pOD); + +static void +printSetMemberArg(FILE * fp, tOptDesc * pOD); + +static void +printFileArg(FILE * fp, tOptDesc * pOD, tOptions* pOpts); +/* = = = END-STATIC-FORWARD = = = */ + +static tCC* +findDirName( tOptions* pOpts, int* p_free ) +{ + tCC* pzDir; + + if ( (pOpts->specOptIdx.save_opts == NO_EQUIVALENT) + || (pOpts->specOptIdx.save_opts == 0)) + return NULL; + + pzDir = pOpts->pOptDesc[ pOpts->specOptIdx.save_opts ].optArg.argString; + if ((pzDir != NULL) && (*pzDir != NUL)) + return pzDir; + + /* + * This function only works if there is a directory where + * we can stash the RC (INI) file. + */ + { + tCC* const* papz = pOpts->papzHomeList; + if (papz == NULL) + return NULL; + + while (papz[1] != NULL) papz++; + pzDir = *papz; + } + + /* + * IF it does not require deciphering an env value, then just copy it + */ + if (*pzDir != '$') + return pzDir; + + { + tCC* pzEndDir = strchr( ++pzDir, DIRCH ); + char* pzFileName; + char* pzEnv; + + if (pzEndDir != NULL) { + char z[ AO_NAME_SIZE ]; + if ((pzEndDir - pzDir) > AO_NAME_LIMIT ) + return NULL; + strncpy( z, pzDir, (size_t)(pzEndDir - pzDir) ); + z[ (pzEndDir - pzDir) ] = NUL; + pzEnv = getenv( z ); + } else { + + /* + * Make sure we can get the env value (after stripping off + * any trailing directory or file names) + */ + pzEnv = getenv( pzDir ); + } + + if (pzEnv == NULL) { + fprintf( stderr, zWarn, pOpts->pzProgName ); + fprintf( stderr, zNotDef, pzDir ); + return NULL; + } + + if (pzEndDir == NULL) + return pzEnv; + + { + size_t sz = strlen( pzEnv ) + strlen( pzEndDir ) + 2; + pzFileName = (char*)AGALOC( sz, "dir name" ); + } + + if (pzFileName == NULL) + return NULL; + + *p_free = 1; + /* + * Glue together the full name into the allocated memory. + * FIXME: We lose track of this memory. + */ + sprintf( pzFileName, "%s/%s", pzEnv, pzEndDir ); + return pzFileName; + } +} + + +static tCC* +findFileName( tOptions* pOpts, int* p_free_name ) +{ + tCC* pzDir; + struct stat stBuf; + int free_dir_name = 0; + + pzDir = findDirName( pOpts, &free_dir_name ); + if (pzDir == NULL) + return NULL; + + /* + * See if we can find the specified directory. We use a once-only loop + * structure so we can bail out early. + */ + if (stat( pzDir, &stBuf ) != 0) do { + + /* + * IF we could not, check to see if we got a full + * path to a file name that has not been created yet. + */ + if (errno == ENOENT) { + char z[AG_PATH_MAX]; + + /* + * Strip off the last component, stat the remaining string and + * that string must name a directory + */ + char* pzDirCh = strrchr( pzDir, DIRCH ); + if (pzDirCh == NULL) { + stBuf.st_mode = S_IFREG; + continue; /* bail out of error condition */ + } + + strncpy( z, pzDir, (size_t)(pzDirCh - pzDir)); + z[ pzDirCh - pzDir ] = NUL; + + if ( (stat( z, &stBuf ) == 0) + && S_ISDIR( stBuf.st_mode )) { + + /* + * We found the directory. Restore the file name and + * mark the full name as a regular file + */ + stBuf.st_mode = S_IFREG; + continue; /* bail out of error condition */ + } + } + + /* + * We got a bogus name. + */ + fprintf( stderr, zWarn, pOpts->pzProgName ); + fprintf( stderr, zNoStat, errno, strerror( errno ), pzDir ); + if (free_dir_name) + AGFREE( (void*)pzDir ); + return NULL; + } while (0); + + /* + * IF what we found was a directory, + * THEN tack on the config file name + */ + if (S_ISDIR( stBuf.st_mode )) { + size_t sz = strlen( pzDir ) + strlen( pOpts->pzRcName ) + 2; + + { + char* pzPath = (char*)AGALOC( sz, "file name" ); +#ifdef HAVE_SNPRINTF + snprintf( pzPath, sz, "%s/%s", pzDir, pOpts->pzRcName ); +#else + sprintf( pzPath, "%s/%s", pzDir, pOpts->pzRcName ); +#endif + if (free_dir_name) + AGFREE( (void*)pzDir ); + pzDir = pzPath; + free_dir_name = 1; + } + + /* + * IF we cannot stat the object for any reason other than + * it does not exist, then we bail out + */ + if (stat( pzDir, &stBuf ) != 0) { + if (errno != ENOENT) { + fprintf( stderr, zWarn, pOpts->pzProgName ); + fprintf( stderr, zNoStat, errno, strerror( errno ), + pzDir ); + AGFREE( (void*)pzDir ); + return NULL; + } + + /* + * It does not exist yet, but it will be a regular file + */ + stBuf.st_mode = S_IFREG; + } + } + + /* + * Make sure that whatever we ultimately found, that it either is + * or will soon be a file. + */ + if (! S_ISREG( stBuf.st_mode )) { + fprintf( stderr, zWarn, pOpts->pzProgName ); + fprintf( stderr, zNotFile, pzDir ); + if (free_dir_name) + AGFREE( (void*)pzDir ); + return NULL; + } + + /* + * Get rid of the old file + */ + unlink( pzDir ); + *p_free_name = free_dir_name; + return pzDir; +} + + +static void +printEntry( + FILE * fp, + tOptDesc * p, + tCC* pzLA ) +{ + /* + * There is an argument. Pad the name so values line up. + * Not disabled *OR* this got equivalenced to another opt, + * then use current option name. + * Otherwise, there must be a disablement name. + */ + { + char const * pz; + if (! DISABLED_OPT(p) || (p->optEquivIndex != NO_EQUIVALENT)) + pz = p->pz_Name; + else + pz = p->pz_DisableName; + + fprintf(fp, "%-18s", pz); + } + /* + * IF the option is numeric only, + * THEN the char pointer is really the number + */ + if (OPTST_GET_ARGTYPE(p->fOptState) == OPARG_TYPE_NUMERIC) + fprintf( fp, " %d\n", (int)(t_word)pzLA ); + + /* + * OTHERWISE, FOR each line of the value text, ... + */ + else if (pzLA == NULL) + fputc( '\n', fp ); + + else { + fputc( ' ', fp ); fputc( ' ', fp ); + for (;;) { + tCC* pzNl = strchr( pzLA, '\n' ); + + /* + * IF this is the last line + * THEN bail and print it + */ + if (pzNl == NULL) + break; + + /* + * Print the continuation and the text from the current line + */ + (void)fwrite( pzLA, (size_t)(pzNl - pzLA), (size_t)1, fp ); + pzLA = pzNl+1; /* advance the Last Arg pointer */ + fputs( "\\\n", fp ); + } + + /* + * Terminate the entry + */ + fputs( pzLA, fp ); + fputc( '\n', fp ); + } +} + + +static void +print_a_value(FILE * fp, int depth, tOptDesc * pOD, tOptionValue const * ovp) +{ + static char const bool_atr[] = "<%1$s type=boolean>%2$s\n"; + static char const numb_atr[] = "<%1$s type=integer>0x%2$lX\n"; + static char const type_atr[] = "<%s type=%s>"; + static char const null_atr[] = "<%s/>\n"; + + while (--depth >= 0) + putc(' ', fp), putc(' ', fp); + + switch (ovp->valType) { + default: + case OPARG_TYPE_NONE: + fprintf(fp, null_atr, ovp->pzName); + break; + + case OPARG_TYPE_STRING: + print_a_string(fp, ovp->pzName, ovp->v.strVal); + break; + + case OPARG_TYPE_ENUMERATION: + case OPARG_TYPE_MEMBERSHIP: + if (pOD != NULL) { + tAoUI opt_state = pOD->fOptState; + uintptr_t val = pOD->optArg.argEnum; + char const * typ = (ovp->valType == OPARG_TYPE_ENUMERATION) + ? "keyword" : "set-membership"; + + fprintf(fp, type_atr, ovp->pzName, typ); + + /* + * This is a magic incantation that will convert the + * bit flag values back into a string suitable for printing. + */ + (*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, pOD ); + if (pOD->optArg.argString != NULL) { + fputs(pOD->optArg.argString, fp); + + if (ovp->valType != OPARG_TYPE_ENUMERATION) { + /* + * set membership strings get allocated + */ + AGFREE( (void*)pOD->optArg.argString ); + } + } + + pOD->optArg.argEnum = val; + pOD->fOptState = opt_state; + fprintf(fp, close_xml, ovp->pzName); + break; + } + /* FALLTHROUGH */ + + case OPARG_TYPE_NUMERIC: + fprintf(fp, numb_atr, ovp->pzName, ovp->v.longVal); + break; + + case OPARG_TYPE_BOOLEAN: + fprintf(fp, bool_atr, ovp->pzName, + ovp->v.boolVal ? "true" : "false"); + break; + + case OPARG_TYPE_HIERARCHY: + printValueList(fp, ovp->pzName, ovp->v.nestVal); + break; + } +} + + +static void +print_a_string(FILE * fp, char const * name, char const * pz) +{ + static char const open_atr[] = "<%s>"; + + fprintf(fp, open_atr, name); + for (;;) { + int ch = ((int)*(pz++)) & 0xFF; + + switch (ch) { + case NUL: goto string_done; + + case '&': + case '<': + case '>': +#if __GNUC__ >= 4 + case 1 ... (' ' - 1): + case ('~' + 1) ... 0xFF: +#endif + emit_special_char(fp, ch); + break; + + default: +#if __GNUC__ < 4 + if ( ((ch >= 1) && (ch <= (' ' - 1))) + || ((ch >= ('~' + 1)) && (ch <= 0xFF)) ) { + emit_special_char(fp, ch); + break; + } +#endif + putc(ch, fp); + } + } string_done:; + fprintf(fp, close_xml, name); +} + + +static void +printValueList(FILE * fp, char const * name, tArgList * al) +{ + static int depth = 1; + + int sp_ct; + int opt_ct; + void ** opt_list; + + if (al == NULL) + return; + opt_ct = al->useCt; + opt_list = (void **)al->apzArgs; + + if (opt_ct <= 0) { + fprintf(fp, "<%s/>\n", name); + return; + } + + fprintf(fp, "<%s type=nested>\n", name); + + depth++; + while (--opt_ct >= 0) { + tOptionValue const * ovp = *(opt_list++); + + print_a_value(fp, depth, NULL, ovp); + } + depth--; + + for (sp_ct = depth; --sp_ct >= 0;) + putc(' ', fp), putc(' ', fp); + fprintf(fp, "\n", name); +} + + +static void +printHierarchy(FILE * fp, tOptDesc * p) +{ + int opt_ct; + tArgList * al = p->optCookie; + void ** opt_list; + + if (al == NULL) + return; + + opt_ct = al->useCt; + opt_list = (void **)al->apzArgs; + + if (opt_ct <= 0) + return; + + do { + tOptionValue const * base = *(opt_list++); + tOptionValue const * ovp = optionGetValue(base, NULL); + + if (ovp == NULL) + continue; + + fprintf(fp, "<%s type=nested>\n", p->pz_Name); + + do { + print_a_value(fp, 1, p, ovp); + + } while (ovp = optionNextValue(base, ovp), + ovp != NULL); + + fprintf(fp, "\n", p->pz_Name); + } while (--opt_ct > 0); +} + + +static FILE * +openSaveFile( tOptions* pOpts ) +{ + FILE* fp; + + { + int free_name = 0; + tCC* pzFName = findFileName( pOpts, &free_name ); + if (pzFName == NULL) + return NULL; + + fp = fopen( pzFName, "w" FOPEN_BINARY_FLAG ); + if (fp == NULL) { + fprintf( stderr, zWarn, pOpts->pzProgName ); + fprintf( stderr, zNoCreat, errno, strerror( errno ), pzFName ); + if (free_name) + AGFREE((void*) pzFName ); + return fp; + } + + if (free_name) + AGFREE( (void*)pzFName ); + } + + { + char const* pz = pOpts->pzUsageTitle; + fputs( "# ", fp ); + do { fputc( *pz, fp ); } while (*(pz++) != '\n'); + } + + { + time_t timeVal = time( NULL ); + char* pzTime = ctime( &timeVal ); + + fprintf( fp, zPresetFile, pzTime ); +#ifdef HAVE_ALLOCATED_CTIME + /* + * The return values for ctime(), localtime(), and gmtime() + * normally point to static data that is overwritten by each call. + * The test to detect allocated ctime, so we leak the memory. + */ + AGFREE( (void*)pzTime ); +#endif + } + + return fp; +} + +static void +printNoArgOpt(FILE * fp, tOptDesc * p, tOptDesc * pOD) +{ + /* + * The aliased to argument indicates whether or not the option + * is "disabled". However, the original option has the name + * string, so we get that there, not with "p". + */ + char const * pznm = + (DISABLED_OPT( p )) ? pOD->pz_DisableName : pOD->pz_Name; + /* + * If the option was disabled and the disablement name is NULL, + * then the disablement was caused by aliasing. + * Use the name as the string to emit. + */ + if (pznm == NULL) + pznm = pOD->pz_Name; + + fprintf(fp, "%s\n", pznm); +} + +static void +printStringArg(FILE * fp, tOptDesc * pOD) +{ + if (pOD->fOptState & OPTST_STACKED) { + tArgList* pAL = (tArgList*)pOD->optCookie; + int uct = pAL->useCt; + tCC** ppz = pAL->apzArgs; + + /* + * un-disable multiple copies of disabled options. + */ + if (uct > 1) + pOD->fOptState &= ~OPTST_DISABLED; + + while (uct-- > 0) + printEntry( fp, pOD, *(ppz++) ); + } else { + printEntry( fp, pOD, pOD->optArg.argString ); + } +} + +static void +printEnumArg(FILE * fp, tOptDesc * pOD) +{ + uintptr_t val = pOD->optArg.argEnum; + + /* + * This is a magic incantation that will convert the + * bit flag values back into a string suitable for printing. + */ + (*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, pOD); + printEntry( fp, pOD, (void*)(pOD->optArg.argString)); + + pOD->optArg.argEnum = val; +} + +static void +printSetMemberArg(FILE * fp, tOptDesc * pOD) +{ + uintptr_t val = pOD->optArg.argEnum; + + /* + * This is a magic incantation that will convert the + * bit flag values back into a string suitable for printing. + */ + (*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, pOD); + printEntry( fp, pOD, (void*)(pOD->optArg.argString)); + + if (pOD->optArg.argString != NULL) { + /* + * set membership strings get allocated + */ + AGFREE( (void*)pOD->optArg.argString ); + pOD->fOptState &= ~OPTST_ALLOC_ARG; + } + + pOD->optArg.argEnum = val; +} + +static void +printFileArg(FILE * fp, tOptDesc * pOD, tOptions* pOpts) +{ + /* + * If the cookie is not NULL, then it has the file name, period. + * Otherwise, if we have a non-NULL string argument, then.... + */ + if (pOD->optCookie != NULL) + printEntry(fp, pOD, pOD->optCookie); + + else if (HAS_originalOptArgArray(pOpts)) { + char const * orig = + pOpts->originalOptArgArray[pOD->optIndex].argString; + + if (pOD->optArg.argString == orig) + return; + + printEntry(fp, pOD, pOD->optArg.argString); + } +} + + +/*=export_func optionSaveFile + * + * what: saves the option state to a file + * + * arg: tOptions*, pOpts, program options descriptor + * + * doc: + * + * This routine will save the state of option processing to a file. The name + * of that file can be specified with the argument to the @code{--save-opts} + * option, or by appending the @code{rcfile} attribute to the last + * @code{homerc} attribute. If no @code{rcfile} attribute was specified, it + * will default to @code{.@i{programname}rc}. If you wish to specify another + * file, you should invoke the @code{SET_OPT_SAVE_OPTS( @i{filename} )} macro. + * + * The recommend usage is as follows: + * @example + * optionProcess(&progOptions, argc, argv); + * if (i_want_a_non_standard_place_for_this) + * SET_OPT_SAVE_OPTS("myfilename"); + * optionSaveFile(&progOptions); + * @end example + * + * err: + * + * If no @code{homerc} file was specified, this routine will silently return + * and do nothing. If the output file cannot be created or updated, a message + * will be printed to @code{stderr} and the routine will return. +=*/ +void +optionSaveFile( tOptions* pOpts ) +{ + tOptDesc* pOD; + int ct; + FILE* fp = openSaveFile(pOpts); + + if (fp == NULL) + return; + + /* + * FOR each of the defined options, ... + */ + ct = pOpts->presetOptCt; + pOD = pOpts->pOptDesc; + do { + tOptDesc* p; + + /* + * IF the option has not been defined + * OR it does not take an initialization value + * OR it is equivalenced to another option + * THEN continue (ignore it) + * + * Equivalenced options get picked up when the equivalenced-to + * option is processed. + */ + if (UNUSED_OPT( pOD )) + continue; + + if ((pOD->fOptState & OPTST_DO_NOT_SAVE_MASK) != 0) + continue; + + if ( (pOD->optEquivIndex != NO_EQUIVALENT) + && (pOD->optEquivIndex != pOD->optIndex)) + continue; + + /* + * The option argument data are found at the equivalenced-to option, + * but the actual option argument type comes from the original + * option descriptor. Be careful! + */ + p = ((pOD->fOptState & OPTST_EQUIVALENCE) != 0) + ? (pOpts->pOptDesc + pOD->optActualIndex) : pOD; + + switch (OPTST_GET_ARGTYPE(pOD->fOptState)) { + case OPARG_TYPE_NONE: + printNoArgOpt(fp, p, pOD); + break; + + case OPARG_TYPE_NUMERIC: + printEntry( fp, p, (void*)(p->optArg.argInt)); + break; + + case OPARG_TYPE_STRING: + printStringArg(fp, p); + break; + + case OPARG_TYPE_ENUMERATION: + printEnumArg(fp, p); + break; + + case OPARG_TYPE_MEMBERSHIP: + printSetMemberArg(fp, p); + break; + + case OPARG_TYPE_BOOLEAN: + printEntry( fp, p, p->optArg.argBool ? "true" : "false" ); + break; + + case OPARG_TYPE_HIERARCHY: + printHierarchy(fp, p); + break; + + case OPARG_TYPE_FILE: + printFileArg(fp, p, pOpts); + break; + + default: + break; /* cannot handle - skip it */ + } + } while ( (pOD++), (--ct > 0)); + + fclose( fp ); +} +/* + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of autoopts/save.c */ diff --git a/libopts/sort.c b/libopts/sort.c new file mode 100644 index 0000000..aac1bf8 --- /dev/null +++ b/libopts/sort.c @@ -0,0 +1,336 @@ + +/* + * sort.c $Id: sort.c,v 4.17 2009/08/01 17:43:06 bkorb Exp $ + * Time-stamp: "2007-07-04 11:34:52 bkorb" + * + * This module implements argument sorting. + * + * This file is part of AutoOpts, a companion to AutoGen. + * AutoOpts is free software. + * AutoOpts is copyright (c) 1992-2009 by Bruce Korb - all rights reserved + * + * AutoOpts is available under any one of two licenses. The license + * in use must be one of these two and the choice is under the control + * of the user of the license. + * + * The GNU Lesser General Public License, version 3 or later + * See the files "COPYING.lgplv3" and "COPYING.gplv3" + * + * The Modified Berkeley Software Distribution License + * See the file "COPYING.mbsd" + * + * These files have the following md5sums: + * + * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 + * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 + * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + */ + +/* = = = START-STATIC-FORWARD = = = */ +/* static forward declarations maintained by mk-fwd */ +static tSuccess +mustHandleArg( tOptions* pOpts, char* pzArg, tOptState* pOS, + char** ppzOpts, int* pOptsIdx ); + +static tSuccess +mayHandleArg( tOptions* pOpts, char* pzArg, tOptState* pOS, + char** ppzOpts, int* pOptsIdx ); + +static tSuccess +checkShortOpts( tOptions* pOpts, char* pzArg, tOptState* pOS, + char** ppzOpts, int* pOptsIdx ); +/* = = = END-STATIC-FORWARD = = = */ + +/* + * "mustHandleArg" and "mayHandleArg" are really similar. The biggest + * difference is that "may" will consume the next argument only if it + * does not start with a hyphen and "must" will consume it, hyphen or not. + */ +static tSuccess +mustHandleArg( tOptions* pOpts, char* pzArg, tOptState* pOS, + char** ppzOpts, int* pOptsIdx ) +{ + /* + * An option argument is required. Long options can either have + * a separate command line argument, or an argument attached by + * the '=' character. Figure out which. + */ + switch (pOS->optType) { + case TOPT_SHORT: + /* + * See if an arg string follows the flag character. If not, + * the next arg must be the option argument. + */ + if (*pzArg != NUL) + return SUCCESS; + break; + + case TOPT_LONG: + /* + * See if an arg string has already been assigned (glued on + * with an `=' character). If not, the next is the opt arg. + */ + if (pOS->pzOptArg != NULL) + return SUCCESS; + break; + + default: + return FAILURE; + } + if (pOpts->curOptIdx >= pOpts->origArgCt) + return FAILURE; + + ppzOpts[ (*pOptsIdx)++ ] = pOpts->origArgVect[ (pOpts->curOptIdx)++ ]; + return SUCCESS; +} + +static tSuccess +mayHandleArg( tOptions* pOpts, char* pzArg, tOptState* pOS, + char** ppzOpts, int* pOptsIdx ) +{ + /* + * An option argument is optional. + */ + switch (pOS->optType) { + case TOPT_SHORT: + /* + * IF nothing is glued on after the current flag character, + * THEN see if there is another argument. If so and if it + * does *NOT* start with a hyphen, then it is the option arg. + */ + if (*pzArg != NUL) + return SUCCESS; + break; + + case TOPT_LONG: + /* + * Look for an argument if we don't already have one (glued on + * with a `=' character) + */ + if (pOS->pzOptArg != NULL) + return SUCCESS; + break; + + default: + return FAILURE; + } + if (pOpts->curOptIdx >= pOpts->origArgCt) + return PROBLEM; + + pzArg = pOpts->origArgVect[ pOpts->curOptIdx ]; + if (*pzArg != '-') + ppzOpts[ (*pOptsIdx)++ ] = pOpts->origArgVect[ (pOpts->curOptIdx)++ ]; + return SUCCESS; +} + +/* + * Process a string of short options glued together. If the last one + * does or may take an argument, the do the argument processing and leave. + */ +static tSuccess +checkShortOpts( tOptions* pOpts, char* pzArg, tOptState* pOS, + char** ppzOpts, int* pOptsIdx ) +{ + while (*pzArg != NUL) { + if (FAILED( shortOptionFind( pOpts, (tAoUC)*pzArg, pOS ))) + return FAILURE; + + /* + * See if we can have an arg. + */ + if (OPTST_GET_ARGTYPE(pOS->pOD->fOptState) == OPARG_TYPE_NONE) { + pzArg++; + + } else if (pOS->pOD->fOptState & OPTST_ARG_OPTIONAL) { + /* + * Take an argument if it is not attached and it does not + * start with a hyphen. + */ + if (pzArg[1] != NUL) + return SUCCESS; + + pzArg = pOpts->origArgVect[ pOpts->curOptIdx ]; + if (*pzArg != '-') + ppzOpts[ (*pOptsIdx)++ ] = + pOpts->origArgVect[ (pOpts->curOptIdx)++ ]; + return SUCCESS; + + } else { + /* + * IF we need another argument, be sure it is there and + * take it. + */ + if (pzArg[1] == NUL) { + if (pOpts->curOptIdx >= pOpts->origArgCt) + return FAILURE; + ppzOpts[ (*pOptsIdx)++ ] = + pOpts->origArgVect[ (pOpts->curOptIdx)++ ]; + } + return SUCCESS; + } + } + return SUCCESS; +} + +/* + * If the program wants sorted options (separated operands and options), + * then this routine will to the trick. + */ +LOCAL void +optionSort( tOptions* pOpts ) +{ + char** ppzOpts; + char** ppzOpds; + int optsIdx = 0; + int opdsIdx = 0; + + tOptState os = OPTSTATE_INITIALIZER(DEFINED); + + /* + * Disable for POSIX conformance, or if there are no operands. + */ + if ( (getenv( "POSIXLY_CORRECT" ) != NULL) + || NAMED_OPTS(pOpts)) + return; + + /* + * Make sure we can allocate two full-sized arg vectors. + */ + ppzOpts = malloc( pOpts->origArgCt * sizeof( char* )); + if (ppzOpts == NULL) + goto exit_no_mem; + + ppzOpds = malloc( pOpts->origArgCt * sizeof( char* )); + if (ppzOpds == NULL) { + free( ppzOpts ); + goto exit_no_mem; + } + + pOpts->curOptIdx = 1; + pOpts->pzCurOpt = NULL; + + /* + * Now, process all the options from our current position onward. + * (This allows interspersed options and arguments for the few + * non-standard programs that require it.) + */ + for (;;) { + char* pzArg; + tSuccess res; + + /* + * If we're out of arguments, we're done. Join the option and + * operand lists into the original argument vector. + */ + if (pOpts->curOptIdx >= pOpts->origArgCt) { + errno = 0; + goto joinLists; + } + + pzArg = pOpts->origArgVect[ pOpts->curOptIdx ]; + if (*pzArg != '-') { + ppzOpds[ opdsIdx++ ] = pOpts->origArgVect[ (pOpts->curOptIdx)++ ]; + continue; + } + + switch (pzArg[1]) { + case NUL: + /* + * A single hyphen is an operand. + */ + ppzOpds[ opdsIdx++ ] = pOpts->origArgVect[ (pOpts->curOptIdx)++ ]; + continue; + + case '-': + /* + * Two consecutive hypens. Put them on the options list and then + * _always_ force the remainder of the arguments to be operands. + */ + if (pzArg[2] == NUL) { + ppzOpts[ optsIdx++ ] = + pOpts->origArgVect[ (pOpts->curOptIdx)++ ]; + goto restOperands; + } + res = longOptionFind( pOpts, pzArg+2, &os ); + break; + + default: + /* + * If short options are not allowed, then do long + * option processing. Otherwise the character must be a + * short (i.e. single character) option. + */ + if ((pOpts->fOptSet & OPTPROC_SHORTOPT) == 0) { + res = longOptionFind( pOpts, pzArg+1, &os ); + } else { + res = shortOptionFind( pOpts, (tAoUC)pzArg[1], &os ); + } + break; + } + if (FAILED( res )) { + errno = EINVAL; + goto freeTemps; + } + + /* + * We've found an option. Add the argument to the option list. + * Next, we have to see if we need to pull another argument to be + * used as the option argument. + */ + ppzOpts[ optsIdx++ ] = pOpts->origArgVect[ (pOpts->curOptIdx)++ ]; + + if (OPTST_GET_ARGTYPE(os.pOD->fOptState) == OPARG_TYPE_NONE) { + /* + * No option argument. If we have a short option here, + * then scan for short options until we get to the end + * of the argument string. + */ + if ( (os.optType == TOPT_SHORT) + && FAILED( checkShortOpts( pOpts, pzArg+2, &os, + ppzOpts, &optsIdx )) ) { + errno = EINVAL; + goto freeTemps; + } + + } else if (os.pOD->fOptState & OPTST_ARG_OPTIONAL) { + switch (mayHandleArg( pOpts, pzArg+2, &os, ppzOpts, &optsIdx )) { + case FAILURE: errno = EIO; goto freeTemps; + case PROBLEM: errno = 0; goto joinLists; + } + + } else { + switch (mustHandleArg( pOpts, pzArg+2, &os, ppzOpts, &optsIdx )) { + case PROBLEM: + case FAILURE: errno = EIO; goto freeTemps; + } + } + } /* for (;;) */ + + restOperands: + while (pOpts->curOptIdx < pOpts->origArgCt) + ppzOpds[ opdsIdx++ ] = pOpts->origArgVect[ (pOpts->curOptIdx)++ ]; + + joinLists: + if (optsIdx > 0) + memcpy( pOpts->origArgVect + 1, ppzOpts, optsIdx * sizeof( char* )); + if (opdsIdx > 0) + memcpy( pOpts->origArgVect + 1 + optsIdx, + ppzOpds, opdsIdx * sizeof( char* )); + + freeTemps: + free( ppzOpts ); + free( ppzOpds ); + return; + + exit_no_mem: + errno = ENOMEM; + return; +} + +/* + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of autoopts/sort.c */ diff --git a/libopts/stack.c b/libopts/stack.c new file mode 100644 index 0000000..9d4a7c1 --- /dev/null +++ b/libopts/stack.c @@ -0,0 +1,264 @@ + +/* + * stack.c + * $Id: stack.c,v 4.19 2009/08/01 17:43:06 bkorb Exp $ + * Time-stamp: "2008-07-30 16:56:32 bkorb" + * + * This is a special option processing routine that will save the + * argument to an option in a FIFO queue. + * + * This file is part of AutoOpts, a companion to AutoGen. + * AutoOpts is free software. + * AutoOpts is copyright (c) 1992-2009 by Bruce Korb - all rights reserved + * + * AutoOpts is available under any one of two licenses. The license + * in use must be one of these two and the choice is under the control + * of the user of the license. + * + * The GNU Lesser General Public License, version 3 or later + * See the files "COPYING.lgplv3" and "COPYING.gplv3" + * + * The Modified Berkeley Software Distribution License + * See the file "COPYING.mbsd" + * + * These files have the following md5sums: + * + * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 + * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 + * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + */ + +#ifdef WITH_LIBREGEX +# include REGEX_HEADER +#endif + +/*=export_func optionUnstackArg + * private: + * + * what: Remove option args from a stack + * arg: + tOptions* + pOpts + program options descriptor + + * arg: + tOptDesc* + pOptDesc + the descriptor for this arg + + * + * doc: + * Invoked for options that are equivalenced to stacked options. +=*/ +void +optionUnstackArg( + tOptions* pOpts, + tOptDesc* pOptDesc ) +{ + int res; + + tArgList* pAL; + + if ((pOptDesc->fOptState & OPTST_RESET) != 0) + return; + pAL = (tArgList*)pOptDesc->optCookie; + + /* + * IF we don't have any stacked options, + * THEN indicate that we don't have any of these options + */ + if (pAL == NULL) { + pOptDesc->fOptState &= OPTST_PERSISTENT_MASK; + if ( (pOptDesc->fOptState & OPTST_INITENABLED) == 0) + pOptDesc->fOptState |= OPTST_DISABLED; + return; + } + +#ifdef WITH_LIBREGEX + { + regex_t re; + int i, ct, dIdx; + + if (regcomp( &re, pOptDesc->optArg.argString, REG_NOSUB ) != 0) + return; + + /* + * search the list for the entry(s) to remove. Entries that + * are removed are *not* copied into the result. The source + * index is incremented every time. The destination only when + * we are keeping a define. + */ + for (i = 0, dIdx = 0, ct = pAL->useCt; --ct >= 0; i++) { + tCC* pzSrc = pAL->apzArgs[ i ]; + char* pzEq = strchr( pzSrc, '=' ); + + if (pzEq != NULL) + *pzEq = NUL; + + res = regexec( &re, pzSrc, (size_t)0, NULL, 0 ); + switch (res) { + case 0: + /* + * Remove this entry by reducing the in-use count + * and *not* putting the string pointer back into + * the list. + */ + AGFREE(pzSrc); + pAL->useCt--; + break; + + default: + case REG_NOMATCH: + if (pzEq != NULL) + *pzEq = '='; + + /* + * IF we have dropped an entry + * THEN we have to move the current one. + */ + if (dIdx != i) + pAL->apzArgs[ dIdx ] = pzSrc; + dIdx++; + } + } + + regfree( &re ); + } +#else /* not WITH_LIBREGEX */ + { + int i, ct, dIdx; + + /* + * search the list for the entry(s) to remove. Entries that + * are removed are *not* copied into the result. The source + * index is incremented every time. The destination only when + * we are keeping a define. + */ + for (i = 0, dIdx = 0, ct = pAL->useCt; --ct >= 0; i++) { + tCC* pzSrc = pAL->apzArgs[ i ]; + char* pzEq = strchr( pzSrc, '=' ); + + if (pzEq != NULL) + *pzEq = NUL; + + if (strcmp( pzSrc, pOptDesc->optArg.argString ) == 0) { + /* + * Remove this entry by reducing the in-use count + * and *not* putting the string pointer back into + * the list. + */ + AGFREE(pzSrc); + pAL->useCt--; + } else { + if (pzEq != NULL) + *pzEq = '='; + + /* + * IF we have dropped an entry + * THEN we have to move the current one. + */ + if (dIdx != i) + pAL->apzArgs[ dIdx ] = pzSrc; + dIdx++; + } + } + } +#endif /* WITH_LIBREGEX */ + /* + * IF we have unstacked everything, + * THEN indicate that we don't have any of these options + */ + if (pAL->useCt == 0) { + pOptDesc->fOptState &= OPTST_PERSISTENT_MASK; + if ( (pOptDesc->fOptState & OPTST_INITENABLED) == 0) + pOptDesc->fOptState |= OPTST_DISABLED; + AGFREE( (void*)pAL ); + pOptDesc->optCookie = NULL; + } +} + + +/* + * Put an entry into an argument list. The first argument points to + * a pointer to the argument list structure. It gets passed around + * as an opaque address. + */ +LOCAL void +addArgListEntry( void** ppAL, void* entry ) +{ + tArgList* pAL = *(void**)ppAL; + + /* + * IF we have never allocated one of these, + * THEN allocate one now + */ + if (pAL == NULL) { + pAL = (tArgList*)AGALOC( sizeof( *pAL ), "new option arg stack" ); + if (pAL == NULL) + return; + pAL->useCt = 0; + pAL->allocCt = MIN_ARG_ALLOC_CT; + *ppAL = (void*)pAL; + } + + /* + * ELSE if we are out of room + * THEN make it bigger + */ + else if (pAL->useCt >= pAL->allocCt) { + size_t sz = sizeof( *pAL ); + pAL->allocCt += INCR_ARG_ALLOC_CT; + + /* + * The base structure contains space for MIN_ARG_ALLOC_CT + * pointers. We subtract it off to find our augment size. + */ + sz += sizeof(char*) * (pAL->allocCt - MIN_ARG_ALLOC_CT); + pAL = (tArgList*)AGREALOC( (void*)pAL, sz, "expanded opt arg stack" ); + if (pAL == NULL) + return; + *ppAL = (void*)pAL; + } + + /* + * Insert the new argument into the list + */ + pAL->apzArgs[ (pAL->useCt)++ ] = entry; +} + + +/*=export_func optionStackArg + * private: + * + * what: put option args on a stack + * arg: + tOptions* + pOpts + program options descriptor + + * arg: + tOptDesc* + pOptDesc + the descriptor for this arg + + * + * doc: + * Keep an entry-ordered list of option arguments. +=*/ +void +optionStackArg( + tOptions* pOpts, + tOptDesc* pOD ) +{ + char * pz; + + if ((pOD->fOptState & OPTST_RESET) != 0) { + tArgList* pAL = (void*)pOD->optCookie; + int ix; + if (pAL == NULL) + return; + + ix = pAL->useCt; + while (--ix >= 0) + AGFREE(pAL->apzArgs[ix]); + AGFREE(pAL); + + } else { + if (pOD->optArg.argString == NULL) + return; + + AGDUPSTR(pz, pOD->optArg.argString, "stack arg"); + addArgListEntry( &(pOD->optCookie), (void*)pz ); + } +} +/* + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of autoopts/stack.c */ diff --git a/libopts/streqvcmp.c b/libopts/streqvcmp.c new file mode 100644 index 0000000..cb437d2 --- /dev/null +++ b/libopts/streqvcmp.c @@ -0,0 +1,266 @@ + +/* + * $Id: streqvcmp.c,v 4.17 2009/08/01 17:43:06 bkorb Exp $ + * Time-stamp: "2008-12-26 10:15:46 bkorb" + * + * String Equivalence Comparison + * + * These routines allow any character to be mapped to any other + * character before comparison. In processing long option names, + * the characters "-", "_" and "^" all need to be equivalent + * (because they are treated so by different development environments). + * + * This file is part of AutoOpts, a companion to AutoGen. + * AutoOpts is free software. + * AutoOpts is copyright (c) 1992-2009 by Bruce Korb - all rights reserved + * + * AutoOpts is available under any one of two licenses. The license + * in use must be one of these two and the choice is under the control + * of the user of the license. + * + * The GNU Lesser General Public License, version 3 or later + * See the files "COPYING.lgplv3" and "COPYING.gplv3" + * + * The Modified Berkeley Software Distribution License + * See the file "COPYING.mbsd" + * + * These files have the following md5sums: + * + * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 + * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 + * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + * + * This array is designed for mapping upper and lower case letter + * together for a case independent comparison. The mappings are + * based upon ascii character sequences. + */ +static unsigned char charmap[] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, '\a', + '\b', '\t', '\n', '\v', '\f', '\r', 0x0E, 0x0F, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, + + ' ', '!', '"', '#', '$', '%', '&', '\'', + '(', ')', '*', '+', ',', '-', '.', '/', + '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', ':', ';', '<', '=', '>', '?', + + '@', 'a', 'b', 'c', 'd', 'e', 'f', 'g', + 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', + 'x', 'y', 'z', '[', '\\', ']', '^', '_', + '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', + 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', + 'x', 'y', 'z', '{', '|', '}', '~', 0x7f, + + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, + 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, + 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, + 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, + 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, + + 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, + 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, + 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, + 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, + 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, + 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, + 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, + 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, +}; + + +/*=export_func strneqvcmp + * + * what: compare two strings with an equivalence mapping + * + * arg: + char const* + str1 + first string + + * arg: + char const* + str2 + second string + + * arg: + int + ct + compare length + + * + * ret_type: int + * ret_desc: the difference between two differing characters + * + * doc: + * + * Using a character mapping, two strings are compared for "equivalence". + * Each input character is mapped to a comparison character and the + * mapped-to characters are compared for the two NUL terminated input strings. + * The comparison is limited to @code{ct} bytes. + * This function name is mapped to option_strneqvcmp so as to not conflict + * with the POSIX name space. + * + * err: none checked. Caller responsible for seg faults. +=*/ +int +strneqvcmp( tCC* s1, tCC* s2, int ct ) +{ + for (; ct > 0; --ct) { + unsigned char u1 = (unsigned char) *s1++; + unsigned char u2 = (unsigned char) *s2++; + int dif = charmap[ u1 ] - charmap[ u2 ]; + + if (dif != 0) + return dif; + + if (u1 == NUL) + return 0; + } + + return 0; +} + + +/*=export_func streqvcmp + * + * what: compare two strings with an equivalence mapping + * + * arg: + char const* + str1 + first string + + * arg: + char const* + str2 + second string + + * + * ret_type: int + * ret_desc: the difference between two differing characters + * + * doc: + * + * Using a character mapping, two strings are compared for "equivalence". + * Each input character is mapped to a comparison character and the + * mapped-to characters are compared for the two NUL terminated input strings. + * This function name is mapped to option_streqvcmp so as to not conflict + * with the POSIX name space. + * + * err: none checked. Caller responsible for seg faults. +=*/ +int +streqvcmp( tCC* s1, tCC* s2 ) +{ + for (;;) { + unsigned char u1 = (unsigned char) *s1++; + unsigned char u2 = (unsigned char) *s2++; + int dif = charmap[ u1 ] - charmap[ u2 ]; + + if (dif != 0) + return dif; + + if (u1 == NUL) + return 0; + } +} + + +/*=export_func streqvmap + * + * what: Set the character mappings for the streqv functions + * + * arg: + char + From + Input character + + * arg: + char + To + Mapped-to character + + * arg: + int + ct + compare length + + * + * doc: + * + * Set the character mapping. If the count (@code{ct}) is set to zero, then + * the map is cleared by setting all entries in the map to their index + * value. Otherwise, the "@code{From}" character is mapped to the "@code{To}" + * character. If @code{ct} is greater than 1, then @code{From} and @code{To} + * are incremented and the process repeated until @code{ct} entries have been + * set. For example, + * @example + * streqvmap( 'a', 'A', 26 ); + * @end example + * @noindent + * will alter the mapping so that all English lower case letters + * will map to upper case. + * + * This function name is mapped to option_streqvmap so as to not conflict + * with the POSIX name space. + * + * err: none. +=*/ +void +streqvmap( char From, char To, int ct ) +{ + if (ct == 0) { + ct = sizeof( charmap ) - 1; + do { + charmap[ ct ] = ct; + } while (--ct >= 0); + } + + else { + int chTo = (int)To & 0xFF; + int chFrom = (int)From & 0xFF; + + do { + charmap[ chFrom ] = (unsigned)chTo; + chFrom++; + chTo++; + if ((chFrom >= sizeof( charmap )) || (chTo >= sizeof( charmap ))) + break; + } while (--ct > 0); + } +} + + +/*=export_func strequate + * + * what: map a list of characters to the same value + * + * arg: + char const* + ch_list + characters to equivalence + + * + * doc: + * + * Each character in the input string get mapped to the first character + * in the string. + * This function name is mapped to option_strequate so as to not conflict + * with the POSIX name space. + * + * err: none. +=*/ +void +strequate( char const* s ) +{ + if ((s != NULL) && (*s != NUL)) { + unsigned char equiv = (unsigned)*s; + while (*s != NUL) + charmap[ (unsigned)*(s++) ] = equiv; + } +} + + +/*=export_func strtransform + * + * what: convert a string into its mapped-to value + * + * arg: + char* + dest + output string + + * arg: + char const* + src + input string + + * + * doc: + * + * Each character in the input string is mapped and the mapped-to + * character is put into the output. + * This function name is mapped to option_strtransform so as to not conflict + * with the POSIX name space. + * + * The source and destination may be the same. + * + * err: none. +=*/ +void +strtransform( char* d, char const* s ) +{ + do { + *(d++) = (char)charmap[ (unsigned)*s ]; + } while (*(s++) != NUL); +} + +/* + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of autoopts/streqvcmp.c */ diff --git a/libopts/text_mmap.c b/libopts/text_mmap.c new file mode 100644 index 0000000..14e1f51 --- /dev/null +++ b/libopts/text_mmap.c @@ -0,0 +1,383 @@ +/* + * $Id: text_mmap.c,v 4.21 2009/08/01 17:43:06 bkorb Exp $ + * + * Time-stamp: "2007-07-04 11:35:49 bkorb" + * + * This file is part of AutoOpts, a companion to AutoGen. + * AutoOpts is free software. + * AutoOpts is copyright (c) 1992-2009 by Bruce Korb - all rights reserved + * + * AutoOpts is available under any one of two licenses. The license + * in use must be one of these two and the choice is under the control + * of the user of the license. + * + * The GNU Lesser General Public License, version 3 or later + * See the files "COPYING.lgplv3" and "COPYING.gplv3" + * + * The Modified Berkeley Software Distribution License + * See the file "COPYING.mbsd" + * + * These files have the following md5sums: + * + * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 + * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 + * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + */ + +#ifndef MAP_ANONYMOUS +# ifdef MAP_ANON +# define MAP_ANONYMOUS MAP_ANON +# endif +#endif + +/* + * Some weird systems require that a specifically invalid FD number + * get passed in as an argument value. Which value is that? Well, + * as everybody knows, if open(2) fails, it returns -1, so that must + * be the value. :) + */ +#define AO_INVALID_FD -1 + +#define FILE_WRITABLE(_prt,_flg) \ + ( (_prt & PROT_WRITE) \ + && ((_flg & (MAP_SHARED|MAP_PRIVATE)) == MAP_SHARED)) +#define MAP_FAILED_PTR ((void*)MAP_FAILED) + +/*=export_func text_mmap + * private: + * + * what: map a text file with terminating NUL + * + * arg: char const*, pzFile, name of the file to map + * arg: int, prot, mmap protections (see mmap(2)) + * arg: int, flags, mmap flags (see mmap(2)) + * arg: tmap_info_t*, mapinfo, returned info about the mapping + * + * ret-type: void* + * ret-desc: The mmaped data address + * + * doc: + * + * This routine will mmap a file into memory ensuring that there is at least + * one @file{NUL} character following the file data. It will return the + * address where the file contents have been mapped into memory. If there is a + * problem, then it will return @code{MAP_FAILED} and set @file{errno} + * appropriately. + * + * The named file does not exist, @code{stat(2)} will set @file{errno} as it + * will. If the file is not a regular file, @file{errno} will be + * @code{EINVAL}. At that point, @code{open(2)} is attempted with the access + * bits set appropriately for the requested @code{mmap(2)} protections and flag + * bits. On failure, @file{errno} will be set according to the documentation + * for @code{open(2)}. If @code{mmap(2)} fails, @file{errno} will be set as + * that routine sets it. If @code{text_mmap} works to this point, a valid + * address will be returned, but there may still be ``issues''. + * + * If the file size is not an even multiple of the system page size, then + * @code{text_map} will return at this point and @file{errno} will be zero. + * Otherwise, an anonymous map is attempted. If not available, then an attempt + * is made to @code{mmap(2)} @file{/dev/zero}. If any of these fail, the + * address of the file's data is returned, bug @code{no} @file{NUL} characters + * are mapped after the end of the data. + * + * see: mmap(2), open(2), stat(2) + * + * err: Any error code issued by mmap(2), open(2), stat(2) is possible. + * Additionally, if the specified file is not a regular file, then + * errno will be set to @code{EINVAL}. + * + * example: + * #include + * tmap_info_t mi; + * int no_nul; + * void* data = text_mmap( "file", PROT_WRITE, MAP_PRIVATE, &mi ); + * if (data == MAP_FAILED) return; + * no_nul = (mi.txt_size == mi.txt_full_size); + * << use the data >> + * text_munmap( &mi ); +=*/ +void* +text_mmap( char const* pzFile, int prot, int flags, tmap_info_t* pMI ) +{ + memset( pMI, 0, sizeof(*pMI) ); +#ifdef HAVE_MMAP + pMI->txt_zero_fd = -1; +#endif + pMI->txt_fd = -1; + + /* + * Make sure we can stat the regular file. Save the file size. + */ + { + struct stat sb; + if (stat( pzFile, &sb ) != 0) { + pMI->txt_errno = errno; + return MAP_FAILED_PTR; + } + + if (! S_ISREG( sb.st_mode )) { + pMI->txt_errno = errno = EINVAL; + return MAP_FAILED_PTR; + } + + pMI->txt_size = sb.st_size; + } + + /* + * Map mmap flags and protections into open flags and do the open. + */ + { + int o_flag; + /* + * See if we will be updating the file. If we can alter the memory + * and if we share the data and we are *not* copy-on-writing the data, + * then our updates will show in the file, so we must open with + * write access. + */ + if (FILE_WRITABLE(prot,flags)) + o_flag = O_RDWR; + else + o_flag = O_RDONLY; + + /* + * If you're not sharing the file and you are writing to it, + * then don't let anyone else have access to the file. + */ + if (((flags & MAP_SHARED) == 0) && (prot & PROT_WRITE)) + o_flag |= O_EXCL; + + pMI->txt_fd = open( pzFile, o_flag ); + } + + if (pMI->txt_fd == AO_INVALID_FD) { + pMI->txt_errno = errno; + return MAP_FAILED_PTR; + } + +#ifdef HAVE_MMAP /* * * * * WITH MMAP * * * * * */ + /* + * do the mmap. If we fail, then preserve errno, close the file and + * return the failure. + */ + pMI->txt_data = + mmap(NULL, pMI->txt_size+1, prot, flags, pMI->txt_fd, (size_t)0); + if (pMI->txt_data == MAP_FAILED_PTR) { + pMI->txt_errno = errno; + goto fail_return; + } + + /* + * Most likely, everything will turn out fine now. The only difficult + * part at this point is coping with files with sizes that are a multiple + * of the page size. Handling that is what this whole thing is about. + */ + pMI->txt_zero_fd = -1; + pMI->txt_errno = 0; + + { + void* pNuls; +#ifdef _SC_PAGESIZE + size_t pgsz = sysconf(_SC_PAGESIZE); +#else + size_t pgsz = getpagesize(); +#endif + /* + * Compute the pagesize rounded mapped memory size. + * IF this is not the same as the file size, then there are NUL's + * at the end of the file mapping and all is okay. + */ + pMI->txt_full_size = (pMI->txt_size + (pgsz - 1)) & ~(pgsz - 1); + if (pMI->txt_size != pMI->txt_full_size) + return pMI->txt_data; + + /* + * Still here? We have to remap the trailing inaccessible page + * either anonymously or to /dev/zero. + */ + pMI->txt_full_size += pgsz; +#if defined(MAP_ANONYMOUS) + pNuls = mmap( + (void*)(((char*)pMI->txt_data) + pMI->txt_size), + pgsz, PROT_READ|PROT_WRITE, + MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE, AO_INVALID_FD, (size_t)0); + + if (pNuls != MAP_FAILED_PTR) + return pMI->txt_data; + + pMI->txt_errno = errno; + +#elif defined(HAVE_DEV_ZERO) + pMI->txt_zero_fd = open( "/dev/zero", O_RDONLY ); + + if (pMI->txt_zero_fd == AO_INVALID_FD) { + pMI->txt_errno = errno; + + } else { + pNuls = mmap( + (void*)(((char*)pMI->txt_data) + pMI->txt_size), pgsz, + PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, + pMI->txt_zero_fd, 0 ); + + if (pNuls != MAP_FAILED_PTR) + return pMI->txt_data; + + pMI->txt_errno = errno; + close( pMI->txt_zero_fd ); + pMI->txt_zero_fd = -1; + } +#endif + + pMI->txt_full_size = pMI->txt_size; + } + + { + void* p = AGALOC( pMI->txt_size+1, "file text" ); + memcpy( p, pMI->txt_data, pMI->txt_size ); + ((char*)p)[pMI->txt_size] = NUL; + munmap(pMI->txt_data, pMI->txt_size ); + pMI->txt_data = p; + } + pMI->txt_alloc = 1; + return pMI->txt_data; + +#else /* * * * * * no HAVE_MMAP * * * * * */ + + pMI->txt_data = AGALOC( pMI->txt_size+1, "file text" ); + if (pMI->txt_data == NULL) { + pMI->txt_errno = ENOMEM; + goto fail_return; + } + + { + size_t sz = pMI->txt_size; + char* pz = pMI->txt_data; + + while (sz > 0) { + ssize_t rdct = read( pMI->txt_fd, pz, sz ); + if (rdct <= 0) { + pMI->txt_errno = errno; + fprintf( stderr, zFSErrReadFile, + errno, strerror( errno ), pzFile ); + free( pMI->txt_data ); + goto fail_return; + } + + pz += rdct; + sz -= rdct; + } + + *pz = NUL; + } + + /* + * We never need a dummy page mapped in + */ + pMI->txt_zero_fd = -1; + pMI->txt_errno = 0; + + return pMI->txt_data; + +#endif /* * * * * * no HAVE_MMAP * * * * * */ + + fail_return: + if (pMI->txt_fd >= 0) { + close( pMI->txt_fd ); + pMI->txt_fd = -1; + } + errno = pMI->txt_errno; + pMI->txt_data = MAP_FAILED_PTR; + return pMI->txt_data; +} + + +/*=export_func text_munmap + * private: + * + * what: unmap the data mapped in by text_mmap + * + * arg: tmap_info_t*, mapinfo, info about the mapping + * + * ret-type: int + * ret-desc: -1 or 0. @file{errno} will have the error code. + * + * doc: + * + * This routine will unmap the data mapped in with @code{text_mmap} and close + * the associated file descriptors opened by that function. + * + * see: munmap(2), close(2) + * + * err: Any error code issued by munmap(2) or close(2) is possible. +=*/ +int +text_munmap( tmap_info_t* pMI ) +{ +#ifdef HAVE_MMAP + int res = 0; + if (pMI->txt_alloc) { + /* + * IF the user has write permission and the text is not mapped private, + * then write back any changes. Hopefully, nobody else has modified + * the file in the mean time. + */ + if ( ((pMI->txt_prot & PROT_WRITE) != 0) + && ((pMI->txt_flags & MAP_PRIVATE) == 0)) { + + if (lseek(pMI->txt_fd, (size_t)0, SEEK_SET) != 0) + goto error_return; + + res = (write( pMI->txt_fd, pMI->txt_data, pMI->txt_size ) < 0) + ? errno : 0; + } + + AGFREE( pMI->txt_data ); + errno = res; + } else { + res = munmap( pMI->txt_data, pMI->txt_full_size ); + } + if (res != 0) + goto error_return; + + res = close( pMI->txt_fd ); + if (res != 0) + goto error_return; + + pMI->txt_fd = -1; + errno = 0; + if (pMI->txt_zero_fd != -1) { + res = close( pMI->txt_zero_fd ); + pMI->txt_zero_fd = -1; + } + + error_return: + pMI->txt_errno = errno; + return res; +#else /* HAVE_MMAP */ + + errno = 0; + /* + * IF the memory is writable *AND* it is not private (copy-on-write) + * *AND* the memory is "sharable" (seen by other processes) + * THEN rewrite the data. + */ + if ( FILE_WRITABLE(pMI->txt_prot, pMI->txt_flags) + && (lseek( pMI->txt_fd, 0, SEEK_SET ) >= 0) ) { + write( pMI->txt_fd, pMI->txt_data, pMI->txt_size ); + } + + close( pMI->txt_fd ); + pMI->txt_fd = -1; + pMI->txt_errno = errno; + free( pMI->txt_data ); + + return pMI->txt_errno; +#endif /* HAVE_MMAP */ +} + +/* + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of autoopts/text_mmap.c */ diff --git a/libopts/time.c b/libopts/time.c new file mode 100644 index 0000000..63d3312 --- /dev/null +++ b/libopts/time.c @@ -0,0 +1,88 @@ + +/* + * $Id: time.c,v 4.5 2009/08/01 17:43:06 bkorb Exp $ + * Time-stamp: "2008-11-16 14:51:48 bkorb" + * + * This file is part of AutoOpts, a companion to AutoGen. + * AutoOpts is free software. + * AutoOpts is copyright (c) 1992-2009 by Bruce Korb - all rights reserved + * + * AutoOpts is available under any one of two licenses. The license + * in use must be one of these two and the choice is under the control + * of the user of the license. + * + * The GNU Lesser General Public License, version 3 or later + * See the files "COPYING.lgplv3" and "COPYING.gplv3" + * + * The Modified Berkeley Software Distribution License + * See the file "COPYING.mbsd" + * + * These files have the following md5sums: + * + * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 + * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 + * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + */ + +#ifndef HAVE_PARSE_DURATION +#include + +static inline char * +ao_xstrdup(char const * pz) +{ + char * str; + AGDUPSTR(str, pz, "time val str"); + return str; +} + +#define xstrdup(_s) ao_xstrdup(_s) + +#include "parse-duration.c" + +#undef xstrdup +#endif + +/*=export_func optionTimeVal + * private: + * + * what: process an option with a time value. + * arg: + tOptions* + pOpts + program options descriptor + + * arg: + tOptDesc* + pOptDesc + the descriptor for this arg + + * + * doc: + * Decipher a time duration value. +=*/ +void +optionTimeVal(tOptions* pOpts, tOptDesc* pOD ) +{ + long val; + + if ((pOD->fOptState & OPTST_RESET) != 0) + return; + + val = parse_duration(pOD->optArg.argString); + if (errno != 0) + goto bad_time; + + if (pOD->fOptState & OPTST_ALLOC_ARG) { + AGFREE(pOD->optArg.argString); + pOD->fOptState &= ~OPTST_ALLOC_ARG; + } + + pOD->optArg.argInt = val; + return; + +bad_time: + fprintf( stderr, zNotNumber, pOpts->pzProgName, pOD->optArg.argString ); + if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0) + (*(pOpts->pUsageProc))(pOpts, EXIT_FAILURE); + + pOD->optArg.argInt = ~0; +} +/* + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of autoopts/numeric.c */ diff --git a/libopts/tokenize.c b/libopts/tokenize.c new file mode 100644 index 0000000..7429567 --- /dev/null +++ b/libopts/tokenize.c @@ -0,0 +1,323 @@ +/* + * This file defines the string_tokenize interface + * Time-stamp: "2007-11-12 20:40:36 bkorb" + * + * This file is part of AutoOpts, a companion to AutoGen. + * AutoOpts is free software. + * AutoOpts is copyright (c) 1992-2009 by Bruce Korb - all rights reserved + * + * AutoOpts is available under any one of two licenses. The license + * in use must be one of these two and the choice is under the control + * of the user of the license. + * + * The GNU Lesser General Public License, version 3 or later + * See the files "COPYING.lgplv3" and "COPYING.gplv3" + * + * The Modified Berkeley Software Distribution License + * See the file "COPYING.mbsd" + * + * These files have the following md5sums: + * + * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 + * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 + * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + */ + +#include +#include + +#define cc_t const unsigned char +#define ch_t unsigned char + +/* = = = START-STATIC-FORWARD = = = */ +/* static forward declarations maintained by mk-fwd */ +static void +copy_cooked( ch_t** ppDest, char const ** ppSrc ); + +static void +copy_raw( ch_t** ppDest, char const ** ppSrc ); +/* = = = END-STATIC-FORWARD = = = */ + +static void +copy_cooked( ch_t** ppDest, char const ** ppSrc ) +{ + ch_t* pDest = (ch_t*)*ppDest; + const ch_t* pSrc = (const ch_t*)(*ppSrc + 1); + + for (;;) { + ch_t ch = *(pSrc++); + switch (ch) { + case NUL: *ppSrc = NULL; return; + case '"': goto done; + case '\\': + pSrc += ao_string_cook_escape_char( (char*)pSrc, (char*)&ch, 0x7F ); + if (ch == 0x7F) + break; + /* FALLTHROUGH */ + + default: + *(pDest++) = ch; + } + } + + done: + *ppDest = (ch_t*)pDest; /* next spot for storing character */ + *ppSrc = (char const *)pSrc; /* char following closing quote */ +} + + +static void +copy_raw( ch_t** ppDest, char const ** ppSrc ) +{ + ch_t* pDest = *ppDest; + cc_t* pSrc = (cc_t*) (*ppSrc + 1); + + for (;;) { + ch_t ch = *(pSrc++); + switch (ch) { + case NUL: *ppSrc = NULL; return; + case '\'': goto done; + case '\\': + /* + * *Four* escapes are handled: newline removal, escape char + * quoting and apostrophe quoting + */ + switch (*pSrc) { + case NUL: *ppSrc = NULL; return; + case '\r': + if (*(++pSrc) == '\n') + ++pSrc; + continue; + + case '\n': + ++pSrc; + continue; + + case '\'': + ch = '\''; + /* FALLTHROUGH */ + + case '\\': + ++pSrc; + break; + } + /* FALLTHROUGH */ + + default: + *(pDest++) = ch; + } + } + + done: + *ppDest = pDest; /* next spot for storing character */ + *ppSrc = (char const *) pSrc; /* char following closing quote */ +} + + +/*=export_func ao_string_tokenize + * + * what: tokenize an input string + * + * arg: + char const* + string + string to be tokenized + + * + * ret_type: token_list_t* + * ret_desc: pointer to a structure that lists each token + * + * doc: + * + * This function will convert one input string into a list of strings. + * The list of strings is derived by separating the input based on + * white space separation. However, if the input contains either single + * or double quote characters, then the text after that character up to + * a matching quote will become the string in the list. + * + * The returned pointer should be deallocated with @code{free(3C)} when + * are done using the data. The data are placed in a single block of + * allocated memory. Do not deallocate individual token/strings. + * + * The structure pointed to will contain at least these two fields: + * @table @samp + * @item tkn_ct + * The number of tokens found in the input string. + * @item tok_list + * An array of @code{tkn_ct + 1} pointers to substring tokens, with + * the last pointer set to NULL. + * @end table + * + * There are two types of quoted strings: single quoted (@code{'}) and + * double quoted (@code{"}). Singly quoted strings are fairly raw in that + * escape characters (@code{\\}) are simply another character, except when + * preceding the following characters: + * @example + * @code{\\} double backslashes reduce to one + * @code{'} incorporates the single quote into the string + * @code{\n} suppresses both the backslash and newline character + * @end example + * + * Double quote strings are formed according to the rules of string + * constants in ANSI-C programs. + * + * example: + * @example + * #include + * int ix; + * token_list_t* ptl = ao_string_tokenize( some_string ) + * for (ix = 0; ix < ptl->tkn_ct; ix++) + * do_something_with_tkn( ptl->tkn_list[ix] ); + * free( ptl ); + * @end example + * Note that everything is freed with the one call to @code{free(3C)}. + * + * err: + * NULL is returned and @code{errno} will be set to indicate the problem: + * @itemize @bullet + * @item + * @code{EINVAL} - There was an unterminated quoted string. + * @item + * @code{ENOENT} - The input string was empty. + * @item + * @code{ENOMEM} - There is not enough memory. + * @end itemize +=*/ +token_list_t* +ao_string_tokenize( char const* str ) +{ + int max_token_ct = 1; /* allow for trailing NUL on string */ + token_list_t* res; + + if (str == NULL) goto bogus_str; + + /* + * Trim leading white space. Use "ENOENT" and a NULL return to indicate + * an empty string was passed. + */ + while (IS_WHITESPACE_CHAR(*str)) str++; + if (*str == NUL) { + bogus_str: + errno = ENOENT; + return NULL; + } + + /* + * Take an approximate count of tokens. If no quoted strings are used, + * it will be accurate. If quoted strings are used, it will be a little + * high and we'll squander the space for a few extra pointers. + */ + { + cc_t* pz = (cc_t*)str; + + do { + max_token_ct++; + while (! IS_WHITESPACE_CHAR(*++pz)) + if (*pz == NUL) goto found_nul; + while (IS_WHITESPACE_CHAR(*pz)) pz++; + } while (*pz != NUL); + + found_nul: + ; + } + + res = malloc( sizeof(*res) + strlen(str) + (max_token_ct * sizeof(ch_t*)) ); + if (res == NULL) { + errno = ENOMEM; + return res; + } + + /* + * Now copy each token into the output buffer. + */ + { + ch_t* pzDest = (ch_t*)(res->tkn_list + (max_token_ct + 1)); + res->tkn_ct = 0; + + do { + res->tkn_list[ res->tkn_ct++ ] = pzDest; + for (;;) { + int ch = (ch_t)*str; + if (IS_WHITESPACE_CHAR(ch)) { + found_white_space: + while (IS_WHITESPACE_CHAR(*++str)) ; + break; + } + + switch (ch) { + case '"': + copy_cooked( &pzDest, &str ); + if (str == NULL) { + free(res); + errno = EINVAL; + return NULL; + } + if (IS_WHITESPACE_CHAR(*str)) + goto found_white_space; + break; + + case '\'': + copy_raw( &pzDest, &str ); + if (str == NULL) { + free(res); + errno = EINVAL; + return NULL; + } + if (IS_WHITESPACE_CHAR(*str)) + goto found_white_space; + break; + + case NUL: + goto copy_done; + + default: + str++; + *(pzDest++) = ch; + } + } copy_done:; + + /* + * NUL terminate the last token and see if we have any more tokens. + */ + *(pzDest++) = NUL; + } while (*str != NUL); + + res->tkn_list[ res->tkn_ct ] = NULL; + } + + return res; +} + +#ifdef TEST +#include +#include + +int +main( int argc, char** argv ) +{ + if (argc == 1) { + printf("USAGE: %s arg [ ... ]\n", *argv); + return 1; + } + while (--argc > 0) { + char* arg = *(++argv); + token_list_t* p = ao_string_tokenize( arg ); + if (p == NULL) { + printf( "Parsing string ``%s'' failed:\n\terrno %d (%s)\n", + arg, errno, strerror( errno )); + } else { + int ix = 0; + printf( "Parsed string ``%s''\ninto %d tokens:\n", arg, p->tkn_ct ); + do { + printf( " %3d: ``%s''\n", ix+1, p->tkn_list[ix] ); + } while (++ix < p->tkn_ct); + free(p); + } + } + return 0; +} +#endif + +/* + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of autoopts/tokenize.c */ diff --git a/libopts/usage.c b/libopts/usage.c new file mode 100644 index 0000000..065b576 --- /dev/null +++ b/libopts/usage.c @@ -0,0 +1,762 @@ + +/* + * usage.c $Id: usage.c,v 4.30 2009/08/01 17:43:06 bkorb Exp $ + * Time-stamp: "2009-01-17 13:18:23 bkorb" + * + * This module implements the default usage procedure for + * Automated Options. It may be overridden, of course. + * + * Sort options: + --start=END-[S]TATIC-FORWARD --patt='^/\*($|[^:])' \ + --out=xx.c key='^[a-zA-Z0-9_]+\(' --trail='^/\*:' \ + --spac=2 --input=usage.c + */ + +/* + * This file is part of AutoOpts, a companion to AutoGen. + * AutoOpts is free software. + * AutoOpts is copyright (c) 1992-2009 by Bruce Korb - all rights reserved + * + * AutoOpts is available under any one of two licenses. The license + * in use must be one of these two and the choice is under the control + * of the user of the license. + * + * The GNU Lesser General Public License, version 3 or later + * See the files "COPYING.lgplv3" and "COPYING.gplv3" + * + * The Modified Berkeley Software Distribution License + * See the file "COPYING.mbsd" + * + * These files have the following md5sums: + * + * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 + * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 + * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + */ + +#define OPTPROC_L_N_S (OPTPROC_LONGOPT | OPTPROC_SHORTOPT) + +static arg_types_t argTypes; + +FILE* option_usage_fp = NULL; +static char zOptFmtLine[ 16 ]; +static ag_bool displayEnum; + +/* = = = START-STATIC-FORWARD = = = */ +/* static forward declarations maintained by mk-fwd */ +static ag_bool +checkGNUUsage( tOptions* pOpts ); + +static void +printExtendedUsage( + tOptions* pOptions, + tOptDesc* pOD, + arg_types_t* pAT ); + +static void +printInitList( + tCC* const* papz, + ag_bool* pInitIntro, + tCC* pzRc, + tCC* pzPN ); + +static void +printOneUsage( + tOptions* pOptions, + tOptDesc* pOD, + arg_types_t* pAT ); + +static void +printOptionUsage( + tOptions* pOpts, + int ex_code, + tCC* pOptTitle ); + +static void +printProgramDetails( tOptions* pOptions ); + +static int +setGnuOptFmts( tOptions* pOpts, tCC** ppT ); + +static int +setStdOptFmts( tOptions* pOpts, tCC** ppT ); +/* = = = END-STATIC-FORWARD = = = */ + + +/* + * Figure out if we should try to format usage text sort-of like + * the way many GNU programs do. + */ +static ag_bool +checkGNUUsage( tOptions* pOpts ) +{ + char* pz = getenv( "AUTOOPTS_USAGE" ); + if (pz == NULL) + ; + + else if (streqvcmp( pz, "gnu" ) == 0) + pOpts->fOptSet |= OPTPROC_GNUUSAGE; + + else if (streqvcmp( pz, "autoopts" ) == 0) + pOpts->fOptSet &= ~OPTPROC_GNUUSAGE; + + return (pOpts->fOptSet & OPTPROC_GNUUSAGE) ? AG_TRUE : AG_FALSE; +} + + +/*=export_func optionOnlyUsage + * + * what: Print usage text for just the options + * arg: + tOptions* + pOpts + program options descriptor + + * arg: + int + ex_code + exit code for calling exit(3) + + * + * doc: + * This routine will print only the usage for each option. + * This function may be used when the emitted usage must incorporate + * information not available to AutoOpts. +=*/ +void +optionOnlyUsage( + tOptions* pOpts, + int ex_code ) +{ + tCC* pOptTitle = NULL; + + /* + * Determine which header and which option formatting strings to use + */ + if (checkGNUUsage(pOpts)) { + (void)setGnuOptFmts( pOpts, &pOptTitle ); + } + else { + (void)setStdOptFmts( pOpts, &pOptTitle ); + } + + printOptionUsage( pOpts, ex_code, pOptTitle ); +} + + +/*=export_func optionUsage + * private: + * + * what: Print usage text + * arg: + tOptions* + pOptions + program options descriptor + + * arg: + int + exitCode + exit code for calling exit(3) + + * + * doc: + * This routine will print usage in both GNU-standard and AutoOpts-expanded + * formats. The descriptor specifies the default, but AUTOOPTS_USAGE will + * over-ride this, providing the value of it is set to either "gnu" or + * "autoopts". This routine will @strong{not} return. + * + * If "exitCode" is "EX_USAGE" (normally 64), then output will to to stdout + * and the actual exit code will be "EXIT_SUCCESS". +=*/ +void +optionUsage( + tOptions* pOptions, + int usage_exit_code ) +{ + int actual_exit_code = + (usage_exit_code == EX_USAGE) ? EXIT_SUCCESS : usage_exit_code; + + displayEnum = AG_FALSE; + + /* + * Paged usage will preset option_usage_fp to an output file. + * If it hasn't already been set, then set it to standard output + * on successful exit (help was requested), otherwise error out. + * + * Test the version before obtaining pzFullUsage or pzShortUsage. + * These fields do not exist before revision 30. + */ + { + char const * pz; + + if (actual_exit_code == EXIT_SUCCESS) { + pz = (pOptions->structVersion >= 30 * 4096) + ? pOptions->pzFullUsage : NULL; + + if (option_usage_fp == NULL) + option_usage_fp = stdout; + } else { + pz = (pOptions->structVersion >= 30 * 4096) + ? pOptions->pzShortUsage : NULL; + + if (option_usage_fp == NULL) + option_usage_fp = stderr; + } + + if (pz != NULL) { + fputs(pz, option_usage_fp); + exit(actual_exit_code); + } + } + + fprintf( option_usage_fp, pOptions->pzUsageTitle, pOptions->pzProgName ); + + { + tCC* pOptTitle = NULL; + + /* + * Determine which header and which option formatting strings to use + */ + if (checkGNUUsage(pOptions)) { + int flen = setGnuOptFmts( pOptions, &pOptTitle ); + sprintf( zOptFmtLine, zFmtFmt, flen ); + fputc( '\n', option_usage_fp ); + } + else { + int flen = setStdOptFmts( pOptions, &pOptTitle ); + sprintf( zOptFmtLine, zFmtFmt, flen ); + + /* + * When we exit with EXIT_SUCCESS and the first option is a doc + * option, we do *NOT* want to emit the column headers. + * Otherwise, we do. + */ + if ( (usage_exit_code != EXIT_SUCCESS) + || ((pOptions->pOptDesc->fOptState & OPTST_DOCUMENT) == 0) ) + + fputs( pOptTitle, option_usage_fp ); + } + + printOptionUsage( pOptions, usage_exit_code, pOptTitle ); + } + + /* + * Describe the mechanics of denoting the options + */ + switch (pOptions->fOptSet & OPTPROC_L_N_S) { + case OPTPROC_L_N_S: fputs( zFlagOkay, option_usage_fp ); break; + case OPTPROC_SHORTOPT: break; + case OPTPROC_LONGOPT: fputs( zNoFlags, option_usage_fp ); break; + case 0: fputs( zOptsOnly, option_usage_fp ); break; + } + + if ((pOptions->fOptSet & OPTPROC_NUM_OPT) != 0) { + fputs( zNumberOpt, option_usage_fp ); + } + + if ((pOptions->fOptSet & OPTPROC_REORDER) != 0) { + fputs( zReorder, option_usage_fp ); + } + + if (pOptions->pzExplain != NULL) + fputs( pOptions->pzExplain, option_usage_fp ); + + /* + * IF the user is asking for help (thus exiting with SUCCESS), + * THEN see what additional information we can provide. + */ + if (usage_exit_code == EXIT_SUCCESS) + printProgramDetails( pOptions ); + + if (pOptions->pzBugAddr != NULL) + fprintf( option_usage_fp, zPlsSendBugs, pOptions->pzBugAddr ); + fflush( option_usage_fp ); + + exit( actual_exit_code ); +} + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * PER OPTION TYPE USAGE INFORMATION + */ +static void +printExtendedUsage( + tOptions* pOptions, + tOptDesc* pOD, + arg_types_t* pAT ) +{ + /* + * IF there are option conflicts or dependencies, + * THEN print them here. + */ + if ( (pOD->pOptMust != NULL) + || (pOD->pOptCant != NULL) ) { + + fputs( zTabHyp, option_usage_fp ); + + /* + * DEPENDENCIES: + */ + if (pOD->pOptMust != NULL) { + const int* pOptNo = pOD->pOptMust; + + fputs( zReqThese, option_usage_fp ); + for (;;) { + fprintf( option_usage_fp, zTabout, pOptions->pOptDesc[ + *pOptNo ].pz_Name ); + if (*++pOptNo == NO_EQUIVALENT) + break; + } + + if (pOD->pOptCant != NULL) + fputs( zTabHypAnd, option_usage_fp ); + } + + /* + * CONFLICTS: + */ + if (pOD->pOptCant != NULL) { + const int* pOptNo = pOD->pOptCant; + + fputs( zProhib, option_usage_fp ); + for (;;) { + fprintf( option_usage_fp, zTabout, pOptions->pOptDesc[ + *pOptNo ].pz_Name ); + if (*++pOptNo == NO_EQUIVALENT) + break; + } + } + } + + /* + * IF there is a disablement string + * THEN print the disablement info + */ + if (pOD->pz_DisableName != NULL ) + fprintf( option_usage_fp, zDis, pOD->pz_DisableName ); + + /* + * Check for argument types that have callbacks with magical properties + */ + switch (OPTST_GET_ARGTYPE(pOD->fOptState)) { + case OPARG_TYPE_NUMERIC: + /* + * IF the numeric option has a special callback, + * THEN call it, requesting the range or other special info + */ + if ( (pOD->pOptProc != NULL) + && (pOD->pOptProc != optionNumericVal) ) { + (*(pOD->pOptProc))(OPTPROC_EMIT_USAGE, pOD); + } + break; + + case OPARG_TYPE_FILE: + (*(pOD->pOptProc))(OPTPROC_EMIT_USAGE, pOD); + break; + } + + /* + * IF the option defaults to being enabled, + * THEN print that out + */ + if (pOD->fOptState & OPTST_INITENABLED) + fputs( zEnab, option_usage_fp ); + + /* + * IF the option is in an equivalence class + * AND not the designated lead + * THEN print equivalence and leave it at that. + */ + if ( (pOD->optEquivIndex != NO_EQUIVALENT) + && (pOD->optEquivIndex != pOD->optActualIndex ) ) { + fprintf( option_usage_fp, zAlt, + pOptions->pOptDesc[ pOD->optEquivIndex ].pz_Name ); + return; + } + + /* + * IF this particular option can NOT be preset + * AND some form of presetting IS allowed, + * AND it is not an auto-managed option (e.g. --help, et al.) + * THEN advise that this option may not be preset. + */ + if ( ((pOD->fOptState & OPTST_NO_INIT) != 0) + && ( (pOptions->papzHomeList != NULL) + || (pOptions->pzPROGNAME != NULL) + ) + && (pOD->optIndex < pOptions->presetOptCt) + ) + + fputs( zNoPreset, option_usage_fp ); + + /* + * Print the appearance requirements. + */ + if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_MEMBERSHIP) + fputs( zMembers, option_usage_fp ); + + else switch (pOD->optMinCt) { + case 1: + case 0: + switch (pOD->optMaxCt) { + case 0: fputs( zPreset, option_usage_fp ); break; + case NOLIMIT: fputs( zNoLim, option_usage_fp ); break; + case 1: break; + /* + * IF the max is more than one but limited, print "UP TO" message + */ + default: fprintf( option_usage_fp, zUpTo, pOD->optMaxCt ); break; + } + break; + + default: + /* + * More than one is required. Print the range. + */ + fprintf( option_usage_fp, zMust, pOD->optMinCt, pOD->optMaxCt ); + } + + if ( NAMED_OPTS( pOptions ) + && (pOptions->specOptIdx.default_opt == pOD->optIndex)) + fputs( zDefaultOpt, option_usage_fp ); +} + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Figure out where all the initialization files might live. + * This requires translating some environment variables and + * testing to see if a name is a directory or a file. It's + * squishy, but important to tell users how to find these files. + */ +static void +printInitList( + tCC* const* papz, + ag_bool* pInitIntro, + tCC* pzRc, + tCC* pzPN ) +{ + char zPath[ AG_PATH_MAX+1 ]; + + if (papz == NULL) + return; + + fputs( zPresetIntro, option_usage_fp ); + *pInitIntro = AG_FALSE; + + for (;;) { + char const* pzPath = *(papz++); + + if (pzPath == NULL) + break; + + if (optionMakePath(zPath, (int)sizeof( zPath ), pzPath, pzPN)) + pzPath = zPath; + + /* + * Print the name of the "homerc" file. If the "rcfile" name is + * not empty, we may or may not print that, too... + */ + fprintf( option_usage_fp, zPathFmt, pzPath ); + if (*pzRc != NUL) { + struct stat sb; + + /* + * IF the "homerc" file is a directory, + * then append the "rcfile" name. + */ + if ( (stat( pzPath, &sb ) == 0) + && S_ISDIR( sb.st_mode ) ) { + fputc( DIRCH, option_usage_fp ); + fputs( pzRc, option_usage_fp ); + } + } + + fputc( '\n', option_usage_fp ); + } +} + + +/* + * Print the usage information for a single option. + */ +static void +printOneUsage( + tOptions* pOptions, + tOptDesc* pOD, + arg_types_t* pAT ) +{ + /* + * Flag prefix: IF no flags at all, then omit it. If not printable + * (not allowed for this option), then blank, else print it. + * Follow it with a comma if we are doing GNU usage and long + * opts are to be printed too. + */ +#ifdef TCPBURST + if(30 == pOD->optIndex) /* ׼tcpreplayָ */ + { + fprintf(option_usage_fp, "\n ========================== 2013-06-06 New Arguments For Tcpburst ===============\n"); + } +#endif + if ((pOptions->fOptSet & OPTPROC_SHORTOPT) == 0) + fputs( pAT->pzSpc, option_usage_fp ); + else if (! IS_GRAPHIC_CHAR(pOD->optValue)) { + if ( (pOptions->fOptSet & (OPTPROC_GNUUSAGE|OPTPROC_LONGOPT)) + == (OPTPROC_GNUUSAGE|OPTPROC_LONGOPT)) + fputc( ' ', option_usage_fp ); + fputs( pAT->pzNoF, option_usage_fp ); + } else { + fprintf( option_usage_fp, " -%c", pOD->optValue ); + if ( (pOptions->fOptSet & (OPTPROC_GNUUSAGE|OPTPROC_LONGOPT)) + == (OPTPROC_GNUUSAGE|OPTPROC_LONGOPT)) + fputs( ", ", option_usage_fp ); + } + + { + char z[ 80 ]; + tCC* pzArgType; + /* + * Determine the argument type string first on its usage, then, + * when the option argument is required, base the type string on the + * argument type. + */ + if (pOD->fOptState & OPTST_ARG_OPTIONAL) { + pzArgType = pAT->pzOpt; + + } else switch (OPTST_GET_ARGTYPE(pOD->fOptState)) { + case OPARG_TYPE_NONE: pzArgType = pAT->pzNo; break; + case OPARG_TYPE_ENUMERATION: pzArgType = pAT->pzKey; break; + case OPARG_TYPE_FILE : pzArgType = pAT->pzFile; break; + case OPARG_TYPE_MEMBERSHIP: pzArgType = pAT->pzKeyL; break; + case OPARG_TYPE_BOOLEAN: pzArgType = pAT->pzBool; break; + case OPARG_TYPE_NUMERIC: pzArgType = pAT->pzNum; break; + case OPARG_TYPE_HIERARCHY: pzArgType = pAT->pzNest; break; + case OPARG_TYPE_STRING: pzArgType = pAT->pzStr; break; + case OPARG_TYPE_TIME: pzArgType = pAT->pzTime; break; + default: goto bogus_desc; + } + + snprintf( z, sizeof(z), pAT->pzOptFmt, pzArgType, pOD->pz_Name, + (pOD->optMinCt != 0) ? pAT->pzReq : pAT->pzOpt ); + + fprintf( option_usage_fp, zOptFmtLine, z, pOD->pzText ); + + switch (OPTST_GET_ARGTYPE(pOD->fOptState)) { + case OPARG_TYPE_ENUMERATION: + case OPARG_TYPE_MEMBERSHIP: + displayEnum = (pOD->pOptProc != NULL) ? AG_TRUE : displayEnum; + } + } + return; + + bogus_desc: + fprintf( stderr, zInvalOptDesc, pOD->pz_Name ); + exit( EX_SOFTWARE ); +} + + +/* + * Print out the usage information for just the options. + */ +static void +printOptionUsage( + tOptions* pOpts, + int ex_code, + tCC* pOptTitle ) +{ + int ct = pOpts->optCt; + int optNo = 0; + tOptDesc* pOD = pOpts->pOptDesc; + int docCt = 0; + + do { + if ((pOD->fOptState & OPTST_NO_USAGE_MASK) != 0) + continue; + + if ((pOD->fOptState & OPTST_DOCUMENT) != 0) { + if (ex_code == EXIT_SUCCESS) { + fprintf(option_usage_fp, argTypes.pzBrk, pOD->pzText, + pOptTitle); + docCt++; + } + + continue; + } + + /* + * IF this is the first auto-opt maintained option + * *AND* we are doing a full help + * *AND* there are documentation options + * *AND* the last one was not a doc option, + * THEN document that the remaining options are not user opts + */ + if ( (pOpts->presetOptCt == optNo) + && (ex_code == EXIT_SUCCESS) + && (docCt > 0) + && ((pOD[-1].fOptState & OPTST_DOCUMENT) == 0) ) + fprintf( option_usage_fp, argTypes.pzBrk, zAuto, pOptTitle ); + + printOneUsage( pOpts, pOD, &argTypes ); + + /* + * IF we were invoked because of the --help option, + * THEN print all the extra info + */ + if (ex_code == EXIT_SUCCESS) + printExtendedUsage( pOpts, pOD, &argTypes ); + + } while (pOD++, optNo++, (--ct > 0)); + + fputc( '\n', option_usage_fp ); +} + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * PROGRAM DETAILS + */ +static void +printProgramDetails( tOptions* pOptions ) +{ + ag_bool initIntro = AG_TRUE; + + /* + * Display all the places we look for config files + */ + printInitList( pOptions->papzHomeList, &initIntro, + pOptions->pzRcName, pOptions->pzProgPath ); + + /* + * Let the user know about environment variable settings + */ + if ((pOptions->fOptSet & OPTPROC_ENVIRON) != 0) { + if (initIntro) + fputs( zPresetIntro, option_usage_fp ); + + fprintf( option_usage_fp, zExamineFmt, pOptions->pzPROGNAME ); + } + + /* + * IF we found an enumeration, + * THEN hunt for it again. Call the handler proc with a NULL + * option struct pointer. That tells it to display the keywords. + */ + if (displayEnum) { + int ct = pOptions->optCt; + int optNo = 0; + tOptDesc* pOD = pOptions->pOptDesc; + + fputc( '\n', option_usage_fp ); + fflush( option_usage_fp ); + do { + switch (OPTST_GET_ARGTYPE(pOD->fOptState)) { + case OPARG_TYPE_ENUMERATION: + case OPARG_TYPE_MEMBERSHIP: + (*(pOD->pOptProc))(OPTPROC_EMIT_USAGE, pOD); + } + } while (pOD++, optNo++, (--ct > 0)); + } + + /* + * If there is a detail string, now is the time for that. + */ + if (pOptions->pzDetail != NULL) + fputs( pOptions->pzDetail, option_usage_fp ); +} + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * OPTION LINE FORMATTING SETUP + * + * The "OptFmt" formats receive three arguments: + * 1. the type of the option's argument + * 2. the long name of the option + * 3. "YES" or "no ", depending on whether or not the option must appear + * on the command line. + * These formats are used immediately after the option flag (if used) has + * been printed. + * + * Set up the formatting for GNU-style output + */ +static int +setGnuOptFmts( tOptions* pOpts, tCC** ppT ) +{ + int flen = 22; + *ppT = zNoRq_ShrtTtl; + + argTypes.pzStr = zGnuStrArg; + argTypes.pzReq = zOneSpace; + argTypes.pzNum = zGnuNumArg; + argTypes.pzKey = zGnuKeyArg; + argTypes.pzKeyL = zGnuKeyLArg; + argTypes.pzTime = zGnuTimeArg; + argTypes.pzFile = zGnuFileArg; + argTypes.pzBool = zGnuBoolArg; + argTypes.pzNest = zGnuNestArg; + argTypes.pzOpt = zGnuOptArg; + argTypes.pzNo = zOneSpace; + argTypes.pzBrk = zGnuBreak; + argTypes.pzNoF = zSixSpaces; + argTypes.pzSpc = zThreeSpaces; + + switch (pOpts->fOptSet & OPTPROC_L_N_S) { + case OPTPROC_L_N_S: argTypes.pzOptFmt = zGnuOptFmt; break; + case OPTPROC_LONGOPT: argTypes.pzOptFmt = zGnuOptFmt; break; + case 0: argTypes.pzOptFmt = zGnuOptFmt + 2; break; + case OPTPROC_SHORTOPT: + argTypes.pzOptFmt = zShrtGnuOptFmt; + zGnuStrArg[0] = zGnuNumArg[0] = zGnuKeyArg[0] = zGnuBoolArg[0] = ' '; + argTypes.pzOpt = " [arg]"; + flen = 8; + break; + } + + return flen; +} + + +/* + * Standard (AutoOpts normal) option line formatting + */ +static int +setStdOptFmts( tOptions* pOpts, tCC** ppT ) +{ + int flen = 0; + + argTypes.pzStr = zStdStrArg; + argTypes.pzReq = zStdReqArg; + argTypes.pzNum = zStdNumArg; + argTypes.pzKey = zStdKeyArg; + argTypes.pzKeyL = zStdKeyLArg; + argTypes.pzTime = zStdTimeArg; + argTypes.pzFile = zStdFileArg; + argTypes.pzBool = zStdBoolArg; + argTypes.pzNest = zStdNestArg; + argTypes.pzOpt = zStdOptArg; + argTypes.pzNo = zStdNoArg; + argTypes.pzBrk = zStdBreak; + argTypes.pzNoF = zFiveSpaces; + argTypes.pzSpc = zTwoSpaces; + + switch (pOpts->fOptSet & (OPTPROC_NO_REQ_OPT | OPTPROC_SHORTOPT)) { + case (OPTPROC_NO_REQ_OPT | OPTPROC_SHORTOPT): + *ppT = zNoRq_ShrtTtl; + argTypes.pzOptFmt = zNrmOptFmt; + flen = 19; + break; + + case OPTPROC_NO_REQ_OPT: + *ppT = zNoRq_NoShrtTtl; + argTypes.pzOptFmt = zNrmOptFmt; + flen = 19; + break; + + case OPTPROC_SHORTOPT: + *ppT = zReq_ShrtTtl; + argTypes.pzOptFmt = zReqOptFmt; + flen = 24; + break; + + case 0: + *ppT = zReq_NoShrtTtl; + argTypes.pzOptFmt = zReqOptFmt; + flen = 24; + } + + return flen; +} + + +/*: + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of autoopts/usage.c */ diff --git a/libopts/value-type.c b/libopts/value-type.c new file mode 100644 index 0000000..27c010b --- /dev/null +++ b/libopts/value-type.c @@ -0,0 +1,120 @@ +/* ANSI-C code produced by gperf version 3.0.2 */ + + +#if 0 /* gperf build options: */ +// %struct-type +// %language=ANSI-C +// %includes +// %global-table +// %omit-struct-type +// %readonly-tables +// %compare-strncmp +// +// %define slot-name vtp_name +// %define hash-function-name value_type_hash +// %define lookup-function-name find_value_type_name +// %define word-array-name value_type_table +// %define initializer-suffix ,VTP_COUNT_KWD +#endif /* gperf build options: */ + +#include "value-type.h" + +typedef struct { + char const * vtp_name; + value_type_enum_t vtp_id; +} value_type_map_t; +#include + +/* maximum key range = 20, duplicates = 0 */ + +#ifdef __GNUC__ +#else +#ifdef __cplusplus +#endif +#endif +inline static unsigned int +value_type_hash (register const char *str, register unsigned int len) +{ + static const unsigned char asso_values[] = + { + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 10, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 5, 23, 23, 5, 0, 0, 23, 15, 23, + 23, 10, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23 + }; + return len + asso_values[(unsigned char)str[2]]; +} + +static const value_type_map_t value_type_table[] = + { + {"",VTP_COUNT_KWD}, {"",VTP_COUNT_KWD}, + {"",VTP_COUNT_KWD}, + {"set", VTP_KWD_SET}, + {"",VTP_COUNT_KWD}, {"",VTP_COUNT_KWD}, + {"nested", VTP_KWD_NESTED}, + {"integer", VTP_KWD_INTEGER}, + {"",VTP_COUNT_KWD}, + {"bool", VTP_KWD_BOOL}, + {"",VTP_COUNT_KWD}, + {"string", VTP_KWD_STRING}, + {"boolean", VTP_KWD_BOOLEAN}, + {"",VTP_COUNT_KWD}, + {"set-membership", VTP_KWD_SET_MEMBERSHIP}, + {"",VTP_COUNT_KWD}, {"",VTP_COUNT_KWD}, + {"keyword", VTP_KWD_KEYWORD}, + {"",VTP_COUNT_KWD}, + {"hierarchy", VTP_KWD_HIERARCHY}, + {"",VTP_COUNT_KWD}, {"",VTP_COUNT_KWD}, + {"invalid", VTP_KWD_INVALID} + }; + +#ifdef __GNUC__ +#endif +static inline const value_type_map_t * +find_value_type_name (register const char *str, register unsigned int len) +{ + if (len <= 14 && len >= 3) + { + register int key = value_type_hash (str, len); + + if (key <= 22 && key >= 0) + { + register const char *s = value_type_table[key].vtp_name; + + if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0') + return &value_type_table[key]; + } + } + return 0; +} + + +value_type_enum_t +find_value_type_id(char const * str, unsigned int len) +{ + const value_type_map_t * p = + find_value_type_name(str, len); + return (p == 0) ? VTP_KWD_INVALID : p->vtp_id; +} diff --git a/libopts/value-type.h b/libopts/value-type.h new file mode 100644 index 0000000..ad3f007 --- /dev/null +++ b/libopts/value-type.h @@ -0,0 +1,25 @@ +/* + * Generated header for gperf generated source Sat Aug 8 10:14:55 PDT 2009 + * This file enumerates the list of names and declares the + * procedure for mapping string names to the enum value. + */ +#ifndef AUTOOPTS_VALUE_TYPE_H_GUARD +#define AUTOOPTS_VALUE_TYPE_H_GUARD 1 + +typedef enum { + VTP_KWD_INVALID, + VTP_KWD_STRING, + VTP_KWD_INTEGER, + VTP_KWD_BOOLEAN, + VTP_KWD_BOOL, + VTP_KWD_KEYWORD, + VTP_KWD_SET, + VTP_KWD_SET_MEMBERSHIP, + VTP_KWD_NESTED, + VTP_KWD_HIERARCHY, + VTP_COUNT_KWD +} value_type_enum_t; + +extern value_type_enum_t +find_value_type_id(char const * str, unsigned int len); +#endif /* AUTOOPTS_VALUE_TYPE_H_GUARD */ diff --git a/libopts/version.c b/libopts/version.c new file mode 100644 index 0000000..e21e2bf --- /dev/null +++ b/libopts/version.c @@ -0,0 +1,157 @@ + +/* $Id: version.c,v 4.19 2009/08/01 17:43:06 bkorb Exp $ + * Time-stamp: "2008-07-27 10:11:30 bkorb" + * + * This module implements the default usage procedure for + * Automated Options. It may be overridden, of course. + */ + +/* + * This file is part of AutoOpts, a companion to AutoGen. + * AutoOpts is free software. + * AutoOpts is copyright (c) 1992-2009 by Bruce Korb - all rights reserved + * + * AutoOpts is available under any one of two licenses. The license + * in use must be one of these two and the choice is under the control + * of the user of the license. + * + * The GNU Lesser General Public License, version 3 or later + * See the files "COPYING.lgplv3" and "COPYING.gplv3" + * + * The Modified Berkeley Software Distribution License + * See the file "COPYING.mbsd" + * + * These files have the following md5sums: + * + * 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 + * 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 + * 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + */ + +/* = = = START-STATIC-FORWARD = = = */ +/* static forward declarations maintained by mk-fwd */ +static void +printVersion( tOptions* pOpts, tOptDesc* pOD, FILE* fp ); +/* = = = END-STATIC-FORWARD = = = */ + +/*=export_func optionVersion + * + * what: return the compiled AutoOpts version number + * ret_type: char const* + * ret_desc: the version string in constant memory + * doc: + * Returns the full version string compiled into the library. + * The returned string cannot be modified. +=*/ +char const* +optionVersion( void ) +{ + static char const zVersion[] = + STR( AO_CURRENT.AO_REVISION ); + + return zVersion; +} + + +static void +printVersion( tOptions* pOpts, tOptDesc* pOD, FILE* fp ) +{ + char swCh; + + /* + * IF the optional argument flag is off, or the argument is not provided, + * then just print the version. + */ + if ( ((pOD->fOptState & OPTST_ARG_OPTIONAL) == 0) + || (pOD->optArg.argString == NULL)) + swCh = 'v'; + else swCh = tolower(pOD->optArg.argString[0]); + + if (pOpts->pzFullVersion != NULL) { + fputs( pOpts->pzFullVersion, fp ); + fputc( '\n', fp ); + + } else { + char const *pz = pOpts->pzUsageTitle; + do { fputc(*pz, fp); } while (*(pz++) != '\n'); + } + + switch (swCh) { + case NUL: /* arg provided, but empty */ + case 'v': + break; + + case 'c': + if (pOpts->pzCopyright != NULL) { + fputs( pOpts->pzCopyright, fp ); + fputc( '\n', fp ); + } + fprintf( fp, zAO_Ver, optionVersion() ); + if (pOpts->pzBugAddr != NULL) + fprintf( fp, zPlsSendBugs, pOpts->pzBugAddr ); + break; + + case 'n': + if (pOpts->pzCopyright != NULL) { + fputs( pOpts->pzCopyright, fp ); + fputc( '\n', fp ); + fputc( '\n', fp ); + } + + if (pOpts->pzCopyNotice != NULL) { + fputs( pOpts->pzCopyNotice, fp ); + fputc( '\n', fp ); + } + + fprintf( fp, zAO_Ver, optionVersion() ); + if (pOpts->pzBugAddr != NULL) + fprintf( fp, zPlsSendBugs, pOpts->pzBugAddr ); + break; + + default: + fprintf( stderr, zBadVerArg, swCh ); + exit( EXIT_FAILURE ); + } + + exit( EXIT_SUCCESS ); +} + +/*=export_func optionPrintVersion + * private: + * + * what: Print the program version + * arg: + tOptions* + pOpts + program options descriptor + + * arg: + tOptDesc* + pOptDesc + the descriptor for this arg + + * + * doc: + * This routine will print the version to stdout. +=*/ +void +optionPrintVersion( tOptions* pOpts, tOptDesc* pOD ) +{ + printVersion( pOpts, pOD, stdout ); +} + +/*=export_func optionVersionStderr + * private: + * + * what: Print the program version to stderr + * arg: + tOptions* + pOpts + program options descriptor + + * arg: + tOptDesc* + pOptDesc + the descriptor for this arg + + * + * doc: + * This routine will print the version to stderr. +=*/ +void +optionVersionStderr( tOptions* pOpts, tOptDesc* pOD ) +{ + printVersion( pOpts, pOD, stderr ); +} + +/* + * Local Variables: + * mode: C + * c-file-style: "stroustrup" + * indent-tabs-mode: nil + * End: + * end of autoopts/version.c */ diff --git a/libopts/xat-attribute.c b/libopts/xat-attribute.c new file mode 100644 index 0000000..85b735f --- /dev/null +++ b/libopts/xat-attribute.c @@ -0,0 +1,111 @@ +/* ANSI-C code produced by gperf version 3.0.2 */ + + +#if 0 /* gperf build options: */ +// %struct-type +// %language=ANSI-C +// %includes +// %global-table +// %omit-struct-type +// %readonly-tables +// %compare-strncmp +// +// %define slot-name xat_name +// %define hash-function-name xat_attribute_hash +// %define lookup-function-name find_xat_attribute_name +// %define word-array-name xat_attribute_table +// %define initializer-suffix ,XAT_COUNT_KWD +#endif /* gperf build options: */ + +#include "xat-attribute.h" + +typedef struct { + char const * xat_name; + xat_attribute_enum_t xat_id; +} xat_attribute_map_t; +#include + +/* maximum key range = 9, duplicates = 0 */ + +#ifdef __GNUC__ +#else +#ifdef __cplusplus +#endif +#endif +inline static unsigned int +xat_attribute_hash (register const char *str, register unsigned int len) +{ + static const unsigned char asso_values[] = + { + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 0, + 13, 13, 13, 13, 13, 5, 13, 5, 13, 0, + 13, 13, 13, 13, 13, 13, 0, 0, 13, 0, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13 + }; + return len + asso_values[(unsigned char)str[0]]; +} + +static const xat_attribute_map_t xat_attribute_table[] = + { + {"",XAT_COUNT_KWD}, {"",XAT_COUNT_KWD}, + {"",XAT_COUNT_KWD}, {"",XAT_COUNT_KWD}, + {"type", XAT_KWD_TYPE}, + {"words", XAT_KWD_WORDS}, + {"cooked", XAT_KWD_COOKED}, + {"members", XAT_KWD_MEMBERS}, + {"uncooked", XAT_KWD_UNCOOKED}, + {"keep", XAT_KWD_KEEP}, + {"",XAT_COUNT_KWD}, {"",XAT_COUNT_KWD}, + {"invalid", XAT_KWD_INVALID} + }; + +#ifdef __GNUC__ +#endif +static inline const xat_attribute_map_t * +find_xat_attribute_name (register const char *str, register unsigned int len) +{ + if (len <= 8 && len >= 4) + { + register int key = xat_attribute_hash (str, len); + + if (key <= 12 && key >= 0) + { + register const char *s = xat_attribute_table[key].xat_name; + + if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0') + return &xat_attribute_table[key]; + } + } + return 0; +} + + +xat_attribute_enum_t +find_xat_attribute_id(char const * str, unsigned int len) +{ + const xat_attribute_map_t * p = + find_xat_attribute_name(str, len); + return (p == 0) ? XAT_KWD_INVALID : p->xat_id; +} diff --git a/libopts/xat-attribute.h b/libopts/xat-attribute.h new file mode 100644 index 0000000..fca1b86 --- /dev/null +++ b/libopts/xat-attribute.h @@ -0,0 +1,22 @@ +/* + * Generated header for gperf generated source Sat Aug 8 10:14:55 PDT 2009 + * This file enumerates the list of names and declares the + * procedure for mapping string names to the enum value. + */ +#ifndef AUTOOPTS_XAT_ATTRIBUTE_H_GUARD +#define AUTOOPTS_XAT_ATTRIBUTE_H_GUARD 1 + +typedef enum { + XAT_KWD_INVALID, + XAT_KWD_TYPE, + XAT_KWD_WORDS, + XAT_KWD_MEMBERS, + XAT_KWD_COOKED, + XAT_KWD_UNCOOKED, + XAT_KWD_KEEP, + XAT_COUNT_KWD +} xat_attribute_enum_t; + +extern xat_attribute_enum_t +find_xat_attribute_id(char const * str, unsigned int len); +#endif /* AUTOOPTS_XAT_ATTRIBUTE_H_GUARD */ diff --git a/m4/libtool.m4 b/m4/libtool.m4 new file mode 100644 index 0000000..39ba996 --- /dev/null +++ b/m4/libtool.m4 @@ -0,0 +1,7357 @@ +# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, +# 2006, 2007, 2008 Free Software Foundation, Inc. +# Written by Gordon Matzigkeit, 1996 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +m4_define([_LT_COPYING], [dnl +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, +# 2006, 2007, 2008 Free Software Foundation, Inc. +# Written by Gordon Matzigkeit, 1996 +# +# This file is part of GNU Libtool. +# +# GNU Libtool is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# As a special exception to the GNU General Public License, +# if you distribute this file as part of a program or library that +# is built using GNU Libtool, you may include this file under the +# same distribution terms that you use for the rest of that program. +# +# GNU Libtool is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Libtool; see the file COPYING. If not, a copy +# can be downloaded from http://www.gnu.org/licenses/gpl.html, or +# obtained by writing to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +]) + +# serial 56 LT_INIT + + +# LT_PREREQ(VERSION) +# ------------------ +# Complain and exit if this libtool version is less that VERSION. +m4_defun([LT_PREREQ], +[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, + [m4_default([$3], + [m4_fatal([Libtool version $1 or higher is required], + 63)])], + [$2])]) + + +# _LT_CHECK_BUILDDIR +# ------------------ +# Complain if the absolute build directory name contains unusual characters +m4_defun([_LT_CHECK_BUILDDIR], +[case `pwd` in + *\ * | *\ *) + AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; +esac +]) + + +# LT_INIT([OPTIONS]) +# ------------------ +AC_DEFUN([LT_INIT], +[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT +AC_BEFORE([$0], [LT_LANG])dnl +AC_BEFORE([$0], [LT_OUTPUT])dnl +AC_BEFORE([$0], [LTDL_INIT])dnl +m4_require([_LT_CHECK_BUILDDIR])dnl + +dnl Autoconf doesn't catch unexpanded LT_ macros by default: +m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl +m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl +dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 +dnl unless we require an AC_DEFUNed macro: +AC_REQUIRE([LTOPTIONS_VERSION])dnl +AC_REQUIRE([LTSUGAR_VERSION])dnl +AC_REQUIRE([LTVERSION_VERSION])dnl +AC_REQUIRE([LTOBSOLETE_VERSION])dnl +m4_require([_LT_PROG_LTMAIN])dnl + +dnl Parse OPTIONS +_LT_SET_OPTIONS([$0], [$1]) + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ltmain" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +_LT_SETUP + +# Only expand once: +m4_define([LT_INIT]) +])# LT_INIT + +# Old names: +AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) +AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_PROG_LIBTOOL], []) +dnl AC_DEFUN([AM_PROG_LIBTOOL], []) + + +# _LT_CC_BASENAME(CC) +# ------------------- +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +m4_defun([_LT_CC_BASENAME], +[for cc_temp in $1""; do + case $cc_temp in + compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; + distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` +]) + + +# _LT_FILEUTILS_DEFAULTS +# ---------------------- +# It is okay to use these file commands and assume they have been set +# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. +m4_defun([_LT_FILEUTILS_DEFAULTS], +[: ${CP="cp -f"} +: ${MV="mv -f"} +: ${RM="rm -f"} +])# _LT_FILEUTILS_DEFAULTS + + +# _LT_SETUP +# --------- +m4_defun([_LT_SETUP], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +_LT_DECL([], [host_alias], [0], [The host system])dnl +_LT_DECL([], [host], [0])dnl +_LT_DECL([], [host_os], [0])dnl +dnl +_LT_DECL([], [build_alias], [0], [The build system])dnl +_LT_DECL([], [build], [0])dnl +_LT_DECL([], [build_os], [0])dnl +dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([LT_PATH_LD])dnl +AC_REQUIRE([LT_PATH_NM])dnl +dnl +AC_REQUIRE([AC_PROG_LN_S])dnl +test -z "$LN_S" && LN_S="ln -s" +_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl +dnl +AC_REQUIRE([LT_CMD_MAX_LEN])dnl +_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl +_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl +dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_CHECK_SHELL_FEATURES])dnl +m4_require([_LT_CMD_RELOAD])dnl +m4_require([_LT_CHECK_MAGIC_METHOD])dnl +m4_require([_LT_CMD_OLD_ARCHIVE])dnl +m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl + +_LT_CONFIG_LIBTOOL_INIT([ +# See if we are running on zsh, and set the options which allow our +# commands through without removal of \ escapes INIT. +if test -n "\${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST +fi +]) +if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST +fi + +_LT_CHECK_OBJDIR + +m4_require([_LT_TAG_COMPILER])dnl +_LT_PROG_ECHO_BACKSLASH + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\([["`\\]]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to delay expansion of an escaped single quote. +delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' + +# Global variables: +ofile=libtool +can_build_shared=yes + +# All known linkers require a `.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a + +with_gnu_ld="$lt_cv_prog_gnu_ld" + +old_CC="$CC" +old_CFLAGS="$CFLAGS" + +# Set sane defaults for various variables +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS +test -z "$LD" && LD=ld +test -z "$ac_objext" && ac_objext=o + +_LT_CC_BASENAME([$compiler]) + +# Only perform the check for file, if the check method requires it +test -z "$MAGIC_CMD" && MAGIC_CMD=file +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + _LT_PATH_MAGIC + fi + ;; +esac + +# Use C for the default configuration in the libtool script +LT_SUPPORTED_TAG([CC]) +_LT_LANG_C_CONFIG +_LT_LANG_DEFAULT_CONFIG +_LT_CONFIG_COMMANDS +])# _LT_SETUP + + +# _LT_PROG_LTMAIN +# --------------- +# Note that this code is called both from `configure', and `config.status' +# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, +# `config.status' has no value for ac_aux_dir unless we are using Automake, +# so we pass a copy along to make sure it has a sensible value anyway. +m4_defun([_LT_PROG_LTMAIN], +[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl +_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) +ltmain="$ac_aux_dir/ltmain.sh" +])# _LT_PROG_LTMAIN + + +## ------------------------------------- ## +## Accumulate code for creating libtool. ## +## ------------------------------------- ## + +# So that we can recreate a full libtool script including additional +# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS +# in macros and then make a single call at the end using the `libtool' +# label. + + +# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) +# ---------------------------------------- +# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. +m4_define([_LT_CONFIG_LIBTOOL_INIT], +[m4_ifval([$1], + [m4_append([_LT_OUTPUT_LIBTOOL_INIT], + [$1 +])])]) + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_INIT]) + + +# _LT_CONFIG_LIBTOOL([COMMANDS]) +# ------------------------------ +# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. +m4_define([_LT_CONFIG_LIBTOOL], +[m4_ifval([$1], + [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], + [$1 +])])]) + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) + + +# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) +# ----------------------------------------------------- +m4_defun([_LT_CONFIG_SAVE_COMMANDS], +[_LT_CONFIG_LIBTOOL([$1]) +_LT_CONFIG_LIBTOOL_INIT([$2]) +]) + + +# _LT_FORMAT_COMMENT([COMMENT]) +# ----------------------------- +# Add leading comment marks to the start of each line, and a trailing +# full-stop to the whole comment if one is not present already. +m4_define([_LT_FORMAT_COMMENT], +[m4_ifval([$1], [ +m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], + [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) +)]) + + + +## ------------------------ ## +## FIXME: Eliminate VARNAME ## +## ------------------------ ## + + +# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) +# ------------------------------------------------------------------- +# CONFIGNAME is the name given to the value in the libtool script. +# VARNAME is the (base) name used in the configure script. +# VALUE may be 0, 1 or 2 for a computed quote escaped value based on +# VARNAME. Any other value will be used directly. +m4_define([_LT_DECL], +[lt_if_append_uniq([lt_decl_varnames], [$2], [, ], + [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], + [m4_ifval([$1], [$1], [$2])]) + lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) + m4_ifval([$4], + [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) + lt_dict_add_subkey([lt_decl_dict], [$2], + [tagged?], [m4_ifval([$5], [yes], [no])])]) +]) + + +# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) +# -------------------------------------------------------- +m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) + + +# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) +# ------------------------------------------------ +m4_define([lt_decl_tag_varnames], +[_lt_decl_filter([tagged?], [yes], $@)]) + + +# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) +# --------------------------------------------------------- +m4_define([_lt_decl_filter], +[m4_case([$#], + [0], [m4_fatal([$0: too few arguments: $#])], + [1], [m4_fatal([$0: too few arguments: $#: $1])], + [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], + [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], + [lt_dict_filter([lt_decl_dict], $@)])[]dnl +]) + + +# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) +# -------------------------------------------------- +m4_define([lt_decl_quote_varnames], +[_lt_decl_filter([value], [1], $@)]) + + +# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) +# --------------------------------------------------- +m4_define([lt_decl_dquote_varnames], +[_lt_decl_filter([value], [2], $@)]) + + +# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) +# --------------------------------------------------- +m4_define([lt_decl_varnames_tagged], +[m4_assert([$# <= 2])dnl +_$0(m4_quote(m4_default([$1], [[, ]])), + m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), + m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) +m4_define([_lt_decl_varnames_tagged], +[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) + + +# lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) +# ------------------------------------------------ +m4_define([lt_decl_all_varnames], +[_$0(m4_quote(m4_default([$1], [[, ]])), + m4_if([$2], [], + m4_quote(lt_decl_varnames), + m4_quote(m4_shift($@))))[]dnl +]) +m4_define([_lt_decl_all_varnames], +[lt_join($@, lt_decl_varnames_tagged([$1], + lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl +]) + + +# _LT_CONFIG_STATUS_DECLARE([VARNAME]) +# ------------------------------------ +# Quote a variable value, and forward it to `config.status' so that its +# declaration there will have the same value as in `configure'. VARNAME +# must have a single quote delimited value for this to work. +m4_define([_LT_CONFIG_STATUS_DECLARE], +[$1='`$ECHO "X$][$1" | $Xsed -e "$delay_single_quote_subst"`']) + + +# _LT_CONFIG_STATUS_DECLARATIONS +# ------------------------------ +# We delimit libtool config variables with single quotes, so when +# we write them to config.status, we have to be sure to quote all +# embedded single quotes properly. In configure, this macro expands +# each variable declared with _LT_DECL (and _LT_TAGDECL) into: +# +# ='`$ECHO "X$" | $Xsed -e "$delay_single_quote_subst"`' +m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], +[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), + [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) + + +# _LT_LIBTOOL_TAGS +# ---------------- +# Output comment and list of tags supported by the script +m4_defun([_LT_LIBTOOL_TAGS], +[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl +available_tags="_LT_TAGS"dnl +]) + + +# _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) +# ----------------------------------- +# Extract the dictionary values for VARNAME (optionally with TAG) and +# expand to a commented shell variable setting: +# +# # Some comment about what VAR is for. +# visible_name=$lt_internal_name +m4_define([_LT_LIBTOOL_DECLARE], +[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], + [description])))[]dnl +m4_pushdef([_libtool_name], + m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl +m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), + [0], [_libtool_name=[$]$1], + [1], [_libtool_name=$lt_[]$1], + [2], [_libtool_name=$lt_[]$1], + [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl +m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl +]) + + +# _LT_LIBTOOL_CONFIG_VARS +# ----------------------- +# Produce commented declarations of non-tagged libtool config variables +# suitable for insertion in the LIBTOOL CONFIG section of the `libtool' +# script. Tagged libtool config variables (even for the LIBTOOL CONFIG +# section) are produced by _LT_LIBTOOL_TAG_VARS. +m4_defun([_LT_LIBTOOL_CONFIG_VARS], +[m4_foreach([_lt_var], + m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), + [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) + + +# _LT_LIBTOOL_TAG_VARS(TAG) +# ------------------------- +m4_define([_LT_LIBTOOL_TAG_VARS], +[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), + [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) + + +# _LT_TAGVAR(VARNAME, [TAGNAME]) +# ------------------------------ +m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) + + +# _LT_CONFIG_COMMANDS +# ------------------- +# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of +# variables for single and double quote escaping we saved from calls +# to _LT_DECL, we can put quote escaped variables declarations +# into `config.status', and then the shell code to quote escape them in +# for loops in `config.status'. Finally, any additional code accumulated +# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. +m4_defun([_LT_CONFIG_COMMANDS], +[AC_PROVIDE_IFELSE([LT_OUTPUT], + dnl If the libtool generation code has been placed in $CONFIG_LT, + dnl instead of duplicating it all over again into config.status, + dnl then we will have config.status run $CONFIG_LT later, so it + dnl needs to know what name is stored there: + [AC_CONFIG_COMMANDS([libtool], + [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], + dnl If the libtool generation code is destined for config.status, + dnl expand the accumulated commands and init code now: + [AC_CONFIG_COMMANDS([libtool], + [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) +])#_LT_CONFIG_COMMANDS + + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], +[ + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +sed_quote_subst='$sed_quote_subst' +double_quote_subst='$double_quote_subst' +delay_variable_subst='$delay_variable_subst' +_LT_CONFIG_STATUS_DECLARATIONS +LTCC='$LTCC' +LTCFLAGS='$LTCFLAGS' +compiler='$compiler_DEFAULT' + +# Quote evaled strings. +for var in lt_decl_all_varnames([[ \ +]], lt_decl_quote_varnames); do + case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in + *[[\\\\\\\`\\"\\\$]]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +# Double-quote double-evaled strings. +for var in lt_decl_all_varnames([[ \ +]], lt_decl_dquote_varnames); do + case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in + *[[\\\\\\\`\\"\\\$]]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +# Fix-up fallback echo if it was mangled by the above quoting rules. +case \$lt_ECHO in +*'\\\[$]0 --fallback-echo"')dnl " + lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\[$]0 --fallback-echo"\[$]/\[$]0 --fallback-echo"/'\` + ;; +esac + +_LT_OUTPUT_LIBTOOL_INIT +]) + + +# LT_OUTPUT +# --------- +# This macro allows early generation of the libtool script (before +# AC_OUTPUT is called), incase it is used in configure for compilation +# tests. +AC_DEFUN([LT_OUTPUT], +[: ${CONFIG_LT=./config.lt} +AC_MSG_NOTICE([creating $CONFIG_LT]) +cat >"$CONFIG_LT" <<_LTEOF +#! $SHELL +# Generated by $as_me. +# Run this file to recreate a libtool stub with the current configuration. + +lt_cl_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_LTEOF + +cat >>"$CONFIG_LT" <<\_LTEOF +AS_SHELL_SANITIZE +_AS_PREPARE + +exec AS_MESSAGE_FD>&1 +exec AS_MESSAGE_LOG_FD>>config.log +{ + echo + AS_BOX([Running $as_me.]) +} >&AS_MESSAGE_LOG_FD + +lt_cl_help="\ +\`$as_me' creates a local libtool stub from the current configuration, +for use in further configure time tests before the real libtool is +generated. + +Usage: $[0] [[OPTIONS]] + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + +Report bugs to ." + +lt_cl_version="\ +m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl +m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) +configured by $[0], generated by m4_PACKAGE_STRING. + +Copyright (C) 2008 Free Software Foundation, Inc. +This config.lt script is free software; the Free Software Foundation +gives unlimited permision to copy, distribute and modify it." + +while test $[#] != 0 +do + case $[1] in + --version | --v* | -V ) + echo "$lt_cl_version"; exit 0 ;; + --help | --h* | -h ) + echo "$lt_cl_help"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --quiet | --q* | --silent | --s* | -q ) + lt_cl_silent=: ;; + + -*) AC_MSG_ERROR([unrecognized option: $[1] +Try \`$[0] --help' for more information.]) ;; + + *) AC_MSG_ERROR([unrecognized argument: $[1] +Try \`$[0] --help' for more information.]) ;; + esac + shift +done + +if $lt_cl_silent; then + exec AS_MESSAGE_FD>/dev/null +fi +_LTEOF + +cat >>"$CONFIG_LT" <<_LTEOF +_LT_OUTPUT_LIBTOOL_COMMANDS_INIT +_LTEOF + +cat >>"$CONFIG_LT" <<\_LTEOF +AC_MSG_NOTICE([creating $ofile]) +_LT_OUTPUT_LIBTOOL_COMMANDS +AS_EXIT(0) +_LTEOF +chmod +x "$CONFIG_LT" + +# configure is writing to config.log, but config.lt does its own redirection, +# appending to config.log, which fails on DOS, as config.log is still kept +# open by configure. Here we exec the FD to /dev/null, effectively closing +# config.log, so it can be properly (re)opened and appended to by config.lt. +if test "$no_create" != yes; then + lt_cl_success=: + test "$silent" = yes && + lt_config_lt_args="$lt_config_lt_args --quiet" + exec AS_MESSAGE_LOG_FD>/dev/null + $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false + exec AS_MESSAGE_LOG_FD>>config.log + $lt_cl_success || AS_EXIT(1) +fi +])# LT_OUTPUT + + +# _LT_CONFIG(TAG) +# --------------- +# If TAG is the built-in tag, create an initial libtool script with a +# default configuration from the untagged config vars. Otherwise add code +# to config.status for appending the configuration named by TAG from the +# matching tagged config vars. +m4_defun([_LT_CONFIG], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +_LT_CONFIG_SAVE_COMMANDS([ + m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl + m4_if(_LT_TAG, [C], [ + # See if we are running on zsh, and set the options which allow our + # commands through without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + + cfgfile="${ofile}T" + trap "$RM \"$cfgfile\"; exit 1" 1 2 15 + $RM "$cfgfile" + + cat <<_LT_EOF >> "$cfgfile" +#! $SHELL + +# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# NOTE: Changes made to this file will be lost: look at ltmain.sh. +# +_LT_COPYING +_LT_LIBTOOL_TAGS + +# ### BEGIN LIBTOOL CONFIG +_LT_LIBTOOL_CONFIG_VARS +_LT_LIBTOOL_TAG_VARS +# ### END LIBTOOL CONFIG + +_LT_EOF + + case $host_os in + aix3*) + cat <<\_LT_EOF >> "$cfgfile" +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +_LT_EOF + ;; + esac + + _LT_PROG_LTMAIN + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + _LT_PROG_XSI_SHELLFNS + + sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" +], +[cat <<_LT_EOF >> "$ofile" + +dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded +dnl in a comment (ie after a #). +# ### BEGIN LIBTOOL TAG CONFIG: $1 +_LT_LIBTOOL_TAG_VARS(_LT_TAG) +# ### END LIBTOOL TAG CONFIG: $1 +_LT_EOF +])dnl /m4_if +], +[m4_if([$1], [], [ + PACKAGE='$PACKAGE' + VERSION='$VERSION' + TIMESTAMP='$TIMESTAMP' + RM='$RM' + ofile='$ofile'], []) +])dnl /_LT_CONFIG_SAVE_COMMANDS +])# _LT_CONFIG + + +# LT_SUPPORTED_TAG(TAG) +# --------------------- +# Trace this macro to discover what tags are supported by the libtool +# --tag option, using: +# autoconf --trace 'LT_SUPPORTED_TAG:$1' +AC_DEFUN([LT_SUPPORTED_TAG], []) + + +# C support is built-in for now +m4_define([_LT_LANG_C_enabled], []) +m4_define([_LT_TAGS], []) + + +# LT_LANG(LANG) +# ------------- +# Enable libtool support for the given language if not already enabled. +AC_DEFUN([LT_LANG], +[AC_BEFORE([$0], [LT_OUTPUT])dnl +m4_case([$1], + [C], [_LT_LANG(C)], + [C++], [_LT_LANG(CXX)], + [Java], [_LT_LANG(GCJ)], + [Fortran 77], [_LT_LANG(F77)], + [Fortran], [_LT_LANG(FC)], + [Windows Resource], [_LT_LANG(RC)], + [m4_ifdef([_LT_LANG_]$1[_CONFIG], + [_LT_LANG($1)], + [m4_fatal([$0: unsupported language: "$1"])])])dnl +])# LT_LANG + + +# _LT_LANG(LANGNAME) +# ------------------ +m4_defun([_LT_LANG], +[m4_ifdef([_LT_LANG_]$1[_enabled], [], + [LT_SUPPORTED_TAG([$1])dnl + m4_append([_LT_TAGS], [$1 ])dnl + m4_define([_LT_LANG_]$1[_enabled], [])dnl + _LT_LANG_$1_CONFIG($1)])dnl +])# _LT_LANG + + +# _LT_LANG_DEFAULT_CONFIG +# ----------------------- +m4_defun([_LT_LANG_DEFAULT_CONFIG], +[AC_PROVIDE_IFELSE([AC_PROG_CXX], + [LT_LANG(CXX)], + [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) + +AC_PROVIDE_IFELSE([AC_PROG_F77], + [LT_LANG(F77)], + [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) + +AC_PROVIDE_IFELSE([AC_PROG_FC], + [LT_LANG(FC)], + [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) + +dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal +dnl pulling things in needlessly. +AC_PROVIDE_IFELSE([AC_PROG_GCJ], + [LT_LANG(GCJ)], + [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], + [LT_LANG(GCJ)], + [AC_PROVIDE_IFELSE([LT_PROG_GCJ], + [LT_LANG(GCJ)], + [m4_ifdef([AC_PROG_GCJ], + [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) + m4_ifdef([A][M_PROG_GCJ], + [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) + m4_ifdef([LT_PROG_GCJ], + [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) + +AC_PROVIDE_IFELSE([LT_PROG_RC], + [LT_LANG(RC)], + [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) +])# _LT_LANG_DEFAULT_CONFIG + +# Obsolete macros: +AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) +AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) +AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) +AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_CXX], []) +dnl AC_DEFUN([AC_LIBTOOL_F77], []) +dnl AC_DEFUN([AC_LIBTOOL_FC], []) +dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) + + +# _LT_TAG_COMPILER +# ---------------- +m4_defun([_LT_TAG_COMPILER], +[AC_REQUIRE([AC_PROG_CC])dnl + +_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl +_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl +_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl +_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC +])# _LT_TAG_COMPILER + + +# _LT_COMPILER_BOILERPLATE +# ------------------------ +# Check for compiler boilerplate output or warnings with +# the simple compiler test code. +m4_defun([_LT_COMPILER_BOILERPLATE], +[m4_require([_LT_DECL_SED])dnl +ac_outfile=conftest.$ac_objext +echo "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$RM conftest* +])# _LT_COMPILER_BOILERPLATE + + +# _LT_LINKER_BOILERPLATE +# ---------------------- +# Check for linker boilerplate output or warnings with +# the simple link test code. +m4_defun([_LT_LINKER_BOILERPLATE], +[m4_require([_LT_DECL_SED])dnl +ac_outfile=conftest.$ac_objext +echo "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$RM -r conftest* +])# _LT_LINKER_BOILERPLATE + +# _LT_REQUIRED_DARWIN_CHECKS +# ------------------------- +m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ + case $host_os in + rhapsody* | darwin*) + AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) + AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) + AC_CHECK_TOOL([LIPO], [lipo], [:]) + AC_CHECK_TOOL([OTOOL], [otool], [:]) + AC_CHECK_TOOL([OTOOL64], [otool64], [:]) + _LT_DECL([], [DSYMUTIL], [1], + [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) + _LT_DECL([], [NMEDIT], [1], + [Tool to change global to local symbols on Mac OS X]) + _LT_DECL([], [LIPO], [1], + [Tool to manipulate fat objects and archives on Mac OS X]) + _LT_DECL([], [OTOOL], [1], + [ldd/readelf like tool for Mach-O binaries on Mac OS X]) + _LT_DECL([], [OTOOL64], [1], + [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) + + AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], + [lt_cv_apple_cc_single_mod=no + if test -z "${LT_MULTI_MODULE}"; then + # By default we will add the -single_module flag. You can override + # by either setting the environment variable LT_MULTI_MODULE + # non-empty at configure time, or by adding -multi_module to the + # link flags. + rm -rf libconftest.dylib* + echo "int foo(void){return 1;}" > conftest.c + echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ +-dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD + $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ + -dynamiclib -Wl,-single_module conftest.c 2>conftest.err + _lt_result=$? + if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then + lt_cv_apple_cc_single_mod=yes + else + cat conftest.err >&AS_MESSAGE_LOG_FD + fi + rm -rf libconftest.dylib* + rm -f conftest.* + fi]) + AC_CACHE_CHECK([for -exported_symbols_list linker flag], + [lt_cv_ld_exported_symbols_list], + [lt_cv_ld_exported_symbols_list=no + save_LDFLAGS=$LDFLAGS + echo "_main" > conftest.sym + LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [lt_cv_ld_exported_symbols_list=yes], + [lt_cv_ld_exported_symbols_list=no]) + LDFLAGS="$save_LDFLAGS" + ]) + case $host_os in + rhapsody* | darwin1.[[012]]) + _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; + darwin1.*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + darwin*) # darwin 5.x on + # if running on 10.5 or later, the deployment target defaults + # to the OS version, if on x86, and 10.4, the deployment + # target defaults to 10.4. Don't you love it? + case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in + 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + 10.[[012]]*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + 10.*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + esac + ;; + esac + if test "$lt_cv_apple_cc_single_mod" = "yes"; then + _lt_dar_single_mod='$single_module' + fi + if test "$lt_cv_ld_exported_symbols_list" = "yes"; then + _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' + else + _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' + fi + if test "$DSYMUTIL" != ":"; then + _lt_dsymutil='~$DSYMUTIL $lib || :' + else + _lt_dsymutil= + fi + ;; + esac +]) + + +# _LT_DARWIN_LINKER_FEATURES +# -------------------------- +# Checks for linker and compiler features on darwin +m4_defun([_LT_DARWIN_LINKER_FEATURES], +[ + m4_require([_LT_REQUIRED_DARWIN_CHECKS]) + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_automatic, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_TAGVAR(whole_archive_flag_spec, $1)='' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" + case $cc_basename in + ifort*) _lt_dar_can_shared=yes ;; + *) _lt_dar_can_shared=$GCC ;; + esac + if test "$_lt_dar_can_shared" = "yes"; then + output_verbose_link_cmd=echo + _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" + _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" + _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" + _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" + m4_if([$1], [CXX], +[ if test "$lt_cv_apple_cc_single_mod" != "yes"; then + _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" + _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" + fi +],[]) + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi +]) + +# _LT_SYS_MODULE_PATH_AIX +# ----------------------- +# Links a minimal program and checks the executable +# for the system default hardcoded library path. In most cases, +# this is /usr/lib:/lib, but when the MPI compilers are used +# the location of the communication and MPI libs are included too. +# If we don't find anything, use the default library path according +# to the aix ld manual. +m4_defun([_LT_SYS_MODULE_PATH_AIX], +[m4_require([_LT_DECL_SED])dnl +AC_LINK_IFELSE(AC_LANG_PROGRAM,[ +lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\(.*\)$/\1/ + p + } + }' +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +fi],[]) +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +])# _LT_SYS_MODULE_PATH_AIX + + +# _LT_SHELL_INIT(ARG) +# ------------------- +m4_define([_LT_SHELL_INIT], +[ifdef([AC_DIVERSION_NOTICE], + [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], + [AC_DIVERT_PUSH(NOTICE)]) +$1 +AC_DIVERT_POP +])# _LT_SHELL_INIT + + +# _LT_PROG_ECHO_BACKSLASH +# ----------------------- +# Add some code to the start of the generated configure script which +# will find an echo command which doesn't interpret backslashes. +m4_defun([_LT_PROG_ECHO_BACKSLASH], +[_LT_SHELL_INIT([ +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} + +case X$lt_ECHO in +X*--fallback-echo) + # Remove one level of quotation (which was required for Make). + ECHO=`echo "$lt_ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` + ;; +esac + +ECHO=${lt_ECHO-echo} +if test "X[$]1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X[$]1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then + # Yippee, $ECHO works! + : +else + # Restart under the correct shell. + exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} +fi + +if test "X[$]1" = X--fallback-echo; then + # used as fallback echo + shift + cat <<_LT_EOF +[$]* +_LT_EOF + exit 0 +fi + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +if test -z "$lt_ECHO"; then + if test "X${echo_test_string+set}" != Xset; then + # find a string as large as possible, as long as the shell can cope with it + for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do + # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... + if { echo_test_string=`eval $cmd`; } 2>/dev/null && + { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null + then + break + fi + done + fi + + if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + : + else + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for dir in $PATH /usr/ucb; do + IFS="$lt_save_ifs" + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + ECHO="$dir/echo" + break + fi + done + IFS="$lt_save_ifs" + + if test "X$ECHO" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # This shell has a builtin print -r that does the trick. + ECHO='print -r' + elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running configure again with it. + ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} + else + # Try using printf. + ECHO='printf %s\n' + if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # Cool, printf works + : + elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + ECHO="$CONFIG_SHELL [$]0 --fallback-echo" + elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + ECHO="$CONFIG_SHELL [$]0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do + if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null + then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "[$]0"'; then + echo_test_string=`eval $prev` + export echo_test_string + exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} + else + # Oops. We lost completely, so just stick with echo. + ECHO=echo + fi + fi + fi + fi + fi +fi + +# Copy echo and quote the copy suitably for passing to libtool from +# the Makefile, instead of quoting the original, which is used later. +lt_ECHO=$ECHO +if test "X$lt_ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then + lt_ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" +fi + +AC_SUBST(lt_ECHO) +]) +_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) +_LT_DECL([], [ECHO], [1], + [An echo program that does not interpret backslashes]) +])# _LT_PROG_ECHO_BACKSLASH + + +# _LT_ENABLE_LOCK +# --------------- +m4_defun([_LT_ENABLE_LOCK], +[AC_ARG_ENABLE([libtool-lock], + [AS_HELP_STRING([--disable-libtool-lock], + [avoid locking (might break parallel builds)])]) +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE="32" + ;; + *ELF-64*) + HPUX_IA64_MODE="64" + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out which ABI we are using. + echo '[#]line __oline__ "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + if test "$lt_cv_prog_gnu_ld" = yes; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ +s390*-*linux*|s390*-*tpf*|sparc*-*linux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.o` in + *32-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_i386_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_i386" + ;; + ppc64-*linux*|powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_x86_64_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + ppc*-*linux*|powerpc*-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*|s390*-*tpf*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, + [AC_LANG_PUSH(C) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) + AC_LANG_POP]) + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; +sparc*-*solaris*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.o` in + *64-bit*) + case $lt_cv_prog_gnu_ld in + yes*) LD="${LD-ld} -m elf64_sparc" ;; + *) + if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then + LD="${LD-ld} -64" + fi + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; +esac + +need_locks="$enable_libtool_lock" +])# _LT_ENABLE_LOCK + + +# _LT_CMD_OLD_ARCHIVE +# ------------------- +m4_defun([_LT_CMD_OLD_ARCHIVE], +[AC_CHECK_TOOL(AR, ar, false) +test -z "$AR" && AR=ar +test -z "$AR_FLAGS" && AR_FLAGS=cru +_LT_DECL([], [AR], [1], [The archiver]) +_LT_DECL([], [AR_FLAGS], [1]) + +AC_CHECK_TOOL(STRIP, strip, :) +test -z "$STRIP" && STRIP=: +_LT_DECL([], [STRIP], [1], [A symbol stripping program]) + +AC_CHECK_TOOL(RANLIB, ranlib, :) +test -z "$RANLIB" && RANLIB=: +_LT_DECL([], [RANLIB], [1], + [Commands used to install an old-style archive]) + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + openbsd*) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" + ;; + *) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" +fi +_LT_DECL([], [old_postinstall_cmds], [2]) +_LT_DECL([], [old_postuninstall_cmds], [2]) +_LT_TAGDECL([], [old_archive_cmds], [2], + [Commands used to build an old-style archive]) +])# _LT_CMD_OLD_ARCHIVE + + +# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------------------- +# Check whether the given compiler option works +AC_DEFUN([_LT_COMPILER_OPTION], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_SED])dnl +AC_CACHE_CHECK([$1], [$2], + [$2=no + m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$3" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + $2=yes + fi + fi + $RM conftest* +]) + +if test x"[$]$2" = xyes; then + m4_if([$5], , :, [$5]) +else + m4_if([$6], , :, [$6]) +fi +])# _LT_COMPILER_OPTION + +# Old name: +AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) + + +# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------- +# Check whether the given linker option works +AC_DEFUN([_LT_LINKER_OPTION], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_SED])dnl +AC_CACHE_CHECK([$1], [$2], + [$2=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $3" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&AS_MESSAGE_LOG_FD + $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + $2=yes + fi + else + $2=yes + fi + fi + $RM -r conftest* + LDFLAGS="$save_LDFLAGS" +]) + +if test x"[$]$2" = xyes; then + m4_if([$4], , :, [$4]) +else + m4_if([$5], , :, [$5]) +fi +])# _LT_LINKER_OPTION + +# Old name: +AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) + + +# LT_CMD_MAX_LEN +#--------------- +AC_DEFUN([LT_CMD_MAX_LEN], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +# find the maximum length of command line arguments +AC_MSG_CHECKING([the maximum length of command line arguments]) +AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl + i=0 + teststring="ABCD" + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw* | cegcc*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` + elif test -x /usr/sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` + else + lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs + fi + # And add a safety zone + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + ;; + + interix*) + # We know the value 262144 and hardcode it with a safety zone (like BSD) + lt_cv_sys_max_cmd_len=196608 + ;; + + osf*) + # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure + # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not + # nice to cause kernel panics so lets avoid the loop below. + # First set a reasonable default. + lt_cv_sys_max_cmd_len=16384 + # + if test -x /sbin/sysconfig; then + case `/sbin/sysconfig -q proc exec_disable_arg_limit` in + *1*) lt_cv_sys_max_cmd_len=-1 ;; + esac + fi + ;; + sco3.2v5*) + lt_cv_sys_max_cmd_len=102400 + ;; + sysv5* | sco5v6* | sysv4.2uw2*) + kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` + if test -n "$kargmax"; then + lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` + else + lt_cv_sys_max_cmd_len=32768 + fi + ;; + *) + lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` + if test -n "$lt_cv_sys_max_cmd_len"; then + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + else + # Make teststring a little bigger before we do anything with it. + # a 1K string should be a reasonable start. + for i in 1 2 3 4 5 6 7 8 ; do + teststring=$teststring$teststring + done + SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} + # If test is not a shell built-in, we'll probably end up computing a + # maximum length that is only half of the actual maximum length, but + # we can't tell. + while { test "X"`$SHELL [$]0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \ + = "XX$teststring$teststring"; } >/dev/null 2>&1 && + test $i != 17 # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + # Only check the string length outside the loop. + lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` + teststring= + # Add a significant safety factor because C++ compilers can tack on + # massive amounts of additional arguments before passing them to the + # linker. It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + fi + ;; + esac +]) +if test -n $lt_cv_sys_max_cmd_len ; then + AC_MSG_RESULT($lt_cv_sys_max_cmd_len) +else + AC_MSG_RESULT(none) +fi +max_cmd_len=$lt_cv_sys_max_cmd_len +_LT_DECL([], [max_cmd_len], [0], + [What is the maximum length of a command?]) +])# LT_CMD_MAX_LEN + +# Old name: +AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) + + +# _LT_HEADER_DLFCN +# ---------------- +m4_defun([_LT_HEADER_DLFCN], +[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl +])# _LT_HEADER_DLFCN + + +# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, +# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) +# ---------------------------------------------------------------- +m4_defun([_LT_TRY_DLOPEN_SELF], +[m4_require([_LT_HEADER_DLFCN])dnl +if test "$cross_compiling" = yes; then : + [$4] +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +[#line __oline__ "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + else + puts (dlerror ()); + + return status; +}] +_LT_EOF + if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) $1 ;; + x$lt_dlneed_uscore) $2 ;; + x$lt_dlunknown|x*) $3 ;; + esac + else : + # compilation failed + $3 + fi +fi +rm -fr conftest* +])# _LT_TRY_DLOPEN_SELF + + +# LT_SYS_DLOPEN_SELF +# ------------------ +AC_DEFUN([LT_SYS_DLOPEN_SELF], +[m4_require([_LT_HEADER_DLFCN])dnl +if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32* | cegcc*) + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen="dlopen" + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ + lt_cv_dlopen="dyld" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ]) + ;; + + *) + AC_CHECK_FUNC([shl_load], + [lt_cv_dlopen="shl_load"], + [AC_CHECK_LIB([dld], [shl_load], + [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], + [AC_CHECK_FUNC([dlopen], + [lt_cv_dlopen="dlopen"], + [AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], + [AC_CHECK_LIB([svld], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], + [AC_CHECK_LIB([dld], [dld_link], + [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) + ]) + ]) + ]) + ]) + ]) + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS="$LDFLAGS" + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS="$LIBS" + LIBS="$lt_cv_dlopen_libs $LIBS" + + AC_CACHE_CHECK([whether a program can dlopen itself], + lt_cv_dlopen_self, [dnl + _LT_TRY_DLOPEN_SELF( + lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, + lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) + ]) + + if test "x$lt_cv_dlopen_self" = xyes; then + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" + AC_CACHE_CHECK([whether a statically linked program can dlopen itself], + lt_cv_dlopen_self_static, [dnl + _LT_TRY_DLOPEN_SELF( + lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, + lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) + ]) + fi + + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi +_LT_DECL([dlopen_support], [enable_dlopen], [0], + [Whether dlopen is supported]) +_LT_DECL([dlopen_self], [enable_dlopen_self], [0], + [Whether dlopen of programs is supported]) +_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], + [Whether dlopen of statically linked programs is supported]) +])# LT_SYS_DLOPEN_SELF + +# Old name: +AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) + + +# _LT_COMPILER_C_O([TAGNAME]) +# --------------------------- +# Check to see if options -c and -o are simultaneously supported by compiler. +# This macro does not hard code the compiler like AC_PROG_CC_C_O. +m4_defun([_LT_COMPILER_C_O], +[m4_require([_LT_DECL_SED])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_TAG_COMPILER])dnl +AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], + [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], + [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + fi + fi + chmod u+w . 2>&AS_MESSAGE_LOG_FD + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* +]) +_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], + [Does compiler simultaneously support -c and -o options?]) +])# _LT_COMPILER_C_O + + +# _LT_COMPILER_FILE_LOCKS([TAGNAME]) +# ---------------------------------- +# Check to see if we can do hard links to lock some files if needed +m4_defun([_LT_COMPILER_FILE_LOCKS], +[m4_require([_LT_ENABLE_LOCK])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +_LT_COMPILER_C_O([$1]) + +hard_links="nottested" +if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + AC_MSG_CHECKING([if we can lock with hard links]) + hard_links=yes + $RM conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + AC_MSG_RESULT([$hard_links]) + if test "$hard_links" = no; then + AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) + need_locks=warn + fi +else + need_locks=no +fi +_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) +])# _LT_COMPILER_FILE_LOCKS + + +# _LT_CHECK_OBJDIR +# ---------------- +m4_defun([_LT_CHECK_OBJDIR], +[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], +[rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null]) +objdir=$lt_cv_objdir +_LT_DECL([], [objdir], [0], + [The name of the directory that contains temporary libtool files])dnl +m4_pattern_allow([LT_OBJDIR])dnl +AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", + [Define to the sub-directory in which libtool stores uninstalled libraries.]) +])# _LT_CHECK_OBJDIR + + +# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) +# -------------------------------------- +# Check hardcoding attributes. +m4_defun([_LT_LINKER_HARDCODE_LIBPATH], +[AC_MSG_CHECKING([how to hardcode library paths into programs]) +_LT_TAGVAR(hardcode_action, $1)= +if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || + test -n "$_LT_TAGVAR(runpath_var, $1)" || + test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then + + # We can hardcode non-existent directories. + if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && + test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then + # Linking always hardcodes the temporary library directory. + _LT_TAGVAR(hardcode_action, $1)=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + _LT_TAGVAR(hardcode_action, $1)=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + _LT_TAGVAR(hardcode_action, $1)=unsupported +fi +AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) + +if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || + test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi +_LT_TAGDECL([], [hardcode_action], [0], + [How to hardcode a shared library path into an executable]) +])# _LT_LINKER_HARDCODE_LIBPATH + + +# _LT_CMD_STRIPLIB +# ---------------- +m4_defun([_LT_CMD_STRIPLIB], +[m4_require([_LT_DECL_EGREP]) +striplib= +old_striplib= +AC_MSG_CHECKING([whether stripping libraries is possible]) +if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + AC_MSG_RESULT([yes]) +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP" ; then + striplib="$STRIP -x" + old_striplib="$STRIP -S" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + ;; + *) + AC_MSG_RESULT([no]) + ;; + esac +fi +_LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) +_LT_DECL([], [striplib], [1]) +])# _LT_CMD_STRIPLIB + + +# _LT_SYS_DYNAMIC_LINKER([TAG]) +# ----------------------------- +# PORTME Fill in your ld.so characteristics +m4_defun([_LT_SYS_DYNAMIC_LINKER], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_OBJDUMP])dnl +m4_require([_LT_DECL_SED])dnl +AC_MSG_CHECKING([dynamic linker characteristics]) +m4_if([$1], + [], [ +if test "$GCC" = yes; then + case $host_os in + darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; + *) lt_awk_arg="/^libraries:/" ;; + esac + lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'` + else + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + # Ok, now we have the path, separated by spaces, we can step through it + # and add multilib dir if necessary. + lt_tmp_lt_search_path_spec= + lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + for lt_sys_path in $lt_search_path_spec; do + if test -d "$lt_sys_path/$lt_multi_os_dir"; then + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" + else + test -d "$lt_sys_path" && \ + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" + fi + done + lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk ' +BEGIN {RS=" "; FS="/|\n";} { + lt_foo=""; + lt_count=0; + for (lt_i = NF; lt_i > 0; lt_i--) { + if ($lt_i != "" && $lt_i != ".") { + if ($lt_i == "..") { + lt_count++; + } else { + if (lt_count == 0) { + lt_foo="/" $lt_i lt_foo; + } else { + lt_count--; + } + } + } + } + if (lt_foo != "") { lt_freq[[lt_foo]]++; } + if (lt_freq[[lt_foo]] == 1) { print lt_foo; } +}'` + sys_lib_search_path_spec=`$ECHO $lt_search_path_spec` +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi]) +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix[[4-9]]*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[[01]] | aix4.[[01]].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + case $host_cpu in + powerpc) + # Since July 2007 AmigaOS4 officially supports .so libraries. + # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + ;; + m68k) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + esac + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[[45]]*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32* | cegcc*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw* | cegcc*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' +m4_if([$1], [],[ + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[[123]]*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[[01]]* | freebsdelf3.[[01]]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ + freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + *) # from 4.6 on, and DragonFly + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +interix[[3-9]]*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux* | k*bsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # Some binutils ld are patched to set DT_RUNPATH + save_LDFLAGS=$LDFLAGS + save_libdir=$libdir + eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ + LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], + [shlibpath_overrides_runpath=yes])]) + LDFLAGS=$save_LDFLAGS + libdir=$save_libdir + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +*nto* | *qnx*) + version_type=qnx + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='ldqnx.so' + ;; + +openbsd*) + version_type=sunos + sys_lib_dlsearch_path_spec="/usr/lib" + need_lib_prefix=no + # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. + case $host_os in + openbsd3.3 | openbsd3.3.*) need_version=yes ;; + *) need_version=no ;; + esac + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[[89]] | openbsd2.[[89]].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +rdos*) + dynamic_linker=no + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=freebsd-elf + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + if test "$with_gnu_ld" = yes; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +tpf*) + # TPF is a cross-target only. Preferred cross-host = GNU/Linux. + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +AC_MSG_RESULT([$dynamic_linker]) +test "$dynamic_linker" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then + sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" +fi +if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then + sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" +fi + +_LT_DECL([], [variables_saved_for_relink], [1], + [Variables whose values should be saved in libtool wrapper scripts and + restored at link time]) +_LT_DECL([], [need_lib_prefix], [0], + [Do we need the "lib" prefix for modules?]) +_LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) +_LT_DECL([], [version_type], [0], [Library versioning type]) +_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) +_LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) +_LT_DECL([], [shlibpath_overrides_runpath], [0], + [Is shlibpath searched before the hard-coded library search path?]) +_LT_DECL([], [libname_spec], [1], [Format of library name prefix]) +_LT_DECL([], [library_names_spec], [1], + [[List of archive names. First name is the real one, the rest are links. + The last name is the one that the linker finds with -lNAME]]) +_LT_DECL([], [soname_spec], [1], + [[The coded name of the library, if different from the real name]]) +_LT_DECL([], [postinstall_cmds], [2], + [Command to use after installation of a shared archive]) +_LT_DECL([], [postuninstall_cmds], [2], + [Command to use after uninstallation of a shared archive]) +_LT_DECL([], [finish_cmds], [2], + [Commands used to finish a libtool library installation in a directory]) +_LT_DECL([], [finish_eval], [1], + [[As "finish_cmds", except a single script fragment to be evaled but + not shown]]) +_LT_DECL([], [hardcode_into_libs], [0], + [Whether we should hardcode library paths into libraries]) +_LT_DECL([], [sys_lib_search_path_spec], [2], + [Compile-time system search path for libraries]) +_LT_DECL([], [sys_lib_dlsearch_path_spec], [2], + [Run-time system search path for libraries]) +])# _LT_SYS_DYNAMIC_LINKER + + +# _LT_PATH_TOOL_PREFIX(TOOL) +# -------------------------- +# find a file program which can recognize shared library +AC_DEFUN([_LT_PATH_TOOL_PREFIX], +[m4_require([_LT_DECL_EGREP])dnl +AC_MSG_CHECKING([for $1]) +AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, +[case $MAGIC_CMD in +[[\\/*] | ?:[\\/]*]) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR +dnl $ac_dummy forces splitting on constant user-supplied paths. +dnl POSIX.2 word splitting is done only on the output of word expansions, +dnl not every word. This closes a longstanding sh security hole. + ac_dummy="m4_if([$2], , $PATH, [$2])" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$1; then + lt_cv_path_MAGIC_CMD="$ac_dir/$1" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<_LT_EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +_LT_EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac]) +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + AC_MSG_RESULT($MAGIC_CMD) +else + AC_MSG_RESULT(no) +fi +_LT_DECL([], [MAGIC_CMD], [0], + [Used to examine libraries when file_magic_cmd begins with "file"])dnl +])# _LT_PATH_TOOL_PREFIX + +# Old name: +AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) + + +# _LT_PATH_MAGIC +# -------------- +# find a file program which can recognize a shared library +m4_defun([_LT_PATH_MAGIC], +[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) + else + MAGIC_CMD=: + fi +fi +])# _LT_PATH_MAGIC + + +# LT_PATH_LD +# ---------- +# find the pathname to the GNU or non-GNU linker +AC_DEFUN([LT_PATH_LD], +[AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_DECL_EGREP])dnl + +AC_ARG_WITH([gnu-ld], + [AS_HELP_STRING([--with-gnu-ld], + [assume the C compiler uses GNU ld @<:@default=no@:>@])], + [test "$withval" = no || with_gnu_ld=yes], + [with_gnu_ld=no])dnl + +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by $CC]) + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [[\\/]]* | ?:[[\\/]]*) + re_direlt='/[[^/]][[^/]]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` + while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do + ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(lt_cv_path_LD, +[if test -z "$LD"; then + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + else + lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + fi + ;; + +cegcc) + # use the weaker test based on 'objdump'. See mingw*. + lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + ;; + +darwin* | rhapsody*) + lt_cv_deplibs_check_method=pass_all + ;; + +freebsd* | dragonfly*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case $host_cpu in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'] + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; + *) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +interix[[3-9]]*) + # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be Linux ELF. +linux* | k*bsd*-gnu) + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +*nto* | *qnx*) + lt_cv_deplibs_check_method=pass_all + ;; + +openbsd*) + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +rdos*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.3*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + pc) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +tpf*) + lt_cv_deplibs_check_method=pass_all + ;; +esac +]) +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown + +_LT_DECL([], [deplibs_check_method], [1], + [Method to check whether dependent libraries are shared objects]) +_LT_DECL([], [file_magic_cmd], [1], + [Command to use when deplibs_check_method == "file_magic"]) +])# _LT_CHECK_MAGIC_METHOD + + +# LT_PATH_NM +# ---------- +# find the pathname to a BSD- or MS-compatible name lister +AC_DEFUN([LT_PATH_NM], +[AC_REQUIRE([AC_PROG_CC])dnl +AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, +[if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM="$NM" +else + lt_nm_to_check="${ac_tool_prefix}nm" + if test -n "$ac_tool_prefix" && test "$build" = "$host"; then + lt_nm_to_check="$lt_nm_to_check nm" + fi + for lt_tmp_nm in $lt_nm_to_check; do + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + tmp_nm="$ac_dir/$lt_tmp_nm" + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in + */dev/null* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + ;; + esac + fi + done + IFS="$lt_save_ifs" + done + : ${lt_cv_path_NM=no} +fi]) +if test "$lt_cv_path_NM" != "no"; then + NM="$lt_cv_path_NM" +else + # Didn't find any BSD compatible name lister, look for dumpbin. + AC_CHECK_TOOLS(DUMPBIN, ["dumpbin -symbols" "link -dump -symbols"], :) + AC_SUBST([DUMPBIN]) + if test "$DUMPBIN" != ":"; then + NM="$DUMPBIN" + fi +fi +test -z "$NM" && NM=nm +AC_SUBST([NM]) +_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl + +AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], + [lt_cv_nm_interface="BSD nm" + echo "int some_variable = 0;" > conftest.$ac_ext + (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$ac_compile" 2>conftest.err) + cat conftest.err >&AS_MESSAGE_LOG_FD + (eval echo "\"\$as_me:__oline__: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) + (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) + cat conftest.err >&AS_MESSAGE_LOG_FD + (eval echo "\"\$as_me:__oline__: output\"" >&AS_MESSAGE_LOG_FD) + cat conftest.out >&AS_MESSAGE_LOG_FD + if $GREP 'External.*some_variable' conftest.out > /dev/null; then + lt_cv_nm_interface="MS dumpbin" + fi + rm -f conftest*]) +])# LT_PATH_NM + +# Old names: +AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) +AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_PROG_NM], []) +dnl AC_DEFUN([AC_PROG_NM], []) + + +# LT_LIB_M +# -------- +# check for math library +AC_DEFUN([LT_LIB_M], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case $host in +*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*) + # These system don't have libm, or don't need it + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") + AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, cos, LIBM="-lm") + ;; +esac +AC_SUBST([LIBM]) +])# LT_LIB_M + +# Old name: +AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_CHECK_LIBM], []) + + +# _LT_COMPILER_NO_RTTI([TAGNAME]) +# ------------------------------- +m4_defun([_LT_COMPILER_NO_RTTI], +[m4_require([_LT_TAG_COMPILER])dnl + +_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + +if test "$GCC" = yes; then + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' + + _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], + lt_cv_prog_compiler_rtti_exceptions, + [-fno-rtti -fno-exceptions], [], + [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) +fi +_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], + [Compiler flag to turn off builtin functions]) +])# _LT_COMPILER_NO_RTTI + + +# _LT_CMD_GLOBAL_SYMBOLS +# ---------------------- +m4_defun([_LT_CMD_GLOBAL_SYMBOLS], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([LT_PATH_NM])dnl +AC_REQUIRE([LT_PATH_LD])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_TAG_COMPILER])dnl + +# Check for command to grab the raw symbol name followed by C symbol from nm. +AC_MSG_CHECKING([command to parse $NM output from $compiler object]) +AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], +[ +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[[BCDEGRST]]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[[BCDT]]' + ;; +cygwin* | mingw* | pw32* | cegcc*) + symcode='[[ABCDGISTW]]' + ;; +hpux*) + if test "$host_cpu" = ia64; then + symcode='[[ABCDEGRST]]' + fi + ;; +irix* | nonstopux*) + symcode='[[BCDEGRST]]' + ;; +osf*) + symcode='[[BCDEGQRST]]' + ;; +solaris*) + symcode='[[BDRT]]' + ;; +sco3.2v5*) + symcode='[[DT]]' + ;; +sysv4.2uw2*) + symcode='[[DT]]' + ;; +sysv5* | sco5v6* | unixware* | OpenUNIX*) + symcode='[[ABDT]]' + ;; +sysv4) + symcode='[[DFNSTU]]' + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[[ABCDGIRSTW]]' ;; +esac + +# Transform an extracted symbol line into a proper C declaration. +# Some systems (esp. on ia64) link data and code symbols differently, +# so use this general approach. +lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# Try without a prefix underscore, then with it. +for ac_symprfx in "" "_"; do + + # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. + symxfrm="\\1 $ac_symprfx\\2 \\2" + + # Write the raw and C identifiers. + if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Fake it for dumpbin and say T for any non-static function + # and D for any global variable. + # Also find C++ and __fastcall symbols from MSVC++, + # which start with @ or ?. + lt_cv_sys_global_symbol_pipe="$AWK ['"\ +" {last_section=section; section=\$ 3};"\ +" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ +" \$ 0!~/External *\|/{next};"\ +" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ +" {if(hide[section]) next};"\ +" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ +" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ +" s[1]~/^[@?]/{print s[1], s[1]; next};"\ +" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ +" ' prfx=^$ac_symprfx]" + else + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + fi + + # Check to see that the pipe works correctly. + pipe_works=no + + rm -f conftest* + cat > conftest.$ac_ext <<_LT_EOF +#ifdef __cplusplus +extern "C" { +#endif +char nm_test_var; +void nm_test_func(void); +void nm_test_func(void){} +#ifdef __cplusplus +} +#endif +int main(){nm_test_var='a';nm_test_func();return(0);} +_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 + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if $GREP ' nm_test_var$' "$nlist" >/dev/null; then + if $GREP ' nm_test_func$' "$nlist" >/dev/null; then + cat <<_LT_EOF > conftest.$ac_ext +#ifdef __cplusplus +extern "C" { +#endif + +_LT_EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' + + cat <<_LT_EOF >> conftest.$ac_ext + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + void *address; +} +lt__PROGRAM__LTX_preloaded_symbols[[]] = +{ + { "@PROGRAM@", (void *) 0 }, +_LT_EOF + $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext + cat <<\_LT_EOF >> conftest.$ac_ext + {0, (void *) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt__PROGRAM__LTX_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif +_LT_EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_save_LIBS="$LIBS" + lt_save_CFLAGS="$CFLAGS" + LIBS="conftstm.$ac_objext" + CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" + if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then + pipe_works=yes + fi + LIBS="$lt_save_LIBS" + CFLAGS="$lt_save_CFLAGS" + else + echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD + fi + else + echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD + cat conftest.$ac_ext >&5 + fi + rm -rf conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done +]) +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + AC_MSG_RESULT(failed) +else + AC_MSG_RESULT(ok) +fi + +_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], + [Take the output of nm and produce a listing of raw symbols and C names]) +_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], + [Transform the output of nm in a proper C declaration]) +_LT_DECL([global_symbol_to_c_name_address], + [lt_cv_sys_global_symbol_to_c_name_address], [1], + [Transform the output of nm in a C name address pair]) +_LT_DECL([global_symbol_to_c_name_address_lib_prefix], + [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], + [Transform the output of nm in a C name address pair when lib prefix is needed]) +]) # _LT_CMD_GLOBAL_SYMBOLS + + +# _LT_COMPILER_PIC([TAGNAME]) +# --------------------------- +m4_defun([_LT_COMPILER_PIC], +[m4_require([_LT_TAG_COMPILER])dnl +_LT_TAGVAR(lt_prog_compiler_wl, $1)= +_LT_TAGVAR(lt_prog_compiler_pic, $1)= +_LT_TAGVAR(lt_prog_compiler_static, $1)= + +AC_MSG_CHECKING([for $compiler option to produce PIC]) +m4_if([$1], [CXX], [ + # C++ specific cases for pic, static, wl, etc. + if test "$GXX" = yes; then + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + mingw* | cygwin* | os2* | pw32* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + *djgpp*) + # DJGPP does not support shared libraries at all + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + interix[[3-9]]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + case $host_os in + aix[[4-9]]*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + chorus*) + case $cc_basename in + cxch68*) + # Green Hills C++ Compiler + # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" + ;; + esac + ;; + dgux*) + case $cc_basename in + ec++*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + ghcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + freebsd* | dragonfly*) + # FreeBSD uses GNU C++ + ;; + hpux9* | hpux10* | hpux11*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + if test "$host_cpu" != ia64; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + fi + ;; + aCC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + ;; + *) + ;; + esac + ;; + interix*) + # This is c89, which is MS Visual C++ (no shared libs) + # Anyone wants to do a port? + ;; + irix5* | irix6* | nonstopux*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + # CC pic flag -KPIC is the default. + ;; + *) + ;; + esac + ;; + linux* | k*bsd*-gnu) + case $cc_basename in + KCC*) + # KAI C++ Compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + ecpc* ) + # old Intel C++ for x86_64 which still supported -KPIC. + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + icpc* ) + # Intel C++, used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + cxx*) + # Compaq C++ + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + xlc* | xlC*) + # IBM XL 8.0 on PPC + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + esac + ;; + esac + ;; + lynxos*) + ;; + m88k*) + ;; + mvs*) + case $cc_basename in + cxx*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' + ;; + *) + ;; + esac + ;; + netbsd*) + ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + ;; + RCC*) + # Rational C++ 2.4.1 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + cxx*) + # Digital/Compaq C++ + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + *) + ;; + esac + ;; + psos*) + ;; + solaris*) + case $cc_basename in + CC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + ;; + *) + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + lcc*) + # Lucid + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + *) + ;; + esac + ;; + vxworks*) + ;; + *) + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +], +[ + if test "$GCC" = yes; then + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + + interix[[3-9]]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + enable_shared=no + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + + hpux9* | hpux10* | hpux11*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC (with -KPIC) is the default. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + linux* | k*bsd*-gnu) + case $cc_basename in + # old Intel for x86_64 which still supported -KPIC. + ecc*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + # icc used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + icc* | ifort*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + # Lahey Fortran 8.1. + lf95*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' + _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' + ;; + pgcc* | pgf77* | pgf90* | pgf95*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + ccc*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All Alpha code is PIC. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + xl*) + # IBM XL C 8.0/Fortran 10.1 on PPC + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C 5.9 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + ;; + *Sun\ F*) + # Sun Fortran 8.3 passes all unrecognized flags to the linker + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='' + ;; + esac + ;; + esac + ;; + + newsos6) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + + osf3* | osf4* | osf5*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All OSF/1 code is PIC. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + rdos*) + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + solaris*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + case $cc_basename in + f77* | f90* | f95*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; + *) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; + esac + ;; + + sunos4*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + unicos*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + + uts4*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *) + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +]) +case $host_os in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" + ;; +esac +AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) +_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], + [How to pass a linker flag through the compiler]) + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then + _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], + [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], + [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], + [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in + "" | " "*) ;; + *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; + esac], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) +fi +_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], + [Additional compiler flags for building library objects]) + +# +# Check to make sure the static flag actually works. +# +wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" +_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], + _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), + $lt_tmp_static_flag, + [], + [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) +_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], + [Compiler flag to prevent dynamic linking]) +])# _LT_COMPILER_PIC + + +# _LT_LINKER_SHLIBS([TAGNAME]) +# ---------------------------- +# See if the linker supports building shared libraries. +m4_defun([_LT_LINKER_SHLIBS], +[AC_REQUIRE([LT_PATH_LD])dnl +AC_REQUIRE([LT_PATH_NM])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl +m4_require([_LT_TAG_COMPILER])dnl +AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) +m4_if([$1], [CXX], [ + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + case $host_os in + aix[[4-9]]*) + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + else + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + fi + ;; + pw32*) + _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" + ;; + cygwin* | mingw* | cegcc*) + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' + ;; + *) + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + ;; + esac + _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] +], [ + runpath_var= + _LT_TAGVAR(allow_undefined_flag, $1)= + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(archive_cmds, $1)= + _LT_TAGVAR(archive_expsym_cmds, $1)= + _LT_TAGVAR(compiler_needs_object, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + _LT_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(hardcode_automatic, $1)=no + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= + _LT_TAGVAR(hardcode_libdir_separator, $1)= + _LT_TAGVAR(hardcode_minus_L, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_TAGVAR(inherit_rpath, $1)=no + _LT_TAGVAR(link_all_deplibs, $1)=unknown + _LT_TAGVAR(module_cmds, $1)= + _LT_TAGVAR(module_expsym_cmds, $1)= + _LT_TAGVAR(old_archive_from_new_cmds, $1)= + _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= + _LT_TAGVAR(thread_safe_flag_spec, $1)= + _LT_TAGVAR(whole_archive_flag_spec, $1)= + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + _LT_TAGVAR(include_expsyms, $1)= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + # Exclude shared library initialization/finalization symbols. +dnl Note also adjust exclude_expsyms for C++ above. + extract_expsyms_cmds= + + case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; + esac + + _LT_TAGVAR(ld_shlibs, $1)=yes + if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then + _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + supports_anon_versioning=no + case `$LD -v 2>&1` in + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + + # See if GNU ld supports shared libraries. + case $host_os in + aix[[3-9]]*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +_LT_EOF + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='' + ;; + m68k) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + interix[[3-9]]*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + gnu* | linux* | tpf* | k*bsd*-gnu) + tmp_diet=no + if test "$host_os" = linux-dietlibc; then + case $cc_basename in + diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) + esac + fi + if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ + && test "$tmp_diet" = no + then + tmp_addflag= + tmp_sharedflag='-shared' + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + lf95*) # Lahey Fortran 8.1 + _LT_TAGVAR(whole_archive_flag_spec, $1)= + tmp_sharedflag='--shared' ;; + xl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) + tmp_sharedflag='-qmkshrobj' + tmp_addflag= ;; + esac + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) # Sun C 5.9 + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + _LT_TAGVAR(compiler_needs_object, $1)=yes + tmp_sharedflag='-G' ;; + *Sun\ F*) # Sun Fortran 8.3 + tmp_sharedflag='-G' ;; + esac + _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + + if test "x$supports_anon_versioning" = xyes; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + fi + + case $cc_basename in + xlf*) + # IBM XL Fortran 10.1 on PPC cannot create shared libs itself + _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' + _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib' + if test "x$supports_anon_versioning" = xyes; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' + fi + ;; + esac + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris*) + if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + ;; + *) + # For security reasons, it is highly recommended that you always + # use absolute paths for naming shared libraries, and exclude the + # DT_RUNPATH tag from executables and libraries. But doing so + # requires that you compile everything twice, which is a pain. + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + sunos4*) + _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + + if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then + runpath_var= + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=yes + _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + _LT_TAGVAR(hardcode_direct, $1)=unsupported + fi + ;; + + aix[[4-9]]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + else + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_TAGVAR(archive_cmds, $1)='' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' + + if test "$GCC" = yes; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + _LT_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)= + fi + ;; + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + _LT_TAGVAR(always_export_symbols, $1)=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + # This is similar to how AIX traditionally builds its shared libraries. + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='' + ;; + m68k) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + ;; + + bsdi[[45]]*) + _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' + # FIXME: Should let the user specify the lib program. + _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' + _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + + darwin* | rhapsody*) + _LT_DARWIN_LINKER_FEATURES($1) + ;; + + dgux*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + freebsd1*) + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | dragonfly*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + hpux9*) + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_direct, $1)=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + ;; + + hpux10*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test "$with_gnu_ld" = no; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + fi + ;; + + hpux11*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + fi + if test "$with_gnu_ld" = no; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + # Try to use the -exported_symbol ld option, if it does not + # work, assume that -exports_file does not work either and + # implicitly export all symbols. + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" + AC_LINK_IFELSE(int foo(void) {}, + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' + ) + LDFLAGS="$save_LDFLAGS" + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(inherit_rpath, $1)=yes + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + newsos6) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *nto* | *qnx*) + ;; + + openbsd*) + if test -f /usr/libexec/ld.so; then + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + else + case $host_os in + openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + ;; + esac + fi + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + os2*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + else + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ + $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' + + # Both c and cxx compiler support -rpath directly + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + solaris*) + _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' + if test "$GCC" = yes; then + wlarc='${wl}' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + else + case `$CC -V 2>&1` in + *"Compilers 5.0"*) + wlarc='' + _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' + ;; + *) + wlarc='${wl}' + _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + ;; + esac + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands `-z linker_flag'. GCC discards it without `$wl', + # but is careful enough not to reorder. + # Supported since Solaris 2.6 (maybe 2.5.1?) + if test "$GCC" = yes; then + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' + fi + ;; + esac + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4) + case $host_vendor in + sni) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' + _LT_TAGVAR(hardcode_direct, $1)=no + ;; + motorola) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4.3*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + _LT_TAGVAR(ld_shlibs, $1)=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + + if test x$host_vendor = xsni; then + case $host in + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' + ;; + esac + fi + fi +]) +AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) +test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no + +_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld + +_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl +_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl +_LT_DECL([], [extract_expsyms_cmds], [2], + [The commands to extract the exported symbol list from a shared archive]) + +# +# Do we need to explicitly link libc? +# +case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in +x|xyes) + # Assume -lc should be added + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $_LT_TAGVAR(archive_cmds, $1) in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + AC_MSG_CHECKING([whether -lc should be explicitly linked in]) + $RM conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + if AC_TRY_EVAL(ac_compile) 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) + pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) + _LT_TAGVAR(allow_undefined_flag, $1)= + if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) + then + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + else + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + fi + _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $RM conftest* + AC_MSG_RESULT([$_LT_TAGVAR(archive_cmds_need_lc, $1)]) + ;; + esac + fi + ;; +esac + +_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], + [Whether or not to add -lc for building shared libraries]) +_LT_TAGDECL([allow_libtool_libs_with_static_runtimes], + [enable_shared_with_static_runtimes], [0], + [Whether or not to disallow shared libs when runtime libs are static]) +_LT_TAGDECL([], [export_dynamic_flag_spec], [1], + [Compiler flag to allow reflexive dlopens]) +_LT_TAGDECL([], [whole_archive_flag_spec], [1], + [Compiler flag to generate shared objects directly from archives]) +_LT_TAGDECL([], [compiler_needs_object], [1], + [Whether the compiler copes with passing no objects directly]) +_LT_TAGDECL([], [old_archive_from_new_cmds], [2], + [Create an old-style archive from a shared archive]) +_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], + [Create a temporary old-style archive to link instead of a shared archive]) +_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) +_LT_TAGDECL([], [archive_expsym_cmds], [2]) +_LT_TAGDECL([], [module_cmds], [2], + [Commands used to build a loadable module if different from building + a shared archive.]) +_LT_TAGDECL([], [module_expsym_cmds], [2]) +_LT_TAGDECL([], [with_gnu_ld], [1], + [Whether we are building with GNU ld or not]) +_LT_TAGDECL([], [allow_undefined_flag], [1], + [Flag that allows shared libraries with undefined symbols to be built]) +_LT_TAGDECL([], [no_undefined_flag], [1], + [Flag that enforces no undefined symbols]) +_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], + [Flag to hardcode $libdir into a binary during linking. + This must work even if $libdir does not exist]) +_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1], + [[If ld is used when linking, flag to hardcode $libdir into a binary + during linking. This must work even if $libdir does not exist]]) +_LT_TAGDECL([], [hardcode_libdir_separator], [1], + [Whether we need a single "-rpath" flag with a separated argument]) +_LT_TAGDECL([], [hardcode_direct], [0], + [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes + DIR into the resulting binary]) +_LT_TAGDECL([], [hardcode_direct_absolute], [0], + [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes + DIR into the resulting binary and the resulting library dependency is + "absolute", i.e impossible to change by setting ${shlibpath_var} if the + library is relocated]) +_LT_TAGDECL([], [hardcode_minus_L], [0], + [Set to "yes" if using the -LDIR flag during linking hardcodes DIR + into the resulting binary]) +_LT_TAGDECL([], [hardcode_shlibpath_var], [0], + [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR + into the resulting binary]) +_LT_TAGDECL([], [hardcode_automatic], [0], + [Set to "yes" if building a shared library automatically hardcodes DIR + into the library and all subsequent libraries and executables linked + against it]) +_LT_TAGDECL([], [inherit_rpath], [0], + [Set to yes if linker adds runtime paths of dependent libraries + to runtime path list]) +_LT_TAGDECL([], [link_all_deplibs], [0], + [Whether libtool must link a program against all its dependency libraries]) +_LT_TAGDECL([], [fix_srcfile_path], [1], + [Fix the shell variable $srcfile for the compiler]) +_LT_TAGDECL([], [always_export_symbols], [0], + [Set to "yes" if exported symbols are required]) +_LT_TAGDECL([], [export_symbols_cmds], [2], + [The commands to list exported symbols]) +_LT_TAGDECL([], [exclude_expsyms], [1], + [Symbols that should not be listed in the preloaded symbols]) +_LT_TAGDECL([], [include_expsyms], [1], + [Symbols that must always be exported]) +_LT_TAGDECL([], [prelink_cmds], [2], + [Commands necessary for linking programs (against libraries) with templates]) +_LT_TAGDECL([], [file_list_spec], [1], + [Specify filename containing input files]) +dnl FIXME: Not yet implemented +dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], +dnl [Compiler flag to generate thread safe objects]) +])# _LT_LINKER_SHLIBS + + +# _LT_LANG_C_CONFIG([TAG]) +# ------------------------ +# Ensure that the configuration variables for a C compiler are suitably +# defined. These variables are subsequently used by _LT_CONFIG to write +# the compiler configuration to `libtool'. +m4_defun([_LT_LANG_C_CONFIG], +[m4_require([_LT_DECL_EGREP])dnl +lt_save_CC="$CC" +AC_LANG_PUSH(C) + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}' + +_LT_TAG_COMPILER +# Save the default compiler, since it gets overwritten when the other +# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. +compiler_DEFAULT=$CC + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + LT_SYS_DLOPEN_SELF + _LT_CMD_STRIPLIB + + # Report which library types will actually be built + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test "$can_build_shared" = "no" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + + aix[[4-9]]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test "$enable_shared" = yes || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_CONFIG($1) +fi +AC_LANG_POP +CC="$lt_save_CC" +])# _LT_LANG_C_CONFIG + + +# _LT_PROG_CXX +# ------------ +# Since AC_PROG_CXX is broken, in that it returns g++ if there is no c++ +# compiler, we have our own version here. +m4_defun([_LT_PROG_CXX], +[ +pushdef([AC_MSG_ERROR], [_lt_caught_CXX_error=yes]) +AC_PROG_CXX +if test -n "$CXX" && ( test "X$CXX" != "Xno" && + ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || + (test "X$CXX" != "Xg++"))) ; then + AC_PROG_CXXCPP +else + _lt_caught_CXX_error=yes +fi +popdef([AC_MSG_ERROR]) +])# _LT_PROG_CXX + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([_LT_PROG_CXX], []) + + +# _LT_LANG_CXX_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for a C++ compiler are suitably +# defined. These variables are subsequently used by _LT_CONFIG to write +# the compiler configuration to `libtool'. +m4_defun([_LT_LANG_CXX_CONFIG], +[AC_REQUIRE([_LT_PROG_CXX])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_EGREP])dnl + +AC_LANG_PUSH(C++) +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(compiler_needs_object, $1)=no +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for C++ test sources. +ac_ext=cpp + +# Object file extension for compiled C++ test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the CXX compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test "$_lt_caught_CXX_error" != yes; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="int some_variable = 0;" + + # Code to be used in simple link tests + lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC=$CC + lt_save_LD=$LD + lt_save_GCC=$GCC + GCC=$GXX + lt_save_with_gnu_ld=$with_gnu_ld + lt_save_path_LD=$lt_cv_path_LD + if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then + lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx + else + $as_unset lt_cv_prog_gnu_ld + fi + if test -n "${lt_cv_path_LDCXX+set}"; then + lt_cv_path_LD=$lt_cv_path_LDCXX + else + $as_unset lt_cv_path_LD + fi + test -z "${LDCXX+set}" || LD=$LDCXX + CC=${CXX-"c++"} + compiler=$CC + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + + if test -n "$compiler"; then + # We don't want -fno-exception when compiling C++ code, so set the + # no_builtin_flag separately + if test "$GXX" = yes; then + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' + else + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + fi + + if test "$GXX" = yes; then + # Set up default GNU C++ configuration + + LT_PATH_LD + + # Check if GNU C++ uses GNU ld as the underlying linker, since the + # archiving commands below assume that GNU ld is being used. + if test "$with_gnu_ld" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + + # If archive_cmds runs LD, not CC, wlarc should be empty + # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to + # investigate it a little bit more. (MM) + wlarc='${wl}' + + # ancient GNU ld didn't support --whole-archive et. al. + if eval "`$CC -print-prog-name=ld` --help 2>&1" | + $GREP 'no-whole-archive' > /dev/null; then + _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + with_gnu_ld=no + wlarc= + + # A generic and very simple default shared library creation + # command for GNU C++ for the case where it uses the native + # linker, instead of GNU ld. If possible, this setting should + # overridden to take advantage of the native linker features on + # the platform it is being used on. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + fi + + # 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 "\-L"' + + else + GXX=no + with_gnu_ld=no + wlarc= + fi + + # PORTME: fill in a description of your system's C++ link characteristics + AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) + _LT_TAGVAR(ld_shlibs, $1)=yes + case $host_os in + aix3*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aix[[4-9]]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) + for ld_flag in $LDFLAGS; do + case $ld_flag in + *-brtl*) + aix_use_runtimelinking=yes + break + ;; + esac + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_TAGVAR(archive_cmds, $1)='' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' + + if test "$GXX" = yes; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + _LT_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)= + fi + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to + # export. + _LT_TAGVAR(always_export_symbols, $1)=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an empty + # executable. + _LT_SYS_MODULE_PATH_AIX + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + # This is similar to how AIX traditionally builds its shared + # libraries. + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + chorus*) + case $cc_basename in + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + darwin* | rhapsody*) + _LT_DARWIN_LINKER_FEATURES($1) + ;; + + dgux*) + case $cc_basename in + ec++*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + ghcx*) + # Green Hills C++ Compiler + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + freebsd[[12]]*) + # C++ shared libraries reported to be fairly broken before + # switch to ELF + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + freebsd-elf*) + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + ;; + + freebsd* | dragonfly*) + # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF + # conventions + _LT_TAGVAR(ld_shlibs, $1)=yes + ;; + + gnu*) + ;; + + hpux9*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # 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; $ECHO "X$list" | $Xsed' + ;; + *) + if test "$GXX" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + hpux10*|hpux11*) + if test $with_gnu_ld = no; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) + ;; + *) + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + ;; + esac + fi + case $host_cpu in + hppa*64*|ia64*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + esac + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # 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; $ECHO "X$list" | $Xsed' + ;; + *) + if test "$GXX" = yes; then + if test $with_gnu_ld = no; then + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + fi + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + interix[[3-9]]*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + irix5* | irix6*) + case $cc_basename in + CC*) + # SGI C++ + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + + # Archives containing C++ object files must be created using + # "CC -ar", where "CC" is the IRIX C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' + ;; + *) + if test "$GXX" = yes; then + if test "$with_gnu_ld" = no; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib' + fi + fi + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + esac + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(inherit_rpath, $1)=yes + ;; + + linux* | k*bsd*-gnu) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # 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 $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' + ;; + icpc* | ecpc* ) + # Intel C++ + with_gnu_ld=yes + # version 8.0 and above of icpc choke on multiply defined symbols + # if we add $predep_objects and $postdep_objects, however 7.1 and + # earlier do not add the objects themselves. + case `$CC -V 2>&1` in + *"Version 7."*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + *) # Version 8.0 or newer + tmp_idyn= + case $host_cpu in + ia64*) tmp_idyn=' -i_dynamic';; + esac + _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + esac + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + case `$CC -V` in + *pgCC\ [[1-5]]* | *pgcpp\ [[1-5]]*) + _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ + compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"' + _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ + $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~ + $RANLIB $oldlib' + _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' + ;; + *) # Version 6 will use weak symbols + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + ;; + cxx*) + # Compaq C++ + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' + + runpath_var=LD_RUN_PATH + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # 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 -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + ;; + xl*) + # IBM XL 8.0 on PPC, with GNU ld + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + if test "x$supports_anon_versioning" = xyes; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + fi + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + _LT_TAGVAR(compiler_needs_object, $1)=yes + + # Not sure whether something based on + # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 + # would be better. + output_verbose_link_cmd='echo' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + esac + ;; + esac + ;; + + lynxos*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + m88k*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + mvs*) + case $cc_basename in + cxx*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' + wlarc= + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + fi + # Workaround some broken pre-1.5 toolchains + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' + ;; + + *nto* | *qnx*) + _LT_TAGVAR(ld_shlibs, $1)=yes + ;; + + openbsd2*) + # C++ shared libraries are fairly broken + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + openbsd*) + if test -f /usr/libexec/ld.so; then + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + fi + output_verbose_link_cmd=echo + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Archives containing C++ object files must be created using + # the KAI C++ compiler. + case $host in + osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; + *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; + esac + ;; + RCC*) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + cxx*) + case $host in + osf3*) + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + ;; + *) + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ + echo "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~ + $RM $lib.exp' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # 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 -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + case $host in + osf3*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # 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 "\-L"' + + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + psos*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + lcc*) + # Lucid + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + solaris*) + case $cc_basename in + CC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_TAGVAR(archive_cmds_need_lc,$1)=yes + _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands `-z linker_flag'. + # Supported since Solaris 2.6 (maybe 2.5.1?) + _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' + ;; + esac + _LT_TAGVAR(link_all_deplibs, $1)=yes + + output_verbose_link_cmd='echo' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + + # The C++ compiler must be used to create the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' + ;; + *) + # GNU C++ compiler with Solaris linker + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' + if $CC --version | $GREP -v '^2\.7' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + # 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 "\-L"' + else + # g++ 2.7 appears to require `-G' NOT `-shared' on this + # platform. + _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + # 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 "\-L"' + fi + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + ;; + esac + fi + ;; + esac + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + vxworks*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + + AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) + test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no + + _LT_TAGVAR(GCC, $1)="$GXX" + _LT_TAGVAR(LD, $1)="$LD" + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_SYS_HIDDEN_LIBDEPS($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + CC=$lt_save_CC + LDCXX=$LD + LD=$lt_save_LD + GCC=$lt_save_GCC + with_gnu_ld=$lt_save_with_gnu_ld + lt_cv_path_LDCXX=$lt_cv_path_LD + lt_cv_path_LD=$lt_save_path_LD + lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld + lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld +fi # test "$_lt_caught_CXX_error" != yes + +AC_LANG_POP +])# _LT_LANG_CXX_CONFIG + + +# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) +# --------------------------------- +# Figure out "hidden" library dependencies from verbose +# compiler output when linking a shared library. +# Parse the compiler output and extract the necessary +# objects, libraries and library flags. +m4_defun([_LT_SYS_HIDDEN_LIBDEPS], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +# Dependencies to place before and after the object being linked: +_LT_TAGVAR(predep_objects, $1)= +_LT_TAGVAR(postdep_objects, $1)= +_LT_TAGVAR(predeps, $1)= +_LT_TAGVAR(postdeps, $1)= +_LT_TAGVAR(compiler_lib_search_path, $1)= + +dnl we can't use the lt_simple_compile_test_code here, +dnl because it contains code intended for an executable, +dnl not a library. It's possible we should let each +dnl tag define a new lt_????_link_test_code variable, +dnl but it's only used here... +m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF +int a; +void foo (void) { a = 0; } +_LT_EOF +], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF +class Foo +{ +public: + Foo (void) { a = 0; } +private: + int a; +}; +_LT_EOF +], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF + subroutine foo + implicit none + integer*4 a + a=0 + return + end +_LT_EOF +], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF + subroutine foo + implicit none + integer a + a=0 + return + end +_LT_EOF +], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF +public class foo { + private int a; + public void bar (void) { + a = 0; + } +}; +_LT_EOF +]) +dnl Parse the compiler output and extract the necessary +dnl objects, libraries and library flags. +if AC_TRY_EVAL(ac_compile); then + # Parse the compiler output and extract the necessary + # objects, libraries and library flags. + + # Sentinel used to keep track of whether or not we are before + # the conftest object file. + pre_test_object_deps_done=no + + for p in `eval "$output_verbose_link_cmd"`; do + case $p in + + -L* | -R* | -l*) + # Some compilers place space between "-{L,R}" and the path. + # Remove the space. + if test $p = "-L" || + test $p = "-R"; then + prev=$p + continue + else + prev= + fi + + if test "$pre_test_object_deps_done" = no; then + case $p in + -L* | -R*) + # Internal compiler library paths should come after those + # provided the user. The postdeps already come after the + # user supplied libs so there is no need to process them. + if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then + _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" + else + _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" + fi + ;; + # The "-l" case would never come before the object being + # linked, so don't bother handling this case. + esac + else + if test -z "$_LT_TAGVAR(postdeps, $1)"; then + _LT_TAGVAR(postdeps, $1)="${prev}${p}" + else + _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" + fi + fi + ;; + + *.$objext) + # This assumes that the test object file only shows up + # once in the compiler output. + if test "$p" = "conftest.$objext"; then + pre_test_object_deps_done=yes + continue + fi + + if test "$pre_test_object_deps_done" = no; then + if test -z "$_LT_TAGVAR(predep_objects, $1)"; then + _LT_TAGVAR(predep_objects, $1)="$p" + else + _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" + fi + else + if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then + _LT_TAGVAR(postdep_objects, $1)="$p" + else + _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" + fi + fi + ;; + + *) ;; # Ignore the rest. + + esac + done + + # Clean up. + rm -f a.out a.exe +else + echo "libtool.m4: error: problem compiling $1 test program" +fi + +$RM -f confest.$objext + +# PORTME: override above test on systems where it is broken +m4_if([$1], [CXX], +[case $host_os in +interix[[3-9]]*) + # Interix 3.5 installs completely hosed .la files for C++, so rather than + # hack all around it, let's just trust "g++" to DTRT. + _LT_TAGVAR(predep_objects,$1)= + _LT_TAGVAR(postdep_objects,$1)= + _LT_TAGVAR(postdeps,$1)= + ;; + +linux*) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + + # The more standards-conforming stlport4 library is + # incompatible with the Cstd library. Avoid specifying + # it if it's in CXXFLAGS. Ignore libCrun as + # -library=stlport4 depends on it. + case " $CXX $CXXFLAGS " in + *" -library=stlport4 "*) + solaris_use_stlport4=yes + ;; + esac + + if test "$solaris_use_stlport4" != yes; then + _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' + fi + ;; + esac + ;; + +solaris*) + case $cc_basename in + CC*) + # The more standards-conforming stlport4 library is + # incompatible with the Cstd library. Avoid specifying + # it if it's in CXXFLAGS. Ignore libCrun as + # -library=stlport4 depends on it. + case " $CXX $CXXFLAGS " in + *" -library=stlport4 "*) + solaris_use_stlport4=yes + ;; + esac + + # Adding this requires a known-good setup of shared libraries for + # Sun compiler versions before 5.6, else PIC objects from an old + # archive will be linked into the output, leading to subtle bugs. + if test "$solaris_use_stlport4" != yes; then + _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' + fi + ;; + esac + ;; +esac +]) + +case " $_LT_TAGVAR(postdeps, $1) " in +*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; +esac + _LT_TAGVAR(compiler_lib_search_dirs, $1)= +if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then + _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` +fi +_LT_TAGDECL([], [compiler_lib_search_dirs], [1], + [The directories searched by this compiler when creating a shared library]) +_LT_TAGDECL([], [predep_objects], [1], + [Dependencies to place before and after the objects being linked to + create a shared library]) +_LT_TAGDECL([], [postdep_objects], [1]) +_LT_TAGDECL([], [predeps], [1]) +_LT_TAGDECL([], [postdeps], [1]) +_LT_TAGDECL([], [compiler_lib_search_path], [1], + [The library search path used internally by the compiler when linking + a shared library]) +])# _LT_SYS_HIDDEN_LIBDEPS + + +# _LT_PROG_F77 +# ------------ +# Since AC_PROG_F77 is broken, in that it returns the empty string +# if there is no fortran compiler, we have our own version here. +m4_defun([_LT_PROG_F77], +[ +pushdef([AC_MSG_ERROR], [_lt_disable_F77=yes]) +AC_PROG_F77 +if test -z "$F77" || test "X$F77" = "Xno"; then + _lt_disable_F77=yes +fi +popdef([AC_MSG_ERROR]) +])# _LT_PROG_F77 + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([_LT_PROG_F77], []) + + +# _LT_LANG_F77_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for a Fortran 77 compiler are +# suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_F77_CONFIG], +[AC_REQUIRE([_LT_PROG_F77])dnl +AC_LANG_PUSH(Fortran 77) + +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for f77 test sources. +ac_ext=f + +# Object file extension for compiled f77 test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the F77 compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test "$_lt_disable_F77" != yes; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="\ + subroutine t + return + end +" + + # Code to be used in simple link tests + lt_simple_link_test_code="\ + program t + end +" + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC="$CC" + lt_save_GCC=$GCC + CC=${F77-"f77"} + compiler=$CC + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + GCC=$G77 + if test -n "$compiler"; then + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test "$can_build_shared" = "no" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + aix[[4-9]]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test "$enable_shared" = yes || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_TAGVAR(GCC, $1)="$G77" + _LT_TAGVAR(LD, $1)="$LD" + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + GCC=$lt_save_GCC + CC="$lt_save_CC" +fi # test "$_lt_disable_F77" != yes + +AC_LANG_POP +])# _LT_LANG_F77_CONFIG + + +# _LT_PROG_FC +# ----------- +# Since AC_PROG_FC is broken, in that it returns the empty string +# if there is no fortran compiler, we have our own version here. +m4_defun([_LT_PROG_FC], +[ +pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes]) +AC_PROG_FC +if test -z "$FC" || test "X$FC" = "Xno"; then + _lt_disable_FC=yes +fi +popdef([AC_MSG_ERROR]) +])# _LT_PROG_FC + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([_LT_PROG_FC], []) + + +# _LT_LANG_FC_CONFIG([TAG]) +# ------------------------- +# Ensure that the configuration variables for a Fortran compiler are +# suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_FC_CONFIG], +[AC_REQUIRE([_LT_PROG_FC])dnl +AC_LANG_PUSH(Fortran) + +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for fc test sources. +ac_ext=${ac_fc_srcext-f} + +# Object file extension for compiled fc test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the FC compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test "$_lt_disable_FC" != yes; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="\ + subroutine t + return + end +" + + # Code to be used in simple link tests + lt_simple_link_test_code="\ + program t + end +" + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC="$CC" + lt_save_GCC=$GCC + CC=${FC-"f95"} + compiler=$CC + GCC=$ac_cv_fc_compiler_gnu + + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + + if test -n "$compiler"; then + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test "$can_build_shared" = "no" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + aix[[4-9]]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test "$enable_shared" = yes || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" + _LT_TAGVAR(LD, $1)="$LD" + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_SYS_HIDDEN_LIBDEPS($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + GCC=$lt_save_GCC + CC="$lt_save_CC" +fi # test "$_lt_disable_FC" != yes + +AC_LANG_POP +])# _LT_LANG_FC_CONFIG + + +# _LT_LANG_GCJ_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for the GNU Java Compiler compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_GCJ_CONFIG], +[AC_REQUIRE([LT_PROG_GCJ])dnl +AC_LANG_SAVE + +# Source file extension for Java test sources. +ac_ext=java + +# Object file extension for compiled Java test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="class foo {}" + +# Code to be used in simple link tests +lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +lt_save_GCC=$GCC +GCC=yes +CC=${GCJ-"gcj"} +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_TAGVAR(LD, $1)="$LD" +_LT_CC_BASENAME([$compiler]) + +# GCJ did not exist at the time GCC didn't implicitly link libc in. +_LT_TAGVAR(archive_cmds_need_lc, $1)=no + +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) +fi + +AC_LANG_RESTORE + +GCC=$lt_save_GCC +CC="$lt_save_CC" +])# _LT_LANG_GCJ_CONFIG + + +# _LT_LANG_RC_CONFIG([TAG]) +# ------------------------- +# Ensure that the configuration variables for the Windows resource compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_RC_CONFIG], +[AC_REQUIRE([LT_PROG_RC])dnl +AC_LANG_SAVE + +# Source file extension for RC test sources. +ac_ext=rc + +# Object file extension for compiled RC test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' + +# Code to be used in simple link tests +lt_simple_link_test_code="$lt_simple_compile_test_code" + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +lt_save_GCC=$GCC +GCC= +CC=${RC-"windres"} +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_CC_BASENAME([$compiler]) +_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + +if test -n "$compiler"; then + : + _LT_CONFIG($1) +fi + +GCC=$lt_save_GCC +AC_LANG_RESTORE +CC="$lt_save_CC" +])# _LT_LANG_RC_CONFIG + + +# LT_PROG_GCJ +# ----------- +AC_DEFUN([LT_PROG_GCJ], +[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], + [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], + [AC_CHECK_TOOL(GCJ, gcj,) + test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" + AC_SUBST(GCJFLAGS)])])[]dnl +]) + +# Old name: +AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_GCJ], []) + + +# LT_PROG_RC +# ---------- +AC_DEFUN([LT_PROG_RC], +[AC_CHECK_TOOL(RC, windres,) +]) + +# Old name: +AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_RC], []) + + +# _LT_DECL_EGREP +# -------------- +# If we don't have a new enough Autoconf to choose the best grep +# available, choose the one first in the user's PATH. +m4_defun([_LT_DECL_EGREP], +[AC_REQUIRE([AC_PROG_EGREP])dnl +AC_REQUIRE([AC_PROG_FGREP])dnl +test -z "$GREP" && GREP=grep +_LT_DECL([], [GREP], [1], [A grep program that handles long lines]) +_LT_DECL([], [EGREP], [1], [An ERE matcher]) +_LT_DECL([], [FGREP], [1], [A literal string matcher]) +dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too +AC_SUBST([GREP]) +]) + + +# _LT_DECL_OBJDUMP +# -------------- +# If we don't have a new enough Autoconf to choose the best objdump +# available, choose the one first in the user's PATH. +m4_defun([_LT_DECL_OBJDUMP], +[AC_CHECK_TOOL(OBJDUMP, objdump, false) +test -z "$OBJDUMP" && OBJDUMP=objdump +_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) +AC_SUBST([OBJDUMP]) +]) + + +# _LT_DECL_SED +# ------------ +# Check for a fully-functional sed program, that truncates +# as few characters as possible. Prefer GNU sed if found. +m4_defun([_LT_DECL_SED], +[AC_PROG_SED +test -z "$SED" && SED=sed +Xsed="$SED -e 1s/^X//" +_LT_DECL([], [SED], [1], [A sed program that does not truncate output]) +_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], + [Sed that helps us avoid accidentally triggering echo(1) options like -n]) +])# _LT_DECL_SED + +m4_ifndef([AC_PROG_SED], [ +############################################################ +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_SED. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # +############################################################ + +m4_defun([AC_PROG_SED], +[AC_MSG_CHECKING([for a sed that does not truncate output]) +AC_CACHE_VAL(lt_cv_path_SED, +[# Loop through the user's path and test for sed and gsed. +# Then use that list of sed's as ones to test for truncation. +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for lt_ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then + lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" + fi + done + done +done +IFS=$as_save_IFS +lt_ac_max=0 +lt_ac_count=0 +# Add /usr/xpg4/bin/sed as it is typically found on Solaris +# along with /bin/sed that truncates output. +for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do + test ! -f $lt_ac_sed && continue + cat /dev/null > conftest.in + lt_ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >conftest.in + # Check for GNU sed and select it if it is found. + if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then + lt_cv_path_SED=$lt_ac_sed + break + fi + while true; do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo >>conftest.nl + $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break + cmp -s conftest.out conftest.nl || break + # 10000 chars as input seems more than enough + test $lt_ac_count -gt 10 && break + lt_ac_count=`expr $lt_ac_count + 1` + if test $lt_ac_count -gt $lt_ac_max; then + lt_ac_max=$lt_ac_count + lt_cv_path_SED=$lt_ac_sed + fi + done +done +]) +SED=$lt_cv_path_SED +AC_SUBST([SED]) +AC_MSG_RESULT([$SED]) +])#AC_PROG_SED +])#m4_ifndef + +# Old name: +AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_SED], []) + + +# _LT_CHECK_SHELL_FEATURES +# ------------------------ +# Find out whether the shell is Bourne or XSI compatible, +# or has some other useful features. +m4_defun([_LT_CHECK_SHELL_FEATURES], +[AC_MSG_CHECKING([whether the shell understands some XSI constructs]) +# Try some XSI features +xsi_shell=no +( _lt_dummy="a/b/c" + test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ + = c,a/b,, \ + && eval 'test $(( 1 + 1 )) -eq 2 \ + && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ + && xsi_shell=yes +AC_MSG_RESULT([$xsi_shell]) +_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) + +AC_MSG_CHECKING([whether the shell understands "+="]) +lt_shell_append=no +( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ + >/dev/null 2>&1 \ + && lt_shell_append=yes +AC_MSG_RESULT([$lt_shell_append]) +_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) + +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + lt_unset=unset +else + lt_unset=false +fi +_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl + +# test EBCDIC or ASCII +case `echo X|tr X '\101'` in + A) # ASCII based system + # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr + lt_SP2NL='tr \040 \012' + lt_NL2SP='tr \015\012 \040\040' + ;; + *) # EBCDIC based system + lt_SP2NL='tr \100 \n' + lt_NL2SP='tr \r\n \100\100' + ;; +esac +_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl +_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl +])# _LT_CHECK_SHELL_FEATURES + + +# _LT_PROG_XSI_SHELLFNS +# --------------------- +# Bourne and XSI compatible variants of some useful shell functions. +m4_defun([_LT_PROG_XSI_SHELLFNS], +[case $xsi_shell in + yes) + cat << \_LT_EOF >> "$cfgfile" + +# func_dirname file append nondir_replacement +# Compute the dirname of FILE. If nonempty, add APPEND to the result, +# otherwise set result to NONDIR_REPLACEMENT. +func_dirname () +{ + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac +} + +# func_basename file +func_basename () +{ + func_basename_result="${1##*/}" +} + +# func_dirname_and_basename file append nondir_replacement +# perform func_basename and func_dirname in a single function +# call: +# dirname: Compute the dirname of FILE. If nonempty, +# add APPEND to the result, otherwise set result +# to NONDIR_REPLACEMENT. +# value returned in "$func_dirname_result" +# basename: Compute filename of FILE. +# value retuned in "$func_basename_result" +# Implementation must be kept synchronized with func_dirname +# and func_basename. For efficiency, we do not delegate to +# those functions but instead duplicate the functionality here. +func_dirname_and_basename () +{ + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac + func_basename_result="${1##*/}" +} + +# func_stripname prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +func_stripname () +{ + # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are + # positional parameters, so assign one to ordinary parameter first. + func_stripname_result=${3} + func_stripname_result=${func_stripname_result#"${1}"} + func_stripname_result=${func_stripname_result%"${2}"} +} + +# func_opt_split +func_opt_split () +{ + func_opt_split_opt=${1%%=*} + func_opt_split_arg=${1#*=} +} + +# func_lo2o object +func_lo2o () +{ + case ${1} in + *.lo) func_lo2o_result=${1%.lo}.${objext} ;; + *) func_lo2o_result=${1} ;; + esac +} + +# func_xform libobj-or-source +func_xform () +{ + func_xform_result=${1%.*}.lo +} + +# func_arith arithmetic-term... +func_arith () +{ + func_arith_result=$(( $[*] )) +} + +# func_len string +# STRING may not start with a hyphen. +func_len () +{ + func_len_result=${#1} +} + +_LT_EOF + ;; + *) # Bourne compatible functions. + cat << \_LT_EOF >> "$cfgfile" + +# func_dirname file append nondir_replacement +# Compute the dirname of FILE. If nonempty, add APPEND to the result, +# otherwise set result to NONDIR_REPLACEMENT. +func_dirname () +{ + # Extract subdirectory from the argument. + func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` + if test "X$func_dirname_result" = "X${1}"; then + func_dirname_result="${3}" + else + func_dirname_result="$func_dirname_result${2}" + fi +} + +# func_basename file +func_basename () +{ + func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` +} + +dnl func_dirname_and_basename +dnl A portable version of this function is already defined in general.m4sh +dnl so there is no need for it here. + +# func_stripname prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +# func_strip_suffix prefix name +func_stripname () +{ + case ${2} in + .*) func_stripname_result=`$ECHO "X${3}" \ + | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;; + *) func_stripname_result=`$ECHO "X${3}" \ + | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;; + esac +} + +# sed scripts: +my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q' +my_sed_long_arg='1s/^-[[^=]]*=//' + +# func_opt_split +func_opt_split () +{ + func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"` + func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"` +} + +# func_lo2o object +func_lo2o () +{ + func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"` +} + +# func_xform libobj-or-source +func_xform () +{ + func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[[^.]]*$/.lo/'` +} + +# func_arith arithmetic-term... +func_arith () +{ + func_arith_result=`expr "$[@]"` +} + +# func_len string +# STRING may not start with a hyphen. +func_len () +{ + func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len` +} + +_LT_EOF +esac + +case $lt_shell_append in + yes) + cat << \_LT_EOF >> "$cfgfile" + +# func_append var value +# Append VALUE to the end of shell variable VAR. +func_append () +{ + eval "$[1]+=\$[2]" +} +_LT_EOF + ;; + *) + cat << \_LT_EOF >> "$cfgfile" + +# func_append var value +# Append VALUE to the end of shell variable VAR. +func_append () +{ + eval "$[1]=\$$[1]\$[2]" +} + +_LT_EOF + ;; + esac +]) diff --git a/m4/ltoptions.m4 b/m4/ltoptions.m4 new file mode 100644 index 0000000..34151a3 --- /dev/null +++ b/m4/ltoptions.m4 @@ -0,0 +1,368 @@ +# Helper functions for option handling. -*- Autoconf -*- +# +# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. +# Written by Gary V. Vaughan, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 6 ltoptions.m4 + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) + + +# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) +# ------------------------------------------ +m4_define([_LT_MANGLE_OPTION], +[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) + + +# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) +# --------------------------------------- +# Set option OPTION-NAME for macro MACRO-NAME, and if there is a +# matching handler defined, dispatch to it. Other OPTION-NAMEs are +# saved as a flag. +m4_define([_LT_SET_OPTION], +[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl +m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), + _LT_MANGLE_DEFUN([$1], [$2]), + [m4_warning([Unknown $1 option `$2'])])[]dnl +]) + + +# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) +# ------------------------------------------------------------ +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +m4_define([_LT_IF_OPTION], +[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) + + +# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) +# ------------------------------------------------------- +# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME +# are set. +m4_define([_LT_UNLESS_OPTIONS], +[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), + [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), + [m4_define([$0_found])])])[]dnl +m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 +])[]dnl +]) + + +# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) +# ---------------------------------------- +# OPTION-LIST is a space-separated list of Libtool options associated +# with MACRO-NAME. If any OPTION has a matching handler declared with +# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about +# the unknown option and exit. +m4_defun([_LT_SET_OPTIONS], +[# Set options +m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), + [_LT_SET_OPTION([$1], _LT_Option)]) + +m4_if([$1],[LT_INIT],[ + dnl + dnl Simply set some default values (i.e off) if boolean options were not + dnl specified: + _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no + ]) + _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no + ]) + dnl + dnl If no reference was made to various pairs of opposing options, then + dnl we run the default mode handler for the pair. For example, if neither + dnl `shared' nor `disable-shared' was passed, we enable building of shared + dnl archives by default: + _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) + _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) + _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) + _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], + [_LT_ENABLE_FAST_INSTALL]) + ]) +])# _LT_SET_OPTIONS + + +## --------------------------------- ## +## Macros to handle LT_INIT options. ## +## --------------------------------- ## + +# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) +# ----------------------------------------- +m4_define([_LT_MANGLE_DEFUN], +[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) + + +# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) +# ----------------------------------------------- +m4_define([LT_OPTION_DEFINE], +[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl +])# LT_OPTION_DEFINE + + +# dlopen +# ------ +LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes +]) + +AU_DEFUN([AC_LIBTOOL_DLOPEN], +[_LT_SET_OPTION([LT_INIT], [dlopen]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the `dlopen' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) + + +# win32-dll +# --------- +# Declare package support for building win32 dll's. +LT_OPTION_DEFINE([LT_INIT], [win32-dll], +[enable_win32_dll=yes + +case $host in +*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-cegcc*) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) + ;; +esac + +test -z "$AS" && AS=as +_LT_DECL([], [AS], [0], [Assembler program])dnl + +test -z "$DLLTOOL" && DLLTOOL=dlltool +_LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl + +test -z "$OBJDUMP" && OBJDUMP=objdump +_LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl +])# win32-dll + +AU_DEFUN([AC_LIBTOOL_WIN32_DLL], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +_LT_SET_OPTION([LT_INIT], [win32-dll]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the `win32-dll' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) + + +# _LT_ENABLE_SHARED([DEFAULT]) +# ---------------------------- +# implement the --enable-shared flag, and supports the `shared' and +# `disable-shared' LT_INIT options. +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +m4_define([_LT_ENABLE_SHARED], +[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([shared], + [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], + [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) + + _LT_DECL([build_libtool_libs], [enable_shared], [0], + [Whether or not to build shared libraries]) +])# _LT_ENABLE_SHARED + +LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) + +# Old names: +AC_DEFUN([AC_ENABLE_SHARED], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) +]) + +AC_DEFUN([AC_DISABLE_SHARED], +[_LT_SET_OPTION([LT_INIT], [disable-shared]) +]) + +AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) +AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_ENABLE_SHARED], []) +dnl AC_DEFUN([AM_DISABLE_SHARED], []) + + + +# _LT_ENABLE_STATIC([DEFAULT]) +# ---------------------------- +# implement the --enable-static flag, and support the `static' and +# `disable-static' LT_INIT options. +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +m4_define([_LT_ENABLE_STATIC], +[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([static], + [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], + [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_static=]_LT_ENABLE_STATIC_DEFAULT) + + _LT_DECL([build_old_libs], [enable_static], [0], + [Whether or not to build static libraries]) +])# _LT_ENABLE_STATIC + +LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) + +# Old names: +AC_DEFUN([AC_ENABLE_STATIC], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) +]) + +AC_DEFUN([AC_DISABLE_STATIC], +[_LT_SET_OPTION([LT_INIT], [disable-static]) +]) + +AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) +AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_ENABLE_STATIC], []) +dnl AC_DEFUN([AM_DISABLE_STATIC], []) + + + +# _LT_ENABLE_FAST_INSTALL([DEFAULT]) +# ---------------------------------- +# implement the --enable-fast-install flag, and support the `fast-install' +# and `disable-fast-install' LT_INIT options. +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +m4_define([_LT_ENABLE_FAST_INSTALL], +[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([fast-install], + [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], + [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) + +_LT_DECL([fast_install], [enable_fast_install], [0], + [Whether or not to optimize for fast installation])dnl +])# _LT_ENABLE_FAST_INSTALL + +LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) + +# Old names: +AU_DEFUN([AC_ENABLE_FAST_INSTALL], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you put +the `fast-install' option into LT_INIT's first parameter.]) +]) + +AU_DEFUN([AC_DISABLE_FAST_INSTALL], +[_LT_SET_OPTION([LT_INIT], [disable-fast-install]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you put +the `disable-fast-install' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) +dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) + + +# _LT_WITH_PIC([MODE]) +# -------------------- +# implement the --with-pic flag, and support the `pic-only' and `no-pic' +# LT_INIT options. +# MODE is either `yes' or `no'. If omitted, it defaults to `both'. +m4_define([_LT_WITH_PIC], +[AC_ARG_WITH([pic], + [AS_HELP_STRING([--with-pic], + [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], + [pic_mode="$withval"], + [pic_mode=default]) + +test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) + +_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl +])# _LT_WITH_PIC + +LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) +LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) + +# Old name: +AU_DEFUN([AC_LIBTOOL_PICMODE], +[_LT_SET_OPTION([LT_INIT], [pic-only]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the `pic-only' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) + +## ----------------- ## +## LTDL_INIT Options ## +## ----------------- ## + +m4_define([_LTDL_MODE], []) +LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], + [m4_define([_LTDL_MODE], [nonrecursive])]) +LT_OPTION_DEFINE([LTDL_INIT], [recursive], + [m4_define([_LTDL_MODE], [recursive])]) +LT_OPTION_DEFINE([LTDL_INIT], [subproject], + [m4_define([_LTDL_MODE], [subproject])]) + +m4_define([_LTDL_TYPE], []) +LT_OPTION_DEFINE([LTDL_INIT], [installable], + [m4_define([_LTDL_TYPE], [installable])]) +LT_OPTION_DEFINE([LTDL_INIT], [convenience], + [m4_define([_LTDL_TYPE], [convenience])]) diff --git a/m4/ltsugar.m4 b/m4/ltsugar.m4 new file mode 100644 index 0000000..9000a05 --- /dev/null +++ b/m4/ltsugar.m4 @@ -0,0 +1,123 @@ +# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- +# +# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. +# Written by Gary V. Vaughan, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 6 ltsugar.m4 + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) + + +# lt_join(SEP, ARG1, [ARG2...]) +# ----------------------------- +# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their +# associated separator. +# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier +# versions in m4sugar had bugs. +m4_define([lt_join], +[m4_if([$#], [1], [], + [$#], [2], [[$2]], + [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) +m4_define([_lt_join], +[m4_if([$#$2], [2], [], + [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) + + +# lt_car(LIST) +# lt_cdr(LIST) +# ------------ +# Manipulate m4 lists. +# These macros are necessary as long as will still need to support +# Autoconf-2.59 which quotes differently. +m4_define([lt_car], [[$1]]) +m4_define([lt_cdr], +[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], + [$#], 1, [], + [m4_dquote(m4_shift($@))])]) +m4_define([lt_unquote], $1) + + +# lt_append(MACRO-NAME, STRING, [SEPARATOR]) +# ------------------------------------------ +# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. +# Note that neither SEPARATOR nor STRING are expanded; they are appended +# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). +# No SEPARATOR is output if MACRO-NAME was previously undefined (different +# than defined and empty). +# +# This macro is needed until we can rely on Autoconf 2.62, since earlier +# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. +m4_define([lt_append], +[m4_define([$1], + m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) + + + +# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) +# ---------------------------------------------------------- +# Produce a SEP delimited list of all paired combinations of elements of +# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list +# has the form PREFIXmINFIXSUFFIXn. +# Needed until we can rely on m4_combine added in Autoconf 2.62. +m4_define([lt_combine], +[m4_if(m4_eval([$# > 3]), [1], + [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl +[[m4_foreach([_Lt_prefix], [$2], + [m4_foreach([_Lt_suffix], + ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, + [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) + + +# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) +# ----------------------------------------------------------------------- +# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited +# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. +m4_define([lt_if_append_uniq], +[m4_ifdef([$1], + [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], + [lt_append([$1], [$2], [$3])$4], + [$5])], + [lt_append([$1], [$2], [$3])$4])]) + + +# lt_dict_add(DICT, KEY, VALUE) +# ----------------------------- +m4_define([lt_dict_add], +[m4_define([$1($2)], [$3])]) + + +# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) +# -------------------------------------------- +m4_define([lt_dict_add_subkey], +[m4_define([$1($2:$3)], [$4])]) + + +# lt_dict_fetch(DICT, KEY, [SUBKEY]) +# ---------------------------------- +m4_define([lt_dict_fetch], +[m4_ifval([$3], + m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), + m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) + + +# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) +# ----------------------------------------------------------------- +m4_define([lt_if_dict_fetch], +[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], + [$5], + [$6])]) + + +# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) +# -------------------------------------------------------------- +m4_define([lt_dict_filter], +[m4_if([$5], [], [], + [lt_join(m4_quote(m4_default([$4], [[, ]])), + lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), + [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl +]) diff --git a/m4/ltversion.m4 b/m4/ltversion.m4 new file mode 100644 index 0000000..f3c5309 --- /dev/null +++ b/m4/ltversion.m4 @@ -0,0 +1,23 @@ +# ltversion.m4 -- version numbers -*- Autoconf -*- +# +# Copyright (C) 2004 Free Software Foundation, Inc. +# Written by Scott James Remnant, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# Generated from ltversion.in. + +# serial 3017 ltversion.m4 +# This file is part of GNU Libtool + +m4_define([LT_PACKAGE_VERSION], [2.2.6b]) +m4_define([LT_PACKAGE_REVISION], [1.3017]) + +AC_DEFUN([LTVERSION_VERSION], +[macro_version='2.2.6b' +macro_revision='1.3017' +_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) +_LT_DECL(, macro_revision, 0) +]) diff --git a/m4/lt~obsolete.m4 b/m4/lt~obsolete.m4 new file mode 100644 index 0000000..637bb20 --- /dev/null +++ b/m4/lt~obsolete.m4 @@ -0,0 +1,92 @@ +# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- +# +# Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. +# Written by Scott James Remnant, 2004. +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 4 lt~obsolete.m4 + +# These exist entirely to fool aclocal when bootstrapping libtool. +# +# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) +# which have later been changed to m4_define as they aren't part of the +# exported API, or moved to Autoconf or Automake where they belong. +# +# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN +# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us +# using a macro with the same name in our local m4/libtool.m4 it'll +# pull the old libtool.m4 in (it doesn't see our shiny new m4_define +# and doesn't know about Autoconf macros at all.) +# +# So we provide this file, which has a silly filename so it's always +# included after everything else. This provides aclocal with the +# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything +# because those macros already exist, or will be overwritten later. +# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. +# +# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. +# Yes, that means every name once taken will need to remain here until +# we give up compatibility with versions before 1.7, at which point +# we need to keep only those names which we still refer to. + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) + +m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) +m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) +m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) +m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) +m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) +m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) +m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) +m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) +m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) +m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) +m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) +m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) +m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) +m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) +m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) +m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) +m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) +m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) +m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) +m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) +m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) +m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) +m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) +m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) +m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) +m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) +m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) +m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) +m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) +m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) +m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) +m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) +m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) +m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) +m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) +m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) +m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) +m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) +m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) +m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) +m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) +m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) +m4_ifndef([AC_LIBTOOL_RC], [AC_DEFUN([AC_LIBTOOL_RC])]) +m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) +m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) +m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) +m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) +m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) +m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) +m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) +m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) diff --git a/scripts/Makefile.am b/scripts/Makefile.am new file mode 100644 index 0000000..4e297cc --- /dev/null +++ b/scripts/Makefile.am @@ -0,0 +1,4 @@ + +EXTRA_DIST = dlt2name.pl + +MAINTAINERCLEANFILES = Makefile.in diff --git a/scripts/Makefile.in b/scripts/Makefile.in new file mode 100644 index 0000000..77e9a5e --- /dev/null +++ b/scripts/Makefile.in @@ -0,0 +1,385 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = scripts +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/src/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +SOURCES = +DIST_SOURCES = +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOGEN = @AUTOGEN@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CUT = @CUT@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DMALLOC_LIB = @DMALLOC_LIB@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +GROFF = @GROFF@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LDNETINC = @LDNETINC@ +LDNETLIB = @LDNETLIB@ +LIBOBJS = @LIBOBJS@ +LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@ +LIBOPTS_DIR = @LIBOPTS_DIR@ +LIBOPTS_LDADD = @LIBOPTS_LDADD@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LNAVLIB = @LNAVLIB@ +LNAV_CFLAGS = @LNAV_CFLAGS@ +LN_S = @LN_S@ +LPCAPINC = @LPCAPINC@ +LPCAPLIB = @LPCAPLIB@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@ +PRINTF = @PRINTF@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TCPREPLAY_RELEASE = @TCPREPLAY_RELEASE@ +TCPREPLAY_VERSION = @TCPREPLAY_VERSION@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +debug_flag = @debug_flag@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +nic1 = @nic1@ +nic2 = @nic2@ +oldincludedir = @oldincludedir@ +pcncfg = @pcncfg@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +tcpdump_path = @tcpdump_path@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +EXTRA_DIST = dlt2name.pl +MAINTAINERCLEANFILES = Makefile.in +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu scripts/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu scripts/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *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);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + distclean distclean-generic distclean-libtool 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-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/scripts/dlt2name.pl b/scripts/dlt2name.pl new file mode 100644 index 0000000..f10dbbc --- /dev/null +++ b/scripts/dlt2name.pl @@ -0,0 +1,186 @@ +#!/usr/bin/perl -w + +# Parses the bpf.h header file to generate the dlt_names.h header +# which maps the DLT types to the DLT string name + +# run from the tcpreplay source base directory as: +# cat /usr/include/pcap-bpf.h | ./scripts/dlt2name.pl + +use strict; +my $out_c = 'src/common/dlt_names.c'; +my $out_h = 'src/common/dlt_names.h'; + +# open outfile +open(OUT_C, ">$out_c") or die("Unable to open $out_c for writing: $!"); +open(OUT_H, ">$out_h") or die("Unable to open $out_h for writing: $!"); + +# read STDIN + +# some DLT types aren't in a format we can parse easily or just doesn't +# exist in my /usr/include/net/bpf.h file so we list them here +my %known = (107 => 'BSD/OS Frame Relay', + 108 => 'OpenBSD Loopback', + 113 => 'Linux Cooked Sockets', + 114 => 'Apple LocalTalk', + 115 => 'Acorn Econet', + 116 => 'OpenBSD IPFilter', + 117 => 'OpenBSD PF Log/SuSE 6.3 LANE 802.3', + 118 => 'Cisco IOS', + 119 => '802.11 Prism Header', + 120 => '802.11 Aironet Header', + 121 => 'Siemens HiPath HDLC', + 122 => 'IP over Fibre Channel' + ); +my @names; + +# put our known DLT types in names since the format of bpf.h is +# inconsistent + +foreach my $dlt (keys %known) { + $names[$dlt]{name} = $known{$dlt}; +} + +while (my $line = ) { + + if ($line =~ /^\#define\s+(DLT_[a-zA-Z0-9_]+)\s+(\d+)/) { + my $key = $1; + my $dlt = $2; + my $name = $names[$dlt]{name} ? $names[$dlt]{name} : ""; + if ($line =~ /\/\*\s+(.*)\s+\*\//) { + $name = $1; + } + $names[$dlt]{key} = $key; + $names[$dlt]{name} = $name; + } + +} + +# print the license info +while (my $line = ) { + print OUT_C $line; + print OUT_H $line; +} + +# prep the header +print OUT_C < + +/* DLT to descriptions */ +char *dlt2desc[] = { +HEADER + +for (my $i = 0; $i < $#names; $i ++) { + if (! defined $names[$i]) { + print OUT_C "\t\t\"Unknown\",\n"; + } else { + print OUT_C "\t\t\"$names[$i]->{name}\",\n"; + } +} + +print OUT_C < +#include +#include +#include "MESA_list.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +/*************************** ڲʵֽӿ ********************************/ + +/* + * Simple doubly linked list implementation. + * + * Some of the internal functions ("__xxx") are useful when + * manipulating whole lists rather than single entries, as + * sometimes we already know the next/prev entries and we can + * generate better code by using them directly rather than + * using the generic single-entry routines. + */ + +static void INIT_LIST_HEAD(struct list_index *head) +{ + head->nextele = head; + head->preele = head; +} + + +/* + * Insert a new entry between two known consecutive entries. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ +static inline void __list_add(struct list_index *new_list, + struct list_index *prev, + struct list_index *next) +{ + next->preele = new_list; + new_list->nextele = next; + new_list->preele = prev; + prev->nextele = new_list; +} + +/** + * list_add - add a new entry + * @new: new entry to be added + * @head: list head to add it after + * + * Insert a new entry after the specified head. + * This is good for implementing stacks. + * lijia comment: list_add()½ڵheadhead->next֮. + */ +void list_add(struct list_index *new_list, struct list_index *head) +{ + __list_add(new_list, head, head->nextele); +} + + +/** + * list_add_tail - add a new entry + * @new: new entry to be added + * @head: list head to add it before + * + * Insert a new entry before the specified head. + * This is useful for implementing queues. + * lijia comment: list_add_tail()½ڵheadhead->prev֮. + */ +void list_add_tail(struct list_index *new_list, struct list_index *head) +{ + __list_add(new_list, head->preele, head); +} + +/* + * Delete a list entry by making the prev/next entries + * point to each other. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ +static inline void __list_del(struct list_index * prev, struct list_index * next) +{ + next->preele = prev; + prev->nextele = next; +} + +static inline void __list_del_entry(struct list_index *entry) +{ + __list_del(entry->preele, entry->nextele); + entry->nextele = NULL; + entry->preele = NULL; +} + +/** + * list_del - deletes entry from list. + * @entry: the element to delete from the list. + * Note: list_empty() on entry does not return true after this, the entry is + * in an undefined state. + */ + +static void list_del(struct list_index *entry) +{ + __list_del(entry->preele, entry->nextele); + entry->nextele = NULL; + entry->preele = NULL; +} + + +/** + * list_move - delete from one list and add as another's head + * @list: the entry to move + * @head: the head that will precede our entry + */ +static void list_move(struct list_index *list, struct list_index *head) +{ + __list_del_entry(list); + list_add(list, head); +} + +/** + * list_move_tail - delete from one list and add as another's tail + * @list: the entry to move + * @head: the head that will follow our entry + */ +static void list_move_tail(struct list_index *list, struct list_index *head) +{ + __list_del_entry(list); + list_add_tail(list, head); +} + +#if 0 +/** + * list_empty - tests whether a list is empty + * @head: the list to test. + */ +static int list_empty(const struct list_index *head) +{ + return head->nextele == head; +} +#endif + +/** + * list_empty_careful - tests whether a list is empty and not being modified + * @head: the list to test + * + * Description: + * tests whether a list is empty _and_ checks that no other CPU might be + * in the process of modifying either member (next or prev) + * + * NOTE: using list_empty_careful() without synchronization + * can only be safe if the only activity that can happen + * to the list entry is list_del_init(). Eg. it cannot be used + * if another CPU could re-list_add() it. + */ +static int list_empty_careful(const struct list_index *head) +{ + MESA_queue_head_t *next = head->nextele; + return (next == head) && (next == head->preele); +} + +static inline void list_count_init(void **list_count) +{ + long *p_c = (long *)list_count; + *p_c = 0; +} + +static inline void list_count_inc(void **list_count) +{ + long *p_c = (long *)list_count; + long c = *p_c; + *p_c = c + 1; +} + +static inline void list_count_dec(void **list_count) +{ + long *p_c = (long *)list_count; + long c = *p_c; + *p_c = c - 1; +} + +#if MESA_LIST_CHECK != 0 +/*Function:Check the intergrity of the list,to dectect memory mess. +*Input: Queue Head,data check call back function +*Output: return a number below zero,if the queue got a problem,else return 0; +*Author:zhengchao@iie.ac.cn at 20100913 +*/ +#if 0 +static int MESA_q_list_check(const MESA_queue_head_t *qhead_obj,int(*quiddity_check)(const void *)) +{ + MESA_list_index_t *p=NULL, *head=NULL; +// int linked_ele_number=0; + int ret=0; +// return 0; + if(qhead_obj->listcount==0) + { + if(qhead_obj->head!=NULL||qhead_obj->head!=NULL) + { + ret=-1; + } + goto exit; + } + + if(qhead_obj->head==NULL||qhead_obj->tail==NULL) + { + ret=-2; + goto exit; + } + if(qhead_obj->listcount>1){ + if(qhead_obj->head->preele!=NULL||qhead_obj->head->nextele==NULL) + { + ret=-3; + goto exit; + } + if(qhead_obj->tail->preele==NULL||qhead_obj->tail->nextele!=NULL) + { + ret=-4; + goto exit; + } + + head = p = qhead_obj->head; + p = p->nextele; + while(p != head) + { + if(p == NULL) break; + if(p == head){ + ret = -5; /* has a cycle */ + goto exit; + } + p = p->nextele; + } + } + /* + pre=qhead_obj->head; + p=pre->nextele; + while(p!=NULL){ + linked_ele_number++; + + //Is the declared size equal to element linked number; + if(linked_ele_number > qhead_obj->listcount) + { + ret=-5; + goto exit; + } + + //Is element's preele pointer equal to its preele + if(pre!=p->preele) + { + ret=-6; + goto exit; + } + if(quiddity_check!=NULL){ + if(0>quiddity_check(p->quiddity)) + { + ret =-7; + goto exit; + } + } + pre=p; + p=p->nextele; + } + //Is the last element equal to tail + if(pre!=qhead_obj->tail) + { + ret=-8; + goto exit; + } + if(linked_ele_number !=qhead_obj->listcount-1) + { + ret=-9; + goto exit; + } + */ +exit: + if(ret<0) + { + return ret; + } + else + { + return 1; + } + +} +#endif + +#if 2==MESA_LIST_CHECK +/*Simple check,not raversal*/ +static int MESA_q_is_item_in_list(MESA_queue_head_t *qhead_obj, MESA_list_index_t *lindex_obj){ +// MESA_list_index_t* pre=lindex_obj->preele; +// MESA_list_index_t*next=lindex_obj->nextele; + MESA_list_index_t*p=NULL; + int i, num; + + if(list_empty_careful(qhead_obj)){ + return 0; + } + + p = qhead_obj->nextele; + num = MESA_get_list_count(qhead_obj); + i = 0; + while((p != qhead_obj) && (i <= num)) + { + if(p == lindex_obj) + { + return 1; + } + p=p->nextele; + i++; + } + + return 0; + +} +#endif + +/*every MESA_list_index_t leaves list,its pre and next will be set NULL + * In Configuration Transmiiter project, not null element will consider in list, + * pre and next is NULL only if there's one element in list only*/ +static int MESA_q_is_item_in_list_quick(MESA_queue_head_t *qhead_obj, MESA_list_index_t *lindex_obj) +{ + //empty list + if(list_empty_careful(qhead_obj)){ + return 0; + } + + //have more element + if(lindex_obj->nextele==NULL || lindex_obj->preele==NULL){ + return 0; + } + if(lindex_obj->nextele->preele != lindex_obj){ + return 0; + } + if(lindex_obj->preele->nextele != lindex_obj){ + return 0; + } + + return 1; + +} +#endif + +/*************************** ⲿýӿ ********************************/ + + +/* + һʹMESA_listģʱô˳ʼģ. +*/ +int MESA_list_init(MESA_queue_head_t *head) +{ + INIT_LIST_HEAD(head); + list_count_init(&head->quiddity); + return 0; +} + +/* Ϊheadʹʱ, "quiddity"Ϊһlongͱ,ڴ洢Ԫ */ +long MESA_get_list_count(const MESA_queue_head_t *head) +{ + return (long)head->quiddity; +} + +MESA_list_index_t *MESA_q_read_head(const MESA_queue_head_t *qhead_obj) +{ + if(list_empty_careful(qhead_obj)){ + return NULL; + } + return qhead_obj->nextele; +} + + +MESA_list_index_t *MESA_q_get_head(MESA_queue_head_t *qhead_obj) +{ + MESA_list_index_t *out; + if(list_empty_careful(qhead_obj)){ + return NULL; + } + out = qhead_obj->nextele; + list_del(out); + list_count_dec(&qhead_obj->quiddity); + + return out; +} + +MESA_list_index_t *MESA_q_get_tail(MESA_queue_head_t *qhead_obj) +{ + MESA_list_index_t *out; + if(list_empty_careful(qhead_obj)){ + return NULL; + } + out = qhead_obj->preele; + list_del(out); + list_count_dec(&qhead_obj->quiddity); + + return out; +} + +MESA_list_index_t *MESA_q_join_tail(MESA_queue_head_t *qhead_obj, MESA_list_index_t *lindex_obj) +{ + list_add_tail(lindex_obj, qhead_obj); + list_count_inc(&qhead_obj->quiddity); + + return lindex_obj; +} + +MESA_list_index_t *MESA_q_join_head(MESA_queue_head_t *qhead_obj, MESA_list_index_t *lindex_obj) +{ + list_add(lindex_obj, qhead_obj); + list_count_inc(&qhead_obj->quiddity); + + return lindex_obj; +} + +MESA_list_index_t *MESA_q_leave_list(MESA_queue_head_t *qhead_obj, MESA_list_index_t *lindex_obj) +{ +#if 1==MESA_LIST_CHECK + if(0 == MESA_q_is_item_in_list_quick(qhead_obj, lindex_obj)){ + //return NULL; + assert(0); //critical + } +#elif 2==MESA_LIST_CHECK + if(0 == MESA_q_is_item_in_list(qhead_obj, lindex_obj)){ + //return NULL; + assert(0); //critical + } +#endif + list_del(lindex_obj); + list_count_dec(&qhead_obj->quiddity); + + return lindex_obj; +} + +MESA_list_index_t *MESA_q_move_head(MESA_queue_head_t *qhead_obj, MESA_list_index_t *lindex_obj) +{ +#if 1==MESA_LIST_CHECK + if(0 == MESA_q_is_item_in_list_quick(qhead_obj, lindex_obj)){ + //return NULL; + assert(0); //critical + } +#elif 2==MESA_LIST_CHECK + if(0 == MESA_q_is_item_in_list(qhead_obj, lindex_obj)){ + //return NULL; + assert(0); //critical + } +#endif + list_move(lindex_obj, qhead_obj); + + return lindex_obj; +} + +MESA_list_index_t *MESA_q_move_tail(MESA_queue_head_t *qhead_obj, MESA_list_index_t *lindex_obj) +{ +#if 1==MESA_LIST_CHECK + if(0 == MESA_q_is_item_in_list_quick(qhead_obj,lindex_obj)){ + //return NULL; + assert(0); //critical + } +#elif 2==MESA_LIST_CHECK + if(0 == MESA_q_is_item_in_list(qhead_obj, lindex_obj)){ + //return NULL; + assert(0); //critical + } +#endif + list_move_tail(lindex_obj, qhead_obj); + + return lindex_obj; +} + +#ifdef __cplusplus +} +#endif + + diff --git a/src/MESA_list.h b/src/MESA_list.h new file mode 100644 index 0000000..524fc61 --- /dev/null +++ b/src/MESA_list.h @@ -0,0 +1,68 @@ +#ifndef _MESA_LIST_NEW_H_ +#define _MESA_LIST_NEW_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif + +#define MESA_LIST_CHECK (1) /* 0:no check; 1:quick check; 2:careful check */ + +typedef struct list_index { + struct list_index *nextele; + struct list_index *preele; + unsigned char *quiddity; + int pktlen; +}MESA_list_index_t; + +typedef struct list_index MESA_queue_head_t; + +/* MESA_fixed_queue implement */ + +typedef struct fixed_qelem{ + void *data; + long datalen; +}MESA_fixed_qelem_t; + +typedef struct list_index MESA_fixed_q_t; +/* + һʹMESA_fixed_qģʱô˳ʼģ!!! +*/ +int MESA_fixed_q_init(MESA_fixed_q_t *head, long total_elem_num, long max_elem_len); +void MESA_fixed_q_destroy(MESA_fixed_q_t *__head); +long MESA_fixed_q_count(const MESA_fixed_q_t *head); +MESA_fixed_qelem_t *MESA_fixed_q_read_head(MESA_fixed_q_t *head); +MESA_fixed_qelem_t *MESA_fixed_q_get_head(MESA_fixed_q_t *head); + +/* In MESA_fixed_queue module, the memory of "data" can not be allocated by malloc, stack memory is alright! */ +MESA_fixed_qelem_t *MESA_fixed_q_join_tail(MESA_fixed_q_t *head, void *data, long datalen); + + +/* + һʹMESA_listģʱô˳ʼģ!!! +*/ +int MESA_list_init(MESA_queue_head_t *head); + +long MESA_get_list_count(const MESA_queue_head_t *head); +MESA_list_index_t *MESA_q_read_head(const MESA_queue_head_t *qhead_obj); +MESA_list_index_t *MESA_q_get_head(MESA_queue_head_t *qhead_obj); +MESA_list_index_t *MESA_q_get_tail(MESA_queue_head_t *qhead_obj); +MESA_list_index_t *MESA_q_join_tail(MESA_queue_head_t *qhead_obj, MESA_list_index_t *lindex_obj); +MESA_list_index_t *MESA_q_join_head(MESA_queue_head_t *qhead_obj, MESA_list_index_t *lindex_obj); +MESA_list_index_t *MESA_q_leave_list(MESA_queue_head_t *qhead_obj, MESA_list_index_t *lindex_obj); +MESA_list_index_t *MESA_q_move_head(MESA_queue_head_t *qhead_obj, MESA_list_index_t *lindex_obj); +MESA_list_index_t *MESA_q_move_tail(MESA_queue_head_t *qhead_obj, MESA_list_index_t *lindex_obj); + +#if 0 /* do do, δʵ */ +MESA_list_index_t *MESA_q_join_list_n(MESA_queue_head_t *qhead_obj, MESA_list_index_t *lobj_next, MESA_list_index_t *lindex_obj); +MESA_list_index_t *MESA_q_join_list_p(MESA_queue_head_t *qhead_obj, MESA_list_index_t *lobj_pre, MESA_list_index_t *lindex_obj); +#endif + + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..163e4b6 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,122 @@ +# $Id: Makefile.am 1632 2007-02-03 18:46:16Z aturner $ +if COMPILE_FRAGROUTE + LIBFRAGROUTE = ./fragroute/libfragroute.a @LDNETLIB@ + FRAGROUTE_DIR = fragroute +else + LIBFRAGROUTE = + FRAGROUTE_DIR = +endif + +SUBDIRS = common tcpedit $(FRAGROUTE_DIR) + +if SYSTEM_STRLCPY +LIBSTRL = +else +LIBSTRL = ../lib/libstrl.a +endif + +manpages: tcpprep.1 tcprewrite.1 tcpreplay.1 tcpbridge.1 tcpreplay-edit.1 + +autoopts: tcpreplay_opts.c tcprewrite_opts.c tcpbridge_opts.c manpages \ + tcpreplay_edit_opts.c + + +# Get AutoOpts search path +opts_list=-L tcpedit + +tcpprep.1: tcpprep_opts.def + @AUTOGEN@ -T agman1.tpl $(opts_list) --base-name tcpprep tcpprep_opts.def + +tcprewrite.1: tcprewrite_opts.def tcpedit/tcpedit_opts.def + @AUTOGEN@ -T agman1.tpl $(opts_list) --base-name tcprewrite tcprewrite_opts.def + +tcpreplay-edit.1: tcpreplay_opts.def + @AUTOGEN@ -T agman1.tpl $(opts_list) -DTCPREPLAY_EDIT --base-name tcpreplay-edit tcpreplay_opts.def + +tcpreplay.1: tcpreplay_opts.def + @AUTOGEN@ -T agman1.tpl $(opts_list) --base-name tcpreplay tcpreplay_opts.def + +tcpbridge.1: tcpbridge_opts.def tcpedit/tcpedit_opts.def + @AUTOGEN@ -T agman1.tpl $(opts_list) --base-name tcpbridge tcpbridge_opts.def + +man_MANS = tcpreplay.1 tcpprep.1 tcprewrite.1 tcpreplay-edit.1 +EXTRA_DIST = tcpreplay.1 tcpprep.1 tcprewrite.1 tcpbridge.1 tcpreplay-edit.1 +bin_PROGRAMS = tcpreplay tcpprep tcprewrite tcpreplay-edit + +if COMPILE_TCPBRIDGE +bin_PROGRAMS += tcpbridge +man_MANS += tcpbridge.1 +endif + +tcpreplay_edit_CFLAGS = $(LIBOPTS_CFLAGS) -I.. $(LNAV_CFLAGS) @LDNETINC@ -DTCPREPLAY -DTCPREPLAY_EDIT -DHAVE_CACHEFILE_SUPPORT +tcpreplay_edit_LDADD = ./tcpedit/libtcpedit.a ./common/libcommon.a ./suppport_lib/libMESA_prof_load.a $(LIBSTRL) @LPCAPLIB@ @LDNETLIB@ $(LIBOPTS_LDADD) +tcpreplay_edit_SOURCES = tcpreplay_edit_opts.c send_packets.c signal_handler.c tcpreplay.c sleep.c +tcpreplay_edit_OBJECTS: tcpreplay_opts.h +tcpreplay_edit_opts.h: tcpreplay_edit_opts.c + +tcpreplay_edit_opts.c: tcpreplay_opts.def + @AUTOGEN@ $(opts_list) -DTCPREPLAY_EDIT -b tcpreplay_edit_opts \ + tcpreplay_opts.def + +tcpreplay_CFLAGS = $(LIBOPTS_CFLAGS) -I.. $(LNAV_CFLAGS) @LDNETINC@ -DTCPREPLAY +tcpreplay_SOURCES = tcpreplay_opts.c send_packets.c signal_handler.c tcpreplay.c sleep.c +tcpreplay_LDADD = ./common/libcommon.a ./suppport_lib/libMESA_prof_load.a $(LIBSTRL) @LPCAPLIB@ @LDNETLIB@ $(LIBOPTS_LDADD) +tcpreplay_OBJECTS: tcpreplay_opts.h +tcpreplay_opts.h: tcpreplay_opts.c + +tcpreplay_opts.c: tcpreplay_opts.def + @AUTOGEN@ $(opts_list) tcpreplay_opts.def + +if ENABLE_OSX_FRAMEWORKS +tcpreplay_LDFLAGS = -framework CoreServices -framework Carbon +tcpreplay_edit_LDFLAGS = -framework CoreServices -framework Carbon +endif + + +tcprewrite_CFLAGS = $(LIBOPTS_CFLAGS) -I.. @LDNETINC@ $(LNAV_CFLAGS) -DTCPREWRITE -DHAVE_CACHEFILE_SUPPORT +tcprewrite_LDADD = ./tcpedit/libtcpedit.a ./common/libcommon.a ./suppport_lib/libMESA_prof_load.a \ + $(LIBSTRL) @LPCAPLIB@ $(LIBOPTS_LDADD) @DMALLOC_LIB@ \ + $(LIBFRAGROUTE) +tcprewrite_SOURCES = tcprewrite_opts.c tcprewrite.c +tcprewrite_OBJECTS: tcprewrite_opts.h +tcprewrite_opts.h: tcprewrite_opts.c +tcprewrite_opts.c: tcprewrite_opts.def tcpedit/tcpedit_opts.def + @AUTOGEN@ $(opts_list) tcprewrite_opts.def + + +tcpprep_CFLAGS = $(LIBOPTS_CFLAGS) -I.. $(LNAV_CFLAGS) @LDNETINC@ -DTCPPREP +tcpprep_LDADD = ./common/libcommon.a suppport_lib/libMESA_prof_load.a \ + $(LIBSTRL) @LPCAPLIB@ $(LIBOPTS_LDADD) @DMALLOC_LIB@ +tcpprep_SOURCES = tcpprep_opts.c tcpprep.c tree.c +tcpprep_OBJECTS: tcpprep_opts.h +tcpprep_opts.h: tcpprep_opts.c +tcpprep_opts.c: tcpprep_opts.def + @AUTOGEN@ tcpprep_opts.def + +tcpbridge_CFLAGS = $(LIBOPTS_CFLAGS) -I.. $(LNAV_CFLAGS) @LDNETINC@ -DTCPBRIDGE +tcpbridge_LDADD = ./tcpedit/libtcpedit.a ./common/libcommon.a suppport_lib/libMESA_prof_load.a \ + $(LIBSTRL) @LPCAPLIB@ @LDNETLIB@ $(LIBOPTS_LDADD) @DMALLOC_LIB@ +if ENABLE_OSX_FRAMEWORKS +tcpbridge_LDFLAGS = -framework CoreServices -framework Carbon +endif +tcpbridge_SOURCES = tcpbridge_opts.c tcpbridge.c bridge.c send_packets.c sleep.c +tcpbridge_OBJECTS: tcpbridge_opts.h +tcpbridge_opts.h: tcpbridge_opts.c +tcpbridge_opts.c: tcpbridge_opts.def tcpedit/tcpedit_opts.def + @AUTOGEN@ $(opts_list) tcpbridge_opts.def + +noinst_HEADERS = tcpreplay.h tcpprep.h bridge.h defines.h tree.h \ + send_packets.h signal_handler.h common.h tcpreplay_opts.h \ + tcpreplay_edit_opts.h tcprewrite.h tcprewrite_opts.h tcpprep_opts.h \ + tcpprep_opts.def tcprewrite_opts.def tcpreplay_opts.def \ + tcpbridge_opts.def tcpbridge.h tcpbridge_opts.h tcpr.h sleep.h + + +MOSTLYCLEANFILES = *~ *.o + +MAINTAINERCLEANFILES = Makefile.in tcpreplay_opts.h tcpreplay_opts.c \ + tcprewrite_opts.c tcprewrite_opts.h tcpprep_opts.c \ + tcpprep_opts.h tcpprep.1 tcpreplay.1 tcprewrite.1 \ + tcpbridge.1 tcpbridge_opts.h tcpbridge_opts.c \ + tcpreplay_edit_opts.c tcpreplay_edit_opts.h \ + tcpreplay-edit.1 diff --git a/src/Makefile.in b/src/Makefile.in new file mode 100644 index 0000000..d1afe20 --- /dev/null +++ b/src/Makefile.in @@ -0,0 +1,1258 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +bin_PROGRAMS = tcpreplay$(EXEEXT) tcpprep$(EXEEXT) tcprewrite$(EXEEXT) \ + tcpreplay-edit$(EXEEXT) $(am__EXEEXT_1) +@COMPILE_TCPBRIDGE_TRUE@am__append_1 = tcpbridge +@COMPILE_TCPBRIDGE_TRUE@am__append_2 = tcpbridge.1 +subdir = src +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(srcdir)/config.h.in \ + $(srcdir)/defines.h.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = defines.h +CONFIG_CLEAN_VPATH_FILES = +@COMPILE_TCPBRIDGE_TRUE@am__EXEEXT_1 = tcpbridge$(EXEEXT) +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" +PROGRAMS = $(bin_PROGRAMS) +am_tcpbridge_OBJECTS = tcpbridge-tcpbridge_opts.$(OBJEXT) \ + tcpbridge-tcpbridge.$(OBJEXT) tcpbridge-bridge.$(OBJEXT) \ + tcpbridge-send_packets.$(OBJEXT) tcpbridge-sleep.$(OBJEXT) +tcpbridge_OBJECTS = $(am_tcpbridge_OBJECTS) +@SYSTEM_STRLCPY_FALSE@am__DEPENDENCIES_1 = ../lib/libstrl.a +am__DEPENDENCIES_2 = +tcpbridge_DEPENDENCIES = ./tcpedit/libtcpedit.a ./common/libcommon.a ./suppport_lib/libMESA_prof_load.a\ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) +tcpbridge_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(tcpbridge_CFLAGS) \ + $(CFLAGS) $(tcpbridge_LDFLAGS) $(LDFLAGS) -o $@ +am_tcpprep_OBJECTS = tcpprep-tcpprep_opts.$(OBJEXT) \ + tcpprep-tcpprep.$(OBJEXT) tcpprep-tree.$(OBJEXT) +tcpprep_OBJECTS = $(am_tcpprep_OBJECTS) +tcpprep_DEPENDENCIES = ./common/libcommon.a $(am__DEPENDENCIES_1) ./suppport_lib/libMESA_prof_load.a \ + $(am__DEPENDENCIES_2) +tcpprep_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(tcpprep_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +am_tcpreplay_OBJECTS = tcpreplay-tcpreplay_opts.$(OBJEXT) \ + tcpreplay-send_packets.$(OBJEXT) \ + tcpreplay-signal_handler.$(OBJEXT) \ + tcpreplay-tcpreplay.$(OBJEXT) tcpreplay-sleep.$(OBJEXT) +tcpreplay_OBJECTS = $(am_tcpreplay_OBJECTS) +tcpreplay_DEPENDENCIES = ./common/libcommon.a $(am__DEPENDENCIES_1) ./suppport_lib/libMESA_prof_load.a\ + $(am__DEPENDENCIES_2) +tcpreplay_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(tcpreplay_CFLAGS) \ + $(CFLAGS) $(tcpreplay_LDFLAGS) $(LDFLAGS) -o $@ +am_tcpreplay_edit_OBJECTS = \ + tcpreplay_edit-tcpreplay_edit_opts.$(OBJEXT) \ + tcpreplay_edit-send_packets.$(OBJEXT) \ + tcpreplay_edit-signal_handler.$(OBJEXT) \ + tcpreplay_edit-tcpreplay.$(OBJEXT) \ + tcpreplay_edit-sleep.$(OBJEXT) +tcpreplay_edit_OBJECTS = $(am_tcpreplay_edit_OBJECTS) +tcpreplay_edit_DEPENDENCIES = ./tcpedit/libtcpedit.a \ + ./common/libcommon.a $(am__DEPENDENCIES_1) ./suppport_lib/libMESA_prof_load.a\ + $(am__DEPENDENCIES_2) +tcpreplay_edit_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(tcpreplay_edit_CFLAGS) \ + $(CFLAGS) $(tcpreplay_edit_LDFLAGS) $(LDFLAGS) -o $@ +am_tcprewrite_OBJECTS = tcprewrite-tcprewrite_opts.$(OBJEXT) \ + tcprewrite-tcprewrite.$(OBJEXT) +tcprewrite_OBJECTS = $(am_tcprewrite_OBJECTS) +@COMPILE_FRAGROUTE_TRUE@am__DEPENDENCIES_3 = \ +@COMPILE_FRAGROUTE_TRUE@ ./fragroute/libfragroute.a +tcprewrite_DEPENDENCIES = ./tcpedit/libtcpedit.a ./common/libcommon.a ./suppport_lib/libMESA_prof_load.a\ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_3) +tcprewrite_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(tcprewrite_CFLAGS) \ + $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ +depcomp = $(SHELL) $(top_srcdir)/config/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(tcpbridge_SOURCES) $(tcpprep_SOURCES) $(tcpreplay_SOURCES) \ + $(tcpreplay_edit_SOURCES) $(tcprewrite_SOURCES) +DIST_SOURCES = $(tcpbridge_SOURCES) $(tcpprep_SOURCES) \ + $(tcpreplay_SOURCES) $(tcpreplay_edit_SOURCES) \ + $(tcprewrite_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +man1dir = $(mandir)/man1 +NROFF = nroff +MANS = $(man_MANS) +HEADERS = $(noinst_HEADERS) +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ + $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ + distdir +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = common tcpedit fragroute +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +am__relativize = \ + dir0=`pwd`; \ + sed_first='s,^\([^/]*\)/.*$$,\1,'; \ + sed_rest='s,^[^/]*/*,,'; \ + sed_last='s,^.*/\([^/]*\)$$,\1,'; \ + sed_butlast='s,/*[^/]*$$,,'; \ + while test -n "$$dir1"; do \ + first=`echo "$$dir1" | sed -e "$$sed_first"`; \ + if test "$$first" != "."; then \ + if test "$$first" = ".."; then \ + dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ + dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ + else \ + first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ + if test "$$first2" = "$$first"; then \ + dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ + else \ + dir2="../$$dir2"; \ + fi; \ + dir0="$$dir0"/"$$first"; \ + fi; \ + fi; \ + dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ + done; \ + reldir="$$dir2" +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOGEN = @AUTOGEN@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CUT = @CUT@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DMALLOC_LIB = @DMALLOC_LIB@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +GROFF = @GROFF@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LDNETINC = @LDNETINC@ +LDNETLIB = @LDNETLIB@ +LIBOBJS = @LIBOBJS@ +LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@ +LIBOPTS_DIR = @LIBOPTS_DIR@ +LIBOPTS_LDADD = @LIBOPTS_LDADD@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LNAVLIB = @LNAVLIB@ +LNAV_CFLAGS = @LNAV_CFLAGS@ +LN_S = @LN_S@ +LPCAPINC = @LPCAPINC@ +LPCAPLIB = @LPCAPLIB@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@ +PRINTF = @PRINTF@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TCPREPLAY_RELEASE = @TCPREPLAY_RELEASE@ +TCPREPLAY_VERSION = @TCPREPLAY_VERSION@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +debug_flag = @debug_flag@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +nic1 = @nic1@ +nic2 = @nic2@ +oldincludedir = @oldincludedir@ +pcncfg = @pcncfg@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +tcpdump_path = @tcpdump_path@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +@COMPILE_FRAGROUTE_FALSE@LIBFRAGROUTE = + +# $Id: Makefile.am 1632 2007-02-03 18:46:16Z aturner $ +@COMPILE_FRAGROUTE_TRUE@LIBFRAGROUTE = ./fragroute/libfragroute.a @LDNETLIB@ +@COMPILE_FRAGROUTE_FALSE@FRAGROUTE_DIR = +@COMPILE_FRAGROUTE_TRUE@FRAGROUTE_DIR = fragroute +SUBDIRS = common tcpedit $(FRAGROUTE_DIR) +@SYSTEM_STRLCPY_FALSE@LIBSTRL = ../lib/libstrl.a +@SYSTEM_STRLCPY_TRUE@LIBSTRL = + +# Get AutoOpts search path +opts_list = -L tcpedit +man_MANS = tcpreplay.1 tcpprep.1 tcprewrite.1 tcpreplay-edit.1 \ + $(am__append_2) +EXTRA_DIST = tcpreplay.1 tcpprep.1 tcprewrite.1 tcpbridge.1 tcpreplay-edit.1 +tcpreplay_edit_CFLAGS = $(LIBOPTS_CFLAGS) -I.. $(LNAV_CFLAGS) @LDNETINC@ -DTCPREPLAY -DTCPREPLAY_EDIT -DHAVE_CACHEFILE_SUPPORT +tcpreplay_edit_LDADD = ./tcpedit/libtcpedit.a ./common/libcommon.a ./suppport_lib/libMESA_prof_load.a $(LIBSTRL) @LPCAPLIB@ @LDNETLIB@ $(LIBOPTS_LDADD) +tcpreplay_edit_SOURCES = tcpreplay_edit_opts.c send_packets.c signal_handler.c tcpreplay.c sleep.c +tcpreplay_CFLAGS = $(LIBOPTS_CFLAGS) -I.. $(LNAV_CFLAGS) @LDNETINC@ -DTCPREPLAY +tcpreplay_SOURCES = tcpreplay_opts.c send_packets.c signal_handler.c tcpreplay.c sleep.c +tcpreplay_LDADD = ./common/libcommon.a $(LIBSTRL) ./suppport_lib/libMESA_prof_load.a @LPCAPLIB@ @LDNETLIB@ $(LIBOPTS_LDADD) +@ENABLE_OSX_FRAMEWORKS_TRUE@tcpreplay_LDFLAGS = -framework CoreServices -framework Carbon +@ENABLE_OSX_FRAMEWORKS_TRUE@tcpreplay_edit_LDFLAGS = -framework CoreServices -framework Carbon +tcprewrite_CFLAGS = $(LIBOPTS_CFLAGS) -I.. @LDNETINC@ $(LNAV_CFLAGS) -DTCPREWRITE -DHAVE_CACHEFILE_SUPPORT +tcprewrite_LDADD = ./tcpedit/libtcpedit.a ./common/libcommon.a ./suppport_lib/libMESA_prof_load.a \ + $(LIBSTRL) @LPCAPLIB@ $(LIBOPTS_LDADD) @DMALLOC_LIB@ \ + $(LIBFRAGROUTE) + +tcprewrite_SOURCES = tcprewrite_opts.c tcprewrite.c +tcpprep_CFLAGS = $(LIBOPTS_CFLAGS) -I.. $(LNAV_CFLAGS) @LDNETINC@ -DTCPPREP +tcpprep_LDADD = ./common/libcommon.a ./suppport_lib/libMESA_prof_load.a \ + $(LIBSTRL) @LPCAPLIB@ $(LIBOPTS_LDADD) @DMALLOC_LIB@ + +tcpprep_SOURCES = tcpprep_opts.c tcpprep.c tree.c +tcpbridge_CFLAGS = $(LIBOPTS_CFLAGS) -I.. $(LNAV_CFLAGS) @LDNETINC@ -DTCPBRIDGE +tcpbridge_LDADD = ./tcpedit/libtcpedit.a ./common/libcommon.a ./suppport_lib/libMESA_prof_load.a\ + $(LIBSTRL) @LPCAPLIB@ @LDNETLIB@ $(LIBOPTS_LDADD) @DMALLOC_LIB@ + +@ENABLE_OSX_FRAMEWORKS_TRUE@tcpbridge_LDFLAGS = -framework CoreServices -framework Carbon +tcpbridge_SOURCES = tcpbridge_opts.c tcpbridge.c bridge.c send_packets.c sleep.c +noinst_HEADERS = tcpreplay.h tcpprep.h bridge.h defines.h tree.h \ + send_packets.h signal_handler.h common.h tcpreplay_opts.h \ + tcpreplay_edit_opts.h tcprewrite.h tcprewrite_opts.h tcpprep_opts.h \ + tcpprep_opts.def tcprewrite_opts.def tcpreplay_opts.def \ + tcpbridge_opts.def tcpbridge.h tcpbridge_opts.h tcpr.h sleep.h + +MOSTLYCLEANFILES = *~ *.o +MAINTAINERCLEANFILES = Makefile.in tcpreplay_opts.h tcpreplay_opts.c \ + tcprewrite_opts.c tcprewrite_opts.h tcpprep_opts.c \ + tcpprep_opts.h tcpprep.1 tcpreplay.1 tcprewrite.1 \ + tcpbridge.1 tcpbridge_opts.h tcpbridge_opts.c \ + tcpreplay_edit_opts.c tcpreplay_edit_opts.h \ + tcpreplay-edit.1 + +all: config.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *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);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +config.h: stamp-h1 + @if test ! -f $@; then \ + rm -f stamp-h1; \ + $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \ + else :; fi + +stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status + @rm -f stamp-h1 + cd $(top_builddir) && $(SHELL) ./config.status src/config.h +$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) + rm -f stamp-h1 + touch $@ + +distclean-hdr: + -rm -f config.h stamp-h1 +defines.h: $(top_builddir)/config.status $(srcdir)/defines.h.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p || test -f $$p1; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +tcpbridge$(EXEEXT): $(tcpbridge_OBJECTS) $(tcpbridge_DEPENDENCIES) + @rm -f tcpbridge$(EXEEXT) + $(tcpbridge_LINK) $(tcpbridge_OBJECTS) $(tcpbridge_LDADD) $(LIBS) +tcpprep$(EXEEXT): $(tcpprep_OBJECTS) $(tcpprep_DEPENDENCIES) + @rm -f tcpprep$(EXEEXT) + $(tcpprep_LINK) $(tcpprep_OBJECTS) $(tcpprep_LDADD) $(LIBS) +tcpreplay$(EXEEXT): $(tcpreplay_OBJECTS) $(tcpreplay_DEPENDENCIES) + @rm -f tcpreplay$(EXEEXT) + $(tcpreplay_LINK) $(tcpreplay_OBJECTS) $(tcpreplay_LDADD) $(LIBS) +tcpreplay-edit$(EXEEXT): $(tcpreplay_edit_OBJECTS) $(tcpreplay_edit_DEPENDENCIES) + @rm -f tcpreplay-edit$(EXEEXT) + $(tcpreplay_edit_LINK) $(tcpreplay_edit_OBJECTS) $(tcpreplay_edit_LDADD) $(LIBS) +tcprewrite$(EXEEXT): $(tcprewrite_OBJECTS) $(tcprewrite_DEPENDENCIES) + @rm -f tcprewrite$(EXEEXT) + $(tcprewrite_LINK) $(tcprewrite_OBJECTS) $(tcprewrite_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +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-send_packets.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpbridge-sleep.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)/tcpprep-tcpprep.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-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_opts.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_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@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +tcpbridge-tcpbridge_opts.o: tcpbridge_opts.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpbridge_CFLAGS) $(CFLAGS) -MT tcpbridge-tcpbridge_opts.o -MD -MP -MF $(DEPDIR)/tcpbridge-tcpbridge_opts.Tpo -c -o tcpbridge-tcpbridge_opts.o `test -f 'tcpbridge_opts.c' || echo '$(srcdir)/'`tcpbridge_opts.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpbridge-tcpbridge_opts.Tpo $(DEPDIR)/tcpbridge-tcpbridge_opts.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcpbridge_opts.c' object='tcpbridge-tcpbridge_opts.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpbridge_CFLAGS) $(CFLAGS) -c -o tcpbridge-tcpbridge_opts.o `test -f 'tcpbridge_opts.c' || echo '$(srcdir)/'`tcpbridge_opts.c + +tcpbridge-tcpbridge_opts.obj: tcpbridge_opts.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpbridge_CFLAGS) $(CFLAGS) -MT tcpbridge-tcpbridge_opts.obj -MD -MP -MF $(DEPDIR)/tcpbridge-tcpbridge_opts.Tpo -c -o tcpbridge-tcpbridge_opts.obj `if test -f 'tcpbridge_opts.c'; then $(CYGPATH_W) 'tcpbridge_opts.c'; else $(CYGPATH_W) '$(srcdir)/tcpbridge_opts.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpbridge-tcpbridge_opts.Tpo $(DEPDIR)/tcpbridge-tcpbridge_opts.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcpbridge_opts.c' object='tcpbridge-tcpbridge_opts.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpbridge_CFLAGS) $(CFLAGS) -c -o tcpbridge-tcpbridge_opts.obj `if test -f 'tcpbridge_opts.c'; then $(CYGPATH_W) 'tcpbridge_opts.c'; else $(CYGPATH_W) '$(srcdir)/tcpbridge_opts.c'; fi` + +tcpbridge-tcpbridge.o: tcpbridge.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpbridge_CFLAGS) $(CFLAGS) -MT tcpbridge-tcpbridge.o -MD -MP -MF $(DEPDIR)/tcpbridge-tcpbridge.Tpo -c -o tcpbridge-tcpbridge.o `test -f 'tcpbridge.c' || echo '$(srcdir)/'`tcpbridge.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpbridge-tcpbridge.Tpo $(DEPDIR)/tcpbridge-tcpbridge.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcpbridge.c' object='tcpbridge-tcpbridge.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpbridge_CFLAGS) $(CFLAGS) -c -o tcpbridge-tcpbridge.o `test -f 'tcpbridge.c' || echo '$(srcdir)/'`tcpbridge.c + +tcpbridge-tcpbridge.obj: tcpbridge.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpbridge_CFLAGS) $(CFLAGS) -MT tcpbridge-tcpbridge.obj -MD -MP -MF $(DEPDIR)/tcpbridge-tcpbridge.Tpo -c -o tcpbridge-tcpbridge.obj `if test -f 'tcpbridge.c'; then $(CYGPATH_W) 'tcpbridge.c'; else $(CYGPATH_W) '$(srcdir)/tcpbridge.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpbridge-tcpbridge.Tpo $(DEPDIR)/tcpbridge-tcpbridge.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcpbridge.c' object='tcpbridge-tcpbridge.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpbridge_CFLAGS) $(CFLAGS) -c -o tcpbridge-tcpbridge.obj `if test -f 'tcpbridge.c'; then $(CYGPATH_W) 'tcpbridge.c'; else $(CYGPATH_W) '$(srcdir)/tcpbridge.c'; fi` + +tcpbridge-bridge.o: bridge.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpbridge_CFLAGS) $(CFLAGS) -MT tcpbridge-bridge.o -MD -MP -MF $(DEPDIR)/tcpbridge-bridge.Tpo -c -o tcpbridge-bridge.o `test -f 'bridge.c' || echo '$(srcdir)/'`bridge.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpbridge-bridge.Tpo $(DEPDIR)/tcpbridge-bridge.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='bridge.c' object='tcpbridge-bridge.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpbridge_CFLAGS) $(CFLAGS) -c -o tcpbridge-bridge.o `test -f 'bridge.c' || echo '$(srcdir)/'`bridge.c + +tcpbridge-bridge.obj: bridge.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpbridge_CFLAGS) $(CFLAGS) -MT tcpbridge-bridge.obj -MD -MP -MF $(DEPDIR)/tcpbridge-bridge.Tpo -c -o tcpbridge-bridge.obj `if test -f 'bridge.c'; then $(CYGPATH_W) 'bridge.c'; else $(CYGPATH_W) '$(srcdir)/bridge.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpbridge-bridge.Tpo $(DEPDIR)/tcpbridge-bridge.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='bridge.c' object='tcpbridge-bridge.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpbridge_CFLAGS) $(CFLAGS) -c -o tcpbridge-bridge.obj `if test -f 'bridge.c'; then $(CYGPATH_W) 'bridge.c'; else $(CYGPATH_W) '$(srcdir)/bridge.c'; fi` + +tcpbridge-send_packets.o: send_packets.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpbridge_CFLAGS) $(CFLAGS) -MT tcpbridge-send_packets.o -MD -MP -MF $(DEPDIR)/tcpbridge-send_packets.Tpo -c -o tcpbridge-send_packets.o `test -f 'send_packets.c' || echo '$(srcdir)/'`send_packets.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpbridge-send_packets.Tpo $(DEPDIR)/tcpbridge-send_packets.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='send_packets.c' object='tcpbridge-send_packets.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpbridge_CFLAGS) $(CFLAGS) -c -o tcpbridge-send_packets.o `test -f 'send_packets.c' || echo '$(srcdir)/'`send_packets.c + +tcpbridge-send_packets.obj: send_packets.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpbridge_CFLAGS) $(CFLAGS) -MT tcpbridge-send_packets.obj -MD -MP -MF $(DEPDIR)/tcpbridge-send_packets.Tpo -c -o tcpbridge-send_packets.obj `if test -f 'send_packets.c'; then $(CYGPATH_W) 'send_packets.c'; else $(CYGPATH_W) '$(srcdir)/send_packets.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpbridge-send_packets.Tpo $(DEPDIR)/tcpbridge-send_packets.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='send_packets.c' object='tcpbridge-send_packets.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpbridge_CFLAGS) $(CFLAGS) -c -o tcpbridge-send_packets.obj `if test -f 'send_packets.c'; then $(CYGPATH_W) 'send_packets.c'; else $(CYGPATH_W) '$(srcdir)/send_packets.c'; fi` + +tcpbridge-sleep.o: sleep.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpbridge_CFLAGS) $(CFLAGS) -MT tcpbridge-sleep.o -MD -MP -MF $(DEPDIR)/tcpbridge-sleep.Tpo -c -o tcpbridge-sleep.o `test -f 'sleep.c' || echo '$(srcdir)/'`sleep.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpbridge-sleep.Tpo $(DEPDIR)/tcpbridge-sleep.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sleep.c' object='tcpbridge-sleep.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpbridge_CFLAGS) $(CFLAGS) -c -o tcpbridge-sleep.o `test -f 'sleep.c' || echo '$(srcdir)/'`sleep.c + +tcpbridge-sleep.obj: sleep.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpbridge_CFLAGS) $(CFLAGS) -MT tcpbridge-sleep.obj -MD -MP -MF $(DEPDIR)/tcpbridge-sleep.Tpo -c -o tcpbridge-sleep.obj `if test -f 'sleep.c'; then $(CYGPATH_W) 'sleep.c'; else $(CYGPATH_W) '$(srcdir)/sleep.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpbridge-sleep.Tpo $(DEPDIR)/tcpbridge-sleep.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sleep.c' object='tcpbridge-sleep.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpbridge_CFLAGS) $(CFLAGS) -c -o tcpbridge-sleep.obj `if test -f 'sleep.c'; then $(CYGPATH_W) 'sleep.c'; else $(CYGPATH_W) '$(srcdir)/sleep.c'; fi` + +tcpprep-tcpprep_opts.o: tcpprep_opts.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpprep_CFLAGS) $(CFLAGS) -MT tcpprep-tcpprep_opts.o -MD -MP -MF $(DEPDIR)/tcpprep-tcpprep_opts.Tpo -c -o tcpprep-tcpprep_opts.o `test -f 'tcpprep_opts.c' || echo '$(srcdir)/'`tcpprep_opts.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpprep-tcpprep_opts.Tpo $(DEPDIR)/tcpprep-tcpprep_opts.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcpprep_opts.c' object='tcpprep-tcpprep_opts.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpprep_CFLAGS) $(CFLAGS) -c -o tcpprep-tcpprep_opts.o `test -f 'tcpprep_opts.c' || echo '$(srcdir)/'`tcpprep_opts.c + +tcpprep-tcpprep_opts.obj: tcpprep_opts.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpprep_CFLAGS) $(CFLAGS) -MT tcpprep-tcpprep_opts.obj -MD -MP -MF $(DEPDIR)/tcpprep-tcpprep_opts.Tpo -c -o tcpprep-tcpprep_opts.obj `if test -f 'tcpprep_opts.c'; then $(CYGPATH_W) 'tcpprep_opts.c'; else $(CYGPATH_W) '$(srcdir)/tcpprep_opts.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpprep-tcpprep_opts.Tpo $(DEPDIR)/tcpprep-tcpprep_opts.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcpprep_opts.c' object='tcpprep-tcpprep_opts.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpprep_CFLAGS) $(CFLAGS) -c -o tcpprep-tcpprep_opts.obj `if test -f 'tcpprep_opts.c'; then $(CYGPATH_W) 'tcpprep_opts.c'; else $(CYGPATH_W) '$(srcdir)/tcpprep_opts.c'; fi` + +tcpprep-tcpprep.o: tcpprep.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpprep_CFLAGS) $(CFLAGS) -MT tcpprep-tcpprep.o -MD -MP -MF $(DEPDIR)/tcpprep-tcpprep.Tpo -c -o tcpprep-tcpprep.o `test -f 'tcpprep.c' || echo '$(srcdir)/'`tcpprep.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpprep-tcpprep.Tpo $(DEPDIR)/tcpprep-tcpprep.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcpprep.c' object='tcpprep-tcpprep.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpprep_CFLAGS) $(CFLAGS) -c -o tcpprep-tcpprep.o `test -f 'tcpprep.c' || echo '$(srcdir)/'`tcpprep.c + +tcpprep-tcpprep.obj: tcpprep.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpprep_CFLAGS) $(CFLAGS) -MT tcpprep-tcpprep.obj -MD -MP -MF $(DEPDIR)/tcpprep-tcpprep.Tpo -c -o tcpprep-tcpprep.obj `if test -f 'tcpprep.c'; then $(CYGPATH_W) 'tcpprep.c'; else $(CYGPATH_W) '$(srcdir)/tcpprep.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpprep-tcpprep.Tpo $(DEPDIR)/tcpprep-tcpprep.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcpprep.c' object='tcpprep-tcpprep.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpprep_CFLAGS) $(CFLAGS) -c -o tcpprep-tcpprep.obj `if test -f 'tcpprep.c'; then $(CYGPATH_W) 'tcpprep.c'; else $(CYGPATH_W) '$(srcdir)/tcpprep.c'; fi` + +tcpprep-tree.o: tree.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpprep_CFLAGS) $(CFLAGS) -MT tcpprep-tree.o -MD -MP -MF $(DEPDIR)/tcpprep-tree.Tpo -c -o tcpprep-tree.o `test -f 'tree.c' || echo '$(srcdir)/'`tree.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpprep-tree.Tpo $(DEPDIR)/tcpprep-tree.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tree.c' object='tcpprep-tree.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpprep_CFLAGS) $(CFLAGS) -c -o tcpprep-tree.o `test -f 'tree.c' || echo '$(srcdir)/'`tree.c + +tcpprep-tree.obj: tree.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpprep_CFLAGS) $(CFLAGS) -MT tcpprep-tree.obj -MD -MP -MF $(DEPDIR)/tcpprep-tree.Tpo -c -o tcpprep-tree.obj `if test -f 'tree.c'; then $(CYGPATH_W) 'tree.c'; else $(CYGPATH_W) '$(srcdir)/tree.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpprep-tree.Tpo $(DEPDIR)/tcpprep-tree.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tree.c' object='tcpprep-tree.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpprep_CFLAGS) $(CFLAGS) -c -o tcpprep-tree.obj `if test -f 'tree.c'; then $(CYGPATH_W) 'tree.c'; else $(CYGPATH_W) '$(srcdir)/tree.c'; fi` + +tcpreplay-tcpreplay_opts.o: tcpreplay_opts.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_CFLAGS) $(CFLAGS) -MT tcpreplay-tcpreplay_opts.o -MD -MP -MF $(DEPDIR)/tcpreplay-tcpreplay_opts.Tpo -c -o tcpreplay-tcpreplay_opts.o `test -f 'tcpreplay_opts.c' || echo '$(srcdir)/'`tcpreplay_opts.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpreplay-tcpreplay_opts.Tpo $(DEPDIR)/tcpreplay-tcpreplay_opts.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcpreplay_opts.c' object='tcpreplay-tcpreplay_opts.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_CFLAGS) $(CFLAGS) -c -o tcpreplay-tcpreplay_opts.o `test -f 'tcpreplay_opts.c' || echo '$(srcdir)/'`tcpreplay_opts.c + +tcpreplay-tcpreplay_opts.obj: tcpreplay_opts.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_CFLAGS) $(CFLAGS) -MT tcpreplay-tcpreplay_opts.obj -MD -MP -MF $(DEPDIR)/tcpreplay-tcpreplay_opts.Tpo -c -o tcpreplay-tcpreplay_opts.obj `if test -f 'tcpreplay_opts.c'; then $(CYGPATH_W) 'tcpreplay_opts.c'; else $(CYGPATH_W) '$(srcdir)/tcpreplay_opts.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpreplay-tcpreplay_opts.Tpo $(DEPDIR)/tcpreplay-tcpreplay_opts.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcpreplay_opts.c' object='tcpreplay-tcpreplay_opts.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_CFLAGS) $(CFLAGS) -c -o tcpreplay-tcpreplay_opts.obj `if test -f 'tcpreplay_opts.c'; then $(CYGPATH_W) 'tcpreplay_opts.c'; else $(CYGPATH_W) '$(srcdir)/tcpreplay_opts.c'; fi` + +tcpreplay-send_packets.o: send_packets.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_CFLAGS) $(CFLAGS) -MT tcpreplay-send_packets.o -MD -MP -MF $(DEPDIR)/tcpreplay-send_packets.Tpo -c -o tcpreplay-send_packets.o `test -f 'send_packets.c' || echo '$(srcdir)/'`send_packets.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpreplay-send_packets.Tpo $(DEPDIR)/tcpreplay-send_packets.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='send_packets.c' object='tcpreplay-send_packets.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_CFLAGS) $(CFLAGS) -c -o tcpreplay-send_packets.o `test -f 'send_packets.c' || echo '$(srcdir)/'`send_packets.c + +tcpreplay-send_packets.obj: send_packets.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_CFLAGS) $(CFLAGS) -MT tcpreplay-send_packets.obj -MD -MP -MF $(DEPDIR)/tcpreplay-send_packets.Tpo -c -o tcpreplay-send_packets.obj `if test -f 'send_packets.c'; then $(CYGPATH_W) 'send_packets.c'; else $(CYGPATH_W) '$(srcdir)/send_packets.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpreplay-send_packets.Tpo $(DEPDIR)/tcpreplay-send_packets.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='send_packets.c' object='tcpreplay-send_packets.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_CFLAGS) $(CFLAGS) -c -o tcpreplay-send_packets.obj `if test -f 'send_packets.c'; then $(CYGPATH_W) 'send_packets.c'; else $(CYGPATH_W) '$(srcdir)/send_packets.c'; fi` + +tcpreplay-signal_handler.o: signal_handler.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_CFLAGS) $(CFLAGS) -MT tcpreplay-signal_handler.o -MD -MP -MF $(DEPDIR)/tcpreplay-signal_handler.Tpo -c -o tcpreplay-signal_handler.o `test -f 'signal_handler.c' || echo '$(srcdir)/'`signal_handler.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpreplay-signal_handler.Tpo $(DEPDIR)/tcpreplay-signal_handler.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='signal_handler.c' object='tcpreplay-signal_handler.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_CFLAGS) $(CFLAGS) -c -o tcpreplay-signal_handler.o `test -f 'signal_handler.c' || echo '$(srcdir)/'`signal_handler.c + +tcpreplay-signal_handler.obj: signal_handler.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_CFLAGS) $(CFLAGS) -MT tcpreplay-signal_handler.obj -MD -MP -MF $(DEPDIR)/tcpreplay-signal_handler.Tpo -c -o tcpreplay-signal_handler.obj `if test -f 'signal_handler.c'; then $(CYGPATH_W) 'signal_handler.c'; else $(CYGPATH_W) '$(srcdir)/signal_handler.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpreplay-signal_handler.Tpo $(DEPDIR)/tcpreplay-signal_handler.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='signal_handler.c' object='tcpreplay-signal_handler.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_CFLAGS) $(CFLAGS) -c -o tcpreplay-signal_handler.obj `if test -f 'signal_handler.c'; then $(CYGPATH_W) 'signal_handler.c'; else $(CYGPATH_W) '$(srcdir)/signal_handler.c'; fi` + +tcpreplay-tcpreplay.o: tcpreplay.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_CFLAGS) $(CFLAGS) -MT tcpreplay-tcpreplay.o -MD -MP -MF $(DEPDIR)/tcpreplay-tcpreplay.Tpo -c -o tcpreplay-tcpreplay.o `test -f 'tcpreplay.c' || echo '$(srcdir)/'`tcpreplay.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpreplay-tcpreplay.Tpo $(DEPDIR)/tcpreplay-tcpreplay.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcpreplay.c' object='tcpreplay-tcpreplay.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_CFLAGS) $(CFLAGS) -c -o tcpreplay-tcpreplay.o `test -f 'tcpreplay.c' || echo '$(srcdir)/'`tcpreplay.c + +tcpreplay-tcpreplay.obj: tcpreplay.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_CFLAGS) $(CFLAGS) -MT tcpreplay-tcpreplay.obj -MD -MP -MF $(DEPDIR)/tcpreplay-tcpreplay.Tpo -c -o tcpreplay-tcpreplay.obj `if test -f 'tcpreplay.c'; then $(CYGPATH_W) 'tcpreplay.c'; else $(CYGPATH_W) '$(srcdir)/tcpreplay.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpreplay-tcpreplay.Tpo $(DEPDIR)/tcpreplay-tcpreplay.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcpreplay.c' object='tcpreplay-tcpreplay.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_CFLAGS) $(CFLAGS) -c -o tcpreplay-tcpreplay.obj `if test -f 'tcpreplay.c'; then $(CYGPATH_W) 'tcpreplay.c'; else $(CYGPATH_W) '$(srcdir)/tcpreplay.c'; fi` + +tcpreplay-sleep.o: sleep.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_CFLAGS) $(CFLAGS) -MT tcpreplay-sleep.o -MD -MP -MF $(DEPDIR)/tcpreplay-sleep.Tpo -c -o tcpreplay-sleep.o `test -f 'sleep.c' || echo '$(srcdir)/'`sleep.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpreplay-sleep.Tpo $(DEPDIR)/tcpreplay-sleep.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sleep.c' object='tcpreplay-sleep.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_CFLAGS) $(CFLAGS) -c -o tcpreplay-sleep.o `test -f 'sleep.c' || echo '$(srcdir)/'`sleep.c + +tcpreplay-sleep.obj: sleep.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_CFLAGS) $(CFLAGS) -MT tcpreplay-sleep.obj -MD -MP -MF $(DEPDIR)/tcpreplay-sleep.Tpo -c -o tcpreplay-sleep.obj `if test -f 'sleep.c'; then $(CYGPATH_W) 'sleep.c'; else $(CYGPATH_W) '$(srcdir)/sleep.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpreplay-sleep.Tpo $(DEPDIR)/tcpreplay-sleep.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sleep.c' object='tcpreplay-sleep.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_CFLAGS) $(CFLAGS) -c -o tcpreplay-sleep.obj `if test -f 'sleep.c'; then $(CYGPATH_W) 'sleep.c'; else $(CYGPATH_W) '$(srcdir)/sleep.c'; fi` + +tcpreplay_edit-tcpreplay_edit_opts.o: tcpreplay_edit_opts.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -MT tcpreplay_edit-tcpreplay_edit_opts.o -MD -MP -MF $(DEPDIR)/tcpreplay_edit-tcpreplay_edit_opts.Tpo -c -o tcpreplay_edit-tcpreplay_edit_opts.o `test -f 'tcpreplay_edit_opts.c' || echo '$(srcdir)/'`tcpreplay_edit_opts.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpreplay_edit-tcpreplay_edit_opts.Tpo $(DEPDIR)/tcpreplay_edit-tcpreplay_edit_opts.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcpreplay_edit_opts.c' object='tcpreplay_edit-tcpreplay_edit_opts.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -c -o tcpreplay_edit-tcpreplay_edit_opts.o `test -f 'tcpreplay_edit_opts.c' || echo '$(srcdir)/'`tcpreplay_edit_opts.c + +tcpreplay_edit-tcpreplay_edit_opts.obj: tcpreplay_edit_opts.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -MT tcpreplay_edit-tcpreplay_edit_opts.obj -MD -MP -MF $(DEPDIR)/tcpreplay_edit-tcpreplay_edit_opts.Tpo -c -o tcpreplay_edit-tcpreplay_edit_opts.obj `if test -f 'tcpreplay_edit_opts.c'; then $(CYGPATH_W) 'tcpreplay_edit_opts.c'; else $(CYGPATH_W) '$(srcdir)/tcpreplay_edit_opts.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpreplay_edit-tcpreplay_edit_opts.Tpo $(DEPDIR)/tcpreplay_edit-tcpreplay_edit_opts.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcpreplay_edit_opts.c' object='tcpreplay_edit-tcpreplay_edit_opts.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -c -o tcpreplay_edit-tcpreplay_edit_opts.obj `if test -f 'tcpreplay_edit_opts.c'; then $(CYGPATH_W) 'tcpreplay_edit_opts.c'; else $(CYGPATH_W) '$(srcdir)/tcpreplay_edit_opts.c'; fi` + +tcpreplay_edit-send_packets.o: send_packets.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -MT tcpreplay_edit-send_packets.o -MD -MP -MF $(DEPDIR)/tcpreplay_edit-send_packets.Tpo -c -o tcpreplay_edit-send_packets.o `test -f 'send_packets.c' || echo '$(srcdir)/'`send_packets.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpreplay_edit-send_packets.Tpo $(DEPDIR)/tcpreplay_edit-send_packets.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='send_packets.c' object='tcpreplay_edit-send_packets.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -c -o tcpreplay_edit-send_packets.o `test -f 'send_packets.c' || echo '$(srcdir)/'`send_packets.c + +tcpreplay_edit-send_packets.obj: send_packets.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -MT tcpreplay_edit-send_packets.obj -MD -MP -MF $(DEPDIR)/tcpreplay_edit-send_packets.Tpo -c -o tcpreplay_edit-send_packets.obj `if test -f 'send_packets.c'; then $(CYGPATH_W) 'send_packets.c'; else $(CYGPATH_W) '$(srcdir)/send_packets.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpreplay_edit-send_packets.Tpo $(DEPDIR)/tcpreplay_edit-send_packets.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='send_packets.c' object='tcpreplay_edit-send_packets.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -c -o tcpreplay_edit-send_packets.obj `if test -f 'send_packets.c'; then $(CYGPATH_W) 'send_packets.c'; else $(CYGPATH_W) '$(srcdir)/send_packets.c'; fi` + +tcpreplay_edit-signal_handler.o: signal_handler.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -MT tcpreplay_edit-signal_handler.o -MD -MP -MF $(DEPDIR)/tcpreplay_edit-signal_handler.Tpo -c -o tcpreplay_edit-signal_handler.o `test -f 'signal_handler.c' || echo '$(srcdir)/'`signal_handler.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpreplay_edit-signal_handler.Tpo $(DEPDIR)/tcpreplay_edit-signal_handler.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='signal_handler.c' object='tcpreplay_edit-signal_handler.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -c -o tcpreplay_edit-signal_handler.o `test -f 'signal_handler.c' || echo '$(srcdir)/'`signal_handler.c + +tcpreplay_edit-signal_handler.obj: signal_handler.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -MT tcpreplay_edit-signal_handler.obj -MD -MP -MF $(DEPDIR)/tcpreplay_edit-signal_handler.Tpo -c -o tcpreplay_edit-signal_handler.obj `if test -f 'signal_handler.c'; then $(CYGPATH_W) 'signal_handler.c'; else $(CYGPATH_W) '$(srcdir)/signal_handler.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpreplay_edit-signal_handler.Tpo $(DEPDIR)/tcpreplay_edit-signal_handler.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='signal_handler.c' object='tcpreplay_edit-signal_handler.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -c -o tcpreplay_edit-signal_handler.obj `if test -f 'signal_handler.c'; then $(CYGPATH_W) 'signal_handler.c'; else $(CYGPATH_W) '$(srcdir)/signal_handler.c'; fi` + +tcpreplay_edit-tcpreplay.o: tcpreplay.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -MT tcpreplay_edit-tcpreplay.o -MD -MP -MF $(DEPDIR)/tcpreplay_edit-tcpreplay.Tpo -c -o tcpreplay_edit-tcpreplay.o `test -f 'tcpreplay.c' || echo '$(srcdir)/'`tcpreplay.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpreplay_edit-tcpreplay.Tpo $(DEPDIR)/tcpreplay_edit-tcpreplay.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcpreplay.c' object='tcpreplay_edit-tcpreplay.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -c -o tcpreplay_edit-tcpreplay.o `test -f 'tcpreplay.c' || echo '$(srcdir)/'`tcpreplay.c + +tcpreplay_edit-tcpreplay.obj: tcpreplay.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -MT tcpreplay_edit-tcpreplay.obj -MD -MP -MF $(DEPDIR)/tcpreplay_edit-tcpreplay.Tpo -c -o tcpreplay_edit-tcpreplay.obj `if test -f 'tcpreplay.c'; then $(CYGPATH_W) 'tcpreplay.c'; else $(CYGPATH_W) '$(srcdir)/tcpreplay.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpreplay_edit-tcpreplay.Tpo $(DEPDIR)/tcpreplay_edit-tcpreplay.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcpreplay.c' object='tcpreplay_edit-tcpreplay.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -c -o tcpreplay_edit-tcpreplay.obj `if test -f 'tcpreplay.c'; then $(CYGPATH_W) 'tcpreplay.c'; else $(CYGPATH_W) '$(srcdir)/tcpreplay.c'; fi` + +tcpreplay_edit-sleep.o: sleep.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -MT tcpreplay_edit-sleep.o -MD -MP -MF $(DEPDIR)/tcpreplay_edit-sleep.Tpo -c -o tcpreplay_edit-sleep.o `test -f 'sleep.c' || echo '$(srcdir)/'`sleep.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpreplay_edit-sleep.Tpo $(DEPDIR)/tcpreplay_edit-sleep.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sleep.c' object='tcpreplay_edit-sleep.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -c -o tcpreplay_edit-sleep.o `test -f 'sleep.c' || echo '$(srcdir)/'`sleep.c + +tcpreplay_edit-sleep.obj: sleep.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -MT tcpreplay_edit-sleep.obj -MD -MP -MF $(DEPDIR)/tcpreplay_edit-sleep.Tpo -c -o tcpreplay_edit-sleep.obj `if test -f 'sleep.c'; then $(CYGPATH_W) 'sleep.c'; else $(CYGPATH_W) '$(srcdir)/sleep.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpreplay_edit-sleep.Tpo $(DEPDIR)/tcpreplay_edit-sleep.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sleep.c' object='tcpreplay_edit-sleep.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcpreplay_edit_CFLAGS) $(CFLAGS) -c -o tcpreplay_edit-sleep.obj `if test -f 'sleep.c'; then $(CYGPATH_W) 'sleep.c'; else $(CYGPATH_W) '$(srcdir)/sleep.c'; fi` + +tcprewrite-tcprewrite_opts.o: tcprewrite_opts.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcprewrite_CFLAGS) $(CFLAGS) -MT tcprewrite-tcprewrite_opts.o -MD -MP -MF $(DEPDIR)/tcprewrite-tcprewrite_opts.Tpo -c -o tcprewrite-tcprewrite_opts.o `test -f 'tcprewrite_opts.c' || echo '$(srcdir)/'`tcprewrite_opts.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcprewrite-tcprewrite_opts.Tpo $(DEPDIR)/tcprewrite-tcprewrite_opts.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcprewrite_opts.c' object='tcprewrite-tcprewrite_opts.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcprewrite_CFLAGS) $(CFLAGS) -c -o tcprewrite-tcprewrite_opts.o `test -f 'tcprewrite_opts.c' || echo '$(srcdir)/'`tcprewrite_opts.c + +tcprewrite-tcprewrite_opts.obj: tcprewrite_opts.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcprewrite_CFLAGS) $(CFLAGS) -MT tcprewrite-tcprewrite_opts.obj -MD -MP -MF $(DEPDIR)/tcprewrite-tcprewrite_opts.Tpo -c -o tcprewrite-tcprewrite_opts.obj `if test -f 'tcprewrite_opts.c'; then $(CYGPATH_W) 'tcprewrite_opts.c'; else $(CYGPATH_W) '$(srcdir)/tcprewrite_opts.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcprewrite-tcprewrite_opts.Tpo $(DEPDIR)/tcprewrite-tcprewrite_opts.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcprewrite_opts.c' object='tcprewrite-tcprewrite_opts.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcprewrite_CFLAGS) $(CFLAGS) -c -o tcprewrite-tcprewrite_opts.obj `if test -f 'tcprewrite_opts.c'; then $(CYGPATH_W) 'tcprewrite_opts.c'; else $(CYGPATH_W) '$(srcdir)/tcprewrite_opts.c'; fi` + +tcprewrite-tcprewrite.o: tcprewrite.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcprewrite_CFLAGS) $(CFLAGS) -MT tcprewrite-tcprewrite.o -MD -MP -MF $(DEPDIR)/tcprewrite-tcprewrite.Tpo -c -o tcprewrite-tcprewrite.o `test -f 'tcprewrite.c' || echo '$(srcdir)/'`tcprewrite.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcprewrite-tcprewrite.Tpo $(DEPDIR)/tcprewrite-tcprewrite.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcprewrite.c' object='tcprewrite-tcprewrite.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcprewrite_CFLAGS) $(CFLAGS) -c -o tcprewrite-tcprewrite.o `test -f 'tcprewrite.c' || echo '$(srcdir)/'`tcprewrite.c + +tcprewrite-tcprewrite.obj: tcprewrite.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcprewrite_CFLAGS) $(CFLAGS) -MT tcprewrite-tcprewrite.obj -MD -MP -MF $(DEPDIR)/tcprewrite-tcprewrite.Tpo -c -o tcprewrite-tcprewrite.obj `if test -f 'tcprewrite.c'; then $(CYGPATH_W) 'tcprewrite.c'; else $(CYGPATH_W) '$(srcdir)/tcprewrite.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcprewrite-tcprewrite.Tpo $(DEPDIR)/tcprewrite-tcprewrite.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tcprewrite.c' object='tcprewrite-tcprewrite.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(tcprewrite_CFLAGS) $(CFLAGS) -c -o tcprewrite-tcprewrite.obj `if test -f 'tcprewrite.c'; then $(CYGPATH_W) 'tcprewrite.c'; else $(CYGPATH_W) '$(srcdir)/tcprewrite.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-man1: $(man_MANS) + @$(NORMAL_INSTALL) + test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)" + @list=''; test -n "$(man1dir)" || exit 0; \ + { for i in $$list; do echo "$$i"; done; \ + l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ + sed -n '/\.1[a-z]*$$/p'; \ + } | while read p; do \ + if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; echo "$$p"; \ + done | \ + sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ + sed 'N;N;s,\n, ,g' | { \ + list=; while read file base inst; do \ + if test "$$base" = "$$inst"; then list="$$list $$file"; else \ + echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ + $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ + fi; \ + done; \ + for i in $$list; do echo "$$i"; done | $(am__base_list) | \ + while read files; do \ + test -z "$$files" || { \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ + done; } + +uninstall-man1: + @$(NORMAL_UNINSTALL) + @list=''; test -n "$(man1dir)" || exit 0; \ + files=`{ for i in $$list; do echo "$$i"; done; \ + l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ + sed -n '/\.1[a-z]*$$/p'; \ + } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ + test -z "$$files" || { \ + echo " ( cd '$(DESTDIR)$(man1dir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(man1dir)" && rm -f $$files; } + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +$(RECURSIVE_CLEAN_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @list='$(MANS)'; if test -n "$$list"; then \ + list=`for p in $$list; do \ + if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ + if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \ + if test -n "$$list" && \ + grep 'ab help2man is required to generate this page' $$list >/dev/null; then \ + echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \ + grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \ + echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \ + echo " typically \`make maintainer-clean' will remove them" >&2; \ + exit 1; \ + else :; fi; \ + else :; fi + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ + $(am__relativize); \ + new_distdir=$$reldir; \ + dir1=$$subdir; dir2="$(top_distdir)"; \ + $(am__relativize); \ + new_top_distdir=$$reldir; \ + echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ + echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ + ($(am__cd) $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$new_top_distdir" \ + distdir="$$new_distdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + am__skip_mode_fix=: \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile $(PROGRAMS) $(MANS) $(HEADERS) config.h +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-recursive + +clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-hdr distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +html-am: + +info: info-recursive + +info-am: + +install-data-am: install-man + +install-dvi: install-dvi-recursive + +install-dvi-am: + +install-exec-am: install-binPROGRAMS + +install-html: install-html-recursive + +install-html-am: + +install-info: install-info-recursive + +install-info-am: + +install-man: install-man1 + +install-pdf: install-pdf-recursive + +install-pdf-am: + +install-ps: install-ps-recursive + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-man + +uninstall-man: uninstall-man1 + +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \ + ctags-recursive install-am install-strip tags-recursive + +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am check check-am clean clean-binPROGRAMS \ + clean-generic clean-libtool ctags ctags-recursive 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-recursive \ + uninstall uninstall-am uninstall-binPROGRAMS uninstall-man \ + uninstall-man1 + + +manpages: tcpprep.1 tcprewrite.1 tcpreplay.1 tcpbridge.1 tcpreplay-edit.1 + +autoopts: tcpreplay_opts.c tcprewrite_opts.c tcpbridge_opts.c manpages \ + tcpreplay_edit_opts.c + +tcpprep.1: tcpprep_opts.def + @AUTOGEN@ -T agman1.tpl $(opts_list) --base-name tcpprep tcpprep_opts.def + +tcprewrite.1: tcprewrite_opts.def tcpedit/tcpedit_opts.def + @AUTOGEN@ -T agman1.tpl $(opts_list) --base-name tcprewrite tcprewrite_opts.def + +tcpreplay-edit.1: tcpreplay_opts.def + @AUTOGEN@ -T agman1.tpl $(opts_list) -DTCPREPLAY_EDIT --base-name tcpreplay-edit tcpreplay_opts.def + +tcpreplay.1: tcpreplay_opts.def + @AUTOGEN@ -T agman1.tpl $(opts_list) --base-name tcpreplay tcpreplay_opts.def + +tcpbridge.1: tcpbridge_opts.def tcpedit/tcpedit_opts.def + @AUTOGEN@ -T agman1.tpl $(opts_list) --base-name tcpbridge tcpbridge_opts.def +tcpreplay_edit_OBJECTS: tcpreplay_opts.h +tcpreplay_edit_opts.h: tcpreplay_edit_opts.c + +tcpreplay_edit_opts.c: tcpreplay_opts.def + @AUTOGEN@ $(opts_list) -DTCPREPLAY_EDIT -b tcpreplay_edit_opts \ + tcpreplay_opts.def +tcpreplay_OBJECTS: tcpreplay_opts.h +tcpreplay_opts.h: tcpreplay_opts.c + +tcpreplay_opts.c: tcpreplay_opts.def + @AUTOGEN@ $(opts_list) tcpreplay_opts.def +tcprewrite_OBJECTS: tcprewrite_opts.h +tcprewrite_opts.h: tcprewrite_opts.c +tcprewrite_opts.c: tcprewrite_opts.def tcpedit/tcpedit_opts.def + @AUTOGEN@ $(opts_list) tcprewrite_opts.def +tcpprep_OBJECTS: tcpprep_opts.h +tcpprep_opts.h: tcpprep_opts.c +tcpprep_opts.c: tcpprep_opts.def + @AUTOGEN@ tcpprep_opts.def +tcpbridge_OBJECTS: tcpbridge_opts.h +tcpbridge_opts.h: tcpbridge_opts.c +tcpbridge_opts.c: tcpbridge_opts.def tcpedit/tcpedit_opts.def + @AUTOGEN@ $(opts_list) tcpbridge_opts.def + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/bridge.c b/src/bridge.c new file mode 100644 index 0000000..4cfa8ae --- /dev/null +++ b/src/bridge.c @@ -0,0 +1,518 @@ +/* $Id: bridge.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "defines.h" +#include "common.h" + +#include +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_BPF +#include /* necessary for using select() for BPF devices */ +#endif + +#include "tcpbridge.h" +#include "bridge.h" +#include "send_packets.h" +#include "tcpedit/tcpedit.h" + +extern tcpbridge_opt_t options; +extern struct timeval begin, end; +extern COUNTER bytes_sent, failed, pkts_sent; +extern volatile int didsig; + +#ifdef DEBUG +extern int debug; +#endif + +static int live_callback(struct live_data_t *, + struct pcap_pkthdr *, const u_char *); + +/** + * First, prep our RB Tree which tracks where each (source) + * MAC really lives so we don't create really nasty network + * storms. + */ +static struct macsrc_t *new_node(void); + +RB_HEAD(macsrc_tree, macsrc_t) macsrc_root; + +static int +rbmacsrc_comp(struct macsrc_t *a, struct macsrc_t *b) +{ + return (memcmp(a->key, b->key, ETHER_ADDR_LEN)); +} + +RB_PROTOTYPE(macsrc_tree, macsrc_t, node, rbmacsrc_comp) +RB_GENERATE(macsrc_tree, macsrc_t, node, rbmacsrc_comp) + +/** + * redblack init + */ +void +rbinit(void) +{ + RB_INIT(&macsrc_root); +} + +/** + * create a new node... Malloc's memory + */ +struct macsrc_t * +new_node(void) +{ + struct macsrc_t *node; + + node = (struct macsrc_t *)safe_malloc(sizeof(struct macsrc_t)); + + memset(node, '\0', sizeof(struct macsrc_t)); + return (node); +} + + +/** + * main loop for bridging in only one direction + * optimized to not use poll(), but rather libpcap's builtin pcap_loop() + */ +static void +do_bridge_unidirectional(tcpbridge_opt_t *options, tcpedit_t *tcpedit) +{ + struct live_data_t livedata; + int retcode; + + assert(options); + assert(tcpedit); + + livedata.tcpedit = tcpedit; + livedata.source = PCAP_INT1; + livedata.pcap = options->pcap1; + livedata.options = options; + + if ((retcode = pcap_loop(options->pcap1, options->limit_send, + (pcap_handler)live_callback, (u_char *) &livedata)) < 0) { + warnx("Error in pcap_loop(): %s", pcap_geterr(options->pcap1)); + } + +} + +#ifndef HAVE_BPF +/** + * main loop for bridging in both directions. Since we dealing with two handles + * we need to poll() on them which isn't the most efficent. + * + * Note that this function is only used on systems which do not have a BPF + * device because poll() behaves poorly with /dev/bpf + */ +static void +do_bridge_bidirectional(tcpbridge_opt_t *options, tcpedit_t *tcpedit) +{ + struct pollfd polls[2]; /* one for left & right pcap */ + int pollresult, pollcount, timeout; + struct live_data_t livedata; + + assert(options); + assert(tcpedit); + + livedata.tcpedit = tcpedit; + livedata.options = options; + + + /* + * loop until ctrl-C or we've sent enough packets + * note that if -L wasn't specified, limit_send is + * set to 0 so this will loop infinately + */ + while ((options->limit_send == 0) || (options->limit_send > pkts_sent)) { + if (didsig) + break; + + dbgx(3, "limit_send: " COUNTER_SPEC " \t pkts_sent: " COUNTER_SPEC, + options->limit_send, pkts_sent); + + /* reset the result codes */ + polls[PCAP_INT1].revents = 0; + polls[PCAP_INT1].events = POLLIN; + polls[PCAP_INT1].fd = pcap_fileno(options->pcap1); + + polls[PCAP_INT2].revents = 0; + polls[PCAP_INT2].events = POLLIN; + polls[PCAP_INT2].fd = pcap_fileno(options->pcap2); + + timeout = options->poll_timeout; + pollcount = 2; + + /* poll for a packet on the two interfaces */ + pollresult = poll(polls, pollcount, timeout); + + /* poll has returned, process the result */ + if (pollresult > 0) { + dbgx(3, "pollresult: %d", pollresult); + + /* success, got one or more packets */ + if (polls[PCAP_INT1].revents > 0) { + dbg(5, "Processing first interface"); + livedata.source = PCAP_INT1; + livedata.pcap = options->pcap1; + pcap_dispatch(options->pcap1, -1, (pcap_handler) live_callback, + (u_char *) &livedata); + } + + /* check the other interface?? */ + if (polls[PCAP_INT2].revents > 0) { + dbg(5, "Processing second interface"); + livedata.source = PCAP_INT2; + livedata.pcap = options->pcap2; + pcap_dispatch(options->pcap2, -1, (pcap_handler) live_callback, + (u_char *) &livedata); + } + + } + else if (pollresult == 0) { + dbg(3, "poll timeout exceeded..."); + /* do something here? */ + } + else { + /* poll error, probably a Ctrl-C */ + warnx("poll() error: %s", strerror(errno)); + } + + /* go back to the top of the loop */ + } + +} /* do_bridge_bidirectional() */ + +#elif defined HAVE_BPF && defined HAVE_PCAP_SETNONBLOCK +/** + * main loop for bridging in both directions with BPF. We'll be using + * select() because that works better on older *BSD and OSX + * + * See this for details behind this maddness: + * http://article.gmane.org/gmane.network.tcpdump.devel/3581 + */ +static void +do_bridge_bidirectional(tcpbridge_opt_t *options, tcpedit_t *tcpedit) +{ + fd_set readfds, writefds, errorfds; + struct live_data_t livedata; + int fd, nfds, ret; + struct timeval timeout = { 0, 100 }; /* default to 100ms timeout */ + char ebuf[PCAP_ERRBUF_SIZE]; + + assert(options); + assert(tcpedit); + + livedata.tcpedit = tcpedit; + livedata.options = options; + + /* + * loop until ctrl-C or we've sent enough packets + * note that if -L wasn't specified, limit_send is + * set to 0 so this will loop infinately + */ + while ((options->limit_send == 0) || (options->limit_send > pkts_sent)) { + if (didsig) + break; + + dbgx(3, "limit_send: " COUNTER_SPEC " \t pkts_sent: " COUNTER_SPEC, + options->limit_send, pkts_sent); + + /* reset the result codes */ + FD_ZERO(&readfds); + FD_ZERO(&writefds); + FD_ZERO(&errorfds); + + /* set for reading */ +#ifdef HAVE_PCAP_GET_SELECTABLE_FD + fd = pcap_get_selectable_fd(options->pcap1); +#else + fd = pcap_fileno(options->pcap1); +#endif + if ((pcap_setnonblock(options->pcap1, 1, ebuf)) < 0) + errx(1, "Unable to set %s into nonblocking mode: %s", options->intf1, ebuf); + FD_SET(fd, &readfds); + +#ifdef HAVE_PCAP_GET_SELECTABLE_FD + fd = pcap_get_selectable_fd(options->pcap2); +#else + fd = pcap_fileno(options->pcap2); +#endif + if ((pcap_setnonblock(options->pcap2, 1, ebuf)) < 0) + errx(1, "Unable to set %s into nonblocking mode: %s", options->intf2, ebuf); + FD_SET(fd, &readfds); + + nfds = 2; + + /* wait for a packet on the two interfaces */ + ret = select(nfds, &readfds, &writefds, &errorfds, &timeout); + + /* + * There is a problem with OS X and certian *BSD's when using + * select() on a character device like /dev/bpf. Hence we always + * must attempt to read off each fd after the timeout. This is why + * we put the fd's in nonblocking mode above! + */ + + dbg(5, "Processing first interface"); + livedata.source = PCAP_INT1; + livedata.pcap = options->pcap1; + pcap_dispatch(options->pcap1, -1, (pcap_handler) live_callback, + (u_char *) &livedata); + + dbg(5, "Processing second interface"); + livedata.source = PCAP_INT2; + livedata.pcap = options->pcap2; + pcap_dispatch(options->pcap2, -1, (pcap_handler) live_callback, + (u_char *) &livedata); + + /* go back to the top of the loop */ + } +} +#else +#error "Your system needs a libpcap with pcap_setnonblock(). Please upgrade libpcap." +#endif + +/** + * Main entry point to bridging. Does some initial setup and then calls the + * correct loop (unidirectional or bidirectional) + */ +void +do_bridge(tcpbridge_opt_t *options, tcpedit_t *tcpedit) +{ + /* do we apply a bpf filter? */ + if (options->bpf.filter != NULL) { + /* compile filter */ + dbgx(2, "Try to compile pcap bpf filter: %s", options->bpf.filter); + if (pcap_compile(options->pcap1, &options->bpf.program, options->bpf.filter, options->bpf.optimize, 0) != 0) { + errx(-1, "Error compiling BPF filter: %s", pcap_geterr(options->pcap1)); + } + + /* apply filter */ + pcap_setfilter(options->pcap1, &options->bpf.program); + + /* same for other interface if applicable */ + if (options->unidir == 0) { + /* compile filter */ + dbgx(2, "Try to compile pcap bpf filter: %s", options->bpf.filter); + if (pcap_compile(options->pcap2, &options->bpf.program, options->bpf.filter, options->bpf.optimize, 0) != 0) { + errx(-1, "Error compiling BPF filter: %s", pcap_geterr(options->pcap2)); + } + + /* apply filter */ + pcap_setfilter(options->pcap2, &options->bpf.program); + } + } + + /* register signals */ + didsig = 0; + (void)signal(SIGINT, catcher); + + + if (options->unidir == 1) { + do_bridge_unidirectional(options, tcpedit); + } else { + do_bridge_bidirectional(options, tcpedit); + } + + packet_stats(&begin, &end, bytes_sent, pkts_sent, failed); +} + + +/** + * This is the callback we use with pcap_dispatch to process + * each packet recieved 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, + const u_char * nextpkt) +{ + ipv4_hdr_t *ip_hdr = NULL; + ipv6_hdr_t *ip6_hdr = NULL; + pcap_t *send = NULL; + static u_char *pktdata = NULL; /* full packet buffer */ + int cache_mode, retcode; + static unsigned long packetnum = 0; + struct macsrc_t *node, finder; /* rb tree nodes */ +#ifdef DEBUG + u_char dstmac[ETHER_ADDR_LEN]; +#endif + u_int16_t l2proto; + + packetnum++; + dbgx(2, "packet %lu caplen %d", packetnum, pkthdr->caplen); + + /* only malloc the first time */ + if (pktdata == NULL) { + /* create packet buffers */ + pktdata = (u_char *)safe_malloc(MAXPACKET); + } else { + /* zero out the old packet info */ + memset(pktdata, '\0', MAXPACKET); + } + + /* copy the packet to our buffer */ + memcpy(pktdata, nextpkt, pkthdr->caplen); + + +#ifdef ENABLE_VERBOSE + /* decode packet? */ + if (livedata->options->verbose) + tcpdump_print(livedata->options->tcpdump, pkthdr, nextpkt); +#endif + + + /* lookup our source MAC in the tree */ + memcpy(&finder.key, &pktdata[ETHER_ADDR_LEN], ETHER_ADDR_LEN); +#ifdef DEBUG + memcpy(&dstmac, pktdata, ETHER_ADDR_LEN); + dbgx(1, "SRC MAC: " MAC_FORMAT "\tDST MAC: " MAC_FORMAT, + MAC_STR(finder.key), MAC_STR(dstmac)); +#endif + + /* 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); + } + 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); + } + + node = RB_FIND(macsrc_tree, &macsrc_root, &finder); + + /* if we can't find the node, build a new one */ + if (node == NULL) { + dbg(1, "Unable to find MAC in the tree"); + node = new_node(); + node->source = livedata->source; + memcpy(&node->key, &finder.key, ETHER_ADDR_LEN); + RB_INSERT(macsrc_tree, &macsrc_root, node); + } + + /* otherwise compare sources */ + else if (node->source != livedata->source) { + dbg(1, "Found the dest MAC in the tree and it doesn't match this source NIC... skipping packet"); + /* + * IMPORTANT!!! + * Never send a packet out the same interface we sourced it on! + */ + return (1); + } + + /* what is our cache mode? */ + cache_mode = livedata->source == PCAP_INT1 ? TCPR_DIR_C2S : TCPR_DIR_S2C; + + l2proto = tcpedit_l3proto(livedata->tcpedit, BEFORE_PROCESS, pktdata, pkthdr->len); + dbgx(2, "Packet protocol: %04hx", l2proto); + + /* should we skip this packet based on CIDR match? */ + if (l2proto == ETHERTYPE_IP) { + dbg(3, "Packet is IPv4"); + ip_hdr = (ipv4_hdr_t *)tcpedit_l3data(livedata->tcpedit, BEFORE_PROCESS, pktdata, pkthdr->len); + + /* look for include or exclude CIDR match */ + if (livedata->options->xX.cidr != NULL) { + if (!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); + } + } + + } + else if (l2proto == ETHERTYPE_IP6) { + dbg(3, "Packet is IPv6"); + ip6_hdr = (ipv6_hdr_t *)tcpedit_l3data(livedata->tcpedit, BEFORE_PROCESS, pktdata, pkthdr->len); + + /* look for include or exclude CIDR match */ + 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); + } + } + + } + + if ((retcode = tcpedit_packet(livedata->tcpedit, &pkthdr, &pktdata, cache_mode)) < 0) { + if (retcode == TCPEDIT_SOFT_ERROR) { + return 1; + } else { /* TCPEDIT_ERROR */ + return -1; + } + } + + /* + * send packets out the OTHER interface + * and update the dst mac if necessary + */ + switch(node->source) { + case PCAP_INT1: + dbgx(2, "Packet source was %s... sending out on %s", livedata->options->intf1, + livedata->options->intf2); + send = livedata->options->pcap2; + break; + + case PCAP_INT2: + dbgx(2, "Packet source was %s... sending out on %s", livedata->options->intf2, + livedata->options->intf1); + send = livedata->options->pcap1; + break; + + default: + errx(-1, "wtf? our node->source != PCAP_INT1 and != PCAP_INT2: %c", + node->source); + } + + /* + * write packet out on the network + */ + if (pcap_sendpacket(send, pktdata, pkthdr->caplen) < 0) + errx(-1, "Unable to send packet out %s: %s", + send == livedata->options->pcap1 ? livedata->options->intf1 : livedata->options->intf2, pcap_geterr(send)); + + bytes_sent += pkthdr->caplen; + pkts_sent++; + + dbgx(1, "Sent packet " COUNTER_SPEC, pkts_sent); + + + return (1); +} /* live_callback() */ + + diff --git a/src/bridge.h b/src/bridge.h new file mode 100644 index 0000000..cbfcfbd --- /dev/null +++ b/src/bridge.h @@ -0,0 +1,81 @@ +/* $Id: bridge.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __BRIDGE_H__ +#define __BRIDGE_H__ + +#include "config.h" +#include "lib/tree.h" +#include "tcpedit/tcpedit.h" + +/* + * RBTree node object for tracking which side of tcpreplay where + * each source MAC address lives + */ +struct macsrc_t { + RB_ENTRY(macsrc_t) node; + u_char key[ETHER_ADDR_LEN]; + u_char source; /* interface device name we first saw the source MAC */ + sendpacket_t *sp; /* sendpacket handle to send packets out */ +}; + +/* pri and secondary pcap interfaces */ +#define PCAP_INT1 0 +#define PCAP_INT2 1 + +/* our custom pcap_dispatch handler user struct */ +struct live_data_t { + u_int32_t linktype; + int l2enabled; + int l2len; + u_char source; + char *l2data; + pcap_t *pcap; + tcpedit_t *tcpedit; + tcpbridge_opt_t *options; +}; + +void rbinit(void); +void do_bridge(tcpbridge_opt_t *, tcpedit_t *); + + +#endif + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + + diff --git a/src/common.h b/src/common.h new file mode 100644 index 0000000..8c579e6 --- /dev/null +++ b/src/common.h @@ -0,0 +1,28 @@ +#ifndef __COMMON_H__ +#define __COMMON_H__ +#include +#include "config.h" +#include "common/pcap_dlt.h" +#include "common/cache.h" +#include "common/cidr.h" +#include "common/err.h" +#include "common/get.h" +#include "common/fakepcap.h" +#include "common/fakepcapnav.h" +#include "common/fakepoll.h" +#include "common/list.h" +#include "common/mac.h" +#include "common/services.h" +#include "common/utils.h" +#include "common/xX.h" +#include "common/rdtsc.h" +#include "common/tcpdump.h" +#include "common/timer.h" +#include "common/abort.h" +#include "common/sendpacket.h" +#include "common/interface.h" + +const char *svn_version(void); /* svn_version.c */ + +#endif + diff --git a/src/common/Makefile.am b/src/common/Makefile.am new file mode 100644 index 0000000..9f26032 --- /dev/null +++ b/src/common/Makefile.am @@ -0,0 +1,34 @@ +# $Id: Makefile.am 1621 2006-11-09 07:01:37Z aturner $ +noinst_LIBRARIES = libcommon.a + +BUILT_SOURCES = svn_version.c + +svn_version.c: + $(ECHO) -n 'const char SVN_Version[] = "' > svn_version.c + svnversion -n ../.. >> svn_version.c + $(ECHO) '";' >> svn_version.c + $(ECHO) 'const char *svn_version(void) {' >> svn_version.c + $(ECHO) ' return SVN_Version;' >> svn_version.c + $(ECHO) '}' >> svn_version.c + +libcommon_a_SOURCES = cidr.c err.c list.c cache.c services.c get.c \ + fakepcap.c fakepcapnav.c fakepoll.c xX.c utils.c \ + timer.c svn_version.c abort.c sendpacket.c \ + dlt_names.c mac.c interface.c rdtsc.c + +if ENABLE_TCPDUMP +libcommon_a_SOURCES += tcpdump.c +endif + +AM_CFLAGS = -I.. -I../.. $(LNAV_CFLAGS) @LDNETINC@ + +libcommon_a_LIBADD = ../../lib/libstrl.a + +noinst_HEADERS = cidr.h err.h list.h cache.h services.h get.h \ + fakepcap.h fakepcapnav.h fakepoll.h xX.h utils.h \ + tcpdump.h timer.h abort.h pcap_dlt.h sendpacket.h \ + dlt_names.h mac.h interface.h rdtsc.h + +MOSTLYCLEANFILES = *~ + +MAINTAINERCLEANFILES = Makefile.in svn_version.c diff --git a/src/common/Makefile.in b/src/common/Makefile.in new file mode 100644 index 0000000..1307259 --- /dev/null +++ b/src/common/Makefile.in @@ -0,0 +1,559 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +@ENABLE_TCPDUMP_TRUE@am__append_1 = tcpdump.c +subdir = src/common +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/src/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +LIBRARIES = $(noinst_LIBRARIES) +ARFLAGS = cru +libcommon_a_AR = $(AR) $(ARFLAGS) +libcommon_a_DEPENDENCIES = ../../lib/libstrl.a +am__libcommon_a_SOURCES_DIST = cidr.c err.c list.c cache.c services.c \ + get.c fakepcap.c fakepcapnav.c fakepoll.c xX.c utils.c timer.c \ + svn_version.c abort.c sendpacket.c dlt_names.c mac.c \ + interface.c rdtsc.c tcpdump.c +@ENABLE_TCPDUMP_TRUE@am__objects_1 = tcpdump.$(OBJEXT) +am_libcommon_a_OBJECTS = cidr.$(OBJEXT) err.$(OBJEXT) list.$(OBJEXT) \ + cache.$(OBJEXT) services.$(OBJEXT) get.$(OBJEXT) \ + fakepcap.$(OBJEXT) fakepcapnav.$(OBJEXT) fakepoll.$(OBJEXT) \ + xX.$(OBJEXT) utils.$(OBJEXT) timer.$(OBJEXT) \ + svn_version.$(OBJEXT) abort.$(OBJEXT) sendpacket.$(OBJEXT) \ + dlt_names.$(OBJEXT) mac.$(OBJEXT) interface.$(OBJEXT) \ + rdtsc.$(OBJEXT) $(am__objects_1) +libcommon_a_OBJECTS = $(am_libcommon_a_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src +depcomp = $(SHELL) $(top_srcdir)/config/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libcommon_a_SOURCES) +DIST_SOURCES = $(am__libcommon_a_SOURCES_DIST) +HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOGEN = @AUTOGEN@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CUT = @CUT@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DMALLOC_LIB = @DMALLOC_LIB@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +GROFF = @GROFF@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LDNETINC = @LDNETINC@ +LDNETLIB = @LDNETLIB@ +LIBOBJS = @LIBOBJS@ +LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@ +LIBOPTS_DIR = @LIBOPTS_DIR@ +LIBOPTS_LDADD = @LIBOPTS_LDADD@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LNAVLIB = @LNAVLIB@ +LNAV_CFLAGS = @LNAV_CFLAGS@ +LN_S = @LN_S@ +LPCAPINC = @LPCAPINC@ +LPCAPLIB = @LPCAPLIB@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@ +PRINTF = @PRINTF@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TCPREPLAY_RELEASE = @TCPREPLAY_RELEASE@ +TCPREPLAY_VERSION = @TCPREPLAY_VERSION@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +debug_flag = @debug_flag@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +nic1 = @nic1@ +nic2 = @nic2@ +oldincludedir = @oldincludedir@ +pcncfg = @pcncfg@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +tcpdump_path = @tcpdump_path@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ + +# $Id: Makefile.am 1621 2006-11-09 07:01:37Z aturner $ +noinst_LIBRARIES = libcommon.a +BUILT_SOURCES = svn_version.c +libcommon_a_SOURCES = cidr.c err.c list.c cache.c services.c get.c \ + fakepcap.c fakepcapnav.c fakepoll.c xX.c utils.c timer.c \ + svn_version.c abort.c sendpacket.c dlt_names.c mac.c \ + interface.c rdtsc.c $(am__append_1) +AM_CFLAGS = -I.. -I../.. $(LNAV_CFLAGS) @LDNETINC@ +libcommon_a_LIBADD = ../../lib/libstrl.a +noinst_HEADERS = cidr.h err.h list.h cache.h services.h get.h \ + fakepcap.h fakepcapnav.h fakepoll.h xX.h utils.h \ + tcpdump.h timer.h abort.h pcap_dlt.h sendpacket.h \ + dlt_names.h mac.h interface.h rdtsc.h + +MOSTLYCLEANFILES = *~ +MAINTAINERCLEANFILES = Makefile.in svn_version.c +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/common/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/common/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *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);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libcommon.a: $(libcommon_a_OBJECTS) $(libcommon_a_DEPENDENCIES) + -rm -f libcommon.a + $(libcommon_a_AR) libcommon.a $(libcommon_a_OBJECTS) $(libcommon_a_LIBADD) + $(RANLIB) libcommon.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/abort.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cache.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cidr.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dlt_names.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/err.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fakepcap.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fakepcapnav.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fakepoll.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/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)/rdtsc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sendpacket.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/services.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/svn_version.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpdump.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timer.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@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am +all-am: Makefile $(LIBRARIES) $(HEADERS) +installdirs: +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: all check install install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLIBRARIES ctags 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 uninstall uninstall-am + + +svn_version.c: + $(ECHO) -n 'const char SVN_Version[] = "' > svn_version.c + svnversion -n ../.. >> svn_version.c + $(ECHO) '";' >> svn_version.c + $(ECHO) 'const char *svn_version(void) {' >> svn_version.c + $(ECHO) ' return SVN_Version;' >> svn_version.c + $(ECHO) '}' >> svn_version.c + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/common/abort.c b/src/common/abort.c new file mode 100644 index 0000000..37d730f --- /dev/null +++ b/src/common/abort.c @@ -0,0 +1,92 @@ +/* $Id: abort.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2005-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "defines.h" +#include "common.h" + +#include +#include + +extern volatile int didsig; +extern COUNTER bytes_sent, pkts_sent, failed; +extern struct timeval begin, end; + +#ifdef DEBUG +extern int debug; +#endif + + +/** + * we've got a race condition, this is our workaround + */ +void +catcher(int signo) +{ + /* stdio in signal handlers causes a race condition, instead set a flag */ + if (signo == SIGINT) + didsig = 1; +} + +/** + * when we're sending only one packet at a time via + * then there's no race and we can quit now + * also called when didsig is set + */ +void +break_now(int signo) +{ + + if (signo == SIGINT || didsig) { + printf("\n"); + +/* +#ifdef ENABLE_VERBOSE + if (tcpdump.pid) + if (kill(tcpdump.pid, SIGTERM) != 0) + kill(tcpdump.pid, SIGKILL); +#endif +*/ + packet_stats(&begin, &end, bytes_sent, pkts_sent, failed); + exit(1); + } +} + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + + diff --git a/src/common/abort.h b/src/common/abort.h new file mode 100644 index 0000000..1024525 --- /dev/null +++ b/src/common/abort.h @@ -0,0 +1,49 @@ +/* $Id: abort.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2005-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __ABORT_H__ +#define __ABORT_H__ + +void catcher(int signo); +void break_now(int signo); + +#endif + + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + diff --git a/src/common/cache.c b/src/common/cache.c new file mode 100644 index 0000000..e747895 --- /dev/null +++ b/src/common/cache.c @@ -0,0 +1,379 @@ +/* $Id: cache.c 2424 2010-03-16 05:33:03Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "defines.h" +#include "common.h" + + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef DEBUG +extern int debug; +#endif + +static tcpr_cache_t *new_cache(void); + +/** + * Takes a single char and returns a ptr to a string representation of the + * 8 bits that make up that char. Use BIT_STR() to print it out + */ +#ifdef DEBUG +static char * +byte2bits(char byte, char *bitstring) { + int i = 1, j = 7; + + for (i = 1; i <= 255; i = i << 1) { + if (byte & i) + bitstring[j] = '\061'; + j--; + } + + return bitstring; +} +#endif + +/** + * simple function to read in a cache file created with tcpprep this let's us + * be really damn fast in picking an interface to send the packet out returns + * number of cache entries read + * + * now also checks for the cache magic and version + */ + +COUNTER +read_cache(char **cachedata, const char *cachefile, char **comment) +{ + int cachefd; + tcpr_cache_file_hdr_t header; + ssize_t read_size = 0; + COUNTER cache_size = 0; + + /* open the file or abort */ + if ((cachefd = open(cachefile, O_RDONLY)) == -1) + errx(-1, "unable to open %s:%s", cachefile, strerror(errno)); + + /* read the cache header and determine compatibility */ + if ((read_size = read(cachefd, &header, sizeof(header))) < 0) + errx(-1, "unable to read from %s:%s,", cachefile, strerror(errno)); + + if (read_size < (ssize_t)sizeof(header)) + errx(-1, "Cache file %s doesn't contain a full header", cachefile); + + /* verify our magic: tcpprep\0 */ + if (memcmp(header.magic, CACHEMAGIC, sizeof(CACHEMAGIC)) != 0) + errx(-1, "Unable to process %s: not a tcpprep cache file", cachefile); + + /* verify version */ + if (atoi(header.version) != atoi(CACHEVERSION)) + errx(-1, "Unable to process %s: cache file version missmatch", + cachefile); + + /* read the comment */ + header.comment_len = ntohs(header.comment_len); + *comment = (char *)safe_malloc(header.comment_len + 1); + + dbgx(1, "Comment length: %d", header.comment_len); + + if ((read_size = read(cachefd, *comment, header.comment_len)) + != header.comment_len) + errx(-1, "Unable to read %d bytes of data for the comment (%zu) %s", + header.comment_len, read_size, + read_size == -1 ? strerror(read_size) : ""); + + dbgx(1, "Cache file comment: %s", *comment); + + /* malloc our cache block */ + header.num_packets = ntohll(header.num_packets); + header.packets_per_byte = ntohs(header.packets_per_byte); + cache_size = header.num_packets / header.packets_per_byte; + + /* deal with any remainder, becuase above divsion is integer */ + if (header.num_packets % header.packets_per_byte) + cache_size ++; + + dbgx(1, "Cache file contains %llu packets in %llu bytes", + header.num_packets, cache_size); + + dbgx(1, "Cache uses %d packets per byte", header.packets_per_byte); + + *cachedata = (char *)safe_malloc(cache_size); + + /* read in the cache */ + if ((COUNTER)(read_size = read(cachefd, *cachedata, cache_size)) + != cache_size) + errx(-1, "Cache data length (%ld bytes) doesn't match " + "cache header (" COUNTER_SPEC " bytes)", read_size, cache_size); + + dbgx(1, "Loaded in %llu packets from cache.", header.num_packets); + + close(cachefd); + return (header.num_packets); +} + + +/** + * writes out the cache file header, comment and then the + * contents of *cachedata to out_file and then returns the number + * of cache entries written + */ +COUNTER +write_cache(tcpr_cache_t * cachedata, const int out_file, COUNTER numpackets, + char *comment) +{ + tcpr_cache_t *mycache = NULL; + tcpr_cache_file_hdr_t *cache_header = NULL; + u_int32_t chars, last = 0; + COUNTER packets = 0; + ssize_t written = 0; + + assert(cachedata); + assert(out_file); + + /* write a header to our file */ + cache_header = (tcpr_cache_file_hdr_t *) + safe_malloc(sizeof(tcpr_cache_file_hdr_t)); + strncpy(cache_header->magic, CACHEMAGIC, strlen(CACHEMAGIC)); + strncpy(cache_header->version, CACHEVERSION, strlen(CACHEVERSION)); + cache_header->packets_per_byte = htons(CACHE_PACKETS_PER_BYTE); + cache_header->num_packets = htonll((u_int64_t)numpackets); + + /* we can't strlen(NULL) so ... */ + if (comment != NULL) { + cache_header->comment_len = htons((u_int16_t)strlen(comment)); + } else { + cache_header->comment_len = 0; + } + + written = write(out_file, cache_header, sizeof(tcpr_cache_file_hdr_t)); + dbgx(1, "Wrote %zu bytes of cache file header", written); + + if (written != sizeof(tcpr_cache_file_hdr_t)) + errx(-1, "Only wrote %zu of %zu bytes of the cache file header!\n%s", + written, sizeof(tcpr_cache_file_hdr_t), + written == -1 ? strerror(errno) : ""); + + /* don't write comment if there is none */ + if (comment != NULL) { + written = write(out_file, comment, strlen(comment)); + dbgx(1, "Wrote %zu bytes of comment", written); + + if (written != (ssize_t)strlen(comment)) + errx(-1, "Only wrote %zu of %zu bytes of the comment!\n%s", + written, strlen(comment), + written == -1 ? strerror(errno) : ""); + } + + mycache = cachedata; + + while (!last) { + /* increment total packets */ + packets += mycache->packets; + + /* calculate how many chars to write */ + chars = mycache->packets / CACHE_PACKETS_PER_BYTE; + if (mycache->packets % CACHE_PACKETS_PER_BYTE) { + chars++; + dbgx(1, "Bumping up to the next byte: %d %% %d", mycache->packets, + CACHE_PACKETS_PER_BYTE); + } + + /* write to file, and verify it wrote properly */ + written = write(out_file, mycache->data, chars); + dbgx(1, "Wrote %zu bytes of cache data", written); + if (written != (ssize_t)chars) + errx(-1, "Only wrote %zu of %i bytes to cache file!", written, chars); + + /* + * if that was the last, stop processing, otherwise wash, + * rinse, repeat + */ + if (mycache->next != NULL) { + mycache = mycache->next; + } + else { + last = 1; + } + } + /* return number of packets written */ + return (packets); +} + +/** + * mallocs a new CACHE struct all pre-set to sane defaults + */ + +static tcpr_cache_t * +new_cache(void) +{ + tcpr_cache_t *newcache; + + /* malloc mem */ + newcache = (tcpr_cache_t *)safe_malloc(sizeof(tcpr_cache_t)); + return (newcache); +} + +/** + * adds the cache data for a packet to the given cachedata + */ + +tcpr_dir_t +add_cache(tcpr_cache_t ** cachedata, const int send, const tcpr_dir_t interface) +{ + static tcpr_cache_t *lastcache = NULL; + u_char *byte = NULL; + u_int32_t bit; + tcpr_dir_t result = TCPR_DIR_ERROR; + COUNTER index; +#ifdef DEBUG + char bitstring[9] = EIGHT_ZEROS; +#endif + + assert(cachedata); + + /* first run? malloc our first entry, set bit count to 0 */ + if (*cachedata == NULL) { + *cachedata = new_cache(); + lastcache = *cachedata; + } + else { + /* check to see if this is the last bit in this struct */ + if ((lastcache->packets + 1) > (CACHEDATASIZE * CACHE_PACKETS_PER_BYTE)) { + /* + * if so, we have to malloc a new one and set bit to 0 + */ + dbg(1, "Adding to cachedata linked list"); + lastcache->next = new_cache(); + lastcache = lastcache->next; + } + } + + /* always increment our bit count */ + lastcache->packets++; + dbgx(1, "Cache array packet %d", lastcache->packets); + + /* send packet ? */ + if (send == SEND) { + index = (lastcache->packets - 1) / (COUNTER)CACHE_PACKETS_PER_BYTE; + bit = (((lastcache->packets - 1) % (COUNTER)CACHE_PACKETS_PER_BYTE) * + (COUNTER)CACHE_BITS_PER_PACKET) + 1; + dbgx(3, "Bit: %d", bit); + + byte = (u_char *) & lastcache->data[index]; + *byte += (u_char) (1 << bit); + + dbgx(2, "set send bit: byte " COUNTER_SPEC " = 0x%x", index, *byte); + + /* if true, set low order bit. else, do squat */ + if (interface == TCPR_DIR_C2S) { + *byte += (u_char)(1 << (bit - 1)); + + dbgx(2, "set interface bit: byte " COUNTER_SPEC " = 0x%x", index, *byte); + result = TCPR_DIR_C2S; + } + else { + dbgx(2, "don't set interface bit: byte " COUNTER_SPEC " = 0x%x", index, *byte); + result = TCPR_DIR_S2C; + } + +#ifdef DEBUG + /* + * only build the byte string when not in debug mode since + * the calculation is a bit expensive + */ + dbgx(3, "Current cache byte: %c%c%c%c%c%c%c%c", + BIT_STR(byte2bits(*byte, bitstring))); +#endif + } + else { + dbg(1, "not setting send bit"); + result = TCPR_DIR_NOSEND; + } + + return result; +} + + +/** + * returns the action for a given packet based on the CACHE + */ +tcpr_dir_t +check_cache(char *cachedata, COUNTER packetid) +{ + COUNTER index = 0; + u_int32_t bit; + + assert(cachedata); + + if (packetid == 0) + err(-1, "packetid must be > 0"); + + index = (packetid - 1) / (COUNTER)CACHE_PACKETS_PER_BYTE; + bit = (u_int32_t)(((packetid - 1) % (COUNTER)CACHE_PACKETS_PER_BYTE) * + (COUNTER)CACHE_BITS_PER_PACKET) + 1; + +#ifdef DEBUG + dbgx(3, "Index: " COUNTER_SPEC "\tBit: %d\tByte: %hhu\tMask: %hhu", index, bit, + cachedata[index], (cachedata[index] & (char)(1 << bit))); +#endif + + if (!(cachedata[index] & (char)(1 << bit))) { + return TCPR_DIR_NOSEND; + } + + /* go back a bit to get the interface */ + bit--; + if (cachedata[index] & (char)(1 << bit)) { + return TCPR_DIR_C2S; + } + else { + return TCPR_DIR_S2C; + } + + return TCPR_DIR_ERROR; +} + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + diff --git a/src/common/cache.h b/src/common/cache.h new file mode 100644 index 0000000..6f7759c --- /dev/null +++ b/src/common/cache.h @@ -0,0 +1,125 @@ +/* $Id: cache.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __CACHE_H__ +#define __CACHE_H__ + +#define CACHEMAGIC "tcpprep" +#define CACHEVERSION "04" +#define CACHEDATASIZE 255 +#define CACHE_PACKETS_PER_BYTE 4 /* number of packets / byte */ +#define CACHE_BITS_PER_PACKET 2 /* number of bits / packet */ + +#define SEND 1 +#define DONT_SEND 0 + +/* + * CACHEVERSION History: + * 01 - Inital release. 1 bit of data/packet (primary or secondary nic) + * 02 - 2 bits of data/packet (drop/send & primary or secondary nic) + * 03 - Write integers in network-byte order + * 04 - Increase num_packets from 32 to 64 bit integer + */ + +struct tcpr_cache_s { + char data[CACHEDATASIZE]; + unsigned int packets; /* number of packets tracked in data */ + struct tcpr_cache_s *next; +}; +typedef struct tcpr_cache_s tcpr_cache_t; + +/* + * Each byte in cache_type.data represents CACHE_PACKETS_PER_BYTE (4) number of packets + * Each packet has CACHE_BITS_PER_PACKETS (2) bits of data. + * High Bit: 1 = send, 0 = don't send + * Low Bit: 1 = primary interface, 0 = secondary interface +*/ + +/* + * cache_file_header Data structure defining a file as a tcpprep cache file + * and it's version + * + * If you need to enhance this struct, do so AFTER the version field and be sure + * to increment CACHEVERSION + */ +struct tcpr_cache_file_hdr_s { + char magic[8]; + char version[4]; + /* begin version 2 features */ + /* version 3 puts everything in network-byte order */ + /* version 4 makes num_packets a 64 bit int */ + u_int64_t num_packets; /* total # of packets in file */ + u_int16_t packets_per_byte; + u_int16_t comment_len; /* how long is the user comment? */ +} __attribute__((__packed__)); + +typedef struct tcpr_cache_file_hdr_s tcpr_cache_file_hdr_t; + +enum tcpr_dir_e { + TCPR_DIR_ERROR = -1, + TCPR_DIR_NOSEND = 0, + TCPR_DIR_C2S = 1, /* aka PRIMARY */ + TCPR_DIR_S2C = 2 /* aka SECONDARY */ +}; +typedef enum tcpr_dir_e tcpr_dir_t; + + +COUNTER write_cache(tcpr_cache_t *, const int, COUNTER, char *); +tcpr_dir_t add_cache(tcpr_cache_t **, const int, const tcpr_dir_t); +COUNTER read_cache(char **, const char *, char **); +tcpr_dir_t check_cache(char *, COUNTER); + +/* return values for check_cache +#define CACHE_ERROR -1 +#define CACHE_NOSEND 0 // NULL +#define CACHE_PRIMARY 1 +#define CACHE_SECONDARY 2 +*/ + + +/* macro to change a bitstring to 8 bits */ +#define BIT_STR(x) x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7] + +/* string of 8 zeros */ +#define EIGHT_ZEROS "\060\060\060\060\060\060\060\060" + +#endif + + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + diff --git a/src/common/cidr.c b/src/common/cidr.c new file mode 100644 index 0000000..ef917ee --- /dev/null +++ b/src/common/cidr.c @@ -0,0 +1,708 @@ +/* $Id: cidr.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#include "config.h" +#include "defines.h" +#include "common.h" +#include "lib/strlcpy.h" + +#include +#include +#include +/* required for inet_aton() */ +#include +#include +#include + + +#ifdef DEBUG +extern int debug; +#endif + +static tcpr_cidr_t *cidr2cidr(char *); + +/** + * prints to the given fd all the entries in mycidr + */ +void +print_cidr(tcpr_cidr_t * mycidr) +{ + tcpr_cidr_t *cidr_ptr; + + fprintf(stderr, "Cidr List: "); + + cidr_ptr = mycidr; + while (cidr_ptr != NULL) { + /* print it */ + fprintf(stderr, "%s/%d, ", get_cidr2name(cidr_ptr, RESOLVE), + cidr_ptr->masklen); + + /* go to the next */ + if (cidr_ptr->next != NULL) { + cidr_ptr = cidr_ptr->next; + } + else { + break; + } + } + fprintf(stderr, "\n"); +} + +/** + * deletes all entries in a cidr and destroys the datastructure + */ +void +destroy_cidr(tcpr_cidr_t * cidr) +{ + + if (cidr != NULL) + if (cidr->next != NULL) + destroy_cidr(cidr->next); + + safe_free(cidr); + return; + +} + +/** + * adds a new tcpr_cidr_t entry to cidrdata + */ +void +add_cidr(tcpr_cidr_t ** cidrdata, tcpr_cidr_t ** newcidr) +{ + tcpr_cidr_t *cidr_ptr; + dbg(1, "Running new_cidr()"); + + if (*cidrdata == NULL) { + *cidrdata = *newcidr; + } else { + cidr_ptr = *cidrdata; + + while (cidr_ptr->next != NULL) + cidr_ptr = cidr_ptr->next; + + cidr_ptr->next = *newcidr; + } +} + +/** + * takes in an IP and masklen, and returns a string in + * cidr format: x.x.x.x/y. This malloc's memory. + */ +u_char * +ip2cidr(const unsigned long ip, const int masklen) +{ + u_char *network; + char mask[3]; + + network = (u_char *)safe_malloc(20); + + strlcpy((char *)network, (char *)get_addr2name4(ip, RESOLVE), + sizeof(network)); + + strcat((char *)network, "/"); + if (masklen < 10) { + snprintf(mask, 1, "%d", masklen); + strncat((char *)network, mask, 1); + } else { + snprintf(mask, 2, "%d", masklen); + strncat((char *)network, mask, 2); + } + + return (network); +} + +/** + * Mallocs and sets to sane defaults a tcpr_cidr_t structure + */ + +tcpr_cidr_t * +new_cidr(void) +{ + tcpr_cidr_t *newcidr; + + newcidr = (tcpr_cidr_t *)safe_malloc(sizeof(tcpr_cidr_t)); + + memset(newcidr, '\0', sizeof(tcpr_cidr_t)); + newcidr->masklen = 99; + newcidr->next = NULL; + + return (newcidr); +} + +/** + * Creates a new tcpr_cidrmap_t structure. Malloc's memory + */ +tcpr_cidrmap_t * +new_cidr_map(void) +{ + tcpr_cidrmap_t *new; + + new = (tcpr_cidrmap_t *)safe_malloc(sizeof(tcpr_cidrmap_t)); + + memset(new, '\0', sizeof(tcpr_cidrmap_t)); + new->next = NULL; + + return (new); +} + + +/** + * Converts a single cidr (string) in the form of x.x.x.x/y into a + * tcpr_cidr_t structure. Will malloc the tcpr_cidr_t structure. + */ +static tcpr_cidr_t * +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]; + int family; + char* p; + + assert(cidr); + assert(strlen(cidr) <= EBUF_SIZE); + + newcidr = new_cidr(); + + for (p = cidr; *p; ++p) { + if (*p == '#') { + *p = ':'; + } else if (*p == ']') { + *p = 0; + break; + } + } + + /* + * scan it, and make sure it scanned correctly, also copy over the + * masklen + */ + count = sscanf(cidr, "%u.%u.%u.%u/%d", &octets[0], &octets[1], + &octets[2], &octets[3], &newcidr->masklen); + + if (count == 4) { + newcidr->masklen = 32; + family = AF_INET; + } else if (count == 5) { + family = AF_INET; + } else { + p = strstr(cidr, "/"); + if (p) { + *p = 0; + ++p; + count = sscanf(p, "%d", &newcidr->masklen); + } else { + newcidr->masklen = 128; + } + + if (newcidr->masklen < 0 || newcidr->masklen > 128) + goto error; + + /* skip past the opening [ */ + if (*cidr == '[') + cidr ++; + + if (get_name2addr6(cidr, RESOLVE, &newcidr->u.network6) > 0) { + family = AF_INET6; + } else { + goto error; + } + } + + if (family == AF_INET) { + /* masklen better be 0 =< masklen <= 32 */ + if (newcidr->masklen > 32) + goto error; + + /* copy in the ip address */ + memset(networkip, '\0', 16); + for (count = 0; count < 4; count++) { + if (octets[count] > 255) + goto error; + + snprintf(tempoctet, sizeof(octets[count]), "%d", octets[count]); + strcat(networkip, tempoctet); + /* we don't want a '.' at the end of the last octet */ + if (count < 3) + strcat(networkip, "."); + } + + /* copy over the network address and return */ +#ifdef HAVE_INET_ATON + inet_aton(networkip, (struct in_addr *)&newcidr->u.network); +#elif HAVE_INET_ADDR + newcidr->network = inet_addr(networkip); +#endif + } else if (family == AF_INET6) { + /* Everything's done */ + } else { + goto error; + } + + newcidr->family = family; + return (newcidr); + + /* we only get here on error parsing input */ +error: + memset(ebuf, '\0', EBUF_SIZE); + strcpy(ebuf, "Unable to parse as a vaild CIDR: "); + strlcat(ebuf, cidr, EBUF_SIZE); + errx(-1, "%s", ebuf); + return NULL; +} + +static void +mask_cidr6(char **cidrin, char* delim) +{ + char *p; + + if (**cidrin == '[' && *delim == ':') { + ++*cidrin; + /* make strtok happy */ + for (p = *cidrin; *p && *p != ']'; ++p) { + if (*p == ':') { + *p = '#'; + } + } + } +} + +/** + * parses a list of tcpr_cidr_t's input from the user which should be in the form + * of x.x.x.x/y,x.x.x.x/y... + * returns 1 for success, or fails to return on failure (exit 1) + * since we use strtok to process cidr, it gets zeroed out. + */ +int +parse_cidr(tcpr_cidr_t ** cidrdata, char *cidrin, char *delim) +{ + tcpr_cidr_t *cidr_ptr; /* ptr to current cidr record */ + char *network = NULL; + char *token = NULL; + + mask_cidr6(&cidrin, delim); + + /* first itteration of input using strtok */ + network = strtok_r(cidrin, delim, &token); + + *cidrdata = cidr2cidr(network); + cidr_ptr = *cidrdata; + + /* do the same with the rest of the input */ + while (1) { + if (token) + mask_cidr6(&token, delim); + + network = strtok_r(NULL, delim, &token); + /* if that was the last CIDR, then kickout */ + if (network == NULL) + break; + + /* next record */ + cidr_ptr->next = cidr2cidr(network); + cidr_ptr = cidr_ptr->next; + } + return 1; + +} + +/** + * parses a pair of IP addresses: : and processes it like: + * -N 0.0.0.0/0: -N 0.0.0.0/0: + * returns 1 for success or returns 0 on failure + * since we use strtok to process optarg, it gets zeroed out + */ +int +parse_endpoints(tcpr_cidrmap_t ** cidrmap1, tcpr_cidrmap_t ** cidrmap2, const char *optarg) +{ +#define NEWMAP_LEN (INET6_ADDRSTRLEN * 2) + char *map = NULL, newmap[NEWMAP_LEN]; + char *token = NULL; + char *string; + char *p; + + string = safe_strdup(optarg); + + if (*string == '[') { + /* ipv6 mode */ + memset(newmap, '\0', NEWMAP_LEN); + p = strstr(string, "]:["); + if (!p) + return 0; + + *p = 0; + strlcpy(newmap, "[::/0]:", NEWMAP_LEN); + strlcat(newmap, string, NEWMAP_LEN); + strlcat(newmap, "]", NEWMAP_LEN); + + if (! parse_cidr_map(cidrmap1, newmap)) + return 0; + + /* do again with the second IP */ + memset(newmap, '\0', NEWMAP_LEN); + strlcpy(newmap, "[::/0]:", NEWMAP_LEN); + strlcat(newmap, p + 2, NEWMAP_LEN); + + if (! parse_cidr_map(cidrmap2, newmap)) + return 0; + + } else { + /* ipv4 mode */ + memset(newmap, '\0', NEWMAP_LEN); + map = strtok_r(string, ":", &token); + + strlcpy(newmap, "0.0.0.0/0:", NEWMAP_LEN); + strlcat(newmap, map, NEWMAP_LEN); + if (! parse_cidr_map(cidrmap1, newmap)) + return 0; + + /* do again with the second IP */ + memset(newmap, '\0', NEWMAP_LEN); + map = strtok_r(NULL, ":", &token); + + strlcpy(newmap, "0.0.0.0/0:", NEWMAP_LEN); + strlcat(newmap, map, NEWMAP_LEN); + if (! parse_cidr_map(cidrmap2, newmap)) + return 0; + } + + safe_free(string); + return 1; /* success */ +} + + +/** + * parses a list of tcpr_cidrmap_t's input from the user which should be in the form + * of x.x.x.x/y:x.x.x.x/y,... + * IPv6 syntax: [addr/y]:[addr/y],... + * returns 1 for success, or returns 0 on failure + * since we use strtok to process optarg, it gets zeroed out. + */ +int +parse_cidr_map(tcpr_cidrmap_t **cidrmap, const char *optarg) +{ + tcpr_cidr_t *cidr = NULL; + char *map = NULL; + char *token = NULL, *string = NULL; + tcpr_cidrmap_t *ptr; + + string = safe_strdup(optarg); + + /* first iteration */ + map = strtok_r(string, ",", &token); + if (! parse_cidr(&cidr, map, ":")) + return 0; + + /* must return a linked list of two */ + if (cidr->next == NULL) + return 0; + + /* copy over */ + *cidrmap = new_cidr_map(); + ptr = *cidrmap; + + ptr->from = cidr; + ptr->to = cidr->next; + ptr->from->next = NULL; + + /* do the same with the reset of the input */ + while(1) { + map = strtok_r(NULL, ",", &token); + if (map == NULL) + break; + + if (! parse_cidr(&cidr, map, ":")) + return 0; + + /* must return a linked list of two */ + if (cidr->next == NULL) + return 0; + + /* copy over */ + ptr->next = new_cidr_map(); + ptr = ptr->next; + ptr->from = cidr; + ptr->to = cidr->next; + ptr->from->next = NULL; + } + + safe_free(string); + return 1; /* success */ +} + +/** + * checks to see if the ip address is in the cidr + * returns 1 for true, 0 for false + */ +int +ip_in_cidr(const tcpr_cidr_t * mycidr, const unsigned long ip) +{ + unsigned long ipaddr = 0, network = 0, mask = 0; + int ret = 0; +#ifdef DEBUG + char netstr[20]; +#endif + + if (mycidr->family != AF_INET) + return 0; + + /* always return 1 if 0.0.0.0/0 */ + if (mycidr->masklen == 0 && mycidr->u.network == 0) + return 1; + + mask = ~0; /* turn on all the bits */ + + /* shift over by the correct number of bits */ + mask = mask << (32 - mycidr->masklen); + + /* apply the mask to the network and ip */ + ipaddr = ntohl(ip) & mask; + + network = htonl(mycidr->u.network) & mask; + + +#ifdef DEBUG + /* copy this for debug purposes, since it's not re-entrant */ + strlcpy(netstr, get_addr2name4(htonl(mycidr->u.network), RESOLVE), 20); +#endif + + /* if they're the same, then ip is in network */ + if (network == ipaddr) { +#ifdef DEBUG + dbgx(1, "The ip %s is inside of %s/%d", + get_addr2name4(ip, RESOLVE), netstr, mycidr->masklen); +#endif + ret = 1; + } else { +#ifdef DEBUG + dbgx(1, "The ip %s is not inside of %s/%d", + get_addr2name4(ip, RESOLVE), netstr, mycidr->masklen); +#endif + ret = 0; + } + return ret; + +} + +static int +ip6_addr_is_unspec(const struct tcpr_in6_addr *addr) +{ + return addr->tcpr_s6_addr32[0] == 0 && addr->tcpr_s6_addr32[1] == 0 && + addr->tcpr_s6_addr32[2] == 0 && addr->tcpr_s6_addr32[3] == 0; +} + +int +ip6_in_cidr(const tcpr_cidr_t * mycidr, const struct tcpr_in6_addr *addr) +{ + int ret = 0; +#ifdef DEBUG + char netstr[INET6_ADDRSTRLEN]; +#endif + int i, j, k; + + if (mycidr->family != AF_INET6) + return 0; + + /* always return 1 if ::/0 */ + if (mycidr->masklen == 0 && ip6_addr_is_unspec(addr)) + return 1; + + j = mycidr->masklen / 8; + + for (i = 0; i < j; i++) { + if (addr->tcpr_s6_addr[i] != mycidr->u.network6.tcpr_s6_addr[i]) { + ret = 0; + goto out; + } + } + + if ((k = mycidr->masklen % 8) == 0) { + ret = 1; + goto out; + } + + k = ~0 << (8 - k); + i = addr->tcpr_s6_addr[j] & k; + j = mycidr->u.network6.tcpr_s6_addr[j] & k; + ret = i == j; +out: + +#ifdef DEBUG + /* copy this for debug purposes, since it's not re-entrant */ + strlcpy(netstr, get_addr2name6(&mycidr->u.network6, RESOLVE), INET6_ADDRSTRLEN); +#endif + + /* if they're the same, then ip is in network */ + if (ret) { +#ifdef DEBUG + dbgx(1, "The ip %s is inside of %s/%d", + get_addr2name6(addr, RESOLVE), netstr, mycidr->masklen); +#endif + } else { +#ifdef DEBUG + dbgx(1, "The ip %s is not inside of %s/%d", + get_addr2name6(addr, RESOLVE), netstr, mycidr->masklen); +#endif + } + return ret; + +} + + +/** + * iterates over cidrdata to find if a given ip matches + * returns 1 for true, 0 for false + */ + +int +check_ip_cidr(tcpr_cidr_t * cidrdata, const unsigned long ip) +{ + tcpr_cidr_t *mycidr; + + /* if we have no cidrdata, of course it isn't in there + * this actually should happen occasionally, so don't put an assert here + */ + if (cidrdata == NULL) + return 1; + + mycidr = cidrdata; + + /* loop through cidr */ + while (1) { + + /* if match, return 1 */ + if (ip_in_cidr(mycidr, ip)) { + dbgx(3, "Found %s in cidr", get_addr2name4(ip, RESOLVE)); + return 1; + } + + /* check for next record */ + if (mycidr->next != NULL) { + mycidr = mycidr->next; + } else { + break; + } + } + + /* if we get here, no match */ + dbgx(3, "Didn't find %s in cidr", get_addr2name4(ip, RESOLVE)); + return 0; +} + +int +check_ip6_cidr(tcpr_cidr_t * cidrdata, const struct tcpr_in6_addr *addr) +{ + tcpr_cidr_t *mycidr; + + /* if we have no cidrdata, of course it isn't in there + * this actually should happen occasionally, so don't put an assert here + */ + if (cidrdata == NULL) { + return 1; + } + + mycidr = cidrdata; + + /* loop through cidr */ + while (1) { + + /* if match, return 1 */ + if (ip6_in_cidr(mycidr, addr)) { + dbgx(3, "Found %s in cidr", get_addr2name6(addr, RESOLVE)); + return 1; + } + + /* check for next record */ + if (mycidr->next != NULL) { + mycidr = mycidr->next; + } else { + break; + } + } + + /* if we get here, no match */ + dbgx(3, "Didn't find %s in cidr", get_addr2name6(addr, RESOLVE)); + return 0; +} + + +/** + * cidr2ip takes a tcpr_cidr_t and a delimiter + * and returns a string which lists all the IP addresses in the cidr + * deliminated by the given char + */ +char * +cidr2iplist(tcpr_cidr_t * cidr, char delim) +{ + char *list = NULL; + char ipaddr[16]; + u_int32_t size, addr, first, last, numips; + struct in_addr in; + + /* + * 16 bytes per IP + delim + * # of IP's = 2^(32-masklen) + */ + numips = 2; + for (int i = 2; i <= (32 - cidr->masklen); i++) + numips *= 2; + + size = 16 * numips; + + list = (char *)safe_malloc(size); + + memset(list, 0, size); + + /* first and last should not include network or broadcast */ + first = ntohl(cidr->u.network) + 1; + last = first + numips - 3; + + dbgx(1, "First: %u\t\tLast: %u", first, last); + + /* loop through all but the last one */ + for (addr = first; addr < last; addr++) { + in.s_addr = htonl(addr); + snprintf(ipaddr, 17, "%s%c", inet_ntoa(in), delim); + dbgx(2, "%s", ipaddr); + strlcat(list, ipaddr, size); + } + + /* last is a special case, end in \0 */ + in.s_addr = htonl(addr); + snprintf(ipaddr, 16, "%s", inet_ntoa(in)); + strlcat(list, ipaddr, size); + + return list; +} diff --git a/src/common/cidr.h b/src/common/cidr.h new file mode 100644 index 0000000..30761d4 --- /dev/null +++ b/src/common/cidr.h @@ -0,0 +1,83 @@ +/* $Id: cidr.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "cache.h" + +#ifndef __CIDR_H__ +#define __CIDR_H__ + +struct tcpr_cidr_s { + int family; /* AF_INET or AF_INET6 */ + union { + u_int32_t network; + struct tcpr_in6_addr network6; + } u; + int masklen; + struct tcpr_cidr_s *next; +}; + +typedef struct tcpr_cidr_s tcpr_cidr_t; + +struct tcpr_cidrmap_s { + tcpr_cidr_t *from; + tcpr_cidr_t *to; + struct tcpr_cidrmap_s *next; +}; +typedef struct tcpr_cidrmap_s tcpr_cidrmap_t; + +int ip_in_cidr(const tcpr_cidr_t *, const unsigned long); +int check_ip_cidr(tcpr_cidr_t *, const unsigned long); +int check_ip6_cidr(tcpr_cidr_t *, const struct tcpr_in6_addr *addr); +int parse_cidr(tcpr_cidr_t **, char *, char *delim); +int parse_cidr_map(tcpr_cidrmap_t **, const char *); +int parse_endpoints(tcpr_cidrmap_t **, tcpr_cidrmap_t **, const char *); +u_char *ip2cidr(const unsigned long, const int); +void add_cidr(tcpr_cidr_t **, tcpr_cidr_t **); +tcpr_cidr_t *new_cidr(void); +tcpr_cidrmap_t *new_cidr_map(void); +void destroy_cidr(tcpr_cidr_t *); +void print_cidr(tcpr_cidr_t *); +char *cidr2iplist(tcpr_cidr_t *, char); + +int ip6_in_cidr(const tcpr_cidr_t * mycidr, const struct tcpr_in6_addr *addr); +int check_ip6_cidr(tcpr_cidr_t *, const struct tcpr_in6_addr *addr); + +#endif + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + diff --git a/src/common/dlt_names.c b/src/common/dlt_names.c new file mode 100644 index 0000000..3b88920 --- /dev/null +++ b/src/common/dlt_names.c @@ -0,0 +1,511 @@ +/* $Id: dlt_names.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner + * All rights reserved. + * + * This file is generated by scripts/dlt2name.pl which converts your pcap-bpf.h + * header file which comes with libpcap into a header file + * which translates DLT values to their string names as well as a list of all + * of the available DLT types. + * + * Hence DO NOT EDIT THIS FILE! + * If your DLT type is not listed here, edit the %known hash in + * scripts/dlt2name.pl + * + * This file contains data which was taken from libpcap's pcap-bpf.h. + * The copyright/license is included below: + */ + + /*- + * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from the Stanford/CMU enet packet filter, + * (net/enet.c) distributed as part of 4.3BSD, and code contributed + * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence + * Berkeley Laboratory. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)bpf.h 7.1 (Berkeley) 5/7/91 + * + * @(#) $Header: /tcpdump/master/libpcap/pcap-bpf.h,v 1.34.2.6 2005/08/13 22:29:47 hannes Exp $ (LBL) + */ + + +#include + +/* DLT to descriptions */ +char *dlt2desc[] = { + "BSD loopback encapsulation", + "Ethernet (10Mb)", + "Experimental Ethernet (3Mb)", + "Amateur Radio AX.25", + "Proteon ProNET Token Ring", + "Chaos", + "IEEE 802 Networks", + "ARCNET, with BSD-style header", + "Serial Line IP", + "Point-to-point Protocol", + "FDDI", + "LLC-encapsulated ATM", + "raw IP", + "BSD/OS Serial Line IP", + "BSD/OS Point-to-point Protocol", + "BSD/OS Serial Line IP", + "BSD/OS Point-to-point Protocol", + "", + "", + "Linux Classical-IP over ATM", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "PPP over serial with HDLC encapsulation", + "PPP over Ethernet", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Cisco HDLC", + "IEEE 802.11 wireless", + "Unknown", + "BSD/OS Frame Relay", + "OpenBSD Loopback", + "", + "Unknown", + "Unknown", + "Unknown", + "Linux Cooked Sockets", + "Apple LocalTalk", + "Acorn Econet", + "OpenBSD IPFilter", + "OpenBSD PF Log/SuSE 6.3 LANE 802.3", + "Cisco IOS", + "802.11 Prism Header", + "802.11 Aironet Header", + "Siemens HiPath HDLC", + "IP over Fibre Channel", + "Solaris+SunATM", + "RapidIO", + "PCI Express", + "Xilinx Aurora link layer", + "802.11 plus radiotap radio header", + "Tazmen Sniffer Protocol", + "ARCNET", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "pseudo-header with various info, followed by MTP2", + "MTP2, without pseudo-header", + "MTP3, without pseudo-header or MTP2", + "SCCP, without pseudo-header or MTP2 or MTP3", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "802.11 plus AVS radio header", + "", + "", + "", + "", + "", + "GPRS LLC", + "GPF-T (ITU-T G.7041/Y.1303)", + "GPF-F (ITU-T G.7041/Y.1303)", + "", + "", + "", + "Ethernet", + "Packet-over-SONET", + "", + "", + "", + "", + NULL +}; + + +/* DLT to names */ +char *dlt2name[] = { + "DLT_NULL", + "DLT_EN10MB", + "DLT_EN3MB", + "DLT_AX25", + "DLT_PRONET", + "DLT_CHAOS", + "DLT_IEEE802", + "DLT_ARCNET", + "DLT_SLIP", + "DLT_PPP", + "DLT_FDDI", + "DLT_ATM_RFC1483", + "DLT_RAW", + "DLT_ENC", + "DLT_PPP_BSDOS", + "DLT_SLIP_BSDOS", + "DLT_PPP_BSDOS", + "DLT_OLD_PFLOG", + "DLT_PFSYNC", + "DLT_ATM_CLIP", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "DLT_REDBACK_SMARTEDGE", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "DLT_PPP_SERIAL", + "DLT_PPP_ETHER", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "DLT_SYMANTEC_FIREWALL", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "DLT_C_HDLC", + "DLT_IEEE802_11", + "Unknown", + "DLT_FRELAY", + "DLT_LOOP", + "DLT_ENC", + "Unknown", + "Unknown", + "Unknown", + "DLT_LINUX_SLL", + "DLT_LTALK", + "DLT_ECONET", + "DLT_IPFILTER", + "DLT_PFLOG", + "DLT_CISCO_IOS", + "DLT_PRISM_HEADER", + "DLT_AIRONET_HEADER", + "DLT_HHDLC", + "DLT_IP_OVER_FC", + "DLT_SUNATM", + "DLT_RIO", + "DLT_PCI_EXP", + "DLT_AURORA", + "DLT_IEEE802_11_RADIO", + "DLT_TZSP", + "DLT_ARCNET_LINUX", + "DLT_JUNIPER_MLPPP", + "DLT_JUNIPER_MLFR", + "DLT_JUNIPER_ES", + "DLT_JUNIPER_GGSN", + "DLT_JUNIPER_MFR", + "DLT_JUNIPER_ATM2", + "DLT_JUNIPER_SERVICES", + "DLT_JUNIPER_ATM1", + "DLT_APPLE_IP_OVER_IEEE1394", + "DLT_MTP2_WITH_PHDR", + "DLT_MTP2", + "DLT_MTP3", + "DLT_SCCP", + "DLT_DOCSIS", + "DLT_LINUX_IRDA", + "DLT_IBM_SP", + "DLT_IBM_SN", + "DLT_USER0", + "DLT_USER1", + "DLT_USER2", + "DLT_USER3", + "DLT_USER4", + "DLT_USER5", + "DLT_USER6", + "DLT_USER7", + "DLT_USER8", + "DLT_USER9", + "DLT_USER10", + "DLT_USER11", + "DLT_USER12", + "DLT_USER13", + "DLT_USER14", + "DLT_USER15", + "DLT_IEEE802_11_RADIO_AVS", + "DLT_JUNIPER_MONITOR", + "DLT_BACNET_MS_TP", + "DLT_PPP_PPPD", + "DLT_JUNIPER_PPPOE", + "DLT_JUNIPER_PPPOE_ATM", + "DLT_GPRS_LLC", + "DLT_GPF_T", + "DLT_GPF_F", + "DLT_GCOM_T1E1", + "DLT_GCOM_SERIAL", + "DLT_JUNIPER_PIC_PEER", + "DLT_ERF_ETH", + "DLT_ERF_POS", + "DLT_LINUX_LAPD", + "DLT_JUNIPER_ETHER", + "DLT_JUNIPER_PPP", + "DLT_JUNIPER_FRELAY", + "DLT_JUNIPER_CHDLC", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + "Unknown", + NULL +}; + diff --git a/src/common/dlt_names.h b/src/common/dlt_names.h new file mode 100644 index 0000000..df8c883 --- /dev/null +++ b/src/common/dlt_names.h @@ -0,0 +1,461 @@ +/* $Id: dlt_names.h 2423 2010-03-13 07:09:49Z aturner $ */ +/* + * Copyright (c) 2006-2010 Aaron Turner + * All rights reserved. + * + * This file is generated by scripts/dlt2name.pl which converts your pcap-bpf.h + * header file which comes with libpcap into a header file + * which translates DLT values to their string names as well as a list of all + * of the available DLT types. + * + * Hence DO NOT EDIT THIS FILE! + * If your DLT type is not listed here, edit the %known hash in + * scripts/dlt2name.pl + * + * This file contains data which was taken from libpcap's pcap-bpf.h. + * The copyright/license is included below: + */ + + /*- + * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from the Stanford/CMU enet packet filter, + * (net/enet.c) distributed as part of 4.3BSD, and code contributed + * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence + * Berkeley Laboratory. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)bpf.h 7.1 (Berkeley) 5/7/91 + * + * @(#) $Header: /tcpdump/master/libpcap/pcap-bpf.h,v 1.34.2.6 2005/08/13 22:29:47 hannes Exp $ (LBL) + */ + + +/* include all the DLT types form pcap-bpf.h */ + +extern const char *dlt2desc[]; +extern const char *dlt2name[]; +#define DLT2DESC_LEN 181 +#define DLT2NAME_LEN 181 + +#ifndef DLT_NULL +#define DLT_NULL 0 +#endif + +#ifndef DLT_EN10MB +#define DLT_EN10MB 1 +#endif + +#ifndef DLT_EN3MB +#define DLT_EN3MB 2 +#endif + +#ifndef DLT_AX25 +#define DLT_AX25 3 +#endif + +#ifndef DLT_PRONET +#define DLT_PRONET 4 +#endif + +#ifndef DLT_CHAOS +#define DLT_CHAOS 5 +#endif + +#ifndef DLT_IEEE802 +#define DLT_IEEE802 6 +#endif + +#ifndef DLT_ARCNET +#define DLT_ARCNET 7 +#endif + +#ifndef DLT_SLIP +#define DLT_SLIP 8 +#endif + +#ifndef DLT_PPP +#define DLT_PPP 9 +#endif + +#ifndef DLT_FDDI +#define DLT_FDDI 10 +#endif + +#ifndef DLT_ATM_RFC1483 +#define DLT_ATM_RFC1483 11 +#endif + +#ifndef DLT_RAW +#define DLT_RAW 12 +#endif + +#ifndef DLT_ENC +#define DLT_ENC 13 +#endif + +#ifndef DLT_PPP_BSDOS +#define DLT_PPP_BSDOS 14 +#endif + +#ifndef DLT_SLIP_BSDOS +#define DLT_SLIP_BSDOS 15 +#endif + +#ifndef DLT_PPP_BSDOS +#define DLT_PPP_BSDOS 16 +#endif + +#ifndef DLT_OLD_PFLOG +#define DLT_OLD_PFLOG 17 +#endif + +#ifndef DLT_PFSYNC +#define DLT_PFSYNC 18 +#endif + +#ifndef DLT_ATM_CLIP +#define DLT_ATM_CLIP 19 +#endif + +#ifndef DLT_REDBACK_SMARTEDGE +#define DLT_REDBACK_SMARTEDGE 32 +#endif + +#ifndef DLT_PPP_SERIAL +#define DLT_PPP_SERIAL 50 +#endif + +#ifndef DLT_PPP_ETHER +#define DLT_PPP_ETHER 51 +#endif + +#ifndef DLT_SYMANTEC_FIREWALL +#define DLT_SYMANTEC_FIREWALL 99 +#endif + +#ifndef DLT_C_HDLC +#define DLT_C_HDLC 104 +#endif + +#ifndef DLT_IEEE802_11 +#define DLT_IEEE802_11 105 +#endif + +#ifndef DLT_FRELAY +#define DLT_FRELAY 107 +#endif + +#ifndef DLT_LOOP +#define DLT_LOOP 108 +#endif + +#ifndef DLT_ENC +#define DLT_ENC 109 +#endif + +#ifndef DLT_LINUX_SLL +#define DLT_LINUX_SLL 113 +#endif + +#ifndef DLT_LTALK +#define DLT_LTALK 114 +#endif + +#ifndef DLT_ECONET +#define DLT_ECONET 115 +#endif + +#ifndef DLT_IPFILTER +#define DLT_IPFILTER 116 +#endif + +#ifndef DLT_PFLOG +#define DLT_PFLOG 117 +#endif + +#ifndef DLT_CISCO_IOS +#define DLT_CISCO_IOS 118 +#endif + +#ifndef DLT_PRISM_HEADER +#define DLT_PRISM_HEADER 119 +#endif + +#ifndef DLT_AIRONET_HEADER +#define DLT_AIRONET_HEADER 120 +#endif + +#ifndef DLT_HHDLC +#define DLT_HHDLC 121 +#endif + +#ifndef DLT_IP_OVER_FC +#define DLT_IP_OVER_FC 122 +#endif + +#ifndef DLT_SUNATM +#define DLT_SUNATM 123 +#endif + +#ifndef DLT_RIO +#define DLT_RIO 124 +#endif + +#ifndef DLT_PCI_EXP +#define DLT_PCI_EXP 125 +#endif + +#ifndef DLT_AURORA +#define DLT_AURORA 126 +#endif + +#ifndef DLT_IEEE802_11_RADIO +#define DLT_IEEE802_11_RADIO 127 +#endif + +#ifndef DLT_TZSP +#define DLT_TZSP 128 +#endif + +#ifndef DLT_ARCNET_LINUX +#define DLT_ARCNET_LINUX 129 +#endif + +#ifndef DLT_JUNIPER_MLPPP +#define DLT_JUNIPER_MLPPP 130 +#endif + +#ifndef DLT_JUNIPER_MLFR +#define DLT_JUNIPER_MLFR 131 +#endif + +#ifndef DLT_JUNIPER_ES +#define DLT_JUNIPER_ES 132 +#endif + +#ifndef DLT_JUNIPER_GGSN +#define DLT_JUNIPER_GGSN 133 +#endif + +#ifndef DLT_JUNIPER_MFR +#define DLT_JUNIPER_MFR 134 +#endif + +#ifndef DLT_JUNIPER_ATM2 +#define DLT_JUNIPER_ATM2 135 +#endif + +#ifndef DLT_JUNIPER_SERVICES +#define DLT_JUNIPER_SERVICES 136 +#endif + +#ifndef DLT_JUNIPER_ATM1 +#define DLT_JUNIPER_ATM1 137 +#endif + +#ifndef DLT_APPLE_IP_OVER_IEEE1394 +#define DLT_APPLE_IP_OVER_IEEE1394 138 +#endif + +#ifndef DLT_MTP2_WITH_PHDR +#define DLT_MTP2_WITH_PHDR 139 +#endif + +#ifndef DLT_MTP2 +#define DLT_MTP2 140 +#endif + +#ifndef DLT_MTP3 +#define DLT_MTP3 141 +#endif + +#ifndef DLT_SCCP +#define DLT_SCCP 142 +#endif + +#ifndef DLT_DOCSIS +#define DLT_DOCSIS 143 +#endif + +#ifndef DLT_LINUX_IRDA +#define DLT_LINUX_IRDA 144 +#endif + +#ifndef DLT_IBM_SP +#define DLT_IBM_SP 145 +#endif + +#ifndef DLT_IBM_SN +#define DLT_IBM_SN 146 +#endif + +#ifndef DLT_USER0 +#define DLT_USER0 147 +#endif + +#ifndef DLT_USER1 +#define DLT_USER1 148 +#endif + +#ifndef DLT_USER2 +#define DLT_USER2 149 +#endif + +#ifndef DLT_USER3 +#define DLT_USER3 150 +#endif + +#ifndef DLT_USER4 +#define DLT_USER4 151 +#endif + +#ifndef DLT_USER5 +#define DLT_USER5 152 +#endif + +#ifndef DLT_USER6 +#define DLT_USER6 153 +#endif + +#ifndef DLT_USER7 +#define DLT_USER7 154 +#endif + +#ifndef DLT_USER8 +#define DLT_USER8 155 +#endif + +#ifndef DLT_USER9 +#define DLT_USER9 156 +#endif + +#ifndef DLT_USER10 +#define DLT_USER10 157 +#endif + +#ifndef DLT_USER11 +#define DLT_USER11 158 +#endif + +#ifndef DLT_USER12 +#define DLT_USER12 159 +#endif + +#ifndef DLT_USER13 +#define DLT_USER13 160 +#endif + +#ifndef DLT_USER14 +#define DLT_USER14 161 +#endif + +#ifndef DLT_USER15 +#define DLT_USER15 162 +#endif + +#ifndef DLT_IEEE802_11_RADIO_AVS +#define DLT_IEEE802_11_RADIO_AVS 163 +#endif + +#ifndef DLT_JUNIPER_MONITOR +#define DLT_JUNIPER_MONITOR 164 +#endif + +#ifndef DLT_BACNET_MS_TP +#define DLT_BACNET_MS_TP 165 +#endif + +#ifndef DLT_PPP_PPPD +#define DLT_PPP_PPPD 166 +#endif + +#ifndef DLT_JUNIPER_PPPOE +#define DLT_JUNIPER_PPPOE 167 +#endif + +#ifndef DLT_JUNIPER_PPPOE_ATM +#define DLT_JUNIPER_PPPOE_ATM 168 +#endif + +#ifndef DLT_GPRS_LLC +#define DLT_GPRS_LLC 169 +#endif + +#ifndef DLT_GPF_T +#define DLT_GPF_T 170 +#endif + +#ifndef DLT_GPF_F +#define DLT_GPF_F 171 +#endif + +#ifndef DLT_GCOM_T1E1 +#define DLT_GCOM_T1E1 172 +#endif + +#ifndef DLT_GCOM_SERIAL +#define DLT_GCOM_SERIAL 173 +#endif + +#ifndef DLT_JUNIPER_PIC_PEER +#define DLT_JUNIPER_PIC_PEER 174 +#endif + +#ifndef DLT_ERF_ETH +#define DLT_ERF_ETH 175 +#endif + +#ifndef DLT_ERF_POS +#define DLT_ERF_POS 176 +#endif + +#ifndef DLT_LINUX_LAPD +#define DLT_LINUX_LAPD 177 +#endif + +#ifndef DLT_JUNIPER_ETHER +#define DLT_JUNIPER_ETHER 178 +#endif + +#ifndef DLT_JUNIPER_PPP +#define DLT_JUNIPER_PPP 179 +#endif + +#ifndef DLT_JUNIPER_FRELAY +#define DLT_JUNIPER_FRELAY 180 +#endif + +#ifndef DLT_JUNIPER_CHDLC +#define DLT_JUNIPER_CHDLC 181 +#endif + + diff --git a/src/common/err.c b/src/common/err.c new file mode 100644 index 0000000..9b0efcc --- /dev/null +++ b/src/common/err.c @@ -0,0 +1,157 @@ +/* $Id: err.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * err.c + * + * Adapted from OpenBSD libc *err* *warn* code. + * + * Copyright (c) 2001-2010 Aaron Turner. + * + * Copyright (c) 2000 Dug Song + * + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "config.h" +#include "defines.h" +#include "common.h" + +#include +#include +#include +#include +#include + +#ifdef DEBUG +extern int debug; +#endif + +/** + * writes a notice message to stderr. Always forces a newline + */ +void +notice(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + if (fmt != NULL) + (void)vfprintf(stderr, fmt, ap); + (void)fprintf(stderr, "\n"); + va_end(ap); + fflush(NULL); +} + +/** + * Inner call to dbgx() which prints the function, line & function along + * with the message to stderr. Always forces a newline. + * + * You don't actually want to call this! use dbgx() instead! + */ +#ifdef DEBUG +void +_our_verbose_dbgx(int dbg_level, const char *fmt, const char *function, + const int line, const char *file, ...) +{ + va_list ap; + + if (debug < dbg_level) + return; + + fprintf(stderr, "DEBUG%d in %s:%s() line %d: ", dbg_level, file, + function, line); + + va_start(ap, file); + + if (fmt != NULL) + (void)vfprintf(stderr, fmt, ap); + (void)fprintf(stderr, "\n"); + va_end(ap); + fflush(NULL); +} +#endif + +/** + * Inner call to errx() which when in DEBUG mode, prints the function, line & file + * along with the actual error message to stderr. Alawys forces a newline + */ +#ifdef DEBUG +void +_our_verbose_errx(int eval, const char *fmt, const char *function, const int line, const char *file, ...) { +#else +void +_our_verbose_errx(int eval, const char *fmt, ...) { +#endif + + va_list ap; + +#ifdef DEBUG + fprintf(stderr, "\nFatal Error in %s:%s() line %d:\n", file, function, line); + va_start(ap, file); +#else + fprintf(stderr, "\nFatal Error: "); + va_start(ap, fmt); +#endif + + if (fmt != NULL) + (void)vfprintf(stderr, fmt, ap); + (void)fprintf(stderr, "\n"); + va_end(ap); + exit(eval); +} + +/** + * Inner call to warnx() which when in DEBUG mode, prints the function, line & file + * along with the actual warning to stderr. Alawys forces a newline + */ +#ifdef DEBUG +void +_our_verbose_warnx(const char *fmt, const char *function, const int line, const char *file, ...) { +#else +void +_our_verbose_warnx(const char *fmt, ...) { +#endif + + va_list ap; +#ifdef DEBUG + fprintf(stderr, "Warning in %s:%s() line %d:\n", file, function, line); + va_start(ap, file); +#else + fprintf(stderr, "Warning: "); + va_start(ap, fmt); +#endif + + if (fmt != NULL) + (void)vfprintf(stderr, fmt, ap); + (void)fprintf(stderr, "\n"); + va_end(ap); +} diff --git a/src/common/err.h b/src/common/err.h new file mode 100644 index 0000000..1695dc8 --- /dev/null +++ b/src/common/err.h @@ -0,0 +1,128 @@ +/* $Id: err.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * err.h + * + * Adapted from OpenBSD libc *err* *warn* code. + * + * Copyright (c) 2001-2010 Aaron Turner. + * + * Copyright (c) 2000 Dug Song + * + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)err.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _ERR_H_ +#define _ERR_H_ + +#include + +#ifdef DEBUG +extern int debug; +#endif + +/* + * We define five functions for reporting errors, warnings and debug messages: + * err() - Fatal error. Pass exit code followed by static string + * errx() - Fatal error. Pass exit code, format string, one or more variables + * warn() - Warning. Pass static string + * warnx() - Warning. Pass format string, one or more variables + * dbg() - Debug. Debug level to trigger, static string + * dbgx() - Debug. Debug level to trigger, format string, one or more variables + * notice() - Informational only via stderr, format string, one or more variables + */ + +/* gcc accepts __FUNCTION__, but C99 says use __func__. Necessary for SunPro compiler */ +#if !defined(__GNUC__) && !defined(__FUNCTION__) +# define __FUNCTION__ __func__ +#endif + +void notice(const char *fmt, ...); + +#ifdef DEBUG /* then err, errx, warn, warnx print file, func, line */ + +#define dbg(x, y) do { \ + if (debug >= x) \ + fprintf(stderr, "DEBUG%d in %s:%s() line %d: %s\n", x, __FILE__, __FUNCTION__, __LINE__, y); \ + } while(0) + +#define dbgx(x, y, ...) do { \ + if (debug >= x) { \ + fprintf(stderr, "DEBUG%d in %s:%s() line %d: " y "\n", x, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); \ + } \ +} while(0) + + +#define warn(x) fprintf(stderr, "Warning in %s:%s() line %d:\n%s\n", __FILE__, __FUNCTION__, __LINE__, x) + + +#define warnx(x, ...) fprintf(stderr, "Warning in %s:%s() line %d:\n" x "\n", __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__) + +#define err(x, y) do { \ + fprintf(stderr, "\nFatal Error in %s:%s() line %d:\n%s\n", __FILE__, __FUNCTION__, __LINE__, y); \ + fflush(NULL); \ + exit(x); \ + } while (0) + +#define errx(x, y, ...) do {\ + fprintf(stderr, "\nFatal Error in %s:%s() line %d:\n " y "\n", __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__); \ + fflush(NULL); \ + exit(x); \ + } while (0) + +#else /* no detailed DEBUG info */ + +/* dbg() and dbgx() become no-ops for non-DEBUG builds */ +#define dbg(x, y) { } +#define dbgx(x, y, ...) { } + +#define warn(x) fprintf(stderr, "Warning: %s\n", x) + +#define warnx(x, ...) fprintf(stderr, "Warning: " x "\n", __VA_ARGS__) + +#define err(x, y) do {\ + fprintf(stderr, "\nFatal Error:\n%s\n", y); \ + fflush(NULL); \ + exit(x); \ + } while(0) + +#define errx(x, y, ...) do {\ + fprintf(stderr, "\nFatal Error: " y "\n", __VA_ARGS__); \ + fflush(NULL); \ + exit(x); \ + } while (0) +#endif /* DEBUG */ + + +#endif /* !_ERR_H_ */ diff --git a/src/common/fakepcap.c b/src/common/fakepcap.c new file mode 100644 index 0000000..78b6d12 --- /dev/null +++ b/src/common/fakepcap.c @@ -0,0 +1,86 @@ +/* $Id: fakepcap.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2004-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This file impliments missing libpcap functions which only exist in really + * recent versions of libpcap. We assume the user has at least 0.6, so anything + * after that needs to be re-implimented here unless we want to start + * requiring a newer version + */ + +#include "config.h" +#include "defines.h" +#include "common.h" + +#include + +#ifndef HAVE_DLT_VAL_TO_DESC + +/** + * replacement for libpcap's pcap_datalink_val_to_description() + * which doesn't exist in all versions + */ +const char * +pcap_datalink_val_to_description(int dlt) +{ + if (dlt > DLT2DESC_LEN) + return "Unknown"; + + return dlt2desc[dlt]; + +} + +/** + * replacement for libpcap's pcap_datalink_val_to_name() + * which doesn't exist in all versions + */ +const char * +pcap_datalink_val_to_name(int dlt) +{ + if (dlt > DLT2NAME_LEN) + return "Unknown"; + + return dlt2name[dlt]; + +} + +#endif + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + + diff --git a/src/common/fakepcap.h b/src/common/fakepcap.h new file mode 100644 index 0000000..96b751c --- /dev/null +++ b/src/common/fakepcap.h @@ -0,0 +1,70 @@ +/* $Id: fakepcap.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2004-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _FAKEPCAP_H_ +#define _FAKEPCAP_H_ + +#include "config.h" + +/* + * libpcap <= 0.5 don't have some DLT types. Add them here + */ +#ifndef HAVE_DLT_LINUX_SLL +#define DLT_LINUX_SLL 113 +#endif + +#ifndef HAVE_DLT_C_HDLC +#define DLT_C_HDLC 104 +#endif + +/* + * libpcap < 0.8 don't have pcap_datalink_val_to_description() + * and pcap_datalink_val_to_name() + */ +#ifndef HAVE_DLT_VAL_TO_DESC + +const char *pcap_datalink_val_to_description(int dlt); +const char *pcap_datalink_val_to_name(int dlt); + +#endif + +#endif /* end of _FAKEPCAP_H_ */ + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + + diff --git a/src/common/fakepcapnav.c b/src/common/fakepcapnav.c new file mode 100644 index 0000000..39d057a --- /dev/null +++ b/src/common/fakepcapnav.c @@ -0,0 +1,108 @@ +/* $Id: fakepcapnav.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* This file impliments a fake, non-functioning version of the libpcapnav + * API based on libpcap. It's solely here for people who don't have + * libpcapnav installed on their system, and to keep the code maintainable. + */ + +#include "config.h" +#include "defines.h" +#include "common.h" + +#include + +#ifndef HAVE_PCAPNAV + +/** + * pcapnav_init does nothing! + */ +void +pcapnav_init(void) +{ + return; +} + +/** + * pcapnav_open_offline opens a pcap file, + * and creates the struct for our use + */ +pcapnav_t * +pcapnav_open_offline(const char *filename) +{ + pcapnav_t *pcapnav; + char errbuf[PCAP_ERRBUF_SIZE]; + + pcapnav = (pcapnav_t *) malloc(sizeof(pcapnav_t)); + if (pcapnav == NULL) { + err(-1, "malloc() error: unable to malloc pcapnav_t"); + } + + pcapnav->pcap = pcap_open_offline(filename, errbuf); + if (pcapnav->pcap == NULL) { + errx(-1, "Error opening pcap file %s: %s", filename, errbuf); + } + + return (pcapnav); +} + +/** + * closes our pcap file and free's the pcapnav + */ +void +pcapnav_close(pcapnav_t * pcapnav) +{ + pcap_close(pcapnav->pcap); + safe_free(pcapnav); +} + +/** + * returns the pcap_t data struct + */ +pcap_t * +pcapnav_pcap(pcapnav_t * pcapnav) +{ + return (pcapnav->pcap); +} + + +#endif + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + + diff --git a/src/common/fakepcapnav.h b/src/common/fakepcapnav.h new file mode 100644 index 0000000..d0bdfbc --- /dev/null +++ b/src/common/fakepcapnav.h @@ -0,0 +1,69 @@ +/* $Id: fakepcapnav.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_PCAPNAV +#include +#define _FAKEPCAPNAV_H_ +#endif + +#ifndef _FAKEPCAPNAV_H_ +#define _FAKEPCAPNAV_H_ + +#include "config.h" +#include "defines.h" + +#ifndef HAVE_PCAPNAV + +typedef struct pcapnav pcapnav_t; + +struct pcapnav { + pcap_t *pcap; +}; + +void pcapnav_init(void); +pcapnav_t *pcapnav_open_offline(const char *); +void pcapnav_close(pcapnav_t *); +pcap_t *pcapnav_pcap(pcapnav_t *); + +#endif + +#endif + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + + diff --git a/src/common/fakepoll.c b/src/common/fakepoll.c new file mode 100644 index 0000000..381ceea --- /dev/null +++ b/src/common/fakepoll.c @@ -0,0 +1,148 @@ +/* $Id: fakepoll.c 2423 2010-03-13 07:09:49Z aturner $ */ +/* + * fakepoll.c + * + * On systems where 'poll' doesn't exist, fake it with 'select'. + * + * Copyright (c) 2001-2003, Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "defines.h" +#include "common.h" + +/* prevents ISO C error */ +static void FAKEPOLL(int stop) +{ + if (! stop) + FAKEPOLL(1); + return; + +} + +#ifdef USE_FAKE_POLL +#include +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_STRING_H +#include +#endif +#if _MSC_VER > 1300 +#include +#include +#elif defined(_MSC_VER) +#include +#endif + +/* by default, windows handles only 64 fd's */ +#if defined(MS_WINDOWS) && !defined(FD_SETSIZE) +#define FD_SETSIZE MAXCONNECTIONS +#endif + +#include "util.h" + +/** + * custom version of poll() using select() in the backend + * only used if you don't actually have poll on your system. + */ +int +poll(struct pollfd *ufds, unsigned int nfds, int timeout) +{ + int idx, maxfd, fd; + int r; +#ifdef MS_WINDOWS + int any_fds_set = 0; +#endif + fd_set readfds, writefds, exceptfds; +#ifdef USING_FAKE_TIMEVAL +#undef timeval +#undef tv_sec +#undef tv_usec +#endif + struct timeval _timeout; + _timeout.tv_sec = timeout / 1000; + _timeout.tv_usec = (timeout % 1000) * 1000; + FD_ZERO(&readfds); + FD_ZERO(&writefds); + FD_ZERO(&exceptfds); + + maxfd = -1; + for (idx = 0; idx < nfds; ++idx) { + ufds[idx].revents = 0; + fd = ufds[idx].fd; + if (fd > maxfd) { + maxfd = fd; +#ifdef MS_WINDOWS + any_fds_set = 1; +#endif + } + if (ufds[idx].events & POLLIN) + FD_SET(fd, &readfds); + if (ufds[idx].events & POLLOUT) + FD_SET(fd, &writefds); + FD_SET(fd, &exceptfds); + } +#ifdef MS_WINDOWS + if (!any_fds_set) { + Sleep(timeout); + return 0; + } +#endif + r = select(maxfd + 1, &readfds, &writefds, &exceptfds, + timeout == -1 ? NULL : &_timeout); + if (r <= 0) + return r; + r = 0; + for (idx = 0; idx < nfds; ++idx) { + fd = ufds[idx].fd; + if (FD_ISSET(fd, &readfds)) + ufds[idx].revents |= POLLIN; + if (FD_ISSET(fd, &writefds)) + ufds[idx].revents |= POLLOUT; + if (FD_ISSET(fd, &exceptfds)) + ufds[idx].revents |= POLLERR; + if (ufds[idx].revents) + ++r; + } + return r; +} +#endif + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + + diff --git a/src/common/fakepoll.h b/src/common/fakepoll.h new file mode 100644 index 0000000..047aa28 --- /dev/null +++ b/src/common/fakepoll.h @@ -0,0 +1,86 @@ +/* $Id: fakepoll.h 2423 2010-03-13 07:09:49Z aturner $ */ +/* + * fakepoll.h + * + * On systems where 'poll' doesn't exist, fake it with 'select'. + * + * Copyright (c) 2001-2003, Nick Mathewson + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* don't warn on OS X that poll is emulated */ +#define POLL_NO_WARN +#define SYS_POLL_NO_WARN + +#ifdef HAVE_SYS_POLL_H +#include +#define __FAKEPOLL_H +#elif HAVE_POLL_H +#include +#define __FAKEPOLL_H +#endif + +#ifndef __FAKEPOLL_H +#define __FAKEPOLL_H + +#include "config.h" + +#ifndef HAVE_POLL_H +#ifndef HAVE_SYS_POLL_H +#define USE_FAKE_POLL + +struct pollfd { + int fd; + short events; + short revents; +}; + +#define POLLIN 0x0001 +#define POLLPRI 0x0002 +#define POLLOUT 0x0004 +#define POLLERR 0x0008 +#define POLLHUP 0x0010 +#define POLLNVAL 0x0020 + +int poll(struct pollfd *ufds, unsigned int nfds, int timeout); + +#endif +#endif +#endif + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + + diff --git a/src/common/get.c b/src/common/get.c new file mode 100644 index 0000000..c259970 --- /dev/null +++ b/src/common/get.c @@ -0,0 +1,633 @@ +/* $Id: get.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#include "config.h" +#include "defines.h" +#include "common.h" +#include "../../lib/sll.h" + +#include +#include +#include +#include +#include +#include +#include + +#ifdef DEBUG +extern int debug; +#endif + +#if defined HAVE_PCAP_VERSION && ! defined HAVE_WIN32 +extern const char pcap_version[]; +#endif + + +/** + * 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 get that + * information. + */ +const char * +get_pcap_version(void) +{ + +#if defined HAVE_WINPCAP + static char ourver[255]; + char *last, *version; + /* WinPcap returns a string like: + * WinPcap version 4.0 (packet.dll version 4.0.0.755), based on libpcap version 0.9.5 + */ + version = safe_strdup(pcap_lib_version()); + + strtok_r(version, " ", &last); + strtok_r(NULL, " ", &last); + strlcpy(ourver, strtok_r(NULL, " ", &last), 255); + safe_free(version); + return ourver; +#elif defined HAVE_PCAP_VERSION + return pcap_version; +#else + return pcap_lib_version(); +#endif +} + + + +/** + * returns the L2 protocol (IP, ARP, etc) + * or 0 for error + */ +u_int16_t +get_l2protocol(const u_char *pktdata, const int datalen, const int datalink) +{ + eth_hdr_t *eth_hdr; + vlan_hdr_t *vlan_hdr; + hdlc_hdr_t *hdlc_hdr; + sll_hdr_t *sll_hdr; + u_int16_t ether_type; + + assert(pktdata); + assert(datalen); + + switch (datalink) { + case DLT_RAW: + return ETHERTYPE_IP; + break; + + case DLT_EN10MB: + eth_hdr = (eth_hdr_t *)pktdata; + ether_type = ntohs(eth_hdr->ether_type); + switch (ether_type) { + case ETHERTYPE_VLAN: /* 802.1q */ + vlan_hdr = (vlan_hdr_t *)pktdata; + return ntohs(vlan_hdr->vlan_len); + default: + return ether_type; /* yes, return it in host byte order */ + } + break; + + case DLT_C_HDLC: + hdlc_hdr = (hdlc_hdr_t *)pktdata; + return hdlc_hdr->protocol; + break; + + case DLT_LINUX_SLL: + sll_hdr = (sll_hdr_t *)pktdata; + return sll_hdr->sll_protocol; + break; + + default: + errx(-1, "Unable to process unsupported DLT type: %s (0x%x)", + pcap_datalink_val_to_description(datalink), datalink); + + } + + return 0; + +} + +/** + * returns the length in number of bytes of the L2 header, or -1 on error + */ +int +get_l2len(const u_char *pktdata, const int datalen, const int datalink) +{ + eth_hdr_t *eth_hdr; + + assert(pktdata); + assert(datalen); + + switch (datalink) { + case DLT_RAW: + /* pktdata IS the ip header! */ + return 0; + break; + + case DLT_EN10MB: + eth_hdr = (struct tcpr_ethernet_hdr *)pktdata; + switch (ntohs(eth_hdr->ether_type)) { + case ETHERTYPE_VLAN: + return 18; + break; + + default: + return 14; + break; + } + break; + + case DLT_C_HDLC: + return CISCO_HDLC_LEN; + break; + + case DLT_LINUX_SLL: + return SLL_HDR_LEN; + break; + + default: + errx(-1, "Unable to process unsupported DLT type: %s (0x%x)", + pcap_datalink_val_to_description(datalink), datalink); + break; + } + + return -1; /* we shouldn't get here */ +} + +/** + * returns a ptr to the ip header + data or NULL if it's not IP + * we may use an extra buffer for the ip header (and above) + * on stricly aligned systems where the layer 2 header doesn't + * fall on a 4 byte boundry (like a standard ethernet header) + * + * Note: you can cast the result as an ip_hdr_t, but you'll be able + * to access data above the header minus any stripped L2 data + */ +const u_char * +get_ipv4(const u_char *pktdata, int datalen, int datalink, u_char **newbuff) +{ + const u_char *ip_hdr = NULL; + int l2_len = 0; + u_int16_t proto; + + assert(pktdata); + assert(datalen); + assert(*newbuff); + + l2_len = get_l2len(pktdata, datalen, datalink); + + /* sanity... datalen must be > l2_len + IP header len*/ + if (l2_len + TCPR_IPV4_H > datalen) { + dbg(1, "get_ipv4(): Layer 2 len > total packet len, hence no IP header"); + return NULL; + } + + proto = get_l2protocol(pktdata, datalen, datalink); + + if (proto != ETHERTYPE_IP) + return NULL; + +#ifdef FORCE_ALIGN + /* + * copy layer 3 and up to our temp packet buffer + * for now on, we have to edit the packetbuff because + * just before we send the packet, we copy the packetbuff + * back onto the pkt.data + l2len buffer + * we do all this work to prevent byte alignment issues + */ + if (l2_len % 4) { + ip_hdr = *newbuff; + memcpy(ip_hdr, (pktdata + l2_len), (datalen - l2_len)); + } else { + + /* we don't have to do a memcpy if l2_len lands on a boundry */ + ip_hdr = (pktdata + l2_len); + } +#else + /* + * on non-strict byte align systems, don't need to memcpy(), + * just point to l2len bytes into the existing buffer + */ + ip_hdr = (pktdata + l2_len); +#endif + + return ip_hdr; +} + +const u_char * +get_ipv6(const u_char *pktdata, int datalen, int datalink, u_char **newbuff) +{ + const u_char *ip6_hdr = NULL; + int l2_len = 0; + u_int16_t proto; + + assert(pktdata); + assert(datalen); + assert(*newbuff); + + l2_len = get_l2len(pktdata, datalen, datalink); + + /* sanity... datalen must be > l2_len + IP header len*/ + if (l2_len + TCPR_IPV6_H > datalen) { + dbg(1, "get_ipv6(): Layer 2 len > total packet len, hence no IPv6 header"); + return NULL; + } + + proto = get_l2protocol(pktdata, datalen, datalink); + + if (proto != ETHERTYPE_IP6) + return NULL; + +#ifdef FORCE_ALIGN + /* + * copy layer 3 and up to our temp packet buffer + * for now on, we have to edit the packetbuff because + * just before we send the packet, we copy the packetbuff + * back onto the pkt.data + l2len buffer + * we do all this work to prevent byte alignment issues + */ + if (l2_len % 4) { + ip6_hdr = *newbuff; + memcpy(ip6_hdr, (pktdata + l2_len), (datalen - l2_len)); + } else { + + /* we don't have to do a memcpy if l2_len lands on a boundry */ + ip6_hdr = (pktdata + l2_len); + } +#else + /* + * on non-strict byte align systems, don't need to memcpy(), + * just point to l2len bytes into the existing buffer + */ + ip6_hdr = (pktdata + l2_len); +#endif + + return ip6_hdr; +} + +/** + * returns a pointer to the layer 4 header which is just beyond the IPv4 header + */ +void * +get_layer4_v4(const ipv4_hdr_t *ip_hdr) +{ + void *ptr; + + assert(ip_hdr); + + ptr = (u_int32_t *) ip_hdr + ip_hdr->ip_hl; + return ((void *)ptr); +} + +/** + * returns a pointer to the layer 4 header which is just beyond the IPv6 header + * and any exension headers or NULL when there is none as in the case of + * v6 Frag or ESP header. Function is recursive. + */ +void * +get_layer4_v6(const ipv6_hdr_t *ip6_hdr) +{ + struct tcpr_ipv6_ext_hdr_base *next, *exthdr; + u_int8_t proto; + + assert(ip6_hdr); + + /* jump to the end of the IPv6 header */ + next = (struct tcpr_ipv6_ext_hdr_base *)((u_char *)ip6_hdr + TCPR_IPV6_H); + proto = ip6_hdr->ip_nh; + + while (TRUE) { + dbgx(3, "Processing proto: 0x%hx", proto); + + switch (proto) { + /* recurse due to v6-in-v6, need to recast next as an IPv6 Header */ + case TCPR_IPV6_NH_IPV6: + dbg(3, "recursing due to v6-in-v6"); + return get_layer4_v6((ipv6_hdr_t *)next); + break; + + /* loop again */ + case TCPR_IPV6_NH_AH: + case TCPR_IPV6_NH_ROUTING: + case TCPR_IPV6_NH_DESTOPTS: + case TCPR_IPV6_NH_HBH: + dbgx(3, "Going deeper due to extension header 0x%02X", proto); + exthdr = get_ipv6_next(next); + proto = exthdr->ip_nh; + next = exthdr; + break; + + /* + * Can't handle. Unparsable IPv6 fragment/encrypted data + */ + case TCPR_IPV6_NH_FRAGMENT: + case TCPR_IPV6_NH_ESP: + return NULL; + break; + + /* + * no further processing, either TCP, UDP, ICMP, etc... + */ + default: + if (proto != ip6_hdr->ip_nh) { + dbgx(3, "Returning byte offset of this ext header: %u", IPV6_EXTLEN_TO_BYTES(next->ip_len)); + return (void *)((u_char *)next + IPV6_EXTLEN_TO_BYTES(next->ip_len)); + } else { + dbgx(3, "%s", "Returning end of IPv6 Header"); + return next; + } + break; + } /* switch */ + } /* while */ +} + + +/** + * returns the next payload or header of the current extention header + * returns NULL for none/ESP. + */ +void * +get_ipv6_next(struct tcpr_ipv6_ext_hdr_base *exthdr) +{ + int len = 0; + + assert(exthdr); + + dbgx(3, "Jumping to next IPv6 header. Processing 0x%02x", exthdr->ip_nh); + switch (exthdr->ip_nh) { + /* no further processing */ + case TCPR_IPV6_NH_NO_NEXT: + case TCPR_IPV6_NH_ESP: + dbg(3, "No-Next or ESP... can't go any further..."); + return NULL; + break; + + /* + * fragment header is fixed size + * FIXME: Frag header has further ext headers (has a ip_nh field) + * but I don't support it because there's never a full L4 + payload beyond. + */ + case TCPR_IPV6_NH_FRAGMENT: + dbg(3, "Looks like were a fragment header. Returning some frag'd data."); + return (void *)((u_char *)exthdr + sizeof(struct tcpr_ipv6_frag_hdr)); + break; + + /* all the rest require us to go deeper using the ip_len field */ + case TCPR_IPV6_NH_IPV6: + case TCPR_IPV6_NH_ROUTING: + case TCPR_IPV6_NH_DESTOPTS: + case TCPR_IPV6_NH_HBH: + case TCPR_IPV6_NH_AH: + len = IPV6_EXTLEN_TO_BYTES(exthdr->ip_len); + dbgx(3, "Looks like we're an ext header (0x%hhx). Jumping %u bytes to the next", exthdr->ip_nh, len); + return (void *)((u_char *)exthdr + len); + break; + + default: + dbg(3, "Must not be a v6 extension header... returning self"); + return (void *)exthdr; + break; + } +} + +/** + * returns the protocol of the actual layer4 header by processing through + * the extension headers + */ +u_int8_t +get_ipv6_l4proto(const ipv6_hdr_t *ip6_hdr) +{ + u_char *ptr = (u_char *)ip6_hdr + TCPR_IPV6_H; /* jump to the end of the IPv6 header */ + u_int8_t proto; + struct tcpr_ipv6_ext_hdr_base *exthdr = NULL; + + proto = ip6_hdr->ip_nh; + assert(ip6_hdr); + + while (TRUE) { + dbgx(3, "Processing next proto 0x%02X", proto); + switch (proto) { + /* no further processing for IPV6 types with nothing beyond them */ + case TCPR_IPV6_NH_FRAGMENT: + case TCPR_IPV6_NH_ESP: + dbg(3, "No-Next or ESP... can't go any further..."); + return proto; + break; + + /* recurse */ + case TCPR_IPV6_NH_IPV6: + dbg(3, "Recursing due to v6 in v6"); + return get_ipv6_l4proto((ipv6_hdr_t *)ptr); + break; + + /* loop again */ + case TCPR_IPV6_NH_AH: + case TCPR_IPV6_NH_ROUTING: + case TCPR_IPV6_NH_DESTOPTS: + case TCPR_IPV6_NH_HBH: + dbgx(3, "Jumping to next extension header (0x%hhx)", proto); + exthdr = get_ipv6_next((struct tcpr_ipv6_ext_hdr_base *)ptr); + proto = exthdr->ip_nh; + ptr = (u_char *)exthdr; + break; + + /* should be TCP, UDP or the like */ + default: + dbgx(3, "Selecting next L4 Proto as: 0x%02x", proto); + return proto; + } + } +} + +/** + * get_name2addr4() + * stolen from LIBNET since I didn't want to have to deal with + * passing a libnet_t around. Returns 0xFFFFFFFF (255.255.255.255) + * on error + */ +u_int32_t +get_name2addr4(const char *hostname, u_int8_t dnslookup) +{ + struct in_addr addr; +#if ! defined HAVE_INET_ATON && defined HAVE_INET_ADDR + struct hostent *host_ent; +#endif + u_int32_t m; + u_int val; + int i; + + if (dnslookup == DNS_RESOLVE) { +#ifdef HAVE_INET_ATON + if (inet_aton(hostname, &addr) != 1) { + return(0xffffffff); + } + +#elif defined HAVE_INET_ADDR + if ((addr.s_addr = inet_addr(hostname)) == INADDR_NONE) { + if (!(host_ent = gethostbyname(hostname))) { + warnx("unable to resolve %s: %s", hostname, strerror(errno)); + /* XXX - this is actually 255.255.255.255 */ + return (0xffffffff); + } + + /* was: host_ent->h_length); */ + memcpy(&addr.s_addr, host_ent->h_addr, sizeof(addr.s_addr)); + } +#else + warn("Unable to support get_name2addr4 w/ resolve"); + /* call ourselves recursively once w/o resolving the hostname */ + return get_name2addr4(hostname, DNS_DONT_RESOLVE); +#endif + /* return in network byte order */ + return (addr.s_addr); + } else { + /* + * We only want dots 'n decimals. + */ + if (!isdigit(hostname[0])) { + warnx("Expected dotted-quad notation (%s) when DNS lookups are disabled", hostname); + /* XXX - this is actually 255.255.255.255 */ + return (-1); + } + + + m = 0; + for (i = 0; i < 4; i++) { + m <<= 8; + if (*hostname) { + val = 0; + while (*hostname && *hostname != '.') { + val *= 10; + val += *hostname - '0'; + if (val > 255) { + dbgx(4, "value %d > 255 for dotted quad", val); + /* XXX - this is actually 255.255.255.255 */ + return (-1); + } + hostname++; + } + m |= val; + if (*hostname) { + hostname++; + } + } + } + /* host byte order */ + return (ntohl(m)); + } +} + +int +get_name2addr6(const char *hostname, u_int8_t dnslookup, struct tcpr_in6_addr *addr) +{ + (void)dnslookup; + +#ifdef HAVE_INET_PTON + return inet_pton(AF_INET6, hostname, addr); +#else +#error "Unable to support get_name2addr6." +#endif + return -1; +} + +/** + * Generic wrapper around inet_ntop() and inet_ntoa() depending on whichever + * is available on your system + */ +const char * +get_addr2name4(const u_int32_t ip, u_int8_t dnslookup) +{ + struct in_addr addr; + static char *new_string = NULL; + + if (new_string == NULL) + new_string = (char *)safe_malloc(255); + + new_string[0] = '\0'; + addr.s_addr = ip; + +#ifdef HAVE_INET_NTOP + if (inet_ntop(AF_INET, &addr, new_string, 255) == NULL) { + warnx("Unable to convert 0x%x to a string", ip); + strlcpy(new_string, "", sizeof(new_string)); + } + return new_string; +#elif defined HAVE_INET_NTOA + return inet_ntoa(&addr); +#else +#error "Unable to support get_addr2name4." +#endif + + if (dnslookup != DNS_DONT_RESOLVE) { + warn("Sorry, we don't support name resolution."); + } + return new_string; +} + +const char * +get_addr2name6(const struct tcpr_in6_addr *addr, u_int8_t dnslookup) +{ + static char *new_string = NULL; + + if (new_string == NULL) + new_string = (char *)safe_malloc(255); + + new_string[0] = '\0'; + +#ifdef HAVE_INET_NTOP + if (inet_ntop(AF_INET6, addr, new_string, 255) == NULL) { + warn("Unable to convert addr to a string"); + strlcpy(new_string, "", sizeof(new_string)); + } + return new_string; +#else +#error "Unable to support get_addr2name6." +#endif + + if (dnslookup != DNS_DONT_RESOLVE) { + warn("Sorry, we don't support name resolution."); + } + return new_string; +} + +const char * +get_cidr2name(const tcpr_cidr_t *cidr_ptr, u_int8_t dnslookup) +{ + if (cidr_ptr->family == AF_INET) { + return get_addr2name4(cidr_ptr->u.network, dnslookup); + } else if (cidr_ptr->family == AF_INET6) { + return get_addr2name6(&cidr_ptr->u.network6, dnslookup); + } else { + return NULL; + } +} diff --git a/src/common/get.h b/src/common/get.h new file mode 100644 index 0000000..1ae3b67 --- /dev/null +++ b/src/common/get.h @@ -0,0 +1,75 @@ +/* $Id: get.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#ifndef __GET_H__ +#define __GET_H__ + +#include "config.h" +#include "defines.h" +#include "common.h" + + +int get_l2len(const u_char *pktdata, const int datalen, const int datalink); + +u_int16_t get_l2protocol(const u_char *pktdata, const int datalen, const int datalink); + +void *get_layer4_v4(const ipv4_hdr_t *ip_hdr); +void *get_layer4_v6(const ipv6_hdr_t *ip_hdr); + +u_int8_t get_ipv6_l4proto(const ipv6_hdr_t *ip6_hdr); +void *get_ipv6_next(struct tcpr_ipv6_ext_hdr_base *exthdr); + +const u_char *get_ipv4(const u_char *pktdata, int datalen, int datalink, u_char **newbuff); +const u_char *get_ipv6(const u_char *pktdata, int datalen, int datalink, u_char **newbuff); + +u_int32_t get_name2addr4(const char *hostname, u_int8_t dnslookup); +const char *get_addr2name4(const u_int32_t ip, u_int8_t dnslookup); +const char *get_addr2name6(const struct tcpr_in6_addr *addr, u_int8_t dnslookup); +const char *get_pcap_version(void); + +int get_name2addr6(const char *hostname, u_int8_t dnslookup, struct tcpr_in6_addr *addr); + + +const char *get_cidr2name(const tcpr_cidr_t *cidr_ptr, u_int8_t dnslookup); + + +#endif + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + diff --git a/src/common/interface.c b/src/common/interface.c new file mode 100644 index 0000000..d267117 --- /dev/null +++ b/src/common/interface.c @@ -0,0 +1,158 @@ +/* $Id: interface.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2007-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include + +#include "config.h" +#include "defines.h" +#include "common.h" +#include "interface.h" + +/** + * Method takes a user specified device name and returns + * the canonical name for that device. This allows me to + * create named interface aliases on platforms like Windows + * which use horrifically long interface names + * + * Returns NULL on error + * + * On success, it *may* malloc() memory equal to the length of *alias. + */ +char * +get_interface(interface_list_t *list, const char *alias) +{ + interface_list_t *ptr; + char *name; + + assert(alias); + + if (list != NULL) { + ptr = list; + + do { + /* check both the alias & name fields */ + if (strcmp(alias, ptr->alias) == 0) + return(ptr->name); + + if (strcmp(alias, ptr->name) == 0) + return(ptr->name); + + ptr = ptr->next; + } while (ptr != NULL); + } else { + name = (char *)safe_malloc(strlen(alias) + 1); + strlcpy(name, alias, sizeof(name)); + return(name); + } + + return(NULL); +} + +/** + * Get all available interfaces as an interface_list * + */ +interface_list_t * +get_interface_list(void) +{ + interface_list_t *list_head, *list_ptr; + char ebuf[PCAP_ERRBUF_SIZE]; + pcap_if_t *pcap_if, *pcap_if_ptr; + int i = 0; + +#ifndef HAVE_WIN32 + /* Unix just has a warning about being root */ + if (geteuid() != 0) + warn("May need to run as root to get complete list."); +#endif + + if (pcap_findalldevs(&pcap_if, ebuf) < 0) + errx(-1, "Error: %s", ebuf); + + pcap_if_ptr = pcap_if; + list_head = (interface_list_t *)safe_malloc(sizeof(interface_list_t)); + list_ptr = list_head; + + while (pcap_if_ptr != NULL) { + if (i > 0) { + list_ptr->next = (interface_list_t *)safe_malloc(sizeof(interface_list_t)); + list_ptr = list_ptr->next; + } + strlcpy(list_ptr->name, pcap_if_ptr->name, sizeof(list_ptr->name)); + + /* description is usually null under Unix */ + if (pcap_if_ptr->description != NULL) + strlcpy(list_ptr->description, pcap_if_ptr->description, sizeof(list_ptr->description)); + + sprintf(list_ptr->alias, "%%%d", i++); + list_ptr->flags = pcap_if_ptr->flags; + pcap_if_ptr = pcap_if_ptr->next; + } + pcap_freealldevs(pcap_if); + return(list_head); +} + +/** + * Prints all the available interfaces found by get_interface_list() + */ +void +list_interfaces(interface_list_t *list) +{ + interface_list_t *ptr; + + if (list == NULL) { + printf("No network interfaces available"); + return; + } + + printf("Available network interfaces:\n"); + +#ifdef HAVE_WIN32 /* Win32 has alias/name/description */ + printf("Alias\tName\tDescription\n"); +#endif + + + ptr = list; + + do { + if (! ptr->flags & PCAP_IF_LOOPBACK) { +#ifdef HAVE_WIN32 + printf("%s\t%s\n\t%s\n", ptr->alias, ptr->name, ptr->description); +#else + printf("%s\n", ptr->name); +#endif + } + ptr = ptr->next; + } while (ptr != NULL); +} diff --git a/src/common/interface.h b/src/common/interface.h new file mode 100644 index 0000000..5ec7fa0 --- /dev/null +++ b/src/common/interface.h @@ -0,0 +1,53 @@ +/* $Id: interface.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2007-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#ifndef _INTERFACE_H_ +#define _INTERFACE_H_ + +struct interface_list_s { + char name[255]; + char alias[255]; + char description[255]; + u_int32_t flags; + struct interface_list_s *next; +}; + +typedef struct interface_list_s interface_list_t; + +#define INTERFACE_LIST_SIZE (80 * 80) /* 80 cols * 80 rows */ + +char *get_interface(interface_list_t *, const char *); +interface_list_t *get_interface_list(void); +void list_interfaces(interface_list_t *); + +#endif diff --git a/src/common/list.c b/src/common/list.c new file mode 100644 index 0000000..05218d8 --- /dev/null +++ b/src/common/list.c @@ -0,0 +1,218 @@ +/* $Id: list.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * A generic method to parse a list of integers which are + * delimited by commas and dashes to indicate individual + * numbers and ranges + * Provides both a way to process the list and determine + * if an integer exists in the list. + */ + +#include "config.h" +#include "defines.h" +#include "common.h" + +#include +#include +#include +#include +#include + + +/** + * Creates a new tcpr_list entry. Malloc's memory. + */ +tcpr_list_t * +new_list() +{ + tcpr_list_t *newlist; + + newlist = (tcpr_list_t *)safe_malloc(sizeof(tcpr_list_t)); + return (newlist); +} + +/** + * Processes a string (ourstr) containing the list in human readable + * format and places the data in **list and finally returns 1 for + * success, 0 for fail. + */ +int +parse_list(tcpr_list_t ** listdata, char *ourstr) +{ + tcpr_list_t *listcur, *list_ptr; + char *this = NULL; + char *first, *second; + int rcode; + regex_t preg; + char ebuf[EBUF_SIZE]; + char regex[] = "^[0-9]+(-[0-9]+)?$"; + char *token = NULL; + + + /* compile the regex first */ + if ((rcode = regcomp(&preg, regex, REG_EXTENDED | REG_NOSUB)) != 0) { + regerror(rcode, &preg, ebuf, sizeof(ebuf)); + errx(-1, "Unable to compile regex (%s): %s", regex, ebuf); + } + + /* first iteration */ + this = strtok_r(ourstr, ",", &token); + first = this; + second = NULL; + + /* regex test */ + if (regexec(&preg, this, 0, NULL, 0) != 0) { + warnx("Unable to parse: %s", this); + return 0; + } + + + *listdata = new_list(); + list_ptr = *listdata; + listcur = list_ptr; + + for (u_int i = 0; i < strlen(this); i++) { + if (this[i] == '-') { + this[i] = '\0'; + second = &this[i + 1]; + } + } + + list_ptr->min = strtoull(first, NULL, 0); + if (second != NULL) { + list_ptr->max = strtoull(second, NULL, 0); + } + else { + list_ptr->max = list_ptr->min; + } + + while (1) { + this = strtok_r(NULL, ",", &token); + if (this == NULL) + break; + + first = this; + second = NULL; + + + /* regex test */ + if (regexec(&preg, this, 0, NULL, 0) != 0) { + warnx("Unable to parse: %s", this); + return 0; + } + + listcur->next = new_list(); + listcur = listcur->next; + + for (u_int i = 0; i < strlen(this); i++) { + if (this[i] == '-') { + this[i] = '\0'; + second = &this[i + 1]; + } + } + + listcur->min = strtoull(first, NULL, 0); + if (second != NULL) { + listcur->max = strtoull(second, NULL, 0); + } + else { + listcur->max = listcur->min; + } + + } + + return 1; +} + + + +/** + * Checks to see if the given integer exists in the LIST. + */ +tcpr_dir_t +check_list(tcpr_list_t * list, COUNTER value) +{ + tcpr_list_t *current; + current = list; + + do { + if ((current->min != 0) && (current->max != 0)) { + if ((value >= current->min) && (value <= current->max)) + return TCPR_DIR_C2S; + } + else if (current->min == 0) { + if (value <= current->max) + return TCPR_DIR_C2S; + } + else if (current->max == 0) { + if (value >= current->min) + return TCPR_DIR_C2S; + } + + if (current->next != NULL) { + current = current->next; + } + else { + current = NULL; + } + + } while (current != NULL); + + return TCPR_DIR_S2C; + +} + + +/** + * Free's all the memory associated with the given LIST + */ +void +free_list(tcpr_list_t * list) +{ + + /* recursively go down the list */ + if (list->next != NULL) + free_list(list->next); + + safe_free(list); +} + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + + diff --git a/src/common/list.h b/src/common/list.h new file mode 100644 index 0000000..53e2ef6 --- /dev/null +++ b/src/common/list.h @@ -0,0 +1,58 @@ +/* $Id: list.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __LIST_H__ +#define __LIST_H__ + +struct list_s { + COUNTER max; + COUNTER min; + struct list_s *next; +}; + +typedef struct list_s tcpr_list_t; + +int parse_list(tcpr_list_t **, char *); +int check_list(tcpr_list_t *, COUNTER); +void free_list(tcpr_list_t *); + +#endif + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + + diff --git a/src/common/mac.c b/src/common/mac.c new file mode 100644 index 0000000..08945f5 --- /dev/null +++ b/src/common/mac.c @@ -0,0 +1,167 @@ +/* $Id: mac.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* Copyright 2004-2010 Aaron Turner + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "defines.h" +#include "common.h" +#include +#include +#include +#include + +#include "mac.h" + +/** + * converts a string representation of a MAC address, based on + * non-portable ether_aton() + */ +void +mac2hex(const char *mac, u_char *dst, int len) +{ + int i; + long l; + char *pp; + + if (len < 6) + return; + + while (isspace(*mac)) + mac++; + + /* expect 6 hex octets separated by ':' or space/NUL if last octet */ + for (i = 0; i < 6; i++) { + l = strtol(mac, &pp, 16); + if (pp == mac || l > 0xFF || l < 0) + return; + if (!(*pp == ':' || (i == 5 && (isspace(*pp) || *pp == '\0')))) + return; + dst[i] = (u_char) l; + mac = pp + 1; + } +} + +/** + * converts a string representation of TWO MAC addresses, which + * are comma deliminated into two hex values. Either *first or *second + * can be NULL if there is nothing before or after the comma. + * returns: + * 1 = first mac + * 2 = second mac + * 3 = both mac's + * 0 = none + */ +int +dualmac2hex(const char *dualmac, u_char *first, u_char *second, int len) +{ + char *tok, *temp, *string; + int ret = 0; + + string = safe_strdup(dualmac); + + /* if we've only got a comma, then return NULL's */ + if (len <= 1) { + second = first = NULL; + return 0; + } + + + temp = strtok_r(string, ",", &tok); + if (strlen(temp)) { + mac2hex(temp, first, len); + ret = 1; + } + + temp = strtok_r(NULL, ",", &tok); + /* temp is null if no comma */ + if (temp != NULL) { + if (strlen(temp)) { + mac2hex(temp, second, len); + ret += 2; + } + } + + return ret; + +} + +/** + * Figures out if a MAC is listed in a comma delimited + * string of MAC addresses. + * returns TCPR_DIR_C2S if listed + * returns TCPR_DIR_S2C if not listed + */ +tcpr_dir_t +macinstring(const char *macstring, const u_char *mac) +{ + char *tok, *tempstr, *ourstring; + u_char tempmac[6]; + int len = 6, ret = TCPR_DIR_S2C; + + ourstring = safe_strdup(macstring); + + tempstr = strtok_r(ourstring, ",", &tok); + if (strlen(tempstr)) { + mac2hex(tempstr, tempmac, len); + if (memcmp(mac, tempmac, len) == 0) { + dbgx(3, "Packet matches: " MAC_FORMAT " sending out primary.\n", MAC_STR(tempmac)); + ret = TCPR_DIR_C2S; + goto EXIT_MACINSTRING; + } + } else { + goto EXIT_MACINSTRING; + } + + while ((tempstr = strtok_r(NULL, ",", &tok)) != NULL) { + mac2hex(tempstr, tempmac, len); + if (memcmp(mac, tempmac, len) == 0) { + ret = TCPR_DIR_C2S; + dbgx(3, "Packet matches: " MAC_FORMAT " sending out primary.\n", MAC_STR(tempmac)); + goto EXIT_MACINSTRING; + } + } + +EXIT_MACINSTRING: + safe_free(ourstring); +#ifdef DEBUG + if (ret == TCPR_DIR_S2C) + dbg(3, "Packet doesn't match any MAC addresses sending out secondary.\n"); +#endif + return ret; +} + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + diff --git a/src/common/mac.h b/src/common/mac.h new file mode 100644 index 0000000..945abc1 --- /dev/null +++ b/src/common/mac.h @@ -0,0 +1,50 @@ +/* $Id: mac.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* Copyright 2004-2010 Aaron Turner + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __MAC_H__ +#define __MAC_H__ + +void mac2hex(const char *mac, u_char *dst, int len); +int dualmac2hex(const char *dualmac, u_char *first, u_char *second, int len); +tcpr_dir_t macinstring(const char *macstring, const u_char *mac); + +#endif /* __MAC_H__ */ + + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + diff --git a/src/common/pcap_dlt.h b/src/common/pcap_dlt.h new file mode 100644 index 0000000..e994cd5 --- /dev/null +++ b/src/common/pcap_dlt.h @@ -0,0 +1,52 @@ +/* $Id: pcap_dlt.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2004-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _PCAP_DLT_H_ +#define _PCAP_DLT_H_ + +/* + * Cisco HDLC. Used by Dag interfaces for SONET + * and possibly others + */ + +#define CISCO_HDLC_LEN 4 + +struct hdlc_hdr_s { + u_int16_t address; + u_int16_t protocol; +}; +typedef struct hdlc_hdr_s hdlc_hdr_t; + + +#endif /* _PCAP_DLT_H_ */ + + diff --git a/src/common/rdtsc.c b/src/common/rdtsc.c new file mode 100644 index 0000000..5b3fb60 --- /dev/null +++ b/src/common/rdtsc.c @@ -0,0 +1,79 @@ +/* $Id:$ */ + +/* + * Copyright (c) 2008-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "defines.h" +#include "common.h" + +#include +#include +#include +#include +#include + +/* + * returns the # of clicks/usec + */ +u_int64_t +rdtsc_calibrate(u_int32_t mhz) +{ + static u_int64_t x = 0; + u_int64_t v = 0; + struct timeval start, end, diff; + u_int64_t x1, x2; + u_int16_t n; + + if (x != 0) { + return x; + } else if (mhz > 0 && x == 0) { + x = (u_int64_t)mhz; + notice("Using user specification of %llu Mhz", x); + } else { + /* haven't calculated clicks/usec yet */ + for (n=0; n<16; ++n) { + gettimeofday(&start, 0); + x1 = rdtsc(); + + usleep(100000); + + x2 = rdtsc(); + gettimeofday(&end, 0); + + timersub(&end, &start, &diff); + + v = (x2 - x1)/(diff.tv_sec * 1000000 + diff.tv_usec); + x = x ? (x + v)/2 : v; + } + notice("Using guessimate of %llu Mhz", x); + } + return x; +} diff --git a/src/common/rdtsc.h b/src/common/rdtsc.h new file mode 100644 index 0000000..3c4f60d --- /dev/null +++ b/src/common/rdtsc.h @@ -0,0 +1,125 @@ +/* $Id:$ */ + +/* + * Copyright (c) 2008-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +/* + * Read TimeStamp Counter (RDTSC) + * http://www-unix.mcs.anl.gov/~kazutomo/rdtsc.html + * I'm not really sure what the license is, but I'll assume Kazutomo Yoshii is + * cool with me using it since he published it on his website. + * Should also check out: http://www.fftw.org/cycle.h + */ + +#ifndef __RDTSC_H__ +#define __RDTSC_H__ + + +u_int64_t rdtsc_calibrate(u_int32_t mhz); + +#if defined(__i386__) +#define HAVE_RDTSC 1 + +static inline u_int64_t +rdtsc(void) +{ + u_int64_t x; + __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x)); + return x; +} + +#elif defined(__x86_64__) +#define HAVE_RDTSC 1 + +static inline u_int64_t +rdtsc(void) +{ + unsigned hi, lo; + __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi)); + return ( (u_int64_t)lo)|( ((u_int64_t)hi)<<32 ); +} + +#elif defined(__powerpc__) +#define HAVE_RDTSC 1 + +static inline u_int64_t +rdtsc(void) +{ + u_int64_t result=0; + u_int32_t upper, lower,tmp; + __asm__ volatile( + "0: \n" + "\tmftbu %0 \n" + "\tmftb %1 \n" + "\tmftbu %2 \n" + "\tcmpw %2,%0 \n" + "\tbne 0b \n" + : "=r"(upper),"=r"(lower),"=r"(tmp) + ); + result = upper; + result = result<<32; + result = result|lower; + + return(result); +} + +#else + +/* do not HAVE_RDTSC for your platform */ + +#endif + +/* only define rdtsc_sleep() if we have rdtsc() */ +#ifdef HAVE_RDTSC +/* + * sleeps for sleep time, using the rdtsc counter for accuracy + * you need to call rdtsc_calibrate() BEFORE this or you'll sleep for + * an additional .1 sec the very first time you call it. + */ +static inline void +rdtsc_sleep(const struct timespec sleep) +{ + u_int64_t sleep_until; + u_int64_t now = 0; + static u_int64_t clicks_per_usec = 0; + + sleep_until = rdtsc(); + clicks_per_usec = clicks_per_usec > 0 ? clicks_per_usec : rdtsc_calibrate(0); + + sleep_until += clicks_per_usec * TIMESPEC_TO_MICROSEC(&sleep); + + while (now < sleep_until) + now = rdtsc(); +} +#endif + +#endif /* __RDTSC_H__ */ + diff --git a/src/common/sendpacket.c b/src/common/sendpacket.c new file mode 100644 index 0000000..5fdfa4d --- /dev/null +++ b/src/common/sendpacket.c @@ -0,0 +1,960 @@ +/* $Id: sendpacket.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * Copyright (c) 1998 - 2004 Mike D. Schiffman + * Copyright (c) 2000 Torsten Landschoff + * Sebastian Krahmer + * Copyright (c) 1993, 1994, 1995, 1996, 1998 + * The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * 4. All advertising materials mentioning features or use of this software + * display the following acknowledgement: + * ``This product includes software developed by the University of + * California, Lawrence Berkeley Laboratory and its contributors.'' + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + /* sendpacket.[ch] is my attempt to write a universal packet injection + * API for BPF, libpcap, libdnet, and Linux's PF_PACKET. I got sick + * and tired dealing with libnet bugs and its lack of active maintenence, + * but unfortunately, libpcap frame injection support is relatively new + * and not everyone uses Linux, so I decided to support all four as + * best as possible. If your platform/OS/hardware supports an additional + * injection method, then by all means add it here (and send me a patch). + * + * Anyways, long story short, for now the order of preference is: + * 1. PF_PACKET + * 2. BPF + * 3. libdnet + * 4. pcap_inject() + * 5. pcap_sendpacket() + * + * Right now, one big problem with the pcap_* methods is that libpcap + * doesn't provide a reliable method of getting the MAC address of + * an interface (required for tcpbridge). + * You can use PF_PACKET or BPF to get that, but if your system suports + * those, might as well inject directly without going through another + * level of indirection. + * + * Please note that some of this code was copied from Libnet 1.1.3 + */ + +#include "config.h" +#include "defines.h" +#include "common.h" +#include "sendpacket.h" + + +#ifdef FORCE_INJECT_LIBDNET +#undef HAVE_PF_PACKET +#undef HAVE_PCAP_INJECT +#undef HAVE_PCAP_SENDPACKET +#undef HAVE_BPF +#endif + +#ifdef FORCE_INJECT_BPF +#undef HAVE_LIBDNET +#undef HAVE_PCAP_INJECT +#undef HAVE_PCAP_SENDPACKET +#undef HAVE_PF_PACKET +#endif + +#ifdef FORCE_INJECT_PCAP_INJECT +#undef HAVE_LIBDNET +#undef HAVE_PCAP_SENDPACKET +#undef HAVE_BPF +#undef HAVE_PF_PACKET +#endif + +#ifdef FORCE_INJECT_PCAP_SENDPACKET +#undef HAVE_LIBDNET +#undef HAVE_PCAP_INJECT +#undef HAVE_BPF +#undef HAVE_PF_PACKET +#endif + +#if (defined HAVE_WINPCAP && defined HAVE_PCAP_INJECT) +#undef HAVE_PCAP_INJECT /* configure returns true for some odd reason */ +#endif + +#if !defined HAVE_PCAP_INJECT && !defined HAVE_PCAP_SENDPACKET && !defined HAVE_LIBDNET && !defined HAVE_PF_PACKET && !defined HAVE_BPF +#error You need pcap_inject() or pcap_sendpacket() from libpcap, libdnet, Linux's PF_PACKET or *BSD's BPF +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef HAVE_SYS_PARAM_H +#include +#endif +#ifdef HAVE_SYS_SYSCTL_H +#include +#endif +#ifdef HAVE_NET_ROUTE_H +#include +#endif +#include +#include + +#ifdef HAVE_PF_PACKET +#undef INJECT_METHOD +#define INJECT_METHOD "PF_PACKET send()" + +#include +#include +#include +#include +#include +#include +#include + +#ifndef __GLIBC__ +typedef int socklen_t; +#endif + +static sendpacket_t *sendpacket_open_pf(const char *, char *); +static struct tcpr_ether_addr *sendpacket_get_hwaddr_pf(sendpacket_t *); +static int get_iface_index(int fd, const int8_t *device, char *); + +#endif /* HAVE_PF_PACKET */ + +#if defined HAVE_BPF && ! defined INJECT_METHOD +#undef INJECT_METHOD +#define INJECT_METHOD "bpf send()" + +#include +#include +#include +#include +#include // used for get_hwaddr_bpf() + +static sendpacket_t *sendpacket_open_bpf(const char *, char *) _U_; +static struct tcpr_ether_addr *sendpacket_get_hwaddr_bpf(sendpacket_t *) _U_; + +#endif /* HAVE_BPF */ + +#if defined HAVE_LIBDNET && ! defined INJECT_METHOD +#undef INJECT_METHOD +#define INJECT_METHOD "libdnet eth_send()" +/* need to undef these which are pulled in via defines.h, prior to importing dnet.h */ +#undef icmp_id +#undef icmp_seq +#undef icmp_data +#undef icmp_mask +#include + +static sendpacket_t *sendpacket_open_libdnet(const char *, char *) _U_; +static struct tcpr_ether_addr *sendpacket_get_hwaddr_libdnet(sendpacket_t *) _U_; +#endif /* HAVE_LIBDNET */ + +#if (defined HAVE_PCAP_INJECT || defined HAVE_PCAP_SENDPACKET) && ! defined INJECT_METHOD +static sendpacket_t *sendpacket_open_pcap(const char *, char *) _U_; +static struct tcpr_ether_addr *sendpacket_get_hwaddr_pcap(sendpacket_t *) _U_; +#endif /* HAVE_PCAP_INJECT || HAVE_PACKET_SENDPACKET */ + +#if defined HAVE_PCAP_INJECT && ! defined INJECT_METHOD +#undef INJECT_METHOD +#define INJECT_METHOD "pcap_inject()" +#elif defined HAVE_PCAP_SENDPACKET && ! defined INJECT_METHOD +#undef INJECT_METHOD +#define INJECT_METHOD "pcap_sendpacket()" +#endif + +static void sendpacket_seterr(sendpacket_t *sp, const char *fmt, ...); + +/* You need to define didsig in your main .c file. Set to 1 if CTRL-C was pressed */ +extern volatile int didsig; + + +/** + * returns number of bytes sent on success or -1 on error + * Note: it is theoretically possible to get a return code >0 and < len + * which for most people would be considered an error (the packet wasn't fully sent) + * so you may want to test for recode != len too. + * + * Most socket API's have two interesting errors: ENOBUFS & EAGAIN. ENOBUFS + * is usually due to the kernel buffers being full. EAGAIN happens when you + * try to send traffic faster then the PHY allows. + */ +int +sendpacket(sendpacket_t *sp, const u_char *data, size_t len) +{ + int retcode; + + assert(sp); + assert(data); + + if (len <= 0) + return -1; + +TRY_SEND_AGAIN: + sp->attempt ++; + +#if defined HAVE_PF_PACKET + retcode = (int)send(sp->handle.fd, (void *)data, len, 0); + + /* out of buffers, or hit max PHY speed, silently retry */ + if (retcode < 0 && !didsig) { + switch (errno) { + case EAGAIN: + sp->retry_eagain ++; + goto TRY_SEND_AGAIN; + break; + case ENOBUFS: + sp->retry_enobufs ++; + goto TRY_SEND_AGAIN; + break; + + default: + sendpacket_seterr(sp, "Error with %s [" COUNTER_SPEC "]: %s (errno = %d)", + INJECT_METHOD, sp->sent + sp->failed + 1, strerror(errno), errno); + } + } + +#elif defined HAVE_BPF + retcode = write(sp->handle.fd, (void *)data, len); + + /* out of buffers, or hit max PHY speed, silently retry */ + if (retcode < 0 && !didsig) { + switch (errno) { + case EAGAIN: + sp->retry_eagain ++; + goto TRY_SEND_AGAIN; + break; + + case ENOBUFS: + sp->retry_enobufs ++; + goto TRY_SEND_AGAIN; + break; + + default: + sendpacket_seterr(sp, "Error with %s [" COUNTER_SPEC "]: %s (errno = %d)", + INJECT_METHOD, sp->sent + sp->failed + 1, strerror(errno), errno); + } + } + +#elif defined HAVE_LIBDNET + retcode = eth_send(sp->handle.ldnet, (void*)data, (size_t)len); + + /* out of buffers, or hit max PHY speed, silently retry */ + if (retcode < 0 && !didsig) { + switch (errno) { + case EAGAIN: + sp->retry_eagain ++; + goto TRY_SEND_AGAIN; + break; + + case ENOBUFS: + sp->retry_enobufs ++; + goto TRY_SEND_AGAIN; + break; + + default: + sendpacket_seterr(sp, "Error with %s [" COUNTER_SPEC "]: %s (errno = %d)", + INJECT_METHOD, sp->sent + sp->failed + 1, strerror(errno), errno); + } + } + +#elif defined HAVE_PCAP_INJECT + /* + * pcap methods don't seem to support ENOBUFS, so we just straight fail + * is there a better way??? + */ + retcode = pcap_inject(sp->handle.pcap, (void*)data, len); + /* out of buffers, or hit max PHY speed, silently retry */ + if (retcode < 0 && !didsig) { + switch (errno) { + case EAGAIN: + sp->retry_eagain ++; + goto TRY_SEND_AGAIN; + break; + + case ENOBUFS: + sp->retry_enobufs ++; + goto TRY_SEND_AGAIN; + break; + + default: + sendpacket_seterr(sp, "Error with %s [" COUNTER_SPEC "]: %s (errno = %d)", + INJECT_METHOD, sp->sent + sp->failed + 1, pcap_geterr(sp->handle.pcap), errno); + } + } + +#elif defined HAVE_PCAP_SENDPACKET + retcode = pcap_sendpacket(sp->handle.pcap, data, (int)len); + /* out of buffers, or hit max PHY speed, silently retry */ + if (retcode < 0 && !didsig) { + switch (errno) { + case EAGAIN: + sp->retry_eagain ++; + goto TRY_SEND_AGAIN; + break; + + case ENOBUFS: + sp->retry_enobufs ++; + goto TRY_SEND_AGAIN; + break; + + default: + sendpacket_seterr(sp, "Error with %s [" COUNTER_SPEC "]: %s (errno = %d)", + INJECT_METHOD, sp->sent + sp->failed + 1, pcap_geterr(sp->handle.pcap), errno); + } + } + /* + * pcap_sendpacket returns 0 on success, not the packet length! + * hence, we have to fix retcode to be more standard on success + */ + if (retcode == 0) + retcode = len; + +#endif + + if (retcode < 0) { + sp->failed ++; + } else if (retcode != (int)len) { + sendpacket_seterr(sp, "Only able to write %d bytes out of %u bytes total", + retcode, len); + } else { + sp->bytes_sent += len; + sp->sent ++; + } + return retcode; +} + +/** + * Open the given network device name and returns a sendpacket_t struct + * pass the error buffer (in case there's a problem) and the direction + * that this interface represents + */ +sendpacket_t * +sendpacket_open(const char *device, char *errbuf, tcpr_dir_t direction) +{ + sendpacket_t *sp; + + assert(device); + assert(errbuf); + +#if defined HAVE_PF_PACKET + sp = sendpacket_open_pf(device, errbuf); +#elif defined HAVE_BPF + sp = sendpacket_open_bpf(device, errbuf); +#elif defined HAVE_LIBDNET + sp = sendpacket_open_libdnet(device, errbuf); +#elif (defined HAVE_PCAP_INJECT || defined HAVE_PCAP_SENDPACKET) + sp = sendpacket_open_pcap(device, errbuf); +#endif + if (sp != NULL) { + sp->open = 1; + sp->cache_dir = direction; + } + return sp; +} + +/** + * Get packet stats for the given sendpacket_t + */ +char * +sendpacket_getstat(sendpacket_t *sp) +{ + static char buf[1024]; + + assert(sp); + + memset(buf, 0, sizeof(buf)); + sprintf(buf, "Statistics for network device: %s\n" + "\tAttempted packets: " COUNTER_SPEC "\n" + "\tSuccessful packets: " COUNTER_SPEC "\n" + "\tFailed packets: " COUNTER_SPEC "\n" + "\tRetried packets (ENOBUFS): " COUNTER_SPEC "\n" + "\tRetried packets (EAGAIN): " COUNTER_SPEC "\n", + sp->device, sp->attempt, sp->sent, sp->failed, sp->retry_enobufs, sp->retry_eagain); + return(buf); +} + +/** + * close the given sendpacket + */ +int +sendpacket_close(sendpacket_t *sp) +{ + assert(sp); + switch(sp->handle_type) { + case SP_TYPE_BPF: +#if (defined HAVE_PCAP_INJECT || defined HAVE_PCAP_SENDPACKET) + close(sp->handle.fd); +#endif + break; + + case SP_TYPE_PF_PACKET: +#ifdef HAVE_PF_PACKET + close(sp->handle.fd); +#endif + break; + + case SP_TYPE_LIBPCAP: +#ifdef HAVE_LIBPCAP + pcap_close(sp->handle.pcap); +#endif + break; + + case SP_TYPE_LIBDNET: +#ifdef HAVE_LIBDNET + eth_close(sp->handle.ldnet); +#endif + break; + + case SP_TYPE_LIBNET: + err(-1, "Libnet is no longer supported!"); + break; + } + safe_free(sp); + return 0; +} + +/** + * returns the Layer 2 address of the interface current + * open. on error, return NULL + */ +struct tcpr_ether_addr * +sendpacket_get_hwaddr(sendpacket_t *sp) +{ + struct tcpr_ether_addr *addr; + assert(sp); + + /* if we already have our MAC address stored, just return it */ + if (memcmp(&sp->ether, "\x00\x00\x00\x00\x00\x00", ETHER_ADDR_LEN) != 0) + return &sp->ether; + +#if defined HAVE_PF_PACKET + addr = sendpacket_get_hwaddr_pf(sp); +#elif defined HAVE_BPF + addr = sendpacket_get_hwaddr_bpf(sp); +#elif defined HAVE_LIBDNET + addr = sendpacket_get_hwaddr_libdnet(sp); +#elif (defined HAVE_PCAP_INJECT || defined HAVE_PCAP_SENDPACKET) + addr = sendpacket_get_hwaddr_pcap(sp); +#endif + return addr; +} + +/** + * returns the error string + */ +char * +sendpacket_geterr(sendpacket_t *sp) +{ + assert(sp); + return sp->errbuf; +} + +/** + * Set's the error string + */ +static void +sendpacket_seterr(sendpacket_t *sp, const char *fmt, ...) +{ + va_list ap; + + assert(sp); + + va_start(ap, fmt); + if (fmt != NULL) + (void)vsnprintf(sp->errbuf, SENDPACKET_ERRBUF_SIZE, fmt, ap); + va_end(ap); + + sp->errbuf[(SENDPACKET_ERRBUF_SIZE-1)] = '\0'; // be safe +} + + +#if defined HAVE_PCAP_INJECT || defined HAVE_PCAP_SENDPACKET +/** + * Inner sendpacket_open() method for using libpcap + */ +static sendpacket_t * +sendpacket_open_pcap(const char *device, char *errbuf) +{ + pcap_t *pcap; + sendpacket_t *sp; +#ifdef BIOCSHDRCMPLT + u_int spoof_eth_src = 1; + int fd; +#endif + + assert(device); + assert(errbuf); + + dbg(1, "sendpacket: using Libpcap"); + + /* open_pcap_live automatically fills out our errbuf for us */ + if ((pcap = pcap_open_live(device, 0, 0, 0, errbuf)) == NULL) + return NULL; + + sp = (sendpacket_t *)safe_malloc(sizeof(sendpacket_t)); + strlcpy(sp->device, device, sizeof(sp->device)); + sp->handle.pcap = pcap; + +#ifdef BIOCSHDRCMPLT + /* + * Only systems using BPF on the backend need this... + * other systems don't have ioctl and will get compile errors. + */ + fd = pcap_get_selectable_fd(pcap); + if (ioctl(fd, BIOCSHDRCMPLT, &spoof_eth_src) == -1) + errx(-1, "Unable to enable source MAC spoof support: %s", strerror(errno)); +#endif + sp->handle_type = SP_TYPE_LIBPCAP; + + return sp; +} + +/** + * Get the hardware MAC address for the given interface using libpcap + */ +static struct tcpr_ether_addr * +sendpacket_get_hwaddr_pcap(sendpacket_t *sp) +{ + assert(sp); + sendpacket_seterr(sp, "Error: sendpacket_get_hwaddr() not yet supported for pcap injection"); + return NULL; +} +#endif /* HAVE_PCAP_INJECT || HAVE_PCAP_SENDPACKET */ + +#if defined HAVE_LIBDNET +/** + * Inner sendpacket_open() method for using libdnet + */ +static sendpacket_t * +sendpacket_open_libdnet(const char *device, char *errbuf) +{ + eth_t *ldnet; + sendpacket_t *sp; + + assert(device); + assert(errbuf); + + dbg(1, "sendpacket: using Libdnet"); + + if ((ldnet = eth_open(device)) == NULL) + return NULL; + + sp = (sendpacket_t *)safe_malloc(sizeof(sendpacket_t)); + strlcpy(sp->device, device, sizeof(sp->device)); + sp->handle.ldnet = ldnet; + sp->handle_type = SP_TYPE_LIBDNET; + return sp; +} + +/** + * Get the hardware MAC address for the given interface using libdnet + */ +static struct tcpr_ether_addr * +sendpacket_get_hwaddr_libdnet(sendpacket_t *sp) +{ + struct tcpr_ether_addr *addr; + int ret; + assert(sp); + + ret = eth_get(sp->handle.ldnet, (eth_addr_t *)addr); + + if (addr == NULL || ret < 0) { + sendpacket_seterr(sp, "Error getting hwaddr via libdnet: %s", strerror(errno)); + return NULL; + } + + memcpy(&sp->ether, addr, sizeof(struct tcpr_ether_addr)); + return(&sp->ether); +} +#endif /* HAVE_LIBDNET */ + +#if defined HAVE_PF_PACKET +/** + * Inner sendpacket_open() method for using Linux's PF_PACKET + */ +static sendpacket_t * +sendpacket_open_pf(const char *device, char *errbuf) +{ + int mysocket; + sendpacket_t *sp; + struct ifreq ifr; + struct sockaddr_ll sa; + int n = 1, err; + socklen_t errlen = sizeof(err); + + assert(device); + assert(errbuf); + + dbg(1, "sendpacket: using PF_PACKET"); + + /* open our socket */ + if ((mysocket = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) < 0) { + snprintf(errbuf, SENDPACKET_ERRBUF_SIZE, "socket: %s", strerror(errno)); + return NULL; + } + + + /* get the interface id for the device */ + if ((sa.sll_ifindex = get_iface_index(mysocket, device, errbuf)) < 0) { + close(mysocket); + return NULL; + } + + /* bind socket to our interface id */ + sa.sll_family = AF_PACKET; + sa.sll_protocol = htons(ETH_P_ALL); + if (bind(mysocket, (struct sockaddr *)&sa, sizeof(sa)) < 0) { + snprintf(errbuf, SENDPACKET_ERRBUF_SIZE, "bind error: %s", strerror(errno)); + close(mysocket); + return NULL; + } + + /* check for errors, network down, etc... */ + if (getsockopt(mysocket, SOL_SOCKET, SO_ERROR, &err, &errlen) < 0) { + snprintf(errbuf, SENDPACKET_ERRBUF_SIZE, "error opening %s: %s", device, + strerror(errno)); + close(mysocket); + return NULL; + } + + if (err > 0) { + snprintf(errbuf, SENDPACKET_ERRBUF_SIZE, "error opening %s: %s", device, + strerror(err)); + close(mysocket); + return NULL; + } + + /* get hardware type for our interface */ + memset(&ifr, 0, sizeof(ifr)); + strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)); + + if (ioctl(mysocket, SIOCGIFHWADDR, &ifr) < 0) { + close(mysocket); + sendpacket_seterr(sp, "Error getting hardware type: %s", strerror(errno)); + return NULL; + } + + /* make sure it's not loopback (PF_PACKET doesn't support it) */ + if (ifr.ifr_hwaddr.sa_family != ARPHRD_ETHER) + warnx("Unsupported physical layer type 0x%04x on %s. Maybe it works, maybe it wont." + " See tickets #123/318", ifr.ifr_hwaddr.sa_family, device); + +#ifdef SO_BROADCAST + /* + * man 7 socket + * + * Set or get the broadcast flag. When enabled, datagram sockets + * receive packets sent to a broadcast address and they are allowed + * to send packets to a broadcast address. This option has no + * effect on stream-oriented sockets. + */ + if (setsockopt(mysocket, SOL_SOCKET, SO_BROADCAST, &n, sizeof(n)) == -1) { + snprintf(errbuf, SENDPACKET_ERRBUF_SIZE, + "SO_BROADCAST: %s\n", strerror(errno)); + close(mysocket); + return NULL; + } +#endif /* SO_BROADCAST */ + + + /* prep & return our sp handle */ + sp = (sendpacket_t *)safe_malloc(sizeof(sendpacket_t)); + strlcpy(sp->device, device, sizeof(sp->device)); + sp->handle.fd = mysocket; + sp->handle_type = SP_TYPE_PF_PACKET; + + return sp; +} + +/** + * get the interface index (necessary for sending packets w/ PF_PACKET) + */ +static int +get_iface_index(int fd, const int8_t *device, char *errbuf) { + struct ifreq ifr; + + memset(&ifr, 0, sizeof(ifr)); + strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)); + + if (ioctl(fd, SIOCGIFINDEX, &ifr) == -1) { + snprintf(errbuf, SENDPACKET_ERRBUF_SIZE, "ioctl: %s", strerror(errno)); + return (-1); + } + + return ifr.ifr_ifindex; +} + +/** + * get's the hardware address via Linux's PF packet interface + */ +struct tcpr_ether_addr * +sendpacket_get_hwaddr_pf(sendpacket_t *sp) +{ + struct ifreq ifr; + int fd; + + assert(sp); + + if (!sp->open) { + sendpacket_seterr(sp, "Unable to get hardware address on un-opened sendpacket handle"); + return NULL; + } + + + /* create dummy socket for ioctl */ + if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + sendpacket_seterr(sp, "Unable to open dummy socket for get_hwaddr: %s", strerror(errno)); + return NULL; + } + + memset(&ifr, 0, sizeof(ifr)); + strlcpy(ifr.ifr_name, sp->device, sizeof(ifr.ifr_name)); + + if (ioctl(fd, SIOCGIFHWADDR, (int8_t *)&ifr) < 0) { + close(fd); + sendpacket_seterr(sp, "Error getting hardware address: %s", strerror(errno)); + return NULL; + } + + memcpy(&sp->ether, &ifr.ifr_hwaddr.sa_data, ETHER_ADDR_LEN); + close(fd); + return(&sp->ether); +} +#endif /* HAVE_PF_PACKET */ + +#if defined HAVE_BPF +/** + * Inner sendpacket_open() method for using BSD's BPF interface + */ +static sendpacket_t * +sendpacket_open_bpf(const char *device, char *errbuf) +{ + sendpacket_t *sp; + char bpf_dev[10]; + int dev, mysocket, link_offset, link_type; + struct ifreq ifr; + struct bpf_version bv; + u_int v; +#if defined(BIOCGHDRCMPLT) && defined(BIOCSHDRCMPLT) + u_int spoof_eth_src = 1; +#endif + + assert(device); + assert(errbuf); + memset(&ifr, '\0', sizeof(struct ifreq)); + + dbg(1, "sendpacket: using BPF"); + /* open socket */ + mysocket = -1; + for (dev = 0; dev <= 9; dev ++) { + memset(bpf_dev, '\0', sizeof(bpf_dev)); + snprintf(bpf_dev, sizeof(bpf_dev), "/dev/bpf%d", dev); + if ((mysocket = open(bpf_dev, O_RDWR, 0)) > 0) { + break; + } + } + + /* error?? */ + if (mysocket < 0) { + snprintf(errbuf, SENDPACKET_ERRBUF_SIZE, + "Unable to open /dev/bpfX: %s", strerror(errno)); + errbuf[SENDPACKET_ERRBUF_SIZE -1] = '\0'; + return NULL; + } + + /* get BPF version */ + if (ioctl(mysocket, BIOCVERSION, (caddr_t)&bv) < 0) { + snprintf(errbuf, SENDPACKET_ERRBUF_SIZE, "Unable to get bpf version: %s", strerror(errno)); + return NULL; + } + + if (bv.bv_major != BPF_MAJOR_VERSION || bv.bv_minor != BPF_MINOR_VERSION) { + snprintf(errbuf, SENDPACKET_ERRBUF_SIZE, "Kernel's bpf version is out of date."); + return NULL; + } + + /* attach to device */ + strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)); + if (ioctl(mysocket, BIOCSETIF, (caddr_t)&ifr) < 0) { + snprintf(errbuf, SENDPACKET_ERRBUF_SIZE, "Unable to bind %s to %s: %s", + bpf_dev, device, strerror(errno)); + return NULL; + } + + /* get datalink type */ + if (ioctl(mysocket, BIOCGDLT, (caddr_t)&v) < 0) { + snprintf(errbuf, SENDPACKET_ERRBUF_SIZE, "Unable to get datalink type: %s", + strerror(errno)); + return NULL; + } + + /* + * NetBSD and FreeBSD BPF have an ioctl for enabling/disabling + * automatic filling of the link level source address. + */ +#if defined(BIOCGHDRCMPLT) && defined(BIOCSHDRCMPLT) + if (ioctl(mysocket, BIOCSHDRCMPLT, &spoof_eth_src) == -1) { + snprintf(errbuf, SENDPACKET_ERRBUF_SIZE, + "Unable to enable spoofing src MAC: %s", strerror(errno)); + return NULL; + } +#endif + + /* assign link type and offset */ + switch (v) { + case DLT_SLIP: + link_offset = 0x10; + break; + case DLT_RAW: + link_offset = 0x0; + break; + case DLT_PPP: + link_offset = 0x04; + break; + case DLT_EN10MB: + default: /* default to Ethernet */ + link_offset = 0xe; + break; + } +#if _BSDI_VERSION - 0 > 199510 + switch (v) { + case DLT_SLIP: + v = DLT_SLIP_BSDOS; + link_offset = 0x10; + break; + case DLT_PPP: + v = DLT_PPP_BSDOS; + link_offset = 0x04; + break; + } +#endif + + link_type = v; + + /* allocate our sp handle, and return it */ + sp = (sendpacket_t *)safe_malloc(sizeof(sendpacket_t)); + strlcpy(sp->device, device, sizeof(sp->device)); + sp->handle.fd = mysocket; + //sp->link_type = link_type; + //sp->link_offset = link_offset; + sp->handle_type = SP_TYPE_BPF; + + return sp; +} + +/** + * Get the interface hardware MAC address when using BPF + */ +struct tcpr_ether_addr * +sendpacket_get_hwaddr_bpf(sendpacket_t *sp) +{ + int mib[6]; + size_t len; + int8_t *buf, *next, *end; + struct if_msghdr *ifm; + struct sockaddr_dl *sdl; + + assert(sp); + + mib[0] = CTL_NET; + mib[1] = AF_ROUTE; + mib[2] = 0; + mib[3] = AF_LINK; + mib[4] = NET_RT_IFLIST; + mib[5] = 0; + + if (sysctl(mib, 6, NULL, &len, NULL, 0) == -1) { + sendpacket_seterr(sp, "%s(): sysctl(): %s", __func__, strerror(errno)); + return NULL; + } + + buf = (int8_t *)safe_malloc(len); + + if (sysctl(mib, 6, buf, &len, NULL, 0) == -1) { + sendpacket_seterr(sp, "%s(): sysctl(): %s", __func__, strerror(errno)); + safe_free(buf); + return NULL; + } + + end = buf + len; + for (next = buf; next < end; next += ifm->ifm_msglen) { + ifm = (struct if_msghdr *)next; + if (ifm->ifm_type == RTM_IFINFO) { + sdl = (struct sockaddr_dl *)(ifm + 1); + if (strncmp(&sdl->sdl_data[0], sp->device, sdl->sdl_len) == 0) { + memcpy(&sp->ether, LLADDR(sdl), ETHER_ADDR_LEN); + break; + } + } + } + safe_free(buf); + return(&sp->ether); +} + +#endif /* HAVE_BPF */ + +/** + * Get the DLT type of the opened sendpacket + * Return -1 if we can't figure it out, else return the DLT_ value + */ +int +sendpacket_get_dlt(sendpacket_t *sp) +{ + int dlt; +#if defined HAVE_BPF + int rcode; + + if ((rcode = ioctl(sp->handle.fd, BIOCGDLT, &dlt)) < 0) { + warnx("Unable to get DLT value for BPF device (%s): %s", sp->device, strerror(errno)); + return(-1); + } +#elif defined HAVE_PF_PACKET || defined HAVE_LIBDNET + /* use libpcap to get dlt */ + pcap_t *pcap; + char errbuf[PCAP_ERRBUF_SIZE]; + if ((pcap = pcap_open_live(sp->device, 65535, 0, 0, errbuf)) == NULL) { + warnx("Unable to get DLT value for %s: %s", sp->device, errbuf); + return(-1); + } + dlt = pcap_datalink(pcap); + pcap_close(pcap); +#elif defined HAVE_PCAP_SENDPACKET || defined HAVE_PCAP_INJECT + dlt = pcap_datalink(sp->handle.pcap); +#endif + return dlt; +} + +const char * +sendpacket_get_method() +{ + return INJECT_METHOD; +} diff --git a/src/common/sendpacket.h b/src/common/sendpacket.h new file mode 100644 index 0000000..1d205a9 --- /dev/null +++ b/src/common/sendpacket.h @@ -0,0 +1,101 @@ +/* $Id: sendpacket.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "defines.h" +#ifdef HAVE_PF_PACKET +#include +#endif + +#ifdef HAVE_LIBDNET +/* need to undef these which are pulled in via defines.h, prior to importing dnet.h */ +#undef icmp_id +#undef icmp_seq +#undef icmp_data +#undef icmp_mask +#include +#endif + +#ifndef _SENDPACKET_H_ +#define _SENDPACKET_H_ + +enum sendpacket_type_t { + SP_TYPE_LIBNET, + SP_TYPE_LIBDNET, + SP_TYPE_LIBPCAP, + SP_TYPE_BPF, + SP_TYPE_PF_PACKET +}; + +union sendpacket_handle { + pcap_t *pcap; + int fd; +#ifdef HAVE_LIBDNET + eth_t *ldnet; +#endif +}; + +#define SENDPACKET_ERRBUF_SIZE 1024 + +struct sendpacket_s { + tcpr_dir_t cache_dir; + int open; + char device[20]; + char errbuf[SENDPACKET_ERRBUF_SIZE]; + COUNTER retry_enobufs; + COUNTER retry_eagain; + COUNTER failed; + COUNTER sent; + COUNTER bytes_sent; + COUNTER attempt; + enum sendpacket_type_t handle_type; + union sendpacket_handle handle; + struct tcpr_ether_addr ether; +#ifdef HAVE_PF_PACKET + struct sockaddr_ll sa; +#endif +}; + +typedef struct sendpacket_s sendpacket_t; + +int sendpacket(sendpacket_t *, const u_char *, size_t); +int sendpacket_close(sendpacket_t *); +char *sendpacket_geterr(sendpacket_t *); +char *sendpacket_getstat(sendpacket_t *); +sendpacket_t *sendpacket_open(const char *, char *, tcpr_dir_t); +struct tcpr_ether_addr *sendpacket_get_hwaddr(sendpacket_t *); +int sendpacket_get_dlt(sendpacket_t *); +const char *sendpacket_get_method(); + +#endif /* _SENDPACKET_H_ */ + + diff --git a/src/common/services.c b/src/common/services.c new file mode 100644 index 0000000..fc981bc --- /dev/null +++ b/src/common/services.c @@ -0,0 +1,116 @@ +/* $Id: services.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2004-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "defines.h" +#include "common.h" + +#include +#include +#include +#include +#include + +/** + * parses /etc/services so we know which ports are service ports + */ +void +parse_services(const char *file, tcpr_services_t *services) +{ + FILE *service = NULL; + char service_line[MAXLINE], port[10], proto[10]; + regex_t preg; + u_int16_t portc; + size_t nmatch = 3; + regmatch_t pmatch[3]; + char regex[] = "([0-9]+)/(tcp|udp)"; /* matches the port as pmatch[1], service pmatch[2] */ + + dbgx(1, "Parsing %s", file); + memset(service_line, '\0', MAXLINE); + + /* mark all ports not a service */ + memset(services->tcp, '\0', NUM_PORTS); + memset(services->udp, '\0', NUM_PORTS); + + if ((service = fopen(file, "r")) == NULL) { + errx(-1, "Unable to open service file: %s\n%s", file, strerror(errno)); + } + + /* compile our regexes */ + if ((regcomp(&preg, regex, REG_ICASE|REG_EXTENDED)) != 0) { + errx(-1, "Unable to compile regex: %s", regex); + } + + /* parse the entire file */ + while ((fgets(service_line, MAXLINE, service)) != NULL) { + /* zero out our vars */ + memset(port, '\0', 10); + memset(proto, '\0', 10); + portc = 0; + + dbgx(4, "Procesing: %s", service_line); + + /* look for format of 1234/tcp */ + if ((regexec(&preg, service_line, nmatch, pmatch, 0)) == 0) { /* matches */ + if (nmatch < 2) { + err(-1, "WTF? I matched the line, but I don't know where!"); + } + + /* strip out the port & proto from the line */ + strncpy(port, &service_line[pmatch[1].rm_so], (pmatch[1].rm_eo - pmatch[1].rm_so)); + strncpy(proto, &service_line[pmatch[2].rm_so], (pmatch[2].rm_eo - pmatch[2].rm_so)); + + /* convert port[] into an integer */ + portc = (u_int16_t)atoi(port); + + /* update appropriate service array with the server port */ + if (strcmp(proto, "tcp") == 0) { + dbgx(3, "Setting TCP/%d as a server port", portc); + services->tcp[portc] = 1; /* mark it as a service port */ + } else if (strcmp(proto, "udp") == 0) { + dbgx(3, "Setting UDP/%d as a server port", portc); + services->udp[portc] = 1; + } else { + warnx("Skipping unknown protocol service %s/%d", proto, portc); + } + } + } +} + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + diff --git a/src/common/services.h b/src/common/services.h new file mode 100644 index 0000000..b7e991d --- /dev/null +++ b/src/common/services.h @@ -0,0 +1,50 @@ +/* $Id: services.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __SERVICES_H__ +#define __SERVICES_H__ + +void parse_services(const char *file, tcpr_services_t *services); + +/* max width of a line in /etc/services */ +#define MAXLINE 1024 + +#endif + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + diff --git a/src/common/svn_version.c b/src/common/svn_version.c new file mode 100644 index 0000000..30d50ec --- /dev/null +++ b/src/common/svn_version.c @@ -0,0 +1,4 @@ +const char SVN_Version[] = "2450"; +const char *svn_version(void) { + return SVN_Version; +} diff --git a/src/common/tcpdump.c b/src/common/tcpdump.c new file mode 100644 index 0000000..cfb40e7 --- /dev/null +++ b/src/common/tcpdump.c @@ -0,0 +1,387 @@ +/* $Id: tcpdump.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This code allows us to use tcpdump to print packet decodes. + * Basically, we create a local AF_UNIX socketpair, fork a copy + * of ourselves, link 1/2 of the pair to STDIN of the child and + * replace the child with tcpdump. We then send a "pcap" file + * over the socket so that tcpdump can print it's decode to STDOUT. + * + * Idea and a lot of code stolen from Christain Kreibich's + * libnetdude 0.4 code. Any bugs are mine. :) + * + * This product includes software developed by the University of California, + * Lawrence Berkeley Laboratory and its contributors + */ + +#include "config.h" +#include "defines.h" +#include "common.h" + +#include +#include +#include +#include +#include +#include +#ifdef HAVE_SIGNAL_H +#include +#endif + +#include "tcpdump.h" +#include "lib/strlcpy.h" + +#ifdef DEBUG +extern int debug; +#endif + +char *options_vec[OPTIONS_VEC_SIZE]; +static int tcpdump_fill_in_options(char *opt); +static int can_exec(const char *filename); + +/** + * given a packet, print a decode of via tcpdump + */ +int +tcpdump_print(tcpdump_t *tcpdump, struct pcap_pkthdr *pkthdr, const u_char *data) +{ + struct pollfd poller[1]; + int result; + char decode[TCPDUMP_DECODE_LEN]; + + assert(tcpdump); + assert(pkthdr); + assert(data); + + poller[0].fd = tcpdump->infd; + poller[0].events = POLLOUT; + poller[0].revents = 0; + + /* wait until we can write to the tcpdump socket */ + result = poll(poller, 1, TCPDUMP_POLL_TIMEOUT); + if (result < 0) + errx(-1, "Error during poll() to write to tcpdump\n%s", strerror(errno)); + + if (result == 0) + err(-1, "poll() timeout... tcpdump seems to be having a problem keeping up\n" + "Try increasing TCPDUMP_POLL_TIMEOUT"); + + + /* result > 0 if we get here */ + + if (write(tcpdump->infd, (char *)pkthdr, sizeof(struct pcap_pkthdr)) + != sizeof(struct pcap_pkthdr)) + errx(-1, "Error writing pcap file header to tcpdump\n%s", strerror(errno)); + +#ifdef DEBUG + if (debug >= 5) { + if (write(tcpdump->debugfd, (char *)pkthdr, sizeof(struct pcap_pkthdr)) + != sizeof(struct pcap_pkthdr)) + errx(-1, "Error writing pcap file header to tcpdump debug\n%s", strerror(errno)); + } +#endif + + if (write(tcpdump->infd, data, pkthdr->caplen) != (ssize_t)pkthdr->caplen) + errx(-1, "Error writing packet data to tcpdump\n%s", strerror(errno)); + +#ifdef DEBUG + if (debug >= 5) { + if (write(tcpdump->debugfd, data, pkthdr->caplen) != (ssize_t)pkthdr->caplen) + errx(-1, "Error writing packet data to tcpdump debug\n%s", strerror(errno)); + } +#endif + + /* Wait for output from tcpdump */ + poller[0].fd = tcpdump->outfd; + poller[0].events = POLLIN; + poller[0].revents = 0; + + result = poll(poller, 1, TCPDUMP_POLL_TIMEOUT); + if (result < 0) + errx(-1, "Error during poll() to write to tcpdump\n%s", strerror(errno)); + + if (result == 0) + err(-1, "poll() timeout... tcpdump seems to be having a problem keeping up\n" + "Try increasing TCPDUMP_POLL_TIMEOUT"); + + /* result > 0 if we get here */ + if (read(tcpdump->outfd, &decode, TCPDUMP_DECODE_LEN) < 0) + errx(-1, "Error reading tcpdump decode: %s", strerror(errno)); + + printf("%s", decode); + + return TRUE; +} + +/** + * init our tcpdump handle using the given pcap handle + * Basically, this starts up tcpdump as a child and communicates + * to it via a pair of sockets (stdout/stdin) + */ +int +tcpdump_open(tcpdump_t *tcpdump, pcap_t *pcap) +{ + int infd[2], outfd[2]; + FILE *writer; + + assert(tcpdump); + assert(pcap); + + if (tcpdump->pid != 0) { + warn("tcpdump process already running"); + return FALSE; + } + + /* is tcpdump executable? */ + if (! can_exec(TCPDUMP_BINARY)) { + errx(-1, "Unable to execute tcpdump binary: %s", TCPDUMP_BINARY); + } + +#ifdef DEBUG + strlcpy(tcpdump->debugfile, TCPDUMP_DEBUG, sizeof(tcpdump->debugfile)); + if (debug >= 5) { + dbgx(5, "Opening tcpdump debug file: %s", tcpdump->debugfile); + + if ((tcpdump->debugfd = open(tcpdump->debugfile, O_WRONLY|O_CREAT|O_TRUNC, + S_IREAD|S_IWRITE|S_IRGRP|S_IROTH)) == -1) { + errx(-1, "Error opening tcpdump debug file: %s\n%s", tcpdump->debugfile, strerror(errno)); + } + } +#endif + + /* copy over the args */ + dbg(2, "Prepping tcpdump options..."); + tcpdump_fill_in_options(tcpdump->args); + + dbg(2, "Starting tcpdump..."); + + /* create our socket pair to send packet data to tcpdump via */ + if (socketpair(AF_UNIX, SOCK_STREAM, 0, infd) < 0) + errx(-1, "Unable to create stdin socket pair: %s", strerror(errno)); + + /* create our socket pair to read packet decode from tcpdump */ + if (socketpair(AF_UNIX, SOCK_STREAM, 0, outfd) < 0) + errx(-1, "Unable to create stdout socket pair: %s", strerror(errno)); + + + if ((tcpdump->pid = fork() ) < 0) + errx(-1, "Fork failed: %s", strerror(errno)); + + dbgx(2, "tcpdump pid: %d", tcpdump->pid); + + if (tcpdump->pid > 0) { + /* we're still in tcpreplay */ + dbgx(2, "[parent] closing input fd %d", infd[1]); + close(infd[1]); /* close the tcpdump side */ + dbgx(2, "[parent] closing output fd %d", outfd[1]); + close(outfd[1]); + tcpdump->infd = infd[0]; + tcpdump->outfd = outfd[0]; + + /* send the pcap file header to tcpdump */ + writer = fdopen(tcpdump->infd, "w"); + if ((tcpdump->dumper = pcap_dump_fopen(pcap, writer)) == NULL) { + warnx("[parent] pcap_dump_fopen(): %s", pcap_geterr(pcap)); + return FALSE; + } + pcap_dump_flush(tcpdump->dumper); + + if (fcntl(tcpdump->infd, F_SETFL, O_NONBLOCK) < 0) + warnx("[parent] Unable to fcntl tcpreplay socket:\n%s", strerror(errno)); + + if (fcntl(tcpdump->outfd, F_SETFL, O_NONBLOCK) < 0) + warnx("[parent] Unable to fnctl stdout socket:\n%s", strerror(errno)); + + } + else { + dbg(2, "[child] started the kid"); + + /* we're in the child process */ + dbgx(2, "[child] closing in fd %d", infd[0]); + dbgx(2, "[child] closing out fd %d", outfd[0]); + close(infd[0]); /* close the tcpreplay side */ + close(outfd[0]); + + /* copy our side of the socketpair to our stdin */ + if (infd[1] != STDIN_FILENO) { + if (dup2(infd[1], STDIN_FILENO) != STDIN_FILENO) + errx(-1, "[child] Unable to copy socket to stdin: %s", + strerror(errno)); + } + + /* copy our side of the socketpair to our stdout */ + if (outfd[1] != STDOUT_FILENO) { + if (dup2(outfd[1], STDOUT_FILENO) != STDOUT_FILENO) + errx(-1, "[child] Unable to copy socket to stdout: %s", + strerror(errno)); + } + + /* exec tcpdump */ + dbg(2, "[child] Exec'ing tcpdump..."); + if (execv(TCPDUMP_BINARY, options_vec) < 0) + errx(-1, "Unable to exec tcpdump: %s", strerror(errno)); + + } + + return TRUE; +} + +/** + * shutdown tcpdump + */ +void +tcpdump_close(tcpdump_t *tcpdump) +{ + if (! tcpdump) + return; + + if (tcpdump->pid <= 0) + return; + + dbgx(2, "[parent] killing tcpdump pid: %d", tcpdump->pid); + + kill(tcpdump->pid, SIGKILL); + close(tcpdump->infd); + close(tcpdump->outfd); + + if (waitpid(tcpdump->pid, NULL, 0) != tcpdump->pid) + errx(-1, "[parent] Error in waitpid: %s", strerror(errno)); + + tcpdump->pid = 0; + tcpdump->infd = 0; + tcpdump->outfd = 0; +} + +/** + * forcefully kill tcpdump + */ +void +tcpdump_kill(tcpdump_t *tcpdump) +{ + if (tcpdump->pid) { + if (kill(tcpdump->pid, SIGTERM) != 0) { + kill(tcpdump->pid, SIGKILL); + } + } + tcpdump->infd = 0; + tcpdump->outfd = 0; + tcpdump->pid = 0; +} + + +/** + * copy the string of args (*opt) to the vector (**opt_vec) + * for a max of opt_len. Returns the number of options + * in the vector + */ +static int +tcpdump_fill_in_options(char *opt) +{ + char options[256]; + char *arg, *newarg; + int i = 1, arglen; + char *token = NULL; + + /* zero out our options_vec for execv() */ + memset(options_vec, '\0', OPTIONS_VEC_SIZE); + + /* first arg should be the binary (by convention) */ + options_vec[0] = TCPDUMP_BINARY; + + + /* prep args */ + memset(options, '\0', 256); + if (opt != NULL) { + strlcat(options, opt, sizeof(options)); + } + strlcat(options, TCPDUMP_ARGS, sizeof(options)); + dbgx(2, "[child] Will execute: tcpdump %s", options); + + + /* process args */ + + /* process the first argument */ + arg = strtok_r(options, OPT_DELIM, &token); + arglen = strlen(arg) + 2; /* -{arg}\0 */ + newarg = (char *)safe_malloc(arglen); + strlcat(newarg, "-", arglen); + strlcat(newarg, arg, arglen); + options_vec[i++] = newarg; + + /* process the remaining args + note that i < OPTIONS_VEC_SIZE - 1 + because: a) we need to add '-' as an option to the end + b) because the array has to be null terminated + */ + while (((arg = strtok_r(NULL, OPT_DELIM, &token)) != NULL) && + (i < OPTIONS_VEC_SIZE - 1)) { + + arglen = strlen(arg) + 2; + newarg = (char *)safe_malloc(arglen); + strlcat(newarg, "-", arglen); + strlcat(newarg, arg, arglen); + options_vec[i++] = newarg; + + } + + /* tell -r to read from stdin */ + options_vec[i] = "-"; + + return(i); +} + + +/** + * can we exec the given file? + */ +static int +can_exec(const char *filename) +{ + struct stat st; + + if (!filename || filename[0] == '\0') + return FALSE; + + /* Stat the file to see if it's executable and + if the user may run it. + */ + if (lstat(filename, &st) < 0) + return FALSE; + + if ((st.st_mode & S_IXUSR) || + (st.st_mode & S_IXGRP) || + (st.st_mode & S_IXOTH)) + return TRUE; + + return FALSE; +} diff --git a/src/common/tcpdump.h b/src/common/tcpdump.h new file mode 100644 index 0000000..fc5829d --- /dev/null +++ b/src/common/tcpdump.h @@ -0,0 +1,93 @@ +/* $Id: tcpdump.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __TCPDUMP_H__ +#define __TCPDUMP_H__ + +/* line buffer stdout, read from stdin */ +#define TCPDUMP_ARGS " -n -l -r -" + +/* max number of tcpdump options; must be a multiple of 4 */ +#define OPTIONS_VEC_SIZE 32 + +/* how long to wait (in ms) to write to tcpdump */ +#define TCPDUMP_POLL_TIMEOUT 500 + +/* delim to be used for strtok() to process tcpdump args */ +#define OPT_DELIM " -" + +/* output file of data passed to tcpdump when debug level 5 is enabled */ +#define TCPDUMP_DEBUG "tcpdump.debug" + +/* taken from libpcap's savefile.c */ +#define TCPDUMP_MAGIC 0xa1b2c3d4 +#define PATCHED_TCPDUMP_MAGIC 0xa1b2cd34 + +#define TCPDUMP_DECODE_LEN 65535 + +struct tcpdump_s { + char *filename; + char *args; + struct pcap_file_header pfh; + int pid; + int infd; /* fd to write to. 1/2 of the socketpair */ + int outfd; /* fd to read from. */ + pcap_dumper_t *dumper; + + /* following vars are for figuring out exactly what we send to + * tcpdump. See TCPDUMP_DEBUG + */ +#ifdef DEBUG + int debugfd; + char debugfile[255]; +#endif +}; + +typedef struct tcpdump_s tcpdump_t; + +//int tcpdump_init(tcpdump_t *tcpdump); +int tcpdump_open(tcpdump_t *tcpdump, pcap_t *pcap); +//int tcpdump_open_live(tcpdump_t *tcpdump, pcap_t *pcap); +int tcpdump_print(tcpdump_t *tcpdump, struct pcap_pkthdr *pkthdr, const u_char *data); +void tcpdump_close(tcpdump_t *tcpdump); +void tcpdump_kill(tcpdump_t *tcpdump); + +#endif + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + diff --git a/src/common/timer.c b/src/common/timer.c new file mode 100644 index 0000000..cc34249 --- /dev/null +++ b/src/common/timer.c @@ -0,0 +1,81 @@ +/* $Id: timer.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "defines.h" +#include "common.h" + +#include "timer.h" + +#include + +/* Miscellaneous timeval routines */ + +/** + * Divide tvp by div, storing the result in tvp + */ +void +timerdiv(struct timeval *tvp, float div) +{ + double interval; + + if (div == 0 || div == 1) + return; + + interval = ((double)tvp->tv_sec * 1000000 + tvp->tv_usec) / (double)div; + tvp->tv_sec = interval / (int)1000000; + tvp->tv_usec = interval - (tvp->tv_sec * 1000000); +} + +/* Divide tvs by div, storing the result in tvs */ +void timesdiv(struct timespec *tvs, float div) +{ + double interval; + + if (div == 0 || div == 1) + return; + + interval = ((double)tvs->tv_sec * 1000000000 + tvs->tv_nsec) / (double)div; + tvs->tv_sec = interval / (int)1000000000; + tvs->tv_nsec = interval - (tvs->tv_sec * 1000000000); +} + +void +init_delta_time(delta_t *ctx) +{ +#ifdef HAVE_ABSOLUTE_TIME + SetZero(*ctx); +#else + timerclear(ctx); +#endif +} + diff --git a/src/common/timer.h b/src/common/timer.h new file mode 100644 index 0000000..004988c --- /dev/null +++ b/src/common/timer.h @@ -0,0 +1,260 @@ +/* $Id: timer.h 2434 2010-03-28 21:04:52Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _TIMER_H_ +#define _TIMER_H_ + +#include "config.h" +#include "defines.h" +#include "tcpreplay.h" +#include "common.h" + +#include +#include +#include + +#ifdef HAVE_ABSOLUTE_TIME +#include +#endif + +/* AbsoluteTime methods */ +#ifndef NonZero +#define NonZero(x) ((x).hi | (x).lo) +#endif +#ifndef SetZero +#define SetZero(x) do { (x).hi = 0 ; (x).lo = 0; } while(0) +#endif +#ifndef CopyAbsolute +#define CopyAbsolute(x, y) do { (x).lo = (y).lo ; (x).hi = (y).hi; } while (0) +#endif +#ifndef AbsoluteCmp +#define AbsoluteCmp(left, right, cmp) \ + (((left)->hi == (right)->hi) ? \ + ((left)->lo cmp (right)->lo) : \ + ((left)->hi cmp (right)->hi)) +#endif + +/* + * 1 sec = 1,0000 millisec (ms) + * 1 sec = 1,000,000 microsec (us) + * 1 sec = 1,000,000,000 nanosec (ns) + * 1 millisec = 1,000 microsec + * 1 microsec = 1,000 nanosec + */ + +void timerdiv(struct timeval *tvp, float div); +void timesdiv(struct timespec *tvs, float div); + +/* convert float time to struct timeval *tvp */ +#ifndef float2timer +#define float2timer(time, tvp) \ + do { \ + (tvp)->tv_sec = time; \ + (tvp)->tv_usec = (time - (tvp)->tv_sec) * 100000; \ + } while (0) +#endif + +/* timesec to float */ +#ifndef timer2float +#define timer2float(tvp, time) \ + do { \ + time = (tvp)->tv_sec; \ + time += (float)((tvp)->tv_usec / 10000) * 0.01; \ + } while (0) +#endif + +#ifndef TIMEVAL_TO_TIMESPEC +#define TIMEVAL_TO_TIMESPEC(tv, ts) { \ + (ts)->tv_sec = (tv)->tv_sec; \ + (ts)->tv_nsec = (tv)->tv_usec * 1000; } +#endif + +#ifndef TIMESPEC_TO_TIMEVAL +#define TIMESPEC_TO_TIMEVAL(tv, ts) { \ + (tv)->tv_sec = (ts)->tv_sec; \ + (tv)->tv_usec = (ts)->tv_nsec / 1000; } +#endif + +#ifndef ROUND_TIMESPEC_TO_MICROSEC +#define ROUND_TIMESPEC_TO_MICROSEC(ts) \ + do { \ + (ts)->tv_nsec = ((((ts)->tv_nsec / 1000) + ((ts)->tv_nsec % 1000 >= 500 ? 1 : 0)) * 1000); \ + } while (0) +#endif + + + +/* zero out a timer */ +#ifndef timerclear +#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0 +#endif + +/* zero out a timespec */ +#ifndef timesclear +#define timesclear(tvs) (tvs)->tv_sec = (tvs)->tv_nsec = 0 +#endif + +/* is timer non-zero? */ +#ifndef timerisset +#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) +#endif + +/* is timespec non-zero? */ +#ifndef timesisset +#define timesisset(tvs) ((tvs)->tv_sec || (tvs)->tv_nsec) +#endif + + +/* add tvp and uvp and store in vvp */ +#ifndef timeradd +#define timeradd(tvp, uvp, vvp) \ + do { \ + (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \ + (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \ + if ((vvp)->tv_usec >= 1000000) { \ + (vvp)->tv_sec++; \ + (vvp)->tv_usec -= 1000000; \ + } \ + } while (0) +#endif + +/* subtract uvp from tvp and store in vvp */ +#ifndef timersub +#define timersub(tvp, uvp, vvp) \ + do { \ + (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \ + (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \ + if ((vvp)->tv_usec < 0) { \ + (vvp)->tv_sec--; \ + (vvp)->tv_usec += 1000000; \ + } \ + } while (0) +#endif + +#ifndef timessub +#define timessub(tsp, usp, vsp) \ + do { \ + (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \ + (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \ + if ((vsp)->tv_nsec < 0) { \ + (vsp)->tv_sec--; \ + (vsp)->tv_nsec += 1000000000; \ + } \ + } while (0) +#endif + +/* compare tvp and uvp using cmp */ +#ifndef timercmp +#define timercmp(tvp, uvp, cmp) \ + (((tvp)->tv_sec == (uvp)->tv_sec) ? \ + ((tvp)->tv_usec cmp (uvp)->tv_usec) : \ + ((tvp)->tv_sec cmp (uvp)->tv_sec)) +#endif + +#ifndef timescmp +#define timescmp(tsp, usp, cmp) \ + (((tsp)->tv_sec == (usp)->tv_sec) ? \ + ((tsp)->tv_nsec cmp (usp)->tv_nsec) : \ + ((tsp)->tv_sec cmp (usp)->tv_sec)) +#endif + +/* multiply tvp by x and store in uvp */ +#define timermul(tvp, uvp, x) \ + do { \ + (uvp)->tv_sec = (tvp)->tv_sec * x; \ + (uvp)->tv_usec = (tvp)->tv_usec * x; \ + while((uvp)->tv_usec > 1000000) { \ + (uvp)->tv_sec++; \ + (uvp)->tv_usec -= 1000000; \ + } \ + } while(0) + +#ifdef HAVE_ABSOLUTE_TIME + typedef AbsoluteTime delta_t; +#else + typedef struct timeval delta_t; +#endif + +/* + * starts a timer so we can figure out how much time has passed + * when we call get_delta_timer() + */ +static inline void +start_delta_time(delta_t *ctx) +{ +#ifdef HAVE_ABSOLUTE_TIME + *ctx = UpTime(); +#else + gettimeofday(ctx, NULL); +#endif +} + +void init_delta_time(delta_t *ctx); + +/* + * returns the amount of time that has passed since the + * last time you called start_delta_time() + */ +static inline void +get_delta_time(delta_t *ctx, struct timespec *ret) +{ +/* OS X has absolute time */ +#ifdef HAVE_ABSOLUTE_TIME + AbsoluteTime now, delta; + Nanoseconds nano; + + now = UpTime(); + + if (! NonZero(*ctx)) { + timesclear(ret); + } else { + delta = SubAbsoluteFromAbsolute(now, *ctx); + nano = AbsoluteToNanoseconds(delta); + NANOSEC_TO_TIMESPEC(UnsignedWideToUInt64(nano) / 10, ret); + } + +/* Everyone else just uses gettimeofday */ +#else + struct timeval now, delta; + + gettimeofday(&now, NULL); + + if (!timerisset(ctx)) { + timesclear(ret); + } else { + timersub(&now, ctx, &delta); + TIMEVAL_TO_TIMESPEC(&delta, ret); + } +#endif +} + +#endif /* _TIMER_H_ */ diff --git a/src/common/utils.c b/src/common/utils.c new file mode 100644 index 0000000..fdea014 --- /dev/null +++ b/src/common/utils.c @@ -0,0 +1,222 @@ +/* $Id: utils.c 2433 2010-03-28 20:57:36Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "defines.h" +#include "common.h" + +#include +#include +#include +#include + +#ifdef DEBUG +extern int debug; +#endif + +/** + * this is wrapped up in a #define safe_malloc + * This function, detects failures to malloc memory and zeros out the + * memory before returning + */ + +void * +_our_safe_malloc(size_t len, const char *funcname, const int line, const char *file) +{ + u_char *ptr; + + if ((ptr = malloc(len)) == NULL) { + fprintf(stderr, "ERROR in %s:%s() line %d: Unable to malloc() %zu bytes", file, funcname, line, len); + exit(-1); + } + + /* zero memory */ + memset(ptr, 0, len); + + /* wrapped inside an #ifdef for better performance */ + dbgx(5, "Malloc'd %zu bytes in %s:%s() line %d", len, file, funcname, line); + + return (void *)ptr; +} + +/** + * this is wrapped up in a #define safe_realloc + * This function, detects failures to realloc memory and zeros + * out the NEW memory if len > current len. As always, remember + * to use it as: + * ptr = safe_realloc(ptr, size) + */ +void * +_our_safe_realloc(void *ptr, size_t len, const char *funcname, const int line, const char *file) +{ + + if ((ptr = realloc(ptr, len)) == NULL) { + fprintf(stderr, "ERROR: in %s:%s() line %d: Unable to remalloc() buffer to %zu bytes", file, funcname, line, len); + exit(-1); + } + + dbgx(5, "Remalloc'd buffer to %zu bytes in %s:%s() line %d", len, file, funcname, line); + + return ptr; +} + +/** + * this is wrapped up in a #define safe_strdup + * This function, detects failures to realloc memory + */ +char * +_our_safe_strdup(const char *str, const char *funcname, const int line, const char *file) +{ + char *newstr; + + if ((newstr = (char *)malloc(strlen(str) + 1)) == NULL) { + fprintf(stderr, "ERROR in %s:%s() line %d: Unable to strdup() %zu bytes\n", file, funcname, line, strlen(str)); + exit(-1); + } + + memcpy(newstr, str, strlen(str) + 1); + + return newstr; + +} + +/** + * calls free and sets to NULL. + */ +void +_our_safe_free(void *ptr, const char *funcname, const int line, const char *file) +{ + if (ptr == NULL) { + fprintf(stderr, "ERROR in %s:%s() line %d: Unable to call free on a NULL ptr", file, funcname, line); + exit(-1); + } + + free(ptr); + ptr = NULL; +} + +/** + * Print various packet statistics + */ +void +packet_stats(struct timeval *begin, struct timeval *end, + COUNTER bytes_sent, COUNTER pkts_sent, COUNTER failed) +{ + float bytes_sec = 0.0, mb_sec = 0.0, pkts_sec = 0.0; + double frac_sec; + struct timeval diff; + + timersub(end, begin, &diff); + timer2float(&diff, frac_sec); + + if (timerisset(&diff)) { + if (bytes_sent){ + bytes_sec = bytes_sent / frac_sec; + mb_sec = (bytes_sec * 8) / (1024 * 1024); + } + if (pkts_sent) + pkts_sec = pkts_sent / frac_sec; + } + printf("Actual: " COUNTER_SPEC " packets (" COUNTER_SPEC " bytes) sent in %.02f seconds.", + pkts_sent, bytes_sent, frac_sec); + printf("\t\tRated: %.1f bps, %.2f Mbps, %.2f pps\n", + bytes_sec, mb_sec, pkts_sec); + + if (failed) + printf(COUNTER_SPEC " write attempts failed from full buffers and were repeated\n", + failed); + +} + +/** + * reads a hexstring in the format of xx,xx,xx,xx spits it back into *hex + * up to hexlen bytes. Returns actual number of bytes returned. On error + * it just calls errx() since all errors are fatal. + */ +int +read_hexstring(const char *l2string, u_char *hex, const int hexlen) +{ + int numbytes = 0; + unsigned int value; + char *l2byte; + u_char databyte; + char *token = NULL; + char *string; + + string = safe_strdup(l2string); + + if (hexlen <= 0) + err(-1, "Hex buffer must be > 0"); + + memset(hex, '\0', hexlen); + + /* data is hex, comma seperated, byte by byte */ + + /* get the first byte */ + l2byte = strtok_r(string, ",", &token); + sscanf(l2byte, "%x", &value); + if (value > 0xff) + errx(-1, "Invalid hex string byte: %s", l2byte); + databyte = (u_char) value; + memcpy(&hex[numbytes], &databyte, 1); + + /* get remaining bytes */ + while ((l2byte = strtok_r(NULL, ",", &token)) != NULL) { + numbytes++; + if (numbytes + 1 > hexlen) { + warn("Hex buffer too small for data- skipping data"); + return (++numbytes); + } + sscanf(l2byte, "%x", &value); + if (value > 0xff) + errx(-1, "Invalid hex string byte: %s", l2byte); + databyte = (u_char) value; + memcpy(&hex[numbytes], &databyte, 1); + } + + numbytes++; + + safe_free(string); + + dbgx(1, "Read %d bytes of hex data", numbytes); + return (numbytes); +} + +#ifdef USE_CUSTOM_INET_ATON +int +inet_aton(const char *name, struct in_addr *addr) +{ + in_addr_t a = inet_addr (name); + addr->s_addr = a; + return a != (in_addr_t)-1; +} +#endif diff --git a/src/common/utils.h b/src/common/utils.h new file mode 100644 index 0000000..c9f6ef6 --- /dev/null +++ b/src/common/utils.h @@ -0,0 +1,75 @@ +/* $Id: utils.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#ifndef _UTILS_H_ +#define _UTILS_H_ + +#include "config.h" +#include "defines.h" +#include "common.h" + +int read_hexstring(const char *l2string, u_char *hex, const int hexlen); +void packet_stats(struct timeval *begin, struct timeval *end, + COUNTER bytes_sent, COUNTER pkts_sent, COUNTER failed); + +/* our "safe" implimentations of functions which allocate memory */ +#define safe_malloc(x) _our_safe_malloc(x, __FUNCTION__, __LINE__, __FILE__) +void *_our_safe_malloc(size_t len, const char *, const int, const char *); + +#define safe_realloc(x, y) _our_safe_realloc(x, y, __FUNCTION__, __LINE__, __FILE__) +void *_our_safe_realloc(void *ptr, size_t len, const char *, const int, const char *); + +#define safe_strdup(x) _our_safe_strdup(x, __FUNCTION__, __LINE__, __FILE__) +char *_our_safe_strdup(const char *str, const char *, const int, const char *); + +#define safe_free(x) _our_safe_free(x, __FUNCTION__, __LINE__, __FILE__) +void _our_safe_free(void *ptr, const char *, const int, const char *); + +#define MAX_ARGS 128 + +#ifndef HAVE_INET_ATON +#define HAVE_INET_ATON +#define USE_CUSTOM_INET_ATON +int inet_aton(const char *name, struct in_addr *addr); +#endif + +#endif + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + diff --git a/src/common/xX.c b/src/common/xX.c new file mode 100644 index 0000000..c80da02 --- /dev/null +++ b/src/common/xX.c @@ -0,0 +1,249 @@ +/* $Id: xX.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * xX stands for "include or exclude" which is used with the + * -x and -X flags + * + * Functions for use to process args for or check data against in + * tcpreplay/do_packets and tcpprep. + */ + +#include "config.h" +#include "defines.h" +#include "common.h" +#include + +/** + * returns the include_exclude_mode on success placing the CIDR or LIST in mybuf + * but on failure, returns xXError + */ +int +parse_xX_str(tcpr_xX_t *xX, char *str, tcpr_bpf_t *bpf) +{ + int out = 0; + + dbgx(1, "Parsing string: %s", str); + dbgx(1, "Switching on: %c", str[0]); + + switch (str[0]) { + case 'B': /* both ip's */ + str = str + 2; + out = xXBoth; + if (!parse_cidr(&(xX->cidr), str, ",")) + return xXError; + break; + + case 'D': /* dst ip */ + str = str + 2; + out = xXDest; + if (!parse_cidr(&(xX->cidr), str, ",")) + return xXError; + break; + + case 'E': /* either ip */ + str = str + 2; + out = xXEither; + if (!parse_cidr(&(xX->cidr), str, ",")) + return xXError; + break; + + case 'F': /* bpf filter */ + str = str + 2; + out = xXBPF; + bpf->filter = safe_strdup(str); + /* + * note: it's temping to compile the BPF here, but we don't + * yet know what the link type is for the file, so we have + * to compile the BPF once we open the pcap file + */ + break; + + case 'P': /* packet id */ + str = str + 2; + out = xXPacket; + if (!parse_list(&(xX->list), str)) + return xXError; + break; + + case 'S': /* source ip */ + str = str + 2; + out = xXSource; + if (!parse_cidr(&(xX->cidr), str, ",")) + return xXError; + break; + + default: + errx(-1, "Invalid -%c option: %c", xX->mode, *str); + break; + } + + if (xX->mode == 'X') { /* run in exclude mode */ + out += xXExclude; + if (bpf->filter != NULL) + err(-1, "Using a BPF filter with -X doesn't work.\n" + "Try using -xF:\"not \" instead"); + } + + xX->mode = out; + return xX->mode; +} + + + +/** + * compare the source/destination IP address according to the mode + * and return 1 if we should send the packet or 0 if not + */ +int +process_xX_by_cidr_ipv4(int mode, tcpr_cidr_t * cidr, ipv4_hdr_t * ip_hdr) +{ + + if (mode & xXExclude) { + /* Exclude mode */ + switch (mode ^ xXExclude) { + case xXSource: + /* note: check_ip_cidr() returns TCPR_DIR_C2S for true, TCPR_DIR_S2C for false + * and NOT true/false or 1/0, etc! + */ + return check_ip_cidr(cidr, ip_hdr->ip_src.s_addr) ? DONT_SEND : SEND; + break; + + case xXDest: + return check_ip_cidr(cidr, ip_hdr->ip_dst.s_addr) ? DONT_SEND : SEND; + + case xXBoth: + return (check_ip_cidr(cidr, ip_hdr->ip_dst.s_addr) && + check_ip_cidr(cidr, ip_hdr->ip_src.s_addr) ) ? DONT_SEND : SEND; + break; + + case xXEither: + return (check_ip_cidr(cidr, ip_hdr->ip_dst.s_addr) || + check_ip_cidr(cidr, ip_hdr->ip_src.s_addr) ) ? DONT_SEND : SEND; + break; + } + } + else { + /* Include Mode */ + switch (mode) { + case xXSource: + return check_ip_cidr(cidr, ip_hdr->ip_src.s_addr) ? SEND : DONT_SEND; + break; + + case xXDest: + return check_ip_cidr(cidr, ip_hdr->ip_dst.s_addr) ? SEND : DONT_SEND; + break; + + case xXBoth: + return (check_ip_cidr(cidr, ip_hdr->ip_dst.s_addr) && + check_ip_cidr(cidr, ip_hdr->ip_src.s_addr) ) ? SEND : DONT_SEND; + break; + + case xXEither: + return (check_ip_cidr(cidr, ip_hdr->ip_dst.s_addr) || + check_ip_cidr(cidr, ip_hdr->ip_src.s_addr) ) ? SEND : DONT_SEND; + break; + } + } + + /* total failure */ + if (mode &xXExclude) { + warn("Unable to determine action in CIDR filter mode. Default: Don't Send."); + return DONT_SEND; + } else { + warn("Unable to determine action in CIDR filter mode. Default: Send."); + return SEND; + } + +} + +int +process_xX_by_cidr_ipv6(int mode, tcpr_cidr_t * cidr, ipv6_hdr_t * ip6_hdr) +{ + + if (mode & xXExclude) { + /* Exclude mode */ + switch (mode ^ xXExclude) { + case xXSource: + /* note: check_ip_cidr() returns TCPR_DIR_C2S for true, TCPR_DIR_S2C for false + * and NOT true/false or 1/0, etc! + */ + return check_ip6_cidr(cidr, &ip6_hdr->ip_src) ? DONT_SEND : SEND; + break; + + case xXDest: + return check_ip6_cidr(cidr, &ip6_hdr->ip_dst) ? DONT_SEND : SEND; + + case xXBoth: + return (check_ip6_cidr(cidr, &ip6_hdr->ip_dst) && + check_ip6_cidr(cidr, &ip6_hdr->ip_src) ) ? DONT_SEND : SEND; + break; + + case xXEither: + return (check_ip6_cidr(cidr, &ip6_hdr->ip_dst) || + check_ip6_cidr(cidr, &ip6_hdr->ip_src) ) ? DONT_SEND : SEND; + break; + } + } + else { + /* Include Mode */ + switch (mode) { + case xXSource: + return check_ip6_cidr(cidr, &ip6_hdr->ip_src) ? SEND : DONT_SEND; + break; + + case xXDest: + return check_ip6_cidr(cidr, &ip6_hdr->ip_dst) ? SEND : DONT_SEND; + break; + + case xXBoth: + return (check_ip6_cidr(cidr, &ip6_hdr->ip_dst) && + check_ip6_cidr(cidr, &ip6_hdr->ip_src) ) ? SEND : DONT_SEND; + break; + + case xXEither: + return (check_ip6_cidr(cidr, &ip6_hdr->ip_dst) || + check_ip6_cidr(cidr, &ip6_hdr->ip_src) ) ? SEND : DONT_SEND; + break; + } + } + + /* total failure */ + if (mode &xXExclude) { + warn("Unable to determine action in CIDR filter mode. Default: Don't Send."); + return DONT_SEND; + } else { + warn("Unable to determine action in CIDR filter mode. Default: Send."); + return SEND; + } + +} diff --git a/src/common/xX.h b/src/common/xX.h new file mode 100644 index 0000000..bc6592e --- /dev/null +++ b/src/common/xX.h @@ -0,0 +1,66 @@ +/* $Id: xX.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __xX_H__ +#define __xX_H__ + +/* + * Functions for processing args/data generated by -x and -X + */ + +int parse_xX_str(tcpr_xX_t *xX, char *str, tcpr_bpf_t *bpf); +int process_xX_by_cidr_ipv4(int, tcpr_cidr_t *, ipv4_hdr_t *); +int process_xX_by_cidr_ipv6(int, tcpr_cidr_t *, ipv6_hdr_t *); + +/* + * Include/Exclude (xXmode) values + */ +#define xXError 0 +#define xXSource 1 +#define xXDest 2 +#define xXBoth 4 +#define xXEither 8 +#define xXPacket 16 +#define xXBPF 32 +#define xXExclude 128 /* if exclude mode, add 128 to above value */ + + +#endif + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + diff --git a/src/config.h.in b/src/config.h.in new file mode 100644 index 0000000..1486415 --- /dev/null +++ b/src/config.h.in @@ -0,0 +1,547 @@ +/* src/config.h.in. Generated from configure.ac by autoheader. */ + +/* Define if building universal (internal helper macro) */ +#undef AC_APPLE_UNIVERSAL_BUILD + +/* What version of autogen is installed on this system */ +#undef AUTOGEN_VERSION + +/* Enable debuging code and support for the -d option */ +#undef DEBUG + +/* Enable dmalloc function arg checking */ +#undef DMALLOC_FUNC_CHECK + +/* Enable Electric Fence memory debugger */ +#undef EFENCE + +/* Use 64bit packet counters */ +#undef ENABLE_64BITS + +/* Enable dmalloc */ +#undef ENABLE_DMALLOC + +/* Enable dynamically linking libs */ +#undef ENABLE_DYNAMIC_LINK + +/* Enable fragroute module */ +#undef ENABLE_FRAGROUTE + +/* Enable use of pcap_findalldevs() */ +#undef ENABLE_PCAP_FINDALLDEVS + +/* Compile tcpbridge */ +#undef ENABLE_TCPBRIDGE + +/* Do we have tcpdump and pcap_dump_fopen()? */ +#undef ENABLE_VERBOSE + +/* fopen(3) accepts a 'b' in the mode flag */ +#undef FOPEN_BINARY_FLAG + +/* fopen(3) accepts a 't' in the mode flag */ +#undef FOPEN_TEXT_FLAG + +/* Are we strictly aligned? */ +#undef FORCE_ALIGN + +/* Force using BPF for sending packet */ +#undef FORCE_INJECT_BPF + +/* Force using libdnet for sending packets */ +#undef FORCE_INJECT_LIBDNET + +/* Force using libpcap's pcap_inject() for sending packets */ +#undef FORCE_INJECT_PCAP_INJECT + +/* Force using libpcap's pcap_sendpacket() for sending packets */ +#undef FORCE_INJECT_PCAP_SENDPACKET + +/* Force using Linux's PF_PACKET for sending packets */ +#undef FORCE_INJECT_PF + +/* Enable GNU Profiler */ +#undef GPROF + +/* Have OS X UpTime()/AbsoluteTime high-precision timing */ +#undef HAVE_ABSOLUTE_TIME + +/* Define to 1 if you have the header file. */ +#undef HAVE_ARPA_INET_H + +/* Do we have BPF device support? */ +#undef HAVE_BPF + +/* Define to 1 if you have the `canonicalize_file_name' function. */ +#undef HAVE_CANONICALIZE_FILE_NAME + +/* Define to 1 if you have the `ctime' function. */ +#undef HAVE_CTIME + +/* Building Apple/Darwin */ +#undef HAVE_DARWIN + +/* Define this if /dev/zero is readable device */ +#undef HAVE_DEV_ZERO + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_DIRENT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Does pcap.h include a header with DLT_C_HDLC? */ +#undef HAVE_DLT_C_HDLC + +/* Does pcap.h include a header with DLT_LINUX_SLL? */ +#undef HAVE_DLT_LINUX_SLL + +/* Does libpcap have pcap_datalink_val_to_description? */ +#undef HAVE_DLT_VAL_TO_DESC + +/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ +#undef HAVE_DOPRNT + +/* Define to 1 if you have the header file. */ +#undef HAVE_ERRNO_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ +#undef HAVE_FSEEKO + +/* Define to 1 if you have the `gettimeofday' function. */ +#undef HAVE_GETTIMEOFDAY + +/* Do we have inet_addr? */ +#undef HAVE_INET_ADDR + +/* Do we have inet_aton? */ +#undef HAVE_INET_ATON + +/* Do we have inet_ntop? */ +#undef HAVE_INET_NTOP + +/* Do we have inet_pton? */ +#undef HAVE_INET_PTON + +/* Define to 1 if the system has the type `int16_t'. */ +#undef HAVE_INT16_T + +/* Define to 1 if the system has the type `int32_t'. */ +#undef HAVE_INT32_T + +/* Define to 1 if the system has the type `int8_t'. */ +#undef HAVE_INT8_T + +/* Define to 1 if the system has the type `intptr_t'. */ +#undef HAVE_INTPTR_T + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Do we have libdnet? */ +#undef HAVE_LIBDNET + +/* Define to 1 if you have the `gen' library (-lgen). */ +#undef HAVE_LIBGEN + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIBGEN_H + +/* Define to 1 if you have the `nsl' library (-lnsl). */ +#undef HAVE_LIBNSL + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +#undef HAVE_LIBRESOLV + +/* Define to 1 if you have the `rt' library (-lrt). */ +#undef HAVE_LIBRT + +/* Define to 1 if you have the `socket' library (-lsocket). */ +#undef HAVE_LIBSOCKET + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIMITS_H + +/* Define to 1 if your system has a GNU libc compatible `malloc' function, and + to 0 otherwise. */ +#undef HAVE_MALLOC + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `memset' function. */ +#undef HAVE_MEMSET + +/* Define to 1 if you have the `mmap' function. */ +#undef HAVE_MMAP + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +#undef HAVE_NDIR_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETINET_IN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NET_ROUTE_H + +/* Define to 1 if you have the `ntohll' function. */ +#undef HAVE_NTOHLL + +/* Define this if pathfind(3) works */ +#undef HAVE_PATHFIND + +/* Do we have libpcapnav? */ +#undef HAVE_PCAPNAV + +/* Does libpcap have pcap_breakloop? */ +#undef HAVE_PCAP_BREAKLOOP + +/* Does libpcap have pcap_dump_fopen? */ +#undef HAVE_PCAP_DUMP_FOPEN + +/* Does libpcap have pcap_get_selectable_fd? */ +#undef HAVE_PCAP_GET_SELECTABLE_FD + +/* Does libpcap have pcap_inject? */ +#undef HAVE_PCAP_INJECT + +/* Does libpcap have pcap_sendpacket? */ +#undef HAVE_PCAP_SENDPACKET + +/* Does libpcap have pcap_setnonblock? */ +#undef HAVE_PCAP_SETNONBLOCK + +/* Does libpcap have pcap_snapshot? */ +#undef HAVE_PCAP_SNAPSHOT + +/* Does libpcap have pcap_version[] */ +#undef HAVE_PCAP_VERSION + +/* Do we have Linux PF_PACKET socket support? */ +#undef HAVE_PF_PACKET + +/* Define to 1 if the system has the type `pid_t'. */ +#undef HAVE_PID_T + +/* Define to 1 if you have the `poll' function. */ +#undef HAVE_POLL + +/* Define to 1 if you have the header file. */ +#undef HAVE_POLL_H + +/* Define this if we have a functional realpath(3C) */ +#undef HAVE_REALPATH + +/* Define to 1 if you have the `regcomp' function. */ +#undef HAVE_REGCOMP + +/* Define to 1 if you have the header file. */ +#undef HAVE_RUNETYPE_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SETJMP_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SIGNAL_H + +/* Define to 1 if the system has the type `size_t'. */ +#undef HAVE_SIZE_T + +/* Define to 1 if you have the `snprintf' function. */ +#undef HAVE_SNPRINTF + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDARG_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDDEF_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the `strchr' function. */ +#undef HAVE_STRCHR + +/* Define to 1 if you have the `strdup' function. */ +#undef HAVE_STRDUP + +/* Define to 1 if you have the `strerror' function. */ +#undef HAVE_STRERROR + +/* Define this if strftime() works */ +#undef HAVE_STRFTIME + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the `strlcpy' function. */ +#undef HAVE_STRLCPY + +/* Define to 1 if you have the `strncpy' function. */ +#undef HAVE_STRNCPY + +/* Define to 1 if you have the `strrchr' function. */ +#undef HAVE_STRRCHR + +/* Define to 1 if you have the `strsignal' function. */ +#undef HAVE_STRSIGNAL + +/* Define to 1 if you have the `strtol' function. */ +#undef HAVE_STRTOL + +/* Define to 1 if you have the `strtoull' function. */ +#undef HAVE_STRTOULL + +/* Define to 1 if `tv_sec' is a member of `struct timeval'. */ +#undef HAVE_STRUCT_TIMEVAL_TV_SEC + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYSEXITS_H + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_SYS_DIR_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_LIMITS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_MMAN_H + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#undef HAVE_SYS_NDIR_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_PARAM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_POLL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_PROCSET_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SELECT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SOCKET_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STROPTS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SYSCTL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIME_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_UN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_WAIT_H + +/* Do we have tcpdump? */ +#undef HAVE_TCPDUMP + +/* Define to 1 if the system has the type `uint16_t'. */ +#undef HAVE_UINT16_T + +/* Define to 1 if the system has the type `uint32_t'. */ +#undef HAVE_UINT32_T + +/* Define to 1 if the system has the type `uint8_t'. */ +#undef HAVE_UINT8_T + +/* Define to 1 if the system has the type `uintptr_t'. */ +#undef HAVE_UINTPTR_T + +/* Define to 1 if the system has the type `uint_t'. */ +#undef HAVE_UINT_T + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UTIME_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_VALUES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_VARARGS_H + +/* Define to 1 if you have the `vprintf' function. */ +#undef HAVE_VPRINTF + +/* Define to 1 if you have the `vsnprintf' function. */ +#undef HAVE_VSNPRINTF + +/* Define to 1 if you have the header file. */ +#undef HAVE_WCHAR_H + +/* Define to 1 if the system has the type `wchar_t'. */ +#undef HAVE_WCHAR_T + +/* Windows/Cygwin */ +#undef HAVE_WIN32 + +/* Do we have WinPcap? */ +#undef HAVE_WINPCAP + +/* Define to 1 if the system has the type `wint_t'. */ +#undef HAVE_WINT_T + +/* What is the path (if any) to the libpcap bpf header file? */ +#undef INCLUDE_PCAP_BPF_HEADER + +/* Version of libdnet */ +#undef LIBDNET_VERSION + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#undef LT_OBJDIR + +/* Define to 1 if `major', `minor', and `makedev' are declared in . + */ +#undef MAJOR_IN_MKDEV + +/* Define to 1 if `major', `minor', and `makedev' are declared in + . */ +#undef MAJOR_IN_SYSMACROS + +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +#undef NO_MINUS_C_MINUS_O + +/* Define this if optional arguments are disallowed */ +#undef NO_OPTIONAL_OPT_ARGS + +/* This is our package name */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* libpcapnav's version? */ +#undef PCAPNAV_VERSION + +/* 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_CHARP + +/* The size of `int', as computed by sizeof. */ +#undef SIZEOF_INT + +/* The size of `long', as computed by sizeof. */ +#undef SIZEOF_LONG + +/* The size of `short', as computed by sizeof. */ +#undef SIZEOF_SHORT + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* The tcpdump binary initially used */ +#undef TCPDUMP_BINARY + +/* Define to 1 if you can safely include both and . */ +#undef TIME_WITH_SYS_TIME + +/* What is our version? */ +#undef VERSION + +/* Define if using the dmalloc debugging malloc package */ +#undef WITH_DMALLOC + +/* Define this if a working libregex can be found */ +#undef WITH_LIBREGEX + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +# undef WORDS_BIGENDIAN +# endif +#endif + +/* Enable large inode numbers on Mac OS X 10.5. */ +#ifndef _DARWIN_USE_64_BIT_INODE +# define _DARWIN_USE_64_BIT_INODE 1 +#endif + +/* Number of bits in a file offset, on hosts where this is settable. */ +#undef _FILE_OFFSET_BITS + +/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ +#undef _LARGEFILE_SOURCE + +/* Define for large files, on AIX-style hosts. */ +#undef _LARGE_FILES + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#undef inline +#endif + +/* Define to rpl_malloc if the replacement function should be used. */ +#undef malloc + +/* Define to `unsigned int' if does not define. */ +#undef size_t + +/* Define to `uint16_t' if does not define. */ +#undef u_int16_t + +/* Define to `uint32_t' if does not define. */ +#undef u_int32_t + +/* Define to `uint64_t' if does not define. */ +#undef u_int64_t + +/* Define to `uint8_t' if does not define. */ +#undef u_int8_t diff --git a/src/defines.h.in b/src/defines.h.in new file mode 100644 index 0000000..3a1bf1e --- /dev/null +++ b/src/defines.h.in @@ -0,0 +1,285 @@ +#ifndef __DEFINES_H__ +#define __DEFINES_H__ + +#include "config.h" +#include "tcpr.h" + +/* should packet counters be 32 or 64 bit? --enable-64bit */ +#ifdef ENABLE_64BITS +#define COUNTER unsigned long long +#define COUNTER_SPEC "%llu" +#else +#define COUNTER unsigned long +#define COUNTER_SPEC "%lu" +#endif + + +#ifdef HAVE_BPF +#include +#define PCAP_DONT_INCLUDE_PCAP_BPF_H 1 +#endif + +#if defined INCLUDE_PCAP_BPF_H_FILE && !defined PCAP_DONT_INCLUDE_PCAP_BPF_H +#include "@PCAP_BPF_H_FILE@" +#define PCAP_DONT_INCLUDE_PCAP_BPF_H 1 /* don't re-include it in pcap.h */ +#endif + +#include "@LPCAPINC@" + +#include "lib/strlcpy.h" +#include "common/list.h" +#include "common/cidr.h" + +/* + * net/bpf.h doesn't include DLT types, but pcap-bpf.h does. + * Unfortunately, pcap-bpf.h also includes things in net/bpf.h + * while also missing some key things (wow, that sucks) + * The result is that I stole the DLT types from pcap-bpf.h and + * put them in here. + */ +#include "common/dlt_names.h" + + +#ifdef HAVE_LIBNET +#include "@LNETINC@" +#endif + +typedef struct tcpr_ipv4_hdr ipv4_hdr_t; +typedef struct tcpr_ipv6_hdr ipv6_hdr_t; +typedef struct tcpr_tcp_hdr tcp_hdr_t; +typedef struct tcpr_udp_hdr udp_hdr_t; +typedef struct tcpr_icmpv4_hdr icmpv4_hdr_t; +typedef struct tcpr_icmpv6_hdr icmpv6_hdr_t; +typedef struct tcpr_ethernet_hdr eth_hdr_t; +typedef struct tcpr_802_1q_hdr vlan_hdr_t; +typedef struct sll_header sll_hdr_t; +typedef struct tcpr_arp_hdr arp_hdr_t; +typedef struct tcpr_dnsv4_hdr dnsv4_hdr_t; + +/* our custom typdefs/structs */ +typedef u_char tcpr_macaddr_t[TCPR_ETH_H]; + +struct tcpr_bpf_s { + char *filter; + int optimize; + struct bpf_program program; +}; +typedef struct tcpr_bpf_s tcpr_bpf_t; + +struct tcpr_xX_s { +#define xX_MODE_INCLUDE 'x' +#define xX_MODE_EXCLUDE 'X' + int mode; + tcpr_list_t *list; + tcpr_cidr_t *cidr; +#define xX_TYPE_LIST 1 +#define xX_TYPE_CIDR 2 + int type; +}; +typedef struct tcpr_xX_s tcpr_xX_t; + +/* number of ports 0-65535 */ +#define NUM_PORTS 65536 +struct tcpr_services_s { + char tcp[NUM_PORTS]; + char udp[NUM_PORTS]; +}; +typedef struct tcpr_services_s tcpr_services_t; + +struct tcpr_speed_s { + /* speed modifiers */ + int mode; +#define SPEED_MULTIPLIER 1 +#define SPEED_MBPSRATE 2 +#define SPEED_PACKETRATE 3 +#define SPEED_TOPSPEED 4 +#define SPEED_ONEATATIME 5 + float speed; + int pps_multi; +}; +typedef struct tcpr_speed_s tcpr_speed_t; + +#define MAX_FILES 1024 /* Max number of files we can pass to tcpreplay */ + +#define DEFAULT_MTU 1500 /* Max Transmission Unit of standard ethernet + * don't forget *frames* are MTU + L2 header! */ + +#define MAXPACKET 65535 /* was 16436 linux loopback, but maybe something is bigger then + linux loopback */ + +#define MAX_SNAPLEN 65535 /* tell libpcap to capture the entire packet */ + +#define DNS_RESOLVE 1 +#define DNS_DONT_RESOLVE 0 + +#define RESOLVE 0 /* disable dns lookups */ +#define BPF_OPTIMIZE 1 /* default is to optimize bpf program */ +#define PCAP_TIMEOUT 100 /* 100ms pcap_open_live timeout */ + +/* HP-UX already defines TRUE/FALSE */ +#ifndef TRUE +enum bool_t { + FALSE = 0, + TRUE +}; +#endif + +#define EBUF_SIZE 1024 /* size of our error buffers */ +#define MAC_SIZE 7 /* size of the mac[] buffer */ + +enum pad_t { + PAD_PACKET, + TRUNC_PACKET +}; + +#define DNS_QUERY_FLAG 0x8000 + +enum direction_t { + DIR_UNKNOWN = -1, + DIR_CLIENT = 0, + DIR_SERVER = 1, + DIR_ANY = 2 +}; + +enum tcpprep_mode { + ERROR_MODE, /* Some kind of error has occurred */ + CIDR_MODE, /* single pass, CIDR netblock */ + REGEX_MODE, /* single pass, regex */ + PORT_MODE, /* single pass, use src/dst ports to split */ + MAC_MODE, /* single pass, use src mac to split */ + FIRST_MODE, /* single pass, use first seen to split */ + AUTO_MODE, /* first pass through in auto mode */ + ROUTER_MODE, /* second pass through in router mode */ + BRIDGE_MODE, /* second pass through in bridge mode */ + SERVER_MODE, /* second pass through in server (router) mode */ + CLIENT_MODE /* second pass through in client (router) mode */ +}; + +#define BROADCAST_MAC "\xFF\xFF\xFF\xFF\xFF\xFF" + +/* MAC macros for printf */ +#define MAC_FORMAT "%02X:%02X:%02X:%02X:%02X:%02X" +#define MAC_STR(x) x[0], x[1], x[2], x[3], x[4], x[5] + +/* struct timeval print structs */ +#ifdef HAVE_DARWIN +/* Darwin defines usec as an __int32_t, not unsigned long. */ +#define TIMEVAL_FORMAT "%lus %dusec" +#else +#define TIMEVAL_FORMAT "%lus %luusec" +#endif +#define TIMESPEC_FORMAT "%lus %lunsec" + +/* force a word or half-word swap on both Big and Little endian systems */ +#ifndef SWAPLONG +#define SWAPLONG(y) \ +((((y)&0xff)<<24) | (((y)&0xff00)<<8) | (((y)&0xff0000)>>8) | (((y)>>24)&0xff)) +#endif + +#ifndef SWAPSHORT +#define SWAPSHORT(y) \ +( (((y)&0xff)<<8) | ((u_short)((y)&0xff00)>>8) ) +#endif + +/* converts a 64bit int to network byte order */ +#ifndef HAVE_NTOHLL +#ifdef WORDS_BIGENDIAN +#define ntohll(x) (x) +#define htonll(x) (x) +#else +/* stolen from http://www.codeproject.com/cpp/endianness.asp */ +#define ntohll(x) (((u_int64_t)(ntohl((int)((x << 32) >> 32))) << 32) | \ + (unsigned int)ntohl(((int)(x >> 32)))) +#define htonll(x) ntohll(x) +#endif /* WORDS_BIGENDIAN */ +#endif + +#define DEBUG_INFO 1 /* informational only, lessthan 1 line per packet */ +#define DEBUG_BASIC 2 /* limited debugging, one line per packet */ +#define DEBUG_DETAIL 3 /* more detailed, a few lines per packet */ +#define DEBUG_MORE 4 /* even more detail */ +#define DEBUG_CODE 5 /* examines code & values, many lines per packet */ + + +/* Win32 doesn't know about PF_INET6 */ +#ifndef PF_INET6 +#ifdef AF_INET6 +#define PF_INET6 AF_INET6 +#else +#define PF_INET6 30 /* stolen from OS/X */ +#endif +#endif + +/* convert IPv6 Extention Header Len value to bytes */ +#define IPV6_EXTLEN_TO_BYTES(x) ((x * 4) + 8) + +#ifndef HAVE_UINT8_T +typedef u_int8_t uint8_t +typedef u_int16_t uint16_t +typedef u_int32_t uint32_t +#endif + +/* Support for flexible arrays. */ +#undef __flexarr +#if defined(__GNUC__) && ((__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)) +/* GCC 2.97 supports C99 flexible array members. */ +# define __flexarr [] +#else +# ifdef __GNUC__ +# define __flexarr [0] +# else +# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +# define __flexarr [] +# elif defined(_WIN32) +/* MS VC++ */ +# define __flexarr [] +# else +/* Some other non-C99 compiler. Approximate with [1]. */ +# define __flexarr [1] +# endif +# endif +#endif + + +/* Time converters */ +#define SEC_TO_MILLISEC(x) (x * 1000) +#define SEC_TO_MICROSEC(x) (x * 1000000) +#define SEC_TO_NANOSEC(x) ((u_int64_t)x * 1000000000) + +#define MILLISEC_TO_SEC(x) (x / 1000) +#define MICROSEC_TO_SEC(x) (x / 1000000) +#define NANOSEC_TO_SEC(x) ((u_int64_t)x / 1000000000) + +#define TIMEVAL_TO_MILLISEC(x) (((x)->tv_sec * 1000) + ((x)->tv_usec / 1000)) +#define TIMEVAL_TO_MICROSEC(x) (((x)->tv_sec * 1000000) + (x)->tv_usec) +#define TIMEVAL_TO_NANOSEC(x) ((u_int64_t)((x)->tv_sec * 1000000000) + ((u_int64_t)(x)->tv_usec * 1000)) + +#define MILLISEC_TO_TIMEVAL(x, tv) \ + do { \ + (tv)->tv_sec = (x) / 1000; \ + (tv)->tv_usec = (x * 1000) - ((tv)->tv_sec * 1000000); \ + } while(0) + +#define MICROSEC_TO_TIMEVAL(x, tv) \ + do { \ + (tv)->tv_sec = (x) / 1000000; \ + (tv)->tv_usec = (x) - ((tv)->tv_sec * 1000000); \ + } while(0) + +#define NANOSEC_TO_TIMEVAL(x, tv) \ + do { \ + (tv)->tv_sec = (x) / 1000000000; \ + (tv)->tv_usec = ((x) % 1000000000) / 1000); \ + } while(0) + +#define NANOSEC_TO_TIMESPEC(x, ts) \ + do { \ + (ts)->tv_sec = (x) / 1000000000; \ + (ts)->tv_nsec = (x) % 1000000000; \ + } while(0) + +#define TIMESPEC_TO_MILLISEC(x) (((x)->tv_sec * 1000) + ((x)->tv_nsec / 1000000)) +#define TIMESPEC_TO_MICROSEC(x) (((x)->tv_sec * 1000000) + (x)->tv_nsec / 1000) +#define TIMESPEC_TO_NANOSEC(x) ((u_int64_t)((x)->tv_sec * 1000000000) + ((u_int64_t)(x)->tv_nsec)) + +#endif /* DEFINES */ diff --git a/src/encap_sample.cfg b/src/encap_sample.cfg new file mode 100644 index 0000000..160dcf4 --- /dev/null +++ b/src/encap_sample.cfg @@ -0,0 +1,7 @@ +[main] +vxlan_smac=74:86:7a:d0:12:fc +vxlan_dmac=00:01:6C:53:A9:94 +vxlan_sip=10.0.6.222 +vxlan_dip=10.0.6.59 +vxlan_sport=50704 +vxlan_dport=4789 diff --git a/src/fragroute/LICENSE b/src/fragroute/LICENSE new file mode 100644 index 0000000..f124de7 --- /dev/null +++ b/src/fragroute/LICENSE @@ -0,0 +1,29 @@ + + Copyright (c) 2001, 2002 Dug Song + Copyright (c) 2008 Aaron Turner + All rights reserved, all wrongs reversed. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. The names of the authors and copyright holders may not be used to + endorse or promote products derived from this software without + specific prior written permission. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/src/fragroute/Makefile.am b/src/fragroute/Makefile.am new file mode 100644 index 0000000..3ff630f --- /dev/null +++ b/src/fragroute/Makefile.am @@ -0,0 +1,19 @@ +noinst_LIBRARIES = libfragroute.a +libfragroute_a_SOURCES = fragroute.c bget.c mod.c pkt.c argv.c \ + randutil.c mod_delay.c mod_drop.c mod_dup.c \ + mod_echo.c mod_ip_chaff.c mod_ip_frag.c mod_ip_opt.c \ + mod_ip_ttl.c mod_ip_tos.c mod_order.c mod_print.c \ + mod_tcp_chaff.c mod_tcp_opt.c mod_tcp_seg.c \ + iputil.c mod_ip6_opt.c mod_ip6_qos.c + + +libfragroute_a_CFLAGS = -I.. -I../.. @LDNETINC@ + +# libfragroute_a_LIBS = @LDNETLIB@ + +noinst_HEADERS = bget.h mod.h pkt.h randutil.h iputil.h fragroute.h argv.h \ + LICENSE README + +MOSTLYCLEANFILES = *~ + +MAINTAINERCLEANFILES = Makefiles.in diff --git a/src/fragroute/Makefile.in b/src/fragroute/Makefile.in new file mode 100644 index 0000000..80cf975 --- /dev/null +++ b/src/fragroute/Makefile.in @@ -0,0 +1,879 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = src/fragroute +DIST_COMMON = README $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/src/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +LIBRARIES = $(noinst_LIBRARIES) +ARFLAGS = cru +libfragroute_a_AR = $(AR) $(ARFLAGS) +libfragroute_a_LIBADD = +am_libfragroute_a_OBJECTS = libfragroute_a-fragroute.$(OBJEXT) \ + libfragroute_a-bget.$(OBJEXT) libfragroute_a-mod.$(OBJEXT) \ + libfragroute_a-pkt.$(OBJEXT) libfragroute_a-argv.$(OBJEXT) \ + libfragroute_a-randutil.$(OBJEXT) \ + libfragroute_a-mod_delay.$(OBJEXT) \ + libfragroute_a-mod_drop.$(OBJEXT) \ + libfragroute_a-mod_dup.$(OBJEXT) \ + libfragroute_a-mod_echo.$(OBJEXT) \ + libfragroute_a-mod_ip_chaff.$(OBJEXT) \ + libfragroute_a-mod_ip_frag.$(OBJEXT) \ + libfragroute_a-mod_ip_opt.$(OBJEXT) \ + libfragroute_a-mod_ip_ttl.$(OBJEXT) \ + libfragroute_a-mod_ip_tos.$(OBJEXT) \ + libfragroute_a-mod_order.$(OBJEXT) \ + libfragroute_a-mod_print.$(OBJEXT) \ + libfragroute_a-mod_tcp_chaff.$(OBJEXT) \ + libfragroute_a-mod_tcp_opt.$(OBJEXT) \ + libfragroute_a-mod_tcp_seg.$(OBJEXT) \ + libfragroute_a-iputil.$(OBJEXT) \ + libfragroute_a-mod_ip6_opt.$(OBJEXT) \ + libfragroute_a-mod_ip6_qos.$(OBJEXT) +libfragroute_a_OBJECTS = $(am_libfragroute_a_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src +depcomp = $(SHELL) $(top_srcdir)/config/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libfragroute_a_SOURCES) +DIST_SOURCES = $(libfragroute_a_SOURCES) +HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOGEN = @AUTOGEN@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CUT = @CUT@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DMALLOC_LIB = @DMALLOC_LIB@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +GROFF = @GROFF@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LDNETINC = @LDNETINC@ +LDNETLIB = @LDNETLIB@ +LIBOBJS = @LIBOBJS@ +LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@ +LIBOPTS_DIR = @LIBOPTS_DIR@ +LIBOPTS_LDADD = @LIBOPTS_LDADD@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LNAVLIB = @LNAVLIB@ +LNAV_CFLAGS = @LNAV_CFLAGS@ +LN_S = @LN_S@ +LPCAPINC = @LPCAPINC@ +LPCAPLIB = @LPCAPLIB@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@ +PRINTF = @PRINTF@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TCPREPLAY_RELEASE = @TCPREPLAY_RELEASE@ +TCPREPLAY_VERSION = @TCPREPLAY_VERSION@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +debug_flag = @debug_flag@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +nic1 = @nic1@ +nic2 = @nic2@ +oldincludedir = @oldincludedir@ +pcncfg = @pcncfg@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +tcpdump_path = @tcpdump_path@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +noinst_LIBRARIES = libfragroute.a +libfragroute_a_SOURCES = fragroute.c bget.c mod.c pkt.c argv.c \ + randutil.c mod_delay.c mod_drop.c mod_dup.c \ + mod_echo.c mod_ip_chaff.c mod_ip_frag.c mod_ip_opt.c \ + mod_ip_ttl.c mod_ip_tos.c mod_order.c mod_print.c \ + mod_tcp_chaff.c mod_tcp_opt.c mod_tcp_seg.c \ + iputil.c mod_ip6_opt.c mod_ip6_qos.c + +libfragroute_a_CFLAGS = -I.. -I../.. @LDNETINC@ + +# libfragroute_a_LIBS = @LDNETLIB@ +noinst_HEADERS = bget.h mod.h pkt.h randutil.h iputil.h fragroute.h argv.h \ + LICENSE README + +MOSTLYCLEANFILES = *~ +MAINTAINERCLEANFILES = Makefiles.in +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/fragroute/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/fragroute/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *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);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libfragroute.a: $(libfragroute_a_OBJECTS) $(libfragroute_a_DEPENDENCIES) + -rm -f libfragroute.a + $(libfragroute_a_AR) libfragroute.a $(libfragroute_a_OBJECTS) $(libfragroute_a_LIBADD) + $(RANLIB) libfragroute.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +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@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +libfragroute_a-fragroute.o: fragroute.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-fragroute.o -MD -MP -MF $(DEPDIR)/libfragroute_a-fragroute.Tpo -c -o libfragroute_a-fragroute.o `test -f 'fragroute.c' || echo '$(srcdir)/'`fragroute.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-fragroute.Tpo $(DEPDIR)/libfragroute_a-fragroute.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='fragroute.c' object='libfragroute_a-fragroute.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-fragroute.o `test -f 'fragroute.c' || echo '$(srcdir)/'`fragroute.c + +libfragroute_a-fragroute.obj: fragroute.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-fragroute.obj -MD -MP -MF $(DEPDIR)/libfragroute_a-fragroute.Tpo -c -o libfragroute_a-fragroute.obj `if test -f 'fragroute.c'; then $(CYGPATH_W) 'fragroute.c'; else $(CYGPATH_W) '$(srcdir)/fragroute.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-fragroute.Tpo $(DEPDIR)/libfragroute_a-fragroute.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='fragroute.c' object='libfragroute_a-fragroute.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-fragroute.obj `if test -f 'fragroute.c'; then $(CYGPATH_W) 'fragroute.c'; else $(CYGPATH_W) '$(srcdir)/fragroute.c'; fi` + +libfragroute_a-bget.o: bget.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-bget.o -MD -MP -MF $(DEPDIR)/libfragroute_a-bget.Tpo -c -o libfragroute_a-bget.o `test -f 'bget.c' || echo '$(srcdir)/'`bget.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-bget.Tpo $(DEPDIR)/libfragroute_a-bget.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='bget.c' object='libfragroute_a-bget.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-bget.o `test -f 'bget.c' || echo '$(srcdir)/'`bget.c + +libfragroute_a-bget.obj: bget.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-bget.obj -MD -MP -MF $(DEPDIR)/libfragroute_a-bget.Tpo -c -o libfragroute_a-bget.obj `if test -f 'bget.c'; then $(CYGPATH_W) 'bget.c'; else $(CYGPATH_W) '$(srcdir)/bget.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-bget.Tpo $(DEPDIR)/libfragroute_a-bget.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='bget.c' object='libfragroute_a-bget.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-bget.obj `if test -f 'bget.c'; then $(CYGPATH_W) 'bget.c'; else $(CYGPATH_W) '$(srcdir)/bget.c'; fi` + +libfragroute_a-mod.o: mod.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod.o -MD -MP -MF $(DEPDIR)/libfragroute_a-mod.Tpo -c -o libfragroute_a-mod.o `test -f 'mod.c' || echo '$(srcdir)/'`mod.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod.Tpo $(DEPDIR)/libfragroute_a-mod.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod.c' object='libfragroute_a-mod.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod.o `test -f 'mod.c' || echo '$(srcdir)/'`mod.c + +libfragroute_a-mod.obj: mod.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod.obj -MD -MP -MF $(DEPDIR)/libfragroute_a-mod.Tpo -c -o libfragroute_a-mod.obj `if test -f 'mod.c'; then $(CYGPATH_W) 'mod.c'; else $(CYGPATH_W) '$(srcdir)/mod.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod.Tpo $(DEPDIR)/libfragroute_a-mod.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod.c' object='libfragroute_a-mod.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod.obj `if test -f 'mod.c'; then $(CYGPATH_W) 'mod.c'; else $(CYGPATH_W) '$(srcdir)/mod.c'; fi` + +libfragroute_a-pkt.o: pkt.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-pkt.o -MD -MP -MF $(DEPDIR)/libfragroute_a-pkt.Tpo -c -o libfragroute_a-pkt.o `test -f 'pkt.c' || echo '$(srcdir)/'`pkt.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-pkt.Tpo $(DEPDIR)/libfragroute_a-pkt.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pkt.c' object='libfragroute_a-pkt.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-pkt.o `test -f 'pkt.c' || echo '$(srcdir)/'`pkt.c + +libfragroute_a-pkt.obj: pkt.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-pkt.obj -MD -MP -MF $(DEPDIR)/libfragroute_a-pkt.Tpo -c -o libfragroute_a-pkt.obj `if test -f 'pkt.c'; then $(CYGPATH_W) 'pkt.c'; else $(CYGPATH_W) '$(srcdir)/pkt.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-pkt.Tpo $(DEPDIR)/libfragroute_a-pkt.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pkt.c' object='libfragroute_a-pkt.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-pkt.obj `if test -f 'pkt.c'; then $(CYGPATH_W) 'pkt.c'; else $(CYGPATH_W) '$(srcdir)/pkt.c'; fi` + +libfragroute_a-argv.o: argv.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-argv.o -MD -MP -MF $(DEPDIR)/libfragroute_a-argv.Tpo -c -o libfragroute_a-argv.o `test -f 'argv.c' || echo '$(srcdir)/'`argv.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-argv.Tpo $(DEPDIR)/libfragroute_a-argv.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='argv.c' object='libfragroute_a-argv.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-argv.o `test -f 'argv.c' || echo '$(srcdir)/'`argv.c + +libfragroute_a-argv.obj: argv.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-argv.obj -MD -MP -MF $(DEPDIR)/libfragroute_a-argv.Tpo -c -o libfragroute_a-argv.obj `if test -f 'argv.c'; then $(CYGPATH_W) 'argv.c'; else $(CYGPATH_W) '$(srcdir)/argv.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-argv.Tpo $(DEPDIR)/libfragroute_a-argv.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='argv.c' object='libfragroute_a-argv.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-argv.obj `if test -f 'argv.c'; then $(CYGPATH_W) 'argv.c'; else $(CYGPATH_W) '$(srcdir)/argv.c'; fi` + +libfragroute_a-randutil.o: randutil.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-randutil.o -MD -MP -MF $(DEPDIR)/libfragroute_a-randutil.Tpo -c -o libfragroute_a-randutil.o `test -f 'randutil.c' || echo '$(srcdir)/'`randutil.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-randutil.Tpo $(DEPDIR)/libfragroute_a-randutil.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='randutil.c' object='libfragroute_a-randutil.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-randutil.o `test -f 'randutil.c' || echo '$(srcdir)/'`randutil.c + +libfragroute_a-randutil.obj: randutil.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-randutil.obj -MD -MP -MF $(DEPDIR)/libfragroute_a-randutil.Tpo -c -o libfragroute_a-randutil.obj `if test -f 'randutil.c'; then $(CYGPATH_W) 'randutil.c'; else $(CYGPATH_W) '$(srcdir)/randutil.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-randutil.Tpo $(DEPDIR)/libfragroute_a-randutil.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='randutil.c' object='libfragroute_a-randutil.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-randutil.obj `if test -f 'randutil.c'; then $(CYGPATH_W) 'randutil.c'; else $(CYGPATH_W) '$(srcdir)/randutil.c'; fi` + +libfragroute_a-mod_delay.o: mod_delay.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_delay.o -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_delay.Tpo -c -o libfragroute_a-mod_delay.o `test -f 'mod_delay.c' || echo '$(srcdir)/'`mod_delay.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_delay.Tpo $(DEPDIR)/libfragroute_a-mod_delay.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_delay.c' object='libfragroute_a-mod_delay.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_delay.o `test -f 'mod_delay.c' || echo '$(srcdir)/'`mod_delay.c + +libfragroute_a-mod_delay.obj: mod_delay.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_delay.obj -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_delay.Tpo -c -o libfragroute_a-mod_delay.obj `if test -f 'mod_delay.c'; then $(CYGPATH_W) 'mod_delay.c'; else $(CYGPATH_W) '$(srcdir)/mod_delay.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_delay.Tpo $(DEPDIR)/libfragroute_a-mod_delay.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_delay.c' object='libfragroute_a-mod_delay.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_delay.obj `if test -f 'mod_delay.c'; then $(CYGPATH_W) 'mod_delay.c'; else $(CYGPATH_W) '$(srcdir)/mod_delay.c'; fi` + +libfragroute_a-mod_drop.o: mod_drop.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_drop.o -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_drop.Tpo -c -o libfragroute_a-mod_drop.o `test -f 'mod_drop.c' || echo '$(srcdir)/'`mod_drop.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_drop.Tpo $(DEPDIR)/libfragroute_a-mod_drop.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_drop.c' object='libfragroute_a-mod_drop.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_drop.o `test -f 'mod_drop.c' || echo '$(srcdir)/'`mod_drop.c + +libfragroute_a-mod_drop.obj: mod_drop.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_drop.obj -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_drop.Tpo -c -o libfragroute_a-mod_drop.obj `if test -f 'mod_drop.c'; then $(CYGPATH_W) 'mod_drop.c'; else $(CYGPATH_W) '$(srcdir)/mod_drop.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_drop.Tpo $(DEPDIR)/libfragroute_a-mod_drop.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_drop.c' object='libfragroute_a-mod_drop.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_drop.obj `if test -f 'mod_drop.c'; then $(CYGPATH_W) 'mod_drop.c'; else $(CYGPATH_W) '$(srcdir)/mod_drop.c'; fi` + +libfragroute_a-mod_dup.o: mod_dup.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_dup.o -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_dup.Tpo -c -o libfragroute_a-mod_dup.o `test -f 'mod_dup.c' || echo '$(srcdir)/'`mod_dup.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_dup.Tpo $(DEPDIR)/libfragroute_a-mod_dup.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_dup.c' object='libfragroute_a-mod_dup.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_dup.o `test -f 'mod_dup.c' || echo '$(srcdir)/'`mod_dup.c + +libfragroute_a-mod_dup.obj: mod_dup.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_dup.obj -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_dup.Tpo -c -o libfragroute_a-mod_dup.obj `if test -f 'mod_dup.c'; then $(CYGPATH_W) 'mod_dup.c'; else $(CYGPATH_W) '$(srcdir)/mod_dup.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_dup.Tpo $(DEPDIR)/libfragroute_a-mod_dup.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_dup.c' object='libfragroute_a-mod_dup.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_dup.obj `if test -f 'mod_dup.c'; then $(CYGPATH_W) 'mod_dup.c'; else $(CYGPATH_W) '$(srcdir)/mod_dup.c'; fi` + +libfragroute_a-mod_echo.o: mod_echo.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_echo.o -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_echo.Tpo -c -o libfragroute_a-mod_echo.o `test -f 'mod_echo.c' || echo '$(srcdir)/'`mod_echo.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_echo.Tpo $(DEPDIR)/libfragroute_a-mod_echo.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_echo.c' object='libfragroute_a-mod_echo.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_echo.o `test -f 'mod_echo.c' || echo '$(srcdir)/'`mod_echo.c + +libfragroute_a-mod_echo.obj: mod_echo.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_echo.obj -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_echo.Tpo -c -o libfragroute_a-mod_echo.obj `if test -f 'mod_echo.c'; then $(CYGPATH_W) 'mod_echo.c'; else $(CYGPATH_W) '$(srcdir)/mod_echo.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_echo.Tpo $(DEPDIR)/libfragroute_a-mod_echo.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_echo.c' object='libfragroute_a-mod_echo.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_echo.obj `if test -f 'mod_echo.c'; then $(CYGPATH_W) 'mod_echo.c'; else $(CYGPATH_W) '$(srcdir)/mod_echo.c'; fi` + +libfragroute_a-mod_ip_chaff.o: mod_ip_chaff.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_ip_chaff.o -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_ip_chaff.Tpo -c -o libfragroute_a-mod_ip_chaff.o `test -f 'mod_ip_chaff.c' || echo '$(srcdir)/'`mod_ip_chaff.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_ip_chaff.Tpo $(DEPDIR)/libfragroute_a-mod_ip_chaff.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_ip_chaff.c' object='libfragroute_a-mod_ip_chaff.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_ip_chaff.o `test -f 'mod_ip_chaff.c' || echo '$(srcdir)/'`mod_ip_chaff.c + +libfragroute_a-mod_ip_chaff.obj: mod_ip_chaff.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_ip_chaff.obj -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_ip_chaff.Tpo -c -o libfragroute_a-mod_ip_chaff.obj `if test -f 'mod_ip_chaff.c'; then $(CYGPATH_W) 'mod_ip_chaff.c'; else $(CYGPATH_W) '$(srcdir)/mod_ip_chaff.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_ip_chaff.Tpo $(DEPDIR)/libfragroute_a-mod_ip_chaff.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_ip_chaff.c' object='libfragroute_a-mod_ip_chaff.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_ip_chaff.obj `if test -f 'mod_ip_chaff.c'; then $(CYGPATH_W) 'mod_ip_chaff.c'; else $(CYGPATH_W) '$(srcdir)/mod_ip_chaff.c'; fi` + +libfragroute_a-mod_ip_frag.o: mod_ip_frag.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_ip_frag.o -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_ip_frag.Tpo -c -o libfragroute_a-mod_ip_frag.o `test -f 'mod_ip_frag.c' || echo '$(srcdir)/'`mod_ip_frag.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_ip_frag.Tpo $(DEPDIR)/libfragroute_a-mod_ip_frag.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_ip_frag.c' object='libfragroute_a-mod_ip_frag.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_ip_frag.o `test -f 'mod_ip_frag.c' || echo '$(srcdir)/'`mod_ip_frag.c + +libfragroute_a-mod_ip_frag.obj: mod_ip_frag.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_ip_frag.obj -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_ip_frag.Tpo -c -o libfragroute_a-mod_ip_frag.obj `if test -f 'mod_ip_frag.c'; then $(CYGPATH_W) 'mod_ip_frag.c'; else $(CYGPATH_W) '$(srcdir)/mod_ip_frag.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_ip_frag.Tpo $(DEPDIR)/libfragroute_a-mod_ip_frag.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_ip_frag.c' object='libfragroute_a-mod_ip_frag.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_ip_frag.obj `if test -f 'mod_ip_frag.c'; then $(CYGPATH_W) 'mod_ip_frag.c'; else $(CYGPATH_W) '$(srcdir)/mod_ip_frag.c'; fi` + +libfragroute_a-mod_ip_opt.o: mod_ip_opt.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_ip_opt.o -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_ip_opt.Tpo -c -o libfragroute_a-mod_ip_opt.o `test -f 'mod_ip_opt.c' || echo '$(srcdir)/'`mod_ip_opt.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_ip_opt.Tpo $(DEPDIR)/libfragroute_a-mod_ip_opt.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_ip_opt.c' object='libfragroute_a-mod_ip_opt.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_ip_opt.o `test -f 'mod_ip_opt.c' || echo '$(srcdir)/'`mod_ip_opt.c + +libfragroute_a-mod_ip_opt.obj: mod_ip_opt.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_ip_opt.obj -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_ip_opt.Tpo -c -o libfragroute_a-mod_ip_opt.obj `if test -f 'mod_ip_opt.c'; then $(CYGPATH_W) 'mod_ip_opt.c'; else $(CYGPATH_W) '$(srcdir)/mod_ip_opt.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_ip_opt.Tpo $(DEPDIR)/libfragroute_a-mod_ip_opt.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_ip_opt.c' object='libfragroute_a-mod_ip_opt.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_ip_opt.obj `if test -f 'mod_ip_opt.c'; then $(CYGPATH_W) 'mod_ip_opt.c'; else $(CYGPATH_W) '$(srcdir)/mod_ip_opt.c'; fi` + +libfragroute_a-mod_ip_ttl.o: mod_ip_ttl.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_ip_ttl.o -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_ip_ttl.Tpo -c -o libfragroute_a-mod_ip_ttl.o `test -f 'mod_ip_ttl.c' || echo '$(srcdir)/'`mod_ip_ttl.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_ip_ttl.Tpo $(DEPDIR)/libfragroute_a-mod_ip_ttl.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_ip_ttl.c' object='libfragroute_a-mod_ip_ttl.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_ip_ttl.o `test -f 'mod_ip_ttl.c' || echo '$(srcdir)/'`mod_ip_ttl.c + +libfragroute_a-mod_ip_ttl.obj: mod_ip_ttl.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_ip_ttl.obj -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_ip_ttl.Tpo -c -o libfragroute_a-mod_ip_ttl.obj `if test -f 'mod_ip_ttl.c'; then $(CYGPATH_W) 'mod_ip_ttl.c'; else $(CYGPATH_W) '$(srcdir)/mod_ip_ttl.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_ip_ttl.Tpo $(DEPDIR)/libfragroute_a-mod_ip_ttl.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_ip_ttl.c' object='libfragroute_a-mod_ip_ttl.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_ip_ttl.obj `if test -f 'mod_ip_ttl.c'; then $(CYGPATH_W) 'mod_ip_ttl.c'; else $(CYGPATH_W) '$(srcdir)/mod_ip_ttl.c'; fi` + +libfragroute_a-mod_ip_tos.o: mod_ip_tos.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_ip_tos.o -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_ip_tos.Tpo -c -o libfragroute_a-mod_ip_tos.o `test -f 'mod_ip_tos.c' || echo '$(srcdir)/'`mod_ip_tos.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_ip_tos.Tpo $(DEPDIR)/libfragroute_a-mod_ip_tos.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_ip_tos.c' object='libfragroute_a-mod_ip_tos.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_ip_tos.o `test -f 'mod_ip_tos.c' || echo '$(srcdir)/'`mod_ip_tos.c + +libfragroute_a-mod_ip_tos.obj: mod_ip_tos.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_ip_tos.obj -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_ip_tos.Tpo -c -o libfragroute_a-mod_ip_tos.obj `if test -f 'mod_ip_tos.c'; then $(CYGPATH_W) 'mod_ip_tos.c'; else $(CYGPATH_W) '$(srcdir)/mod_ip_tos.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_ip_tos.Tpo $(DEPDIR)/libfragroute_a-mod_ip_tos.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_ip_tos.c' object='libfragroute_a-mod_ip_tos.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_ip_tos.obj `if test -f 'mod_ip_tos.c'; then $(CYGPATH_W) 'mod_ip_tos.c'; else $(CYGPATH_W) '$(srcdir)/mod_ip_tos.c'; fi` + +libfragroute_a-mod_order.o: mod_order.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_order.o -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_order.Tpo -c -o libfragroute_a-mod_order.o `test -f 'mod_order.c' || echo '$(srcdir)/'`mod_order.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_order.Tpo $(DEPDIR)/libfragroute_a-mod_order.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_order.c' object='libfragroute_a-mod_order.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_order.o `test -f 'mod_order.c' || echo '$(srcdir)/'`mod_order.c + +libfragroute_a-mod_order.obj: mod_order.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_order.obj -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_order.Tpo -c -o libfragroute_a-mod_order.obj `if test -f 'mod_order.c'; then $(CYGPATH_W) 'mod_order.c'; else $(CYGPATH_W) '$(srcdir)/mod_order.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_order.Tpo $(DEPDIR)/libfragroute_a-mod_order.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_order.c' object='libfragroute_a-mod_order.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_order.obj `if test -f 'mod_order.c'; then $(CYGPATH_W) 'mod_order.c'; else $(CYGPATH_W) '$(srcdir)/mod_order.c'; fi` + +libfragroute_a-mod_print.o: mod_print.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_print.o -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_print.Tpo -c -o libfragroute_a-mod_print.o `test -f 'mod_print.c' || echo '$(srcdir)/'`mod_print.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_print.Tpo $(DEPDIR)/libfragroute_a-mod_print.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_print.c' object='libfragroute_a-mod_print.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_print.o `test -f 'mod_print.c' || echo '$(srcdir)/'`mod_print.c + +libfragroute_a-mod_print.obj: mod_print.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_print.obj -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_print.Tpo -c -o libfragroute_a-mod_print.obj `if test -f 'mod_print.c'; then $(CYGPATH_W) 'mod_print.c'; else $(CYGPATH_W) '$(srcdir)/mod_print.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_print.Tpo $(DEPDIR)/libfragroute_a-mod_print.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_print.c' object='libfragroute_a-mod_print.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_print.obj `if test -f 'mod_print.c'; then $(CYGPATH_W) 'mod_print.c'; else $(CYGPATH_W) '$(srcdir)/mod_print.c'; fi` + +libfragroute_a-mod_tcp_chaff.o: mod_tcp_chaff.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_tcp_chaff.o -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_tcp_chaff.Tpo -c -o libfragroute_a-mod_tcp_chaff.o `test -f 'mod_tcp_chaff.c' || echo '$(srcdir)/'`mod_tcp_chaff.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_tcp_chaff.Tpo $(DEPDIR)/libfragroute_a-mod_tcp_chaff.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_tcp_chaff.c' object='libfragroute_a-mod_tcp_chaff.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_tcp_chaff.o `test -f 'mod_tcp_chaff.c' || echo '$(srcdir)/'`mod_tcp_chaff.c + +libfragroute_a-mod_tcp_chaff.obj: mod_tcp_chaff.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_tcp_chaff.obj -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_tcp_chaff.Tpo -c -o libfragroute_a-mod_tcp_chaff.obj `if test -f 'mod_tcp_chaff.c'; then $(CYGPATH_W) 'mod_tcp_chaff.c'; else $(CYGPATH_W) '$(srcdir)/mod_tcp_chaff.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_tcp_chaff.Tpo $(DEPDIR)/libfragroute_a-mod_tcp_chaff.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_tcp_chaff.c' object='libfragroute_a-mod_tcp_chaff.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_tcp_chaff.obj `if test -f 'mod_tcp_chaff.c'; then $(CYGPATH_W) 'mod_tcp_chaff.c'; else $(CYGPATH_W) '$(srcdir)/mod_tcp_chaff.c'; fi` + +libfragroute_a-mod_tcp_opt.o: mod_tcp_opt.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_tcp_opt.o -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_tcp_opt.Tpo -c -o libfragroute_a-mod_tcp_opt.o `test -f 'mod_tcp_opt.c' || echo '$(srcdir)/'`mod_tcp_opt.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_tcp_opt.Tpo $(DEPDIR)/libfragroute_a-mod_tcp_opt.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_tcp_opt.c' object='libfragroute_a-mod_tcp_opt.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_tcp_opt.o `test -f 'mod_tcp_opt.c' || echo '$(srcdir)/'`mod_tcp_opt.c + +libfragroute_a-mod_tcp_opt.obj: mod_tcp_opt.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_tcp_opt.obj -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_tcp_opt.Tpo -c -o libfragroute_a-mod_tcp_opt.obj `if test -f 'mod_tcp_opt.c'; then $(CYGPATH_W) 'mod_tcp_opt.c'; else $(CYGPATH_W) '$(srcdir)/mod_tcp_opt.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_tcp_opt.Tpo $(DEPDIR)/libfragroute_a-mod_tcp_opt.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_tcp_opt.c' object='libfragroute_a-mod_tcp_opt.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_tcp_opt.obj `if test -f 'mod_tcp_opt.c'; then $(CYGPATH_W) 'mod_tcp_opt.c'; else $(CYGPATH_W) '$(srcdir)/mod_tcp_opt.c'; fi` + +libfragroute_a-mod_tcp_seg.o: mod_tcp_seg.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_tcp_seg.o -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_tcp_seg.Tpo -c -o libfragroute_a-mod_tcp_seg.o `test -f 'mod_tcp_seg.c' || echo '$(srcdir)/'`mod_tcp_seg.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_tcp_seg.Tpo $(DEPDIR)/libfragroute_a-mod_tcp_seg.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_tcp_seg.c' object='libfragroute_a-mod_tcp_seg.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_tcp_seg.o `test -f 'mod_tcp_seg.c' || echo '$(srcdir)/'`mod_tcp_seg.c + +libfragroute_a-mod_tcp_seg.obj: mod_tcp_seg.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_tcp_seg.obj -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_tcp_seg.Tpo -c -o libfragroute_a-mod_tcp_seg.obj `if test -f 'mod_tcp_seg.c'; then $(CYGPATH_W) 'mod_tcp_seg.c'; else $(CYGPATH_W) '$(srcdir)/mod_tcp_seg.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_tcp_seg.Tpo $(DEPDIR)/libfragroute_a-mod_tcp_seg.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_tcp_seg.c' object='libfragroute_a-mod_tcp_seg.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_tcp_seg.obj `if test -f 'mod_tcp_seg.c'; then $(CYGPATH_W) 'mod_tcp_seg.c'; else $(CYGPATH_W) '$(srcdir)/mod_tcp_seg.c'; fi` + +libfragroute_a-iputil.o: iputil.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-iputil.o -MD -MP -MF $(DEPDIR)/libfragroute_a-iputil.Tpo -c -o libfragroute_a-iputil.o `test -f 'iputil.c' || echo '$(srcdir)/'`iputil.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-iputil.Tpo $(DEPDIR)/libfragroute_a-iputil.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='iputil.c' object='libfragroute_a-iputil.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-iputil.o `test -f 'iputil.c' || echo '$(srcdir)/'`iputil.c + +libfragroute_a-iputil.obj: iputil.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-iputil.obj -MD -MP -MF $(DEPDIR)/libfragroute_a-iputil.Tpo -c -o libfragroute_a-iputil.obj `if test -f 'iputil.c'; then $(CYGPATH_W) 'iputil.c'; else $(CYGPATH_W) '$(srcdir)/iputil.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-iputil.Tpo $(DEPDIR)/libfragroute_a-iputil.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='iputil.c' object='libfragroute_a-iputil.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-iputil.obj `if test -f 'iputil.c'; then $(CYGPATH_W) 'iputil.c'; else $(CYGPATH_W) '$(srcdir)/iputil.c'; fi` + +libfragroute_a-mod_ip6_opt.o: mod_ip6_opt.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_ip6_opt.o -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_ip6_opt.Tpo -c -o libfragroute_a-mod_ip6_opt.o `test -f 'mod_ip6_opt.c' || echo '$(srcdir)/'`mod_ip6_opt.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_ip6_opt.Tpo $(DEPDIR)/libfragroute_a-mod_ip6_opt.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_ip6_opt.c' object='libfragroute_a-mod_ip6_opt.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_ip6_opt.o `test -f 'mod_ip6_opt.c' || echo '$(srcdir)/'`mod_ip6_opt.c + +libfragroute_a-mod_ip6_opt.obj: mod_ip6_opt.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_ip6_opt.obj -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_ip6_opt.Tpo -c -o libfragroute_a-mod_ip6_opt.obj `if test -f 'mod_ip6_opt.c'; then $(CYGPATH_W) 'mod_ip6_opt.c'; else $(CYGPATH_W) '$(srcdir)/mod_ip6_opt.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_ip6_opt.Tpo $(DEPDIR)/libfragroute_a-mod_ip6_opt.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_ip6_opt.c' object='libfragroute_a-mod_ip6_opt.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_ip6_opt.obj `if test -f 'mod_ip6_opt.c'; then $(CYGPATH_W) 'mod_ip6_opt.c'; else $(CYGPATH_W) '$(srcdir)/mod_ip6_opt.c'; fi` + +libfragroute_a-mod_ip6_qos.o: mod_ip6_qos.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_ip6_qos.o -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_ip6_qos.Tpo -c -o libfragroute_a-mod_ip6_qos.o `test -f 'mod_ip6_qos.c' || echo '$(srcdir)/'`mod_ip6_qos.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_ip6_qos.Tpo $(DEPDIR)/libfragroute_a-mod_ip6_qos.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_ip6_qos.c' object='libfragroute_a-mod_ip6_qos.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_ip6_qos.o `test -f 'mod_ip6_qos.c' || echo '$(srcdir)/'`mod_ip6_qos.c + +libfragroute_a-mod_ip6_qos.obj: mod_ip6_qos.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -MT libfragroute_a-mod_ip6_qos.obj -MD -MP -MF $(DEPDIR)/libfragroute_a-mod_ip6_qos.Tpo -c -o libfragroute_a-mod_ip6_qos.obj `if test -f 'mod_ip6_qos.c'; then $(CYGPATH_W) 'mod_ip6_qos.c'; else $(CYGPATH_W) '$(srcdir)/mod_ip6_qos.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libfragroute_a-mod_ip6_qos.Tpo $(DEPDIR)/libfragroute_a-mod_ip6_qos.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mod_ip6_qos.c' object='libfragroute_a-mod_ip6_qos.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfragroute_a_CFLAGS) $(CFLAGS) -c -o libfragroute_a-mod_ip6_qos.obj `if test -f 'mod_ip6_qos.c'; then $(CYGPATH_W) 'mod_ip6_qos.c'; else $(CYGPATH_W) '$(srcdir)/mod_ip6_qos.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LIBRARIES) $(HEADERS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLIBRARIES ctags 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 uninstall uninstall-am + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/fragroute/README b/src/fragroute/README new file mode 100644 index 0000000..4a8f3a0 --- /dev/null +++ b/src/fragroute/README @@ -0,0 +1,33 @@ +This code is heavily based on, even stolen from Dug Song's excellent fragroute +utility. I've taken a perfectly good application and converted it into a +packet editing library for my own needs. Any bugs are my fault. Any praises +really should go to Dug. + +Please consider all files here under the original fragroute LICENSE, with the +added caveat that any changes are: + +Copyright 2008, Aaron Turner + + +Notes: +Fragroute runs as a daemon which intercepts packets by modifying the host +operating systems routing table, redirecting packets destined to the target +IP over the loopback interface. Packets reaching the loopback interface +are then read using libpcap/BPF filter processed according to the fragroute +rule set and then resent out the configured interface. + +libfragroute works differently. First, we do away with any changes to the +host routing table. Secondly, packets are not sent out any interface, but +are read back by the caller. The API should look something like this: + +ctx = fragroute_init(mtu, ); // init library + +// process a packet +fragroute_process(ctx, char *pktbuff, int pktsize) + +// read resulting fragments +while ((ret = fragroute_read(ctx, char **fragment)) > 0) { + // do something with fragment +} else { + // no more fragments +} \ No newline at end of file diff --git a/src/fragroute/argv.c b/src/fragroute/argv.c new file mode 100644 index 0000000..8118490 --- /dev/null +++ b/src/fragroute/argv.c @@ -0,0 +1,68 @@ +/* + * argv.c + * + * Copyright (c) 2001 Dug Song + * + * $Id: argv.c 2000 2008-04-27 06:17:35Z aturner $ + */ + +#include "config.h" + +#include +#include +#include +#include + +#include "argv.h" + +int +argv_create(char *p, int argc, char *argv[]) +{ + int i; + + for (i = 0; i < argc - 1; i++) { + while (*p != '\0' && isspace((int)*p)) + *p++ = '\0'; + + if (*p == '\0') + break; + argv[i] = p; + + while (*p != '\0' && !isspace((int)*p)) + p++; + } + p[0] = '\0'; + argv[i] = NULL; + + return (i); +} + +/* XXX - from tcpdump util.c. */ +char * +argv_copy(char *argv[]) +{ + char **p, *buf, *src, *dst; + int len = 0; + + p = argv; + if (*p == 0) + return (NULL); + + while (*p) + len += strlen(*p++) + 1; + + if ((buf = (char *)malloc(len)) == NULL) + return (NULL); + + p = argv; + dst = buf; + + while ((src = *p++) != NULL) { + while ((*dst++ = *src++) != '\0') + ; + dst[-1] = ' '; + } + dst[-1] = '\0'; + + return (buf); +} diff --git a/src/fragroute/argv.h b/src/fragroute/argv.h new file mode 100644 index 0000000..0395dfa --- /dev/null +++ b/src/fragroute/argv.h @@ -0,0 +1,15 @@ +/* + * argv.h + * + * Copyright (c) 2001 Dug Song + * + * $Id: argv.h 2000 2008-04-27 06:17:35Z aturner $ + */ + +#ifndef ARGV_H +#define ARGV_H + +int argv_create(char *p, int argc, char *argv[]); +char *argv_copy(char *argv[]); + +#endif /* ARGV_H */ diff --git a/src/fragroute/bget.c b/src/fragroute/bget.c new file mode 100644 index 0000000..f2190f2 --- /dev/null +++ b/src/fragroute/bget.c @@ -0,0 +1,1592 @@ +/* + + B G E T + + Buffer allocator + + Designed and implemented in April of 1972 by John Walker, based on the + Case Algol OPRO$ algorithm implemented in 1966. + + Reimplemented in 1975 by John Walker for the Interdata 70. + Reimplemented in 1977 by John Walker for the Marinchip 9900. + Reimplemented in 1982 by Duff Kurland for the Intel 8080. + + Portable C version implemented in September of 1990 by an older, wiser + instance of the original implementor. + + Souped up and/or weighed down slightly shortly thereafter by Greg + Lutz. + + AMIX edition, including the new compaction call-back option, prepared + by John Walker in July of 1992. + + Bug in built-in test program fixed, ANSI compiler warnings eradicated, + buffer pool validator implemented, and guaranteed repeatable test + added by John Walker in October of 1995. + + This program is in the public domain. + + 1. This is the book of the generations of Adam. In the day that God + created man, in the likeness of God made he him; + 2. Male and female created he them; and blessed them, and called + their name Adam, in the day when they were created. + 3. And Adam lived an hundred and thirty years, and begat a son in + his own likeness, and after his image; and called his name Seth: + 4. And the days of Adam after he had begotten Seth were eight + hundred years: and he begat sons and daughters: + 5. And all the days that Adam lived were nine hundred and thirty + years: and he died. + 6. And Seth lived an hundred and five years, and begat Enos: + 7. And Seth lived after he begat Enos eight hundred and seven years, + and begat sons and daughters: + 8. And all the days of Seth were nine hundred and twelve years: and + he died. + 9. And Enos lived ninety years, and begat Cainan: + 10. And Enos lived after he begat Cainan eight hundred and fifteen + years, and begat sons and daughters: + 11. And all the days of Enos were nine hundred and five years: and + he died. + 12. And Cainan lived seventy years and begat Mahalaleel: + 13. And Cainan lived after he begat Mahalaleel eight hundred and + forty years, and begat sons and daughters: + 14. And all the days of Cainan were nine hundred and ten years: and + he died. + 15. And Mahalaleel lived sixty and five years, and begat Jared: + 16. And Mahalaleel lived after he begat Jared eight hundred and + thirty years, and begat sons and daughters: + 17. And all the days of Mahalaleel were eight hundred ninety and + five years: and he died. + 18. And Jared lived an hundred sixty and two years, and he begat + Enoch: + 19. And Jared lived after he begat Enoch eight hundred years, and + begat sons and daughters: + 20. And all the days of Jared were nine hundred sixty and two years: + and he died. + 21. And Enoch lived sixty and five years, and begat Methuselah: + 22. And Enoch walked with God after he begat Methuselah three + hundred years, and begat sons and daughters: + 23. And all the days of Enoch were three hundred sixty and five + years: + 24. And Enoch walked with God: and he was not; for God took him. + 25. And Methuselah lived an hundred eighty and seven years, and + begat Lamech. + 26. And Methuselah lived after he begat Lamech seven hundred eighty + and two years, and begat sons and daughters: + 27. And all the days of Methuselah were nine hundred sixty and nine + years: and he died. + 28. And Lamech lived an hundred eighty and two years, and begat a + son: + 29. And he called his name Noah, saying, This same shall comfort us + concerning our work and toil of our hands, because of the ground + which the LORD hath cursed. + 30. And Lamech lived after he begat Noah five hundred ninety and + five years, and begat sons and daughters: + 31. And all the days of Lamech were seven hundred seventy and seven + years: and he died. + 32. And Noah was five hundred years old: and Noah begat Shem, Ham, + and Japheth. + + And buffers begat buffers, and links begat links, and buffer pools + begat links to chains of buffer pools containing buffers, and lo the + buffers and links and pools of buffers and pools of links to chains of + pools of buffers were fruitful and they multiplied and the Operating + System looked down upon them and said that it was Good. + + + INTRODUCTION + ============ + + BGET is a comprehensive memory allocation package which is easily + configured to the needs of an application. BGET is efficient in + both the time needed to allocate and release buffers and in the + memory overhead required for buffer pool management. It + automatically consolidates contiguous space to minimise + fragmentation. BGET is configured by compile-time definitions, + Major options include: + + * A built-in test program to exercise BGET and + demonstrate how the various functions are used. + + * Allocation by either the "first fit" or "best fit" + method. + + * Wiping buffers at release time to catch code which + references previously released storage. + + * Built-in routines to dump individual buffers or the + entire buffer pool. + + * Retrieval of allocation and pool size statistics. + + * Quantisation of buffer sizes to a power of two to + satisfy hardware alignment constraints. + + * Automatic pool compaction, growth, and shrinkage by + means of call-backs to user defined functions. + + Applications of BGET can range from storage management in + ROM-based embedded programs to providing the framework upon which + a multitasking system incorporating garbage collection is + constructed. BGET incorporates extensive internal consistency + checking using the mechanism; all these checks can be + turned off by compiling with NDEBUG defined, yielding a version of + BGET with minimal size and maximum speed. + + The basic algorithm underlying BGET has withstood the test of + time; more than 25 years have passed since the first + implementation of this code. And yet, it is substantially more + efficient than the native allocation schemes of many operating + systems: the Macintosh and Microsoft Windows to name two, on which + programs have obtained substantial speed-ups by layering BGET as + an application level memory manager atop the underlying system's. + + BGET has been implemented on the largest mainframes and the lowest + of microprocessors. It has served as the core for multitasking + operating systems, multi-thread applications, embedded software in + data network switching processors, and a host of C programs. And + while it has accreted flexibility and additional options over the + years, it remains fast, memory efficient, portable, and easy to + integrate into your program. + + + BGET IMPLEMENTATION ASSUMPTIONS + =============================== + + BGET is written in as portable a dialect of C as possible. The + only fundamental assumption about the underlying hardware + architecture is that memory is allocated is a linear array which + can be addressed as a vector of C "char" objects. On segmented + address space architectures, this generally means that BGET should + be used to allocate storage within a single segment (although some + compilers simulate linear address spaces on segmented + architectures). On segmented architectures, then, BGET buffer + pools may not be larger than a segment, but since BGET allows any + number of separate buffer pools, there is no limit on the total + storage which can be managed, only on the largest individual + object which can be allocated. Machines with a linear address + architecture, such as the VAX, 680x0, Sparc, MIPS, or the Intel + 80386 and above in native mode, may use BGET without restriction. + + + GETTING STARTED WITH BGET + ========================= + + Although BGET can be configured in a multitude of fashions, there + are three basic ways of working with BGET. The functions + mentioned below are documented in the following section. Please + excuse the forward references which are made in the interest of + providing a roadmap to guide you to the BGET functions you're + likely to need. + + Embedded Applications + --------------------- + + Embedded applications typically have a fixed area of memory + dedicated to buffer allocation (often in a separate RAM address + space distinct from the ROM that contains the executable code). + To use BGET in such an environment, simply call bpool() with the + start address and length of the buffer pool area in RAM, then + allocate buffers with bget() and release them with brel(). + Embedded applications with very limited RAM but abundant CPU speed + may benefit by configuring BGET for BestFit allocation (which is + usually not worth it in other environments). + + Malloc() Emulation + ------------------ + + If the C library malloc() function is too slow, not present in + your development environment (for example, an a native Windows or + Macintosh program), or otherwise unsuitable, you can replace it + with BGET. Initially define a buffer pool of an appropriate size + with bpool()--usually obtained by making a call to the operating + system's low-level memory allocator. Then allocate buffers with + bget(), bgetz(), and bgetr() (the last two permit the allocation + of buffers initialised to zero and [inefficient] re-allocation of + existing buffers for compatibility with C library functions). + Release buffers by calling brel(). If a buffer allocation request + fails, obtain more storage from the underlying operating system, + add it to the buffer pool by another call to bpool(), and continue + execution. + + Automatic Storage Management + ---------------------------- + + You can use BGET as your application's native memory manager and + implement automatic storage pool expansion, contraction, and + optionally application-specific memory compaction by compiling + BGET with the BECtl variable defined, then calling bectl() and + supplying functions for storage compaction, acquisition, and + release, as well as a standard pool expansion increment. All of + these functions are optional (although it doesn't make much sense + to provide a release function without an acquisition function, + does it?). Once the call-back functions have been defined with + bectl(), you simply use bget() and brel() to allocate and release + storage as before. You can supply an initial buffer pool with + bpool() or rely on automatic allocation to acquire the entire + pool. When a call on bget() cannot be satisfied, BGET first + checks if a compaction function has been supplied. If so, it is + called (with the space required to satisfy the allocation request + and a sequence number to allow the compaction routine to be called + successively without looping). If the compaction function is able + to free any storage (it needn't know whether the storage it freed + was adequate) it should return a nonzero value, whereupon BGET + will retry the allocation request and, if it fails again, call the + compaction function again with the next-higher sequence number. + + If the compaction function returns zero, indicating failure to + free space, or no compaction function is defined, BGET next tests + whether a non-NULL allocation function was supplied to bectl(). + If so, that function is called with an argument indicating how + many bytes of additional space are required. This will be the + standard pool expansion increment supplied in the call to bectl() + unless the original bget() call requested a buffer larger than + this; buffers larger than the standard pool block can be managed + "off the books" by BGET in this mode. If the allocation function + succeeds in obtaining the storage, it returns a pointer to the new + block and BGET expands the buffer pool; if it fails, the + allocation request fails and returns NULL to the caller. If a + non-NULL release function is supplied, expansion blocks which + become totally empty are released to the global free pool by + passing their addresses to the release function. + + Equipped with appropriate allocation, release, and compaction + functions, BGET can be used as part of very sophisticated memory + management strategies, including garbage collection. (Note, + however, that BGET is *not* a garbage collector by itself, and + that developing such a system requires much additional logic and + careful design of the application's memory allocation strategy.) + + + BGET FUNCTION DESCRIPTIONS + ========================== + + Functions implemented in this file (some are enabled by certain of + the optional settings below): + + void bpool(void *buffer, bufsize len); + + Create a buffer pool of bytes, using the storage starting at + . You can call bpool() subsequently to contribute + additional storage to the overall buffer pool. + + void *bget(bufsize size); + + Allocate a buffer of bytes. The address of the buffer is + returned, or NULL if insufficient memory was available to allocate + the buffer. + + void *bgetz(bufsize size); + + Allocate a buffer of bytes and clear it to all zeroes. The + address of the buffer is returned, or NULL if insufficient memory + was available to allocate the buffer. + + void *bgetr(void *buffer, bufsize newsize); + + Reallocate a buffer previously allocated by bget(), changing its + size to and preserving all existing data. NULL is + returned if insufficient memory is available to reallocate the + buffer, in which case the original buffer remains intact. + + void brel(void *buf); + + Return the buffer , previously allocated by bget(), to the + free space pool. + + void bectl(int (*compact)(bufsize sizereq, int sequence), + void *(*acquire)(bufsize size), + void (*release)(void *buf), + bufsize pool_incr); + + Expansion control: specify functions through which the package may + compact storage (or take other appropriate action) when an + allocation request fails, and optionally automatically acquire + storage for expansion blocks when necessary, and release such + blocks when they become empty. If is non-NULL, whenever + a buffer allocation request fails, the function will be + called with arguments specifying the number of bytes (total buffer + size, including header overhead) required to satisfy the + allocation request, and a sequence number indicating the number of + consecutive calls on attempting to satisfy this + allocation request. The sequence number is 1 for the first call + on for a given allocation request, and increments on + subsequent calls, permitting the function to take + increasingly dire measures in an attempt to free up storage. If + the function returns a nonzero value, the allocation + attempt is re-tried. If returns 0 (as it must if it + isn't able to release any space or add storage to the buffer + pool), the allocation request fails, which can trigger automatic + pool expansion if the argument is non-NULL. At the time + the function is called, the state of the buffer + allocator is identical to that at the moment the allocation + request was made; consequently, the function may call + brel(), bpool(), bstats(), and/or directly manipulate the buffer + pool in any manner which would be valid were the application in + control. This does not, however, relieve the function + of the need to ensure that whatever actions it takes do not change + things underneath the application that made the allocation + request. For example, a function that released a buffer + in the process of being reallocated with bgetr() would lead to + disaster. Implementing a safe and effective mechanism + requires careful design of an application's memory architecture, + and cannot generally be easily retrofitted into existing code. + + If is non-NULL, that function will be called whenever an + allocation request fails. If the function succeeds in + allocating the requested space and returns a pointer to the new + area, allocation will proceed using the expanded buffer pool. If + cannot obtain the requested space, it should return NULL + and the entire allocation process will fail. + specifies the normal expansion block size. Providing an + function will cause subsequent bget() requests for buffers too + large to be managed in the linked-block scheme (in other words, + larger than minus the buffer overhead) to be satisfied + directly by calls to the function. Automatic release of + empty pool blocks will occur only if all pool blocks in the system + are the size given by . + + void bstats(bufsize *curalloc, bufsize *totfree, + bufsize *maxfree, long *nget, long *nrel); + + The amount of space currently allocated is stored into the + variable pointed to by . The total free space (sum of + all free blocks in the pool) is stored into the variable pointed + to by , and the size of the largest single block in the + free space pool is stored into the variable pointed to by + . The variables pointed to by and are + filled, respectively, with the number of successful (non-NULL + return) bget() calls and the number of brel() calls. + + void bstatse(bufsize *pool_incr, long *npool, + long *npget, long *nprel, + long *ndget, long *ndrel); + + Extended statistics: The expansion block size will be stored into + the variable pointed to by , or the negative thereof if + automatic expansion block releases are disabled. The number of + currently active pool blocks will be stored into the variable + pointed to by . The variables pointed to by and + will be filled with, respectively, the number of expansion + block acquisitions and releases which have occurred. The + variables pointed to by and will be filled with + the number of bget() and brel() calls, respectively, managed + through blocks directly allocated by the acquisition and release + functions. + + void bufdump(void *buf); + + The buffer pointed to by is dumped on standard output. + + void bpoold(void *pool, int dumpalloc, int dumpfree); + + All buffers in the buffer pool , previously initialised by a + call on bpool(), are listed in ascending memory address order. If + is nonzero, the contents of allocated buffers are + dumped; if is nonzero, the contents of free blocks are + dumped. + + int bpoolv(void *pool); + + The named buffer pool, previously initialised by a call on + bpool(), is validated for bad pointers, overwritten data, etc. If + compiled with NDEBUG not defined, any error generates an assertion + failure. Otherwise 1 is returned if the pool is valid, 0 if an + error is found. + + + BGET CONFIGURATION + ================== +*/ + +#if 0 +#define TestProg 20000 /* Generate built-in test program + if defined. The value specifies + how many buffer allocation attempts + the test program should make. */ +#endif +#define SizeQuant 4 /* Buffer allocation size quantum: + all buffers allocated are a + multiple of this size. This + MUST be a power of two. */ +#if 0 +#define BufDump 1 /* Define this symbol to enable the + bpoold() function which dumps the + buffers in a buffer pool. */ + +#define BufValid 1 /* Define this symbol to enable the + bpoolv() function for validating + a buffer pool. */ + +#define DumpData 1 /* Define this symbol to enable the + bufdump() function which allows + dumping the contents of an allocated + or free buffer. */ + +#define BufStats 1 /* Define this symbol to enable the + bstats() function which calculates + the total free space in the buffer + pool, the largest available + buffer, and the total space + currently allocated. */ + +#define FreeWipe 1 /* Wipe free buffers to a guaranteed + pattern of garbage to trip up + miscreants who attempt to use + pointers into released buffers. */ + +#define BestFit 1 /* Use a best fit algorithm when + searching for space for an + allocation request. This uses + memory more efficiently, but + allocation will be much slower. */ +#endif +#define BECtl 1 /* Define this symbol to enable the + bectl() function for automatic + pool space control. */ + +#include + +#ifdef lint +#define NDEBUG /* Exits in asserts confuse lint */ +/* LINTLIBRARY */ /* Don't complain about def, no ref */ +extern char *sprintf(); /* Sun includes don't define sprintf */ +#endif + +#include +#include + +#ifdef BufDump /* BufDump implies DumpData */ +#ifndef DumpData +#define DumpData 1 +#endif +#endif + +#ifdef DumpData +#include +#endif + +/* Declare the interface, including the requested buffer size type, + bufsize. */ + +#include "bget.h" + +#define MemSize int /* Type for size arguments to memxxx() + functions such as memcmp(). */ + +/* Queue links */ + +struct qlinks { + struct bfhead *flink; /* Forward link */ + struct bfhead *blink; /* Backward link */ +}; + +/* Header in allocated and free buffers */ + +struct bhead { + bufsize prevfree; /* Relative link back to previous + free buffer in memory or 0 if + previous buffer is allocated. */ + bufsize bsize; /* Buffer size: positive if free, + negative if allocated. */ +}; +#define BH(p) ((struct bhead *) (p)) + +/* Header in directly allocated buffers (by acqfcn) */ + +struct bdhead { + bufsize tsize; /* Total size, including overhead */ + struct bhead bh; /* Common header */ +}; +#define BDH(p) ((struct bdhead *) (p)) + +/* Header in free buffers */ + +struct bfhead { + struct bhead bh; /* Common allocated/free header */ + struct qlinks ql; /* Links on free list */ +}; +#define BFH(p) ((struct bfhead *) (p)) + +static struct bfhead freelist = { /* List of free buffers */ + {0, 0}, + {&freelist, &freelist} +}; + + +#ifdef BufStats +static bufsize totalloc = 0; /* Total space currently allocated */ +static long numget = 0, numrel = 0; /* Number of bget() and brel() calls */ +#ifdef BECtl +static long numpblk = 0; /* Number of pool blocks */ +static long numpget = 0, numprel = 0; /* Number of block gets and rels */ +static long numdget = 0, numdrel = 0; /* Number of direct gets and rels */ +#endif /* BECtl */ +#endif /* BufStats */ + +#ifdef BECtl + +/* Automatic expansion block management functions */ + +static int (*compfcn) _((bufsize sizereq, int sequence)) = NULL; +static void *(*acqfcn) _((bufsize size)) = NULL; +static void (*relfcn) _((void *buf)) = NULL; + +static bufsize exp_incr = 0; /* Expansion block size */ +static bufsize pool_len = 0; /* 0: no bpool calls have been made + -1: not all pool blocks are + the same size + >0: (common) block size for all + bpool calls made so far + */ +#endif + +/* Minimum allocation quantum: */ + +#define QLSize (sizeof(struct qlinks)) +#define SizeQ ((SizeQuant > QLSize) ? SizeQuant : QLSize) + +#define V (void) /* To denote unwanted returned values */ + +/* End sentinel: value placed in bsize field of dummy block delimiting + end of pool block. The most negative number which will fit in a + bufsize, defined in a way that the compiler will accept. */ + +#define ESent ((bufsize) (-(((1L << (sizeof(bufsize) * 8 - 2)) - 1) * 2) - 2)) + +/* BGET -- Allocate a buffer. */ + +void *bget(requested_size) + bufsize requested_size; +{ + bufsize size = requested_size; + struct bfhead *b; +#ifdef BestFit + struct bfhead *best; +#endif + void *buf; +#ifdef BECtl + int compactseq = 0; +#endif + + assert(size > 0); + + if (size < SizeQ) { /* Need at least room for the */ + size = SizeQ; /* queue links. */ + } +#ifdef SizeQuant +#if SizeQuant > 1 + size = (size + (SizeQuant - 1)) & (~(SizeQuant - 1)); +#endif +#endif + + size += sizeof(struct bhead); /* Add overhead in allocated buffer + to size required. */ + +#ifdef BECtl + /* If a compact function was provided in the call to bectl(), wrap + a loop around the allocation process to allow compaction to + intervene in case we don't find a suitable buffer in the chain. */ + + while (1) { +#endif + b = freelist.ql.flink; +#ifdef BestFit + best = &freelist; +#endif + + + /* Scan the free list searching for the first buffer big enough + to hold the requested size buffer. */ + +#ifdef BestFit + while (b != &freelist) { + if (b->bh.bsize >= size) { + if ((best == &freelist) || (b->bh.bsize < best->bh.bsize)) { + best = b; + } + } + b = b->ql.flink; /* Link to next buffer */ + } + b = best; +#endif /* BestFit */ + + while (b != &freelist) { + if ((bufsize) b->bh.bsize >= size) { + + /* Buffer is big enough to satisfy the request. Allocate it + to the caller. We must decide whether the buffer is large + enough to split into the part given to the caller and a + free buffer that remains on the free list, or whether the + entire buffer should be removed from the free list and + given to the caller in its entirety. We only split the + buffer if enough room remains for a header plus the minimum + quantum of allocation. */ + + if ((b->bh.bsize - size) > (SizeQ + (sizeof(struct bhead)))) { + struct bhead *ba, *bn; + + ba = BH(((char *) b) + (b->bh.bsize - size)); + bn = BH(((char *) ba) + size); + assert(bn->prevfree == b->bh.bsize); + /* Subtract size from length of free block. */ + b->bh.bsize -= size; + /* Link allocated buffer to the previous free buffer. */ + ba->prevfree = b->bh.bsize; + /* Plug negative size into user buffer. */ + ba->bsize = -(bufsize) size; + /* Mark buffer after this one not preceded by free block. */ + bn->prevfree = 0; + +#ifdef BufStats + totalloc += size; + numget++; /* Increment number of bget() calls */ +#endif + buf = (void *) ((((char *) ba) + sizeof(struct bhead))); + return buf; + } else { + struct bhead *ba; + + ba = BH(((char *) b) + b->bh.bsize); + assert(ba->prevfree == b->bh.bsize); + + /* The buffer isn't big enough to split. Give the whole + shebang to the caller and remove it from the free list. */ + + assert(b->ql.blink->ql.flink == b); + assert(b->ql.flink->ql.blink == b); + b->ql.blink->ql.flink = b->ql.flink; + b->ql.flink->ql.blink = b->ql.blink; + +#ifdef BufStats + totalloc += b->bh.bsize; + numget++; /* Increment number of bget() calls */ +#endif + /* Negate size to mark buffer allocated. */ + b->bh.bsize = -(b->bh.bsize); + + /* Zero the back pointer in the next buffer in memory + to indicate that this buffer is allocated. */ + ba->prevfree = 0; + + /* Give user buffer starting at queue links. */ + buf = (void *) &(b->ql); + return buf; + } + } + b = b->ql.flink; /* Link to next buffer */ + } +#ifdef BECtl + + /* We failed to find a buffer. If there's a compact function + defined, notify it of the size requested. If it returns + TRUE, try the allocation again. */ + + if ((compfcn == NULL) || (!(*compfcn)(size, ++compactseq))) { + break; + } + } + + /* No buffer available with requested size free. */ + + /* Don't give up yet -- look in the reserve supply. */ + + if (acqfcn != NULL) { + if (size > exp_incr - sizeof(struct bhead)) { + + /* Request is too large to fit in a single expansion + block. Try to satisy it by a direct buffer acquisition. */ + + struct bdhead *bdh; + + size += sizeof(struct bdhead) - sizeof(struct bhead); + if ((bdh = BDH((*acqfcn)((bufsize) size))) != NULL) { + + /* Mark the buffer special by setting the size field + of its header to zero. */ + bdh->bh.bsize = 0; + bdh->bh.prevfree = 0; + bdh->tsize = size; +#ifdef BufStats + totalloc += size; + numget++; /* Increment number of bget() calls */ + numdget++; /* Direct bget() call count */ +#endif + buf = (void *) (bdh + 1); + return buf; + } + + } else { + + /* Try to obtain a new expansion block */ + + void *newpool; + + if ((newpool = (*acqfcn)((bufsize) exp_incr)) != NULL) { + bpool(newpool, exp_incr); + buf = bget(requested_size); /* This can't, I say, can't + get into a loop. */ + return buf; + } + } + } + + /* Still no buffer available */ + +#endif /* BECtl */ + + return NULL; +} + +/* BGETZ -- Allocate a buffer and clear its contents to zero. We clear + the entire contents of the buffer to zero, not just the + region requested by the caller. */ + +void *bgetz(size) + bufsize size; +{ + char *buf = (char *) bget(size); + + if (buf != NULL) { + struct bhead *b; + bufsize rsize; + + b = BH(buf - sizeof(struct bhead)); + rsize = -(b->bsize); + if (rsize == 0) { + struct bdhead *bd; + + bd = BDH(buf - sizeof(struct bdhead)); + rsize = bd->tsize - sizeof(struct bdhead); + } else { + rsize -= sizeof(struct bhead); + } + assert(rsize >= size); + V memset(buf, 0, (MemSize) rsize); + } + return ((void *) buf); +} + +/* BGETR -- Reallocate a buffer. This is a minimal implementation, + simply in terms of brel() and bget(). It could be + enhanced to allow the buffer to grow into adjacent free + blocks and to avoid moving data unnecessarily. */ + +void *bgetr(buf, size) + void *buf; + bufsize size; +{ + void *nbuf; + bufsize osize; /* Old size of buffer */ + struct bhead *b; + + if ((nbuf = bget(size)) == NULL) { /* Acquire new buffer */ + return NULL; + } + if (buf == NULL) { + return nbuf; + } + b = BH(((char *) buf) - sizeof(struct bhead)); + osize = -b->bsize; +#ifdef BECtl + if (osize == 0) { + /* Buffer acquired directly through acqfcn. */ + struct bdhead *bd; + + bd = BDH(((char *) buf) - sizeof(struct bdhead)); + osize = bd->tsize - sizeof(struct bdhead); + } else +#endif + osize -= sizeof(struct bhead); + assert(osize > 0); + V memcpy((char *) nbuf, (char *) buf, /* Copy the data */ + (MemSize) ((size < osize) ? size : osize)); + brel(buf); + return nbuf; +} + +/* BREL -- Release a buffer. */ + +void brel(buf) + void *buf; +{ + struct bfhead *b, *bn; + + b = BFH(((char *) buf) - sizeof(struct bhead)); +#ifdef BufStats + numrel++; /* Increment number of brel() calls */ +#endif + assert(buf != NULL); + +#ifdef BECtl + if (b->bh.bsize == 0) { /* Directly-acquired buffer? */ + struct bdhead *bdh; + + bdh = BDH(((char *) buf) - sizeof(struct bdhead)); + assert(b->bh.prevfree == 0); +#ifdef BufStats + totalloc -= bdh->tsize; + assert(totalloc >= 0); + numdrel++; /* Number of direct releases */ +#endif /* BufStats */ +#ifdef FreeWipe + V memset((char *) buf, 0x55, + (MemSize) (bdh->tsize - sizeof(struct bdhead))); +#endif /* FreeWipe */ + assert(relfcn != NULL); + (*relfcn)((void *) bdh); /* Release it directly. */ + return; + } +#endif /* BECtl */ + + /* Buffer size must be negative, indicating that the buffer is + allocated. */ + + if (b->bh.bsize >= 0) { + bn = NULL; + } + assert(b->bh.bsize < 0); + + /* Back pointer in next buffer must be zero, indicating the + same thing: */ + + assert(BH((char *) b - b->bh.bsize)->prevfree == 0); + +#ifdef BufStats + totalloc += b->bh.bsize; + assert(totalloc >= 0); +#endif + + /* If the back link is nonzero, the previous buffer is free. */ + + if (b->bh.prevfree != 0) { + + /* The previous buffer is free. Consolidate this buffer with it + by adding the length of this buffer to the previous free + buffer. Note that we subtract the size in the buffer being + released, since it's negative to indicate that the buffer is + allocated. */ + + register bufsize size = b->bh.bsize; + + /* Make the previous buffer the one we're working on. */ + assert(BH((char *) b - b->bh.prevfree)->bsize == b->bh.prevfree); + b = BFH(((char *) b) - b->bh.prevfree); + b->bh.bsize -= size; + } else { + + /* The previous buffer isn't allocated. Insert this buffer + on the free list as an isolated free block. */ + + assert(freelist.ql.blink->ql.flink == &freelist); + assert(freelist.ql.flink->ql.blink == &freelist); + b->ql.flink = &freelist; + b->ql.blink = freelist.ql.blink; + freelist.ql.blink = b; + b->ql.blink->ql.flink = b; + b->bh.bsize = -b->bh.bsize; + } + + /* Now we look at the next buffer in memory, located by advancing from + the start of this buffer by its size, to see if that buffer is + free. If it is, we combine this buffer with the next one in + memory, dechaining the second buffer from the free list. */ + + bn = BFH(((char *) b) + b->bh.bsize); + if (bn->bh.bsize > 0) { + + /* The buffer is free. Remove it from the free list and add + its size to that of our buffer. */ + + assert(BH((char *) bn + bn->bh.bsize)->prevfree == bn->bh.bsize); + assert(bn->ql.blink->ql.flink == bn); + assert(bn->ql.flink->ql.blink == bn); + bn->ql.blink->ql.flink = bn->ql.flink; + bn->ql.flink->ql.blink = bn->ql.blink; + b->bh.bsize += bn->bh.bsize; + + /* Finally, advance to the buffer that follows the newly + consolidated free block. We must set its backpointer to the + head of the consolidated free block. We know the next block + must be an allocated block because the process of recombination + guarantees that two free blocks will never be contiguous in + memory. */ + + bn = BFH(((char *) b) + b->bh.bsize); + } +#ifdef FreeWipe + V memset(((char *) b) + sizeof(struct bfhead), 0x55, + (MemSize) (b->bh.bsize - sizeof(struct bfhead))); +#endif + assert(bn->bh.bsize < 0); + + /* The next buffer is allocated. Set the backpointer in it to point + to this buffer; the previous free buffer in memory. */ + + bn->bh.prevfree = b->bh.bsize; + +#ifdef BECtl + + /* If a block-release function is defined, and this free buffer + constitutes the entire block, release it. Note that pool_len + is defined in such a way that the test will fail unless all + pool blocks are the same size. */ + + if (relfcn != NULL && + ((bufsize) b->bh.bsize) == (pool_len - sizeof(struct bhead))) { + + assert(b->bh.prevfree == 0); + assert(BH((char *) b + b->bh.bsize)->bsize == ESent); + assert(BH((char *) b + b->bh.bsize)->prevfree == b->bh.bsize); + /* Unlink the buffer from the free list */ + b->ql.blink->ql.flink = b->ql.flink; + b->ql.flink->ql.blink = b->ql.blink; + + (*relfcn)(b); +#ifdef BufStats + numprel++; /* Nr of expansion block releases */ + numpblk--; /* Total number of blocks */ + assert(numpblk == numpget - numprel); +#endif /* BufStats */ + } +#endif /* BECtl */ +} + +#ifdef BECtl + +/* BECTL -- Establish automatic pool expansion control */ + +void bectl(compact, acquire, release, pool_incr) + int (*compact) _((bufsize sizereq, int sequence)); + void *(*acquire) _((bufsize size)); + void (*release) _((void *buf)); + bufsize pool_incr; +{ + compfcn = compact; + acqfcn = acquire; + relfcn = release; + exp_incr = pool_incr; +} +#endif + +/* BPOOL -- Add a region of memory to the buffer pool. */ + +void bpool(buf, len) + void *buf; + bufsize len; +{ + struct bfhead *b = BFH(buf); + struct bhead *bn; + +#ifdef SizeQuant + len &= ~(SizeQuant - 1); +#endif +#ifdef BECtl + if (pool_len == 0) { + pool_len = len; + } else if (len != pool_len) { + pool_len = -1; + } +#ifdef BufStats + numpget++; /* Number of block acquisitions */ + numpblk++; /* Number of blocks total */ + assert(numpblk == numpget - numprel); +#endif /* BufStats */ +#endif /* BECtl */ + + /* Since the block is initially occupied by a single free buffer, + it had better not be (much) larger than the largest buffer + whose size we can store in bhead.bsize. */ + + assert(len - sizeof(struct bhead) <= -((bufsize) ESent + 1)); + + /* Clear the backpointer at the start of the block to indicate that + there is no free block prior to this one. That blocks + recombination when the first block in memory is released. */ + + b->bh.prevfree = 0; + + /* Chain the new block to the free list. */ + + assert(freelist.ql.blink->ql.flink == &freelist); + assert(freelist.ql.flink->ql.blink == &freelist); + b->ql.flink = &freelist; + b->ql.blink = freelist.ql.blink; + freelist.ql.blink = b; + b->ql.blink->ql.flink = b; + + /* Create a dummy allocated buffer at the end of the pool. This dummy + buffer is seen when a buffer at the end of the pool is released and + blocks recombination of the last buffer with the dummy buffer at + the end. The length in the dummy buffer is set to the largest + negative number to denote the end of the pool for diagnostic + routines (this specific value is not counted on by the actual + allocation and release functions). */ + + len -= sizeof(struct bhead); + b->bh.bsize = (bufsize) len; +#ifdef FreeWipe + V memset(((char *) b) + sizeof(struct bfhead), 0x55, + (MemSize) (len - sizeof(struct bfhead))); +#endif + bn = BH(((char *) b) + len); + bn->prevfree = (bufsize) len; + /* Definition of ESent assumes two's complement! */ + assert((~0) == -1); + bn->bsize = ESent; +} + +#ifdef BufStats + +/* BSTATS -- Return buffer allocation free space statistics. */ + +void bstats(curalloc, totfree, maxfree, nget, nrel) + bufsize *curalloc, *totfree, *maxfree; + long *nget, *nrel; +{ + struct bfhead *b = freelist.ql.flink; + + *nget = numget; + *nrel = numrel; + *curalloc = totalloc; + *totfree = 0; + *maxfree = -1; + while (b != &freelist) { + assert(b->bh.bsize > 0); + *totfree += b->bh.bsize; + if (b->bh.bsize > *maxfree) { + *maxfree = b->bh.bsize; + } + b = b->ql.flink; /* Link to next buffer */ + } +} + +#ifdef BECtl + +/* BSTATSE -- Return extended statistics */ + +void bstatse(pool_incr, npool, npget, nprel, ndget, ndrel) + bufsize *pool_incr; + long *npool, *npget, *nprel, *ndget, *ndrel; +{ + *pool_incr = (pool_len < 0) ? -exp_incr : exp_incr; + *npool = numpblk; + *npget = numpget; + *nprel = numprel; + *ndget = numdget; + *ndrel = numdrel; +} +#endif /* BECtl */ +#endif /* BufStats */ + +#ifdef DumpData + +/* BUFDUMP -- Dump the data in a buffer. This is called with the user + data pointer, and backs up to the buffer header. It will + dump either a free block or an allocated one. */ + +void bufdump(buf) + void *buf; +{ + struct bfhead *b; + unsigned char *bdump; + bufsize bdlen; + + b = BFH(((char *) buf) - sizeof(struct bhead)); + assert(b->bh.bsize != 0); + if (b->bh.bsize < 0) { + bdump = (unsigned char *) buf; + bdlen = (-b->bh.bsize) - sizeof(struct bhead); + } else { + bdump = (unsigned char *) (((char *) b) + sizeof(struct bfhead)); + bdlen = b->bh.bsize - sizeof(struct bfhead); + } + + while (bdlen > 0) { + int i, dupes = 0; + bufsize l = bdlen; + char bhex[50], bascii[20]; + + if (l > 16) { + l = 16; + } + + for (i = 0; i < l; i++) { + V sprintf(bhex + i * 3, "%02X ", bdump[i]); + bascii[i] = isprint(bdump[i]) ? bdump[i] : ' '; + } + bascii[i] = 0; + V printf("%-48s %s\n", bhex, bascii); + bdump += l; + bdlen -= l; + while ((bdlen > 16) && (memcmp((char *) (bdump - 16), + (char *) bdump, 16) == 0)) { + dupes++; + bdump += 16; + bdlen -= 16; + } + if (dupes > 1) { + V printf( + " (%d lines [%d bytes] identical to above line skipped)\n", + dupes, dupes * 16); + } else if (dupes == 1) { + bdump -= 16; + bdlen += 16; + } + } +} +#endif + +#ifdef BufDump + +/* BPOOLD -- Dump a buffer pool. The buffer headers are always listed. + If DUMPALLOC is nonzero, the contents of allocated buffers + are dumped. If DUMPFREE is nonzero, free blocks are + dumped as well. If FreeWipe checking is enabled, free + blocks which have been clobbered will always be dumped. */ + +void bpoold(buf, dumpalloc, dumpfree) + void *buf; + int dumpalloc, dumpfree; +{ + struct bfhead *b = BFH(buf); + + while (b->bh.bsize != ESent) { + bufsize bs = b->bh.bsize; + + if (bs < 0) { + bs = -bs; + V printf("Allocated buffer: size %6ld bytes.\n", (long) bs); + if (dumpalloc) { + bufdump((void *) (((char *) b) + sizeof(struct bhead))); + } + } else { + char *lerr = ""; + + assert(bs > 0); + if ((b->ql.blink->ql.flink != b) || + (b->ql.flink->ql.blink != b)) { + lerr = " (Bad free list links)"; + } + V printf("Free block: size %6ld bytes.%s\n", + (long) bs, lerr); +#ifdef FreeWipe + lerr = ((char *) b) + sizeof(struct bfhead); + if ((bs > sizeof(struct bfhead)) && ((*lerr != 0x55) || + (memcmp(lerr, lerr + 1, + (MemSize) (bs - (sizeof(struct bfhead) + 1))) != 0))) { + V printf( + "(Contents of above free block have been overstored.)\n"); + bufdump((void *) (((char *) b) + sizeof(struct bhead))); + } else +#endif + if (dumpfree) { + bufdump((void *) (((char *) b) + sizeof(struct bhead))); + } + } + b = BFH(((char *) b) + bs); + } +} +#endif /* BufDump */ + +#ifdef BufValid + +/* BPOOLV -- Validate a buffer pool. If NDEBUG isn't defined, + any error generates an assertion failure. */ + +int bpoolv(buf) + void *buf; +{ + struct bfhead *b = BFH(buf); + + while (b->bh.bsize != ESent) { + bufsize bs = b->bh.bsize; + + if (bs < 0) { + bs = -bs; + } else { + char *lerr = ""; + + assert(bs > 0); + if (bs <= 0) { + return 0; + } + if ((b->ql.blink->ql.flink != b) || + (b->ql.flink->ql.blink != b)) { + V printf("Free block: size %6ld bytes. (Bad free list links)\n", + (long) bs); + assert(0); + return 0; + } +#ifdef FreeWipe + lerr = ((char *) b) + sizeof(struct bfhead); + if ((bs > sizeof(struct bfhead)) && ((*lerr != 0x55) || + (memcmp(lerr, lerr + 1, + (MemSize) (bs - (sizeof(struct bfhead) + 1))) != 0))) { + V printf( + "(Contents of above free block have been overstored.)\n"); + bufdump((void *) (((char *) b) + sizeof(struct bhead))); + assert(0); + return 0; + } +#endif + } + b = BFH(((char *) b) + bs); + } + return 1; +} +#endif /* BufValid */ + + /***********************\ + * * + * Built-in test program * + * * + \***********************/ + +#ifdef TestProg + +#define Repeatable 1 /* Repeatable pseudorandom sequence */ + /* If Repeatable is not defined, a + time-seeded pseudorandom sequence + is generated, exercising BGET with + a different pattern of calls on each + run. */ +#define OUR_RAND /* Use our own built-in version of + rand() to guarantee the test is + 100% repeatable. */ + +#ifdef BECtl +#define PoolSize 300000 /* Test buffer pool size */ +#else +#define PoolSize 50000 /* Test buffer pool size */ +#endif +#define ExpIncr 32768 /* Test expansion block size */ +#define CompactTries 10 /* Maximum tries at compacting */ + +#define dumpAlloc 0 /* Dump allocated buffers ? */ +#define dumpFree 0 /* Dump free buffers ? */ + +#ifndef Repeatable +extern long time(); +#endif + +extern char *malloc(); +extern int free _((char *)); + +static char *bchain = NULL; /* Our private buffer chain */ +static char *bp = NULL; /* Our initial buffer pool */ + +#include + +#ifdef OUR_RAND + +static unsigned long int next = 1; + +/* Return next random integer */ + +int rand() +{ + next = next * 1103515245L + 12345; + return (unsigned int) (next / 65536L) % 32768L; +} + +/* Set seed for random generator */ + +void srand(seed) + unsigned int seed; +{ + next = seed; +} +#endif + +/* STATS -- Edit statistics returned by bstats() or bstatse(). */ + +static void stats(when) + char *when; +{ + bufsize cural, totfree, maxfree; + long nget, nfree; +#ifdef BECtl + bufsize pincr; + long totblocks, npget, nprel, ndget, ndrel; +#endif + + bstats(&cural, &totfree, &maxfree, &nget, &nfree); + V printf( + "%s: %ld gets, %ld releases. %ld in use, %ld free, largest = %ld\n", + when, nget, nfree, (long) cural, (long) totfree, (long) maxfree); +#ifdef BECtl + bstatse(&pincr, &totblocks, &npget, &nprel, &ndget, &ndrel); + V printf( + " Blocks: size = %ld, %ld (%ld bytes) in use, %ld gets, %ld frees\n", + (long)pincr, totblocks, pincr * totblocks, npget, nprel); + V printf(" %ld direct gets, %ld direct frees\n", ndget, ndrel); +#endif /* BECtl */ +} + +#ifdef BECtl +static int protect = 0; /* Disable compaction during bgetr() */ + +/* BCOMPACT -- Compaction call-back function. */ + +static int bcompact(bsize, seq) + bufsize bsize; + int seq; +{ +#ifdef CompactTries + char *bc = bchain; + int i = rand() & 0x3; + +#ifdef COMPACTRACE + V printf("Compaction requested. %ld bytes needed, sequence %d.\n", + (long) bsize, seq); +#endif + + if (protect || (seq > CompactTries)) { +#ifdef COMPACTRACE + V printf("Compaction gave up.\n"); +#endif + return 0; + } + + /* Based on a random cast, release a random buffer in the list + of allocated buffers. */ + + while (i > 0 && bc != NULL) { + bc = *((char **) bc); + i--; + } + if (bc != NULL) { + char *fb; + + fb = *((char **) bc); + if (fb != NULL) { + *((char **) bc) = *((char **) fb); + brel((void *) fb); + return 1; + } + } + +#ifdef COMPACTRACE + V printf("Compaction bailed out.\n"); +#endif +#endif /* CompactTries */ + return 0; +} + +/* BEXPAND -- Expand pool call-back function. */ + +static void *bexpand(size) + bufsize size; +{ + void *np = NULL; + bufsize cural, totfree, maxfree; + long nget, nfree; + + /* Don't expand beyond the total allocated size given by PoolSize. */ + + bstats(&cural, &totfree, &maxfree, &nget, &nfree); + + if (cural < PoolSize) { + np = (void *) malloc((unsigned) size); + } +#ifdef EXPTRACE + V printf("Expand pool by %ld -- %s.\n", (long) size, + np == NULL ? "failed" : "succeeded"); +#endif + return np; +} + +/* BSHRINK -- Shrink buffer pool call-back function. */ + +static void bshrink(buf) + void *buf; +{ + if (((char *) buf) == bp) { +#ifdef EXPTRACE + V printf("Initial pool released.\n"); +#endif + bp = NULL; + } +#ifdef EXPTRACE + V printf("Shrink pool.\n"); +#endif + free((char *) buf); +} + +#endif /* BECtl */ + +/* Restrict buffer requests to those large enough to contain our pointer and + small enough for the CPU architecture. */ + +static bufsize blimit(bs) + bufsize bs; +{ + if (bs < sizeof(char *)) { + bs = sizeof(char *); + } + + /* This is written out in this ugly fashion because the + cool expression in sizeof(int) that auto-configured + to any length int befuddled some compilers. */ + + if (sizeof(int) == 2) { + if (bs > 32767) { + bs = 32767; + } + } else { + if (bs > 200000) { + bs = 200000; + } + } + return bs; +} + +int main() +{ + int i; + double x; + + /* Seed the random number generator. If Repeatable is defined, we + always use the same seed. Otherwise, we seed from the clock to + shake things up from run to run. */ + +#ifdef Repeatable + V srand(1234); +#else + V srand((int) time((long *) NULL)); +#endif + + /* Compute x such that pow(x, p) ranges between 1 and 4*ExpIncr as + p ranges from 0 to ExpIncr-1, with a concentration in the lower + numbers. */ + + x = 4.0 * ExpIncr; + x = log(x); + x = exp(log(4.0 * ExpIncr) / (ExpIncr - 1.0)); + +#ifdef BECtl + bectl(bcompact, bexpand, bshrink, (bufsize) ExpIncr); + bp = malloc(ExpIncr); + assert(bp != NULL); + bpool((void *) bp, (bufsize) ExpIncr); +#else + bp = malloc(PoolSize); + assert(bp != NULL); + bpool((void *) bp, (bufsize) PoolSize); +#endif + + stats("Create pool"); + V bpoolv((void *) bp); + bpoold((void *) bp, dumpAlloc, dumpFree); + + for (i = 0; i < TestProg; i++) { + char *cb; + bufsize bs = pow(x, (double) (rand() & (ExpIncr - 1))); + + assert(bs <= (((bufsize) 4) * ExpIncr)); + bs = blimit(bs); + if (rand() & 0x400) { + cb = (char *) bgetz(bs); + } else { + cb = (char *) bget(bs); + } + if (cb == NULL) { +#ifdef EasyOut + break; +#else + char *bc = bchain; + + if (bc != NULL) { + char *fb; + + fb = *((char **) bc); + if (fb != NULL) { + *((char **) bc) = *((char **) fb); + brel((void *) fb); + } + continue; + } +#endif + } + *((char **) cb) = (char *) bchain; + bchain = cb; + + /* Based on a random cast, release a random buffer in the list + of allocated buffers. */ + + if ((rand() & 0x10) == 0) { + char *bc = bchain; + int i = rand() & 0x3; + + while (i > 0 && bc != NULL) { + bc = *((char **) bc); + i--; + } + if (bc != NULL) { + char *fb; + + fb = *((char **) bc); + if (fb != NULL) { + *((char **) bc) = *((char **) fb); + brel((void *) fb); + } + } + } + + /* Based on a random cast, reallocate a random buffer in the list + to a random size */ + + if ((rand() & 0x20) == 0) { + char *bc = bchain; + int i = rand() & 0x3; + + while (i > 0 && bc != NULL) { + bc = *((char **) bc); + i--; + } + if (bc != NULL) { + char *fb; + + fb = *((char **) bc); + if (fb != NULL) { + char *newb; + + bs = pow(x, (double) (rand() & (ExpIncr - 1))); + bs = blimit(bs); +#ifdef BECtl + protect = 1; /* Protect against compaction */ +#endif + newb = (char *) bgetr((void *) fb, bs); +#ifdef BECtl + protect = 0; +#endif + if (newb != NULL) { + *((char **) bc) = newb; + } + } + } + } + } + stats("\nAfter allocation"); + if (bp != NULL) { + V bpoolv((void *) bp); + bpoold((void *) bp, dumpAlloc, dumpFree); + } + + while (bchain != NULL) { + char *buf = bchain; + + bchain = *((char **) buf); + brel((void *) buf); + } + stats("\nAfter release"); +#ifndef BECtl + if (bp != NULL) { + V bpoolv((void *) bp); + bpoold((void *) bp, dumpAlloc, dumpFree); + } +#endif + + return 0; +} +#endif diff --git a/src/fragroute/bget.h b/src/fragroute/bget.h new file mode 100644 index 0000000..0c72d0e --- /dev/null +++ b/src/fragroute/bget.h @@ -0,0 +1,30 @@ +/* + + Interface definitions for bget.c, the memory management package. + +*/ + +#ifndef _ +#ifdef PROTOTYPES +#define _(x) x /* If compiler knows prototypes */ +#else +#define _(x) () /* It it doesn't */ +#endif /* PROTOTYPES */ +#endif + +typedef long bufsize; +void bpool _((void *buffer, bufsize len)); +void *bget _((bufsize size)); +void *bgetz _((bufsize size)); +void *bgetr _((void *buffer, bufsize newsize)); +void brel _((void *buf)); +void bectl _((int (*compact)(bufsize sizereq, int sequence), + void *(*acquire)(bufsize size), + void (*release)(void *buf), bufsize pool_incr)); +void bstats _((bufsize *curalloc, bufsize *totfree, bufsize *maxfree, + long *nget, long *nrel)); +void bstatse _((bufsize *pool_incr, long *npool, long *npget, + long *nprel, long *ndget, long *ndrel)); +void bufdump _((void *buf)); +void bpoold _((void *pool, int dumpalloc, int dumpfree)); +int bpoolv _((void *pool)); diff --git a/src/fragroute/fragroute.c b/src/fragroute/fragroute.c new file mode 100644 index 0000000..09cc3a5 --- /dev/null +++ b/src/fragroute/fragroute.c @@ -0,0 +1,144 @@ +/* + * fragroute.c + * + * Copyright (c) 2001 Dug Song + * Copyright (c) 2007-2008 Aaron Turner. + * $Id: fragroute.c 2303 2009-05-06 18:48:20Z aturner $ + */ + +#include "config.h" +#include "defines.h" +#include "common.h" + +#include +#include +#include +#include +#include + +#ifdef HAVE_LIBDNET +/* need to undef these which are pulled in via defines.h, prior to importing dnet.h */ +#undef icmp_id +#undef icmp_seq +#undef icmp_data +#undef icmp_mask +#include +#endif + +#include "fragroute.h" +#include "pkt.h" +#include "mod.h" +// #include "tun.h" + +void +fragroute_close(fragroute_t *ctx) +{ + free(ctx->pktq); + free(ctx); + ctx = NULL; +} + + +int +fragroute_process(fragroute_t *ctx, void *buf, size_t len) +{ + struct pkt *pkt; + assert(ctx); + assert(buf); + + ctx->first_packet = 0; + /* save the l2 header of the original packet for later */ + ctx->l2len = get_l2len(buf, len, ctx->dlt); + memcpy(ctx->l2header, buf, ctx->l2len); + + if ((pkt = pkt_new()) == NULL) { + strcpy(ctx->errbuf, "unable to pkt_new()"); + return -1; + } + if (len > PKT_BUF_LEN) { + sprintf(ctx->errbuf, "skipping oversized packet: %zu", len); + return -1; + } + + memcpy(pkt->pkt_data, buf, len); + pkt->pkt_end = pkt->pkt_data + len; + + pkt_decorate(pkt); + + if (pkt->pkt_ip == NULL) { + strcpy(ctx->errbuf, "skipping non-IP packet"); + return -1; + } + if (pkt->pkt_eth && htons(pkt->pkt_eth->eth_type) == ETH_TYPE_IP) { + ip_checksum(pkt->pkt_ip, len); + } + + TAILQ_INIT(ctx->pktq); + TAILQ_INSERT_TAIL(ctx->pktq, pkt, pkt_next); + + mod_apply(ctx->pktq); + + return 0; +} + +/* + * keep calling this after fragroute_process() to get all the fragments. + * Each call returns the fragment length which is stored in **packet. + * Returns 0 when no more fragments remain or -1 on error + */ +int +fragroute_getfragment(fragroute_t *ctx, char **packet) +{ + static struct pkt *pkt = NULL; + static struct pkt *next = NULL; + char *pkt_data = *packet; + u_int32_t length; + + if (ctx->first_packet != 0) { + pkt = next; + } else { + ctx->first_packet = 1; + pkt = TAILQ_FIRST(ctx->pktq); + } + + if (pkt != TAILQ_END(&(ctx->pktq))) { + next = TAILQ_NEXT(pkt, pkt_next); + memcpy(pkt_data, pkt->pkt_data, pkt->pkt_end - pkt->pkt_data); + + /* return the original L2 header */ + memcpy(pkt_data, ctx->l2header, ctx->l2len); + length = pkt->pkt_end - pkt->pkt_data; + pkt = next; + return length; + } + + return 0; // nothing +} + +fragroute_t * +fragroute_init(const int mtu, const int dlt, const char *config, char *errbuf) +{ + fragroute_t *ctx; + + if (dlt != DLT_EN10MB) { + sprintf(errbuf, "Fragroute only supports DLT_EN10MB pcap files"); + return NULL; + } + + + ctx = (fragroute_t *)safe_malloc(sizeof(fragroute_t)); + ctx->pktq = (struct pktq *)safe_malloc(sizeof(struct pktq)); + ctx->dlt = dlt; + + pkt_init(128); + + ctx->mtu = mtu; + + /* parse the config */ + if (mod_open(config, errbuf) < 0) { + fragroute_close(ctx); + return NULL; + } + + return ctx; +} diff --git a/src/fragroute/fragroute.h b/src/fragroute/fragroute.h new file mode 100644 index 0000000..ac8b253 --- /dev/null +++ b/src/fragroute/fragroute.h @@ -0,0 +1,69 @@ +/* $Id: fragroute.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2007-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#include "config.h" +#include "pkt.h" + +#ifndef __FRAGROUTE_H__ +#define __FRAGROUTE_H__ + +#define FRAGROUTE_ERRBUF_LEN 1024 + +/* Fragroute context. */ +struct fragroute_s { + struct addr src; + struct addr dst; + struct addr smac; + struct addr dmac; + int dlt; + int mtu; + int first_packet; /* have we called getfragment() yet after process()? */ + int l2len; + u_char l2header[50]; +// arp_t *arp; +// eth_t *eth; +// intf_t *intf; +// route_t *route; +// tun_t *tun; + char errbuf[FRAGROUTE_ERRBUF_LEN]; + struct pktq *pktq; /* packet chain */ +}; + +typedef struct fragroute_s fragroute_t; + +int fragroute_process(fragroute_t *ctx, void *buf, size_t len); +int fragroute_getfragment(fragroute_t *ctx, char **packet); +fragroute_t * fragroute_init(const int mtu, const int dlt, const char *config, char *errbuf); +void fragroute_close(fragroute_t *ctx); + +#endif /* __FRAGROUTE_H__ */ diff --git a/src/fragroute/iputil.c b/src/fragroute/iputil.c new file mode 100644 index 0000000..ce18583 --- /dev/null +++ b/src/fragroute/iputil.c @@ -0,0 +1,147 @@ +#include "config.h" +#include "defines.h" +#include "common.h" +#include "iputil.h" +#include +#include +#include +#include + +static ssize_t +inet_add_option_6(void *buf, size_t len, int proto, const void *optbuf, size_t optlen); + +ssize_t +inet_add_option(uint16_t eth_type, void *buf, size_t len, + int proto, const void *optbuf, size_t optlen) +{ + if (eth_type == ETH_TYPE_IP) { + return ip_add_option(buf, len, proto, optbuf, optlen); + } else if (eth_type == ETH_TYPE_IPV6) { + return inet_add_option_6(buf, len, proto, optbuf, optlen); + } else { + errno = EINVAL; + return -1; + } +} + +/* + * IPv6 version of libdnet's ip_add_option(): + */ +ssize_t +inet_add_option_6(void *buf, size_t len, int proto, const void *optbuf, size_t optlen) +{ + struct ip6_hdr *ip6; + struct tcp_hdr *tcp = NULL; + u_char *p; + int hl, datalen, padlen; + + if (proto != IP_PROTO_TCP) { + errno = EINVAL; + return (-1); + } + + ip6 = (struct ip6_hdr *)buf; + p = (u_char *)buf + IP6_HDR_LEN; + + tcp = (struct tcp_hdr *)p; + hl = tcp->th_off << 2; + p = (u_char *)tcp + hl; + + datalen = ntohs(ip6->ip6_plen) + IP6_HDR_LEN - (p - (u_char *)buf); + + /* Compute padding to next word boundary. */ + if ((padlen = 4 - (optlen % 4)) == 4) + padlen = 0; + + /* XXX - IP_HDR_LEN_MAX == TCP_HDR_LEN_MAX */ + if (hl + optlen + padlen > IP_HDR_LEN_MAX || + ntohs(ip6->ip6_plen) + IP6_HDR_LEN + optlen + padlen > len) { + errno = EINVAL; + return (-1); + } + + /* Shift any existing data. */ + if (datalen) { + memmove(p + optlen + padlen, p, datalen); + } + /* XXX - IP_OPT_NOP == TCP_OPT_NOP */ + if (padlen) { + memset(p, IP_OPT_NOP, padlen); + p += padlen; + } + memmove(p, optbuf, optlen); + p += optlen; + optlen += padlen; + + tcp->th_off = (p - (u_char *)tcp) >> 2; + + ip6->ip6_plen = htons(ntohs(ip6->ip6_plen) + optlen); + + return (optlen); +} + + +void +inet_checksum(uint16_t eth_type, void *buf, size_t len) +{ + if (eth_type == ETH_TYPE_IP) { + return ip_checksum(buf, len); + } else if (eth_type == ETH_TYPE_IPV6) { + return ip6_checksum(buf, len); + } +} + +int +raw_ip_opt_parse(int argc, char *argv[], uint8_t *opt_type, uint8_t *opt_len, + uint8_t *buff, int buff_len) +{ + int i, j; + + if (sscanf(argv[0], "%hhx", opt_type) != 1) { + warn("invalid opt_type"); + return -1; + } + if (sscanf(argv[1], "%hhx", opt_len) != 1) { + warn("invalid opt_len"); + return -1; + } + j = 0; + for (i = 2; i < argc && j < buff_len; ++i, ++j) { + if (sscanf(argv[i], "%hhx", &buff[j]) != 1) { + warn("invalid opt_data"); + return -1; + } + } + if (*opt_len != j + 2) { + warnx("invalid opt->len (%d) doesn't match data length (%d)", + *opt_len, j); + return -1; + } + return 0; +} + +int +raw_ip6_opt_parse(int argc, char *argv[], uint8_t *proto, int *len, + uint8_t *buff, int buff_len) +{ + int i, j; + + if (sscanf(argv[0], "%hhx", proto) != 1) { + warn("invalid protocol"); + return -1; + } + + j = 0; + for (i = 1; i < argc && j < buff_len; ++i, ++j) { + if (sscanf(argv[i], "%hhx", &buff[j]) != 1) { + warn("invalid opt_data"); + return -1; + } + } + *len = j; + if ((j + 2) % 8 != 0) { + warnx("(opt_len (%d) + 2) %% 8 != 0", j); + return -1; + } + return 0; +} diff --git a/src/fragroute/iputil.h b/src/fragroute/iputil.h new file mode 100644 index 0000000..3d2d4b1 --- /dev/null +++ b/src/fragroute/iputil.h @@ -0,0 +1,13 @@ +#ifndef IPUTIL_H +#define IPUTIL_H + +ssize_t inet_add_option(uint16_t eth_type, void *buf, size_t len, + int proto, const void *optbuf, size_t optlen); +void inet_checksum(uint16_t eth_type, void *buf, size_t len); + +int raw_ip_opt_parse(int argc, char *argv[], uint8_t *type, uint8_t *len, + uint8_t *buff, int buff_len); +int raw_ip6_opt_parse(int argc, char *argv[], uint8_t *proto, int *len, + uint8_t *buff, int buff_len); + +#endif /* IPUTIL_H */ diff --git a/src/fragroute/mod.c b/src/fragroute/mod.c new file mode 100644 index 0000000..41b765b --- /dev/null +++ b/src/fragroute/mod.c @@ -0,0 +1,187 @@ +/* + * mod.c + * + * Copyright (c) 2001 Dug Song + * Copyright (c) 2007-2010 Aaron Turner. + * + * $Id: mod.c 2423 2010-03-13 07:09:49Z aturner $ + */ + +#include "config.h" +#include "defines.h" +#include "common.h" + +#include +#include +#include +#include + +#include "argv.h" +#include "mod.h" + +#define MAX_ARGS 128 /* XXX */ + +struct rule { + struct mod *mod; + void *data; + TAILQ_ENTRY(rule) next; +}; + +/* + * XXX - new modules must be registered here. + */ +extern struct mod mod_delay; +extern struct mod mod_drop; +extern struct mod mod_dup; +extern struct mod mod_echo; +extern struct mod mod_ip_chaff; +extern struct mod mod_ip_frag; +extern struct mod mod_ip_opt; +extern struct mod mod_ip_ttl; +extern struct mod mod_ip_tos; +extern struct mod mod_ip6_qos; +extern struct mod mod_ip6_opt; +extern struct mod mod_order; +extern struct mod mod_print; +extern struct mod mod_tcp_chaff; +extern struct mod mod_tcp_opt; +extern struct mod mod_tcp_seg; + +static struct mod *mods[] = { + &mod_delay, + &mod_drop, + &mod_dup, + &mod_echo, + &mod_ip_chaff, + &mod_ip_frag, + &mod_ip_opt, + &mod_ip_ttl, + &mod_ip_tos, + &mod_ip6_qos, + &mod_ip6_opt, + &mod_order, + &mod_print, + &mod_tcp_chaff, + &mod_tcp_opt, + &mod_tcp_seg, + NULL +}; + +static TAILQ_HEAD(head, rule) rules; + +void +mod_usage(void) +{ + struct mod **m; + + for (m = mods; *m != NULL; m++) { + fprintf(stderr, " %s\n", (*m)->usage); + } +} + +int +mod_open(const char *script, char *errbuf) +{ + FILE *fp; + struct mod **m; + struct rule *rule; + char *argv[MAX_ARGS], buf[BUFSIZ]; + int i, argc, ret = 0; + + TAILQ_INIT(&rules); + + /* open the config/script file */ + if ((fp = fopen(script, "r")) == NULL) { + sprintf(errbuf, "couldn't open %s", script); + return (-1); + } + dbg(1, "opened config file..."); + /* read the file, one line at a time... */ + for (i = 1; fgets(buf, sizeof(buf), fp) != NULL; i++) { + + /* skip comments & blank lines */ + if (*buf == '#' || *buf == '\r' || *buf == '\n') + continue; + + /* parse the line into an array */ + if ((argc = argv_create(buf, MAX_ARGS, argv)) < 1) { + sprintf(errbuf, "couldn't parse arguments (line %d)", i); + ret = -1; + break; + } + + dbgx(1, "argc = %d, %s, %s, %s", argc, argv[0], argv[1], argv[2]); + /* check first keyword against modules */ + for (m = mods; *m != NULL; m++) { + if (strcasecmp((*m)->name, argv[0]) == 0) { + dbgx(1, "comparing %s to %s", argv[0], (*m)->name); + break; + } + } + + /* do we have a match? */ + if (*m == NULL) { + sprintf(errbuf, "unknown directive '%s' (line %d)", argv[0], i); + ret = -1; + break; + } + + /* allocate memory for our rule */ + if ((rule = calloc(1, sizeof(*rule))) == NULL) { + sprintf(errbuf, "calloc"); + ret = -1; + break; + } + rule->mod = *m; + + /* pass the remaining args to the rule */ + if (rule->mod->open != NULL && + (rule->data = rule->mod->open(argc, argv)) == NULL) { + sprintf(errbuf, "invalid argument to directive '%s' (line %d)", + rule->mod->name, i); + ret = -1; + break; + } + /* append the rule to the rule list */ + TAILQ_INSERT_TAIL(&rules, rule, next); + } + + /* close the file */ + fclose(fp); + dbg(1, "close file..."); + + if (ret == 0) { + buf[0] = '\0'; + TAILQ_FOREACH(rule, &rules, next) { + strlcat(buf, rule->mod->name, sizeof(buf)); + strlcat(buf, " -> ", sizeof(buf)); + } + buf[strlen(buf) - 4] = '\0'; + sprintf(errbuf, "wtf: %s", buf); + // ret = -1; + } + return (ret); +} + +void +mod_apply(struct pktq *pktq) +{ + struct rule *rule; + + TAILQ_FOREACH(rule, &rules, next) { + rule->mod->apply(rule->data, pktq); + } +} + +void +mod_close(void) +{ + struct rule *rule; + + TAILQ_FOREACH_REVERSE(rule, &rules, next, head) { + if (rule->mod->close != NULL) + rule->data = rule->mod->close(rule->data); + TAILQ_REMOVE(&rules, rule, next); + free(rule); + } +} diff --git a/src/fragroute/mod.h b/src/fragroute/mod.h new file mode 100644 index 0000000..c620d6f --- /dev/null +++ b/src/fragroute/mod.h @@ -0,0 +1,27 @@ +/* + * mod.h + * + * Copyright (c) 2001 Dug Song + * + * $Id: mod.h 2000 2008-04-27 06:17:35Z aturner $ + */ + +#ifndef MOD_H +#define MOD_H + +#include "pkt.h" + +struct mod { + char *name; + char *usage; + void *(*open)(int argc, char *argv[]); + int (*apply)(void *data, struct pktq *pktq); + void *(*close)(void *data); +}; + +void mod_usage(void); +int mod_open(const char *script, char *errbuf); +void mod_apply(struct pktq *pktq); +void mod_close(void); + +#endif /* MOD_H */ diff --git a/src/fragroute/mod_delay.c b/src/fragroute/mod_delay.c new file mode 100644 index 0000000..a6a5365 --- /dev/null +++ b/src/fragroute/mod_delay.c @@ -0,0 +1,97 @@ +/* + * mod_delay.c + * + * Copyright (c) 2001 Dug Song + * + * $Id: mod_delay.c 2000 2008-04-27 06:17:35Z aturner $ + */ + +#include "config.h" + +#include +#include +#include + +#include "pkt.h" +#include "mod.h" + +#define DELAY_FIRST 1 +#define DELAY_LAST 2 +#define DELAY_RANDOM 3 + +struct delay_data { + rand_t *rnd; + int which; + struct timeval tv; +}; + +void * +delay_close(void *d) +{ + struct delay_data *data = (struct delay_data *)d; + + if (data != NULL) { + rand_close(data->rnd); + free(data); + } + return (NULL); +} + +void * +delay_open(int argc, char *argv[]) +{ + struct delay_data *data; + uint64_t usec; + + if (argc != 3) + return (NULL); + + if ((data = malloc(sizeof(*data))) == NULL) + return (NULL); + + data->rnd = rand_open(); + + if (strcasecmp(argv[1], "first") == 0) + data->which = DELAY_FIRST; + else if (strcasecmp(argv[1], "last") == 0) + data->which = DELAY_LAST; + else if (strcasecmp(argv[1], "random") == 0) + data->which = DELAY_RANDOM; + else + return (delay_close(data)); + + if ((usec = atoi(argv[2])) <= 0) + return (delay_close(data)); + + usec *= 1000; + data->tv.tv_sec = usec / 1000000; + data->tv.tv_usec = usec % 1000000; + + return (data); +} + +int +delay_apply(void *d, struct pktq *pktq) +{ + struct delay_data *data = (struct delay_data *)d; + struct pkt *pkt; + + if (data->which == DELAY_FIRST) + pkt = TAILQ_FIRST(pktq); + else if (data->which == DELAY_LAST) + pkt = TAILQ_LAST(pktq, pktq); + else + pkt = pktq_random(data->rnd, pktq); + + memcpy(&pkt->pkt_ts, &data->tv, sizeof(pkt->pkt_ts)); + + return (0); +} + +struct mod mod_delay = { + "delay", /* name */ + "delay first|last|random ", /* usage */ + delay_open, /* open */ + delay_apply, /* apply */ + delay_close /* close */ +}; diff --git a/src/fragroute/mod_drop.c b/src/fragroute/mod_drop.c new file mode 100644 index 0000000..b1fd130 --- /dev/null +++ b/src/fragroute/mod_drop.c @@ -0,0 +1,97 @@ +/* + * mod_drop.c + * + * Copyright (c) 2001 Dug Song + * + * $Id: mod_drop.c 2000 2008-04-27 06:17:35Z aturner $ + */ + +#include "config.h" + +#include +#include +#include + +#include "pkt.h" +#include "mod.h" + +#define DROP_FIRST 1 +#define DROP_LAST 2 +#define DROP_RANDOM 3 + +struct drop_data { + rand_t *rnd; + int which; + int percent; +}; + +void * +drop_close(void *d) +{ + struct drop_data *data = (struct drop_data *)d; + + if (data != NULL) { + rand_close(data->rnd); + free(data); + } + return (NULL); +} + +void * +drop_open(int argc, char *argv[]) +{ + struct drop_data *data; + + if (argc != 3) + return (NULL); + + if ((data = calloc(1, sizeof(*data))) == NULL) + return (NULL); + + data->rnd = rand_open(); + + if (strcasecmp(argv[1], "first") == 0) + data->which = DROP_FIRST; + else if (strcasecmp(argv[1], "last") == 0) + data->which = DROP_LAST; + else if (strcasecmp(argv[1], "random") == 0) + data->which = DROP_RANDOM; + else + return (drop_close(data)); + + if ((data->percent = atoi(argv[2])) <= 0 || data->percent > 100) + return (drop_close(data)); + + return (data); +} + +int +drop_apply(void *d, struct pktq *pktq) +{ + struct drop_data *data = (struct drop_data *)d; + struct pkt *pkt; + + if (data->percent < 100 && + (rand_uint16(data->rnd) % 100) > data->percent) + return (0); + + if (data->which == DROP_FIRST) + pkt = TAILQ_FIRST(pktq); + else if (data->which == DROP_LAST) + pkt = TAILQ_LAST(pktq, pktq); + else + pkt = pktq_random(data->rnd, pktq); + + TAILQ_REMOVE(pktq, pkt, pkt_next); + pkt_free(pkt); + + return (0); +} + +struct mod mod_drop = { + "drop", /* name */ + "drop first|last|random ", /* usage */ + drop_open, /* open */ + drop_apply, /* apply */ + drop_close /* close */ +}; diff --git a/src/fragroute/mod_dup.c b/src/fragroute/mod_dup.c new file mode 100644 index 0000000..825ff78 --- /dev/null +++ b/src/fragroute/mod_dup.c @@ -0,0 +1,100 @@ +/* + * mod_dup.c + * + * Copyright (c) 2001 Dug Song + * + * $Id: mod_dup.c 2000 2008-04-27 06:17:35Z aturner $ + */ + +#include "config.h" + +#include +#include +#include + +#include "pkt.h" +#include "mod.h" + +#define DUP_FIRST 1 +#define DUP_LAST 2 +#define DUP_RANDOM 3 + +struct dup_data { + rand_t *rnd; + int which; + int percent; +}; + +void * +dup_close(void *d) +{ + struct dup_data *data = (struct dup_data *)d; + + if (data != NULL) { + rand_close(data->rnd); + free(data); + } + return (NULL); +} + +void * +dup_open(int argc, char *argv[]) +{ + struct dup_data *data; + + if (argc != 3) + return (NULL); + + if ((data = malloc(sizeof(*data))) == NULL) + return (NULL); + + data->rnd = rand_open(); + + if (strcasecmp(argv[1], "first") == 0) + data->which = DUP_FIRST; + else if (strcasecmp(argv[1], "last") == 0) + data->which = DUP_LAST; + else if (strcasecmp(argv[1], "random") == 0) + data->which = DUP_RANDOM; + else + return (dup_close(data)); + + if ((data->percent = atoi(argv[2])) <= 0 || data->percent > 100) + return (dup_close(data)); + + return (data); +} + +int +dup_apply(void *d, struct pktq *pktq) +{ + struct dup_data *data = (struct dup_data *)d; + struct pkt *pkt, *new; + + if (data->percent < 100 && + (rand_uint16(data->rnd) % 100) > data->percent) + return (0); + + if ((new = pkt_new()) == NULL) + return (-1); + + if (data->which == DUP_FIRST) + pkt = TAILQ_FIRST(pktq); + else if (data->which == DUP_LAST) + pkt = TAILQ_LAST(pktq, pktq); + else + pkt = pktq_random(data->rnd, pktq); + + new = pkt_dup(pkt); + TAILQ_INSERT_AFTER(pktq, pkt, new, pkt_next); + + return (0); +} + +struct mod mod_dup = { + "dup", /* name */ + "dup first|last|random ", /* usage */ + dup_open, /* open */ + dup_apply, /* apply */ + dup_close /* close */ +}; diff --git a/src/fragroute/mod_echo.c b/src/fragroute/mod_echo.c new file mode 100644 index 0000000..ebe8f77 --- /dev/null +++ b/src/fragroute/mod_echo.c @@ -0,0 +1,57 @@ +/* + * mod_echo.c + * + * Copyright (c) 2001 Dug Song + * + * $Id: mod_echo.c 2000 2008-04-27 06:17:35Z aturner $ + */ + +#include "config.h" + +#include + +#include +#include +#include + +#include "argv.h" +#include "mod.h" + +void * +echo_open(int argc, char *argv[]) +{ + char *p; + + if (argc < 2) + return (NULL); + + if ((p = argv_copy(argv + 1)) == NULL) + return (NULL); + + return (p); +} + +int +echo_apply(void *d, struct pktq *pktq) +{ + char *p = (char *)d; + + printf("%s\n", p); + return (0); +} + +void * +echo_close(void *d) +{ + if (d != NULL) + free(d); + return (NULL); +} + +struct mod mod_echo = { + "echo", /* name */ + "echo ...", /* usage */ + echo_open, /* open */ + echo_apply, /* apply */ + echo_close /* close */ +}; diff --git a/src/fragroute/mod_ip6_opt.c b/src/fragroute/mod_ip6_opt.c new file mode 100644 index 0000000..f90a895 --- /dev/null +++ b/src/fragroute/mod_ip6_opt.c @@ -0,0 +1,196 @@ +/* + * mod_ip6_opt.c + * + * Copyright (c) 2001 Dug Song + * + */ + +#include "config.h" + +#include +#include +#include +#include + +#include "pkt.h" +#include "mod.h" +#include "iputil.h" + +#define MAX_ADDRS 32 + +#define OPT6_TYPE_ROUTE 1 +#define OPT6_TYPE_RAW 2 + +struct ip6_opt_data_route +{ + int segments; + struct addr addr[MAX_ADDRS]; +}; + +struct ip6_opt_data_raw +{ + int len; + uint8_t proto; + uint8_t data8[512]; +}; + +struct ip6_opt_data +{ + int type; + union + { + struct ip6_opt_data_route route; + struct ip6_opt_data_raw raw; + } u; +}; + +void * +ip6_opt_close(void *d) +{ + if (d != NULL) + free(d); + return (NULL); +} + +void * +ip6_opt_open(int argc, char *argv[]) +{ + struct ip6_opt_data *opt; + int i, j; + + if (argc < 4) + return (NULL); + + if ((opt = calloc(1, sizeof(*opt))) == NULL) + return (NULL); + + if (strcasecmp(argv[1], "route") == 0) { + opt->type = OPT6_TYPE_ROUTE; + + if ((opt->u.route.segments = atoi(argv[2])) < 1 || + opt->u.route.segments > MAX_ADDRS) { + warnx(" must be >= 1"); + return (ip6_opt_close(opt)); + } + + i = 0; + j = 3; + + if (opt->u.route.segments + 3 != argc) { + return (ip6_opt_close(opt)); + } + + for (; j < argc; i++, j++) { + if (addr_aton(argv[j], &opt->u.route.addr[i]) < 0 || + opt->u.route.addr[i].addr_type != ADDR_TYPE_IP6) { + return (ip6_opt_close(opt)); + } + } + } else if (strcasecmp(argv[1], "raw") == 0) { + opt->type = OPT6_TYPE_RAW; + + if (raw_ip6_opt_parse(argc - 2, &argv[2], + &opt->u.raw.proto, &opt->u.raw.len, + &opt->u.raw.data8[2], sizeof(opt->u.raw.data8) - 2) != 0) + return (ip6_opt_close(opt)); + opt->u.raw.len += 2; + opt->u.raw.data8[0] = 0; + opt->u.raw.data8[1] = opt->u.raw.len / 8; + } else { + return (ip6_opt_close(opt)); + } + + return (opt); +} + +int +ip6_opt_apply(void *d, struct pktq *pktq) +{ + struct ip6_opt_data *opt = (struct ip6_opt_data *)d; + struct __ip6_ext_data_routing* route; + struct ip6_ext_hdr* ext; + int offset, len; + struct pkt *pkt; + uint8_t nxt, iph_nxt; + uint8_t* p; + int i; + + TAILQ_FOREACH(pkt, pktq, pkt_next) { + uint16_t eth_type = htons(pkt->pkt_eth->eth_type); + + if (eth_type != ETH_TYPE_IPV6) { + continue; + } + + nxt = pkt->pkt_ip6->ip6_nxt; + ext = (struct ip6_ext_hdr*)(((u_char*)pkt->pkt_ip6) + IP6_HDR_LEN); + + if (opt->type == OPT6_TYPE_ROUTE) { + offset = 8 + IP6_ADDR_LEN * opt->u.route.segments; + memmove(((u_char*)ext) + offset, ext, pkt->pkt_end - (u_char*)ext); + + pkt->pkt_end += offset; + pkt->pkt_ip_data += offset; + + len = (IP6_ADDR_LEN / 8) * opt->u.route.segments; + + route = (struct __ip6_ext_data_routing*)ext; + + ext->ext_data.routing.type = 0; + ext->ext_data.routing.segleft = opt->u.route.segments; + ((uint32_t*)ext)[1] = 0; /* reserved */ + + iph_nxt = IP_PROTO_ROUTING; + + p = (uint8_t*)(ext) + 8; + + for (i = 0; i < opt->u.route.segments; ++i, p += IP6_ADDR_LEN) { + memcpy(p, opt->u.route.addr[i].addr_data8, IP6_ADDR_LEN); + } + + } else if (opt->type == OPT6_TYPE_RAW) { + offset = opt->u.raw.len; + memmove(((u_char*)ext) + offset, ext, pkt->pkt_end - (u_char*)ext); + + pkt->pkt_end += offset; + pkt->pkt_ip_data += offset; + + iph_nxt = opt->u.raw.proto; + + p = (uint8_t*)ext; + memcpy(p, opt->u.raw.data8, opt->u.raw.len); + +#if 0 + printf("len: %d, data %02x %02x %02x %02x %02x %02x %02x %02x\n", + opt->u.raw.len, opt->u.raw.data8[0], opt->u.raw.data8[1], + opt->u.raw.data8[2], opt->u.raw.data8[3], + opt->u.raw.data8[4], opt->u.raw.data8[5], + opt->u.raw.data8[6], opt->u.raw.data8[7]); +#endif + + len = (opt->u.raw.len - 8) / 8; + + } else { + continue; + } + + ext->ext_nxt = nxt; + ext->ext_len = len; + + pkt->pkt_ip6->ip6_nxt = iph_nxt; + pkt->pkt_ip6->ip6_plen = htons(htons(pkt->pkt_ip6->ip6_plen) + offset); + + /* XXX: do we need it? */ + pkt_decorate(pkt); + /* ip6_checksum(pkt->pkt_ip, pkt->pkt_end - pkt->pkt_eth_data); */ + } + return (0); +} + +struct mod mod_ip6_opt = { + "ip6_opt", /* name */ + "ip6_opt [route ...] | [raw ]", /* usage */ + ip6_opt_open, /* open */ + ip6_opt_apply, /* apply */ + ip6_opt_close /* close */ +}; diff --git a/src/fragroute/mod_ip6_qos.c b/src/fragroute/mod_ip6_qos.c new file mode 100644 index 0000000..f2439b4 --- /dev/null +++ b/src/fragroute/mod_ip6_qos.c @@ -0,0 +1,83 @@ +/* + * mod_ip6_qos.c + * + * Copyright (c) 2001 Dug Song + * + */ + +#include "config.h" + +#include +#include +#include + +#include "argv.h" +#include "mod.h" +#include "pkt.h" + +struct ip6_qos_data +{ + int ip6_tc; + int ip6_fl; +}; + +static void * +ip6_qos_close(void *d) +{ + if (d != NULL) + free(d); + return (NULL); +} + +static void * +ip6_qos_open(int argc, char *argv[]) +{ + struct ip6_qos_data *data; + + if (argc != 3) { + return NULL; + } + + if ((data = calloc(1, sizeof(*data))) == NULL) + return (NULL); + + if (sscanf(argv[1], "%x", &data->ip6_tc) != 1 || + data->ip6_tc < 0 || data->ip6_tc > 255) + return (ip6_qos_close(data)); + + if (sscanf(argv[2], "%x", &data->ip6_fl) != 1 || + data->ip6_fl < 0 || data->ip6_fl > 0x100000) + return (ip6_qos_close(data)); + + printf("init: %x\n", data->ip6_fl); + + return (data); +} + +static int +ip6_qos_apply(void *d, struct pktq *pktq) +{ + struct ip6_qos_data *data = (struct ip6_qos_data *)d; + struct pkt *pkt; + + TAILQ_FOREACH(pkt, pktq, pkt_next) { + uint16_t eth_type = htons(pkt->pkt_eth->eth_type); + + if (eth_type == ETH_TYPE_IPV6) { + if (data->ip6_tc || data->ip6_fl) { + pkt->pkt_ip6->ip6_flow = htonl((uint32_t)data->ip6_tc << 20 | + data->ip6_fl); + pkt->pkt_ip6->ip6_vfc = (IP6_VERSION | (data->ip6_tc >> 4)); + } + } + } + return (0); +} + +struct mod mod_ip6_qos = { + "ip6_qos", /* name */ + "ip6_qos ", /* usage */ + ip6_qos_open, /* open */ + ip6_qos_apply, /* apply */ + ip6_qos_close /* close */ +}; diff --git a/src/fragroute/mod_ip_chaff.c b/src/fragroute/mod_ip_chaff.c new file mode 100644 index 0000000..ce6020f --- /dev/null +++ b/src/fragroute/mod_ip_chaff.c @@ -0,0 +1,137 @@ +/* + * mod_ip_chaff.c + * + * Copyright (c) 2001 Dug Song + * + * $Id: mod_ip_chaff.c 2303 2009-05-06 18:48:20Z aturner $ + */ + +#include "config.h" + +#include +#include +#include + +#include "mod.h" +#include "pkt.h" +#include "randutil.h" + +#define CHAFF_TYPE_DUP 1 +#define CHAFF_TYPE_OPT 2 +#define CHAFF_TYPE_TTL 3 + +struct ip_chaff_data { + rand_t *rnd; + int type; + int ttl; + struct pktq *pktq; +}; + +void * +ip_chaff_close(void *d) +{ + struct ip_chaff_data *data = (struct ip_chaff_data *)d; + + if (data != NULL) { + rand_close(data->rnd); + free(data); + } + return (NULL); +} + +void * +ip_chaff_open(int argc, char *argv[]) +{ + struct ip_chaff_data *data; + + if (argc < 2) + return (NULL); + + if ((data = calloc(1, sizeof(*data))) == NULL) + return (NULL); + + data->rnd = rand_open(); + + if (strcasecmp(argv[1], "dup") == 0) { + data->type = CHAFF_TYPE_DUP; + } else if (strcasecmp(argv[1], "opt") == 0) { + data->type = CHAFF_TYPE_OPT; + } else if ((data->ttl = atoi(argv[1])) >= 0 && data->ttl < 256) { + data->type = CHAFF_TYPE_TTL; + } else + return (ip_chaff_close(data)); + + return (data); +} + +int +ip_chaff_apply(void *d, struct pktq *pktq) +{ + struct ip_chaff_data *data = (struct ip_chaff_data *)d; + struct pkt *pkt, *new, *next; + struct ip_opt opt; + int i; + uint16_t eth_type; + + for (pkt = TAILQ_FIRST(pktq); pkt != TAILQ_END(pktq); pkt = next) { + next = TAILQ_NEXT(pkt, pkt_next); + eth_type = htons(pkt->pkt_eth->eth_type); + + if (pkt->pkt_ip_data == NULL) + continue; + + new = pkt_dup(pkt); + rand_strset(data->rnd, new->pkt_ip_data, + new->pkt_end - new->pkt_ip_data + 1); + + switch (data->type) { + case CHAFF_TYPE_DUP: + new->pkt_ts.tv_usec = 1; + if (eth_type == ETH_TYPE_IP) { + ip_checksum(new->pkt_ip, new->pkt_ip_data - + new->pkt_eth_data); + } + break; + case CHAFF_TYPE_OPT: + if (eth_type == ETH_TYPE_IP) { + opt.opt_type = 0x42; + opt.opt_len = IP_OPT_LEN; + i = ip_add_option(new->pkt_ip, + PKT_BUF_LEN - ETH_HDR_LEN, IP_PROTO_IP, + &opt, opt.opt_len); + /* XXX - whack opt with random crap */ + *(uint32_t *)new->pkt_ip_data = rand_uint32(data->rnd); + new->pkt_ip_data += i; + new->pkt_end += i; + ip_checksum(new->pkt_ip, new->pkt_ip_data - + new->pkt_eth_data); + } else if (eth_type == ETH_TYPE_IPV6) { + continue; + } + case CHAFF_TYPE_TTL: + if (eth_type == ETH_TYPE_IP) { + new->pkt_ip->ip_ttl = data->ttl; + ip_checksum(new->pkt_ip, new->pkt_ip_data - + new->pkt_eth_data); + } else if (eth_type == ETH_TYPE_IPV6) { + pkt->pkt_ip6->ip6_hlim = data->ttl; + } + + break; + } + /* Minimal random reordering - for ipv4 and ipv6 */ + if ((new->pkt_ip_data[0] & 1) == 0) + TAILQ_INSERT_BEFORE(pkt, new, pkt_next); + else + TAILQ_INSERT_AFTER(pktq, pkt, new, pkt_next); + } + return (0); +} + +struct mod mod_ip_chaff = { + "ip_chaff", /* name */ + "ip_chaff dup|opt|", /* usage */ + ip_chaff_open, /* open */ + ip_chaff_apply, /* apply */ + ip_chaff_close /* close */ +}; diff --git a/src/fragroute/mod_ip_frag.c b/src/fragroute/mod_ip_frag.c new file mode 100644 index 0000000..21f81b7 --- /dev/null +++ b/src/fragroute/mod_ip_frag.c @@ -0,0 +1,316 @@ +/* + * mod_ip_frag.c + * + * Copyright (c) 2001 Dug Song + * + * $Id: mod_ip_frag.c 2303 2009-05-06 18:48:20Z aturner $ + */ + +#include "config.h" +#include "defines.h" +#include "common.h" + +#include +#include +#include + +#include "mod.h" +#include "pkt.h" +#include "randutil.h" + +#ifndef MAX +#define MAX(a,b) (((a)>(b))?(a):(b)) +#endif + +#define FAVOR_OLD 1 +#define FAVOR_NEW 2 + +static int +ip_frag_apply_ipv4(void *d, struct pktq *pktq); + +static int +ip_frag_apply_ipv6(void *d, struct pktq *pktq); + +static struct ip_frag_data +{ + rand_t *rnd; + int size; + int overlap; + uint32_t ident; +} ip_frag_data; + +void * +ip_frag_close(void *d) +{ + if (ip_frag_data.rnd != NULL) + rand_close(ip_frag_data.rnd); + ip_frag_data.size = 0; + return (NULL); +} + +void * +ip_frag_open(int argc, char *argv[]) +{ + if (argc < 2) { + warn("need fragment in bytes"); + return (NULL); + } + ip_frag_data.rnd = rand_open(); + ip_frag_data.size = atoi(argv[1]); + + if (ip_frag_data.size == 0 || (ip_frag_data.size % 8) != 0) { + warn("fragment size must be a multiple of 8"); + return (ip_frag_close(&ip_frag_data)); + } + if (argc == 3) { + if (strcmp(argv[2], "old") == 0 || + strcmp(argv[2], "win32") == 0) + ip_frag_data.overlap = FAVOR_OLD; + else if (strcmp(argv[2], "new") == 0 || + strcmp(argv[2], "unix") == 0) + ip_frag_data.overlap = FAVOR_NEW; + else + return (ip_frag_close(&ip_frag_data)); + } + + ip_frag_data.ident = rand_uint32(ip_frag_data.rnd); + + return (&ip_frag_data); +} + +int +ip_frag_apply(void *d, struct pktq *pktq) +{ + struct pkt *pkt; + + /* Select eth protocol via first packet in que: */ + pkt = TAILQ_FIRST(pktq); + if (pkt != TAILQ_END(pktq)) { + uint16_t eth_type = htons(pkt->pkt_eth->eth_type); + + if (eth_type == ETH_TYPE_IP) { + ip_frag_apply_ipv4(d, pktq); + } else if (eth_type == ETH_TYPE_IPV6) { + ip_frag_apply_ipv6(d, pktq); + } + return 0; + } + return 0; +} + +static int +ip_frag_apply_ipv4(void *d, struct pktq *pktq) +{ + struct pkt *pkt, *new, *next, tmp; + int hl, fraglen, off; + u_char *p, *p1, *p2; + + for (pkt = TAILQ_FIRST(pktq); pkt != TAILQ_END(pktq); pkt = next) { + next = TAILQ_NEXT(pkt, pkt_next); + + if (pkt->pkt_ip == NULL || pkt->pkt_ip_data == NULL) + continue; + + hl = pkt->pkt_ip->ip_hl << 2; + + /* + * Preserve transport protocol header in first frag, + * to bypass filters that block `short' fragments. + */ + switch (pkt->pkt_ip->ip_p) { + case IP_PROTO_ICMP: + fraglen = MAX(ICMP_LEN_MIN, ip_frag_data.size); + break; + case IP_PROTO_UDP: + fraglen = MAX(UDP_HDR_LEN, ip_frag_data.size); + break; + case IP_PROTO_TCP: + fraglen = MAX(pkt->pkt_tcp->th_off << 2, + ip_frag_data.size); + break; + default: + fraglen = ip_frag_data.size; + break; + } + if (fraglen & 7) + fraglen = (fraglen & ~7) + 8; + + if (pkt->pkt_end - pkt->pkt_ip_data < fraglen) + continue; + + for (p = pkt->pkt_ip_data; p < pkt->pkt_end; ) { + new = pkt_new(); + memcpy(new->pkt_eth, pkt->pkt_eth, (u_char*)pkt->pkt_eth_data - (u_char*)pkt->pkt_eth); + memcpy(new->pkt_ip, pkt->pkt_ip, hl); + new->pkt_ip_data = new->pkt_eth_data + hl; + + p1 = p, p2 = NULL; + off = (p - pkt->pkt_ip_data) >> 3; + + if (ip_frag_data.overlap != 0 && (off & 1) != 0 && + p + (fraglen << 1) < pkt->pkt_end) { + rand_strset(ip_frag_data.rnd, tmp.pkt_buf, + fraglen); + if (ip_frag_data.overlap == FAVOR_OLD) { + p1 = p + fraglen; + p2 = tmp.pkt_buf; + } else if (ip_frag_data.overlap == FAVOR_NEW) { + p1 = tmp.pkt_buf; + p2 = p + fraglen; + } + new->pkt_ip->ip_off = htons(IP_MF | + (off + (fraglen >> 3))); + } else { + new->pkt_ip->ip_off = htons(off | + ((p + fraglen < pkt->pkt_end) ? IP_MF: 0)); + } + new->pkt_ip->ip_len = htons(hl + fraglen); + ip_checksum(new->pkt_ip, hl + fraglen); + + memcpy(new->pkt_ip_data, p1, fraglen); + new->pkt_end = new->pkt_ip_data + fraglen; + TAILQ_INSERT_BEFORE(pkt, new, pkt_next); + + if (p2 != NULL) { + new = pkt_dup(new); + new->pkt_ts.tv_usec = 1; + new->pkt_ip->ip_off = htons(IP_MF | off); + new->pkt_ip->ip_len = htons(hl + (fraglen<<1)); + ip_checksum(new->pkt_ip, hl + (fraglen<<1)); + + memcpy(new->pkt_ip_data, p, fraglen); + memcpy(new->pkt_ip_data+fraglen, p2, fraglen); + new->pkt_end = new->pkt_ip_data + (fraglen<<1); + TAILQ_INSERT_BEFORE(pkt, new, pkt_next); + p += (fraglen << 1); + } else + p += fraglen; + + if ((fraglen = pkt->pkt_end - p) > ip_frag_data.size) + fraglen = ip_frag_data.size; + } + TAILQ_REMOVE(pktq, pkt, pkt_next); + pkt_free(pkt); + } + return (0); +} + + +static int +ip_frag_apply_ipv6(void *d, struct pktq *pktq) +{ + struct pkt *pkt, *new, *next, tmp; + struct ip6_ext_hdr *ext; + int hl, fraglen, off; + u_char *p, *p1, *p2; + uint8_t next_hdr; + + ip_frag_data.ident++; + + for (pkt = TAILQ_FIRST(pktq); pkt != TAILQ_END(pktq); pkt = next) { + next = TAILQ_NEXT(pkt, pkt_next); + + if (pkt->pkt_ip == NULL || pkt->pkt_ip_data == NULL) + continue; + + hl = IP6_HDR_LEN; + + /* + * Preserve transport protocol header in first frag, + * to bypass filters that block `short' fragments. + */ + switch (pkt->pkt_ip->ip_p) { + case IP_PROTO_ICMP: + fraglen = MAX(ICMP_LEN_MIN, ip_frag_data.size); + break; + case IP_PROTO_UDP: + fraglen = MAX(UDP_HDR_LEN, ip_frag_data.size); + break; + case IP_PROTO_TCP: + fraglen = MAX(pkt->pkt_tcp->th_off << 2, + ip_frag_data.size); + break; + default: + fraglen = ip_frag_data.size; + break; + } + if (fraglen & 7) + fraglen = (fraglen & ~7) + 8; + + if (pkt->pkt_end - pkt->pkt_ip_data < fraglen) + continue; + + next_hdr = pkt->pkt_ip6->ip6_nxt; + + for (p = pkt->pkt_ip_data; p < pkt->pkt_end; ) { + new = pkt_new(); + memcpy(new->pkt_eth, pkt->pkt_eth, (u_char*)pkt->pkt_eth_data - (u_char*)pkt->pkt_eth); + memcpy(new->pkt_ip, pkt->pkt_ip, hl); + ext = (struct ip6_ext_hdr *)((u_char*)new->pkt_eth_data + hl); + new->pkt_ip_data = (u_char *)(ext) + 2 + + sizeof(struct ip6_ext_data_fragment); + new->pkt_ip6->ip6_nxt = IP_PROTO_FRAGMENT; + + ext->ext_nxt = next_hdr; + ext->ext_len = 0; /* ip6 fragf reserved */ + ext->ext_data.fragment.ident = ip_frag_data.ident; + + + p1 = p, p2 = NULL; + off = (p - pkt->pkt_ip_data) >> 3; + + if (ip_frag_data.overlap != 0 && (off & 1) != 0 && + p + (fraglen << 1) < pkt->pkt_end) { + rand_strset(ip_frag_data.rnd, tmp.pkt_buf, + fraglen); + if (ip_frag_data.overlap == FAVOR_OLD) { + p1 = p + fraglen; + p2 = tmp.pkt_buf; + } else if (ip_frag_data.overlap == FAVOR_NEW) { + p1 = tmp.pkt_buf; + p2 = p + fraglen; + } + ext->ext_data.fragment.offlg = + htons((off /*+ (fraglen >> 3)*/) << 3) | IP6_MORE_FRAG; + } else { + ext->ext_data.fragment.offlg = htons(off << 3) | + ((p + fraglen < pkt->pkt_end) ? IP6_MORE_FRAG : 0); + } + new->pkt_ip6->ip6_plen = htons(fraglen + 8); + + memcpy(new->pkt_ip_data, p1, fraglen); + new->pkt_end = new->pkt_ip_data + fraglen; + TAILQ_INSERT_BEFORE(pkt, new, pkt_next); + + if (p2 != NULL) { + new = pkt_dup(new); + new->pkt_ts.tv_usec = 1; + + ext->ext_data.fragment.offlg = htons(off << 3) | IP6_MORE_FRAG; + new->pkt_ip6->ip6_plen = htons((fraglen << 1) + 8); + + memcpy(new->pkt_ip_data, p, fraglen); + memcpy(new->pkt_ip_data + fraglen, p2, fraglen); + new->pkt_end = new->pkt_ip_data + (fraglen << 1); + TAILQ_INSERT_BEFORE(pkt, new, pkt_next); + p += (fraglen << 1); + } else { + p += fraglen; + } + + if ((fraglen = pkt->pkt_end - p) > ip_frag_data.size) + fraglen = ip_frag_data.size; + } + TAILQ_REMOVE(pktq, pkt, pkt_next); + pkt_free(pkt); + } + return 0; +} + +struct mod mod_ip_frag = { + "ip_frag", /* name */ + "ip_frag [old|new]", /* usage */ + ip_frag_open, /* open */ + ip_frag_apply, /* apply */ + ip_frag_close /* close */ +}; diff --git a/src/fragroute/mod_ip_opt.c b/src/fragroute/mod_ip_opt.c new file mode 100644 index 0000000..1b8e8f2 --- /dev/null +++ b/src/fragroute/mod_ip_opt.c @@ -0,0 +1,102 @@ +/* + * mod_ip_opt.c + * + * Copyright (c) 2001 Dug Song + * + * $Id: mod_ip_opt.c 2303 2009-05-06 18:48:20Z aturner $ + */ + +#include "config.h" +#include "defines.h" +#include "common.h" + +#include +#include +#include + +#include "pkt.h" +#include "mod.h" +#include "iputil.h" + +void * +ip_opt_close(void *d) +{ + if (d != NULL) + free(d); + return (NULL); +} + +void * +ip_opt_open(int argc, char *argv[]) +{ + struct ip_opt *opt; + struct addr addr; + int i, j; + + if (argc < 4) + return (NULL); + + if ((opt = calloc(1, sizeof(*opt))) == NULL) + return (NULL); + + if (strcasecmp(argv[1], "lsrr") == 0) { + opt->opt_type = IP_OPT_LSRR; + } else if (strcasecmp(argv[1], "ssrr") == 0) { + opt->opt_type = IP_OPT_SSRR; + } else if (strcasecmp(argv[1], "raw") == 0) { + if (raw_ip_opt_parse(argc - 2, &argv[2], &opt->opt_type, &opt->opt_len, + &opt->opt_data.data8[0], sizeof(opt->opt_data.data8)) != 0) + return (ip_opt_close(opt)); + return opt; + } else + return (ip_opt_close(opt)); + + if ((i = atoi(argv[2])) < 4 || i > 0xff) { + warn(" must be >= 4, and should be a multiple of 4"); + return (ip_opt_close(opt)); + } + opt->opt_data.rr.ptr = i; + + for (i = 3, j = 0; i < argc && j < 9; i++, j++) { + if (addr_aton(argv[i], &addr) < 0) { + return (ip_opt_close(opt)); + } + opt->opt_data.rr.iplist[j] = addr.addr_ip; + } + opt->opt_len = IP_OPT_LEN + 1 + (IP_ADDR_LEN * j); + + return (opt); +} + +int +ip_opt_apply(void *d, struct pktq *pktq) +{ + struct ip_opt *opt = (struct ip_opt *)d; + struct pkt *pkt; + size_t len; + + TAILQ_FOREACH(pkt, pktq, pkt_next) { + uint16_t eth_type = htons(pkt->pkt_eth->eth_type); + + if (eth_type == ETH_TYPE_IP) { + len = ip_add_option(pkt->pkt_ip, PKT_BUF_LEN - ETH_HDR_LEN, + IP_PROTO_IP, opt, opt->opt_len); + + if (len > 0) { + pkt->pkt_end += len; + pkt_decorate(pkt); + ip_checksum(pkt->pkt_ip, + pkt->pkt_end - pkt->pkt_eth_data); + } + } + } + return (0); +} + +struct mod mod_ip_opt = { + "ip_opt", /* name */ + "ip_opt [lsrr|ssrr ...] | [raw ]", /* usage */ + ip_opt_open, /* open */ + ip_opt_apply, /* apply */ + ip_opt_close /* close */ +}; diff --git a/src/fragroute/mod_ip_tos.c b/src/fragroute/mod_ip_tos.c new file mode 100644 index 0000000..e0a8a80 --- /dev/null +++ b/src/fragroute/mod_ip_tos.c @@ -0,0 +1,73 @@ +/* + * mod_ip_tos.c + * + * Copyright (c) 2001 Dug Song + * + * $Id: mod_ip_tos.c 2303 2009-05-06 18:48:20Z aturner $ + */ + +#include "config.h" + +#include +#include +#include + +#include "argv.h" +#include "mod.h" +#include "pkt.h" + +struct ip_tos_data { + int tos; +}; + +void * +ip_tos_close(void *d) +{ + if (d != NULL) + free(d); + return (NULL); +} + +void * +ip_tos_open(int argc, char *argv[]) +{ + struct ip_tos_data *data; + + if (argc != 2) + return (NULL); + + if ((data = calloc(1, sizeof(*data))) == NULL) + return (NULL); + + if (sscanf(argv[1], "%i", &data->tos) != 1 || + data->tos < 0 || data->tos > 255) + return (ip_tos_close(data)); + + return (data); +} + +int +ip_tos_apply(void *d, struct pktq *pktq) +{ + struct ip_tos_data *data = (struct ip_tos_data *)d; + struct pkt *pkt; + + TAILQ_FOREACH(pkt, pktq, pkt_next) { + uint16_t eth_type = htons(pkt->pkt_eth->eth_type); + + if (eth_type == ETH_TYPE_IP) { + pkt->pkt_ip->ip_tos = data->tos; + /* XXX - do incremental checksum */ + ip_checksum(pkt->pkt_ip, pkt->pkt_ip_data - pkt->pkt_eth_data); + } + } + return (0); +} + +struct mod mod_ip_tos = { + "ip_tos", /* name */ + "ip_tos ", /* usage */ + ip_tos_open, /* open */ + ip_tos_apply, /* apply */ + ip_tos_close /* close */ +}; diff --git a/src/fragroute/mod_ip_ttl.c b/src/fragroute/mod_ip_ttl.c new file mode 100644 index 0000000..68cab60 --- /dev/null +++ b/src/fragroute/mod_ip_ttl.c @@ -0,0 +1,79 @@ +/* + * mod_ip_ttl.c + * + * Copyright (c) 2001 Dug Song + * + * $Id: mod_ip_ttl.c 2303 2009-05-06 18:48:20Z aturner $ + */ + +#include "config.h" + +#include +#include +#include + +#include "argv.h" +#include "mod.h" +#include "pkt.h" + +struct ip_ttl_data { + int ttl; +}; + +void * +ip_ttl_close(void *d) +{ + if (d != NULL) + free(d); + return (NULL); +} + +void * +ip_ttl_open(int argc, char *argv[]) +{ + struct ip_ttl_data *data; + + if (argc != 2) + return (NULL); + + if ((data = calloc(1, sizeof(*data))) == NULL) + return (NULL); + + if ((data->ttl = atoi(argv[1])) <= 0 || data->ttl > 255) + return (ip_ttl_close(data)); + + return (data); +} + +int +ip_ttl_apply(void *d, struct pktq *pktq) +{ + struct ip_ttl_data *data = (struct ip_ttl_data *)d; + struct pkt *pkt; + int ttldec; + + TAILQ_FOREACH(pkt, pktq, pkt_next) { + uint16_t eth_type = htons(pkt->pkt_eth->eth_type); + + if (eth_type == ETH_TYPE_IP) { + ttldec = pkt->pkt_ip->ip_ttl - data->ttl; + pkt->pkt_ip->ip_ttl = data->ttl; + + if (pkt->pkt_ip->ip_sum >= htons(0xffff - (ttldec << 8))) + pkt->pkt_ip->ip_sum += htons(ttldec << 8) + 1; + else + pkt->pkt_ip->ip_sum += htons(ttldec << 8); + } else if (eth_type == ETH_TYPE_IPV6) { + pkt->pkt_ip6->ip6_hlim = data->ttl; + } + } + return (0); +} + +struct mod mod_ip_ttl = { + "ip_ttl", /* name */ + "ip_ttl ", /* usage */ + ip_ttl_open, /* open */ + ip_ttl_apply, /* apply */ + ip_ttl_close /* close */ +}; diff --git a/src/fragroute/mod_order.c b/src/fragroute/mod_order.c new file mode 100644 index 0000000..bbfebba --- /dev/null +++ b/src/fragroute/mod_order.c @@ -0,0 +1,79 @@ +/* + * mod_order.c + * + * Copyright (c) 2001 Dug Song + * + * $Id: mod_order.c 2000 2008-04-27 06:17:35Z aturner $ + */ + +#include "config.h" + +#include +#include +#include + +#include "mod.h" + +#define ORDER_RANDOM 1 +#define ORDER_REVERSE 2 + +struct order_data { + rand_t *rnd; + int type; +}; + +void * +order_close(void *d) +{ + struct order_data *data = (struct order_data *)d; + + if (data != NULL) { + rand_close(data->rnd); + free(data); + } + return (NULL); +} + +void * +order_open(int argc, char *argv[]) +{ + struct order_data *data; + + if (argc < 2) + return (NULL); + + if ((data = malloc(sizeof(*data))) == NULL) + return (NULL); + + data->rnd = rand_open(); + + if (strcasecmp(argv[1], "random") == 0) { + data->type = ORDER_RANDOM; + } else if (strcasecmp(argv[1], "reverse") == 0) { + data->type = ORDER_REVERSE; + } else + return (order_close(data)); + + return (data); +} + +int +order_apply(void *d, struct pktq *pktq) +{ + struct order_data *data = (struct order_data *)d; + + if (data->type == ORDER_RANDOM) + pktq_shuffle(data->rnd, pktq); + else + pktq_reverse(pktq); + + return (0); +} + +struct mod mod_order = { + "order", /* name */ + "order random|reverse", /* usage */ + order_open, /* open */ + order_apply, /* apply */ + order_close /* close */ +}; diff --git a/src/fragroute/mod_print.c b/src/fragroute/mod_print.c new file mode 100644 index 0000000..4b99ffc --- /dev/null +++ b/src/fragroute/mod_print.c @@ -0,0 +1,446 @@ +/* + * mod_print.c + * + * Copyright (c) 2001 Dug Song + * + * $Id: mod_print.c 2303 2009-05-06 18:48:20Z aturner $ + */ + +#include "config.h" + +#include +#include +#include + +#include "mod.h" +#include "pkt.h" + +#ifndef INET6_ADDRSTRLEN +#define INET6_ADDRSTRLEN 46 +#endif + +#define EXTRACT_16BITS(p) ((uint16_t)ntohs(*(uint16_t *)(p))) +#define EXTRACT_32BITS(p) ((uint32_t)ntohl(*(uint32_t *)(p))) + +/* XXX - _print_* routines adapted from tcpdump */ + +static void +_print_icmp(u_char *p, int length) +{ + struct ip_hdr *ip; + struct icmp_hdr *icmp; + + ip = (struct ip_hdr *)p; + icmp = (struct icmp_hdr *)(p + (ip->ip_hl * 4)); + + /* XXX - truncation? */ + printf("%s > %s:", ip_ntoa(&ip->ip_src), ip_ntoa(&ip->ip_dst)); + printf(" icmp: type %d code %d", icmp->icmp_type, icmp->icmp_code); +} + +static void +_print_icmp6(u_char *p, int length) +{ + struct ip6_hdr *ip6; + struct icmp_hdr *icmp; + + ip6 = (struct ip6_hdr *)p; + icmp = (struct icmp_hdr *)(p + IP6_HDR_LEN); + + /* XXX - truncation? */ + printf("%s > %s:", ip6_ntoa(&ip6->ip6_src), ip6_ntoa(&ip6->ip6_dst)); + printf(" icmp: type %hhu code %hhu", icmp->icmp_type, icmp->icmp_code); +} + +void +_print_tcp(int family, unsigned char *p, int length) +{ + struct tcp_hdr *tcp; + u_short sport, dport, win, urp; + u_long seq, ack; + int len, tcp_hl; + register char ch; + + char src[INET6_ADDRSTRLEN], dst[INET6_ADDRSTRLEN]; + + if (family == AF_INET6) { + struct ip6_hdr *ip6 = (struct ip6_hdr *)p; + tcp = (struct tcp_hdr *)(p + IP6_HDR_LEN); + len = length; + + ip6_ntop(&ip6->ip6_src, src, sizeof(src)); + ip6_ntop(&ip6->ip6_dst, dst, sizeof(dst)); + } else { + struct ip_hdr *ip; + + ip = (struct ip_hdr *)p; + tcp = (struct tcp_hdr *)(p + (ip->ip_hl * 4)); + len = length - (ip->ip_hl * 4); + + ip_ntop(&ip->ip_src, src, sizeof(src)); + ip_ntop(&ip->ip_dst, dst, sizeof(dst)); + } + + if (len < TCP_HDR_LEN) { + printf("truncated-tcp %d", len); + return; + } + sport = ntohs(tcp->th_sport); + dport = ntohs(tcp->th_dport); + seq = ntohl(tcp->th_seq); + ack = ntohl(tcp->th_ack); + win = ntohs(tcp->th_win); + urp = ntohs(tcp->th_urp); + tcp_hl = tcp->th_off * 4; + + printf("%s.%d > %s.%d: ", src, sport, dst, dport); + + if (tcp->th_flags & (TH_SYN|TH_FIN|TH_RST|TH_PUSH)) { + if (tcp->th_flags & TH_SYN) putchar('S'); + if (tcp->th_flags & TH_FIN) putchar('F'); + if (tcp->th_flags & TH_RST) putchar('R'); + if (tcp->th_flags & TH_PUSH) putchar('P'); + } else + putchar('.'); + + if (tcp_hl > len) { + printf(" [bad hdr length]"); + return; + } + len -= tcp_hl; + + if (len > 0 || tcp->th_flags & (TH_SYN | TH_FIN | TH_RST)) + printf(" %lu:%lu(%d)", seq, seq + len, len); + + if (tcp->th_flags & TH_ACK) + printf(" ack %lu", ack); + printf(" win %d", win); + if (tcp->th_flags & TH_URG) + printf(" urg %d", urp); + + /* Handle options. */ + if ((tcp_hl -= TCP_HDR_LEN) > 0) { + register const u_char *cp; + register int i, opt, len, datalen; + + cp = (const u_char *)tcp + TCP_HDR_LEN; + putchar(' '); + ch = '<'; + + while (tcp_hl > 0) { + putchar(ch); + opt = *cp++; + if (TCP_OPT_TYPEONLY(opt)) { + len = 1; + } else { + len = *cp++; /* total including type, len */ + if (len < 2 || len > tcp_hl) + goto bad; + --tcp_hl; /* account for length byte */ + } + --tcp_hl; /* account for type byte */ + datalen = 0; + +/* Bail if "l" bytes of data are not left or were not captured */ +#define LENCHECK(l) { if ((l) > tcp_hl) goto bad; } + + switch (opt) { + case TCP_OPT_MSS: + printf("mss"); + datalen = 2; + LENCHECK(datalen); + printf(" %u", EXTRACT_16BITS(cp)); + break; + case TCP_OPT_EOL: + printf("eol"); + break; + case TCP_OPT_NOP: + printf("nop"); + break; + case TCP_OPT_WSCALE: + printf("wscale"); + datalen = 1; + LENCHECK(datalen); + printf(" %u", *cp); + break; + case TCP_OPT_SACKOK: + printf("sackOK"); + if (len != 2) + printf("[len %d]", len); + break; + case TCP_OPT_SACK: + datalen = len - 2; + if ((datalen % 8) != 0 || + !(tcp->th_flags & TH_ACK)) { + printf("malformed sack "); + printf("[len %d] ", datalen); + break; + } + printf("sack %d ", datalen / 8); + break; + case TCP_OPT_ECHO: + printf("echo"); + datalen = 4; + LENCHECK(datalen); + printf(" %u", EXTRACT_32BITS(cp)); + break; + case TCP_OPT_ECHOREPLY: + printf("echoreply"); + datalen = 4; + LENCHECK(datalen); + printf(" %u", EXTRACT_32BITS(cp)); + break; + case TCP_OPT_TIMESTAMP: + printf("timestamp"); + datalen = 8; + LENCHECK(4); + printf(" %u", EXTRACT_32BITS(cp)); + LENCHECK(datalen); + printf(" %u", EXTRACT_32BITS(cp + 4)); + break; + case TCP_OPT_CC: + printf("cc"); + datalen = 4; + LENCHECK(datalen); + printf(" %u", EXTRACT_32BITS(cp)); + break; + case TCP_OPT_CCNEW: + printf("ccnew"); + datalen = 4; + LENCHECK(datalen); + printf(" %u", EXTRACT_32BITS(cp)); + break; + case TCP_OPT_CCECHO: + printf("ccecho"); + datalen = 4; + LENCHECK(datalen); + printf(" %u", EXTRACT_32BITS(cp)); + break; + default: + printf("opt-%d:", opt); + datalen = len - 2; + for (i = 0; i < datalen; ++i) { + LENCHECK(i); + printf("%02x", cp[i]); + } + break; + } + /* Account for data printed */ + cp += datalen; + tcp_hl -= datalen; + + /* Check specification against observed length */ + ++datalen; /* option octet */ + if (!TCP_OPT_TYPEONLY(opt)) + ++datalen; /* size octet */ + if (datalen != len) + printf("[len %d]", len); + ch = ','; + if (opt == TCP_OPT_EOL) + break; + } + putchar('>'); + } + return; + bad: + fputs("[bad opt]", stdout); + if (ch != '\0') + putchar('>'); + return; +} + +static void +_print_udp(int family, u_char *p, int length) +{ + struct udp_hdr *udp; + char src[INET6_ADDRSTRLEN], dst[INET6_ADDRSTRLEN]; + + if (family == AF_INET6) { + struct ip6_hdr *ip6 = (struct ip6_hdr *)p; + udp = (struct udp_hdr *)(p + IP6_HDR_LEN); + + ip6_ntop(&ip6->ip6_src, src, sizeof(src)); + ip6_ntop(&ip6->ip6_dst, dst, sizeof(dst)); + } else { + struct ip_hdr *ip; + + ip = (struct ip_hdr *)p; + udp = (struct udp_hdr *)(p + (ip->ip_hl * 4)); + + ip_ntop(&ip->ip_src, src, sizeof(src)); + ip_ntop(&ip->ip_dst, dst, sizeof(dst)); + } + + /* XXX - truncation? */ + printf("%s.%d > %s.%d:", src, ntohs(udp->uh_sport), + dst, ntohs(udp->uh_dport)); + printf(" udp %d", ntohs(udp->uh_ulen) - UDP_HDR_LEN); +} + +static void +_print_frag6(u_char *p, int length) +{ + struct ip6_hdr *ip6; + struct ip6_ext_hdr *ext; + int off; + + ip6 = (struct ip6_hdr *)p; + ext = (struct ip6_ext_hdr *)(p + IP6_HDR_LEN); + + off = htons(ext->ext_data.fragment.offlg & IP6_OFF_MASK); + + printf("%s > %s:", ip6_ntoa(&ip6->ip6_src), ip6_ntoa(&ip6->ip6_dst)); + printf(" fragment: next %hhu offset %d%s ident 0x%08x", + ext->ext_nxt, off, + (ext->ext_data.fragment.offlg & IP6_MORE_FRAG) ? " MF" : "", + htonl(ext->ext_data.fragment.ident)); +} + +static void +_print_ip(u_char *p, int length) +{ + struct ip_hdr *ip; + u_int ip_off, ip_hl, ip_len; + + ip = (struct ip_hdr *)p; + + if (length < IP_HDR_LEN) { + printf("truncated-ip %d", length); + return; + } + ip_hl = ip->ip_hl * 4; + ip_len = ntohs(ip->ip_len); + + if (length < ip_len) { + printf("truncated-ip - %d bytes missing!", ip_len - length); + return; + } + ip_off = ntohs(ip->ip_off); + + /* Handle first fragment. */ + if ((ip_off & IP_OFFMASK) == 0) { + switch (ip->ip_p) { + case IP_PROTO_TCP: + _print_tcp(AF_INET, p, ip_len); + break; + case IP_PROTO_UDP: + _print_udp(AF_INET, p, ip_len); + break; + case IP_PROTO_ICMP: + _print_icmp(p, ip_len); + break; + default: + printf("%s > %s:", ip_ntoa(&ip->ip_src), + ip_ntoa(&ip->ip_dst)); + printf(" ip-proto-%d %d", ip->ip_p, ip_len); + break; + } + } + /* Handle more frags. */ + if (ip_off & (IP_MF|IP_OFFMASK)) { + if (ip_off & IP_OFFMASK) + printf("%s > %s:", ip_ntoa(&ip->ip_src), + ip_ntoa(&ip->ip_dst)); + printf(" (frag %d:%d@%d%s)", ntohs(ip->ip_id), ip_len - ip_hl, + (ip_off & IP_OFFMASK) << 3, (ip_off & IP_MF) ? "+" : ""); + } else if (ip_off & IP_DF) + printf(" (DF)"); + + if (ip->ip_tos) + printf(" [tos 0x%x]", ip->ip_tos); + if (ip->ip_ttl <= 1) + printf(" [ttl %d]", ip->ip_ttl); +} + +static void +_print_ip6(u_char *p, int length) +{ + struct ip6_hdr *ip6; + int plen; + + ip6 = (struct ip6_hdr *)p; + + if (length < IP6_HDR_LEN) { + printf("truncated-ip6 %d", length); + return; + } + + plen = htons(ip6->ip6_plen); + + switch (ip6->ip6_nxt) { + case IP_PROTO_TCP: + _print_tcp(AF_INET6, p, plen); + break; + case IP_PROTO_UDP: + _print_udp(AF_INET6, p, plen); + break; + case IP_PROTO_ICMPV6: + _print_icmp6(p, plen); + break; + case IP_PROTO_FRAGMENT: + _print_frag6(p, plen); + break; + default: + printf("%s > %s:", ip6_ntoa(&ip6->ip6_src), + ip6_ntoa(&ip6->ip6_dst)); + printf(" ip-proto-%hhu ttl %hhu payload len %hu", ip6->ip6_nxt, + ip6->ip6_hlim, plen); + break; + } + + if (ip6->ip6_hlim <= 1) + printf(" [ttl %d]", ip6->ip6_hlim); +} + +static void +_print_eth(struct eth_hdr* e, int length) +{ + char d[20], s[20]; + eth_ntop(&e->eth_dst, &d[0], sizeof(d)); + eth_ntop(&e->eth_src, &s[0], sizeof(s)); + + printf("%s > %s type 0x%04hx length %d", d, s, htons(e->eth_type), length); +} + +static char * +timerntoa(struct timeval *tv) +{ + static char buf[128]; + uint64_t usec; + + usec = (tv->tv_sec * 1000000) + tv->tv_usec; + + snprintf(buf, sizeof(buf), "%d.%03d ms", + (int)(usec / 1000), (int)(usec % 1000)); + + return (buf); +} + +int +print_apply(void *d, struct pktq *pktq) +{ + struct pkt *pkt; + + TAILQ_FOREACH(pkt, pktq, pkt_next) { + uint16_t eth_type = htons(pkt->pkt_eth->eth_type); + + if (eth_type == ETH_TYPE_IP) + _print_ip(pkt->pkt_eth_data, pkt->pkt_end - pkt->pkt_eth_data); + else if (eth_type == ETH_TYPE_IPV6) + _print_ip6(pkt->pkt_eth_data, pkt->pkt_end - pkt->pkt_eth_data); + else + _print_eth(pkt->pkt_eth, pkt->pkt_end - pkt->pkt_data); + if (timerisset(&pkt->pkt_ts)) + printf(" [delay %s]", timerntoa(&pkt->pkt_ts)); + printf("\n"); + } + return (0); +} + +struct mod mod_print = { + "print", /* name */ + "print", /* usage */ + NULL, /* init */ + print_apply, /* apply */ + NULL /* close */ +}; diff --git a/src/fragroute/mod_tcp_chaff.c b/src/fragroute/mod_tcp_chaff.c new file mode 100644 index 0000000..d08443d --- /dev/null +++ b/src/fragroute/mod_tcp_chaff.c @@ -0,0 +1,197 @@ +/* + * mod_tcp_chaff.c + * + * Copyright (c) 2001 Dug Song + * + * $Id: mod_tcp_chaff.c 2303 2009-05-06 18:48:20Z aturner $ + */ + +#include "config.h" + +#include +#include +#include + +#include "pkt.h" +#include "mod.h" +#include "randutil.h" +#include "iputil.h" + +#define CHAFF_TYPE_CKSUM 1 +#define CHAFF_TYPE_NULL 2 +#define CHAFF_TYPE_PAWS 3 +#define CHAFF_TYPE_REXMIT 4 +#define CHAFF_TYPE_SEQ 5 +#define CHAFF_TYPE_SYN 6 +#define CHAFF_TYPE_TTL 7 + +struct tcp_chaff_data { + rand_t *rnd; + int type; + int ttl; +}; + +void * +tcp_chaff_close(void *d) +{ + struct tcp_chaff_data *data = (struct tcp_chaff_data *)d; + + if (data != NULL) { + rand_close(data->rnd); + free(data); + } + return (NULL); +} + +void * +tcp_chaff_open(int argc, char *argv[]) +{ + struct tcp_chaff_data *data; + + if (argc < 2) + return (NULL); + + if ((data = calloc(1, sizeof(*data))) == NULL) + return (NULL); + + data->rnd = rand_open(); + + if (strcasecmp(argv[1], "cksum") == 0) + data->type = CHAFF_TYPE_CKSUM; + else if (strcasecmp(argv[1], "null") == 0) + data->type = CHAFF_TYPE_NULL; + else if (strcasecmp(argv[1], "paws") == 0) + data->type = CHAFF_TYPE_PAWS; + else if (strcasecmp(argv[1], "rexmit") == 0) + data->type = CHAFF_TYPE_REXMIT; + else if (strcasecmp(argv[1], "seq") == 0) + data->type = CHAFF_TYPE_SEQ; + else if (strcasecmp(argv[1], "syn") == 0) + data->type = CHAFF_TYPE_SYN; + else if ((data->ttl = atoi(argv[1])) > 0 && data->ttl < 256) + data->type = CHAFF_TYPE_TTL; + else + return (tcp_chaff_close(data)); + + return (data); +} + +int +tcp_chaff_apply(void *d, struct pktq *pktq) +{ + struct tcp_chaff_data *data = (struct tcp_chaff_data *)d; + struct pkt *pkt, *new, *next; + struct tcp_opt opt; + int i; + uint16_t eth_type; + uint8_t nxt; + + for (pkt = TAILQ_FIRST(pktq); pkt != TAILQ_END(pktq); pkt = next) { + next = TAILQ_NEXT(pkt, pkt_next); + + eth_type = htons(pkt->pkt_eth->eth_type); + + if (pkt->pkt_ip == NULL) + continue; + + if (eth_type == ETH_TYPE_IP) { + nxt = pkt->pkt_ip->ip_p; + } else if (eth_type == ETH_TYPE_IPV6) { + nxt = pkt->pkt_ip6->ip6_nxt; + } else { + continue; + } + + if (nxt != IP_PROTO_TCP || + pkt->pkt_tcp == NULL || pkt->pkt_tcp_data == NULL || + (pkt->pkt_tcp->th_flags & TH_ACK) == 0) + continue; + + new = pkt_dup(pkt); + rand_strset(data->rnd, new->pkt_tcp_data, new->pkt_end - + new->pkt_tcp_data + 1); + + switch (data->type) { + case CHAFF_TYPE_CKSUM: + inet_checksum(eth_type, new->pkt_ip, + new->pkt_ip_data - new->pkt_eth_data); + new->pkt_tcp->th_sum = rand_uint16(data->rnd); + break; + case CHAFF_TYPE_NULL: + new->pkt_tcp->th_flags = 0; + inet_checksum(eth_type, new->pkt_ip, + new->pkt_ip_data - new->pkt_eth_data); + break; + case CHAFF_TYPE_PAWS: + /* Delete any existing TCP options. */ + i = (new->pkt_tcp->th_off << 2) - TCP_HDR_LEN; + new->pkt_tcp->th_off = 5; + new->pkt_end -= i; + new->pkt_ip->ip_len = htons(new->pkt_end - + new->pkt_eth_data); + + /* Insert initial timestamp, for PAWS elimination. */ + opt.opt_type = TCP_OPT_TIMESTAMP; + opt.opt_len = TCP_OPT_LEN + 8; + opt.opt_data.timestamp[0] = 0; + opt.opt_data.timestamp[1] = 0; + if ((i = inet_add_option(eth_type, new->pkt_ip, + PKT_BUF_LEN - ETH_HDR_LEN, + IP_PROTO_TCP, &opt, opt.opt_len)) < 0) { + pkt_free(new); + continue; + } + new->pkt_end += i; + inet_checksum(eth_type, new->pkt_ip, + new->pkt_ip_data - new->pkt_eth_data); + pkt_decorate(new); + break; + case CHAFF_TYPE_REXMIT: + new->pkt_ts.tv_usec = 1; + inet_checksum(eth_type, new->pkt_ip, + new->pkt_ip_data - new->pkt_eth_data); + break; + case CHAFF_TYPE_SEQ: + /* XXX - dunno recv window? */ + new->pkt_tcp->th_seq = htonl(666); + new->pkt_tcp->th_ack = htonl(666); + inet_checksum(eth_type, new->pkt_ip, + new->pkt_ip_data - new->pkt_eth_data); + break; + case CHAFF_TYPE_SYN: + new->pkt_tcp->th_flags = TH_SYN; + new->pkt_tcp->th_seq = rand_uint32(data->rnd); + new->pkt_tcp->th_ack = 0; + new->pkt_end = new->pkt_tcp_data; + new->pkt_tcp_data = NULL; + new->pkt_ip->ip_len = htons(new->pkt_end - + new->pkt_eth_data); + inet_checksum(eth_type, new->pkt_ip, + new->pkt_ip_data - new->pkt_eth_data); + break; + case CHAFF_TYPE_TTL: + if (eth_type == ETH_TYPE_IP) { + new->pkt_ip->ip_ttl = data->ttl; + ip_checksum(new->pkt_ip, + new->pkt_ip_data - new->pkt_eth_data); + } else if (eth_type == ETH_TYPE_IPV6) { + new->pkt_ip6->ip6_hlim = data->ttl; + } + break; + } + /* Minimal random reordering. */ + if ((new->pkt_tcp->th_sum & 1) == 0) + TAILQ_INSERT_BEFORE(pkt, new, pkt_next); + else + TAILQ_INSERT_AFTER(pktq, pkt, new, pkt_next); + } + return (0); +} + +struct mod mod_tcp_chaff = { + "tcp_chaff", /* name */ + "tcp_chaff cksum|null|paws|rexmit|seq|syn|", /* usage */ + tcp_chaff_open, /* open */ + tcp_chaff_apply, /* apply */ + tcp_chaff_close /* close */ +}; diff --git a/src/fragroute/mod_tcp_opt.c b/src/fragroute/mod_tcp_opt.c new file mode 100644 index 0000000..13ae801 --- /dev/null +++ b/src/fragroute/mod_tcp_opt.c @@ -0,0 +1,98 @@ +/* + * mod_tcp_opt.c + * + * Copyright (c) 2001 Dug Song + * + * $Id: mod_tcp_opt.c 2303 2009-05-06 18:48:20Z aturner $ + */ + +#include "config.h" +#include "defines.h" +#include "common.h" + +#include +#include +#include + +#include "pkt.h" +#include "mod.h" +#include "iputil.h" + +void * +tcp_opt_close(void *d) +{ + if (d != NULL) + free(d); + return (NULL); +} + +void * +tcp_opt_open(int argc, char *argv[]) +{ + struct tcp_opt *opt; + int i; + + if (argc < 3) + return (NULL); + + if ((opt = calloc(1, sizeof(*opt))) == NULL) + return (NULL); + + if (strcasecmp(argv[1], "mss") == 0) { + opt->opt_type = TCP_OPT_MSS; + opt->opt_len = TCP_OPT_LEN + 2; + + if ((i = atoi(argv[2])) <= 0 || i > 0xffff) { + warn("mss must be from 0-65535"); + return (tcp_opt_close(opt)); + } + opt->opt_data.mss = htons(i); + } else if (strcasecmp(argv[1], "wscale") == 0) { + opt->opt_type = TCP_OPT_WSCALE; + opt->opt_len = TCP_OPT_LEN + 2; + + if ((i = atoi(argv[2])) <= 0 || i > 0xff) { + warn("wscale must be from 0-255"); + return (tcp_opt_close(opt)); + } + opt->opt_data.wscale = i; + } else if (strcasecmp(argv[1], "raw") == 0) { + if (raw_ip_opt_parse(argc - 2, &argv[2], &opt->opt_type, &opt->opt_len, + &opt->opt_data.data8[0], sizeof(opt->opt_data.data8)) != 0) + return (tcp_opt_close(opt)); + } else + return (tcp_opt_close(opt)); + + return (opt); +} + +int +tcp_opt_apply(void *d, struct pktq *pktq) +{ + struct tcp_opt *opt = (struct tcp_opt *)d; + struct pkt *pkt; + size_t len; + + TAILQ_FOREACH(pkt, pktq, pkt_next) { + uint16_t eth_type = htons(pkt->pkt_eth->eth_type); + + len = inet_add_option(eth_type, pkt->pkt_ip, + sizeof(pkt->pkt_data) - ETH_HDR_LEN, + IP_PROTO_TCP, opt, opt->opt_len); + + if (len > 0) { + pkt->pkt_end += len; + pkt_decorate(pkt); + inet_checksum(eth_type, pkt->pkt_ip, pkt->pkt_end - pkt->pkt_eth_data); + } + } + return (0); +} + +struct mod mod_tcp_opt = { + "tcp_opt", /* name */ + "tcp_opt mss|wscale |raw ", /* usage */ + tcp_opt_open, /* open */ + tcp_opt_apply, /* apply */ + tcp_opt_close /* close */ +}; diff --git a/src/fragroute/mod_tcp_seg.c b/src/fragroute/mod_tcp_seg.c new file mode 100644 index 0000000..a70b269 --- /dev/null +++ b/src/fragroute/mod_tcp_seg.c @@ -0,0 +1,182 @@ +/* + * mod_tcp_seg.c + * + * Copyright (c) 2001 Dug Song + * + * $Id: mod_tcp_seg.c 2303 2009-05-06 18:48:20Z aturner $ + */ + +#include "config.h" +#include "defines.h" +#include "common.h" + +#include +#include +#include + +#include "mod.h" +#include "pkt.h" +#include "randutil.h" +#include "iputil.h" + +#ifndef MIN +#define MIN(a,b) (((a)<(b))?(a):(b)) +#endif + +#define FAVOR_OLD 1 +#define FAVOR_NEW 2 + +static struct tcp_seg_data { + rand_t *rnd; + int size; + int overlap; +} tcp_seg_data; + +void * +tcp_seg_close(void *d) +{ + if (tcp_seg_data.rnd != NULL) + rand_close(tcp_seg_data.rnd); + tcp_seg_data.size = 0; + return (NULL); +} + +void * +tcp_seg_open(int argc, char *argv[]) +{ + if (argc < 2) { + warn("need segment in bytes"); + return (NULL); + } + tcp_seg_data.rnd = rand_open(); + + if ((tcp_seg_data.size = atoi(argv[1])) == 0) { + warnx("invalid segment size '%s'", argv[1]); + return (tcp_seg_close(&tcp_seg_data)); + } + if (argc == 3) { + if (strcmp(argv[2], "old") == 0 || + strcmp(argv[2], "win32") == 0) + tcp_seg_data.overlap = FAVOR_OLD; + else if (strcmp(argv[2], "new") == 0 || + strcmp(argv[2], "unix") == 0) + tcp_seg_data.overlap = FAVOR_NEW; + else + return (tcp_seg_close(&tcp_seg_data)); + } + return (&tcp_seg_data); +} + +int +tcp_seg_apply(void *d, struct pktq *pktq) +{ + struct pkt *pkt, *new, *next, tmp; + uint32_t seq; + int hl, tl, len; + u_char *p, *p1, *p2; + uint16_t eth_type; + uint8_t nxt; + + for (pkt = TAILQ_FIRST(pktq); pkt != TAILQ_END(pktq); pkt = next) { + next = TAILQ_NEXT(pkt, pkt_next); + + eth_type = htons(pkt->pkt_eth->eth_type); + + if (pkt->pkt_ip == NULL) + continue; + + if (eth_type == ETH_TYPE_IP) { + nxt = pkt->pkt_ip->ip_p; + } else if (eth_type == ETH_TYPE_IPV6) { + nxt = pkt->pkt_ip6->ip6_nxt; + } else { + continue; + } + + if (nxt != IP_PROTO_TCP || + pkt->pkt_tcp == NULL || pkt->pkt_tcp_data == NULL || + (pkt->pkt_tcp->th_flags & TH_ACK) == 0 || + pkt->pkt_end - pkt->pkt_tcp_data <= tcp_seg_data.size) + continue; + + if (eth_type == ETH_TYPE_IP) { + hl = pkt->pkt_ip->ip_hl << 2; + } else if (eth_type == ETH_TYPE_IPV6) { + hl = IP6_HDR_LEN; + } else { + continue; + } + + tl = pkt->pkt_tcp->th_off << 2; + seq = ntohl(pkt->pkt_tcp->th_seq); + + for (p = pkt->pkt_tcp_data; p < pkt->pkt_end; p += len) { + new = pkt_new(); + memcpy(new->pkt_eth, pkt->pkt_eth, (u_char*)pkt->pkt_eth_data - (u_char*)pkt->pkt_eth); + p1 = p, p2 = NULL; + len = MIN(pkt->pkt_end - p, tcp_seg_data.size); + + if (tcp_seg_data.overlap != 0 && + p + (len << 1) < pkt->pkt_end) { + rand_strset(tcp_seg_data.rnd, tmp.pkt_buf,len); + + if (tcp_seg_data.overlap == FAVOR_OLD) { + p1 = p + len; + p2 = tmp.pkt_buf; + } else if (tcp_seg_data.overlap == FAVOR_NEW) { + p1 = tmp.pkt_buf; + p2 = p + len; + } + len = tcp_seg_data.size; + seq += tcp_seg_data.size; + } + memcpy(new->pkt_ip, pkt->pkt_ip, hl + tl); + new->pkt_ip_data = new->pkt_eth_data + hl; + new->pkt_tcp_data = new->pkt_ip_data + tl; + memcpy(new->pkt_tcp_data, p1, len); + new->pkt_end = new->pkt_tcp_data + len; + + if (eth_type == ETH_TYPE_IP) { + new->pkt_ip->ip_id = rand_uint16(tcp_seg_data.rnd); + new->pkt_ip->ip_len = htons(hl + tl + len); + } else { + new->pkt_ip6->ip6_plen = htons(tl + len); + } + + new->pkt_tcp->th_seq = htonl(seq); + inet_checksum(eth_type, new->pkt_ip, hl + tl + len); + TAILQ_INSERT_BEFORE(pkt, new, pkt_next); + + if (p2 != NULL) { + new = pkt_dup(new); + new->pkt_ts.tv_usec = 1; + if (eth_type == ETH_TYPE_IP) { + new->pkt_ip->ip_id = rand_uint16(tcp_seg_data.rnd); + new->pkt_ip->ip_len = htons(hl + tl + (len << 1)); + } else if (eth_type == ETH_TYPE_IPV6) { + new->pkt_ip6->ip6_plen = htons(tl + (len << 1)); + } + new->pkt_tcp->th_seq = htonl(seq - len); + + memcpy(new->pkt_tcp_data, p, len); + memcpy(new->pkt_tcp_data + len, p2, len); + new->pkt_end = new->pkt_tcp_data + (len << 1); + inet_checksum(eth_type, new->pkt_ip, hl + tl + (len << 1)); + TAILQ_INSERT_BEFORE(pkt, new, pkt_next); + p += len; + } + seq += len; + } + TAILQ_REMOVE(pktq, pkt, pkt_next); + pkt_free(pkt); + } + return (0); +} + +struct mod mod_tcp_seg = { + "tcp_seg", /* name */ + "tcp_seg [old|new]", /* usage */ + tcp_seg_open, /* open */ + tcp_seg_apply, /* apply */ + tcp_seg_close /* close */ +}; diff --git a/src/fragroute/pkt.c b/src/fragroute/pkt.c new file mode 100644 index 0000000..e69adc2 --- /dev/null +++ b/src/fragroute/pkt.c @@ -0,0 +1,312 @@ +/* + * pkt.c + * + * Copyright (c) 2001 Dug Song + * + * $Id: pkt.c 2303 2009-05-06 18:48:20Z aturner $ + */ + +#include "config.h" + +#include + +#include +#include +#include + +#include "bget.h" +#include "pkt.h" + +void +pkt_init(int size) +{ + bectl(NULL, malloc, free, sizeof(struct pkt) * size); +} + +struct pkt * +pkt_new(void) +{ + struct pkt *pkt; + + if ((pkt = bget(sizeof(*pkt))) == NULL) + return (NULL); + + timerclear(&pkt->pkt_ts); + // memset(&pkt->pkt_ev, 0, sizeof(pkt->pkt_ev)); + + pkt->pkt_data = pkt->pkt_buf + PKT_BUF_ALIGN; + pkt->pkt_eth = (struct eth_hdr *)pkt->pkt_data; + pkt->pkt_eth_data = pkt->pkt_data + ETH_HDR_LEN; + pkt->pkt_ip_data = pkt->pkt_data + ETH_HDR_LEN + IP_HDR_LEN; + pkt->pkt_tcp_data = NULL; + pkt->pkt_end = pkt->pkt_ip_data; + + return (pkt); +} + +struct pkt * +pkt_dup(struct pkt *pkt) +{ + struct pkt *new; + off_t off; + + if ((new = bget(sizeof(*new))) == NULL) + return (NULL); + + off = new->pkt_buf - pkt->pkt_buf; + + new->pkt_ts = pkt->pkt_ts; + // memset(&new->pkt_ev, 0, sizeof(new->pkt_ev)); + + new->pkt_data = pkt->pkt_data + off; + + new->pkt_eth = (pkt->pkt_eth != NULL) ? + (struct eth_hdr *)new->pkt_data : NULL; + + new->pkt_eth_data = (pkt->pkt_eth_data != NULL) ? + pkt->pkt_eth_data + off : NULL; + + new->pkt_ip_data = (pkt->pkt_ip_data != NULL) ? + pkt->pkt_ip_data + off : NULL; + + new->pkt_tcp_data = (pkt->pkt_tcp_data != NULL) ? + pkt->pkt_tcp_data + off : NULL; + + memcpy(new->pkt_data, pkt->pkt_data, pkt->pkt_end - pkt->pkt_data); + + new->pkt_end = pkt->pkt_end + off; + + return (new); +} + +#define IP6_IS_EXT(n) \ + ((n) == IP_PROTO_HOPOPTS || (n) == IP_PROTO_DSTOPTS || \ + (n) == IP_PROTO_ROUTING || (n) == IP_PROTO_FRAGMENT) + +void +pkt_decorate(struct pkt *pkt) +{ + u_char *p; + uint16_t eth_type; + int hl, len, off; + uint8_t next_hdr; + struct ip6_ext_hdr *ext; + + pkt->pkt_data = pkt->pkt_buf + PKT_BUF_ALIGN; + pkt->pkt_eth = NULL; + pkt->pkt_ip = NULL; + pkt->pkt_ip_data = NULL; + pkt->pkt_tcp_data = NULL; + + p = pkt->pkt_data; + + if (p + ETH_HDR_LEN > pkt->pkt_end) + return; + + pkt->pkt_eth = (struct eth_hdr *)p; + p += ETH_HDR_LEN; + + eth_type = htons(pkt->pkt_eth->eth_type); + + if (eth_type == ETH_TYPE_IP) { + if (p + IP_HDR_LEN > pkt->pkt_end) + return; + + pkt->pkt_eth_data = p; + + /* If IP header length is longer than packet length, stop. */ + hl = pkt->pkt_ip->ip_hl << 2; + if (p + hl > pkt->pkt_end) { + pkt->pkt_ip = NULL; + return; + } + /* If IP length is longer than packet length, stop. */ + len = ntohs(pkt->pkt_ip->ip_len); + if (p + len > pkt->pkt_end) + return; + + /* If IP fragment, stop. */ + off = ntohs(pkt->pkt_ip->ip_off); + if ((off & IP_OFFMASK) != 0 || (off & IP_MF) != 0) + return; + + pkt->pkt_end = p + len; + p += hl; + next_hdr = pkt->pkt_ip->ip_p; + } else if (eth_type == ETH_TYPE_IPV6) { + if (p + IP6_HDR_LEN > pkt->pkt_end) + return; + + pkt->pkt_eth_data = p; + p += IP6_HDR_LEN; + next_hdr = pkt->pkt_ip6->ip6_nxt; + + for (; IP6_IS_EXT(next_hdr); p += (ext->ext_len + 1) << 3) { + if (p > pkt->pkt_end) + return; + ext = (struct ip6_ext_hdr *)p; + next_hdr = ext->ext_nxt; + } + } else { + return; + } + + /* If transport layer header is longer than packet length, stop. */ + switch (next_hdr) { + case IP_PROTO_ICMP: + case IP_PROTO_ICMPV6: + hl = ICMP_HDR_LEN; + break; + case IP_PROTO_TCP: + if (p + TCP_HDR_LEN > pkt->pkt_end) + return; + hl = ((struct tcp_hdr *)p)->th_off << 2; + break; + case IP_PROTO_UDP: + hl = UDP_HDR_LEN; + break; + default: + return; + } + if (p + hl > pkt->pkt_end) + return; + + pkt->pkt_ip_data = p; + p += hl; + + /* Check for transport layer data. */ + switch (next_hdr) { + case IP_PROTO_ICMP: + pkt->pkt_icmp_msg = (union icmp_msg *)p; + + switch (pkt->pkt_icmp->icmp_type) { + case ICMP_ECHO: + case ICMP_ECHOREPLY: + hl = sizeof(pkt->pkt_icmp_msg->echo); + break; + case ICMP_UNREACH: + if (pkt->pkt_icmp->icmp_code == ICMP_UNREACH_NEEDFRAG) + hl = sizeof(pkt->pkt_icmp_msg->needfrag); + else + hl = sizeof(pkt->pkt_icmp_msg->unreach); + break; + case ICMP_SRCQUENCH: + case ICMP_REDIRECT: + case ICMP_TIMEXCEED: + case ICMP_PARAMPROB: + hl = sizeof(pkt->pkt_icmp_msg->srcquench); + break; + case ICMP_RTRADVERT: + hl = sizeof(pkt->pkt_icmp_msg->rtradvert); + break; + case ICMP_RTRSOLICIT: + hl = sizeof(pkt->pkt_icmp_msg->rtrsolicit); + break; + case ICMP_TSTAMP: + case ICMP_TSTAMPREPLY: + hl = sizeof(pkt->pkt_icmp_msg->tstamp); + break; + case ICMP_INFO: + case ICMP_INFOREPLY: + case ICMP_DNS: + hl = sizeof(pkt->pkt_icmp_msg->info); + break; + case ICMP_MASK: + case ICMP_MASKREPLY: + hl = sizeof(pkt->pkt_icmp_msg->mask); + break; + case ICMP_DNSREPLY: + hl = sizeof(pkt->pkt_icmp_msg->dnsreply); + break; + default: + hl = pkt->pkt_end - p + 1; + break; + } + if (p + hl > pkt->pkt_end) + pkt->pkt_icmp_msg = NULL; + break; + case IP_PROTO_ICMPV6: + pkt->pkt_icmp_msg = (union icmp_msg *)p; + break; + case IP_PROTO_TCP: + if (p < pkt->pkt_end) + pkt->pkt_tcp_data = p; + break; + case IP_PROTO_UDP: + if (pkt->pkt_ip_data + ntohs(pkt->pkt_udp->uh_ulen) <= + pkt->pkt_end) + pkt->pkt_udp_data = p; + break; + } +} + +void +pkt_free(struct pkt *pkt) +{ + brel(pkt); +} + +void +pktq_reverse(struct pktq *pktq) +{ + struct pktq tmpq; + struct pkt *pkt, *next; + + TAILQ_INIT(&tmpq); + for (pkt = TAILQ_FIRST(pktq); pkt != TAILQ_END(pktq); pkt = next) { + next = TAILQ_NEXT(pkt, pkt_next); + TAILQ_INSERT_HEAD(&tmpq, pkt, pkt_next); + } + *pktq = tmpq; +} + +void +pktq_shuffle(rand_t *r, struct pktq *pktq) +{ + static struct pkt **pvbase; + static int pvlen; + struct pkt *pkt; + int i; + + i = 0; + TAILQ_FOREACH(pkt, pktq, pkt_next) { + i++; + } + if (i > pvlen) { + pvlen = i; + if (pvbase == NULL) + pvbase = malloc(sizeof(pkt) * pvlen); + else + pvbase = realloc(pvbase, sizeof(pkt) * pvlen); + } + i = 0; + TAILQ_FOREACH(pkt, pktq, pkt_next) { + pvbase[i++] = pkt; + } + TAILQ_INIT(pktq); + + rand_shuffle(r, pvbase, i, sizeof(pkt)); + + while (--i >= 0) { + TAILQ_INSERT_TAIL(pktq, pvbase[i], pkt_next); + } +} + +struct pkt * +pktq_random(rand_t *r, struct pktq *pktq) +{ + struct pkt *pkt; + int i; + + i = 0; + TAILQ_FOREACH(pkt, pktq, pkt_next) { + i++; + } + i = rand_uint32(r) % (i - 1); + pkt = TAILQ_FIRST(pktq); + + while (--i >= 0) { + pkt = TAILQ_NEXT(pkt, pkt_next); + } + return (pkt); +} diff --git a/src/fragroute/pkt.h b/src/fragroute/pkt.h new file mode 100644 index 0000000..526265c --- /dev/null +++ b/src/fragroute/pkt.h @@ -0,0 +1,82 @@ +/* + * pkt.h + * + * Copyright (c) 2001 Dug Song + * + * $Id: pkt.h 2303 2009-05-06 18:48:20Z aturner $ + */ + +#ifndef PKT_H +#define PKT_H + +#include "config.h" +#include "defines.h" +#include "../../lib/queue.h" +#include + +#ifdef HAVE_LIBDNET +/* need to undef these which are pulled in via defines.h, prior to importing dnet.h */ +#undef icmp_id +#undef icmp_seq +#undef icmp_data +#undef icmp_mask +#include +#endif + +#define PKT_BUF_LEN (ETH_HDR_LEN + ETH_MTU) +#define PKT_BUF_ALIGN 2 + +struct pkt { + struct timeval pkt_ts; + // struct event pkt_ev; + + struct eth_hdr *pkt_eth; + union { + u_char *eth_data; + struct ip_hdr *ip; + struct ip6_hdr *ip6; + } pkt_n_hdr_u; + union { + u_char *ip_data; + struct icmp_hdr *icmp; + struct tcp_hdr *tcp; + struct udp_hdr *udp; + } pkt_t_hdr_u; + union { + u_char *t_data; + union icmp_msg *icmp; + } pkt_t_data_u; + + u_char pkt_buf[PKT_BUF_ALIGN + PKT_BUF_LEN]; + u_char *pkt_data; + u_char *pkt_end; + + TAILQ_ENTRY(pkt) pkt_next; +}; +#define pkt_ip pkt_n_hdr_u.ip +#define pkt_ip6 pkt_n_hdr_u.ip6 +#define pkt_eth_data pkt_n_hdr_u.eth_data + +#define pkt_icmp pkt_t_hdr_u.icmp +#define pkt_tcp pkt_t_hdr_u.tcp +#define pkt_udp pkt_t_hdr_u.udp +#define pkt_ip_data pkt_t_hdr_u.ip_data + +#define pkt_tcp_data pkt_t_data_u.t_data +#define pkt_udp_data pkt_t_data_u.t_data +#define pkt_icmp_msg pkt_t_data_u.icmp + +TAILQ_HEAD(pktq, pkt); + +void pkt_init(int size); + +struct pkt *pkt_new(void); +struct pkt *pkt_dup(struct pkt *); +void pkt_decorate(struct pkt *pkt); +void pkt_free(struct pkt *pkt); + +void pktq_reverse(struct pktq *pktq); +void pktq_shuffle(rand_t *r, struct pktq *pktq); +struct pkt *pktq_random(rand_t *r, struct pktq *pktq); + +#endif /* PKT_H */ diff --git a/src/fragroute/randutil.c b/src/fragroute/randutil.c new file mode 100644 index 0000000..5bbda84 --- /dev/null +++ b/src/fragroute/randutil.c @@ -0,0 +1,55 @@ +/* + * randutil.c + * + * Copyright (c) 2001 Dug Song + * + * $Id: randutil.c 2191 2009-02-01 21:34:27Z aturner $ + */ + +#include "config.h" + +#ifdef HAVE_LIBDNET +/* need to undef these which are pulled in via defines.h, prior to importing dnet.h */ +#undef icmp_id +#undef icmp_seq +#undef icmp_data +#undef icmp_mask +#include +#endif + +#include +#include +#include +#include + +#include "randutil.h" + +static const char base64[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + +void +rand_strset(rand_t *r, void *buf, size_t len) +{ + uint32_t u; + char *p; + int i; + + p = (char *)buf; + i = (len + 3) / 4; + u = rand_uint32(r); + + /* XXX - more Duff's device tomfoolery. */ + switch (len % 4) { + case 0: do { + u = rand_uint32(r); + *p++ = base64[(u >> 18) & 0x3f]; + case 3: + *p++ = base64[(u >> 12) & 0x3f]; + case 2: + *p++ = base64[(u >> 6) & 0x3f]; + case 1: + *p++ = base64[(u >> 0) & 0x3f]; + } while (--i > 0); + } + p[-1] = '\0'; +} diff --git a/src/fragroute/randutil.h b/src/fragroute/randutil.h new file mode 100644 index 0000000..4f547fd --- /dev/null +++ b/src/fragroute/randutil.h @@ -0,0 +1,14 @@ +/* + * randutil.h + * + * Copyright (c) 2001 Dug Song + * + * $Id: randutil.h 2000 2008-04-27 06:17:35Z aturner $ + */ + +#ifndef RANDUTIL_H +#define RANDUTIL_H + +void rand_strset(rand_t *r, void *buf, size_t len); + +#endif /* RANDUTIL_H */ diff --git a/src/send_packets.c b/src/send_packets.c new file mode 100644 index 0000000..a0ab6f2 --- /dev/null +++ b/src/send_packets.c @@ -0,0 +1,715 @@ +/* $Id: send_packets.c 2444 2010-03-30 04:47:09Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "defines.h" +#include "common.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "tcpreplay.h" + +#ifdef TCPREPLAY + +#ifdef TCPREPLAY_EDIT +#include "tcpreplay_edit_opts.h" +#include "tcpedit/tcpedit.h" +extern tcpedit_t *tcpedit; +#else +#include "tcpreplay_opts.h" +#endif + +#endif /* TCPREPLAY */ + +#include "send_packets.h" +#include "sleep.h" + +extern tcpreplay_opt_t options; +extern struct timeval begin, end; +extern COUNTER bytes_sent, failed, pkts_sent; +extern volatile int didsig; + +#ifdef DEBUG +extern int debug; +#endif + +int send_pkt_driver_mode = 1; /* ͬƽ̨ģʽֵ, 1=pcap, 12=marsio */ +extern int stream_burst_send_pkt(void *handle, const u_char *pkt, size_t pktlen); +extern int stream_burst(sendpacket_t *sp, const u_char *pkt, size_t pktlen, int, int); + +static void do_sleep(struct timeval *time, struct timeval *last, int len, + int accurate, sendpacket_t *sp, COUNTER counter, delta_t *ctx); +static u_int32_t get_user_count(sendpacket_t *sp, COUNTER counter); + +/** + * the main loop function for tcpreplay. This is where we figure out + * what to do with each packet + */ +void +send_packets(pcap_t *pcap, int cache_file_idx) +{ + struct timeval last = { 0, 0 }, last_print_time = { 0, 0 }, print_delta, now; + COUNTER packetnum = 0; + struct pcap_pkthdr pkthdr; + const u_char *pktdata = NULL; + sendpacket_t *sp = options.intf1; + u_int32_t pktlen; + packet_cache_t *cached_packet = NULL; + packet_cache_t **prev_packet = NULL; +#if defined TCPREPLAY && defined TCPREPLAY_EDIT + struct pcap_pkthdr *pkthdr_ptr; +#endif + delta_t delta_ctx; + + init_delta_time(&delta_ctx); + + /* register signals */ + didsig = 0; + if (options.speed.mode != SPEED_ONEATATIME) { + (void)signal(SIGINT, catcher); + } else { + (void)signal(SIGINT, break_now); + } + + if (options.enable_file_cache) { + prev_packet = &cached_packet; + } else { + prev_packet = NULL; + } + + + /* MAIN LOOP + * Keep sending while we have packets or until + * we've sent enough packets + */ + while ((pktdata = get_next_packet(pcap, &pkthdr, cache_file_idx, prev_packet)) != NULL) { + /* die? */ + if (didsig) + break_now(0); + + /* stop sending based on the limit -L? */ + if (options.limit_send > 0 && pkts_sent >= options.limit_send) + return; + + packetnum++; + +#ifdef TCPREPLAY + /* do we use the snaplen (caplen) or the "actual" packet len? */ + pktlen = HAVE_OPT(PKTLEN) ? pkthdr.len : pkthdr.caplen; +#elif TCPBRIDGE + pktlen = pkthdr.caplen; +#else +#error WTF??? We should not be here! +#endif + + dbgx(2, "packet " COUNTER_SPEC " caplen %d", packetnum, pktlen); + + /* Dual nic processing */ + if (options.intf2 != NULL) { + + sp = (sendpacket_t *) cache_mode(options.cachedata, packetnum); + + /* sometimes we should not send the packet */ + if (sp == TCPR_DIR_NOSEND) + continue; + } + + /* do we need to print the packet via tcpdump? */ +#ifdef ENABLE_VERBOSE + if (options.verbose) + tcpdump_print(options.tcpdump, &pkthdr, pktdata); +#endif + +#if defined TCPREPLAY && defined TCPREPLAY_EDIT + pkthdr_ptr = &pkthdr; + if (tcpedit_packet(tcpedit, &pkthdr_ptr, &pktdata, sp->cache_dir) == -1) { + errx(-1, "Error editing packet #" COUNTER_SPEC ": %s", packetnum, tcpedit_geterr(tcpedit)); + } + pktlen = HAVE_OPT(PKTLEN) ? pkthdr_ptr->len : pkthdr_ptr->caplen; +#endif + + /* + * we have to cast the ts, since OpenBSD sucks + * had to be special and use bpf_timeval. + * Only sleep if we're not in top speed mode (-t) + */ + if (options.speed.mode != SPEED_TOPSPEED) + do_sleep((struct timeval *)&pkthdr.ts, &last, pktlen, options.accurate, sp, packetnum, &delta_ctx); + + /* mark the time when we send the last packet */ + start_delta_time(&delta_ctx); + dbgx(2, "Sending packet #" COUNTER_SPEC, packetnum); + +#if 0 + /* write packet out on network */ + if (1== send_pkt_driver_mode ){ + if(options.encap_cfg_file != NULL){ + return sendpacket_with_encapsulation((sendpacket_t *)sp, pkt, pktlen); + } + if(sendpacket(sp, pktdata, pktlen) < (int)pktlen){ + warnx("Unable to send packet: %s", sendpacket_geterr(sp)); + } + } +#endif + +#ifdef TCPBURST +#ifdef TCPREPLAY + /* write packet out on network */ + if (stream_burst_send_pkt(sp, pktdata, pktlen) < (int)pktlen){ + //warnx("Unable to send packet: %s", sendpacket_geterr(sp)); + } + if(options.stream_multiple > 0) /* Ŵ */ + { + stream_burst(sp, pktdata, pktlen, 0, cache_file_idx); + } +#endif +#endif + + /* + * track the time of the "last packet sent". Again, because of OpenBSD + * we have to do a mempcy rather then assignment. + * + * A number of 3rd party tools generate bad timestamps which go backwards + * in time. Hence, don't update the "last" unless pkthdr.ts > last + */ + if (timercmp(&last, &pkthdr.ts, <)) + memcpy(&last, &pkthdr.ts, sizeof(struct timeval)); + pkts_sent ++; + bytes_sent += pktlen; + + /* print stats during the run? */ + if (options.stats > 0) { + if (gettimeofday(&now, NULL) < 0) + errx(-1, "gettimeofday() failed: %s", strerror(errno)); + + if (! timerisset(&last_print_time)) { + memcpy(&last_print_time, &now, sizeof(struct timeval)); + } else { + timersub(&now, &last_print_time, &print_delta); + if (print_delta.tv_sec >= options.stats) { + packet_stats(&begin, &now, bytes_sent, pkts_sent, failed); + memcpy(&last_print_time, &now, sizeof(struct timeval)); + } + } + } + } /* while */ +#ifdef TCPBURST +#ifdef TCPREPLAY + if(options.stream_multiple > 0) + { + stream_burst(sp, NULL, 0, 1, cache_file_idx); + } +#endif +#endif + + if (options.enable_file_cache) { + options.file_cache[cache_file_idx].cached = TRUE; + } +} + +/** + * Gets the next packet to be sent out. This will either read from the pcap file + * or will retrieve the packet from the internal cache. + * + * The parameter prev_packet is used as the parent of the new entry in the cache list. + * This should be NULL on the first call to this function for each file and + * will be updated as new entries are added (or retrieved) from the cache list. + */ +const u_char * +get_next_packet(pcap_t *pcap, struct pcap_pkthdr *pkthdr, int file_idx, + packet_cache_t **prev_packet) +{ + u_char *pktdata = NULL; + u_int32_t pktlen; + + /* pcap may be null in cache mode! */ + /* packet_cache_t may be null in file read mode! */ + assert(pkthdr); + + /* + * Check if we're caching files + */ + if ((options.enable_file_cache || options.preload_pcap) && (prev_packet != NULL)) { + /* + * Yes we are caching files - has this one been cached? + */ + if (options.file_cache[file_idx].cached) { + if (*prev_packet == NULL) { + /* + * Get the first packet in the cache list directly from the file + */ + *prev_packet = options.file_cache[file_idx].packet_cache; + } else { + /* + * Get the next packet in the cache list + */ + *prev_packet = (*prev_packet)->next; + } + + if (*prev_packet != NULL) { + pktdata = (*prev_packet)->pktdata; + memcpy(pkthdr, &((*prev_packet)->pkthdr), sizeof(struct pcap_pkthdr)); + } + } else { + /* + * We should read the pcap file, and cache the results + */ + pktdata = (u_char *)pcap_next(pcap, pkthdr); + if (pktdata != NULL) { + if (*prev_packet == NULL) { + /* + * Create the first packet in the list + */ + *prev_packet = safe_malloc(sizeof(packet_cache_t)); + options.file_cache[file_idx].packet_cache = *prev_packet; + } else { + /* + * Add a packet to the end of the list + */ + (*prev_packet)->next = safe_malloc(sizeof(packet_cache_t)); + *prev_packet = (*prev_packet)->next; + } + + if (*prev_packet != NULL) { + (*prev_packet)->next = NULL; + pktlen = pkthdr->len; + + (*prev_packet)->pktdata = safe_malloc(pktlen); + memcpy((*prev_packet)->pktdata, pktdata, pktlen); + memcpy(&((*prev_packet)->pkthdr), pkthdr, sizeof(struct pcap_pkthdr)); + } + } + } + } else { + /* + * Read pcap file as normal + */ + pktdata = (u_char *)pcap_next(pcap, pkthdr); + } + + /* this get's casted to a const on the way out */ + return pktdata; +} + +/** + * determines based upon the cachedata which interface the given packet + * should go out. Also rewrites any layer 2 data we might need to adjust. + * Returns a void cased pointer to the options.intfX of the corresponding + * interface. + */ +void * +cache_mode(char *cachedata, COUNTER packet_num) +{ + void *sp = NULL; + int result; + + if (packet_num > options.cache_packets) + err(-1, "Exceeded number of packets in cache file."); + + result = check_cache(cachedata, packet_num); + if (result == TCPR_DIR_NOSEND) { + dbgx(2, "Cache: Not sending packet " COUNTER_SPEC ".", packet_num); + return TCPR_DIR_NOSEND; + } + else if (result == TCPR_DIR_C2S) { + dbgx(2, "Cache: Sending packet " COUNTER_SPEC " out primary interface.", packet_num); + sp = options.intf1; + } + else if (result == TCPR_DIR_S2C) { + dbgx(2, "Cache: Sending packet " COUNTER_SPEC " out secondary interface.", packet_num); + sp = options.intf2; + } + else { + err(-1, "check_cache() returned an error. Aborting..."); + } + + return sp; +} + + +/** + * Given the timestamp on the current packet and the last packet sent, + * calculate the appropriate amount of time to sleep and do so. + */ +static void +do_sleep(struct timeval *time, struct timeval *last, int len, int accurate, + sendpacket_t *sp, COUNTER counter, delta_t *delta_ctx) +{ + static struct timeval didsleep = { 0, 0 }; + static struct timeval start = { 0, 0 }; +#ifdef DEBUG + static struct timeval totalsleep = { 0, 0 }; +#endif + struct timespec adjuster = { 0, 0 }; + static struct timespec nap = { 0, 0 }, delta_time = {0, 0}; + struct timeval nap_for, now, sleep_until; + struct timespec nap_this_time; + static int32_t nsec_adjuster = -1, nsec_times = -1; + float n; + static u_int32_t send = 0; /* accellerator. # of packets to send w/o sleeping */ + u_int32_t ppnsec; /* packets per usec */ + static int first_time = 1; /* need to track the first time through for the pps accelerator */ + + +#ifdef TCPREPLAY + adjuster.tv_nsec = options.sleep_accel * 1000; + dbgx(4, "Adjuster: " TIMESPEC_FORMAT, adjuster.tv_sec, adjuster.tv_nsec); +#else + adjuster.tv_nsec = 0; +#endif + + /* acclerator time? */ + if (send > 0) { + send --; + return; + } + + /* + * pps_multi accelerator. This uses the existing send accelerator above + * and hence requires the funky math to get the expected timings. + */ + if (options.speed.mode == SPEED_PACKETRATE && options.speed.pps_multi) { + send = options.speed.pps_multi - 1; + if (first_time) { + first_time = 0; + return; + } + } + + dbgx(4, "This packet time: " TIMEVAL_FORMAT, time->tv_sec, time->tv_usec); + dbgx(4, "Last packet time: " TIMEVAL_FORMAT, last->tv_sec, last->tv_usec); + + if (gettimeofday(&now, NULL) < 0) + errx(-1, "Error gettimeofday: %s", strerror(errno)); + + dbgx(4, "Now time: " TIMEVAL_FORMAT, now.tv_sec, now.tv_usec); + + /* First time through for this file */ + if (pkts_sent == 0 || ((options.speed.mode != SPEED_MBPSRATE) && (counter == 0))) { + start = now; + timerclear(&sleep_until); + timerclear(&didsleep); + } + else { + timersub(&now, &start, &sleep_until); + } + + /* If top speed, you shouldn't even be here */ + assert(options.speed.mode != SPEED_TOPSPEED); + + /* + * 1. First, figure out how long we should sleep for... + */ + switch(options.speed.mode) { + case SPEED_MULTIPLIER: + /* + * Replay packets a factor of the time they were originally sent. + */ + if (timerisset(last)) { + if (timercmp(time, last, <)) { + /* Packet has gone back in time! Don't sleep and warn user */ + warnx("Packet #" COUNTER_SPEC " has gone back in time!", counter); + timesclear(&nap); + } else { + /* time has increased or is the same, so handle normally */ + timersub(time, last, &nap_for); + dbgx(3, "original packet delta time: " TIMEVAL_FORMAT, nap_for.tv_sec, nap_for.tv_usec); + + TIMEVAL_TO_TIMESPEC(&nap_for, &nap); + dbgx(3, "original packet delta timv: " TIMESPEC_FORMAT, nap.tv_sec, nap.tv_nsec); + timesdiv(&nap, options.speed.speed); + dbgx(3, "original packet delta/div: " TIMESPEC_FORMAT, nap.tv_sec, nap.tv_nsec); + } + } else { + /* Don't sleep if this is our first packet */ + timesclear(&nap); + } + break; + + case SPEED_MBPSRATE: + /* + * Ignore the time supplied by the capture file and send data at + * a constant 'rate' (bytes per second). + */ + if (pkts_sent != 0) { + n = (float)len / (options.speed.speed * 1024 * 1024 / 8); /* convert Mbps to bps */ + nap.tv_sec = n; + nap.tv_nsec = (n - nap.tv_sec) * 1000000000; + + dbgx(3, "packet size %d\t\tequals %f bps\t\tnap " TIMESPEC_FORMAT, len, n, + nap.tv_sec, nap.tv_nsec); + } + else { + /* don't sleep at all for the first packet */ + timesclear(&nap); + } + break; + + case SPEED_PACKETRATE: + /* + * Only need to calculate this the first time since this is a + * constant time function + */ + if (! timesisset(&nap)) { + /* run in packets/sec */ + ppnsec = 1000000000 / options.speed.speed * (options.speed.pps_multi > 0 ? options.speed.pps_multi : 1); + NANOSEC_TO_TIMESPEC(ppnsec, &nap); + dbgx(1, "sending %d packet(s) per %lu nsec", (options.speed.pps_multi > 0 ? options.speed.pps_multi : 1), nap.tv_nsec); + } + break; + + case SPEED_ONEATATIME: + /* + * Prompt the user for sending each packet(s) + */ + + /* do we skip prompting for a key press? */ + if (send == 0) { + send = get_user_count(sp, counter); + } + + /* decrement our send counter */ + printf("Sending packet " COUNTER_SPEC " out: %s\n", counter, + sp == options.intf1 ? options.intf1_name : options.intf2_name); + send --; + + return; /* leave do_sleep() */ + + break; + + default: + errx(-1, "Unknown/supported speed mode: %d", options.speed.mode); + break; + } + + /* + * since we apply the adjuster to the sleep time, we can't modify nap + */ + memcpy(&nap_this_time, &nap, sizeof(nap_this_time)); + + dbgx(2, "nap_time before rounding: " TIMESPEC_FORMAT, nap_this_time.tv_sec, nap_this_time.tv_nsec); + + + if (accurate != ACCURATE_ABS_TIME) { + + switch (options.speed.mode) { + /* + * We used to round to the nearest uset for Mbps & Multipler + * because they are "dynamic timings", but that seems stupid + * so I'm turning that off and we do nothing now + */ + case SPEED_MBPSRATE: + case SPEED_MULTIPLIER: + break; + + /* Packets/sec is static, so we weight packets for .1usec accuracy */ + case SPEED_PACKETRATE: + if (nsec_adjuster < 0) + nsec_adjuster = (nap_this_time.tv_nsec % 10000) / 1000; + + /* update in the range of 0-9 */ + nsec_times = (nsec_times + 1) % 10; + + if (nsec_times < nsec_adjuster) { + /* sorta looks like a no-op, but gives us a nice round usec number */ + nap_this_time.tv_nsec = (nap_this_time.tv_nsec / 1000 * 1000) + 1000; + } else { + nap_this_time.tv_nsec -= (nap_this_time.tv_nsec % 1000); + } + + dbgx(3, "(%d)\tnsec_times = %d\tnap adjust: %lu -> %lu", nsec_adjuster, nsec_times, nap.tv_nsec, nap_this_time.tv_nsec); + break; + + default: + errx(-1, "Unknown/supported speed mode: %d", options.speed.mode); + } + } + + dbgx(2, "nap_time before delta calc: " TIMESPEC_FORMAT, nap_this_time.tv_sec, nap_this_time.tv_nsec); + get_delta_time(delta_ctx, &delta_time); + dbgx(2, "delta: " TIMESPEC_FORMAT, delta_time.tv_sec, delta_time.tv_nsec); + + if (timesisset(&delta_time)) { + if (timescmp(&nap_this_time, &delta_time, >)) { + timessub(&nap_this_time, &delta_time, &nap_this_time); + dbgx(3, "timesub: %lu %lu", delta_time.tv_sec, delta_time.tv_nsec); + } else { + timesclear(&nap_this_time); + dbgx(3, "timesclear: " TIMESPEC_FORMAT, delta_time.tv_sec, delta_time.tv_nsec); + } + } + + /* apply the adjuster... */ + if (timesisset(&adjuster)) { + if (timescmp(&nap_this_time, &adjuster, >)) { + timessub(&nap_this_time, &adjuster, &nap_this_time); + } else { + timesclear(&nap_this_time); + } + } + + dbgx(2, "Sleeping: " TIMESPEC_FORMAT, nap_this_time.tv_sec, nap_this_time.tv_nsec); + + /* don't sleep if nap = {0, 0} */ + if (!timesisset(&nap_this_time)) + return; + + /* + * Depending on the accurate method & packet rate computation method + * We have multiple methods of sleeping, pick the right one... + */ + switch (accurate) { +#ifdef HAVE_SELECT + case ACCURATE_SELECT: + select_sleep(nap_this_time); + break; +#endif + +#ifdef HAVE_IOPERM + case ACCURATE_IOPORT: + ioport_sleep(nap_this_time); + break; +#endif + +#ifdef HAVE_RDTSC + case ACCURATE_RDTSC: + rdtsc_sleep(nap_this_time); + break; +#endif + +#ifdef HAVE_ABSOLUTE_TIME + case ACCURATE_ABS_TIME: + absolute_time_sleep(nap_this_time); + break; +#endif + + case ACCURATE_GTOD: + gettimeofday_sleep(nap_this_time); + break; + + case ACCURATE_NANOSLEEP: + nanosleep_sleep(nap_this_time); + break; + /* + timeradd(&didsleep, &nap_this_time, &didsleep); + + dbgx(4, "I will sleep " TIMEVAL_FORMAT, nap_this_time.tv_sec, nap_this_time.tv_usec); + + if (timercmp(&didsleep, &sleep_until, >)) { + timersub(&didsleep, &sleep_until, &nap_this_time); + + TIMEVAL_TO_TIMESPEC(&nap_this_time, &sleep); + dbgx(4, "Sleeping " TIMEVAL_FORMAT, nap_this_time.tv_sec, nap_this_time.tv_usec); +#ifdef DEBUG + timeradd(&totalsleep, &nap_this_time, &totalsleep); +#endif + if (nanosleep(&sleep, &ignore) == -1) { + warnx("nanosleep error: %s", strerror(errno)); + } + } + break; + */ + default: + errx(-1, "Unknown timer mode %d", accurate); + } + +#ifdef DEBUG + dbgx(4, "Total sleep time: " TIMEVAL_FORMAT, totalsleep.tv_sec, totalsleep.tv_usec); +#endif + + dbgx(2, "sleep delta: " TIMESPEC_FORMAT, delta_time.tv_sec, delta_time.tv_nsec); + +} + +/** + * Ask the user how many packets they want to send. + */ +static u_int32_t +get_user_count(sendpacket_t *sp, COUNTER counter) +{ + struct pollfd poller[1]; /* use poll to read from the keyboard */ + char input[EBUF_SIZE]; + u_int32_t send = 0; + + printf("**** Next packet #" COUNTER_SPEC " out %s. How many packets do you wish to send? ", + counter, (sp == options.intf1 ? options.intf1_name : options.intf2_name)); + fflush(NULL); + poller[0].fd = STDIN_FILENO; + poller[0].events = POLLIN | POLLPRI | POLLNVAL; + poller[0].revents = 0; + + if (fcntl(0, F_SETFL, fcntl(0, F_GETFL) & ~O_NONBLOCK)) + errx(-1, "Unable to clear non-blocking flag on stdin: %s", strerror(errno)); + + /* wait for the input */ + if (poll(poller, 1, -1) < 0) + errx(-1, "Error reading user input from stdin: %s", strerror(errno)); + + /* + * read to the end of the line or EBUF_SIZE, + * Note, if people are stupid, and type in more text then EBUF_SIZE + * then the next fgets() will pull in that data, which will have poor + * results. fuck them. + */ + if (fgets(input, sizeof(input), stdin) == NULL) { + errx(-1, "Unable to process user input for fd %d: %s", fileno(stdin), strerror(errno)); + } else if (strlen(input) > 1) { + send = strtoul(input, NULL, 0); + } + + /* how many packets should we send? */ + if (send == 0) { + dbg(1, "Input was less then 1 or non-numeric, assuming 1"); + + /* assume send only one packet */ + send = 1; + } + + return send; +} + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + diff --git a/src/send_packets.h b/src/send_packets.h new file mode 100644 index 0000000..a17131f --- /dev/null +++ b/src/send_packets.h @@ -0,0 +1,50 @@ +/* $Id: send_packets.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __SEND_PACKETS_H__ +#define __SEND_PACKETS_H__ + +void send_packets(pcap_t *, int); +void *cache_mode(char *, COUNTER); +const u_char * get_next_packet(pcap_t *pcap, struct pcap_pkthdr *pkthdr, + int file_idx, packet_cache_t **prev_packet); + +#endif + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + diff --git a/src/signal_handler.c b/src/signal_handler.c new file mode 100644 index 0000000..3cc16d7 --- /dev/null +++ b/src/signal_handler.c @@ -0,0 +1,125 @@ +/* $Id: signal_handler.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "defines.h" +#include "common.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "tcpreplay.h" +#include "signal_handler.h" + +struct timeval suspend_time; +static struct timeval suspend_start; +static struct timeval suspend_end; + +/** + * init_signal_handlers - + * Initialize signal handlers to be used in tcpreplay. + */ +void +init_signal_handlers() +{ + signal(SIGUSR1, suspend_handler); + signal(SIGCONT, continue_handler); + + reset_suspend_time(); +} + +/** + * reset_suspend_time - + * Reset time values for suspend signal. + */ +void +reset_suspend_time() +{ + timerclear(&suspend_time); + timerclear(&suspend_start); + timerclear(&suspend_end); +} + +/** + * suspend signal handler - + * Signal handler for signal SIGUSR1. SIGSTOP cannot be + * caught, so SIGUSR1 is caught and it throws SIGSTOP. + */ +void +suspend_handler(int signo) +{ + if (signo != SIGUSR1) { + warnx("suspend_handler() got the wrong signal: %d", signo); + return; + } + + if (gettimeofday(&suspend_start, NULL) < 0) + errx(-1, "gettimeofday(): %s", strerror(errno)); + + kill(getpid(), SIGSTOP); +} + +/** + * continue_handler - + * Signal handler for continue signal. + */ +void +continue_handler(int signo) +{ + struct timeval suspend_delta; + + if (signo != SIGCONT) { + warnx("continue_handler() got the wrong signal: %d", signo); + return; + } + + if (gettimeofday(&suspend_end, NULL) < 0) + errx(-1, "gettimeofday(): %s", strerror(errno)); + + timersub(&suspend_end, &suspend_start, &suspend_delta); + timeradd(&suspend_time, &suspend_delta, &suspend_time); +} + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + + diff --git a/src/signal_handler.h b/src/signal_handler.h new file mode 100644 index 0000000..ad996ea --- /dev/null +++ b/src/signal_handler.h @@ -0,0 +1,51 @@ +/* $Id: signal_handler.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SIGNAL_HANDLER_H +#define SIGNAL_HANDLER_H + +void init_signal_handlers(); +void reset_suspend_time(); +void suspend_handler(int signo); +void continue_handler(int signo); + +#endif + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + + diff --git a/src/sleep.c b/src/sleep.c new file mode 100644 index 0000000..f3876a8 --- /dev/null +++ b/src/sleep.c @@ -0,0 +1,101 @@ +/* $Id:$ */ + +/* + * Copyright (c) 2008-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "defines.h" +#include "common.h" + +#include +#include +#include +#include +#include + +#ifdef HAVE_SYS_EVENT +#include +#endif + +/* necessary for ioport_sleep() functions */ +#ifdef HAVE_SYS_IO_H /* Linux */ +#include +#elif defined HAVE_ARCHITECTURE_I386_PIO_H /* OS X */ +#include +#endif + +float gettimeofday_sleep_value; +int ioport_sleep_value; + + +void +ioport_sleep_init(void) +{ +#ifdef HAVE_IOPERM + ioperm(0x80,1,1); + ioport_sleep_value = inb(0x80); +#else + err(-1, "Platform does not support IO Port for timing"); +#endif +} + +void +ioport_sleep(const struct timespec nap) +{ +#ifdef HAVE_IOPERM + struct timeval nap_for; + u_int32_t usec; + time_t i; + + TIMESPEC_TO_TIMEVAL(&nap_for, &nap); + + /* + * process the seconds, we do this in a loop so we don't have to + * use slower 64bit integers or worry about integer overflows. + */ + for (i = 0; i < nap_for.tv_sec; i ++) { + usec = SEC_TO_MICROSEC(nap_for.tv_sec); + while (usec > 0) { + usec --; + outb(ioport_sleep_value, 0x80); + } + } + + /* process the usec */ + usec = nap.tv_nsec / 1000; + usec --; /* fudge factor for all the above */ + while (usec > 0) { + usec --; + outb(ioport_sleep_value, 0x80); + } +#else + err(-1, "Platform does not support IO Port for timing"); +#endif +} diff --git a/src/sleep.h b/src/sleep.h new file mode 100644 index 0000000..77ac312 --- /dev/null +++ b/src/sleep.h @@ -0,0 +1,146 @@ +/* $Id:$ */ + +/* + * Copyright (c) 2008-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "defines.h" +#include "common.h" + +#ifdef HAVE_SYS_SELECT /* According to POSIX 1003.1-2001 */ +#include +#endif + +#include +#include +#include +#include +#include +#ifdef HAVE_SYS_EVENT +#include +#endif + +/* necessary for ioport_sleep() functions */ +#ifdef HAVE_SYS_IO_H /* Linux */ +#include +#elif defined HAVE_ARCHITECTURE_I386_PIO_H /* OS X */ +#include +#endif + + +#ifndef __SLEEP_H__ +#define __SLEEP_H__ + +static inline void +nanosleep_sleep(struct timespec nap) +{ + nanosleep(&nap, NULL); +} + + +/* + * Straight forward... keep calling gettimeofday() unti the apporpriate amount + * of time has passed. Pretty damn accurate from 1 to 100Mbps + */ +static inline void +gettimeofday_sleep(struct timespec nap) +{ + struct timeval now, sleep_until, nap_for; + gettimeofday(&now, NULL); + TIMESPEC_TO_TIMEVAL(&nap_for, &nap); + timeradd(&now, &nap_for, &sleep_until); + + do { + gettimeofday(&now, NULL); + } while (timercmp(&now, &sleep_until, <)); +} + + +#ifdef HAVE_ABSOLUTE_TIME +#include + +/* + * Apple's AbsoluteTime functions give at least .1usec precision + * which is pretty damn sweet + */ +static inline void +absolute_time_sleep(struct timespec nap) +{ + AbsoluteTime sleep_until, naptime, time_left; + Nanoseconds nanosec; + + nanosec = UInt64ToUnsignedWide(TIMESPEC_TO_NANOSEC(&nap)); + naptime = NanosecondsToAbsolute(nanosec); + + sleep_until = AddAbsoluteToAbsolute(UpTime(), naptime); + + do { + time_left = SubAbsoluteFromAbsolute(sleep_until, UpTime()); + } while (NonZero(time_left)); +} + +#endif /* HAVE_ABSOLUTE_TIME */ + + + +#ifdef HAVE_SELECT +/* + * sleep for some time using the select() call timeout method. This is + * highly portable for sub-second sleeping, but only for about 1msec + * resolution which is pretty much useless for our needs. Keeping it here + * for furture reference + */ +static inline void +select_sleep(const struct timespec nap) +{ + struct timeval timeout; + + TIMESPEC_TO_TIMEVAL(&timeout, &nap); + + if (select(0, NULL, NULL, NULL, &timeout) < 0) + warnx("select_sleep() returned early due to error: %s", strerror(errno)); +} +#endif /* HAVE_SELECT */ + +/* + * ioport_sleep() only works on Intel and quite possibly only Linux. + * But the basic idea is to write to the IO Port 0x80 which should + * take exactly 1usec regardless of the CPU speed and without + * calling a sleep method which allows the kernel to service another thread + * Idea stolen from: http://c-faq.com/osdep/sd25.html + */ +extern int ioport_sleep_value; + +/* before calling port_sleep(), you have to call port_sleep_init() */ +void ioport_sleep_init(void); + +void ioport_sleep(const struct timespec nap); + +#endif /* __SLEEP_H__ */ diff --git a/src/suppport_lib/libMESA_prof_load.a b/src/suppport_lib/libMESA_prof_load.a new file mode 100644 index 0000000..0328d60 Binary files /dev/null and b/src/suppport_lib/libMESA_prof_load.a differ diff --git a/src/tcpbridge.1 b/src/tcpbridge.1 new file mode 100644 index 0000000..6183fa1 --- /dev/null +++ b/src/tcpbridge.1 @@ -0,0 +1,623 @@ +.TH TCPBRIDGE 1 2010-04-04 "(tcpbridge )" "Programmer's Manual" +.\" DO NOT EDIT THIS FILE (tcpbridge.1) +.\" +.\" It has been AutoGen-ed April 4, 2010 at 05:59:20 PM by AutoGen 5.9.9 +.\" From the definitions tcpbridge_opts.def +.\" and the template file agman1.tpl +.\" +.SH NAME +tcpbridge \- Bridge network traffic across two interfaces +.SH SYNOPSIS +.B tcpbridge +.\" Mixture of short (flag) options and long options +.RB [ \-\fIflag\fP " [\fIvalue\fP]]... [" \--\fIopt-name\fP " [[=| ]\fIvalue\fP]]..." +.PP +All arguments must be options. +.PP +tcpbridge is a tool for selectively briding network traffic across two interfaces +and optionally modifying the packets in betweeen +.SH "DESCRIPTION" +This manual page briefly documents the \fBtcpbridge\fP command. +The basic operation of tcpbridge is to be a network bridge between two +subnets. All packets received on one interface are sent via the other. + +Optionally, packets can be edited in a variety of ways according to your needs. + +For more details, please see the Tcpreplay Manual at: +http://tcpreplay.synfin.net/trac/wiki/manual +.SH OPTIONS +.SS "" +.TP +.BR \-r " \fIstring\fP, " \--portmap "=" \fIstring\fP +Rewrite TCP/UDP ports. +This option may appear up to \-1 times. +.sp +Specify a list of comma delimited port mappingings consisting of +colon delimited port number pairs. Each colon delimited port pair +consists of the port to match followed by the port number to rewrite. + +Examples: +.nf + \--portmap=80:8000 \--portmap=8080:80 # 80->8000 and 8080->80 + \--portmap=8000,8080,88888:80 # 3 different ports become 80 + \--portmap=8000-8999:80 # ports 8000 to 8999 become 80 +.fi +.TP +.BR \-s " \fInumber\fP, " \--seed "=" \fInumber\fP +Randomize src/dst IPv4/v6 addresses w/ given seed. +This option may appear up to 1 times. +This option takes an integer number as its argument. +.sp +Causes the source and destination IPv4/v6 addresses to be pseudo +randomized but still maintain client/server relationships. +Since the randomization is deterministic based on the seed, +you can reuse the same seed value to recreate the traffic. +.TP +.BR \-N " \fIstring\fP, " \--pnat "=" \fIstring\fP +Rewrite IPv4/v6 addresses using pseudo-NAT. +This option may appear up to 2 times. +This option must not appear in combination with any of the following options: +srcipmap. +.sp +Takes a comma delimited series of colon delimited CIDR +netblock pairs. Each netblock pair is evaluated in order against +the IP addresses. If the IP address in the packet matches the +first netblock, it is rewriten using the second netblock as a +mask against the high order bits. + +IPv4 Example: +.nf + \--pnat=192.168.0.0/16:10.77.0.0/16,172.16.0.0/12:10.1.0.0/24 +.fi +IPv6 Example: +.nf + \--pnat=[2001:db8::/32]:[dead::/16],[2001:db8::/32]:[::ffff:0:0/96] +.fi +.TP +.BR \-S " \fIstring\fP, " \--srcipmap "=" \fIstring\fP +Rewrite source IPv4/v6 addresses using pseudo-NAT. +This option may appear up to 1 times. +This option must not appear in combination with any of the following options: +pnat. +.sp +Works just like the \--pnat option, but only affects the source IP +addresses in the IPv4/v6 header. +.TP +.BR \-D " \fIstring\fP, " \--dstipmap "=" \fIstring\fP +Rewrite destination IPv4/v6 addresses using pseudo-NAT. +This option may appear up to 1 times. +This option must not appear in combination with any of the following options: +pnat. +.sp +Works just like the \--pnat option, but only affects the destination IP +addresses in the IPv4/v6 header. +.TP +.BR \-e " \fIstring\fP, " \--endpoints "=" \fIstring\fP +Rewrite IP addresses to be between two endpoints. +This option may appear up to 1 times. +This option must appear in combination with the following options: +cachefile. +.sp +Takes a pair of colon delimited IPv4/v6 addresses which will be used to rewrite +all traffic to appear to be between the two IP's. + +IPv4 Example: +.nf + \--endpoints=172.16.0.1:172.16.0.2 +.fi +IPv6 Example: +.nf + \--endpoints=[2001:db8::dead:beef]:[::ffff:0:0:ac:f:0:2] +.fi + +.TP +.BR \-b ", " \--skipbroadcast +Skip rewriting broadcast/multicast IPv4/v6 addresses. +.sp +By default \--seed, \--pnat and \--endpoints will rewrite +broadcast and multicast IPv4/v6 and MAC addresses. Setting this flag +will keep broadcast/multicast IPv4/v6 and MAC addresses from being rewritten. +.TP +.BR \-C ", " \--fixcsum +Force recalculation of IPv4/TCP/UDP header checksums. +.sp +Causes each IPv4/v6 packet to have it's checksums recalcualted and +fixed. Automatically enabled for packets modified with \fB--seed\fP, +\fB--pnat\fP, \fB--endpoints\fP or \fB--fixlen\fP. +.TP +.BR \-m " \fInumber\fP, " \--mtu "=" \fInumber\fP +Override default MTU length (1500 bytes). +This option may appear up to 1 times. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 1 through MAXPACKET +.fi +.in -4 +.sp +Override the default 1500 byte MTU size for determining the maximum padding length +(--fixlen=pad) or when truncating (--mtu-trunc). +.TP +.BR \--mtu-trunc +Truncate packets larger then specified MTU. +This option may appear up to 1 times. +.sp +Similar to \--fixlen, this option will truncate data in packets from Layer 3 and above to be +no larger then the MTU. +.TP +.BR \-E ", " \--efcs +Remove Ethernet checksums (FCS) from end of frames. +.sp +Note, this option is pretty dangerous! We don't actually check to see if a FCS +actually exists in the frame, we just blindly delete the last two bytes. Hence, +you should only use this if you know know that your OS provides the FCS when +reading raw packets. +.TP +.BR \--ttl "=\fIstring\fP" +Modify the IPv4/v6 TTL/Hop Limit. +.sp +Allows you to modify the TTL/Hop Limit of all the IPv4/v6 packets. Specify a number to hard-code +the value or +/-value to increase or decrease by the value provided (limited to 1-255). + +Examples: +.nf + \--ttl=10 + \--ttl=+7 + \--ttl=-64 +.fi +.TP +.BR \--tos "=\fInumber\fP" +Set the IPv4 TOS/DiffServ/ECN byte. +This option may appear up to 1 times. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 255 +.fi +.in -4 +.sp +Allows you to override the TOS (also known as DiffServ/ECN) value in IPv4. +.TP +.BR \--tclass "=\fInumber\fP" +Set the IPv6 Traffic Class byte. +This option may appear up to 1 times. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 255 +.fi +.in -4 +.sp +Allows you to override the IPv6 Traffic Class field. +.TP +.BR \--flowlabel "=\fInumber\fP" +Set the IPv6 Flow Label. +This option may appear up to 1 times. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 1048575 +.fi +.in -4 +.sp +Allows you to override the 20bit IPv6 Flow Label field. Has no effect on IPv4 +packets. +.TP +.BR \-F " \fIstring\fP, " \--fixlen "=" \fIstring\fP +Pad or truncate packet data to match header length. +This option may appear up to 1 times. +.sp +Packets may be truncated during capture if the snaplen is smaller then the +packet. This option allows you to modify the packet to pad the packet back +out to the size stored in the IPv4/v6 header or rewrite the IP header total length +to reflect the stored packet length. +.sp 1 +\fBpad\fP +Truncated packets will be padded out so that the packet length matches the +IPv4 total length +.sp 1 +\fBtrunc\fP +Truncated packets will have their IPv4 total length field rewritten to match +the actual packet length +.sp 1 +\fBdel\fP +Delete the packet +.TP +.BR \--skipl2broadcast +Skip rewriting broadcast/multicast Layer 2 addresses. +.sp +By default, editing Layer 2 addresses will rewrite +broadcast and multicast MAC addresses. Setting this flag +will keep broadcast/multicast MAC addresses from being rewritten. +.TP +.BR \--dlt "=\fIstring\fP" +Override output DLT encapsulation. +This option may appear up to 1 times. +.sp +By default, no DLT (data link type) conversion will be made. +To change the DLT type of the output pcap, select one of the following values: +.sp 1 +\fBenet\fP +Ethernet aka DLT_EN10MB +.sp 1 +\fBhdlc\fP +Cisco HDLC aka DLT_C_HDLC +.sp 1 +\fBuser\fP +User specified Layer 2 header and DLT type +.br +.TP +.BR \--enet-dmac "=\fIstring\fP" +Override destination ethernet MAC addresses. +This option may appear up to 1 times. +.sp +Takes a pair of comma deliminated ethernet MAC addresses which +will replace the destination MAC address of outbound packets. +The first MAC address will be used for the server to client traffic +and the optional second MAC address will be used for the client +to server traffic. + +Example: +.nf + \--enet-dmac=00:12:13:14:15:16,00:22:33:44:55:66 +.fi +.TP +.BR \--enet-smac "=\fIstring\fP" +Override source ethernet MAC addresses. +This option may appear up to 1 times. +.sp +Takes a pair of comma deliminated ethernet MAC addresses which +will replace the source MAC address of outbound packets. +The first MAC address will be used for the server to client traffic +and the optional second MAC address will be used for the client +to server traffic. + +Example: +.nf + \--enet-smac=00:12:13:14:15:16,00:22:33:44:55:66 +.fi +.TP +.BR \--enet-vlan "=\fIstring\fP" +Specify ethernet 802.1q VLAN tag mode. +This option may appear up to 1 times. +.sp +Allows you to rewrite ethernet frames to add a 802.1q header to standard 802.3 +ethernet headers or remove the 802.1q VLAN tag information. +.sp 1 +\fBadd\fP +Rewrites the existing 802.3 ethernet header as an 802.1q VLAN header +.sp 1 +\fBdel\fP +Rewrites the existing 802.1q VLAN header as an 802.3 ethernet header +.TP +.BR \--enet-vlan-tag "=\fInumber\fP" +Specify the new ethernet 802.1q VLAN tag value. +This option may appear up to 1 times. +This option must appear in combination with the following options: +enet-vlan. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 4095 +.fi +.in -4 +.sp + +.TP +.BR \--enet-vlan-cfi "=\fInumber\fP" +Specify the ethernet 802.1q VLAN CFI value. +This option may appear up to 1 times. +This option must appear in combination with the following options: +enet-vlan. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 1 +.fi +.in -4 +.sp + +.TP +.BR \--enet-vlan-pri "=\fInumber\fP" +Specify the ethernet 802.1q VLAN priority. +This option may appear up to 1 times. +This option must appear in combination with the following options: +enet-vlan. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 7 +.fi +.in -4 +.sp + +.TP +.BR \--hdlc-control "=\fInumber\fP" +Specify HDLC control value. +This option may appear up to 1 times. +This option takes an integer number as its argument. +.sp +The Cisco HDLC header has a 1 byte "control" field. Apparently this should +always be 0, but if you can use any 1 byte value. +.TP +.BR \--hdlc-address "=\fInumber\fP" +Specify HDLC address. +This option may appear up to 1 times. +This option takes an integer number as its argument. +.sp +The Cisco HDLC header has a 1 byte "address" field which has two valid +values: +.sp 1 +\fB0x0F\fP +Unicast +.sp 1 +\fB0xBF\fP +Broadcast +.br +You can however specify any single byte value. +.TP +.BR \--user-dlt "=\fInumber\fP" +Set output file DLT type. +This option may appear up to 1 times. +This option takes an integer number as its argument. +.sp +Set the DLT value of the output pcap file. +.TP +.BR \--user-dlink "=\fIstring\fP" +Rewrite Data-Link layer with user specified data. +This option may appear up to 2 times. +.sp +Provide a series of comma deliminated hex values which will be +used to rewrite or create the Layer 2 header of the packets. +The first instance of this argument will rewrite both server +and client traffic, but if this argument is specified a second +time, it will be used for the client traffic. + +Example: +.nf + \--user-dlink=01,02,03,04,05,06,00,1A,2B,3C,4D,5E,6F,08,00 +.fi +.TP +.BR \-d " \fInumber\fP, " \--dbug "=" \fInumber\fP +Enable debugging output. +This option may appear up to 1 times. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 5 +.fi +.in -4 +The default \fInumber\fP for this option is: +.ti +4 + 0 +.sp +If configured with \--enable-debug, then you can specify a verbosity +level for debugging output. Higher numbers increase verbosity. +.TP +.BR \-i " \fIstring\fP, " \--intf1 "=" \fIstring\fP +Primary interface (listen in uni-directional mode). +This option may appear up to 1 times. +.sp + +.TP +.BR \-I " \fIstring\fP, " \--intf2 "=" \fIstring\fP +Secondary interface (send in uni-directional mode). +This option may appear up to 1 times. +.sp + +.TP +.BR \-u ", " \--unidir +Send and receive in only one direction. +This option may appear up to 1 times. +.sp +Normally, tcpbridge will send and receive traffic in both directions +(bi-directionally). However, if you choose this option, traffic will +be sent uni-directionally. +.TP +.BR \--listnics +List available network interfaces and exit. +.sp + +.TP +.BR \-L " \fInumber\fP, " \--limit "=" \fInumber\fP +Limit the number of packets to send. +This option may appear up to 1 times. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +greater than or equal to 1 +.fi +.in -4 +The default \fInumber\fP for this option is: +.ti +4 + \-1 +.sp +By default, tcpbridge will send packets forever or until Ctrl-C. Alternatively, +you can specify a maximum number of packets to send. +.TP +.BR \-M " \fIstring\fP, " \--mac "=" \fIstring\fP +MAC addresses of local NIC's. +This option may appear up to 2 times. +.sp +tcpbridge does not support detecting the MAC addresses of the local network +interfaces under Windows. Please specify both MAC addresses of the interfaces +used in the bridge: \-M \-M +.TP +.BR \-x " \fIstring\fP, " \--include "=" \fIstring\fP +Include only packets matching rule. +This option may appear up to 1 times. +This option must not appear in combination with any of the following options: +exclude. +.sp +Override default of sending all packets stored in the capture file and only +send packets which match the provided rule. Rules can be one of: + +.sp +.IR "S:,..." +- Source IP must match specified CIDR(s) +.sp +.IR "D:,..." +- Destination IP must match specified CIDR(s) +.sp +.IR "B:,..." +- Both source and destination IP must match specified CIDR(s) +.sp +.IR "E:,..." +- Either IP must match specified CIDR(s) +.sp +.IR "P:" +- Must be one of the listed packets where the list +corresponds to the packet number in the capture file. +.nf + \--include=P:1-5,9,15,72- +.fi +would send packets 1 thru 5, the 9th and 15th packet, and packets 72 until the +end of the file +.sp +.IR "F:''" +- BPF filter. See the \fItcpdump(8)\fP man page for syntax. +.br +.TP +.BR \-X " \fIstring\fP, " \--exclude "=" \fIstring\fP +Exclude any packet matching this rule. +This option may appear up to 1 times. +This option must not appear in combination with any of the following options: +include. +.sp +Override default of sending all packets stored in the capture file and only +send packets which do not match the provided rule. Rules can be one of: + +.sp +.IR "S:,..." +- Source IP must not match specified CIDR(s) +.sp +.IR "D:,..." +- Destination IP must not match specified CIDR(s) +.sp +.IR "B:,..." +- Both source and destination IP must not match specified CIDR(s) +.sp +.IR "E:,..." +- Either IP must not match specified CIDR(s) +.sp +.IR "P:" +- Must not be one of the listed packets where the list +corresponds to the packet number in the capture file. +.nf + \--exclude=P:1-5,9,15,72- +.fi +would drop packets 1 thru 5, the 9th and 15th packet, and packets 72 until the +end of the file +.br +.TP +.BR \-P ", " \--pid +Print the PID of tcpbridge at startup. +.sp + +.TP +.BR \-v ", " \--verbose +Print decoded packets via tcpdump to STDOUT. +This option may appear up to 1 times. +.sp + +.TP +.BR \-A " \fIstring\fP, " \--decode "=" \fIstring\fP +Arguments passed to tcpdump decoder. +This option may appear up to 1 times. +This option must appear in combination with the following options: +verbose. +.sp +When enabling verbose mode (\fB-v\fP) you may also specify one or more +additional arguments to pass to \fBtcpdump\fP to modify the way packets +are decoded. By default, \-n and \-l are used. Be sure to +quote the arguments like: \--verbose="-axxx" so that they are not interpreted +by tcpbridge. The following arguments are vaild: + [ \-aAeNqRStuvxX ] + [ \-E spi@ipaddr algo:secret,... ] + [ \-s snaplen ] +.TP +.BR \-V ", " \--version +Print version information. +.sp + +.TP +.BR \-h ", " \--less-help +Display less usage information and exit. +.sp + +.TP +.BR \-H , " \--help" +Display usage information and exit. +.TP +.BR \-! , " \--more-help" +Extended usage information passed thru pager. +.TP +.BR \- " [\fIrcfile\fP]," " \--save-opts" "[=\fIrcfile\fP]" +Save the option state to \fIrcfile\fP. The default is the \fIlast\fP +configuration file listed in the \fBOPTION PRESETS\fP section, below. +.TP +.BR \- " \fIrcfile\fP," " \--load-opts" "=\fIrcfile\fP," " \--no-load-opts" +Load options from \fIrcfile\fP. +The \fIno-load-opts\fP form will disable the loading +of earlier RC/INI files. \fI--no-load-opts\fP is handled early, +out of order. +.SH OPTION PRESETS +Any option that is not marked as \fInot presettable\fP may be preset +by loading values from configuration ("RC" or ".INI") file(s). +The \fIhomerc\fP file is "\fI$$/\fP", unless that is a directory. +In that case, the file "\fI.tcpbridgerc\fP" +is searched for within that directory. +.SH "SIGNALS" +tcpbridge understands the following signals: +.sp +.IR "\fBSIGUSR1\fP" +Suspend tcpbridge +.sp +.IR "\fBSIGCONT\fP" +Restart tcpbridge +.br + +.SH "SEE ALSO" +tcpdump(1), tcpprep(1), tcprewrite(1), tcpreplay(1) + +.SH "BUGS" +tcpbridge can only send packets as fast as your computer's interface, +processor and system bus will allow. + +Connecting both interfaces to the same subnet may create a broadcast storm and +take down the network. Improper use of the packet editing functions may have +other undefined and possible negative consequences. + +Some operating systems by default do not allow for forging source MAC +addresses. Please consult your operating system's documentation and the +tcpreplay FAQ if you experiance this issue. +.SH AUTHOR +Copyright 2000-2010 Aaron Turner + +For support please use the tcpreplay-users@lists.sourceforge.net mailing list. + +The latest version of this software is always available from: +http://tcpreplay.synfin.net/ +.PP +Released under the Free BSD License. +.PP +This manual page was \fIAutoGen\fP-erated from the \fBtcpbridge\fP +option definitions. diff --git a/src/tcpbridge.c b/src/tcpbridge.c new file mode 100644 index 0000000..18583fc --- /dev/null +++ b/src/tcpbridge.c @@ -0,0 +1,266 @@ +/* $Id: tcpbridge.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2004-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Purpose: Modify packets in a pcap file based on rules provided by the + * user to offload work from tcpreplay and provide a easier means of + * reproducing traffic for testing purposes. + */ + + +#include "config.h" +#include "defines.h" +#include "common.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "tcpbridge.h" +#include "tcpbridge_opts.h" +#include "bridge.h" +#include "tcpedit/tcpedit.h" +#include "send_packets.h" + +#ifdef DEBUG +int debug; +#endif + + +COUNTER bytes_sent, total_bytes, failed, pkts_sent, cache_packets; +struct timeval begin, end; +volatile int didsig; +tcpbridge_opt_t options; +tcpedit_t *tcpedit; + +/* local functions */ +void init(void); +void post_args(int argc, char *argv[]); + +int +main(int argc, char *argv[]) +{ + int optct, rcode; + + init(); + + /* call autoopts to process arguments */ + optct = optionProcess(&tcpbridgeOptions, argc, argv); + argc -= optct; + argv += optct; + + post_args(argc, argv); + + + /* init tcpedit context */ + if (tcpedit_init(&tcpedit, pcap_datalink(options.pcap1)) < 0) { + errx(-1, "Error initializing tcpedit: %s", tcpedit_geterr(tcpedit)); + } + + /* parse the tcpedit args */ + rcode = tcpedit_post_args(&tcpedit); + if (rcode < 0) { + errx(-1, "Unable to parse args: %s", tcpedit_geterr(tcpedit)); + } else if (rcode == 1) { + warnx("%s", tcpedit_geterr(tcpedit)); + } + + if (tcpedit_validate(tcpedit) < 0) { + errx(-1, "Unable to edit packets given options:\n%s", + tcpedit_geterr(tcpedit)); + } + +#ifdef ENABLE_VERBOSE + if (options.verbose) { + options.tcpdump = (tcpdump_t*)safe_malloc(sizeof(tcpdump_t)); + tcpdump_open(options.tcpdump, options.pcap1); + } +#endif + + if (gettimeofday(&begin, NULL) < 0) + err(-1, "gettimeofday() failed"); + + + /* process packets */ + do_bridge(&options, tcpedit); + + /* clean up after ourselves */ + pcap_close(options.pcap1); + + if (options.unidir) { + pcap_close(options.pcap2); + } + +#ifdef ENABLE_VERBOSE + tcpdump_close(options.tcpdump); +#endif + + return 0; +} + +void +init(void) +{ + + bytes_sent = total_bytes = failed = pkts_sent = cache_packets = 0; + memset(&options, 0, sizeof(options)); + + options.snaplen = 65535; + options.promisc = 1; + options.to_ms = 1; + + total_bytes = 0; + + if (fcntl(STDERR_FILENO, F_SETFL, O_NONBLOCK) < 0) + warnx("Unable to set STDERR to non-blocking: %s", strerror(errno)); + +} + + +void +post_args(_U_ int argc, _U_ char *argv[]) +{ + char ebuf[SENDPACKET_ERRBUF_SIZE]; + struct tcpr_ether_addr *eth_buff; + char *intname; + sendpacket_t *sp; +#ifdef ENABLE_PCAP_FINDALLDEVS + interface_list_t *intlist = get_interface_list(); +#else + interface_list_t *intlist = NULL; +#endif + +#ifdef DEBUG + if (HAVE_OPT(DBUG)) + debug = OPT_VALUE_DBUG; +#else + if (HAVE_OPT(DBUG)) + warn("not configured with --enable-debug. Debugging disabled."); +#endif + + +#ifdef ENABLE_VERBOSE + if (HAVE_OPT(VERBOSE)) + options.verbose = 1; + + if (HAVE_OPT(DECODE)) + options.tcpdump->args = safe_strdup(OPT_ARG(DECODE)); + +#endif + + if (HAVE_OPT(UNIDIR)) + options.unidir = 1; + + if (HAVE_OPT(LIMIT)) + options.limit_send = OPT_VALUE_LIMIT; /* default is -1 */ + + + if ((intname = get_interface(intlist, OPT_ARG(INTF1))) == NULL) + errx(-1, "Invalid interface name/alias: %s", OPT_ARG(INTF1)); + + options.intf1 = safe_strdup(intname); + + if (HAVE_OPT(INTF2)) { + if ((intname = get_interface(intlist, OPT_ARG(INTF2))) == NULL) + errx(-1, "Invalid interface name/alias: %s", OPT_ARG(INTF2)); + + options.intf2 = safe_strdup(intname); + } + + + if (HAVE_OPT(MAC)) { + int ct = STACKCT_OPT(MAC); + char **list = STACKLST_OPT(MAC); + int first = 1; + do { + char *p = *list++; + if (first) + mac2hex(p, (u_char *)options.intf1_mac, ETHER_ADDR_LEN); + else + mac2hex(p, (u_char *)options.intf2_mac, ETHER_ADDR_LEN); + first = 0; + } while (--ct > 0); + } + + /* + * Figure out MAC addresses of sending interface(s) + * if user doesn't specify MAC address on CLI, query for it + */ + if (memcmp(options.intf1_mac, "\00\00\00\00\00\00", ETHER_ADDR_LEN) == 0) { + if ((sp = sendpacket_open(options.intf1, ebuf, TCPR_DIR_C2S)) == NULL) + errx(-1, "Unable to open interface %s: %s", options.intf1, ebuf); + + if ((eth_buff = sendpacket_get_hwaddr(sp)) == NULL) { + warnx("Unable to get MAC address: %s", sendpacket_geterr(sp)); + err(-1, "Please consult the man page for using the -M option."); + } + sendpacket_close(sp); + memcpy(options.intf1_mac, eth_buff, ETHER_ADDR_LEN); + } + + if (memcmp(options.intf2_mac, "\00\00\00\00\00\00", ETHER_ADDR_LEN) == 0) { + if ((sp = sendpacket_open(options.intf2, ebuf, TCPR_DIR_S2C)) == NULL) + errx(-1, "Unable to open interface %s: %s", options.intf2, ebuf); + + if ((eth_buff = sendpacket_get_hwaddr(sp)) == NULL) { + warnx("Unable to get MAC address: %s", sendpacket_geterr(sp)); + err(-1, "Please consult the man page for using the -M option."); + } + sendpacket_close(sp); + memcpy(options.intf2_mac, eth_buff, ETHER_ADDR_LEN); + } + + /* + * Open interfaces for sending & receiving + */ + if ((options.pcap1 = pcap_open_live(options.intf1, options.snaplen, + options.promisc, options.to_ms, ebuf)) == NULL) + errx(-1, "Unable to open interface %s: %s", options.intf1, ebuf); + + + if (strcmp(options.intf1, options.intf2) == 0) + errx(-1, "Whoa tiger! You don't want to use %s twice!", options.intf1); + + + /* we always have to open the other pcap handle to send, but we may not listen */ + if ((options.pcap2 = pcap_open_live(options.intf2, options.snaplen, + options.promisc, options.to_ms, ebuf)) == NULL) + errx(-1, "Unable to open interface %s: %s", options.intf2, ebuf); + + /* poll should be -1 to wait indefinitely */ + options.poll_timeout = -1; +} diff --git a/src/tcpbridge.h b/src/tcpbridge.h new file mode 100644 index 0000000..745820a --- /dev/null +++ b/src/tcpbridge.h @@ -0,0 +1,109 @@ +/* $Id: tcpbridge.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2005-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __TCPBRIDGE_H__ +#define __TCPBRIDGE_H__ + +/* we don't support endpoints w/ tcpbridge */ +#define TCPEDIT_ENDPOINTS_DISABLE 1 + +#include "config.h" +#include "defines.h" +#include "common.h" +#include "tcpedit/tcpedit.h" + +#include +#include +#include +#include + +#ifdef ENABLE_DMALLOC +#include +#endif + + +/* run-time options */ +struct tcpbridge_opt_s { + char *intf1; + char *intf2; + + /* store the mac address of each interface here to prevent loops */ + char intf1_mac[ETHER_ADDR_LEN]; + char intf2_mac[ETHER_ADDR_LEN]; + + /* truncate packet ? */ + int truncate; + + COUNTER limit_send; + + pcap_t *pcap1; + pcap_t *pcap2; + int unidir; + int snaplen; + int to_ms; + int promisc; + int poll_timeout; + +#ifdef ENABLE_VERBOSE + /* tcpdump verbose printing */ + int verbose; + char *tcpdump_args; + tcpdump_t *tcpdump; +#endif + + + + /* filter options */ + tcpr_xX_t xX; + tcpr_bpf_t bpf; + regex_t preg; + tcpr_cidr_t *cidrdata; + + int mtu; + int maxpacket; + int fixcsum; + u_int16_t l2proto; + u_int16_t l2_mem_align; /* keep things 4 byte aligned */ +}; + +typedef struct tcpbridge_opt_s tcpbridge_opt_t; + +#endif + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + diff --git a/src/tcpbridge_opts.c b/src/tcpbridge_opts.c new file mode 100644 index 0000000..d91d184 --- /dev/null +++ b/src/tcpbridge_opts.c @@ -0,0 +1,1979 @@ +/* -*- buffer-read-only: t -*- vi: set ro: + * + * DO NOT EDIT THIS FILE (tcpbridge_opts.c) + * + * It has been AutoGen-ed April 4, 2010 at 05:59:19 PM by AutoGen 5.9.9 + * From the definitions tcpbridge_opts.def + * and the template file options + * + * Generated from AutoOpts 32:2:7 templates. + */ + +/* + * This file was produced by an AutoOpts template. AutoOpts is a + * copyrighted work. This source file is not encumbered by AutoOpts + * licensing, but is provided under the licensing terms chosen by the + * tcpbridge author or copyright holder. AutoOpts is licensed under + * the terms of the LGPL. The redistributable library (``libopts'') is + * licensed under the terms of either the LGPL or, at the users discretion, + * the BSD license. See the AutoOpts and/or libopts sources for details. + * + * This source file is copyrighted and licensed under the following terms: + * + * tcpbridge copyright (c) 2000-2010 Aaron Turner - all rights reserved + * + * tcpbridge is free software copyrighted by Aaron Turner. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name ``Aaron Turner'' nor the name of any other + * contributor may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * tcpbridge IS PROVIDED BY Aaron Turner ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL Aaron Turner OR ANY OTHER CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +extern FILE * option_usage_fp; +#define OPTION_CODE_COMPILE 1 +#include "tcpbridge_opts.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* TRANSLATORS: choose the translation for option names wisely because you + cannot ever change your mind. */ +tSCC zCopyright[] = + "tcpbridge copyright (c) 2000-2010 Aaron Turner, all rights reserved"; +tSCC zCopyrightNotice[1458] = +"tcpbridge is free software copyrighted by Aaron Turner.\n\n\ +Redistribution and use in source and binary forms, with or without\n\ +modification, are permitted provided that the following conditions are met: 1.\n\ +Redistributions of source code must retain the above copyright notice, this\n\ +list of conditions and the following disclaimer. 2. Redistributions in binary\n\ +form must reproduce the above copyright notice, this list of conditions and the\n\ +following disclaimer in the documentation and/or other materials provided with\n\ +the distribution. 3. Neither the name ``Aaron Turner'' nor the name of any\n\ +other contributor may be used to endorse or promote products derived from this\n\ +software without specific prior written permission.\n\n\ +tcpbridge IS PROVIDED BY Aaron Turner ``AS IS'' AND ANY EXPRESS OR IMPLIED\n\ +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n\ +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO\n\ +EVENT SHALL Aaron Turner OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n\ +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\n\ +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n\ +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n\ +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n\ +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\n\ +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."; + +extern tUsageProc optionUsage; + +/* + * global included definitions + */ +#include "defines.h" +#include "tcpbridge.h" +#include "common.h" +#include "config.h" +#include +#include +#include +#include +extern tcpbridge_opt_t options; + + +#ifndef NULL +# define NULL 0 +#endif +#ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +#endif +#ifndef EXIT_FAILURE +# define EXIT_FAILURE 1 +#endif +/* + * Tcpedit option description: + */ +tSCC zTcpeditText[] = + ""; +#define TCPEDIT_FLAGS (OPTST_DOCUMENT | OPTST_NO_INIT) + +/* + * Portmap option description: + */ +tSCC zPortmapText[] = + "Rewrite TCP/UDP ports"; +tSCC zPortmap_NAME[] = "PORTMAP"; +tSCC zPortmap_Name[] = "portmap"; +#define PORTMAP_FLAGS (OPTST_DISABLED | OPTST_STACKED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Seed option description: + */ +tSCC zSeedText[] = + "Randomize src/dst IPv4/v6 addresses w/ given seed"; +tSCC zSeed_NAME[] = "SEED"; +tSCC zSeed_Name[] = "seed"; +#define SEED_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Pnat option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zPnatText[] = + "Rewrite IPv4/v6 addresses using pseudo-NAT"; +tSCC zPnat_NAME[] = "PNAT"; +tSCC zPnat_Name[] = "pnat"; +static const int + aPnatCantList[] = { + INDEX_OPT_SRCIPMAP, NO_EQUIVALENT }; +#define PNAT_FLAGS (OPTST_DISABLED | OPTST_STACKED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Srcipmap option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zSrcipmapText[] = + "Rewrite source IPv4/v6 addresses using pseudo-NAT"; +tSCC zSrcipmap_NAME[] = "SRCIPMAP"; +tSCC zSrcipmap_Name[] = "srcipmap"; +static const int + aSrcipmapCantList[] = { + INDEX_OPT_PNAT, NO_EQUIVALENT }; +#define SRCIPMAP_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Dstipmap option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zDstipmapText[] = + "Rewrite destination IPv4/v6 addresses using pseudo-NAT"; +tSCC zDstipmap_NAME[] = "DSTIPMAP"; +tSCC zDstipmap_Name[] = "dstipmap"; +static const int + aDstipmapCantList[] = { + INDEX_OPT_PNAT, NO_EQUIVALENT }; +#define DSTIPMAP_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Endpoints option description with + * "Must also have options" and "Incompatible options": + */ +#ifdef HAVE_CACHEFILE_SUPPORT +tSCC zEndpointsText[] = + "Rewrite IP addresses to be between two endpoints"; +tSCC zEndpoints_NAME[] = "ENDPOINTS"; +tSCC zEndpoints_Name[] = "endpoints"; +static const int + aEndpointsMustList[] = { + INDEX_OPT_CACHEFILE, NO_EQUIVALENT }; +#define ENDPOINTS_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +#else /* disable Endpoints */ +#define VALUE_OPT_ENDPOINTS NO_EQUIVALENT +#define ENDPOINTS_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define aEndpointsMustList NULL +#define zEndpointsText NULL +#define zEndpoints_NAME NULL +#define zEndpoints_Name NULL +#endif /* HAVE_CACHEFILE_SUPPORT */ + +/* + * Skipbroadcast option description: + */ +tSCC zSkipbroadcastText[] = + "Skip rewriting broadcast/multicast IPv4/v6 addresses"; +tSCC zSkipbroadcast_NAME[] = "SKIPBROADCAST"; +tSCC zSkipbroadcast_Name[] = "skipbroadcast"; +#define SKIPBROADCAST_FLAGS (OPTST_DISABLED) + +/* + * Fixcsum option description: + */ +tSCC zFixcsumText[] = + "Force recalculation of IPv4/TCP/UDP header checksums"; +tSCC zFixcsum_NAME[] = "FIXCSUM"; +tSCC zFixcsum_Name[] = "fixcsum"; +#define FIXCSUM_FLAGS (OPTST_DISABLED) + +/* + * Mtu option description: + */ +tSCC zMtuText[] = + "Override default MTU length (1500 bytes)"; +tSCC zMtu_NAME[] = "MTU"; +tSCC zMtu_Name[] = "mtu"; +#define MTU_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Mtu_Trunc option description: + */ +tSCC zMtu_TruncText[] = + "Truncate packets larger then specified MTU"; +tSCC zMtu_Trunc_NAME[] = "MTU_TRUNC"; +tSCC zMtu_Trunc_Name[] = "mtu-trunc"; +#define MTU_TRUNC_FLAGS (OPTST_DISABLED) + +/* + * Efcs option description: + */ +tSCC zEfcsText[] = + "Remove Ethernet checksums (FCS) from end of frames"; +tSCC zEfcs_NAME[] = "EFCS"; +tSCC zEfcs_Name[] = "efcs"; +#define EFCS_FLAGS (OPTST_DISABLED) + +/* + * Ttl option description: + */ +tSCC zTtlText[] = + "Modify the IPv4/v6 TTL/Hop Limit"; +tSCC zTtl_NAME[] = "TTL"; +tSCC zTtl_Name[] = "ttl"; +#define TTL_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Tos option description: + */ +tSCC zTosText[] = + "Set the IPv4 TOS/DiffServ/ECN byte"; +tSCC zTos_NAME[] = "TOS"; +tSCC zTos_Name[] = "tos"; +#define TOS_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Tclass option description: + */ +tSCC zTclassText[] = + "Set the IPv6 Traffic Class byte"; +tSCC zTclass_NAME[] = "TCLASS"; +tSCC zTclass_Name[] = "tclass"; +#define TCLASS_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Flowlabel option description: + */ +tSCC zFlowlabelText[] = + "Set the IPv6 Flow Label"; +tSCC zFlowlabel_NAME[] = "FLOWLABEL"; +tSCC zFlowlabel_Name[] = "flowlabel"; +#define FLOWLABEL_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Fixlen option description: + */ +tSCC zFixlenText[] = + "Pad or truncate packet data to match header length"; +tSCC zFixlen_NAME[] = "FIXLEN"; +tSCC zFixlen_Name[] = "fixlen"; +#define FIXLEN_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Skipl2broadcast option description: + */ +tSCC zSkipl2broadcastText[] = + "Skip rewriting broadcast/multicast Layer 2 addresses"; +tSCC zSkipl2broadcast_NAME[] = "SKIPL2BROADCAST"; +tSCC zSkipl2broadcast_Name[] = "skipl2broadcast"; +#define SKIPL2BROADCAST_FLAGS (OPTST_DISABLED) + +/* + * Dlt option description: + */ +tSCC zDltText[] = + "Override output DLT encapsulation"; +tSCC zDlt_NAME[] = "DLT"; +tSCC zDlt_Name[] = "dlt"; +#define DLT_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Enet_Dmac option description: + */ +tSCC zEnet_DmacText[] = + "Override destination ethernet MAC addresses"; +tSCC zEnet_Dmac_NAME[] = "ENET_DMAC"; +tSCC zEnet_Dmac_Name[] = "enet-dmac"; +#define ENET_DMAC_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Enet_Smac option description: + */ +tSCC zEnet_SmacText[] = + "Override source ethernet MAC addresses"; +tSCC zEnet_Smac_NAME[] = "ENET_SMAC"; +tSCC zEnet_Smac_Name[] = "enet-smac"; +#define ENET_SMAC_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Enet_Vlan option description: + */ +tSCC zEnet_VlanText[] = + "Specify ethernet 802.1q VLAN tag mode"; +tSCC zEnet_Vlan_NAME[] = "ENET_VLAN"; +tSCC zEnet_Vlan_Name[] = "enet-vlan"; +#define ENET_VLAN_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Enet_Vlan_Tag option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zEnet_Vlan_TagText[] = + "Specify the new ethernet 802.1q VLAN tag value"; +tSCC zEnet_Vlan_Tag_NAME[] = "ENET_VLAN_TAG"; +tSCC zEnet_Vlan_Tag_Name[] = "enet-vlan-tag"; +static const int + aEnet_Vlan_TagMustList[] = { + INDEX_OPT_ENET_VLAN, NO_EQUIVALENT }; +#define ENET_VLAN_TAG_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Enet_Vlan_Cfi option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zEnet_Vlan_CfiText[] = + "Specify the ethernet 802.1q VLAN CFI value"; +tSCC zEnet_Vlan_Cfi_NAME[] = "ENET_VLAN_CFI"; +tSCC zEnet_Vlan_Cfi_Name[] = "enet-vlan-cfi"; +static const int + aEnet_Vlan_CfiMustList[] = { + INDEX_OPT_ENET_VLAN, NO_EQUIVALENT }; +#define ENET_VLAN_CFI_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Enet_Vlan_Pri option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zEnet_Vlan_PriText[] = + "Specify the ethernet 802.1q VLAN priority"; +tSCC zEnet_Vlan_Pri_NAME[] = "ENET_VLAN_PRI"; +tSCC zEnet_Vlan_Pri_Name[] = "enet-vlan-pri"; +static const int + aEnet_Vlan_PriMustList[] = { + INDEX_OPT_ENET_VLAN, NO_EQUIVALENT }; +#define ENET_VLAN_PRI_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Hdlc_Control option description: + */ +tSCC zHdlc_ControlText[] = + "Specify HDLC control value"; +tSCC zHdlc_Control_NAME[] = "HDLC_CONTROL"; +tSCC zHdlc_Control_Name[] = "hdlc-control"; +#define HDLC_CONTROL_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Hdlc_Address option description: + */ +tSCC zHdlc_AddressText[] = + "Specify HDLC address"; +tSCC zHdlc_Address_NAME[] = "HDLC_ADDRESS"; +tSCC zHdlc_Address_Name[] = "hdlc-address"; +#define HDLC_ADDRESS_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * User_Dlt option description: + */ +tSCC zUser_DltText[] = + "Set output file DLT type"; +tSCC zUser_Dlt_NAME[] = "USER_DLT"; +tSCC zUser_Dlt_Name[] = "user-dlt"; +#define USER_DLT_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * User_Dlink option description: + */ +tSCC zUser_DlinkText[] = + "Rewrite Data-Link layer with user specified data"; +tSCC zUser_Dlink_NAME[] = "USER_DLINK"; +tSCC zUser_Dlink_Name[] = "user-dlink"; +#define USER_DLINK_FLAGS (OPTST_DISABLED | OPTST_STACKED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Dbug option description: + */ +#ifdef DEBUG +tSCC zDbugText[] = + "Enable debugging output"; +tSCC zDbug_NAME[] = "DBUG"; +tSCC zDbug_Name[] = "dbug"; +#define zDbugDefaultArg ((char const*)0) +#define DBUG_FLAGS (OPTST_DISABLED | OPTST_IMM \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +#else /* disable Dbug */ +#define VALUE_OPT_DBUG NO_EQUIVALENT +#define DBUG_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zDbugDefaultArg NULL +#define zDbugText NULL +#define zDbug_NAME NULL +#define zDbug_Name NULL +#endif /* DEBUG */ + +/* + * Intf1 option description: + */ +tSCC zIntf1Text[] = + "Primary interface (listen in uni-directional mode)"; +tSCC zIntf1_NAME[] = "INTF1"; +tSCC zIntf1_Name[] = "intf1"; +#define INTF1_FLAGS (OPTST_DISABLED | OPTST_MUST_SET \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Intf2 option description: + */ +tSCC zIntf2Text[] = + "Secondary interface (send in uni-directional mode)"; +tSCC zIntf2_NAME[] = "INTF2"; +tSCC zIntf2_Name[] = "intf2"; +#define INTF2_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Unidir option description: + */ +tSCC zUnidirText[] = + "Send and receive in only one direction"; +tSCC zUnidir_NAME[] = "UNIDIR"; +tSCC zUnidir_Name[] = "unidir"; +#define UNIDIR_FLAGS (OPTST_DISABLED) + +/* + * Listnics option description: + */ +#ifdef ENABLE_PCAP_FINDALLDEVS +tSCC zListnicsText[] = + "List available network interfaces and exit"; +tSCC zListnics_NAME[] = "LISTNICS"; +tSCC zListnics_Name[] = "listnics"; +#define LISTNICS_FLAGS (OPTST_DISABLED | OPTST_IMM) + +#else /* disable Listnics */ +#define VALUE_OPT_LISTNICS NO_EQUIVALENT +#define LISTNICS_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zListnicsText NULL +#define zListnics_NAME NULL +#define zListnics_Name NULL +#endif /* ENABLE_PCAP_FINDALLDEVS */ + +/* + * Limit option description: + */ +tSCC zLimitText[] = + "Limit the number of packets to send"; +tSCC zLimit_NAME[] = "LIMIT"; +tSCC zLimit_Name[] = "limit"; +#define zLimitDefaultArg ((char const*)-1) +#define LIMIT_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Mac option description: + */ +tSCC zMacText[] = + "MAC addresses of local NIC's"; +tSCC zMac_NAME[] = "MAC"; +tSCC zMac_Name[] = "mac"; +#define MAC_FLAGS (OPTST_DISABLED | OPTST_STACKED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Include option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zIncludeText[] = + "Include only packets matching rule"; +tSCC zInclude_NAME[] = "INCLUDE"; +tSCC zInclude_Name[] = "include"; +static const int + aIncludeCantList[] = { + INDEX_OPT_EXCLUDE, NO_EQUIVALENT }; +#define INCLUDE_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Exclude option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zExcludeText[] = + "Exclude any packet matching this rule"; +tSCC zExclude_NAME[] = "EXCLUDE"; +tSCC zExclude_Name[] = "exclude"; +static const int + aExcludeCantList[] = { + INDEX_OPT_INCLUDE, NO_EQUIVALENT }; +#define EXCLUDE_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Pid option description: + */ +tSCC zPidText[] = + "Print the PID of tcpbridge at startup"; +tSCC zPid_NAME[] = "PID"; +tSCC zPid_Name[] = "pid"; +#define PID_FLAGS (OPTST_DISABLED) + +/* + * Verbose option description: + */ +#ifdef ENABLE_VERBOSE +tSCC zVerboseText[] = + "Print decoded packets via tcpdump to STDOUT"; +tSCC zVerbose_NAME[] = "VERBOSE"; +tSCC zVerbose_Name[] = "verbose"; +#define VERBOSE_FLAGS (OPTST_DISABLED | OPTST_IMM) + +#else /* disable Verbose */ +#define VALUE_OPT_VERBOSE NO_EQUIVALENT +#define VERBOSE_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zVerboseText NULL +#define zVerbose_NAME NULL +#define zVerbose_Name NULL +#endif /* ENABLE_VERBOSE */ + +/* + * Decode option description with + * "Must also have options" and "Incompatible options": + */ +#ifdef ENABLE_VERBOSE +tSCC zDecodeText[] = + "Arguments passed to tcpdump decoder"; +tSCC zDecode_NAME[] = "DECODE"; +tSCC zDecode_Name[] = "decode"; +static const int + aDecodeMustList[] = { + INDEX_OPT_VERBOSE, NO_EQUIVALENT }; +#define DECODE_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +#else /* disable Decode */ +#define VALUE_OPT_DECODE NO_EQUIVALENT +#define DECODE_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define aDecodeMustList NULL +#define zDecodeText NULL +#define zDecode_NAME NULL +#define zDecode_Name NULL +#endif /* ENABLE_VERBOSE */ + +/* + * Version option description: + */ +tSCC zVersionText[] = + "Print version information"; +tSCC zVersion_NAME[] = "VERSION"; +tSCC zVersion_Name[] = "version"; +#define VERSION_FLAGS (OPTST_DISABLED) + +/* + * Less_Help option description: + */ +tSCC zLess_HelpText[] = + "Display less usage information and exit"; +tSCC zLess_Help_NAME[] = "LESS_HELP"; +tSCC zLess_Help_Name[] = "less-help"; +#define LESS_HELP_FLAGS (OPTST_DISABLED | OPTST_IMM) + +/* + * Help/More_Help option descriptions: + */ +tSCC zHelpText[] = "Display usage information and exit"; +tSCC zHelp_Name[] = "help"; +tSCC zMore_HelpText[] = "Extended usage information passed thru pager"; +tSCC zMore_Help_Name[] = "more-help"; +tSCC zSave_OptsText[] = "Save the option state to a config file"; +tSCC zSave_Opts_Name[] = "save-opts"; +tSCC zLoad_OptsText[] = "Load options from a config file"; +tSCC zLoad_Opts_NAME[] = "LOAD_OPTS"; +tSCC zNotLoad_Opts_Name[] = "no-load-opts"; +tSCC zNotLoad_Opts_Pfx[] = "no"; +#define zLoad_Opts_Name (zNotLoad_Opts_Name + 3) +/* + * Declare option callback procedures + */ +#ifdef DEBUG + static tOptProc doOptDbug; +#else /* not DEBUG */ +# define doOptDbug NULL +#endif /* def/not DEBUG */ +#ifdef ENABLE_PCAP_FINDALLDEVS + static tOptProc doOptListnics; +#else /* not ENABLE_PCAP_FINDALLDEVS */ +# define doOptListnics NULL +#endif /* def/not ENABLE_PCAP_FINDALLDEVS */ +extern tOptProc + optionNumericVal, optionPagedUsage, optionStackArg; +static tOptProc + doOptEnet_Vlan_Cfi, doOptEnet_Vlan_Pri, doOptEnet_Vlan_Tag, + doOptExclude, doOptFlowlabel, doOptInclude, + doOptLess_Help, doOptLimit, doOptMtu, + doOptPid, doOptTclass, doOptTos, + doOptVersion, doUsageOpt; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Define the Tcpbridge Option Descriptions. + */ +static tOptDesc optDesc[ OPTION_CT ] = { + { /* entry idx, value */ 0, 0, + /* equiv idx, value */ 0, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 0, 0, + /* opt state flags */ TCPEDIT_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zTcpeditText, NULL, NULL, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 1, VALUE_OPT_PORTMAP, + /* equiv idx, value */ 1, VALUE_OPT_PORTMAP, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, -1, 0, + /* opt state flags */ PORTMAP_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionStackArg, + /* desc, NAME, name */ zPortmapText, zPortmap_NAME, zPortmap_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 2, VALUE_OPT_SEED, + /* equiv idx, value */ 2, VALUE_OPT_SEED, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ SEED_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionNumericVal, + /* desc, NAME, name */ zSeedText, zSeed_NAME, zSeed_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 3, VALUE_OPT_PNAT, + /* equiv idx, value */ 3, VALUE_OPT_PNAT, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 2, 0, + /* opt state flags */ PNAT_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aPnatCantList, + /* option proc */ optionStackArg, + /* desc, NAME, name */ zPnatText, zPnat_NAME, zPnat_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 4, VALUE_OPT_SRCIPMAP, + /* equiv idx, value */ 4, VALUE_OPT_SRCIPMAP, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ SRCIPMAP_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aSrcipmapCantList, + /* option proc */ NULL, + /* desc, NAME, name */ zSrcipmapText, zSrcipmap_NAME, zSrcipmap_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 5, VALUE_OPT_DSTIPMAP, + /* equiv idx, value */ 5, VALUE_OPT_DSTIPMAP, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ DSTIPMAP_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aDstipmapCantList, + /* option proc */ NULL, + /* desc, NAME, name */ zDstipmapText, zDstipmap_NAME, zDstipmap_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 6, VALUE_OPT_ENDPOINTS, + /* equiv idx, value */ 6, VALUE_OPT_ENDPOINTS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ ENDPOINTS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aEndpointsMustList, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zEndpointsText, zEndpoints_NAME, zEndpoints_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 7, VALUE_OPT_SKIPBROADCAST, + /* equiv idx, value */ 7, VALUE_OPT_SKIPBROADCAST, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ SKIPBROADCAST_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zSkipbroadcastText, zSkipbroadcast_NAME, zSkipbroadcast_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 8, VALUE_OPT_FIXCSUM, + /* equiv idx, value */ 8, VALUE_OPT_FIXCSUM, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ FIXCSUM_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zFixcsumText, zFixcsum_NAME, zFixcsum_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 9, VALUE_OPT_MTU, + /* equiv idx, value */ 9, VALUE_OPT_MTU, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ MTU_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptMtu, + /* desc, NAME, name */ zMtuText, zMtu_NAME, zMtu_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 10, VALUE_OPT_MTU_TRUNC, + /* equiv idx, value */ 10, VALUE_OPT_MTU_TRUNC, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ MTU_TRUNC_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zMtu_TruncText, zMtu_Trunc_NAME, zMtu_Trunc_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 11, VALUE_OPT_EFCS, + /* equiv idx, value */ 11, VALUE_OPT_EFCS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ EFCS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zEfcsText, zEfcs_NAME, zEfcs_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 12, VALUE_OPT_TTL, + /* equiv idx, value */ 12, VALUE_OPT_TTL, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ TTL_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zTtlText, zTtl_NAME, zTtl_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 13, VALUE_OPT_TOS, + /* equiv idx, value */ 13, VALUE_OPT_TOS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ TOS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptTos, + /* desc, NAME, name */ zTosText, zTos_NAME, zTos_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 14, VALUE_OPT_TCLASS, + /* equiv idx, value */ 14, VALUE_OPT_TCLASS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ TCLASS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptTclass, + /* desc, NAME, name */ zTclassText, zTclass_NAME, zTclass_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 15, VALUE_OPT_FLOWLABEL, + /* equiv idx, value */ 15, VALUE_OPT_FLOWLABEL, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ FLOWLABEL_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptFlowlabel, + /* desc, NAME, name */ zFlowlabelText, zFlowlabel_NAME, zFlowlabel_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 16, VALUE_OPT_FIXLEN, + /* equiv idx, value */ 16, VALUE_OPT_FIXLEN, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ FIXLEN_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zFixlenText, zFixlen_NAME, zFixlen_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 17, VALUE_OPT_SKIPL2BROADCAST, + /* equiv idx, value */ 17, VALUE_OPT_SKIPL2BROADCAST, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ SKIPL2BROADCAST_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zSkipl2broadcastText, zSkipl2broadcast_NAME, zSkipl2broadcast_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 18, VALUE_OPT_DLT, + /* equiv idx, value */ 18, VALUE_OPT_DLT, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ DLT_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zDltText, zDlt_NAME, zDlt_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 19, VALUE_OPT_ENET_DMAC, + /* equiv idx, value */ 19, VALUE_OPT_ENET_DMAC, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ ENET_DMAC_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zEnet_DmacText, zEnet_Dmac_NAME, zEnet_Dmac_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 20, VALUE_OPT_ENET_SMAC, + /* equiv idx, value */ 20, VALUE_OPT_ENET_SMAC, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ ENET_SMAC_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zEnet_SmacText, zEnet_Smac_NAME, zEnet_Smac_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 21, VALUE_OPT_ENET_VLAN, + /* equiv idx, value */ 21, VALUE_OPT_ENET_VLAN, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ ENET_VLAN_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zEnet_VlanText, zEnet_Vlan_NAME, zEnet_Vlan_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 22, VALUE_OPT_ENET_VLAN_TAG, + /* equiv idx, value */ 22, VALUE_OPT_ENET_VLAN_TAG, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ ENET_VLAN_TAG_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aEnet_Vlan_TagMustList, NULL, + /* option proc */ doOptEnet_Vlan_Tag, + /* desc, NAME, name */ zEnet_Vlan_TagText, zEnet_Vlan_Tag_NAME, zEnet_Vlan_Tag_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 23, VALUE_OPT_ENET_VLAN_CFI, + /* equiv idx, value */ 23, VALUE_OPT_ENET_VLAN_CFI, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ ENET_VLAN_CFI_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aEnet_Vlan_CfiMustList, NULL, + /* option proc */ doOptEnet_Vlan_Cfi, + /* desc, NAME, name */ zEnet_Vlan_CfiText, zEnet_Vlan_Cfi_NAME, zEnet_Vlan_Cfi_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 24, VALUE_OPT_ENET_VLAN_PRI, + /* equiv idx, value */ 24, VALUE_OPT_ENET_VLAN_PRI, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ ENET_VLAN_PRI_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aEnet_Vlan_PriMustList, NULL, + /* option proc */ doOptEnet_Vlan_Pri, + /* desc, NAME, name */ zEnet_Vlan_PriText, zEnet_Vlan_Pri_NAME, zEnet_Vlan_Pri_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 25, VALUE_OPT_HDLC_CONTROL, + /* equiv idx, value */ 25, VALUE_OPT_HDLC_CONTROL, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ HDLC_CONTROL_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionNumericVal, + /* desc, NAME, name */ zHdlc_ControlText, zHdlc_Control_NAME, zHdlc_Control_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 26, VALUE_OPT_HDLC_ADDRESS, + /* equiv idx, value */ 26, VALUE_OPT_HDLC_ADDRESS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ HDLC_ADDRESS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionNumericVal, + /* desc, NAME, name */ zHdlc_AddressText, zHdlc_Address_NAME, zHdlc_Address_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 27, VALUE_OPT_USER_DLT, + /* equiv idx, value */ 27, VALUE_OPT_USER_DLT, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ USER_DLT_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionNumericVal, + /* desc, NAME, name */ zUser_DltText, zUser_Dlt_NAME, zUser_Dlt_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 28, VALUE_OPT_USER_DLINK, + /* equiv idx, value */ 28, VALUE_OPT_USER_DLINK, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 2, 0, + /* opt state flags */ USER_DLINK_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionStackArg, + /* desc, NAME, name */ zUser_DlinkText, zUser_Dlink_NAME, zUser_Dlink_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 29, VALUE_OPT_DBUG, + /* equiv idx, value */ 29, VALUE_OPT_DBUG, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ DBUG_FLAGS, 0, + /* last opt argumnt */ { zDbugDefaultArg }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptDbug, + /* desc, NAME, name */ zDbugText, zDbug_NAME, zDbug_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 30, VALUE_OPT_INTF1, + /* equiv idx, value */ 30, VALUE_OPT_INTF1, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 1, 1, 0, + /* opt state flags */ INTF1_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zIntf1Text, zIntf1_NAME, zIntf1_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 31, VALUE_OPT_INTF2, + /* equiv idx, value */ 31, VALUE_OPT_INTF2, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ INTF2_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zIntf2Text, zIntf2_NAME, zIntf2_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 32, VALUE_OPT_UNIDIR, + /* equiv idx, value */ 32, VALUE_OPT_UNIDIR, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ UNIDIR_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zUnidirText, zUnidir_NAME, zUnidir_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 33, VALUE_OPT_LISTNICS, + /* equiv idx, value */ 33, VALUE_OPT_LISTNICS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ LISTNICS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptListnics, + /* desc, NAME, name */ zListnicsText, zListnics_NAME, zListnics_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 34, VALUE_OPT_LIMIT, + /* equiv idx, value */ 34, VALUE_OPT_LIMIT, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ LIMIT_FLAGS, 0, + /* last opt argumnt */ { zLimitDefaultArg }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptLimit, + /* desc, NAME, name */ zLimitText, zLimit_NAME, zLimit_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 35, VALUE_OPT_MAC, + /* equiv idx, value */ 35, VALUE_OPT_MAC, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 2, 0, + /* opt state flags */ MAC_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionStackArg, + /* desc, NAME, name */ zMacText, zMac_NAME, zMac_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 36, VALUE_OPT_INCLUDE, + /* equiv idx, value */ 36, VALUE_OPT_INCLUDE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ INCLUDE_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aIncludeCantList, + /* option proc */ doOptInclude, + /* desc, NAME, name */ zIncludeText, zInclude_NAME, zInclude_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 37, VALUE_OPT_EXCLUDE, + /* equiv idx, value */ 37, VALUE_OPT_EXCLUDE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ EXCLUDE_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aExcludeCantList, + /* option proc */ doOptExclude, + /* desc, NAME, name */ zExcludeText, zExclude_NAME, zExclude_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 38, VALUE_OPT_PID, + /* equiv idx, value */ 38, VALUE_OPT_PID, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ PID_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptPid, + /* desc, NAME, name */ zPidText, zPid_NAME, zPid_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 39, VALUE_OPT_VERBOSE, + /* equiv idx, value */ 39, VALUE_OPT_VERBOSE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ VERBOSE_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zVerboseText, zVerbose_NAME, zVerbose_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 40, VALUE_OPT_DECODE, + /* equiv idx, value */ 40, VALUE_OPT_DECODE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ DECODE_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aDecodeMustList, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zDecodeText, zDecode_NAME, zDecode_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 41, VALUE_OPT_VERSION, + /* equiv idx, value */ 41, VALUE_OPT_VERSION, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ VERSION_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptVersion, + /* desc, NAME, name */ zVersionText, zVersion_NAME, zVersion_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 42, VALUE_OPT_LESS_HELP, + /* equiv idx, value */ 42, VALUE_OPT_LESS_HELP, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ LESS_HELP_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptLess_Help, + /* desc, NAME, name */ zLess_HelpText, zLess_Help_NAME, zLess_Help_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doUsageOpt, + /* desc, NAME, name */ zHelpText, NULL, zHelp_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionPagedUsage, + /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) + | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, NOLIMIT, 0, + /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) + | OPTST_DISABLE_IMM, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionLoadOpt, + /* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name, + /* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx } +}; +tOptDesc * const tcpedit_tcpedit_optDesc_p = optDesc + 0; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Define the Tcpbridge Option Environment + */ +tSCC zPROGNAME[] = "TCPBRIDGE"; +tSCC zUsageTitle[] = +"tcpbridge (tcpbridge) - Bridge network traffic across two interfaces\n\ +USAGE: %s [ - [] | --[{=| }] ]...\n"; +tSCC zRcName[] = ".tcpbridgerc"; +tSCC* apzHomeList[] = { + "$$/", + NULL }; + +#define zBugsAddr NULL +tSCC zExplain[] = "\n\ +tcpbridge is a tool for selectively briding network traffic across two interfaces\n\ +and optionally modifying the packets in betweeen\n"; +tSCC zDetail[] = "\n\ +The basic operation of tcpbridge is to be a network bridge between two\n\ +subnets. All packets received on one interface are sent via the other.\n\n\ +Optionally, packets can be edited in a variety of ways according to your needs.\n\n\ +For more details, please see the Tcpreplay Manual at:\n\ +http://tcpreplay.synfin.net/trac/wiki/manual\n"; +#define zFullVersion NULL +/* extracted from /usr/local/share/autogen/optcode.tpl near line 501 */ + +#if defined(ENABLE_NLS) +# define OPTPROC_BASE OPTPROC_TRANSLATE + static tOptionXlateProc translate_option_strings; +#else +# define OPTPROC_BASE OPTPROC_NONE +# define translate_option_strings NULL +#endif /* ENABLE_NLS */ + + +#define tcpbridge_full_usage NULL +#define tcpbridge_short_usage NULL +tOptions tcpbridgeOptions = { + OPTIONS_STRUCT_VERSION, + 0, NULL, /* original argc + argv */ + ( OPTPROC_BASE + + OPTPROC_ERRSTOP + + OPTPROC_SHORTOPT + + OPTPROC_LONGOPT + + OPTPROC_NO_REQ_OPT + + OPTPROC_NO_ARGS + + OPTPROC_GNUUSAGE ), + 0, NULL, /* current option index, current option */ + NULL, NULL, zPROGNAME, + zRcName, zCopyright, zCopyrightNotice, + zFullVersion, apzHomeList, zUsageTitle, + zExplain, zDetail, optDesc, + zBugsAddr, /* address to send bugs to */ + NULL, NULL, /* extensions/saved state */ + optionUsage, /* usage procedure */ + translate_option_strings, /* translation procedure */ + /* + * Indexes to special options + */ + { INDEX_OPT_MORE_HELP, /* more-help option index */ + INDEX_OPT_SAVE_OPTS, /* save option index */ + NO_EQUIVALENT, /* '-#' option index */ + 9 /* index of default opt */ + }, + 47 /* full option count */, 43 /* user option count */, + tcpbridge_full_usage, tcpbridge_short_usage, + NULL, NULL +}; + +/* + * Create the static procedure(s) declared above. + */ +static void +doUsageOpt( + tOptions* pOptions, + tOptDesc* pOptDesc ) +{ + (void)pOptions; + USAGE( EXIT_SUCCESS ); +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the mtu option. + */ +static void +doOptMtu(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 1, MAXPACKET } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the tos option. + */ +static void +doOptTos(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 0, 255 } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the tclass option. + */ +static void +doOptTclass(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 0, 255 } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the flowlabel option. + */ +static void +doOptFlowlabel(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 0, 1048575 } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the enet-vlan-tag option. + */ +static void +doOptEnet_Vlan_Tag(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 0, 4095 } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the enet-vlan-cfi option. + */ +static void +doOptEnet_Vlan_Cfi(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 0, 1 } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the enet-vlan-pri option. + */ +static void +doOptEnet_Vlan_Pri(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 0, 7 } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the dbug option, when DEBUG is #define-d. + */ +#ifdef DEBUG +static void +doOptDbug(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 0, 5 } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} +#endif /* defined DEBUG */ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the listnics option, when ENABLE_PCAP_FINDALLDEVS is #define-d. + */ +#ifdef ENABLE_PCAP_FINDALLDEVS +static void +doOptListnics(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcpbridge_opts.def, line 148 */ + +interface_list_t *list = get_interface_list(); +list_interfaces(list); +free(list); +exit(0); + +} +#endif /* defined ENABLE_PCAP_FINDALLDEVS */ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the limit option. + */ +static void +doOptLimit(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 1, LONG_MAX } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the include option. + */ +static void +doOptInclude(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcpbridge_opts.def, line 205 */ + + char *include; + + include = safe_strdup(OPT_ARG(INCLUDE)); + options.xX.mode = xX_MODE_INCLUDE; + + if ((options.xX.mode = parse_xX_str(&options.xX, include, &options.bpf)) == xXError) + errx(-1, "Unable to parse include/exclude rule: %s", OPT_ARG(INCLUDE)); + + free(include); + +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the exclude option. + */ +static void +doOptExclude(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcpbridge_opts.def, line 252 */ + + char *exclude; + + exclude = safe_strdup(OPT_ARG(EXCLUDE)); + options.xX.mode = xX_MODE_EXCLUDE; + + if ((options.xX.mode = parse_xX_str(&options.xX, exclude, &options.bpf)) == xXError) + errx(-1, "Unable to parse include/exclude rule: %s", OPT_ARG(EXCLUDE)); + + free(exclude); + +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the pid option. + */ +static void +doOptPid(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcpbridge_opts.def, line 294 */ + + fprintf(stderr, "PID: %hu\n", getpid()); + +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the version option. + */ +static void +doOptVersion(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcpbridge_opts.def, line 339 */ + + fprintf(stderr, "tcpbridge version: %s (build %s)", VERSION, svn_version()); +#ifdef DEBUG + fprintf(stderr, " (debug)"); +#endif + fprintf(stderr, "\n"); + fprintf(stderr, "Copyright 2000-2010 by Aaron Turner \n"); +#ifdef HAVE_LIBDNET + fprintf(stderr, "Compiled against libdnet: %s\n", LIBDNET_VERSION); +#else + fprintf(stderr, "Not compiled with libdnet.\n"); +#endif +#ifdef HAVE_WINPCAP + fprintf(stderr, "Compiled against winpcap: %s\n", get_pcap_version()); +#else + fprintf(stderr, "Compiled against libpcap: %s\n", get_pcap_version()); +#endif +#ifdef ENABLE_64BITS + fprintf(stderr, "64 bit packet counters: enabled\n"); +#else + fprintf(stderr, "64 bit packet counters: disabled\n"); +#endif +#ifdef ENABLE_VERBOSE + fprintf(stderr, "Verbose printing via tcpdump: enabled\n"); +#else + fprintf(stderr, "Verbose printing via tcpdump: disabled\n"); +#endif + fprintf(stderr, "Injection method: %s\n", sendpacket_get_method()); + + exit(0); + +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the less-help option. + */ +static void +doOptLess_Help(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcpbridge_opts.def, line 380 */ + + USAGE(EXIT_FAILURE); + +} +/* extracted from /usr/local/share/autogen/optcode.tpl near line 633 */ + +#if ENABLE_NLS +#include +#include +#include +#include +#include + +static char* AO_gettext( char const* pz ); +static void coerce_it(void** s); + +static char* +AO_gettext( char const* pz ) +{ + char* pzRes; + if (pz == NULL) + return NULL; + pzRes = _(pz); + if (pzRes == pz) + return pzRes; + pzRes = strdup( pzRes ); + if (pzRes == NULL) { + fputs( _("No memory for duping translated strings\n"), stderr ); + exit( EXIT_FAILURE ); + } + return pzRes; +} + +static void coerce_it(void** s) { *s = AO_gettext(*s); } +#define COERSION(_f) \ + coerce_it((void*)&(tcpbridgeOptions._f)) + +/* + * This invokes the translation code (e.g. gettext(3)). + */ +static void +translate_option_strings( void ) +{ + /* + * Guard against re-translation. It won't work. The strings will have + * been changed by the first pass through this code. One shot only. + */ + if (option_usage_text.field_ct != 0) { + + /* + * Do the translations. The first pointer follows the field count + * field. The field count field is the size of a pointer. + */ + tOptDesc* pOD = tcpbridgeOptions.pOptDesc; + char** ppz = (char**)(void*)&(option_usage_text); + int ix = option_usage_text.field_ct; + + do { + ppz++; + *ppz = AO_gettext(*ppz); + } while (--ix > 0); + + COERSION(pzCopyright); + COERSION(pzCopyNotice); + COERSION(pzFullVersion); + COERSION(pzUsageTitle); + COERSION(pzExplain); + COERSION(pzDetail); + option_usage_text.field_ct = 0; + + for (ix = tcpbridgeOptions.optCt; ix > 0; ix--, pOD++) + coerce_it((void*)&(pOD->pzText)); + } + + if ((tcpbridgeOptions.fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) { + tOptDesc* pOD = tcpbridgeOptions.pOptDesc; + int ix; + + for (ix = tcpbridgeOptions.optCt; ix > 0; ix--, pOD++) { + coerce_it((void*)&(pOD->pz_Name)); + coerce_it((void*)&(pOD->pz_DisableName)); + coerce_it((void*)&(pOD->pz_DisablePfx)); + } + /* prevent re-translation */ + tcpbridgeOptions.fOptSet |= OPTPROC_NXLAT_OPT_CFG | OPTPROC_NXLAT_OPT; + } +} + +#endif /* ENABLE_NLS */ + +#ifdef __cplusplus +} +#endif +/* tcpbridge_opts.c ends here */ diff --git a/src/tcpbridge_opts.def b/src/tcpbridge_opts.def new file mode 100644 index 0000000..76a332e --- /dev/null +++ b/src/tcpbridge_opts.def @@ -0,0 +1,385 @@ +autogen definitions options; + + +copyright = { + date = "2000-2010"; + owner = "Aaron Turner"; + type = "bsd"; + author = <<- EOText +Copyright 2000-2010 Aaron Turner + +For support please use the tcpreplay-users@lists.sourceforge.net mailing list. + +The latest version of this software is always available from: +http://tcpreplay.synfin.net/ +EOText; +}; + +package = "tcpbridge"; +prog-name = "tcpbridge"; +prog-title = "Bridge network traffic across two interfaces"; +long-opts; +gnu-usage; +help-value = "H"; +save-opts-value = ""; +load-opts-value = ""; +config-header = "config.h"; + +include = "#include \"defines.h\"\n" + "#include \"tcpbridge.h\"\n" + "#include \"common.h\"\n" + "#include \"config.h\"\n" + "#include \n" + "#include \n" + "#include \n" + "#include \n" + "extern tcpbridge_opt_t options;\n"; + + +#include tcpedit/tcpedit_opts.def + + +homerc = "$$/"; + +explain = <<- EOExplain +tcpbridge is a tool for selectively briding network traffic across two interfaces +and optionally modifying the packets in betweeen +EOExplain; + +detail = <<- EODetail +The basic operation of tcpbridge is to be a network bridge between two +subnets. All packets received on one interface are sent via the other. + +Optionally, packets can be edited in a variety of ways according to your needs. + +For more details, please see the Tcpreplay Manual at: +http://tcpreplay.synfin.net/trac/wiki/manual +EODetail; + +man-doc = <<- EOMan +.SH "SIGNALS" +tcpbridge understands the following signals: +@enumerate +@item @var{SIGUSR1} +Suspend tcpbridge +@item @var{SIGCONT} +Restart tcpbridge +@end enumerate + +.SH "SEE ALSO" +tcpdump(1), tcpprep(1), tcprewrite(1), tcpreplay(1) + +.SH "BUGS" +tcpbridge can only send packets as fast as your computer's interface, +processor and system bus will allow. + +Connecting both interfaces to the same subnet may create a broadcast storm and +take down the network. Improper use of the packet editing functions may have +other undefined and possible negative consequences. + +Some operating systems by default do not allow for forging source MAC +addresses. Please consult your operating system's documentation and the +tcpreplay FAQ if you experiance this issue. +EOMan; + +/* + * Debugging + */ + +flag = { + ifdef = DEBUG; + name = dbug; + value = d; + arg-type = number; + max = 1; + immediate; + arg-range = "0->5"; + arg-default = 0; + descrip = "Enable debugging output"; + doc = <<- EOText +If configured with --enable-debug, then you can specify a verbosity +level for debugging output. Higher numbers increase verbosity. +EOText; +}; + + +/* + * Outputs: -i, -I + */ + +flag = { + name = intf1; + value = i; + arg-type = string; + max = 1; + must-set; + descrip = "Primary interface (listen in uni-directional mode)"; + doc = ""; +}; + +flag = { + name = intf2; + value = I; + arg-type = string; + max = 1; + descrip = "Secondary interface (send in uni-directional mode)"; + doc = ""; +}; + +flag = { + name = unidir; + value = u; + max = 1; + descrip = "Send and receive in only one direction"; + doc = <<- EOText +Normally, tcpbridge will send and receive traffic in both directions +(bi-directionally). However, if you choose this option, traffic will +be sent uni-directionally. +EOText; +}; + +flag = { + ifdef = ENABLE_PCAP_FINDALLDEVS; + name = listnics; + descrip = "List available network interfaces and exit"; + immediate; + doc = ""; + flag-code = <<- EOFlag + +interface_list_t *list = get_interface_list(); +list_interfaces(list); +free(list); +exit(0); + +EOFlag; +}; + + +/* + * Select which packets to process + */ + +flag = { + name = limit; + value = L; + arg-type = number; + max = 1; + arg-default = -1; + arg-range = "1->"; + descrip = "Limit the number of packets to send"; + doc = <<- EOText +By default, tcpbridge will send packets forever or until Ctrl-C. Alternatively, +you can specify a maximum number of packets to send. +EOText; +}; + +/* + * Windows users need to provide the MAC addresses of the interfaces + * so we can prevent looping (since winpcap doesn't have an API to query) + * the MAC address of the NIC's + */ +flag = { + name = mac; + value = M; + arg-type = string; + max = 2; + stack-arg; + descrip = "MAC addresses of local NIC's"; + doc = <<- EOText +tcpbridge does not support detecting the MAC addresses of the local network +interfaces under Windows. Please specify both MAC addresses of the interfaces +used in the bridge: -M -M +EOText; +}; + + +/* Include/Exclude */ +flag = { + name = include; + value = x; + arg-type = string; + max = 1; + descrip = "Include only packets matching rule"; + flags-cant = exclude; + flag-code = <<- EOInclude + + char *include; + + include = safe_strdup(OPT_ARG(INCLUDE)); + options.xX.mode = xX_MODE_INCLUDE; + + if ((options.xX.mode = parse_xX_str(&options.xX, include, &options.bpf)) == xXError) + errx(-1, "Unable to parse include/exclude rule: %s", OPT_ARG(INCLUDE)); + + free(include); + +EOInclude; + doc = <<- EOText +Override default of sending all packets stored in the capture file and only +send packets which match the provided rule. Rules can be one of: + +@table @bullet +@item S:,... +- Source IP must match specified CIDR(s) +@item D:,... +- Destination IP must match specified CIDR(s) +@item B:,... +- Both source and destination IP must match specified CIDR(s) +@item E:,... +- Either IP must match specified CIDR(s) +@item P: +- Must be one of the listed packets where the list +corresponds to the packet number in the capture file. +@example +--include=P:1-5,9,15,72- +@end example +would send packets 1 thru 5, the 9th and 15th packet, and packets 72 until the +end of the file +@item F:'' +- BPF filter. See the @file{tcpdump(8)} man page for syntax. +@end table +EOText; +}; + +flag = { + name = exclude; + value = X; + arg-type = string; + max = 1; + descrip = "Exclude any packet matching this rule"; + flags-cant = include; + flag-code = <<- EOExclude + + char *exclude; + + exclude = safe_strdup(OPT_ARG(EXCLUDE)); + options.xX.mode = xX_MODE_EXCLUDE; + + if ((options.xX.mode = parse_xX_str(&options.xX, exclude, &options.bpf)) == xXError) + errx(-1, "Unable to parse include/exclude rule: %s", OPT_ARG(EXCLUDE)); + + free(exclude); + +EOExclude; + doc = <<- EOText +Override default of sending all packets stored in the capture file and only +send packets which do not match the provided rule. Rules can be one of: + +@table @bullet +@item S:,... +- Source IP must not match specified CIDR(s) +@item D:,... +- Destination IP must not match specified CIDR(s) +@item B:,... +- Both source and destination IP must not match specified CIDR(s) +@item E:,... +- Either IP must not match specified CIDR(s) +@item P: +- Must not be one of the listed packets where the list +corresponds to the packet number in the capture file. +@example +--exclude=P:1-5,9,15,72- +@end example +would drop packets 1 thru 5, the 9th and 15th packet, and packets 72 until the +end of the file +@end table +EOText; +}; + +flag = { + name = pid; + value = P; + descrip = "Print the PID of tcpbridge at startup"; + flag-code = <<- EOPid + + fprintf(stderr, "PID: %hu\n", getpid()); + +EOPid; + doc = ""; +}; + +/* Verbose decoding via tcpdump */ + +flag = { + ifdef = ENABLE_VERBOSE; + name = verbose; + value = v; + max = 1; + immediate; + descrip = "Print decoded packets via tcpdump to STDOUT"; + settable; + doc = ""; +}; + +flag = { + ifdef = ENABLE_VERBOSE; + name = decode; + flags-must = verbose; + value = A; + arg-type = string; + max = 1; + descrip = "Arguments passed to tcpdump decoder"; + doc = <<- EOText +When enabling verbose mode (@var{-v}) you may also specify one or more +additional arguments to pass to @code{tcpdump} to modify the way packets +are decoded. By default, -n and -l are used. Be sure to +quote the arguments like: --verbose="-axxx" so that they are not interpreted +by tcpbridge. The following arguments are vaild: + [ -aAeNqRStuvxX ] + [ -E spi@ipaddr algo:secret,... ] + [ -s snaplen ] +EOText; +}; + +flag = { + name = version; + value = V; + descrip = "Print version information"; + flag-code = <<- EOVersion + + fprintf(stderr, "tcpbridge version: %s (build %s)", VERSION, svn_version()); +#ifdef DEBUG + fprintf(stderr, " (debug)"); +#endif + fprintf(stderr, "\n"); + fprintf(stderr, "Copyright 2000-2010 by Aaron Turner \n"); +#ifdef HAVE_LIBDNET + fprintf(stderr, "Compiled against libdnet: %s\n", LIBDNET_VERSION); +#else + fprintf(stderr, "Not compiled with libdnet.\n"); +#endif +#ifdef HAVE_WINPCAP + fprintf(stderr, "Compiled against winpcap: %s\n", get_pcap_version()); +#else + fprintf(stderr, "Compiled against libpcap: %s\n", get_pcap_version()); +#endif +#ifdef ENABLE_64BITS + fprintf(stderr, "64 bit packet counters: enabled\n"); +#else + fprintf(stderr, "64 bit packet counters: disabled\n"); +#endif +#ifdef ENABLE_VERBOSE + fprintf(stderr, "Verbose printing via tcpdump: enabled\n"); +#else + fprintf(stderr, "Verbose printing via tcpdump: disabled\n"); +#endif + fprintf(stderr, "Injection method: %s\n", sendpacket_get_method()); + + exit(0); + +EOVersion; + doc = ""; +}; + +flag = { + name = less-help; + value = "h"; + immediate; + descrip = "Display less usage information and exit"; + flag-code = <<- EOHelp + + USAGE(EXIT_FAILURE); + +EOHelp; + doc = ""; +}; diff --git a/src/tcpbridge_opts.h b/src/tcpbridge_opts.h new file mode 100644 index 0000000..913d387 --- /dev/null +++ b/src/tcpbridge_opts.h @@ -0,0 +1,291 @@ +/* -*- buffer-read-only: t -*- vi: set ro: + * + * DO NOT EDIT THIS FILE (tcpbridge_opts.h) + * + * It has been AutoGen-ed April 4, 2010 at 05:59:19 PM by AutoGen 5.9.9 + * From the definitions tcpbridge_opts.def + * and the template file options + * + * Generated from AutoOpts 32:2:7 templates. + */ + +/* + * This file was produced by an AutoOpts template. AutoOpts is a + * copyrighted work. This header file is not encumbered by AutoOpts + * licensing, but is provided under the licensing terms chosen by the + * tcpbridge author or copyright holder. AutoOpts is licensed under + * the terms of the LGPL. The redistributable library (``libopts'') is + * licensed under the terms of either the LGPL or, at the users discretion, + * the BSD license. See the AutoOpts and/or libopts sources for details. + * + * This source file is copyrighted and licensed under the following terms: + * + * tcpbridge copyright (c) 2000-2010 Aaron Turner - all rights reserved + * + * tcpbridge is free software copyrighted by Aaron Turner. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name ``Aaron Turner'' nor the name of any other + * contributor may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * tcpbridge IS PROVIDED BY Aaron Turner ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL Aaron Turner OR ANY OTHER CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/* + * This file contains the programmatic interface to the Automated + * Options generated for the tcpbridge program. + * These macros are documented in the AutoGen info file in the + * "AutoOpts" chapter. Please refer to that doc for usage help. + */ +#ifndef AUTOOPTS_TCPBRIDGE_OPTS_H_GUARD +#define AUTOOPTS_TCPBRIDGE_OPTS_H_GUARD 1 +#include "config.h" +#include + +/* + * Ensure that the library used for compiling this generated header is at + * least as new as the version current when the header template was released + * (not counting patch version increments). Also ensure that the oldest + * tolerable version is at least as old as what was current when the header + * template was released. + */ +#define AO_TEMPLATE_VERSION 131074 +#if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \ + || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION) +# error option template version mismatches autoopts/options.h header + Choke Me. +#endif + +/* + * Enumeration of each option: + */ +typedef enum { + INDEX_OPT_PORTMAP = 1, + INDEX_OPT_SEED = 2, + INDEX_OPT_PNAT = 3, + INDEX_OPT_SRCIPMAP = 4, + INDEX_OPT_DSTIPMAP = 5, + INDEX_OPT_ENDPOINTS = 6, + INDEX_OPT_SKIPBROADCAST = 7, + INDEX_OPT_FIXCSUM = 8, + INDEX_OPT_MTU = 9, + INDEX_OPT_MTU_TRUNC = 10, + INDEX_OPT_EFCS = 11, + INDEX_OPT_TTL = 12, + INDEX_OPT_TOS = 13, + INDEX_OPT_TCLASS = 14, + INDEX_OPT_FLOWLABEL = 15, + INDEX_OPT_FIXLEN = 16, + INDEX_OPT_SKIPL2BROADCAST = 17, + INDEX_OPT_DLT = 18, + INDEX_OPT_ENET_DMAC = 19, + INDEX_OPT_ENET_SMAC = 20, + INDEX_OPT_ENET_VLAN = 21, + INDEX_OPT_ENET_VLAN_TAG = 22, + INDEX_OPT_ENET_VLAN_CFI = 23, + INDEX_OPT_ENET_VLAN_PRI = 24, + INDEX_OPT_HDLC_CONTROL = 25, + INDEX_OPT_HDLC_ADDRESS = 26, + INDEX_OPT_USER_DLT = 27, + INDEX_OPT_USER_DLINK = 28, + INDEX_OPT_DBUG = 29, + INDEX_OPT_INTF1 = 30, + INDEX_OPT_INTF2 = 31, + INDEX_OPT_UNIDIR = 32, + INDEX_OPT_LISTNICS = 33, + INDEX_OPT_LIMIT = 34, + INDEX_OPT_MAC = 35, + INDEX_OPT_INCLUDE = 36, + INDEX_OPT_EXCLUDE = 37, + INDEX_OPT_PID = 38, + INDEX_OPT_VERBOSE = 39, + INDEX_OPT_DECODE = 40, + INDEX_OPT_VERSION = 41, + INDEX_OPT_LESS_HELP = 42, + INDEX_OPT_HELP = 43, + INDEX_OPT_MORE_HELP = 44, + INDEX_OPT_SAVE_OPTS = 45, + INDEX_OPT_LOAD_OPTS = 46 +} teOptIndex; + +#define OPTION_CT 47 + +/* + * Interface defines for all options. Replace "n" with the UPPER_CASED + * option name (as in the teOptIndex enumeration above). + * e.g. HAVE_OPT( TCPEDIT ) + */ +#define DESC(n) (tcpbridgeOptions.pOptDesc[INDEX_OPT_## n]) +#define HAVE_OPT(n) (! UNUSED_OPT(& DESC(n))) +#define OPT_ARG(n) (DESC(n).optArg.argString) +#define STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK) +#define COUNT_OPT(n) (DESC(n).optOccCt) +#define ISSEL_OPT(n) (SELECTED_OPT(&DESC(n))) +#define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n))) +#define ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n))) +#define STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt) +#define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs) +#define CLEAR_OPT(n) STMTS( \ + DESC(n).fOptState &= OPTST_PERSISTENT_MASK; \ + if ( (DESC(n).fOptState & OPTST_INITENABLED) == 0) \ + DESC(n).fOptState |= OPTST_DISABLED; \ + DESC(n).optCookie = NULL ) + +/* * * * * * + * + * Interface defines for specific options. + */ +#define VALUE_OPT_PORTMAP 'r' +#define VALUE_OPT_SEED 's' +#define OPT_VALUE_SEED (DESC(SEED).optArg.argInt) +#define VALUE_OPT_PNAT 'N' +#define VALUE_OPT_SRCIPMAP 'S' +#define VALUE_OPT_DSTIPMAP 'D' +#ifdef HAVE_CACHEFILE_SUPPORT +#define VALUE_OPT_ENDPOINTS 'e' +#endif /* HAVE_CACHEFILE_SUPPORT */ +#define VALUE_OPT_SKIPBROADCAST 'b' +#define VALUE_OPT_FIXCSUM 'C' +#define VALUE_OPT_MTU 'm' +#define OPT_VALUE_MTU (DESC(MTU).optArg.argInt) +#define VALUE_OPT_MTU_TRUNC 10 +#define VALUE_OPT_EFCS 'E' +#define VALUE_OPT_TTL 12 +#define VALUE_OPT_TOS 13 +#define OPT_VALUE_TOS (DESC(TOS).optArg.argInt) +#define VALUE_OPT_TCLASS 14 +#define OPT_VALUE_TCLASS (DESC(TCLASS).optArg.argInt) +#define VALUE_OPT_FLOWLABEL 15 +#define OPT_VALUE_FLOWLABEL (DESC(FLOWLABEL).optArg.argInt) +#define VALUE_OPT_FIXLEN 'F' +#define VALUE_OPT_SKIPL2BROADCAST 17 +#define VALUE_OPT_DLT 18 +#define VALUE_OPT_ENET_DMAC 19 +#define VALUE_OPT_ENET_SMAC 20 +#define VALUE_OPT_ENET_VLAN 21 +#define VALUE_OPT_ENET_VLAN_TAG 22 +#define OPT_VALUE_ENET_VLAN_TAG (DESC(ENET_VLAN_TAG).optArg.argInt) +#define VALUE_OPT_ENET_VLAN_CFI 23 +#define OPT_VALUE_ENET_VLAN_CFI (DESC(ENET_VLAN_CFI).optArg.argInt) +#define VALUE_OPT_ENET_VLAN_PRI 24 +#define OPT_VALUE_ENET_VLAN_PRI (DESC(ENET_VLAN_PRI).optArg.argInt) +#define VALUE_OPT_HDLC_CONTROL 25 +#define OPT_VALUE_HDLC_CONTROL (DESC(HDLC_CONTROL).optArg.argInt) +#define VALUE_OPT_HDLC_ADDRESS 26 +#define OPT_VALUE_HDLC_ADDRESS (DESC(HDLC_ADDRESS).optArg.argInt) +#define VALUE_OPT_USER_DLT 27 +#define OPT_VALUE_USER_DLT (DESC(USER_DLT).optArg.argInt) +#define VALUE_OPT_USER_DLINK 28 +#ifdef DEBUG +#define VALUE_OPT_DBUG 'd' +#define OPT_VALUE_DBUG (DESC(DBUG).optArg.argInt) +#endif /* DEBUG */ +#define VALUE_OPT_INTF1 'i' +#define VALUE_OPT_INTF2 'I' +#define VALUE_OPT_UNIDIR 'u' +#ifdef ENABLE_PCAP_FINDALLDEVS +#define VALUE_OPT_LISTNICS 129 +#endif /* ENABLE_PCAP_FINDALLDEVS */ +#define VALUE_OPT_LIMIT 'L' +#define OPT_VALUE_LIMIT (DESC(LIMIT).optArg.argInt) +#define VALUE_OPT_MAC 'M' +#define VALUE_OPT_INCLUDE 'x' +#define VALUE_OPT_EXCLUDE 'X' +#define VALUE_OPT_PID 'P' +#ifdef ENABLE_VERBOSE +#define VALUE_OPT_VERBOSE 'v' +#define SET_OPT_VERBOSE STMTS( \ + DESC(VERBOSE).optActualIndex = 39; \ + DESC(VERBOSE).optActualValue = VALUE_OPT_VERBOSE; \ + DESC(VERBOSE).fOptState &= OPTST_PERSISTENT_MASK; \ + DESC(VERBOSE).fOptState |= OPTST_SET ) +#endif /* ENABLE_VERBOSE */ +#ifdef ENABLE_VERBOSE +#define VALUE_OPT_DECODE 'A' +#endif /* ENABLE_VERBOSE */ +#define VALUE_OPT_VERSION 'V' +#define VALUE_OPT_LESS_HELP 'h' +#define VALUE_OPT_HELP 'H' +#define VALUE_OPT_MORE_HELP '!' +#define VALUE_OPT_SAVE_OPTS INDEX_OPT_SAVE_OPTS +#define VALUE_OPT_LOAD_OPTS INDEX_OPT_LOAD_OPTS +#define SET_OPT_SAVE_OPTS(a) STMTS( \ + DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \ + DESC(SAVE_OPTS).fOptState |= OPTST_SET; \ + DESC(SAVE_OPTS).optArg.argString = (char const*)(a) ) +/* + * Interface defines not associated with particular options + */ +#define ERRSKIP_OPTERR STMTS( tcpbridgeOptions.fOptSet &= ~OPTPROC_ERRSTOP ) +#define ERRSTOP_OPTERR STMTS( tcpbridgeOptions.fOptSet |= OPTPROC_ERRSTOP ) +#define RESTART_OPT(n) STMTS( \ + tcpbridgeOptions.curOptIdx = (n); \ + tcpbridgeOptions.pzCurOpt = NULL ) +#define START_OPT RESTART_OPT(1) +#define USAGE(c) (*tcpbridgeOptions.pUsageProc)( &tcpbridgeOptions, c ) +/* extracted from /usr/local/share/autogen/opthead.tpl near line 409 */ + +/* * * * * * + * + * Declare the tcpbridge option descriptor. + */ +#ifdef __cplusplus +extern "C" { +#endif + +extern tOptions tcpbridgeOptions; + +#if defined(ENABLE_NLS) +# ifndef _ +# include + static inline char* aoGetsText( char const* pz ) { + if (pz == NULL) return NULL; + return (char*)gettext( pz ); + } +# define _(s) aoGetsText(s) +# endif /* _() */ + +# define OPT_NO_XLAT_CFG_NAMES STMTS(tcpbridgeOptions.fOptSet |= \ + OPTPROC_NXLAT_OPT_CFG;) +# define OPT_NO_XLAT_OPT_NAMES STMTS(tcpbridgeOptions.fOptSet |= \ + OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;) + +# define OPT_XLAT_CFG_NAMES STMTS(tcpbridgeOptions.fOptSet &= \ + ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);) +# define OPT_XLAT_OPT_NAMES STMTS(tcpbridgeOptions.fOptSet &= \ + ~OPTPROC_NXLAT_OPT;) + +#else /* ENABLE_NLS */ +# define OPT_NO_XLAT_CFG_NAMES +# define OPT_NO_XLAT_OPT_NAMES + +# define OPT_XLAT_CFG_NAMES +# define OPT_XLAT_OPT_NAMES + +# ifndef _ +# define _(_s) _s +# endif +#endif /* ENABLE_NLS */ + +#ifdef __cplusplus +} +#endif +#endif /* AUTOOPTS_TCPBRIDGE_OPTS_H_GUARD */ +/* tcpbridge_opts.h ends here */ diff --git a/src/tcpedit/Makefile.am b/src/tcpedit/Makefile.am new file mode 100644 index 0000000..759c311 --- /dev/null +++ b/src/tcpedit/Makefile.am @@ -0,0 +1,36 @@ +# $Id: Makefile.am 1630 2007-02-03 04:23:14Z aturner $ +#SUBDIRS = plugins + +noinst_LIBRARIES = libtcpedit.a + +BUILT_SOURCES = tcpedit_stub.h + +libtcpedit_a_SOURCES = tcpedit.c parse_args.c edit_packet.c \ + portmap.c dlt.c checksum.c + +manpages: tcpedit.1 + +tcpedit.1: tcpedit_stub.def + @AUTOGEN@ -T agman1.tpl --base-name tcpedit tcpedit_stub.def + +tcpedit.c: tcpedit_stub.h + +# Get AutoOpts search path +#opts_list=`find plugins -type d -not -regex ".*\.svn.*" -not -regex ".*\.deps.*" -exec echo -n "-L {} " \;` + +tcpedit_stub.h: tcpedit_opts.def tcpedit_stub.def $(srcdir)/plugins/dlt_stub.def + @AUTOGEN@ $(opts_list) tcpedit_stub.def + +AM_CFLAGS = -I.. -I../common -I../.. @LDNETINC@ $(LIBOPTS_CFLAGS) $(LNAV_CFLAGS) + +noinst_HEADERS = tcpedit.h edit_packet.h portmap.h \ + tcpedit_stub.h parse_args.h dlt.h checksum.h tcpedit-int.h + +MOSTLYCLEANFILES = *~ + +MAINTAINERCLEANFILES = Makefile.in tcpedit_stub.h tcpedit.1 + +EXTRA_DIST = tcpedit_stub.def tcpedit_opts.def + +include $(srcdir)/plugins/Makefile.am + diff --git a/src/tcpedit/Makefile.in b/src/tcpedit/Makefile.in new file mode 100644 index 0000000..38cc0c1 --- /dev/null +++ b/src/tcpedit/Makefile.in @@ -0,0 +1,950 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# $Id: Makefile.am 1630 2007-02-03 04:23:14Z aturner $ +#SUBDIRS = plugins + +# $Id: $ + +# $Id: Makefile.am 1830 2007-04-21 07:33:54Z aturner $ +# START OF: dlt_en10mb +# Note, if you add any files to your plugin, you will need to edit dlt_/Makefile.am +# add your .c files to libdltplugin_a_SOURCES +# add your .h files to noinst_HEADERS +# add any other files (like documentation, notes, etc) to EXTRA_DIST +# add your dependancy information (see comment below) + +# $Id: Makefile.am 1830 2007-04-21 07:33:54Z aturner $ +# START OF: dlt_hdlc +# Note, if you add any files to your plugin, you will need to edit dlt_/Makefile.am +# add your .c files to libtcpedit_a_SOURCES +# add your .h files to noinst_HEADERS +# add any other files (like documentation, notes, etc) to EXTRA_DIST +# add your dependancy information (see comment below) + +# $Id: Makefile.am 1830 2007-04-21 07:33:54Z aturner $ +# START OF: dlt_user +# Note, if you add any files to your plugin, you will need to edit dlt_/Makefile.am +# add your .c files to libtcpedit_a_SOURCES +# add your .h files to noinst_HEADERS +# add any other files (like documentation, notes, etc) to EXTRA_DIST +# add your dependancy information (see comment below) + +# $Id: Makefile.am 1830 2007-04-21 07:33:54Z aturner $ +# START OF: dlt_raw +# Note, if you add any files to your plugin, you will need to edit dlt_/Makefile.am +# add your .c files to libtcpedit_a_SOURCES +# add your .h files to noinst_HEADERS +# add any other files (like documentation, notes, etc) to EXTRA_DIST +# add your dependancy information (see comment below) + +# $Id: Makefile.am 1830 2007-04-21 07:33:54Z aturner $ +# START OF: dlt_null +# Note, if you add any files to your plugin, you will need to edit dlt_/Makefile.am +# add your .c files to libtcpedit_a_SOURCES +# add your .h files to noinst_HEADERS +# add any other files (like documentation, notes, etc) to EXTRA_DIST +# add your dependancy information (see comment below) + +# $Id: Makefile.am 1830 2007-04-21 07:33:54Z aturner $ +# START OF: dlt_loop +# Note, if you add any files to your plugin, you will need to edit dlt_/Makefile.am +# add your .c files to libtcpedit_a_SOURCES +# add your .h files to noinst_HEADERS +# add any other files (like documentation, notes, etc) to EXTRA_DIST +# add your dependancy information (see comment below) + +# $Id: Makefile.am 1830 2007-04-21 07:33:54Z aturner $ +# START OF: dlt_linuxsll +# Note, if you add any files to your plugin, you will need to edit dlt_/Makefile.am +# add your .c files to libtcpedit_a_SOURCES +# add your .h files to noinst_HEADERS +# add any other files (like documentation, notes, etc) to EXTRA_DIST +# add your dependancy information (see comment below) + +# $Id: Makefile.am 1838 2007-04-22 18:23:38Z aturner $ +# START OF: dlt_ieee80211 +# Note, if you add any files to your plugin, you will need to edit dlt_ieee80211/Makefile.am +# add your .c files to libtcpedit_a_SOURCES +# add your .h files to noinst_HEADERS +# add any other files (like documentation, notes, etc) to EXTRA_DIST +# add your dependancy information (see comment below) + +# $Id: Makefile.am 1869 2007-05-12 19:53:15Z aturner $ +# START OF: dlt_radiotap +# Note, if you add any files to your plugin, you will need to edit dlt_radiotap/Makefile.am +# add your .c files to libtcpedit_a_SOURCES +# add your .h files to noinst_HEADERS +# add any other files (like documentation, notes, etc) to EXTRA_DIST +# add your dependancy information (see comment below) + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(srcdir)/plugins/Makefile.am \ + $(srcdir)/plugins/dlt_en10mb/Makefile.am \ + $(srcdir)/plugins/dlt_hdlc/Makefile.am \ + $(srcdir)/plugins/dlt_ieee80211/Makefile.am \ + $(srcdir)/plugins/dlt_linuxsll/Makefile.am \ + $(srcdir)/plugins/dlt_loop/Makefile.am \ + $(srcdir)/plugins/dlt_null/Makefile.am \ + $(srcdir)/plugins/dlt_radiotap/Makefile.am \ + $(srcdir)/plugins/dlt_raw/Makefile.am \ + $(srcdir)/plugins/dlt_user/Makefile.am +subdir = src/tcpedit +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/src/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +LIBRARIES = $(noinst_LIBRARIES) +ARFLAGS = cru +libtcpedit_a_AR = $(AR) $(ARFLAGS) +libtcpedit_a_LIBADD = +am_libtcpedit_a_OBJECTS = tcpedit.$(OBJEXT) parse_args.$(OBJEXT) \ + edit_packet.$(OBJEXT) portmap.$(OBJEXT) dlt.$(OBJEXT) \ + checksum.$(OBJEXT) dlt_plugins.$(OBJEXT) ethernet.$(OBJEXT) \ + dlt_utils.$(OBJEXT) en10mb.$(OBJEXT) hdlc.$(OBJEXT) \ + user.$(OBJEXT) raw.$(OBJEXT) null.$(OBJEXT) loop.$(OBJEXT) \ + linuxsll.$(OBJEXT) ieee80211.$(OBJEXT) ieee80211_hdr.$(OBJEXT) \ + radiotap.$(OBJEXT) +libtcpedit_a_OBJECTS = $(am_libtcpedit_a_OBJECTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src +depcomp = $(SHELL) $(top_srcdir)/config/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libtcpedit_a_SOURCES) +DIST_SOURCES = $(libtcpedit_a_SOURCES) +HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOGEN = @AUTOGEN@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CUT = @CUT@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DMALLOC_LIB = @DMALLOC_LIB@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +GROFF = @GROFF@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LDNETINC = @LDNETINC@ +LDNETLIB = @LDNETLIB@ +LIBOBJS = @LIBOBJS@ +LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@ +LIBOPTS_DIR = @LIBOPTS_DIR@ +LIBOPTS_LDADD = @LIBOPTS_LDADD@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LNAVLIB = @LNAVLIB@ +LNAV_CFLAGS = @LNAV_CFLAGS@ +LN_S = @LN_S@ +LPCAPINC = @LPCAPINC@ +LPCAPLIB = @LPCAPLIB@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@ +PRINTF = @PRINTF@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TCPREPLAY_RELEASE = @TCPREPLAY_RELEASE@ +TCPREPLAY_VERSION = @TCPREPLAY_VERSION@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +debug_flag = @debug_flag@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +nic1 = @nic1@ +nic2 = @nic2@ +oldincludedir = @oldincludedir@ +pcncfg = @pcncfg@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +tcpdump_path = @tcpdump_path@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +noinst_LIBRARIES = libtcpedit.a +BUILT_SOURCES = tcpedit_stub.h +libtcpedit_a_SOURCES = tcpedit.c parse_args.c edit_packet.c portmap.c \ + dlt.c checksum.c $(srcdir)/plugins/dlt_plugins.c \ + $(srcdir)/plugins/ethernet.c $(srcdir)/plugins/dlt_utils.c \ + $(srcdir)/plugins/dlt_en10mb/en10mb.c \ + $(srcdir)/plugins/dlt_hdlc/hdlc.c \ + $(srcdir)/plugins/dlt_user/user.c \ + $(srcdir)/plugins/dlt_raw/raw.c \ + $(srcdir)/plugins/dlt_null/null.c \ + $(srcdir)/plugins/dlt_loop/loop.c \ + $(srcdir)/plugins/dlt_linuxsll/linuxsll.c \ + $(srcdir)/plugins/dlt_ieee80211/ieee80211.c \ + $(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c \ + $(srcdir)/plugins/dlt_radiotap/radiotap.c +AM_CFLAGS = -I.. -I../common -I../.. @LDNETINC@ $(LIBOPTS_CFLAGS) \ + $(LNAV_CFLAGS) -I. -I$(srcdir)/plugins -I$(srcdir)/../common \ + $(LIBOPTS_CFLAGS) +noinst_HEADERS = tcpedit.h edit_packet.h portmap.h tcpedit_stub.h \ + parse_args.h dlt.h checksum.h tcpedit-int.h \ + $(srcdir)/plugins/dlt_plugins.h $(srcdir)/plugins/ethernet.h \ + $(srcdir)/plugins/dlt_utils.h \ + $(srcdir)/plugins/dlt_plugins-int.h \ + $(srcdir)/plugins/dlt_en10mb/en10mb.h \ + $(srcdir)/plugins/dlt_hdlc/hdlc.h \ + $(srcdir)/plugins/dlt_user/user.h \ + $(srcdir)/plugins/dlt_raw/raw.h \ + $(srcdir)/plugins/dlt_null/null.h \ + $(srcdir)/plugins/dlt_loop/loop.h \ + $(srcdir)/plugins/dlt_linuxsll/linuxsll.h \ + $(srcdir)/plugins/dlt_ieee80211/ieee80211.h \ + $(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.h \ + $(srcdir)/plugins/dlt_radiotap/radiotap.h + +# You probably don't want to touch anything below this line until the end of the plugin +MOSTLYCLEANFILES = *~ $(srcdir)/plugins/*~ \ + $(srcdir)/plugins/dlt_en10mb/*~ $(srcdir)/plugins/dlt_hdlc/*~ \ + $(srcdir)/plugins/dlt_user/*~ $(srcdir)/plugins/dlt_raw/*~ \ + $(srcdir)/plugins/dlt_null/*~ $(srcdir)/plugins/dlt_loop/*~ \ + $(srcdir)/plugins/dlt_linuxsll/*~ \ + $(srcdir)/plugins/dlt_ieee80211/*~ \ + $(srcdir)/plugins/dlt_radiotap/*~ +MAINTAINERCLEANFILES = Makefile.in tcpedit_stub.h tcpedit.1 \ + Makefile.in +EXTRA_DIST = tcpedit_stub.def tcpedit_opts.def \ + $(srcdir)/plugins/dlt_opts.def $(srcdir)/plugins/dlt_stub.def \ + $(srcdir)/plugins/dlt_en10mb/en10mb_opts.def \ + $(srcdir)/plugins/dlt_hdlc/hdlc_opts.def \ + $(srcdir)/plugins/dlt_user/user_opts.def \ + $(srcdir)/plugins/dlt_raw/raw_opts.def \ + $(srcdir)/plugins/dlt_null/null_opts.def \ + $(srcdir)/plugins/dlt_loop/loop_opts.def \ + $(srcdir)/plugins/dlt_linuxsll/linuxsll_opts.def \ + $(srcdir)/plugins/dlt_ieee80211/ieee80211_opts.def \ + $(srcdir)/plugins/dlt_radiotap/radiotap_opts.def + +# Note: +# You probably don't want to touch anything below this line until the end of the plugin + +# You probably don't want to touch anything below this line until the end of the plugin + +# You probably don't want to touch anything below this line until the end of the plugin + +# You probably don't want to touch anything below this line until the end of the plugin + +# You probably don't want to touch anything below this line until the end of the plugin + +# You probably don't want to touch anything below this line until the end of the plugin + +# You probably don't want to touch anything below this line until the end of the plugin + +# You probably don't want to touch anything below this line until the end of the plugin +DLT_STUB_DEPS = $(srcdir)/plugins/dlt_opts.def \ + $(srcdir)/plugins/dlt_en10mb/en10mb_opts.def \ + $(srcdir)/plugins/dlt_user/user_opts.def \ + $(srcdir)/plugins/dlt_raw/raw_opts.def \ + $(srcdir)/plugins/dlt_null/null_opts.def \ + $(srcdir)/plugins/dlt_loop/loop_opts.def \ + $(srcdir)/plugins/dlt_linuxsll/linuxsll_opts.def \ + $(srcdir)/plugins/dlt_ieee80211/ieee80211_opts.def \ + $(srcdir)/plugins/dlt_radiotap/radiotap_opts.def +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/plugins/Makefile.am $(srcdir)/plugins/dlt_en10mb/Makefile.am $(srcdir)/plugins/dlt_hdlc/Makefile.am $(srcdir)/plugins/dlt_user/Makefile.am $(srcdir)/plugins/dlt_raw/Makefile.am $(srcdir)/plugins/dlt_null/Makefile.am $(srcdir)/plugins/dlt_loop/Makefile.am $(srcdir)/plugins/dlt_linuxsll/Makefile.am $(srcdir)/plugins/dlt_ieee80211/Makefile.am $(srcdir)/plugins/dlt_radiotap/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/tcpedit/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu src/tcpedit/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *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);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +libtcpedit.a: $(libtcpedit_a_OBJECTS) $(libtcpedit_a_DEPENDENCIES) + -rm -f libtcpedit.a + $(libtcpedit_a_AR) libtcpedit.a $(libtcpedit_a_OBJECTS) $(libtcpedit_a_LIBADD) + $(RANLIB) libtcpedit.a + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +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)/dlt_plugins.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dlt_utils.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edit_packet.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/en10mb.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ethernet.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hdlc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ieee80211.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ieee80211_hdr.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linuxsll.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loop.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/null.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse_args.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/portmap.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/radiotap.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/raw.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpedit.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/user.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +dlt_plugins.o: $(srcdir)/plugins/dlt_plugins.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT dlt_plugins.o -MD -MP -MF $(DEPDIR)/dlt_plugins.Tpo -c -o dlt_plugins.o `test -f '$(srcdir)/plugins/dlt_plugins.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_plugins.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/dlt_plugins.Tpo $(DEPDIR)/dlt_plugins.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/plugins/dlt_plugins.c' object='dlt_plugins.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o dlt_plugins.o `test -f '$(srcdir)/plugins/dlt_plugins.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_plugins.c + +dlt_plugins.obj: $(srcdir)/plugins/dlt_plugins.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT dlt_plugins.obj -MD -MP -MF $(DEPDIR)/dlt_plugins.Tpo -c -o dlt_plugins.obj `if test -f '$(srcdir)/plugins/dlt_plugins.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_plugins.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_plugins.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/dlt_plugins.Tpo $(DEPDIR)/dlt_plugins.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/plugins/dlt_plugins.c' object='dlt_plugins.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o dlt_plugins.obj `if test -f '$(srcdir)/plugins/dlt_plugins.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_plugins.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_plugins.c'; fi` + +ethernet.o: $(srcdir)/plugins/ethernet.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ethernet.o -MD -MP -MF $(DEPDIR)/ethernet.Tpo -c -o ethernet.o `test -f '$(srcdir)/plugins/ethernet.c' || echo '$(srcdir)/'`$(srcdir)/plugins/ethernet.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/ethernet.Tpo $(DEPDIR)/ethernet.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/plugins/ethernet.c' object='ethernet.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ethernet.o `test -f '$(srcdir)/plugins/ethernet.c' || echo '$(srcdir)/'`$(srcdir)/plugins/ethernet.c + +ethernet.obj: $(srcdir)/plugins/ethernet.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ethernet.obj -MD -MP -MF $(DEPDIR)/ethernet.Tpo -c -o ethernet.obj `if test -f '$(srcdir)/plugins/ethernet.c'; then $(CYGPATH_W) '$(srcdir)/plugins/ethernet.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/ethernet.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/ethernet.Tpo $(DEPDIR)/ethernet.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/plugins/ethernet.c' object='ethernet.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ethernet.obj `if test -f '$(srcdir)/plugins/ethernet.c'; then $(CYGPATH_W) '$(srcdir)/plugins/ethernet.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/ethernet.c'; fi` + +dlt_utils.o: $(srcdir)/plugins/dlt_utils.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT dlt_utils.o -MD -MP -MF $(DEPDIR)/dlt_utils.Tpo -c -o dlt_utils.o `test -f '$(srcdir)/plugins/dlt_utils.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_utils.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/dlt_utils.Tpo $(DEPDIR)/dlt_utils.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/plugins/dlt_utils.c' object='dlt_utils.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o dlt_utils.o `test -f '$(srcdir)/plugins/dlt_utils.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_utils.c + +dlt_utils.obj: $(srcdir)/plugins/dlt_utils.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT dlt_utils.obj -MD -MP -MF $(DEPDIR)/dlt_utils.Tpo -c -o dlt_utils.obj `if test -f '$(srcdir)/plugins/dlt_utils.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_utils.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_utils.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/dlt_utils.Tpo $(DEPDIR)/dlt_utils.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/plugins/dlt_utils.c' object='dlt_utils.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o dlt_utils.obj `if test -f '$(srcdir)/plugins/dlt_utils.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_utils.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_utils.c'; fi` + +en10mb.o: $(srcdir)/plugins/dlt_en10mb/en10mb.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT en10mb.o -MD -MP -MF $(DEPDIR)/en10mb.Tpo -c -o en10mb.o `test -f '$(srcdir)/plugins/dlt_en10mb/en10mb.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_en10mb/en10mb.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/en10mb.Tpo $(DEPDIR)/en10mb.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/plugins/dlt_en10mb/en10mb.c' object='en10mb.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o en10mb.o `test -f '$(srcdir)/plugins/dlt_en10mb/en10mb.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_en10mb/en10mb.c + +en10mb.obj: $(srcdir)/plugins/dlt_en10mb/en10mb.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT en10mb.obj -MD -MP -MF $(DEPDIR)/en10mb.Tpo -c -o en10mb.obj `if test -f '$(srcdir)/plugins/dlt_en10mb/en10mb.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_en10mb/en10mb.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_en10mb/en10mb.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/en10mb.Tpo $(DEPDIR)/en10mb.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/plugins/dlt_en10mb/en10mb.c' object='en10mb.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o en10mb.obj `if test -f '$(srcdir)/plugins/dlt_en10mb/en10mb.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_en10mb/en10mb.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_en10mb/en10mb.c'; fi` + +hdlc.o: $(srcdir)/plugins/dlt_hdlc/hdlc.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hdlc.o -MD -MP -MF $(DEPDIR)/hdlc.Tpo -c -o hdlc.o `test -f '$(srcdir)/plugins/dlt_hdlc/hdlc.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_hdlc/hdlc.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/hdlc.Tpo $(DEPDIR)/hdlc.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/plugins/dlt_hdlc/hdlc.c' object='hdlc.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hdlc.o `test -f '$(srcdir)/plugins/dlt_hdlc/hdlc.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_hdlc/hdlc.c + +hdlc.obj: $(srcdir)/plugins/dlt_hdlc/hdlc.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT hdlc.obj -MD -MP -MF $(DEPDIR)/hdlc.Tpo -c -o hdlc.obj `if test -f '$(srcdir)/plugins/dlt_hdlc/hdlc.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_hdlc/hdlc.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_hdlc/hdlc.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/hdlc.Tpo $(DEPDIR)/hdlc.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/plugins/dlt_hdlc/hdlc.c' object='hdlc.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o hdlc.obj `if test -f '$(srcdir)/plugins/dlt_hdlc/hdlc.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_hdlc/hdlc.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_hdlc/hdlc.c'; fi` + +user.o: $(srcdir)/plugins/dlt_user/user.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT user.o -MD -MP -MF $(DEPDIR)/user.Tpo -c -o user.o `test -f '$(srcdir)/plugins/dlt_user/user.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_user/user.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/user.Tpo $(DEPDIR)/user.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/plugins/dlt_user/user.c' object='user.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o user.o `test -f '$(srcdir)/plugins/dlt_user/user.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_user/user.c + +user.obj: $(srcdir)/plugins/dlt_user/user.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT user.obj -MD -MP -MF $(DEPDIR)/user.Tpo -c -o user.obj `if test -f '$(srcdir)/plugins/dlt_user/user.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_user/user.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_user/user.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/user.Tpo $(DEPDIR)/user.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/plugins/dlt_user/user.c' object='user.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o user.obj `if test -f '$(srcdir)/plugins/dlt_user/user.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_user/user.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_user/user.c'; fi` + +raw.o: $(srcdir)/plugins/dlt_raw/raw.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT raw.o -MD -MP -MF $(DEPDIR)/raw.Tpo -c -o raw.o `test -f '$(srcdir)/plugins/dlt_raw/raw.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_raw/raw.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/raw.Tpo $(DEPDIR)/raw.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/plugins/dlt_raw/raw.c' object='raw.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o raw.o `test -f '$(srcdir)/plugins/dlt_raw/raw.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_raw/raw.c + +raw.obj: $(srcdir)/plugins/dlt_raw/raw.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT raw.obj -MD -MP -MF $(DEPDIR)/raw.Tpo -c -o raw.obj `if test -f '$(srcdir)/plugins/dlt_raw/raw.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_raw/raw.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_raw/raw.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/raw.Tpo $(DEPDIR)/raw.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/plugins/dlt_raw/raw.c' object='raw.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o raw.obj `if test -f '$(srcdir)/plugins/dlt_raw/raw.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_raw/raw.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_raw/raw.c'; fi` + +null.o: $(srcdir)/plugins/dlt_null/null.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT null.o -MD -MP -MF $(DEPDIR)/null.Tpo -c -o null.o `test -f '$(srcdir)/plugins/dlt_null/null.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_null/null.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/null.Tpo $(DEPDIR)/null.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/plugins/dlt_null/null.c' object='null.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o null.o `test -f '$(srcdir)/plugins/dlt_null/null.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_null/null.c + +null.obj: $(srcdir)/plugins/dlt_null/null.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT null.obj -MD -MP -MF $(DEPDIR)/null.Tpo -c -o null.obj `if test -f '$(srcdir)/plugins/dlt_null/null.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_null/null.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_null/null.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/null.Tpo $(DEPDIR)/null.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/plugins/dlt_null/null.c' object='null.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o null.obj `if test -f '$(srcdir)/plugins/dlt_null/null.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_null/null.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_null/null.c'; fi` + +loop.o: $(srcdir)/plugins/dlt_loop/loop.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT loop.o -MD -MP -MF $(DEPDIR)/loop.Tpo -c -o loop.o `test -f '$(srcdir)/plugins/dlt_loop/loop.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_loop/loop.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/loop.Tpo $(DEPDIR)/loop.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/plugins/dlt_loop/loop.c' object='loop.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o loop.o `test -f '$(srcdir)/plugins/dlt_loop/loop.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_loop/loop.c + +loop.obj: $(srcdir)/plugins/dlt_loop/loop.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT loop.obj -MD -MP -MF $(DEPDIR)/loop.Tpo -c -o loop.obj `if test -f '$(srcdir)/plugins/dlt_loop/loop.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_loop/loop.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_loop/loop.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/loop.Tpo $(DEPDIR)/loop.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/plugins/dlt_loop/loop.c' object='loop.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o loop.obj `if test -f '$(srcdir)/plugins/dlt_loop/loop.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_loop/loop.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_loop/loop.c'; fi` + +linuxsll.o: $(srcdir)/plugins/dlt_linuxsll/linuxsll.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT linuxsll.o -MD -MP -MF $(DEPDIR)/linuxsll.Tpo -c -o linuxsll.o `test -f '$(srcdir)/plugins/dlt_linuxsll/linuxsll.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_linuxsll/linuxsll.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/linuxsll.Tpo $(DEPDIR)/linuxsll.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/plugins/dlt_linuxsll/linuxsll.c' object='linuxsll.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o linuxsll.o `test -f '$(srcdir)/plugins/dlt_linuxsll/linuxsll.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_linuxsll/linuxsll.c + +linuxsll.obj: $(srcdir)/plugins/dlt_linuxsll/linuxsll.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT linuxsll.obj -MD -MP -MF $(DEPDIR)/linuxsll.Tpo -c -o linuxsll.obj `if test -f '$(srcdir)/plugins/dlt_linuxsll/linuxsll.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_linuxsll/linuxsll.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_linuxsll/linuxsll.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/linuxsll.Tpo $(DEPDIR)/linuxsll.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/plugins/dlt_linuxsll/linuxsll.c' object='linuxsll.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o linuxsll.obj `if test -f '$(srcdir)/plugins/dlt_linuxsll/linuxsll.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_linuxsll/linuxsll.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_linuxsll/linuxsll.c'; fi` + +ieee80211.o: $(srcdir)/plugins/dlt_ieee80211/ieee80211.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ieee80211.o -MD -MP -MF $(DEPDIR)/ieee80211.Tpo -c -o ieee80211.o `test -f '$(srcdir)/plugins/dlt_ieee80211/ieee80211.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_ieee80211/ieee80211.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/ieee80211.Tpo $(DEPDIR)/ieee80211.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/plugins/dlt_ieee80211/ieee80211.c' object='ieee80211.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ieee80211.o `test -f '$(srcdir)/plugins/dlt_ieee80211/ieee80211.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_ieee80211/ieee80211.c + +ieee80211.obj: $(srcdir)/plugins/dlt_ieee80211/ieee80211.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ieee80211.obj -MD -MP -MF $(DEPDIR)/ieee80211.Tpo -c -o ieee80211.obj `if test -f '$(srcdir)/plugins/dlt_ieee80211/ieee80211.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_ieee80211/ieee80211.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_ieee80211/ieee80211.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/ieee80211.Tpo $(DEPDIR)/ieee80211.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/plugins/dlt_ieee80211/ieee80211.c' object='ieee80211.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ieee80211.obj `if test -f '$(srcdir)/plugins/dlt_ieee80211/ieee80211.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_ieee80211/ieee80211.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_ieee80211/ieee80211.c'; fi` + +ieee80211_hdr.o: $(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ieee80211_hdr.o -MD -MP -MF $(DEPDIR)/ieee80211_hdr.Tpo -c -o ieee80211_hdr.o `test -f '$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/ieee80211_hdr.Tpo $(DEPDIR)/ieee80211_hdr.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c' object='ieee80211_hdr.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ieee80211_hdr.o `test -f '$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c + +ieee80211_hdr.obj: $(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ieee80211_hdr.obj -MD -MP -MF $(DEPDIR)/ieee80211_hdr.Tpo -c -o ieee80211_hdr.obj `if test -f '$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/ieee80211_hdr.Tpo $(DEPDIR)/ieee80211_hdr.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c' object='ieee80211_hdr.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ieee80211_hdr.obj `if test -f '$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c'; fi` + +radiotap.o: $(srcdir)/plugins/dlt_radiotap/radiotap.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT radiotap.o -MD -MP -MF $(DEPDIR)/radiotap.Tpo -c -o radiotap.o `test -f '$(srcdir)/plugins/dlt_radiotap/radiotap.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_radiotap/radiotap.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/radiotap.Tpo $(DEPDIR)/radiotap.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/plugins/dlt_radiotap/radiotap.c' object='radiotap.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o radiotap.o `test -f '$(srcdir)/plugins/dlt_radiotap/radiotap.c' || echo '$(srcdir)/'`$(srcdir)/plugins/dlt_radiotap/radiotap.c + +radiotap.obj: $(srcdir)/plugins/dlt_radiotap/radiotap.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT radiotap.obj -MD -MP -MF $(DEPDIR)/radiotap.Tpo -c -o radiotap.obj `if test -f '$(srcdir)/plugins/dlt_radiotap/radiotap.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_radiotap/radiotap.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_radiotap/radiotap.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/radiotap.Tpo $(DEPDIR)/radiotap.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/plugins/dlt_radiotap/radiotap.c' object='radiotap.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o radiotap.obj `if test -f '$(srcdir)/plugins/dlt_radiotap/radiotap.c'; then $(CYGPATH_W) '$(srcdir)/plugins/dlt_radiotap/radiotap.c'; else $(CYGPATH_W) '$(srcdir)/$(srcdir)/plugins/dlt_radiotap/radiotap.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am +all-am: Makefile $(LIBRARIES) $(HEADERS) +installdirs: +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: all check install install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLIBRARIES ctags 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 uninstall uninstall-am + + +manpages: tcpedit.1 + +tcpedit.1: tcpedit_stub.def + @AUTOGEN@ -T agman1.tpl --base-name tcpedit tcpedit_stub.def + +tcpedit.c: tcpedit_stub.h + +# Get AutoOpts search path +#opts_list=`find plugins -type d -not -regex ".*\.svn.*" -not -regex ".*\.deps.*" -exec echo -n "-L {} " \;` + +tcpedit_stub.h: tcpedit_opts.def tcpedit_stub.def $(srcdir)/plugins/dlt_stub.def + @AUTOGEN@ $(opts_list) tcpedit_stub.def + +$(srcdir)/plugins/dlt_stub.def: $(DLT_STUB_DEPS) + +# dependancies for your plugin source code. Edit as necessary +$(srcdir)/plugins/dlt_en10mb/en10mb.c: $(srcdir)/tcpedit_stub.h $(srcdir)/plugins/dlt_utils.h \ + $(srcdir)/plugins/dlt_en10mb/en10mb.h $(srcdir)/plugins/dlt_plugins.h $(srcdir)/plugins/dlt_plugins-int.h + +# END OF: dlt_en10mb + +# dependancies for your plugin source code. Edit as necessary +$(srcdir)/plugins/dlt_hdlc/hdlc.c: $(srcdir)/tcpedit_stub.h $(srcdir)/plugins/dlt_utils.h \ + $(srcdir)/plugins/dlt_hdlc/hdlc.h $(srcdir)/plugins/dlt_plugins.h $(srcdir)/plugins/dlt_plugins-int.h + +# END OF: dlt_hdlc + +# dependancies for your plugin source code. Edit as necessary +$(srcdir)/plugins/dlt_user/user.c: $(srcdir)/tcpedit_stub.h $(srcdir)/plugins/dlt_utils.h \ + $(srcdir)/plugins/dlt_user/user.h $(srcdir)/plugins/dlt_plugins.h $(srcdir)/plugins/dlt_plugins-int.h + +# END OF: dlt_user + +# dependancies for your plugin source code. Edit as necessary +$(srcdir)/plugins/dlt_raw/raw.c: $(srcdir)/tcpedit_stub.h $(srcdir)/plugins/dlt_utils.h \ + $(srcdir)/plugins/dlt_raw/raw.h $(srcdir)/plugins/dlt_plugins.h $(srcdir)/plugins/dlt_plugins-int.h + +# END OF: dlt_raw + +# dependancies for your plugin source code. Edit as necessary +$(srcdir)/plugins/dlt_null/null.c: $(srcdir)/tcpedit_stub.h $(srcdir)/plugins/dlt_utils.h \ + $(srcdir)/plugins/dlt_null/null.h $(srcdir)/plugins/dlt_plugins.h $(srcdir)/plugins/dlt_plugins-int.h + +# END OF: dlt_null + +# dependancies for your plugin source code. Edit as necessary +$(srcdir)/plugins/dlt_loop/loop.c: $(srcdir)/tcpedit_stub.h $(srcdir)/plugins/dlt_utils.h \ + $(srcdir)/plugins/dlt_loop/loop.h $(srcdir)/plugins/dlt_plugins.h $(srcdir)/plugins/dlt_plugins-int.h + +# END OF: dlt_loop + +# dependancies for your plugin source code. Edit as necessary +$(srcdir)/plugins/dlt_linuxsll/linuxsll.c: $(srcdir)/tcpedit_stub.h $(srcdir)/plugins/dlt_utils.h \ + $(srcdir)/plugins/dlt_linuxsll/linuxsll.h $(srcdir)/plugins/dlt_plugins.h $(srcdir)/plugins/dlt_plugins-int.h + +# END OF: dlt_linuxsll + +# dependancies for your plugin source code. Edit as necessary +$(srcdir)/plugins/dlt_ieee80211/ieee80211.c: $(srcdir)/tcpedit_stub.h $(srcdir)/plugins/dlt_utils.h \ + $(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c $(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.h \ + $(srcdir)/plugins/dlt_ieee80211/ieee80211.h $(srcdir)/plugins/dlt_plugins.h $(srcdir)/plugins/dlt_plugins-int.h + +# END OF: dlt_ieee80211 + +# dependancies for your plugin source code. Edit as necessary +$(srcdir)/plugins/dlt_radiotap/radiotap.c: $(srcdir)/tcpedit_stub.h $(srcdir)/plugins/dlt_utils.h \ + $(srcdir)/plugins/dlt_radiotap/radiotap.h $(srcdir)/plugins/dlt_plugins.h $(srcdir)/plugins/dlt_plugins-int.h + +# END OF: dlt_radiotap + +######################################################## +# Add your plugin Makefile.am's below this line +######################################################## + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/tcpedit/checksum.c b/src/tcpedit/checksum.c new file mode 100644 index 0000000..23c73dc --- /dev/null +++ b/src/tcpedit/checksum.c @@ -0,0 +1,191 @@ +/* $Id: checksum.c 2423 2010-03-13 07:09:49Z aturner $ */ +/* + * Copyright (c) 2006-2010 Aaron Turner. + * Copyright (c) 1998 - 2004 Mike D. Schiffman + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This code is heavily based on (some might even say stolen from) Mike Shiffman's + * checksumming code from Libnet 1.1.3 + */ + +#include "config.h" +#include "tcpedit-int.h" +#include "checksum.h" + +static int do_checksum_math(u_int16_t *, int); + + +/** + * Returns -1 on error and 0 on success, 1 on warn + */ +int +do_checksum(tcpedit_t *tcpedit, u_int8_t *data, int proto, int len) { + ipv4_hdr_t *ipv4; + ipv6_hdr_t *ipv6; + tcp_hdr_t *tcp; + udp_hdr_t *udp; + icmpv4_hdr_t *icmp; + icmpv6_hdr_t *icmp6; + int ip_hl; + int sum; + + sum = 0; + ipv4 = NULL; + ipv6 = NULL; + assert(data); + + if (len <= 0) { + tcpedit_seterr(tcpedit, "%s", "length of data must be > 0"); + return TCPEDIT_ERROR; + } + + ipv4 = (ipv4_hdr_t *)data; + if (ipv4->ip_v == 6) { + ipv6 = (ipv6_hdr_t *)data; + ipv4 = NULL; + + proto = get_ipv6_l4proto(ipv6); + dbgx(3, "layer4 proto is 0x%hhu", proto); + + ip_hl = (u_char*)get_layer4_v6(ipv6) - (u_char*)data; + dbgx(3, "ip_hl proto is 0x%d", ip_hl); + + len -= (ip_hl - TCPR_IPV6_H); + } else { + ip_hl = ipv4->ip_hl << 2; + } + + switch (proto) { + + case IPPROTO_TCP: + tcp = (tcp_hdr_t *)(data + ip_hl); +#ifdef STUPID_SOLARIS_CHECKSUM_BUG + tcp->th_sum = tcp->th_off << 2; + return (TCPEDIT_OK); +#endif + tcp->th_sum = 0; + + /* Note, we do both src & dst IP's at the same time, that's why the + * length is 2x a single IP + */ + if (ipv6 != NULL) { + sum = do_checksum_math((u_int16_t *)&ipv6->ip_src, 32); + } else { + sum = do_checksum_math((u_int16_t *)&ipv4->ip_src, 8); + } + sum += ntohs(IPPROTO_TCP + len); + sum += do_checksum_math((u_int16_t *)tcp, len); + tcp->th_sum = CHECKSUM_CARRY(sum); + break; + + case IPPROTO_UDP: + udp = (udp_hdr_t *)(data + ip_hl); + udp->uh_sum = 0; + if (ipv6 != NULL) { + sum = do_checksum_math((u_int16_t *)&ipv6->ip_src, 32); + } else { + sum = do_checksum_math((u_int16_t *)&ipv4->ip_src, 8); + } + sum += ntohs(IPPROTO_UDP + len); + sum += do_checksum_math((u_int16_t *)udp, len); + udp->uh_sum = CHECKSUM_CARRY(sum); + break; + + case IPPROTO_ICMP: + icmp = (icmpv4_hdr_t *)(data + ip_hl); + icmp->icmp_sum = 0; + if (ipv6 != NULL) { + sum = do_checksum_math((u_int16_t *)&ipv6->ip_src, 32); + icmp->icmp_sum = CHECKSUM_CARRY(sum); + } + sum += do_checksum_math((u_int16_t *)icmp, len); + icmp->icmp_sum = CHECKSUM_CARRY(sum); + break; + + case IPPROTO_ICMP6: + icmp6 = (icmpv6_hdr_t *)(data + ip_hl); + icmp6->icmp_sum = 0; + if (ipv6 != NULL) { + sum = do_checksum_math((u_int16_t *)&ipv6->ip_src, 32); + } + sum += ntohs(IPPROTO_ICMP6 + len); + sum += do_checksum_math((u_int16_t *)icmp6, len); + icmp6->icmp_sum = CHECKSUM_CARRY(sum); + break; + + + case IPPROTO_IP: + ipv4->ip_sum = 0; + sum = do_checksum_math((u_int16_t *)data, ip_hl); + ipv4->ip_sum = CHECKSUM_CARRY(sum); + break; + + + case IPPROTO_IGMP: + case IPPROTO_GRE: + case IPPROTO_OSPF: + case IPPROTO_OSPF_LSA: + case IPPROTO_VRRP: + case TCPR_PROTO_CDP: + case TCPR_PROTO_ISL: + default: + tcpedit_setwarn(tcpedit, "Unsupported protocol for checksum: 0x%x", proto); + return TCPEDIT_WARN; + } + + return TCPEDIT_OK; +} + +/** + * code to do a ones-compliment checksum + */ +static int +do_checksum_math(u_int16_t *data, int len) +{ + int sum = 0; + union { + u_int16_t s; + u_int8_t b[2]; + } pad; + + while (len > 1) { + sum += *data++; + len -= 2; + } + + if (len == 1) { + pad.b[0] = *(u_int8_t *)data; + pad.b[1] = 0; + sum += pad.s; + } + + return (sum); +} + diff --git a/src/tcpedit/checksum.h b/src/tcpedit/checksum.h new file mode 100644 index 0000000..aef8a82 --- /dev/null +++ b/src/tcpedit/checksum.h @@ -0,0 +1,41 @@ +/* $Id: checksum.h 2423 2010-03-13 07:09:49Z aturner $ */ +/* + * Copyright (c) 2006-2010 Aaron Turner. + * Copyright (c) 1998 - 2004 Mike D. Schiffman + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _CHECKSUM_H_ +#define _CHECKSUM_H_ + +#define CHECKSUM_CARRY(x) \ + (x = (x >> 16) + (x & 0xffff), (~(x + (x >> 16)) & 0xffff)) + +int do_checksum(tcpedit_t *, u_int8_t *, int, int); + +#endif diff --git a/src/tcpedit/dlt.c b/src/tcpedit/dlt.c new file mode 100644 index 0000000..a6f15d0 --- /dev/null +++ b/src/tcpedit/dlt.c @@ -0,0 +1,171 @@ +/* $Id: dlt.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include +#include "config.h" +#include "defines.h" +#include "tcpedit-int.h" +#include "dlt.h" + +/** + * takes in a libpcap DLT_ type and returns the length of the layer2 header + * returns -1 for unsupported DLT + */ +int +dlt2layer2len(tcpedit_t *tcpedit, int dlt) +{ + assert(tcpedit); + int len; + switch(dlt) { + /* + case DLT_USER: + len = tcpedit->l2.len; + break; + */ + case DLT_NULL: + len = 2; + break; + + case DLT_RAW: + len = 0; + break; + + case DLT_EN10MB: + len = 12; + break; + /* + case DLT_VLAN: + len = 14; + break; + */ + case DLT_LINUX_SLL: + len = 16; + break; + + case DLT_C_HDLC: + len = 4; + break; + + default: + tcpedit_seterr(tcpedit, "Invalid DLT Type: %d", dlt); + len = -1; + } + + return len; +} + +/** + * each DLT type may require one or more user specified Layer 2 field + * to be able to rewrite it as plain ethernet DLT_EN10MB + * returns -1 on error or >= 0 on success + */ +int +dltrequires(tcpedit_t *tcpedit, int dlt) +{ + assert(tcpedit); + int req = TCPEDIT_DLT_OK; // no change required by default + + switch(dlt) { + case DLT_EN10MB: +/* case DLT_USER: + case DLT_VLAN: */ + /* we have everthing we need in the original packet */ + break; + + case DLT_NULL: + case DLT_RAW: + case DLT_C_HDLC: + req = TCPEDIT_DLT_SRC + TCPEDIT_DLT_DST; + /* we just have the proto */ + break; + + case DLT_LINUX_SLL: + /* we have proto & SRC address */ + req = TCPEDIT_DLT_DST; + break; + + default: + tcpedit_seterr(tcpedit, "Invalid DLT Type: %d", dlt); + req = -1; + } + + return req; +} + +/** + * returns the default MTU size for the given DLT type. Returns -1 + * for invalid DLT + */ +int +dlt2mtu(tcpedit_t *tcpedit, int dlt) +{ + int mtu; + assert(tcpedit); + switch (dlt) { +/* case DLT_VLAN: + case DLT_USER: */ + case DLT_EN10MB: + case DLT_RAW: + case DLT_C_HDLC: + mtu = 1500; + break; + + case DLT_LINUX_SLL: + mtu = 16436; + break; + + case DLT_LOOP: + mtu = 16384; + break; + + default: + tcpedit_seterr(tcpedit, "Invalid DLT Type: %d", dlt); + mtu = -1; + break; + } + + return mtu; +} + +/** + * Returns the current layer 2 len based on the + * DLT of the pcap or the --dlink value or -1 on error. + * You need to call this function AFTER rewriting the layer 2 header + * for it to be at all useful. + */ +int +layer2len(tcpedit_t *tcpedit) +{ + assert(tcpedit); + + return tcpedit->dlt_ctx->l2len; +} + diff --git a/src/tcpedit/dlt.h b/src/tcpedit/dlt.h new file mode 100644 index 0000000..abad26a --- /dev/null +++ b/src/tcpedit/dlt.h @@ -0,0 +1,51 @@ +/* $Id: dlt.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2004-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _DLT_H_ +#define _DLT_H_ + +#include "tcpedit.h" + +#define TCPEDIT_DLT_OK 0 +#define TCPEDIT_DLT_SRC 1 +#define TCPEDIT_DLT_DST 2 +#define TCPEDIT_DLT_PROTO 4 + + +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); + +#endif /* _DLT_H_ */ + + diff --git a/src/tcpedit/edit_packet.c b/src/tcpedit/edit_packet.c new file mode 100644 index 0000000..d5910a3 --- /dev/null +++ b/src/tcpedit/edit_packet.c @@ -0,0 +1,914 @@ +/* $Id: edit_packet.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "defines.h" +#include "common.h" + +#include "tcpedit-int.h" +#include "edit_packet.h" +#include "checksum.h" +#include "lib/sll.h" +#include "dlt.h" + +#include +#include +#include +#include +#include +#include + +static u_int32_t randomize_ipv4_addr(tcpedit_t *tcpedit, u_int32_t ip); +static u_int32_t remap_ipv4(tcpedit_t *tcpedit, tcpr_cidr_t *cidr, const u_int32_t original); +static int is_unicast_ipv4(tcpedit_t *tcpedit, u_int32_t ip); + +static void randomize_ipv6_addr(tcpedit_t *tcpedit, struct tcpr_in6_addr *addr); +static int remap_ipv6(tcpedit_t *tcpedit, tcpr_cidr_t *cidr, struct tcpr_in6_addr *addr); +static int is_multicast_ipv6(tcpedit_t *tcpedit, struct tcpr_in6_addr *addr); + +/** + * this code re-calcs the IP and Layer 4 checksums + * the IMPORTANT THING is that the Layer 4 header + * is contiguious in memory after *ip_hdr we're actually + * writing to the layer 4 header via the ip_hdr ptr. + * (Yes, this sucks, but that's the way libnet works, and + * I was too lazy to re-invent the wheel. + * Returns 0 on sucess, -1 on error + */ +int +fix_ipv4_checksums(tcpedit_t *tcpedit, struct pcap_pkthdr *pkthdr, ipv4_hdr_t *ip_hdr) +{ + int ret1 = 0, ret2 = 0; + assert(tcpedit); + assert(pkthdr); + assert(ip_hdr); + + + /* calc the L4 checksum if we have the whole packet && not a frag or first frag */ + if (pkthdr->caplen == pkthdr->len && (htons(ip_hdr->ip_off) & IP_OFFMASK) == 0) { + ret1 = do_checksum(tcpedit, (u_char *) ip_hdr, + ip_hdr->ip_p, ntohs(ip_hdr->ip_len) - (ip_hdr->ip_hl << 2)); + if (ret1 < 0) + return TCPEDIT_ERROR; + } + + /* calc IP checksum */ + ret2 = do_checksum(tcpedit, (u_char *) ip_hdr, IPPROTO_IP, ntohs(ip_hdr->ip_len)); + if (ret2 < 0) + return TCPEDIT_ERROR; + + /* what do we return? */ + if (ret1 == TCPEDIT_WARN || ret2 == TCPEDIT_WARN) + return TCPEDIT_WARN; + + return TCPEDIT_OK; +} + +int +fix_ipv6_checksums(tcpedit_t *tcpedit, struct pcap_pkthdr *pkthdr, ipv6_hdr_t *ip6_hdr) +{ + int ret = 0; + assert(tcpedit); + assert(pkthdr); + assert(ip6_hdr); + + + /* calc the L4 checksum if we have the whole packet && not a frag or first frag */ + if (pkthdr->caplen == pkthdr->len) { + ret = do_checksum(tcpedit, (u_char *) ip6_hdr, ip6_hdr->ip_nh, + htons(ip6_hdr->ip_len)); + if (ret < 0) + return TCPEDIT_ERROR; + } + + /* what do we return? */ + if (ret == TCPEDIT_WARN) + return TCPEDIT_WARN; + + return TCPEDIT_OK; +} + +/** + * returns a new 32bit integer which is the randomized IP + * based upon the user specified seed + */ +static u_int32_t +randomize_ipv4_addr(tcpedit_t *tcpedit, u_int32_t ip) +{ + assert(tcpedit); + + /* don't rewrite broadcast addresses */ + if (tcpedit->skip_broadcast && !is_unicast_ipv4(tcpedit, ip)) + return ip; + + return ((ip ^ htonl(tcpedit->seed)) - (ip & htonl(tcpedit->seed))); +} + +static void +randomize_ipv6_addr(tcpedit_t *tcpedit, struct tcpr_in6_addr *addr) +{ + u_int32_t *p; + int i; + u_char was_multicast; + + assert(tcpedit); + + p = &addr->__u6_addr.__u6_addr32[0]; + + was_multicast = is_multicast_ipv6(tcpedit, addr); + + for (i = 0; i < 4; ++i) { + p[i] = ((p[i] ^ htonl(tcpedit->seed)) - (p[i] & htonl(tcpedit->seed))); + } + + if (was_multicast) { + addr->tcpr_s6_addr[0] = 0xff; + } else if (is_multicast_ipv6(tcpedit, addr)) { + addr->tcpr_s6_addr[0] = 0xaa; + } +} + + +/** + * randomizes the source and destination IP addresses based on a + * pseudo-random number which is generated via the seed. + * return 1 since we changed one or more IP addresses + */ +int +randomize_ipv4(tcpedit_t *tcpedit, struct pcap_pkthdr *pkthdr, + u_char *pktdata, ipv4_hdr_t *ip_hdr) +{ +#ifdef DEBUG + char srcip[16], dstip[16]; +#endif + assert(tcpedit); + assert(pkthdr); + assert(pktdata); + assert(ip_hdr); + +#ifdef DEBUG + strlcpy(srcip, get_addr2name4(ip_hdr->ip_src.s_addr, RESOLVE), 16); + strlcpy(dstip, get_addr2name4(ip_hdr->ip_dst.s_addr, RESOLVE), 16); +#endif + + /* randomize IP addresses based on the value of random */ + dbgx(1, "Old Src IP: %s\tOld Dst IP: %s", srcip, dstip); + + /* don't rewrite broadcast addresses */ + if ((tcpedit->skip_broadcast && is_unicast_ipv4(tcpedit, (u_int32_t)ip_hdr->ip_dst.s_addr)) + || !tcpedit->skip_broadcast) { + ip_hdr->ip_dst.s_addr = randomize_ipv4_addr(tcpedit, ip_hdr->ip_dst.s_addr); + } + + if ((tcpedit->skip_broadcast && is_unicast_ipv4(tcpedit, (u_int32_t)ip_hdr->ip_src.s_addr)) + || !tcpedit->skip_broadcast) { + ip_hdr->ip_src.s_addr = randomize_ipv4_addr(tcpedit, ip_hdr->ip_src.s_addr); + } + +#ifdef DEBUG + strlcpy(srcip, get_addr2name4(ip_hdr->ip_src.s_addr, RESOLVE), 16); + strlcpy(dstip, get_addr2name4(ip_hdr->ip_dst.s_addr, RESOLVE), 16); +#endif + + dbgx(1, "New Src IP: %s\tNew Dst IP: %s\n", srcip, dstip); + + return(1); +} + +int +randomize_ipv6(tcpedit_t *tcpedit, struct pcap_pkthdr *pkthdr, + u_char *pktdata, ipv6_hdr_t *ip6_hdr) +{ +#ifdef DEBUG + char srcip[INET6_ADDRSTRLEN], dstip[INET6_ADDRSTRLEN]; +#endif + assert(tcpedit); + assert(pkthdr); + assert(pktdata); + assert(ip6_hdr); + +#ifdef DEBUG + strlcpy(srcip, get_addr2name6(&ip6_hdr->ip_src, RESOLVE), INET6_ADDRSTRLEN); + strlcpy(dstip, get_addr2name6(&ip6_hdr->ip_dst, RESOLVE), INET6_ADDRSTRLEN); +#endif + + /* randomize IP addresses based on the value of random */ + dbgx(1, "Old Src IP: %s\tOld Dst IP: %s", srcip, dstip); + + /* don't rewrite broadcast addresses */ + if ((tcpedit->skip_broadcast && !is_multicast_ipv6(tcpedit, &ip6_hdr->ip_dst)) + || !tcpedit->skip_broadcast) { + randomize_ipv6_addr(tcpedit, &ip6_hdr->ip_dst); + } + + if ((tcpedit->skip_broadcast && !is_multicast_ipv6(tcpedit, &ip6_hdr->ip_src)) + || !tcpedit->skip_broadcast) { + randomize_ipv6_addr(tcpedit, &ip6_hdr->ip_src); + } + +#ifdef DEBUG + strlcpy(srcip, get_addr2name6(&ip6_hdr->ip_src, RESOLVE), INET6_ADDRSTRLEN); + strlcpy(dstip, get_addr2name6(&ip6_hdr->ip_dst, RESOLVE), INET6_ADDRSTRLEN); +#endif + + dbgx(1, "New Src IP: %s\tNew Dst IP: %s\n", srcip, dstip); + + return(1); +} + +/** + * this code will untruncate a packet via padding it with null + * or resetting the actual IPv4 packet len to the snaplen - L2 header. + * return 0 if no change, 1 if change, -1 on error. + */ + +int +untrunc_packet(tcpedit_t *tcpedit, struct pcap_pkthdr *pkthdr, + u_char *pktdata, ipv4_hdr_t *ip_hdr, ipv6_hdr_t *ip6_hdr) +{ + int l2len; + assert(tcpedit); + assert(pkthdr); + assert(pktdata); + + /* if actual len == cap len or there's no IP header, don't do anything */ + if ((pkthdr->caplen == pkthdr->len) || (ip_hdr == NULL && ip6_hdr == NULL)) { + /* unless we're in MTU truncate mode */ + if (! tcpedit->mtu_truncate) + return(0); + } + + if ((l2len = layer2len(tcpedit)) < 0) { + tcpedit_seterr(tcpedit, "Non-sensical layer 2 length: %d", l2len); + return -1; + } + + /* Pad packet or truncate it */ + if (tcpedit->fixlen == TCPEDIT_FIXLEN_PAD) { + /* + * this should be an unnecessary check + * but I've gotten a report that sometimes the caplen > len + * which seems like a corrupted pcap + */ + if (pkthdr->len > pkthdr->caplen) { + memset(pktdata + pkthdr->caplen, '\0', pkthdr->len - pkthdr->caplen); + pkthdr->caplen = pkthdr->len; + } else if (pkthdr->len < pkthdr->caplen) { + /* i guess this is necessary if we've got a bogus pcap */ + //ip_hdr->ip_len = htons(pkthdr->caplen - l2len); + tcpedit_seterr(tcpedit, "%s", "WTF? Why is your packet larger then the capture len?"); + return -1; + } + } + else if (tcpedit->fixlen == TCPEDIT_FIXLEN_TRUNC) { + if (pkthdr->len != pkthdr->caplen) + ip_hdr->ip_len = htons(pkthdr->caplen - l2len); + pkthdr->len = pkthdr->caplen; + } + else if (tcpedit->mtu_truncate) { + if (pkthdr->len > (u_int16_t)(tcpedit->mtu + l2len)) { + /* first truncate the packet */ + pkthdr->len = pkthdr->caplen = l2len + tcpedit->mtu; + + /* if ip_hdr exists, update the length */ + if (ip_hdr != NULL) { + ip_hdr->ip_len = htons(tcpedit->mtu); + } else if (ip6_hdr != NULL) { + ip6_hdr->ip_len = htons(tcpedit->mtu - sizeof(*ip6_hdr)); + } else { + /* for non-IP frames, don't try to fix checksums */ + return 0; + } + } + } + else { + tcpedit_seterr(tcpedit, "Invalid fixlen value: 0x%x", tcpedit->fixlen); + return -1; + } + + return(1); +} + +/** + * Extracts the layer 7 data from the packet for TCP, UDP, ICMP + * returns the number of bytes and a pointer to the layer 7 data. + * Returns 0 for no data + */ +int +extract_data(tcpedit_t *tcpedit, const u_char *pktdata, int caplen, + char *l7data[]) +{ + int datalen = 0; /* amount of data beyond ip header */ + ipv4_hdr_t *ip_hdr = NULL; + tcp_hdr_t *tcp_hdr = NULL; + udp_hdr_t *udp_hdr = NULL; + u_char ipbuff[MAXPACKET]; + u_char *dataptr = NULL; + + assert(tcpedit); + assert(pktdata); + assert(l7data); + + /* grab our IPv4 header */ + dataptr = ipbuff; + if ((ip_hdr = (ipv4_hdr_t*)get_ipv4(pktdata, caplen, + tcpedit->runtime.dlt1, &dataptr)) == NULL) + return 0; + + /* + * figure out the actual datalen which might be < the caplen + * due to ethernet padding + */ + if (caplen > ntohs(ip_hdr->ip_len)) { + datalen = ntohs(ip_hdr->ip_len); + } else { + datalen = caplen - tcpedit->dlt_ctx->l2len; + } + + /* update the datlen to not include the IP header len */ + datalen -= ip_hdr->ip_hl << 2; + dataptr += ip_hdr->ip_hl << 2; + if (datalen <= 0) + goto nodata; + + /* TCP ? */ + if (ip_hdr->ip_p == IPPROTO_TCP) { + tcp_hdr = (tcp_hdr_t *) get_layer4_v4(ip_hdr); + datalen -= tcp_hdr->th_off << 2; + if (datalen <= 0) + goto nodata; + + dataptr += tcp_hdr->th_off << 2; + } + + /* UDP ? */ + else if (ip_hdr->ip_p == IPPROTO_UDP) { + udp_hdr = (udp_hdr_t *) get_layer4_v4(ip_hdr); + datalen -= TCPR_UDP_H; + if (datalen <= 0) + goto nodata; + + dataptr += TCPR_UDP_H; + } + + /* ICMP ? just ignore it for now */ + else if (ip_hdr->ip_p == IPPROTO_ICMP) { + dbg(2, "Ignoring any possible data in ICMP packet"); + goto nodata; + } + + /* unknown proto, just dump everything past the IP header */ + else { + dbg(2, "Unknown protocol, dumping everything past the IP header"); + dataptr = (u_char *)ip_hdr; + } + + dbgx(2, "packet had %d bytes of layer 7 data", datalen); + memcpy(l7data, dataptr, datalen); + return datalen; + + nodata: + dbg(2, "packet has no data, skipping..."); + return 0; +} + +/** + * rewrites an IPv4 packet's TTL based on the rules + * return 0 if no change, 1 if changed + */ +int +rewrite_ipv4_ttl(tcpedit_t *tcpedit, ipv4_hdr_t *ip_hdr) +{ + assert(tcpedit); + + /* make sure there's something to edit */ + if (ip_hdr == NULL || tcpedit->ttl_mode == TCPEDIT_TTL_OFF) + return(0); + + switch(tcpedit->ttl_mode) { + case TCPEDIT_TTL_SET: + if (ip_hdr->ip_ttl == tcpedit->ttl_value) + return(0); /* no change required */ + ip_hdr->ip_ttl = tcpedit->ttl_value; + break; + case TCPEDIT_TTL_ADD: + if (((int)ip_hdr->ip_ttl + tcpedit->ttl_value) > 255) { + ip_hdr->ip_ttl = 255; + } else { + ip_hdr->ip_ttl += tcpedit->ttl_value; + } + break; + case TCPEDIT_TTL_SUB: + if (ip_hdr->ip_ttl <= tcpedit->ttl_value) { + ip_hdr->ip_ttl = 1; + } else { + ip_hdr->ip_ttl -= tcpedit->ttl_value; + } + break; + default: + errx(1, "invalid ttl_mode: %d", tcpedit->ttl_mode); + } + return(1); +} + +/** + * rewrites an IPv6 packet's hop limit based on the rules + * return 0 if no change, 1 if changed + */ +int +rewrite_ipv6_hlim(tcpedit_t *tcpedit, ipv6_hdr_t *ip6_hdr) +{ + assert(tcpedit); + + /* make sure there's something to edit */ + if (ip6_hdr == NULL || tcpedit->ttl_mode == TCPEDIT_TTL_OFF) + return(0); + + switch(tcpedit->ttl_mode) { + case TCPEDIT_TTL_SET: + if (ip6_hdr->ip_hl == tcpedit->ttl_value) + return(0); /* no change required */ + ip6_hdr->ip_hl = tcpedit->ttl_value; + break; + case TCPEDIT_TTL_ADD: + if (((int)ip6_hdr->ip_hl + tcpedit->ttl_value) > 255) { + ip6_hdr->ip_hl = 255; + } else { + ip6_hdr->ip_hl += tcpedit->ttl_value; + } + break; + case TCPEDIT_TTL_SUB: + if (ip6_hdr->ip_hl <= tcpedit->ttl_value) { + ip6_hdr->ip_hl = 1; + } else { + ip6_hdr->ip_hl -= tcpedit->ttl_value; + } + break; + default: + errx(1, "invalid ttl_mode: %d", tcpedit->ttl_mode); + } + return(1); +} + +/** + * takes a CIDR notation netblock and uses that to "remap" given IP + * onto that netblock. ie: 10.0.0.0/8 and 192.168.55.123 -> 10.168.55.123 + * while 10.150.9.0/24 and 192.168.55.123 -> 10.150.9.123 + */ +static u_int32_t +remap_ipv4(tcpedit_t *tcpedit, tcpr_cidr_t *cidr, const u_int32_t original) +{ + u_int32_t ipaddr = 0, network = 0, mask = 0, result = 0; + + assert(tcpedit); + assert(cidr); + + if (cidr->family != AF_INET) { + return 0; + } + + /* don't rewrite broadcast addresses */ + if (tcpedit->skip_broadcast && !is_unicast_ipv4(tcpedit, original)) + return original; + + mask = 0xffffffff; /* turn on all the bits */ + + /* shift over by correct # of bits */ + mask = mask << (32 - cidr->masklen); + + /* apply the mask to the network */ + network = htonl(cidr->u.network) & mask; + + /* apply the reverse of the mask to the IP */ + mask = mask ^ 0xffffffff; + ipaddr = ntohl(original) & mask; + + /* merge the network portion and ip portions */ + result = network ^ ipaddr; + + /* return the result in network byte order */ + return(htonl(result)); +} + +static int +remap_ipv6(tcpedit_t *tcpedit, tcpr_cidr_t *cidr, struct tcpr_in6_addr *addr) +{ + int i, j, k; + + assert(tcpedit); + assert(cidr); + + if (cidr->family != AF_INET6) { + return 0; + } + + /* don't rewrite broadcast addresses */ + if (tcpedit->skip_broadcast && is_multicast_ipv6(tcpedit, addr)) + return 0; + + j = cidr->masklen / 8; + + for (i = 0; i < j; i++) + addr->tcpr_s6_addr[i] = cidr->u.network6.tcpr_s6_addr[i]; + + if ((k = cidr->masklen % 8) == 0) + return 1; + + k = ~0 << (8 - k); + i = addr->tcpr_s6_addr[i] & k; + + addr->tcpr_s6_addr[i] = (cidr->u.network6.tcpr_s6_addr[j] & (0xff << (8 - k))) | + (addr->tcpr_s6_addr[i] & (0xff >> k)); + + return 1; +} + +/** + * rewrite IP address (layer3) + * uses -N to rewrite (map) one subnet onto another subnet + * also support --srcipmap and --dstipmap + * return 0 if no change, 1 or 2 if changed + */ +int +rewrite_ipv4l3(tcpedit_t *tcpedit, ipv4_hdr_t *ip_hdr, tcpr_dir_t direction) +{ + tcpr_cidrmap_t *cidrmap1 = NULL, *cidrmap2 = NULL; + int didsrc = 0, diddst = 0, loop = 1; + + assert(tcpedit); + assert(ip_hdr); + + /* first check the src/dst IP maps */ + if (tcpedit->srcipmap != NULL) { + if (ip_in_cidr(tcpedit->srcipmap->from, ip_hdr->ip_src.s_addr)) { + ip_hdr->ip_src.s_addr = remap_ipv4(tcpedit, tcpedit->srcipmap->to, ip_hdr->ip_src.s_addr); + dbgx(2, "Remapped src addr to: %s", get_addr2name4(ip_hdr->ip_src.s_addr, RESOLVE)); + } + } + + if (tcpedit->dstipmap != NULL) { + if (ip_in_cidr(tcpedit->dstipmap->from, ip_hdr->ip_dst.s_addr)) { + ip_hdr->ip_dst.s_addr = remap_ipv4(tcpedit, tcpedit->dstipmap->to, ip_hdr->ip_dst.s_addr); + dbgx(2, "Remapped src addr to: %s", get_addr2name4(ip_hdr->ip_dst.s_addr, RESOLVE)); + } + } + + /* anything else to rewrite? */ + if (tcpedit->cidrmap1 == NULL) + return(0); + + /* don't play with the main pointers */ + if (direction == TCPR_DIR_C2S) { + cidrmap1 = tcpedit->cidrmap1; + cidrmap2 = tcpedit->cidrmap2; + } else { + cidrmap1 = tcpedit->cidrmap2; + cidrmap2 = tcpedit->cidrmap1; + } + + + /* loop through the cidrmap to rewrite */ + do { + if ((! diddst) && ip_in_cidr(cidrmap2->from, ip_hdr->ip_dst.s_addr)) { + ip_hdr->ip_dst.s_addr = remap_ipv4(tcpedit, cidrmap2->to, ip_hdr->ip_dst.s_addr); + dbgx(2, "Remapped dst addr to: %s", get_addr2name4(ip_hdr->ip_dst.s_addr, RESOLVE)); + diddst = 1; + } + if ((! didsrc) && ip_in_cidr(cidrmap1->from, ip_hdr->ip_src.s_addr)) { + ip_hdr->ip_src.s_addr = remap_ipv4(tcpedit, cidrmap1->to, ip_hdr->ip_src.s_addr); + dbgx(2, "Remapped src addr to: %s", get_addr2name4(ip_hdr->ip_src.s_addr, RESOLVE)); + didsrc = 1; + } + + /* + * loop while we haven't modified both src/dst AND + * at least one of the cidr maps have a next pointer + */ + if ((! (diddst && didsrc)) && + (! ((cidrmap1->next == NULL) && (cidrmap2->next == NULL)))) { + + /* increment our ptr's if possible */ + if (cidrmap1->next != NULL) + cidrmap1 = cidrmap1->next; + + if (cidrmap2->next != NULL) + cidrmap2 = cidrmap2->next; + + } else { + loop = 0; + } + + /* Later on we should support various IP protocols which embed + * the IP address in the application layer. Things like + * DNS and FTP. + */ + + } while (loop); + + /* return how many changes we made */ + return (diddst + didsrc); +} + +int +rewrite_ipv6l3(tcpedit_t *tcpedit, ipv6_hdr_t *ip6_hdr, tcpr_dir_t direction) +{ + tcpr_cidrmap_t *cidrmap1 = NULL, *cidrmap2 = NULL; + int didsrc = 0, diddst = 0, loop = 1; + + assert(tcpedit); + assert(ip6_hdr); + + /* first check the src/dst IP maps */ + if (tcpedit->srcipmap != NULL) { + if (ip6_in_cidr(tcpedit->srcipmap->from, &ip6_hdr->ip_src)) { + remap_ipv6(tcpedit, tcpedit->srcipmap->to, &ip6_hdr->ip_src); + dbgx(2, "Remapped src addr to: %s", get_addr2name6(&ip6_hdr->ip_src, RESOLVE)); + } + } + + if (tcpedit->dstipmap != NULL) { + if (ip6_in_cidr(tcpedit->dstipmap->from, &ip6_hdr->ip_dst)) { + remap_ipv6(tcpedit, tcpedit->dstipmap->to, &ip6_hdr->ip_dst); + dbgx(2, "Remapped src addr to: %s", get_addr2name6(&ip6_hdr->ip_dst, RESOLVE)); + } + } + + /* anything else to rewrite? */ + if (tcpedit->cidrmap1 == NULL) + return(0); + + /* don't play with the main pointers */ + if (direction == TCPR_DIR_C2S) { + cidrmap1 = tcpedit->cidrmap1; + cidrmap2 = tcpedit->cidrmap2; + } else { + cidrmap1 = tcpedit->cidrmap2; + cidrmap2 = tcpedit->cidrmap1; + } + + + /* loop through the cidrmap to rewrite */ + do { + if ((! diddst) && ip6_in_cidr(cidrmap2->from, &ip6_hdr->ip_dst)) { + remap_ipv6(tcpedit, cidrmap2->to, &ip6_hdr->ip_dst); + dbgx(2, "Remapped dst addr to: %s", get_addr2name6(&ip6_hdr->ip_dst, RESOLVE)); + diddst = 1; + } + if ((! didsrc) && ip6_in_cidr(cidrmap1->from, &ip6_hdr->ip_src)) { + remap_ipv6(tcpedit, cidrmap1->to, &ip6_hdr->ip_src); + dbgx(2, "Remapped src addr to: %s", get_addr2name6(&ip6_hdr->ip_src, RESOLVE)); + didsrc = 1; + } + + /* + * loop while we haven't modified both src/dst AND + * at least one of the cidr maps have a next pointer + */ + if ((! (diddst && didsrc)) && + (! ((cidrmap1->next == NULL) && (cidrmap2->next == NULL)))) { + + /* increment our ptr's if possible */ + if (cidrmap1->next != NULL) + cidrmap1 = cidrmap1->next; + + if (cidrmap2->next != NULL) + cidrmap2 = cidrmap2->next; + + } else { + loop = 0; + } + + /* Later on we should support various IP protocols which embed + * the IP address in the application layer. Things like + * DNS and FTP. + */ + + } while (loop); + + /* return how many changes we made */ + return (diddst + didsrc); +} + +/** + * Randomize the IP addresses in an ARP packet based on the user seed + * return 0 if no change, or 1 for a change + */ +int +randomize_iparp(tcpedit_t *tcpedit, struct pcap_pkthdr *pkthdr, + u_char *pktdata, int datalink) +{ + arp_hdr_t *arp_hdr = NULL; + int l2len = 0; + u_int32_t *ip, tempip; + u_char *add_hdr; + + assert(tcpedit); + assert(pkthdr); + assert(pktdata); + + l2len = get_l2len(pktdata, pkthdr->caplen, datalink); + arp_hdr = (arp_hdr_t *)(pktdata + l2len); + + /* + * only rewrite IP addresses from REPLY/REQUEST's + */ + if ((ntohs(arp_hdr->ar_pro) == ETHERTYPE_IP) && + ((ntohs(arp_hdr->ar_op) == ARPOP_REQUEST) || + (ntohs(arp_hdr->ar_op) == ARPOP_REPLY))) { + + /* jump to the addresses */ + add_hdr = (u_char *)arp_hdr; + add_hdr += sizeof(arp_hdr_t) + arp_hdr->ar_hln; + ip = (u_int32_t *)add_hdr; + tempip = randomize_ipv4_addr(tcpedit, *ip); + memcpy(ip, &tempip, sizeof(u_int32_t)); + + add_hdr += arp_hdr->ar_pln + arp_hdr->ar_hln; + ip = (u_int32_t *)add_hdr; + tempip = randomize_ipv4_addr(tcpedit, *ip); + memcpy(ip, &tempip, sizeof(u_int32_t)); + } + + return 1; /* yes we changed the packet */ +} + +/** + * rewrite IP address (arp) + * uses -a to rewrite (map) one subnet onto another subnet + * pointer must point to the WHOLE and CONTIGOUS memory buffer + * because the arp_hdr_t doesn't have the space for the IP/MAC + * addresses + * return 0 if no change, 1 or 2 if changed + */ +int +rewrite_iparp(tcpedit_t *tcpedit, arp_hdr_t *arp_hdr, int cache_mode) +{ + u_char *add_hdr = NULL; + u_int32_t *ip1 = NULL, *ip2 = NULL; + u_int32_t newip = 0; + tcpr_cidrmap_t *cidrmap1 = NULL, *cidrmap2 = NULL; + int didsrc = 0, diddst = 0, loop = 1; +#ifdef FORCE_ALIGN + u_int32_t iptemp; +#endif + + assert(tcpedit); + assert(arp_hdr); + + /* figure out what mapping to use */ + if (cache_mode == TCPR_DIR_C2S) { + cidrmap1 = tcpedit->cidrmap1; + cidrmap2 = tcpedit->cidrmap2; + } else if (cache_mode == TCPR_DIR_S2C) { + cidrmap1 = tcpedit->cidrmap2; + cidrmap2 = tcpedit->cidrmap1; + } + + /* anything to rewrite? */ + if (cidrmap1 == NULL || cidrmap2 == NULL) + return(0); + + /* + * must be IPv4 and request or reply + * Do other op codes use the same subheader stub? + * If so we won't need to check the op code. + */ + if ((ntohs(arp_hdr->ar_pro) == ETHERTYPE_IP) && + ((ntohs(arp_hdr->ar_op) == ARPOP_REQUEST) || + (ntohs(arp_hdr->ar_op) == ARPOP_REPLY))) + { + /* jump to the addresses */ + add_hdr = (u_char *)arp_hdr; + add_hdr += sizeof(arp_hdr_t) + arp_hdr->ar_hln; + ip1 = (u_int32_t *)add_hdr; + add_hdr += arp_hdr->ar_pln + arp_hdr->ar_hln; +#ifdef FORCE_ALIGN + /* copy IP2 to a temporary buffer for processing */ + memcpy(&iptemp, add_hdr, sizeof(u_int32_t)); + ip2 = &iptemp; +#else + ip2 = (u_int32_t *)add_hdr; +#endif + + + /* loop through the cidrmap to rewrite */ + do { + /* arp request ? */ + if (ntohs(arp_hdr->ar_op) == ARPOP_REQUEST) { + if ((!diddst) && ip_in_cidr(cidrmap2->from, *ip1)) { + newip = remap_ipv4(tcpedit, cidrmap2->to, *ip1); + memcpy(ip1, &newip, 4); + diddst = 1; + } + if ((!didsrc) && ip_in_cidr(cidrmap1->from, *ip2)) { + newip = remap_ipv4(tcpedit, cidrmap1->to, *ip2); + memcpy(ip2, &newip, 4); + didsrc = 1; + } + } + /* else it's an arp reply */ + else { + if ((!diddst) && ip_in_cidr(cidrmap2->from, *ip2)) { + newip = remap_ipv4(tcpedit, cidrmap2->to, *ip2); + memcpy(ip2, &newip, 4); + diddst = 1; + } + if ((!didsrc) && ip_in_cidr(cidrmap1->from, *ip1)) { + newip = remap_ipv4(tcpedit, cidrmap1->to, *ip1); + memcpy(ip1, &newip, 4); + didsrc = 1; + } + } + +#ifdef FORCE_ALIGN + /* copy temporary IP to IP2 location in buffer */ + memcpy(add_hdr, &iptemp, sizeof(u_int32_t)); +#endif + + /* + * loop while we haven't modified both src/dst AND + * at least one of the cidr maps have a next pointer + */ + if ((! (diddst && didsrc)) && + (! ((cidrmap1->next == NULL) && (cidrmap2->next == NULL)))) { + + /* increment our ptr's if possible */ + if (cidrmap1->next != NULL) + cidrmap1 = cidrmap1->next; + + if (cidrmap2->next != NULL) + cidrmap2 = cidrmap2->next; + + } else { + loop = 0; + } + + } while (loop); + + } else { + warn("ARP packet isn't for IPv4! Can't rewrite IP's"); + } + + return(didsrc + diddst); +} + +/** + * returns 1 if the IP address is a unicast address, otherwise, returns 0 + * for broadcast/multicast addresses. Returns -1 on error + */ +static int +is_unicast_ipv4(tcpedit_t *tcpedit, u_int32_t ip) +{ + assert(tcpedit); + + /* multicast/broadcast is 224.0.0.0 or greater */ + if (ip > 3758096384) + return 0; + + return 1; +} + +/** + * returns 1 if the IPv6 address is a multicast address, otherwise, returns 0 + * for unicast/anycast addresses. Returns -1 on error + */ +static int +is_multicast_ipv6(tcpedit_t *tcpedit, struct tcpr_in6_addr *addr) +{ + assert(tcpedit); + + if (addr->tcpr_s6_addr[0] == 0xff) + return 1; + + return 0; +} + diff --git a/src/tcpedit/edit_packet.h b/src/tcpedit/edit_packet.h new file mode 100644 index 0000000..6748deb --- /dev/null +++ b/src/tcpedit/edit_packet.h @@ -0,0 +1,81 @@ +/* $Id: edit_packet.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _EDIT_PACKETS_H_ +#define _EDIT_PACKETS_H_ + +#include "tcpedit.h" +#include "common.h" + +int untrunc_packet(tcpedit_t *tcpedit, struct pcap_pkthdr *pkthdr, + u_char *pktdata, ipv4_hdr_t *ip_hdr, ipv6_hdr_t *ip6_hdr); + +int randomize_ipv4(tcpedit_t *tcpedit, struct pcap_pkthdr *pktdhr, + u_char *pktdata, ipv4_hdr_t *ip_hdr); + +int randomize_ipv6(tcpedit_t *tcpedit, struct pcap_pkthdr *pktdhr, + u_char *pktdata, ipv6_hdr_t *ip_hdr); + +int randomize_iparp(tcpedit_t *tcpedit, struct pcap_pkthdr *pkthdr, + u_char *pktdata, int datalink); + +int fix_ipv4_checksums(tcpedit_t *tcpedit, struct pcap_pkthdr *pkdhdr, + ipv4_hdr_t *ip_hdr); + +int fix_ipv6_checksums(tcpedit_t *tcpedit, struct pcap_pkthdr *pkdhdr, + ipv6_hdr_t *ip_hdr); + +int extract_data(tcpedit_t *tcpedit, const u_char *pktdata, + int caplen, char *l7data[]); + +int rewrite_ipv4l3(tcpedit_t *tcpedit, ipv4_hdr_t *ip_hdr, tcpr_dir_t direction); + +int rewrite_ipv6l3(tcpedit_t *tcpedit, ipv6_hdr_t *ip_hdr, tcpr_dir_t direction); + +int rewrite_iparp(tcpedit_t *tcpedit, arp_hdr_t *arp_hdr, int direction); + +int rewrite_ipv4_ttl(tcpedit_t *tcpedit, ipv4_hdr_t *ip_hdr); + +int rewrite_ipv6_hlim(tcpedit_t *tcpedit, ipv6_hdr_t *ip6_hdr); + +#define BROADCAST_IP 4294967295 + +#endif + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + diff --git a/src/tcpedit/parse_args.c b/src/tcpedit/parse_args.c new file mode 100644 index 0000000..da3ae51 --- /dev/null +++ b/src/tcpedit/parse_args.c @@ -0,0 +1,255 @@ +/* $Id: parse_args.c 2430 2010-03-27 21:05:46Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "defines.h" +#include "common.h" +#include "tcpedit-int.h" +#include "tcpedit_stub.h" +#include "parse_args.h" +#include "portmap.h" + +#include +#include + + +/** + * returns 0 for sucess w/o errors + * returns 1 for sucess w/ warnings + * returns -1 for error + */ +int +tcpedit_post_args(tcpedit_t **tcpedit_ex) { + tcpedit_t *tcpedit; + int rcode = 0; + long ttl; + assert(tcpedit_ex); + tcpedit = *tcpedit_ex; + assert(tcpedit); + + + /* --pnat */ + if (HAVE_OPT(PNAT)) { + int ct = STACKCT_OPT(PNAT); + char **list = STACKLST_OPT(PNAT); + int first = 1; + + tcpedit->rewrite_ip ++; + + do { + char *p = *list++; + if (first) { + if (! parse_cidr_map(&tcpedit->cidrmap1, p)) { + tcpedit_seterr(tcpedit, + "Unable to parse first --pnat=%s", p); + return -1; + } + } else { + if (! parse_cidr_map(&tcpedit->cidrmap2, p)) { + tcpedit_seterr(tcpedit, + "Unable to parse second --pnat=%s", p); + return -1; + } + } + + first = 0; + } while (--ct > 0); + } + + /* --srcipmap */ + if (HAVE_OPT(SRCIPMAP)) { + tcpedit->rewrite_ip ++; + if (! parse_cidr_map(&tcpedit->srcipmap, OPT_ARG(SRCIPMAP))) { + tcpedit_seterr(tcpedit, + "Unable to parse --srcipmap=%s", OPT_ARG(SRCIPMAP)); + return -1; + } + } + + /* --dstipmap */ + if (HAVE_OPT(DSTIPMAP)) { + tcpedit->rewrite_ip ++; + if (! parse_cidr_map(&tcpedit->dstipmap, OPT_ARG(DSTIPMAP))) { + tcpedit_seterr(tcpedit, + "Unable to parse --dstipmap=%s", OPT_ARG(DSTIPMAP)); + return -1; + } + } + + /* + * If we have one and only one -N, then use the same map data + * for both interfaces/files + */ + if ((tcpedit->cidrmap1 != NULL) && (tcpedit->cidrmap2 == NULL)) + tcpedit->cidrmap2 = tcpedit->cidrmap1; + + /* --fixcsum */ + if (HAVE_OPT(FIXCSUM)) + tcpedit->fixcsum = 1; + + /* --efcs */ + if (HAVE_OPT(EFCS)) + tcpedit->efcs = 1; + + /* --ttl */ + if (HAVE_OPT(TTL)) { + if (strchr(OPT_ARG(TTL), '+')) { + tcpedit->ttl_mode = TCPEDIT_TTL_ADD; + } else if (strchr(OPT_ARG(TTL), '-')) { + tcpedit->ttl_mode = TCPEDIT_TTL_SUB; + } else { + tcpedit->ttl_mode = TCPEDIT_TTL_SET; + } + + ttl = strtol(OPT_ARG(TTL), (char **)NULL, 10); + if (ttl < 0) + ttl *= -1; /* convert to positive value */ + + if (ttl > 255) + errx(-1, "Invalid --ttl value (must be 0-255): %ld", ttl); + + tcpedit->ttl_value = (u_int8_t)ttl; + } + + /* --tos */ + if (HAVE_OPT(TOS)) + tcpedit->tos = OPT_VALUE_TOS; + + /* --flowlabel */ + if (HAVE_OPT(FLOWLABEL)) + tcpedit->flowlabel = OPT_VALUE_FLOWLABEL; + + /* --mtu */ + if (HAVE_OPT(MTU)) + tcpedit->mtu = OPT_VALUE_MTU; + + /* --mtu-trunc */ + if (HAVE_OPT(MTU_TRUNC)) + tcpedit->mtu_truncate = 1; + + /* --skipbroadcast */ + if (HAVE_OPT(SKIPBROADCAST)) + tcpedit->skip_broadcast = 1; + + /* --fixlen */ + if (HAVE_OPT(FIXLEN)) { + if (strcmp(OPT_ARG(FIXLEN), "pad") == 0) { + tcpedit->fixlen = TCPEDIT_FIXLEN_PAD; + } else if (strcmp(OPT_ARG(FIXLEN), "trunc") == 0) { + tcpedit->fixlen = TCPEDIT_FIXLEN_TRUNC; + } else if (strcmp(OPT_ARG(FIXLEN), "del") == 0) { + tcpedit->fixlen = TCPEDIT_FIXLEN_DEL; + } else { + tcpedit_seterr(tcpedit, "Invalid --fixlen=%s", OPT_ARG(FIXLEN)); + return -1; + } + } + + /* TCP/UDP port rewriting */ + if (HAVE_OPT(PORTMAP)) { + int ct = STACKCT_OPT(PORTMAP); + char **list = STACKLST_OPT(PORTMAP); + int first = 1; + tcpedit_portmap_t *portmap_head, *portmap; + + do { + char *p = *list++; + if (first) { + if (! parse_portmap(&tcpedit->portmap, p)) { + tcpedit_seterr(tcpedit, "Unable to parse --portmap=%s", p); + return -1; + } + } else { + if (! parse_portmap(&portmap, p)) { + tcpedit_seterr(tcpedit, "Unable to parse --portmap=%s", p); + return -1; + } + + /* append to end of tcpedit->portmap linked list */ + portmap_head = tcpedit->portmap; + while (portmap_head->next != NULL) + portmap_head = portmap_head->next; + portmap_head->next = portmap; + + } + first = 0; + } while (--ct > 0); + } + + /* + * IP address rewriting processing. Call srandom() then add up + * 5 calls to random() as our mixer for randomizing. This should + * work better since most people aren't going to write out values + * close to 32bit integers. + */ + if (HAVE_OPT(SEED)) { + tcpedit->rewrite_ip = TCPEDIT_REWRITE_IP_ON; + srandom(OPT_VALUE_SEED); + tcpedit->seed = random() + random() + random() + random() + random(); + } + + if (HAVE_OPT(ENDPOINTS)) { + tcpedit->rewrite_ip = TCPEDIT_REWRITE_IP_ON; + if (! parse_endpoints(&tcpedit->cidrmap1, &tcpedit->cidrmap2, + OPT_ARG(ENDPOINTS))) { + tcpedit_seterr(tcpedit, + "Unable to parse --endpoints=%s", OPT_ARG(ENDPOINTS)); + return -1; + } + } + + /* + * figure out the max packet len + if (tcpedit->l2.enabled) { + // custom l2 header + dbg(1, "Using custom L2 header to calculate max frame size\n"); + tcpedit->maxpacket = tcpedit->mtu + tcpedit->l2.len; + } + else if (tcpedit->l2.dlt == DLT_EN10MB || tcpedit->l2.dlt == DLT_VLAN) { + // ethernet + dbg(1, "Using Ethernet to calculate max frame size\n"); + tcpedit->maxpacket = tcpedit->mtu + TCPR_ETH_H; + } else { + // uh, wtf is this now? we'll just assume ethernet and hope things work + tcpedit->maxpacket = tcpedit->mtu + TCPR_ETH_H; + tcpedit_seterr(tcpedit, + "Unsupported DLT type: %s. We'll just treat it as ethernet.\n" + "You may need to increase the MTU (-t ) if you get errors\n", + pcap_datalink_val_to_name(tcpedit->l2.dlt)); + rcode = 1; + } + */ + + return rcode; +} + + diff --git a/src/tcpedit/parse_args.h b/src/tcpedit/parse_args.h new file mode 100644 index 0000000..a7cee88 --- /dev/null +++ b/src/tcpedit/parse_args.h @@ -0,0 +1,41 @@ +/* $Id: parse_args.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _PARSE_ARGS_H_ +#define _PARSE_ARGS_H_ + +#include "tcpedit.h" + +int tcpedit_post_args(tcpedit_t **tcpedit_ex); + +#endif + diff --git a/src/tcpedit/plugins/Makefile.am b/src/tcpedit/plugins/Makefile.am new file mode 100644 index 0000000..fec59ac --- /dev/null +++ b/src/tcpedit/plugins/Makefile.am @@ -0,0 +1,33 @@ +# $Id: $ + +libtcpedit_a_SOURCES += $(srcdir)/plugins/dlt_plugins.c \ + $(srcdir)/plugins/ethernet.c $(srcdir)/plugins/dlt_utils.c + +noinst_HEADERS += $(srcdir)/plugins/dlt_plugins.h $(srcdir)/plugins/ethernet.h \ + $(srcdir)/plugins/dlt_utils.h $(srcdir)/plugins/dlt_plugins-int.h + +AM_CFLAGS += -I. -I$(srcdir)/plugins -I$(srcdir)/../common $(LIBOPTS_CFLAGS) + +EXTRA_DIST += $(srcdir)/plugins/dlt_opts.def $(srcdir)/plugins/dlt_stub.def + +MOSTLYCLEANFILES += $(srcdir)/plugins/*~ + +MAINTAINERCLEANFILES += Makefile.in + + +DLT_STUB_DEPS = $(srcdir)/plugins/dlt_opts.def + +$(srcdir)/plugins/dlt_stub.def: $(DLT_STUB_DEPS) + +######################################################## +# Add your plugin Makefile.am's below this line +######################################################## +include $(srcdir)/plugins/dlt_en10mb/Makefile.am +include $(srcdir)/plugins/dlt_hdlc/Makefile.am +include $(srcdir)/plugins/dlt_user/Makefile.am +include $(srcdir)/plugins/dlt_raw/Makefile.am +include $(srcdir)/plugins/dlt_null/Makefile.am +include $(srcdir)/plugins/dlt_loop/Makefile.am +include $(srcdir)/plugins/dlt_linuxsll/Makefile.am +include $(srcdir)/plugins/dlt_ieee80211/Makefile.am +include $(srcdir)/plugins/dlt_radiotap/Makefile.am diff --git a/src/tcpedit/plugins/Makefile.in b/src/tcpedit/plugins/Makefile.in new file mode 100644 index 0000000..e69de29 diff --git a/src/tcpedit/plugins/dlt_en10mb/Makefile.am b/src/tcpedit/plugins/dlt_en10mb/Makefile.am new file mode 100644 index 0000000..a1e4ef1 --- /dev/null +++ b/src/tcpedit/plugins/dlt_en10mb/Makefile.am @@ -0,0 +1,26 @@ +# $Id: Makefile.am 1830 2007-04-21 07:33:54Z aturner $ +# START OF: dlt_en10mb +# Note, if you add any files to your plugin, you will need to edit dlt_/Makefile.am +# add your .c files to libdltplugin_a_SOURCES +# add your .h files to noinst_HEADERS +# add any other files (like documentation, notes, etc) to EXTRA_DIST +# add your dependancy information (see comment below) + +libtcpedit_a_SOURCES += $(srcdir)/plugins/dlt_en10mb/en10mb.c + +noinst_HEADERS += $(srcdir)/plugins/dlt_en10mb/en10mb.h + +EXTRA_DIST += $(srcdir)/plugins/dlt_en10mb/en10mb_opts.def + +# dependancies for your plugin source code. Edit as necessary +$(srcdir)/plugins/dlt_en10mb/en10mb.c: $(srcdir)/tcpedit_stub.h $(srcdir)/plugins/dlt_utils.h \ + $(srcdir)/plugins/dlt_en10mb/en10mb.h $(srcdir)/plugins/dlt_plugins.h $(srcdir)/plugins/dlt_plugins-int.h + +# Note: +# You probably don't want to touch anything below this line until the end of the plugin + +DLT_STUB_DEPS += $(srcdir)/plugins/dlt_en10mb/en10mb_opts.def + +MOSTLYCLEANFILES += $(srcdir)/plugins/dlt_en10mb/*~ + +# END OF: dlt_en10mb diff --git a/src/tcpedit/plugins/dlt_en10mb/Makefile.in b/src/tcpedit/plugins/dlt_en10mb/Makefile.in new file mode 100644 index 0000000..e69de29 diff --git a/src/tcpedit/plugins/dlt_en10mb/en10mb.c b/src/tcpedit/plugins/dlt_en10mb/en10mb.c new file mode 100644 index 0000000..e8c4afc --- /dev/null +++ b/src/tcpedit/plugins/dlt_en10mb/en10mb.c @@ -0,0 +1,630 @@ +/* $Id: en10mb.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + +#include "en10mb.h" +#include "dlt_plugins-int.h" +#include "tcpedit.h" +#include "common.h" +#include "tcpr.h" +#include "dlt_utils.h" +#include "tcpedit_stub.h" +#include "../ethernet.h" + +static char _U_ dlt_name[] = "en10mb"; +static char dlt_prefix[] = "enet"; +static u_int16_t dlt_value = DLT_EN10MB; + +/* + * Function to register ourselves. This function is always called, regardless + * of what DLT types are being used, so it shouldn't be allocating extra buffers + * or anything like that (use the dlt_en10mb_init() function below for that). + * Tasks: + * - Create a new plugin struct + * - Fill out the provides/requires bit masks. Note: Only specify which fields are + * actually in the header. + * - Add the plugin to the context's plugin chain + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_en10mb_register(tcpeditdlt_t *ctx) +{ + tcpeditdlt_plugin_t *plugin; + assert(ctx); + + /* create a new plugin structure */ + plugin = tcpedit_dlt_newplugin(); + + /* set what we provide & require */ + plugin->provides += PLUGIN_MASK_PROTO + PLUGIN_MASK_SRCADDR + PLUGIN_MASK_DSTADDR; + plugin->requires += PLUGIN_MASK_PROTO + PLUGIN_MASK_SRCADDR + PLUGIN_MASK_DSTADDR; + + /* what is our dlt type? */ + plugin->dlt = dlt_value; + + /* set the prefix name of our plugin. This is also used as the prefix for our options */ + plugin->name = safe_strdup(dlt_prefix); + + /* + * Point to our functions, note, you need a function for EVERY method. + * Even if it is only an empty stub returning success. + */ + plugin->plugin_init = dlt_en10mb_init; + plugin->plugin_cleanup = dlt_en10mb_cleanup; + plugin->plugin_parse_opts = dlt_en10mb_parse_opts; + plugin->plugin_decode = dlt_en10mb_decode; + plugin->plugin_encode = dlt_en10mb_encode; + plugin->plugin_proto = dlt_en10mb_proto; + plugin->plugin_l2addr_type = dlt_en10mb_l2addr_type; + plugin->plugin_l2len = dlt_en10mb_l2len; + plugin->plugin_get_layer3 = dlt_en10mb_get_layer3; + plugin->plugin_merge_layer3 = dlt_en10mb_merge_layer3; + plugin->plugin_get_mac = dlt_en10mb_get_mac; + + /* add it to the available plugin list */ + return tcpedit_dlt_addplugin(ctx, plugin); +} + + +/* + * Initializer function. This function is called only once, if and only iif + * this plugin will be utilized. Remember, if you need to keep track of any state, + * store it in your plugin->config, not a global! + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_en10mb_init(tcpeditdlt_t *ctx) +{ + tcpeditdlt_plugin_t *plugin; + en10mb_config_t *config; + assert(ctx); + + /* vlan tags need an additional 4 bytes */ + if ((plugin = tcpedit_dlt_getplugin(ctx, dlt_value)) == NULL) { + tcpedit_seterr(ctx->tcpedit, "%s", "Unable to initalize unregistered plugin en10mb"); + return TCPEDIT_ERROR; + } + + ctx->decoded_extra = safe_malloc(sizeof(en10mb_extra_t)); + plugin->config = safe_malloc(sizeof(en10mb_config_t)); + config = (en10mb_config_t *)plugin->config; + + /* init vlan user values to -1 to indicate not set */ + config->vlan_tag = 65535; + config->vlan_pri = 255; + config->vlan_cfi = 255; + + + 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_en10mb_init(), this is just an stub. + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +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; + } + + if (plugin->config != NULL) { + safe_free(plugin->config); + plugin->config = NULL; + } + + return TCPEDIT_OK; /* success */ +} + +/* + * This is where you should define all your AutoGen AutoOpts option parsing. + * Any user specified option should have it's bit turned on in the 'provides' + * bit mask. + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_en10mb_parse_opts(tcpeditdlt_t *ctx) +{ + tcpeditdlt_plugin_t *plugin; + en10mb_config_t *config; + assert(ctx); + + plugin = tcpedit_dlt_getplugin(ctx, dlt_value); + config = (en10mb_config_t *)plugin->config; + + /* --dmac */ + if (HAVE_OPT(ENET_DMAC)) { + int macparse; + macparse = dualmac2hex(OPT_ARG(ENET_DMAC), config->intf1_dmac, + config->intf2_dmac, strlen(OPT_ARG(ENET_DMAC))); + switch (macparse) { + case 1: + config->mac_mask += TCPEDIT_MAC_MASK_DMAC1; + break; + case 2: + config->mac_mask += TCPEDIT_MAC_MASK_DMAC2; + break; + case 3: + config->mac_mask += TCPEDIT_MAC_MASK_DMAC1; + config->mac_mask += TCPEDIT_MAC_MASK_DMAC2; + break; + case 0: + /* nothing to do */ + break; + default: + tcpedit_seterr(ctx->tcpedit, + "Unable to parse --enet-dmac=%s", OPT_ARG(ENET_DMAC)); + return TCPEDIT_ERROR; + break; + } + + plugin->requires -= PLUGIN_MASK_DSTADDR; + + } + + /* --smac */ + if (HAVE_OPT(ENET_SMAC)) { + int macparse; + macparse = dualmac2hex(OPT_ARG(ENET_SMAC), config->intf1_smac, + config->intf2_smac, strlen(OPT_ARG(ENET_SMAC))); + switch (macparse) { + case 1: + config->mac_mask += TCPEDIT_MAC_MASK_SMAC1; + break; + case 2: + config->mac_mask += TCPEDIT_MAC_MASK_SMAC2; + break; + case 3: + config->mac_mask += TCPEDIT_MAC_MASK_SMAC1; + config->mac_mask += TCPEDIT_MAC_MASK_SMAC2; + break; + case 0: + /* nothing to do */ + break; + default: + tcpedit_seterr(ctx->tcpedit, + "Unable to parse --enet-smac=%s", OPT_ARG(ENET_SMAC)); + return TCPEDIT_ERROR; + break; + } + plugin->requires -= PLUGIN_MASK_SRCADDR; + } + + /* + * Validate 802.1q vlan args and populate tcpedit->vlan_record + */ + if (HAVE_OPT(ENET_VLAN)) { + if (strcmp(OPT_ARG(ENET_VLAN), "add") == 0) { // add or change + config->vlan = TCPEDIT_VLAN_ADD; + } else if (strcmp(OPT_ARG(ENET_VLAN), "del") == 0) { + config->vlan = TCPEDIT_VLAN_DEL; + } else { + tcpedit_seterr(ctx->tcpedit, "Invalid --enet-vlan=%s", OPT_ARG(ENET_VLAN)); + return -1; + } + + if (config->vlan != TCPEDIT_VLAN_OFF) { + if (config->vlan == TCPEDIT_VLAN_ADD) { + if (! HAVE_OPT(ENET_VLAN_TAG)) { + tcpedit_seterr(ctx->tcpedit, "%s", + "Must specify a new 802.1 VLAN tag if vlan " + "mode is add"); + return TCPEDIT_ERROR; + } + + /* + * fill out the 802.1q header + */ + config->vlan_tag = OPT_VALUE_ENET_VLAN_TAG; + + dbgx(1, "We will %s 802.1q headers", + config->vlan == TCPEDIT_VLAN_DEL ? "delete" : "add/modify"); + + if (HAVE_OPT(ENET_VLAN_PRI)) + config->vlan_pri = OPT_VALUE_ENET_VLAN_PRI; + + if (HAVE_OPT(ENET_VLAN_CFI)) + config->vlan_cfi = OPT_VALUE_ENET_VLAN_CFI; + } + } + } + + + return TCPEDIT_OK; /* success */ +} + +/* + * Function to decode the layer 2 header in the packet + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_en10mb_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen) +{ + tcpeditdlt_plugin_t *plugin = NULL; + struct tcpr_ethernet_hdr *eth = NULL; + struct tcpr_802_1q_hdr *vlan = NULL; + en10mb_extra_t *extra = NULL; + en10mb_config_t *config = NULL; + + assert(ctx); + assert(packet); + assert(pktlen >= 14); + + plugin = tcpedit_dlt_getplugin(ctx, dlt_value); + config = plugin->config; + + /* get our src & dst address */ + eth = (struct tcpr_ethernet_hdr *)packet; + memcpy(&(ctx->dstaddr.ethernet), eth, ETHER_ADDR_LEN); + memcpy(&(ctx->srcaddr.ethernet), &(eth->ether_shost), ETHER_ADDR_LEN); + + extra = (en10mb_extra_t *)ctx->decoded_extra; + extra->vlan = 0; + + /* get the L3 protocol type & L2 len*/ + switch (ntohs(eth->ether_type)) { + case ETHERTYPE_VLAN: + vlan = (struct tcpr_802_1q_hdr *)packet; + ctx->proto = vlan->vlan_len; + + /* Get VLAN tag info */ + extra->vlan = 1; + /* must use these mask values, rather then what's in the tcpr.h since it assumes you're shifting */ + extra->vlan_tag = vlan->vlan_priority_c_vid & 0x0FFF; + extra->vlan_pri = vlan->vlan_priority_c_vid & 0xE000; + extra->vlan_cfi = vlan->vlan_priority_c_vid & 0x1000; + ctx->l2len = TCPR_802_1Q_H; + break; + + /* we don't properly handle SNAP encoding */ + default: + ctx->proto = eth->ether_type; + ctx->l2len = TCPR_802_3_H; + break; + } + + return TCPEDIT_OK; /* success */ +} + +/* + * Function to encode the layer 2 header back into the packet. + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_en10mb_encode(tcpeditdlt_t *ctx, u_char *packet, int pktlen, tcpr_dir_t dir) +{ + tcpeditdlt_plugin_t *plugin = NULL; + struct tcpr_ethernet_hdr *eth = NULL; + struct tcpr_802_1q_hdr *vlan = NULL; + en10mb_config_t *config = NULL; + en10mb_extra_t *extra = NULL; + + int newl2len = 0; + + assert(ctx); + assert(packet); + + if (pktlen < 14) { + tcpedit_seterr(ctx->tcpedit, + "Unable to process packet #" COUNTER_SPEC " since it is less then 14 bytes.", + ctx->tcpedit->runtime.packetnum); + return TCPEDIT_ERROR; + } + + plugin = tcpedit_dlt_getplugin(ctx, dlt_value); + config = plugin->config; + extra = (en10mb_extra_t *)ctx->decoded_extra; + + /* figure out the new layer2 length, first for the case: ethernet -> ethernet? */ + if (ctx->decoder->dlt == dlt_value) { + if ((ctx->l2len == TCPR_802_1Q_H && config->vlan == TCPEDIT_VLAN_OFF) || + (config->vlan == TCPEDIT_VLAN_ADD)) { + newl2len = TCPR_802_1Q_H; + } else if ((ctx->l2len == TCPR_802_3_H && config->vlan == TCPEDIT_VLAN_OFF) || + (config->vlan == TCPEDIT_VLAN_DEL)) { + newl2len = TCPR_802_3_H; + } + } + + /* newl2len for some other DLT -> ethernet */ + else { + /* if add a vlan then 18, else 14 bytes */ + newl2len = config->vlan == TCPEDIT_VLAN_ADD ? TCPR_802_1Q_H : TCPR_802_3_H; + } + + /* Make space for our new L2 header */ + if (newl2len != ctx->l2len) + memmove(packet + newl2len, packet + ctx->l2len, pktlen - ctx->l2len); + + /* update the total packet length */ + pktlen += newl2len - ctx->l2len; + + /* always set the src & dst address as the first 12 bytes */ + eth = (struct tcpr_ethernet_hdr *)packet; + + if (dir == TCPR_DIR_C2S) { + /* copy user supplied SRC MAC if provided or from original packet */ + if (config->mac_mask & TCPEDIT_MAC_MASK_SMAC1) { + if ((ctx->addr_type == ETHERNET && + ((ctx->skip_broadcast && + is_unicast_ethernet(ctx, ctx->srcaddr.ethernet)) || !ctx->skip_broadcast)) + || ctx->addr_type != ETHERNET) { + memcpy(eth->ether_shost, config->intf1_smac, ETHER_ADDR_LEN); + } else { + memcpy(eth->ether_shost, ctx->srcaddr.ethernet, ETHER_ADDR_LEN); + } + } else if (ctx->addr_type == ETHERNET) { + memcpy(eth->ether_shost, ctx->srcaddr.ethernet, ETHER_ADDR_LEN); + } else { + tcpedit_seterr(ctx->tcpedit, "%s", "Please provide a source address"); + return TCPEDIT_ERROR; + } + + /* copy user supplied DMAC MAC if provided or from original packet */ + if (config->mac_mask & TCPEDIT_MAC_MASK_DMAC1) { + if ((ctx->addr_type == ETHERNET && + ((ctx->skip_broadcast && is_unicast_ethernet(ctx, ctx->dstaddr.ethernet)) || !ctx->skip_broadcast)) + || ctx->addr_type != ETHERNET) { + memcpy(eth->ether_dhost, config->intf1_dmac, ETHER_ADDR_LEN); + } else { + memcpy(eth->ether_dhost, ctx->dstaddr.ethernet, ETHER_ADDR_LEN); + } + } else if (ctx->addr_type == ETHERNET) { + memcpy(eth->ether_dhost, ctx->dstaddr.ethernet, ETHER_ADDR_LEN); + } else { + tcpedit_seterr(ctx->tcpedit, "%s", "Please provide a destination address"); + return TCPEDIT_ERROR; + } + + } else if (dir == TCPR_DIR_S2C) { + /* copy user supplied SRC MAC if provided or from original packet */ + if (config->mac_mask & TCPEDIT_MAC_MASK_SMAC2) { + if ((ctx->addr_type == ETHERNET && + ((ctx->skip_broadcast && is_unicast_ethernet(ctx, ctx->srcaddr.ethernet)) || !ctx->skip_broadcast)) + || ctx->addr_type != ETHERNET) { + memcpy(eth->ether_shost, config->intf2_smac, ETHER_ADDR_LEN); + } else { + memcpy(eth->ether_shost, ctx->srcaddr.ethernet, ETHER_ADDR_LEN); + } + } else if (ctx->addr_type == ETHERNET) { + memcpy(eth->ether_shost, ctx->srcaddr.ethernet, ETHER_ADDR_LEN); + } else { + tcpedit_seterr(ctx->tcpedit, "%s", "Please provide a source address"); + return TCPEDIT_ERROR; + } + + + /* copy user supplied DMAC MAC if provided or from original packet */ + if (config->mac_mask & TCPEDIT_MAC_MASK_DMAC2) { + if ((ctx->addr_type == ETHERNET && + ((ctx->skip_broadcast && is_unicast_ethernet(ctx, ctx->dstaddr.ethernet)) || !ctx->skip_broadcast)) + || ctx->addr_type != ETHERNET) { + memcpy(eth->ether_dhost, config->intf2_dmac, ETHER_ADDR_LEN); + } else { + memcpy(eth->ether_dhost, ctx->dstaddr.ethernet, ETHER_ADDR_LEN); + } + } else if (ctx->addr_type == ETHERNET) { + memcpy(eth->ether_dhost, ctx->dstaddr.ethernet, ETHER_ADDR_LEN); + } else { + tcpedit_seterr(ctx->tcpedit, "%s", "Please provide a destination address"); + return TCPEDIT_ERROR; + } + + + } else { + tcpedit_seterr(ctx->tcpedit, "%s", "Encoders only support C2S or C2S!"); + return TCPEDIT_ERROR; + } + + if (newl2len == TCPR_802_3_H) { + /* all we need for 802.3 is the proto */ + eth->ether_type = ctx->proto; + + } else if (newl2len == TCPR_802_1Q_H) { + /* VLAN tags need a bit more */ + vlan = (struct tcpr_802_1q_hdr *)packet; + vlan->vlan_len = ctx->proto; + vlan->vlan_tpi = htons(ETHERTYPE_VLAN); + + /* are we changing VLAN info? */ + if (config->vlan_tag < 65535) { + vlan->vlan_priority_c_vid = + htons((u_int16_t)config->vlan_tag & TCPR_802_1Q_VIDMASK); + } else if (extra->vlan) { + vlan->vlan_priority_c_vid = extra->vlan_tag; + } else { + tcpedit_seterr(ctx->tcpedit, "%s", "Non-VLAN tagged packet requires --enet-vlan-tag"); + return TCPEDIT_ERROR; + } + + if (config->vlan_pri < 255) { + vlan->vlan_priority_c_vid += htons((u_int16_t)config->vlan_pri << 13); + } else if (extra->vlan) { + vlan->vlan_priority_c_vid += extra->vlan_pri; + } else { + tcpedit_seterr(ctx->tcpedit, "%s", "Non-VLAN tagged packet requires --enet-vlan-pri"); + return TCPEDIT_ERROR; + } + + if (config->vlan_cfi < 255) { + vlan->vlan_priority_c_vid += htons((u_int16_t)config->vlan_cfi << 12); + } else if (extra->vlan) { + vlan->vlan_priority_c_vid += extra->vlan_cfi; + } else { + tcpedit_seterr(ctx->tcpedit, "%s", "Non-VLAN tagged packet requires --enet-vlan-cfi"); + return TCPEDIT_ERROR; + } + + } else { + tcpedit_seterr(ctx->tcpedit, "Unsupported new layer 2 length: %d", newl2len); + return TCPEDIT_ERROR; + } + + return pktlen; +} + + +/* + * Function returns the Layer 3 protocol type of the given packet, or TCPEDIT_ERROR on error + */ +int +dlt_en10mb_proto(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen) +{ + struct tcpr_ethernet_hdr *eth = NULL; + struct tcpr_802_1q_hdr *vlan = NULL; + + assert(ctx); + assert(packet); + assert(pktlen); + + eth = (struct tcpr_ethernet_hdr *)packet; + switch (ntohs(eth->ether_type)) { + case ETHERTYPE_VLAN: + vlan = (struct tcpr_802_1q_hdr *)packet; + return vlan->vlan_len; + break; + + default: + return eth->ether_type; + break; + } + return TCPEDIT_ERROR; +} + +/* + * Function returns a pointer to the layer 3 protocol header or NULL on error + */ +u_char * +dlt_en10mb_get_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen) +{ + int l2len; + assert(ctx); + assert(packet); + assert(pktlen); + + l2len = dlt_en10mb_l2len(ctx, packet, pktlen); + return tcpedit_dlt_l3data_copy(ctx, packet, pktlen, l2len); +} + +/* + * function merges the packet (containing L2 and old L3) with the l3data buffer + * containing the new l3 data. Note, if L2 % 4 == 0, then they're pointing to the + * same buffer, otherwise there was a memcpy involved on strictly aligned architectures + * like SPARC + */ +u_char * +dlt_en10mb_merge_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen, u_char *l3data) +{ + int l2len; + assert(ctx); + assert(packet); + assert(l3data); + + l2len = dlt_en10mb_l2len(ctx, packet, pktlen); + + assert(pktlen >= l2len); + + return tcpedit_dlt_l3data_merge(ctx, packet, pktlen, l3data, l2len); +} + +/* + * return a static pointer to the source/destination MAC address + * return NULL on error/address doesn't exist + */ +u_char * +dlt_en10mb_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen) +{ + assert(ctx); + assert(packet); + assert(pktlen); + + /* FIXME: return a ptr to the source or dest mac address. */ + switch(mac) { + case SRC_MAC: + memcpy(ctx->srcmac, &packet[6], ETHER_ADDR_LEN); + return(ctx->srcmac); + break; + + case DST_MAC: + memcpy(ctx->dstmac, packet, ETHER_ADDR_LEN); + return(ctx->dstmac); + break; + + default: + errx(1, "Invalid tcpeditdlt_mac_type_t: %d", mac); + } + return(NULL); +} + +/* + * return the length of the L2 header of the current packet + */ +int +dlt_en10mb_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen) +{ + struct tcpr_ethernet_hdr *eth = NULL; + + assert(ctx); + assert(packet); + assert(pktlen); + + eth = (struct tcpr_ethernet_hdr *)packet; + switch (ntohs(eth->ether_type)) { + case ETHERTYPE_VLAN: + return 18; + break; + + default: + return 14; + break; + } + tcpedit_seterr(ctx->tcpedit, "%s", "Whoops! Bug in my code!"); + return -1; +} + +tcpeditdlt_l2addr_type_t +dlt_en10mb_l2addr_type(void) +{ + return ETHERNET; +} diff --git a/src/tcpedit/plugins/dlt_en10mb/en10mb.h b/src/tcpedit/plugins/dlt_en10mb/en10mb.h new file mode 100644 index 0000000..9954df3 --- /dev/null +++ b/src/tcpedit/plugins/dlt_en10mb/en10mb.h @@ -0,0 +1,91 @@ +/* $Id: en10mb.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#include "dlt_plugins-int.h" + +#ifndef _DLT_en10mb_H_ +#define _DLT_en10mb_H_ + +int dlt_en10mb_register(tcpeditdlt_t *ctx); +int dlt_en10mb_init(tcpeditdlt_t *ctx); +int dlt_en10mb_cleanup(tcpeditdlt_t *ctx); +int dlt_en10mb_parse_opts(tcpeditdlt_t *ctx); +int dlt_en10mb_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); +int dlt_en10mb_encode(tcpeditdlt_t *ctx, u_char *packet, int pktlen, tcpr_dir_t dir); +int dlt_en10mb_proto(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); +u_char *dlt_en10mb_get_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen); +u_char *dlt_en10mb_merge_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen, u_char *l3data); +int dlt_en10mb_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); +u_char *dlt_en10mb_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen); + +tcpeditdlt_l2addr_type_t dlt_en10mb_l2addr_type(void); + +struct en10mb_extra_s { + int vlan; /* set to 1 for vlan_ fields being filled out */ + + u_int16_t vlan_tag; + u_int16_t vlan_pri; + u_int16_t vlan_cfi; +}; +typedef struct en10mb_extra_s en10mb_extra_t; + +struct en10mb_config_s { + /* values to rewrite src/dst MAC addresses */ + tcpr_macaddr_t intf1_dmac; + tcpr_macaddr_t intf1_smac; + tcpr_macaddr_t intf2_dmac; + tcpr_macaddr_t intf2_smac; + + /* we use the mask to say which are valid values */ + int mac_mask; +#define TCPEDIT_MAC_MASK_SMAC1 0x1 +#define TCPEDIT_MAC_MASK_SMAC2 0x2 +#define TCPEDIT_MAC_MASK_DMAC1 0x4 +#define TCPEDIT_MAC_MASK_DMAC2 0x8 + + /* 802.1q VLAN tag stuff */ + int vlan; +#define TCPEDIT_VLAN_OFF 0x0 +#define TCPEDIT_VLAN_DEL 0x1 /* strip 802.1q and rewrite as standard + * 802.3 Ethernet */ +#define TCPEDIT_VLAN_ADD 0x2 /* add/replace 802.1q vlan tag */ + + /* user defined values, -1 means unset! */ + u_int16_t vlan_tag; + u_int8_t vlan_pri; + u_int8_t vlan_cfi; +}; +typedef struct en10mb_config_s en10mb_config_t; + +#endif + diff --git a/src/tcpedit/plugins/dlt_en10mb/en10mb_opts.def b/src/tcpedit/plugins/dlt_en10mb/en10mb_opts.def new file mode 100644 index 0000000..0c7518a --- /dev/null +++ b/src/tcpedit/plugins/dlt_en10mb/en10mb_opts.def @@ -0,0 +1,88 @@ + +flag = { + name = enet-dmac; + arg-type = string; + max = 1; + descrip = "Override destination ethernet MAC addresses"; + doc = <<- EOText +Takes a pair of comma deliminated ethernet MAC addresses which +will replace the destination MAC address of outbound packets. +The first MAC address will be used for the server to client traffic +and the optional second MAC address will be used for the client +to server traffic. + +Example: +@example +--enet-dmac=00:12:13:14:15:16,00:22:33:44:55:66 +@end example +EOText; +}; + + +flag = { + name = enet-smac; + arg-type = string; + max = 1; + descrip = "Override source ethernet MAC addresses"; + doc = <<- EOText +Takes a pair of comma deliminated ethernet MAC addresses which +will replace the source MAC address of outbound packets. +The first MAC address will be used for the server to client traffic +and the optional second MAC address will be used for the client +to server traffic. + +Example: +@example +--enet-smac=00:12:13:14:15:16,00:22:33:44:55:66 +@end example +EOText; +}; + +/* rewrite 802.1q vlan tags */ +flag = { + name = enet-vlan; + max = 1; + descrip = "Specify ethernet 802.1q VLAN tag mode"; + arg-type = string; + doc = <<- EOText +Allows you to rewrite ethernet frames to add a 802.1q header to standard 802.3 +ethernet headers or remove the 802.1q VLAN tag information. +@table @bullet +@item +@var{add} +Rewrites the existing 802.3 ethernet header as an 802.1q VLAN header +@item +@var{del} +Rewrites the existing 802.1q VLAN header as an 802.3 ethernet header +EOText; +}; + +flag = { + name = enet-vlan-tag; + max = 1; + descrip = "Specify the new ethernet 802.1q VLAN tag value"; + arg-type = number; + flags-must = enet-vlan; + arg-range = "0->4095"; /* VID's are 12bit unsigned int's */ + doc = ""; +}; + +flag = { + name = enet-vlan-cfi; + max = 1; + descrip = "Specify the ethernet 802.1q VLAN CFI value"; + arg-type = number; + flags-must = enet-vlan; + arg-range = "0->1"; /* one bit */ + doc = ""; +}; + +flag = { + name = enet-vlan-pri; + max = 1; + descrip = "Specify the ethernet 802.1q VLAN priority"; + flags-must = enet-vlan; + arg-type = number; + arg-range = "0->7"; /* one byte */ + doc = ""; +}; diff --git a/src/tcpedit/plugins/dlt_hdlc/Makefile.am b/src/tcpedit/plugins/dlt_hdlc/Makefile.am new file mode 100644 index 0000000..908ee08 --- /dev/null +++ b/src/tcpedit/plugins/dlt_hdlc/Makefile.am @@ -0,0 +1,23 @@ +# $Id: Makefile.am 1830 2007-04-21 07:33:54Z aturner $ +# START OF: dlt_hdlc +# Note, if you add any files to your plugin, you will need to edit dlt_/Makefile.am +# add your .c files to libtcpedit_a_SOURCES +# add your .h files to noinst_HEADERS +# add any other files (like documentation, notes, etc) to EXTRA_DIST +# add your dependancy information (see comment below) + +libtcpedit_a_SOURCES += $(srcdir)/plugins/dlt_hdlc/hdlc.c + +noinst_HEADERS += $(srcdir)/plugins/dlt_hdlc/hdlc.h + +EXTRA_DIST += $(srcdir)/plugins/dlt_hdlc/hdlc_opts.def + +# dependancies for your plugin source code. Edit as necessary +$(srcdir)/plugins/dlt_hdlc/hdlc.c: $(srcdir)/tcpedit_stub.h $(srcdir)/plugins/dlt_utils.h \ + $(srcdir)/plugins/dlt_hdlc/hdlc.h $(srcdir)/plugins/dlt_plugins.h $(srcdir)/plugins/dlt_plugins-int.h + +# You probably don't want to touch anything below this line until the end of the plugin + +MOSTLYCLEANFILES += $(srcdir)/plugins/dlt_hdlc/*~ + +# END OF: dlt_hdlc diff --git a/src/tcpedit/plugins/dlt_hdlc/Makefile.in b/src/tcpedit/plugins/dlt_hdlc/Makefile.in new file mode 100644 index 0000000..e69de29 diff --git a/src/tcpedit/plugins/dlt_hdlc/hdlc.c b/src/tcpedit/plugins/dlt_hdlc/hdlc.c new file mode 100644 index 0000000..756d0b8 --- /dev/null +++ b/src/tcpedit/plugins/dlt_hdlc/hdlc.c @@ -0,0 +1,386 @@ +/* $Id: hdlc.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + +#include "dlt_plugins-int.h" +#include "dlt_utils.h" +#include "hdlc.h" +#include "tcpedit.h" +#include "common.h" +#include "tcpr.h" + +static char dlt_name[] = "hdlc"; +static char _U_ dlt_prefix[] = "hdlc"; +static u_int16_t dlt_value = DLT_C_HDLC; + +/* + * Function to register ourselves. This function is always called, regardless + * of what DLT types are being used, so it shouldn't be allocating extra buffers + * or anything like that (use the dlt_hdlc_init() function below for that). + * Tasks: + * - Create a new plugin struct + * - Fill out the provides/requires bit masks. Note: Only specify which fields are + * actually in the header. + * - Add the plugin to the context's plugin chain + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_hdlc_register(tcpeditdlt_t *ctx) +{ + tcpeditdlt_plugin_t *plugin; + assert(ctx); + + /* create a new plugin structure */ + plugin = tcpedit_dlt_newplugin(); + + /* FIXME: set what we provide & require */ + plugin->provides += PLUGIN_MASK_PROTO; + plugin->requires += PLUGIN_MASK_PROTO; + + /* what is our DLT value? */ + plugin->dlt = dlt_value; + + /* set the prefix name of our plugin. This is also used as the prefix for our options */ + plugin->name = safe_strdup(dlt_prefix); + + /* + * Point to our functions, note, you need a function for EVERY method. + * Even if it is only an empty stub returning success. + */ + plugin->plugin_init = dlt_hdlc_init; + plugin->plugin_cleanup = dlt_hdlc_cleanup; + plugin->plugin_parse_opts = dlt_hdlc_parse_opts; + plugin->plugin_decode = dlt_hdlc_decode; + plugin->plugin_encode = dlt_hdlc_encode; + plugin->plugin_proto = dlt_hdlc_proto; + plugin->plugin_l2addr_type = dlt_hdlc_l2addr_type; + plugin->plugin_l2len = dlt_hdlc_l2len; + plugin->plugin_get_layer3 = dlt_hdlc_get_layer3; + plugin->plugin_merge_layer3 = dlt_hdlc_merge_layer3; + plugin->plugin_get_mac = dlt_hdlc_get_mac; + + /* add it to the available plugin list */ + return tcpedit_dlt_addplugin(ctx, plugin); +} + + +/* + * Initializer function. This function is called only once, if and only iif + * this plugin will be utilized. Remember, if you need to keep track of any state, + * store it in your plugin->config, not a global! + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_hdlc_init(tcpeditdlt_t *ctx) +{ + tcpeditdlt_plugin_t *plugin; + hdlc_config_t *config; + assert(ctx); + + if ((plugin = tcpedit_dlt_getplugin(ctx, dlt_value)) == NULL) { + tcpedit_seterr(ctx->tcpedit, "Unable to initalize unregistered plugin %s", dlt_name); + return TCPEDIT_ERROR; + } + + /* allocate memory for our deocde extra data */ + if (sizeof(hdlc_extra_t) > 0) + ctx->decoded_extra = safe_malloc(sizeof(hdlc_extra_t)); + + /* allocate memory for our config data */ + if (sizeof(hdlc_config_t) > 0) + plugin->config = safe_malloc(sizeof(hdlc_config_t)); + + config = (hdlc_config_t *)plugin->config; + + /* default to unset */ + config->address = 65535; + config->control = 65535; + 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_hdlc_init(), this is just an stub. + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_hdlc_cleanup(tcpeditdlt_t *ctx) +{ + tcpeditdlt_plugin_t *plugin; + assert(ctx); + + if ((plugin = tcpedit_dlt_getplugin(ctx, dlt_value)) == NULL) { + tcpedit_seterr(ctx->tcpedit, "Unable to cleanup unregistered plugin %s", dlt_name); + return TCPEDIT_ERROR; + } + + if (ctx->decoded_extra != NULL) { + safe_free(ctx->decoded_extra); + ctx->decoded_extra = NULL; + } + + if (plugin->config != NULL) { + safe_free(plugin->config); + plugin->config = NULL; + } + + return TCPEDIT_OK; /* success */ +} + +/* + * This is where you should define all your AutoGen AutoOpts option parsing. + * Any user specified option should have it's bit turned on in the 'provides' + * bit mask. + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_hdlc_parse_opts(tcpeditdlt_t *ctx) +{ + tcpeditdlt_plugin_t *plugin; + hdlc_config_t *config; + assert(ctx); + + plugin = tcpedit_dlt_getplugin(ctx, dlt_value); + config = plugin->config; + + if (HAVE_OPT(HDLC_CONTROL)) { + config->control = (u_int16_t)OPT_VALUE_HDLC_CONTROL; + } + + if (HAVE_OPT(HDLC_ADDRESS)) { + config->address = (u_int16_t)OPT_VALUE_HDLC_ADDRESS; + } + + return TCPEDIT_OK; /* success */ +} + +/* + * Function to decode the layer 2 header in the packet. + * You need to fill out: + * - ctx->l2len + * - ctx->srcaddr + * - ctx->dstaddr + * - ctx->proto + * - ctx->decoded_extra + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_hdlc_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen) +{ + cisco_hdlc_t *hdlc; + hdlc_extra_t *extra; + assert(ctx); + assert(packet); + assert(pktlen >= 4); + + extra = (hdlc_extra_t *)ctx->decoded_extra; + hdlc = (cisco_hdlc_t *)packet; + + ctx->proto = hdlc->protocol; + ctx->l2len = 4; + + extra->address = hdlc->address; + extra->control = hdlc->control; + + return TCPEDIT_OK; /* success */ +} + +/* + * Function to encode the layer 2 header back into the packet. + * Returns: total packet len or TCPEDIT_ERROR + */ +int +dlt_hdlc_encode(tcpeditdlt_t *ctx, u_char *packet, int pktlen, _U_ tcpr_dir_t dir) +{ + cisco_hdlc_t *hdlc; + hdlc_config_t *config = NULL; + hdlc_extra_t *extra = NULL; + tcpeditdlt_plugin_t *plugin = NULL; + u_char tmpbuff[MAXPACKET]; + int newpktlen; + + assert(ctx); + assert(pktlen >= 4); + assert(packet); + + /* Make room for our new l2 header if old l2len != 4 */ + if (ctx->l2len > 4) { + memmove(packet + 4, packet + ctx->l2len, pktlen - ctx->l2len); + } else if (ctx->l2len < 4) { + memcpy(tmpbuff, packet, pktlen); + memcpy(packet + 4, (tmpbuff + ctx->l2len), pktlen - ctx->l2len); + } + + /* update the total packet length */ + newpktlen = pktlen + 4 - ctx->l2len; + + /* + * HDLC doesn't support direction, since we have no real src/dst addresses + * to deal with, so we just use the original packet data or option data + */ + hdlc = (cisco_hdlc_t *)packet; + plugin = tcpedit_dlt_getplugin(ctx, dlt_value); + config = plugin->config; + extra = (hdlc_extra_t *)ctx->decoded_extra; + + /* set the address field */ + if (config->address < 65535) { + hdlc->address = (u_int8_t)config->address; + } else if (extra->hdlc) { + hdlc->address = extra->hdlc; + } else { + tcpedit_seterr(ctx->tcpedit, "%s", "Non-HDLC packet requires --hdlc-address"); + return TCPEDIT_ERROR; + } + + /* set the control field */ + if (config->control < 65535) { + hdlc->control = (u_int8_t)config->control; + } else if (extra->hdlc) { + hdlc->control = extra->hdlc; + } else { + tcpedit_seterr(ctx->tcpedit, "%s", "Non-HDLC packet requires --hdlc-control"); + return TCPEDIT_ERROR; + } + + /* copy over our protocol */ + hdlc->protocol = ctx->proto; + + return newpktlen; /* success */ +} + +/* + * Function returns the Layer 3 protocol type of the given packet, or TCPEDIT_ERROR on error + */ +int +dlt_hdlc_proto(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen) +{ + cisco_hdlc_t *hdlc; + assert(ctx); + assert(packet); + assert(pktlen >= 4); + + hdlc = (cisco_hdlc_t *)packet; + + return hdlc->protocol; +} + +/* + * Function returns a pointer to the layer 3 protocol header or NULL on error + */ +u_char * +dlt_hdlc_get_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen) +{ + int l2len; + assert(ctx); + assert(packet); + + /* FIXME: Is there anything else we need to do?? */ + l2len = dlt_hdlc_l2len(ctx, packet, pktlen); + + assert(pktlen >= l2len); + + return tcpedit_dlt_l3data_copy(ctx, packet, pktlen, l2len); +} + +/* + * function merges the packet (containing L2 and old L3) with the l3data buffer + * containing the new l3 data. Note, if L2 % 4 == 0, then they're pointing to the + * same buffer, otherwise there was a memcpy involved on strictly aligned architectures + * like SPARC + */ +u_char * +dlt_hdlc_merge_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen, u_char *l3data) +{ + int l2len; + assert(ctx); + assert(packet); + assert(l3data); + + /* FIXME: Is there anything else we need to do?? */ + l2len = dlt_hdlc_l2len(ctx, packet, pktlen); + + assert(pktlen >= l2len); + + return tcpedit_dlt_l3data_merge(ctx, packet, pktlen, l3data, l2len); +} + +/* + * return the length of the L2 header of the current packet + */ +int +dlt_hdlc_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen) +{ + assert(ctx); + assert(packet); + assert(pktlen); + + /* HDLC is a static 4 bytes */ + return 4; +} + +/* + * return a static pointer to the source/destination MAC address + * return NULL on error/address doesn't exist + */ +u_char * +dlt_hdlc_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen) +{ + assert(ctx); + assert(packet); + assert(pktlen); + + /* FIXME: return a ptr to the source or dest mac address. */ + switch(mac) { + case SRC_MAC: + return(NULL); + break; + + case DST_MAC: + memcpy(ctx->dstmac, packet, 2); + return(ctx->dstmac); + break; + + default: + errx(-1, "Invalid tcpeditdlt_mac_type_t: %d", mac); + } + return(NULL); +} + +tcpeditdlt_l2addr_type_t +dlt_hdlc_l2addr_type(void) +{ + return C_HDLC; +} + diff --git a/src/tcpedit/plugins/dlt_hdlc/hdlc.h b/src/tcpedit/plugins/dlt_hdlc/hdlc.h new file mode 100644 index 0000000..cb7eadb --- /dev/null +++ b/src/tcpedit/plugins/dlt_hdlc/hdlc.h @@ -0,0 +1,91 @@ +/* $Id: hdlc.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#include "dlt_plugins-int.h" + +#ifndef _DLT_hdlc_H_ +#define _DLT_hdlc_H_ + +int dlt_hdlc_register(tcpeditdlt_t *ctx); +int dlt_hdlc_init(tcpeditdlt_t *ctx); +int dlt_hdlc_cleanup(tcpeditdlt_t *ctx); +int dlt_hdlc_parse_opts(tcpeditdlt_t *ctx); +int dlt_hdlc_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); +int dlt_hdlc_encode(tcpeditdlt_t *ctx, u_char *packet, int pktlen, tcpr_dir_t dir); +int dlt_hdlc_proto(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); +u_char *dlt_hdlc_get_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen); +u_char *dlt_hdlc_merge_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen, u_char *l3data); +tcpeditdlt_l2addr_type_t dlt_hdlc_l2addr_type(void); +int dlt_hdlc_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); +u_char *dlt_hdlc_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen); + +/* + * structure to hold any data parsed from the packet by the decoder. + * Example: Ethernet VLAN tag info + */ +struct hdlc_extra_s { + int hdlc; /* set to 1 if values below are filled out */ + u_int8_t address; + u_int8_t control; +}; +typedef struct hdlc_extra_s hdlc_extra_t; + + +/* + * FIXME: structure to hold any data in the tcpeditdlt_plugin_t->config + * Things like: + * - Parsed user options + * - State between packets + * - Note, you should only use this for the encoder function, decoder functions should place + * "extra" data parsed from the packet in the tcpeditdlt_t->decoded_extra buffer since that + * is available to any encoder plugin. + */ +struct hdlc_config_s { + /* user defined values. 65535 == unset */ + u_int16_t address; + u_int16_t control; +}; +typedef struct hdlc_config_s hdlc_config_t; + +/* Cisco HDLC has a simple 32 bit header */ +#define CISCO_HDLC_LEN 4 +struct cisco_hdlc_s { + u_int8_t address; +#define CISCO_HDLC_ADDR_UNICAST 0x0F +#define CISCO_HDLC_ADDR_BROADCAST 0x8F + u_int8_t control; // always zero + u_int16_t protocol; +}; +typedef struct cisco_hdlc_s cisco_hdlc_t; +#endif + diff --git a/src/tcpedit/plugins/dlt_hdlc/hdlc_opts.def b/src/tcpedit/plugins/dlt_hdlc/hdlc_opts.def new file mode 100644 index 0000000..5401003 --- /dev/null +++ b/src/tcpedit/plugins/dlt_hdlc/hdlc_opts.def @@ -0,0 +1,35 @@ +/* Add the flag definitions for your plugin here */ + +/* rewrite HDLC control */ +flag = { + name = hdlc-control; + max = 1; + descrip = "Specify HDLC control value"; + arg-type = "number"; + range = "0->255"; + doc = <<- EOText +The Cisco HDLC header has a 1 byte "control" field. Apparently this should +always be 0, but if you can use any 1 byte value. +EOText; +}; + +flag = { + name = hdlc-address; + max = 1; + descrip = "Specify HDLC address"; + arg-type = "number"; + range = "0->255"; + doc = <<- EOText +The Cisco HDLC header has a 1 byte "address" field which has two valid +values: +@table @bullet +@item +@var{0x0F} +Unicast +@item +@var{0xBF} +Broadcast +@end table +You can however specify any single byte value. +EOText; +}; \ No newline at end of file diff --git a/src/tcpedit/plugins/dlt_ieee80211/Makefile.am b/src/tcpedit/plugins/dlt_ieee80211/Makefile.am new file mode 100644 index 0000000..c274972 --- /dev/null +++ b/src/tcpedit/plugins/dlt_ieee80211/Makefile.am @@ -0,0 +1,26 @@ +# $Id: Makefile.am 1838 2007-04-22 18:23:38Z aturner $ +# START OF: dlt_ieee80211 +# Note, if you add any files to your plugin, you will need to edit dlt_ieee80211/Makefile.am +# add your .c files to libtcpedit_a_SOURCES +# add your .h files to noinst_HEADERS +# add any other files (like documentation, notes, etc) to EXTRA_DIST +# add your dependancy information (see comment below) + +libtcpedit_a_SOURCES += $(srcdir)/plugins/dlt_ieee80211/ieee80211.c $(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c + +noinst_HEADERS += $(srcdir)/plugins/dlt_ieee80211/ieee80211.h $(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.h + +EXTRA_DIST += $(srcdir)/plugins/dlt_ieee80211/ieee80211_opts.def + +# dependancies for your plugin source code. Edit as necessary +$(srcdir)/plugins/dlt_ieee80211/ieee80211.c: $(srcdir)/tcpedit_stub.h $(srcdir)/plugins/dlt_utils.h \ + $(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.c $(srcdir)/plugins/dlt_ieee80211/ieee80211_hdr.h \ + $(srcdir)/plugins/dlt_ieee80211/ieee80211.h $(srcdir)/plugins/dlt_plugins.h $(srcdir)/plugins/dlt_plugins-int.h + +# You probably don't want to touch anything below this line until the end of the plugin + +DLT_STUB_DEPS += $(srcdir)/plugins/dlt_ieee80211/ieee80211_opts.def + +MOSTLYCLEANFILES += $(srcdir)/plugins/dlt_ieee80211/*~ + +# END OF: dlt_ieee80211 diff --git a/src/tcpedit/plugins/dlt_ieee80211/Makefile.in b/src/tcpedit/plugins/dlt_ieee80211/Makefile.in new file mode 100644 index 0000000..e69de29 diff --git a/src/tcpedit/plugins/dlt_ieee80211/ieee80211.c b/src/tcpedit/plugins/dlt_ieee80211/ieee80211.c new file mode 100644 index 0000000..bb87630 --- /dev/null +++ b/src/tcpedit/plugins/dlt_ieee80211/ieee80211.c @@ -0,0 +1,416 @@ +/* $Id: ieee80211.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + +#include "dlt_plugins-int.h" +#include "dlt_utils.h" +#include "ieee80211.h" +#include "ieee80211_hdr.h" +#include "tcpedit.h" +#include "common.h" +#include "tcpr.h" + +/* + * Notes about the ieee80211 plugin: + * 802.11 is a little different from most other L2 protocols: + * - Not all frames are data frames (control, data, management) (data frame == L3 or higher included) + * - Not all data frames have data (QoS frames are "data" frames, but have no L3 header) + * - L2 header is 802.11 + an 802.2/802.2SNAP header + */ +static char dlt_name[] = "ieee80211"; +_U_ static char dlt_prefix[] = "ieee802_11"; +static u_int16_t dlt_value = DLT_IEEE802_11; + +/* + * Function to register ourselves. This function is always called, regardless + * of what DLT types are being used, so it shouldn't be allocating extra buffers + * or anything like that (use the dlt_ieee80211_init() function below for that). + * Tasks: + * - Create a new plugin struct + * - Fill out the provides/requires bit masks. Note: Only specify which fields are + * actually in the header. + * - Add the plugin to the context's plugin chain + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_ieee80211_register(tcpeditdlt_t *ctx) +{ + tcpeditdlt_plugin_t *plugin; + assert(ctx); + + /* create a new plugin structure */ + plugin = tcpedit_dlt_newplugin(); + + /* we're a decoder only plugin */ + plugin->provides += PLUGIN_MASK_PROTO + PLUGIN_MASK_SRCADDR + PLUGIN_MASK_DSTADDR; + plugin->requires += 0; + + /* what is our DLT value? */ + plugin->dlt = dlt_value; + + /* set the prefix name of our plugin. This is also used as the prefix for our options */ + plugin->name = safe_strdup(dlt_name); + + /* + * Point to our functions, note, you need a function for EVERY method. + * Even if it is only an empty stub returning success. + */ + plugin->plugin_init = dlt_ieee80211_init; + plugin->plugin_cleanup = dlt_ieee80211_cleanup; + plugin->plugin_parse_opts = dlt_ieee80211_parse_opts; + plugin->plugin_decode = dlt_ieee80211_decode; + plugin->plugin_encode = dlt_ieee80211_encode; + plugin->plugin_proto = dlt_ieee80211_proto; + plugin->plugin_l2addr_type = dlt_ieee80211_l2addr_type; + plugin->plugin_l2len = dlt_ieee80211_l2len; + plugin->plugin_get_layer3 = dlt_ieee80211_get_layer3; + plugin->plugin_merge_layer3 = dlt_ieee80211_merge_layer3; + plugin->plugin_get_mac = dlt_ieee80211_get_mac; + + /* add it to the available plugin list */ + return tcpedit_dlt_addplugin(ctx, plugin); +} + + +/* + * Initializer function. This function is called only once, if and only iif + * this plugin will be utilized. Remember, if you need to keep track of any state, + * store it in your plugin->config, not a global! + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_ieee80211_init(tcpeditdlt_t *ctx) +{ + tcpeditdlt_plugin_t *plugin; + ieee80211_config_t *config; + assert(ctx); + + if ((plugin = tcpedit_dlt_getplugin(ctx, dlt_value)) == NULL) { + tcpedit_seterr(ctx->tcpedit, "Unable to initalize unregistered plugin %s", dlt_name); + return TCPEDIT_ERROR; + } + + /* allocate memory for our deocde extra data */ + if (sizeof(ieee80211_extra_t) > 0) + ctx->decoded_extra = safe_malloc(sizeof(ieee80211_extra_t)); + + /* allocate memory for our config data */ + if (sizeof(ieee80211_config_t) > 0) + plugin->config = safe_malloc(sizeof(ieee80211_config_t)); + + config = (ieee80211_config_t *)plugin->config; + + /* FIXME: set default config values here */ + + return TCPEDIT_OK; /* success */ +} + +/* + * Since this is used in a library, we should manually clean up after ourselves + * Unless you allocated some memory in dlt_ieee80211_init(), this is just an stub. + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_ieee80211_cleanup(tcpeditdlt_t *ctx) +{ + tcpeditdlt_plugin_t *plugin; + assert(ctx); + + if ((plugin = tcpedit_dlt_getplugin(ctx, dlt_value)) == NULL) { + tcpedit_seterr(ctx->tcpedit, "Unable to cleanup unregistered plugin %s", dlt_name); + return TCPEDIT_ERROR; + } + + if (ctx->decoded_extra != NULL) { + safe_free(ctx->decoded_extra); + ctx->decoded_extra = NULL; + } + + if (plugin->config != NULL) { + safe_free(plugin->config); + plugin->config = NULL; + } + + return TCPEDIT_OK; /* success */ +} + +/* + * This is where you should define all your AutoGen AutoOpts option parsing. + * Any user specified option should have it's bit turned on in the 'provides' + * bit mask. + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_ieee80211_parse_opts(tcpeditdlt_t *ctx) +{ + assert(ctx); + + /* we have none */ + + return TCPEDIT_OK; /* success */ +} + +/* + * Function to decode the layer 2 header in the packet. + * You need to fill out: + * - ctx->l2len + * - ctx->srcaddr + * - ctx->dstaddr + * - ctx->proto + * - ctx->decoded_extra + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_ieee80211_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen) +{ + assert(ctx); + assert(packet); + assert(pktlen >= dlt_ieee80211_l2len(ctx, packet, pktlen)); + + dbgx(3, "Decoding 802.11 packet " COUNTER_SPEC, ctx->tcpedit->runtime.packetnum); + if (! ieee80211_is_data(ctx, packet, pktlen)) { + tcpedit_seterr(ctx->tcpedit, "Packet " COUNTER_SPEC " is not a normal 802.11 data frame", + ctx->tcpedit->runtime.packetnum); + return TCPEDIT_SOFT_ERROR; + } + + if (ieee80211_is_encrypted(ctx, packet, pktlen)) { + tcpedit_seterr(ctx->tcpedit, "Packet " COUNTER_SPEC " is encrypted. Unable to decode frame.", + ctx->tcpedit->runtime.packetnum); + return TCPEDIT_SOFT_ERROR; + } + + ctx->l2len = dlt_ieee80211_l2len(ctx, packet, pktlen); + memcpy(&(ctx->srcaddr), ieee80211_get_src((ieee80211_hdr_t *)packet), ETHER_ADDR_LEN); + memcpy(&(ctx->dstaddr), ieee80211_get_dst((ieee80211_hdr_t *)packet), ETHER_ADDR_LEN); + ctx->proto = dlt_ieee80211_proto(ctx, packet, pktlen); + + return TCPEDIT_OK; /* success */ +} + +/* + * Function to encode the layer 2 header back into the packet. + * Returns: total packet len or TCPEDIT_ERROR + */ +int +dlt_ieee80211_encode(tcpeditdlt_t *ctx, u_char *packet, int pktlen, _U_ tcpr_dir_t dir) +{ + assert(ctx); + assert(pktlen); + assert(packet); + + tcpedit_seterr(ctx->tcpedit, "%s", "DLT_IEEE802_11 plugin does not support packet encoding"); + return TCPEDIT_ERROR; +} + +/* + * Function returns the Layer 3 protocol type of the given packet, or TCPEDIT_ERROR on error + */ +int +dlt_ieee80211_proto(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen) +{ + int l2len; + int hdrlen = 0; + u_int16_t *frame_control, fc; + struct tcpr_802_2snap_hdr *hdr; + + assert(ctx); + assert(packet); + + l2len = dlt_ieee80211_l2len(ctx, packet, pktlen); + assert(pktlen >= l2len); + + /* check 802.11 frame control field */ + frame_control = (u_int16_t *)packet; + fc = ntohs(*frame_control); + + /* Not all 802.11 frames have data */ + if ((fc & ieee80211_FC_TYPE_MASK) != ieee80211_FC_TYPE_DATA) + return TCPEDIT_SOFT_ERROR; + + /* Some data frames are QoS and have no data + if (((fc & ieee80211_FC_SUBTYPE_MASK) & ieee80211_FC_SUBTYPE_QOS) == ieee80211_FC_SUBTYPE_QOS) + return TCPEDIT_SOFT_ERROR; + */ + if ((fc & ieee80211_FC_SUBTYPE_QOS) == ieee80211_FC_SUBTYPE_QOS) { + hdrlen += 2; + } + + /* figure out the actual header length */ + if (ieee80211_USE_4(fc)) { + hdrlen += sizeof(ieee80211_addr4_hdr_t); + } else { + hdrlen += sizeof(ieee80211_hdr_t); + } + + hdr = (struct tcpr_802_2snap_hdr *)&packet[hdrlen]; + + /* verify the header is 802.2SNAP (8 bytes) not 802.2 (3 bytes) */ + if (hdr->snap_dsap == 0xAA && hdr->snap_ssap == 0xAA) + return hdr->snap_type; + + + return TCPEDIT_SOFT_ERROR; /* 802.2 has no type field */ +} + +/* + * Function returns a pointer to the layer 3 protocol header or NULL on error + */ +u_char * +dlt_ieee80211_get_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen) +{ + int l2len; + assert(ctx); + assert(packet); + + l2len = dlt_ieee80211_l2len(ctx, packet, pktlen); + + assert(pktlen >= l2len); + dbgx(1, "Getting data for packet " COUNTER_SPEC " from offset: %d", ctx->tcpedit->runtime.packetnum, l2len); + + return tcpedit_dlt_l3data_copy(ctx, packet, pktlen, l2len); +} + +/* + * function merges the packet (containing L2 and old L3) with the l3data buffer + * containing the new l3 data. Note, if L2 % 4 == 0, then they're pointing to the + * same buffer, otherwise there was a memcpy involved on strictly aligned architectures + * like SPARC + */ +u_char * +dlt_ieee80211_merge_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen, u_char *l3data) +{ + int l2len; + assert(ctx); + assert(packet); + assert(l3data); + + + l2len = dlt_ieee80211_l2len(ctx, packet, pktlen); + + assert(pktlen >= l2len); + + return tcpedit_dlt_l3data_merge(ctx, packet, pktlen, l3data, l2len); +} + +/* + * return the length of the L2 header of the current packet + * based on: http://www.tcpdump.org/lists/workers/2004/07/msg00121.html + */ +int +dlt_ieee80211_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen) +{ + u_int16_t *frame_control, fc; + struct tcpr_802_2snap_hdr *hdr; + int hdrlen = 0; + + + assert(ctx); + assert(packet); + assert(pktlen); + + dbgx(2, "packet = %p\t\tplen = %d", packet, pktlen); + + frame_control = (u_int16_t *)packet; + fc = ntohs(*frame_control); + + + if (ieee80211_USE_4(fc)) { + hdrlen = sizeof(ieee80211_addr4_hdr_t); + } else { + hdrlen = sizeof(ieee80211_hdr_t); + } + + /* if Data/QoS, then L2 len is + 2 bytes */ + if ((fc & ieee80211_FC_SUBTYPE_QOS) == ieee80211_FC_SUBTYPE_QOS) { + dbgx(2, "total header length (fc %04x) (802.11 + QoS data): %d", fc, hdrlen + 2); + hdrlen += 2; + } + + if (pktlen >= (hdrlen + (int)sizeof(struct tcpr_802_2snap_hdr))) { + + hdr = (struct tcpr_802_2snap_hdr *)&packet[hdrlen]; + + /* verify the header is 802.2SNAP (8 bytes) not 802.2 (3 bytes) */ + if (hdr->snap_dsap == 0xAA && hdr->snap_ssap == 0xAA) { + hdrlen += (int)sizeof(struct tcpr_802_2snap_hdr); + dbgx(2, "total header length (802.11 + 802.2SNAP): %d", hdrlen); + } else { + hdrlen += (int)sizeof(struct tcpr_802_2_hdr); + dbgx(2, "total header length (802.11 + 802.2): %d (%02x/%02x)", hdrlen, hdr->snap_dsap, hdr->snap_ssap); + } + } + + dbgx(2, "header length: %d", hdrlen); + return hdrlen; +} + +/* + * return a static pointer to the source/destination MAC address + * return NULL on error/address doesn't exist + */ +u_char * +dlt_ieee80211_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen) +{ + assert(ctx); + assert(packet); + assert(pktlen); + char *macaddr; + + switch(mac) { + case SRC_MAC: + macaddr = ieee80211_get_src(packet); + memcpy(ctx->srcmac, macaddr, ETHER_ADDR_LEN); + return(ctx->srcmac); + break; + + case DST_MAC: + macaddr = ieee80211_get_dst(packet); + memcpy(ctx->dstmac, macaddr, ETHER_ADDR_LEN); + return(ctx->dstmac); + break; + + default: + errx(1, "Invalid tcpeditdlt_mac_type_t: %d", mac); + } + return(NULL); +} + + +tcpeditdlt_l2addr_type_t +dlt_ieee80211_l2addr_type(void) +{ + return ETHERNET; +} + diff --git a/src/tcpedit/plugins/dlt_ieee80211/ieee80211.h b/src/tcpedit/plugins/dlt_ieee80211/ieee80211.h new file mode 100644 index 0000000..10661d8 --- /dev/null +++ b/src/tcpedit/plugins/dlt_ieee80211/ieee80211.h @@ -0,0 +1,130 @@ +/* $Id: ieee80211.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#include "dlt_plugins-int.h" + +#ifndef _DLT_ieee80211_H_ +#define _DLT_ieee80211_H_ + +int dlt_ieee80211_register(tcpeditdlt_t *ctx); +int dlt_ieee80211_init(tcpeditdlt_t *ctx); +int dlt_ieee80211_cleanup(tcpeditdlt_t *ctx); +int dlt_ieee80211_parse_opts(tcpeditdlt_t *ctx); +int dlt_ieee80211_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); +int dlt_ieee80211_encode(tcpeditdlt_t *ctx, u_char *packet, int pktlen, tcpr_dir_t dir); +int dlt_ieee80211_proto(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); +u_char *dlt_ieee80211_get_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen); +u_char *dlt_ieee80211_merge_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen, u_char *l3data); +tcpeditdlt_l2addr_type_t dlt_ieee80211_l2addr_type(void); +int dlt_ieee80211_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); +u_char *dlt_ieee80211_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen); + +/* 802.11 packet header w/ 3 addresses (non-WDS) */ +struct ieee80211_hdr_s { + u_int16_t frame_control; +/* version is first two bytes */ +#define ieee80211_FC_VERSION_MASK 0x0300 + +/* type is second 2 bytes */ +#define ieee80211_FC_TYPE_MASK 0x0F00 +#define ieee80211_FC_TYPE_DATA 0x0800 +#define ieee80211_FC_TYPE_MGMT 0x0000 +#define ieee80211_FC_TYPE_CONTROL 0x0400 + +/* subtype is the 4 high bytes */ +#define ieee80211_FC_SUBTYPE_MASK 0xF000 +#define ieee80211_FC_SUBTYPE_QOS 0x8000 /* high bit is QoS, but there are sub-sub types for QoS */ +#define ieee80211_FC_SUBTYPE_NULL 0xC000 /* no data */ + +/* Direction */ +#define ieee80211_FC_TO_DS_MASK 0x0001 +#define ieee80211_FC_FROM_DS_MASK 0x0002 + +/* Flags */ +#define ieee80211_FC_MORE_FRAG 0x0004 +#define ieee80211_FC_RETRY_MASK 0x0008 +#define ieee80211_FC_PWR_MGMT_MASK 0x0010 +#define ieee80211_FC_MORE_DATA_MASK 0x0020 +#define ieee80211_FC_WEP_MASK 0x0040 +#define ieee80211_FC_ORDER_MASK 0x0080 + u_int16_t duration; + u_char addr1[6]; + u_char addr2[6]; + u_char addr3[6]; + u_int16_t fragid; +}; +typedef struct ieee80211_hdr_s ieee80211_hdr_t; + +struct ieee80211_addr4_hdr_s { + u_int16_t frame_control; + u_int16_t duration; + u_char addr1[6]; + u_char addr2[6]; + u_char addr3[6]; + u_char addr4[6]; + u_int16_t fragid; +}; +typedef struct ieee80211_addr4_hdr_s ieee80211_addr4_hdr_t; + +#define ieee80211_USE_4(frame_control) \ + (frame_control & (ieee80211_FC_TO_DS_MASK + ieee80211_FC_FROM_DS_MASK)) == \ + (ieee80211_FC_TO_DS_MASK + ieee80211_FC_FROM_DS_MASK) + +/* + * FIXME: structure to hold any data parsed from the packet by the decoder. + * Example: Ethernet VLAN tag info + */ +struct ieee80211_extra_s { + /* dummy entry for SunPro compiler which doesn't like empty structs */ + int dummy; +}; +typedef struct ieee80211_extra_s ieee80211_extra_t; + + +/* + * FIXME: structure to hold any data in the tcpeditdlt_plugin_t->config + * Things like: + * - Parsed user options + * - State between packets + * - Note, you should only use this for the encoder function, decoder functions should place + * "extra" data parsed from the packet in the tcpeditdlt_t->decoded_extra buffer since that + * is available to any encoder plugin. + */ +struct ieee80211_config_s { + /* dummy entry for SunPro compiler which doesn't like empty structs */ + int dummy; +}; +typedef struct ieee80211_config_s ieee80211_config_t; + + +#endif diff --git a/src/tcpedit/plugins/dlt_ieee80211/ieee80211_hdr.c b/src/tcpedit/plugins/dlt_ieee80211/ieee80211_hdr.c new file mode 100644 index 0000000..476da67 --- /dev/null +++ b/src/tcpedit/plugins/dlt_ieee80211/ieee80211_hdr.c @@ -0,0 +1,206 @@ +/* $Id: ieee80211_hdr.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + +#include "dlt_plugins-int.h" +#include "ieee80211.h" + +/* + * Does the given 802.11 header have data? + * returns 1 for true & 0 for false + */ +int +ieee80211_is_data(tcpeditdlt_t *ctx, const void *packet, const int pktlen) +{ + u_int16_t *frame_control, fc; + struct tcpr_802_2snap_hdr *snap; + int hdrlen = 0; + + assert(ctx); + assert(packet); + + /* Ack, Auth, NULL packets often are very small (10-30 bytes) */ + if (pktlen <= (int)sizeof(ieee80211_hdr_t)) { + dbgx(1, "**** packet " COUNTER_SPEC " is too small (%d)", ctx->tcpedit->runtime.packetnum, pktlen); + return 0; + } + + /* + * Fields: Version|Type|Subtype|Flags + * Bytes: 2|2|4|8 + * Types: 00 = Management, 01 = Control, 10 = Data + * Data Subtypes (in binary): + * 0000 - Data + * 0001 - Data + Ack + * 0010 - Data + Poll + * 0011 - Data + Ack + Poll + * 01?? - Data + Null (no data) + * 1000 - QoS (w/ data) + * 1100 - QoS (no data) + * 1??? - Reserved (beacon, etc) + * FIXME: + * So right now, we only look for pure data frames, since I'm not sure what to do with ACK/Poll + */ + + frame_control = (u_int16_t *)packet; + fc = ntohs(*frame_control); + + /* reserved == no data */ + if ((fc & ieee80211_FC_SUBTYPE_MASK) == ieee80211_FC_SUBTYPE_NULL) { + dbg(2, "packet is NULL"); + return 1; + } + + /* check for data */ + if ((fc & ieee80211_FC_TYPE_MASK) == ieee80211_FC_TYPE_DATA) { + dbg(2, "packet has data bit set"); + return 1; + } + + /* QoS is set by the high bit, all the lower bits are QoS sub-types + QoS seems to add 2 bytes of data at the end of the 802.11 hdr */ + if ((fc & ieee80211_FC_SUBTYPE_MASK) >= ieee80211_FC_SUBTYPE_QOS) { + hdrlen += 2; + } + + /* frame must also have a 802.2 SNAP header */ + if (ieee80211_USE_4(fc)) { + hdrlen += sizeof(ieee80211_addr4_hdr_t); + } else { + hdrlen += sizeof(ieee80211_hdr_t); + } + + if (pktlen < hdrlen + (int)sizeof(struct tcpr_802_2snap_hdr)) { + return 0; /* not long enough for SNAP */ + } + + snap = (struct tcpr_802_2snap_hdr *)&((u_char *)packet)[hdrlen]; + + /* verify the header is 802.2SNAP (8 bytes) not 802.2 (3 bytes) */ + if (snap->snap_dsap == 0xAA && snap->snap_ssap == 0xAA) { + dbg(2, "packet is 802.2SNAP which I think always has data"); + return 1; + } + + warnx("Packet " COUNTER_SPEC " is unknown reason for non-data", ctx->tcpedit->runtime.packetnum); + + return 0; +} + +/* + * returns 1 if WEP is enabled, 0 if not + */ +int +ieee80211_is_encrypted(tcpeditdlt_t *ctx, const void *packet, const int pktlen) +{ + u_int16_t *frame_control, fc; + + assert(ctx); + assert(packet); + assert(pktlen >= (int)sizeof(ieee80211_hdr_t)); + + frame_control = (u_int16_t *)packet; + fc = ntohs(*frame_control); + + if ((fc & ieee80211_FC_WEP_MASK) == ieee80211_FC_WEP_MASK) { + return 1; + } + return 0; +} + +/* + * 802.11 headers are variable length and the clients (non-AP's) have their + * src & dst MAC addresses in different places in the header based on the + * flags set in the first two bytes of the header (frame control) + */ + +u_char * +ieee80211_get_src(const void *header) +{ + ieee80211_hdr_t *addr3; + ieee80211_addr4_hdr_t *addr4; + u_int16_t *frame_control, fc; + + assert(header); + frame_control = (u_int16_t *)header; + fc = ntohs(*frame_control); + + if (ieee80211_USE_4(fc)) { + addr4 = (ieee80211_addr4_hdr_t *)header; + return addr4->addr4; + } else { + addr3 = (ieee80211_hdr_t *)header; + switch (fc & (ieee80211_FC_TO_DS_MASK + ieee80211_FC_FROM_DS_MASK)) { + case ieee80211_FC_TO_DS_MASK: + return addr3->addr2; + case ieee80211_FC_FROM_DS_MASK: + return addr3->addr3; + case 0: + return addr3->addr2; + default: + err(-1, "Whoops... we shouldn't of gotten here."); + } + } + return NULL; +} + +u_char * +ieee80211_get_dst(const void *header) +{ + ieee80211_hdr_t *addr3; + ieee80211_addr4_hdr_t *addr4; + u_int16_t *frame_control, fc; + + assert(header); + frame_control = (u_int16_t *)header; + fc = ntohs(*frame_control); + + if (ieee80211_USE_4(fc)) { + addr4 = (ieee80211_addr4_hdr_t *)header; + return addr4->addr3; + } else { + addr3 = (ieee80211_hdr_t *)header; + switch (fc & (ieee80211_FC_TO_DS_MASK + ieee80211_FC_FROM_DS_MASK)) { + case ieee80211_FC_TO_DS_MASK: + return addr3->addr3; + case ieee80211_FC_FROM_DS_MASK: + return addr3->addr1; + case 0: + return addr3->addr3; + default: + err(-1, "Whoops... we shouldn't of gotten here."); + } + } + return NULL; +} diff --git a/src/tcpedit/plugins/dlt_ieee80211/ieee80211_hdr.h b/src/tcpedit/plugins/dlt_ieee80211/ieee80211_hdr.h new file mode 100644 index 0000000..ea3cdb3 --- /dev/null +++ b/src/tcpedit/plugins/dlt_ieee80211/ieee80211_hdr.h @@ -0,0 +1,46 @@ +/* $Id: ieee80211_hdr.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2007-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#include "dlt_plugins-int.h" + +#ifndef _DLT_ieee80211_hdr_H_ +#define _DLT_ieee80211_hdr_H_ +#include "ieee80211.h" + +int ieee80211_is_data(tcpeditdlt_t *ctx, const void *packet, const int pktlen); +int ieee80211_is_encrypted(tcpeditdlt_t *ctx, const void *packet, const int pktlen); + +char *ieee80211_get_src(const void *header); +char *ieee80211_get_dst(const void *header); + +#endif diff --git a/src/tcpedit/plugins/dlt_ieee80211/ieee80211_opts.def b/src/tcpedit/plugins/dlt_ieee80211/ieee80211_opts.def new file mode 100644 index 0000000..2b79413 --- /dev/null +++ b/src/tcpedit/plugins/dlt_ieee80211/ieee80211_opts.def @@ -0,0 +1 @@ +/* Add the flag definitions for your plugin here */ diff --git a/src/tcpedit/plugins/dlt_linuxsll/Makefile.am b/src/tcpedit/plugins/dlt_linuxsll/Makefile.am new file mode 100644 index 0000000..d2457d2 --- /dev/null +++ b/src/tcpedit/plugins/dlt_linuxsll/Makefile.am @@ -0,0 +1,25 @@ +# $Id: Makefile.am 1830 2007-04-21 07:33:54Z aturner $ +# START OF: dlt_linuxsll +# Note, if you add any files to your plugin, you will need to edit dlt_/Makefile.am +# add your .c files to libtcpedit_a_SOURCES +# add your .h files to noinst_HEADERS +# add any other files (like documentation, notes, etc) to EXTRA_DIST +# add your dependancy information (see comment below) + +libtcpedit_a_SOURCES += $(srcdir)/plugins/dlt_linuxsll/linuxsll.c + +noinst_HEADERS += $(srcdir)/plugins/dlt_linuxsll/linuxsll.h + +EXTRA_DIST += $(srcdir)/plugins/dlt_linuxsll/linuxsll_opts.def + +# dependancies for your plugin source code. Edit as necessary +$(srcdir)/plugins/dlt_linuxsll/linuxsll.c: $(srcdir)/tcpedit_stub.h $(srcdir)/plugins/dlt_utils.h \ + $(srcdir)/plugins/dlt_linuxsll/linuxsll.h $(srcdir)/plugins/dlt_plugins.h $(srcdir)/plugins/dlt_plugins-int.h + +# You probably don't want to touch anything below this line until the end of the plugin + +DLT_STUB_DEPS += $(srcdir)/plugins/dlt_linuxsll/linuxsll_opts.def + +MOSTLYCLEANFILES += $(srcdir)/plugins/dlt_linuxsll/*~ + +# END OF: dlt_linuxsll diff --git a/src/tcpedit/plugins/dlt_linuxsll/Makefile.in b/src/tcpedit/plugins/dlt_linuxsll/Makefile.in new file mode 100644 index 0000000..e69de29 diff --git a/src/tcpedit/plugins/dlt_linuxsll/linuxsll.c b/src/tcpedit/plugins/dlt_linuxsll/linuxsll.c new file mode 100644 index 0000000..d61af5e --- /dev/null +++ b/src/tcpedit/plugins/dlt_linuxsll/linuxsll.c @@ -0,0 +1,324 @@ +/* $Id: linuxsll.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + +#include "dlt_plugins-int.h" +#include "dlt_utils.h" +#include "linuxsll.h" +#include "tcpedit.h" +#include "common.h" +#include "tcpr.h" + +static char dlt_name[] = "linuxsll"; +static char _U_ dlt_prefix[] = "linuxsll"; +static u_int16_t dlt_value = DLT_LINUX_SLL; + +/* + * Function to register ourselves. This function is always called, regardless + * of what DLT types are being used, so it shouldn't be allocating extra buffers + * or anything like that (use the dlt_linuxsll_init() function below for that). + * Tasks: + * - Create a new plugin struct + * - Fill out the provides/requires bit masks. Note: Only specify which fields are + * actually in the header. + * - Add the plugin to the context's plugin chain + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_linuxsll_register(tcpeditdlt_t *ctx) +{ + tcpeditdlt_plugin_t *plugin; + assert(ctx); + + /* create a new plugin structure */ + plugin = tcpedit_dlt_newplugin(); + + /* FIXME: set what we provide & require */ + plugin->provides += PLUGIN_MASK_PROTO + PLUGIN_MASK_SRCADDR; + plugin->requires += 0; + + + /* what is our DLT value? */ + plugin->dlt = dlt_value; + + /* set the prefix name of our plugin. This is also used as the prefix for our options */ + plugin->name = safe_strdup(dlt_prefix); + + /* + * Point to our functions, note, you need a function for EVERY method. + * Even if it is only an empty stub returning success. + */ + plugin->plugin_init = dlt_linuxsll_init; + plugin->plugin_cleanup = dlt_linuxsll_cleanup; + plugin->plugin_parse_opts = dlt_linuxsll_parse_opts; + plugin->plugin_decode = dlt_linuxsll_decode; + plugin->plugin_encode = dlt_linuxsll_encode; + plugin->plugin_proto = dlt_linuxsll_proto; + plugin->plugin_l2addr_type = dlt_linuxsll_l2addr_type; + plugin->plugin_l2len = dlt_linuxsll_l2len; + plugin->plugin_get_layer3 = dlt_linuxsll_get_layer3; + plugin->plugin_merge_layer3 = dlt_linuxsll_merge_layer3; + plugin->plugin_get_mac = dlt_linuxsll_get_mac; + + /* add it to the available plugin list */ + return tcpedit_dlt_addplugin(ctx, plugin); +} + + +/* + * Initializer function. This function is called only once, if and only iif + * this plugin will be utilized. Remember, if you need to keep track of any state, + * store it in your plugin->config, not a global! + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_linuxsll_init(tcpeditdlt_t *ctx) +{ + tcpeditdlt_plugin_t *plugin; + linuxsll_config_t *config; + assert(ctx); + + if ((plugin = tcpedit_dlt_getplugin(ctx, dlt_value)) == NULL) { + tcpedit_seterr(ctx->tcpedit, "Unable to initalize unregistered plugin %s", dlt_name); + return TCPEDIT_ERROR; + } + + /* allocate memory for our deocde extra data */ + if (sizeof(linuxsll_extra_t) > 0) + ctx->decoded_extra = safe_malloc(sizeof(linuxsll_extra_t)); + + /* allocate memory for our config data */ + if (sizeof(linuxsll_config_t) > 0) + plugin->config = safe_malloc(sizeof(linuxsll_config_t)); + + config = (linuxsll_config_t *)plugin->config; + + 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_linuxsll_init(), this is just an stub. + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_linuxsll_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; + } + + /* FIXME: make this function do something if necessary */ + if (ctx->decoded_extra != NULL) { + safe_free(ctx->decoded_extra); + ctx->decoded_extra = NULL; + } + + if (plugin->config != NULL) { + safe_free(plugin->config); + plugin->config = NULL; + } + + return TCPEDIT_OK; /* success */ +} + +/* + * This is where you should define all your AutoGen AutoOpts option parsing. + * Any user specified option should have it's bit turned on in the 'provides' + * bit mask. + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_linuxsll_parse_opts(tcpeditdlt_t *ctx) +{ + assert(ctx); + + /* nothing to parse */ + return TCPEDIT_OK; /* success */ +} + +/* + * Function to decode the layer 2 header in the packet. + * You need to fill out: + * - ctx->l2len + * - ctx->srcaddr + * - ctx->dstaddr + * - ctx->proto + * - ctx->decoded_extra + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_linuxsll_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen) +{ + linux_sll_header_t *linux_sll; + assert(ctx); + assert(packet); + assert(pktlen > (int)sizeof(linux_sll_header_t)); + + linux_sll = (linux_sll_header_t *)packet; + ctx->proto = linux_sll->proto; + ctx->l2len = sizeof(linux_sll_header_t); + + + if (ntohs(linux_sll->type) == ARPHRD_ETHER) { /* ethernet */ + memcpy(&(ctx->srcaddr), linux_sll->address, ETHER_ADDR_LEN); + } else { + tcpedit_seterr(ctx->tcpedit, "%s", "DLT_LINUX_SLL pcap's must contain only ethernet packets"); + return TCPEDIT_ERROR; + } + + return TCPEDIT_OK; /* success */ +} + +/* + * Function to encode the layer 2 header back into the packet. + * Returns: total packet len or TCPEDIT_ERROR + */ +int +dlt_linuxsll_encode(tcpeditdlt_t *ctx, u_char *packet, int pktlen, _U_ tcpr_dir_t dir) +{ + assert(ctx); + assert(pktlen > 0); + assert(packet); + + tcpedit_seterr(ctx->tcpedit, "%s", "DLT_LINUX_SLL plugin does not support packet encoding"); + return TCPEDIT_ERROR; +} + +/* + * Function returns the Layer 3 protocol type of the given packet, or TCPEDIT_ERROR on error + */ +int +dlt_linuxsll_proto(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen) +{ + linux_sll_header_t *linux_sll; + assert(ctx); + assert(packet); + assert(pktlen >= (int)sizeof(linux_sll_header_t)); + + linux_sll = (linux_sll_header_t *)packet; + + return linux_sll->proto; +} + +/* + * Function returns a pointer to the layer 3 protocol header or NULL on error + */ +u_char * +dlt_linuxsll_get_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen) +{ + int l2len; + assert(ctx); + assert(packet); + + l2len = dlt_linuxsll_l2len(ctx, packet, pktlen); + + assert(pktlen >= l2len); + + return tcpedit_dlt_l3data_copy(ctx, packet, pktlen, l2len); +} + +/* + * function merges the packet (containing L2 and old L3) with the l3data buffer + * containing the new l3 data. Note, if L2 % 4 == 0, then they're pointing to the + * same buffer, otherwise there was a memcpy involved on strictly aligned architectures + * like SPARC + */ +u_char * +dlt_linuxsll_merge_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen, u_char *l3data) +{ + int l2len; + assert(ctx); + assert(packet); + assert(l3data); + + l2len = dlt_linuxsll_l2len(ctx, packet, pktlen); + + assert(pktlen >= l2len); + + return tcpedit_dlt_l3data_merge(ctx, packet, pktlen, l3data, l2len); +} + +/* + * return the length of the L2 header of the current packet + */ +int +dlt_linuxsll_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen) +{ + assert(ctx); + assert(packet); + assert(pktlen); + + return sizeof(linux_sll_header_t); +} + +/* + * return a static pointer to the source/destination MAC address + * return NULL on error/address doesn't exist + */ +u_char * +dlt_linuxsll_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen) +{ + assert(ctx); + assert(packet); + assert(pktlen); + + /* FIXME: return a ptr to the source or dest mac address. */ + switch(mac) { + case SRC_MAC: + memcpy(ctx->srcmac, &packet[6], 8); /* linuxssl defines the src mac field to be 8 bytes, not 6 */ + return(ctx->srcmac); + break; + + case DST_MAC: + return(NULL); + break; + + default: + errx(-1, "Invalid tcpeditdlt_mac_type_t: %d", mac); + } + return(NULL); +} + +tcpeditdlt_l2addr_type_t +dlt_linuxsll_l2addr_type(void) +{ + /* we only support ethernet packets */ + return ETHERNET; +} + diff --git a/src/tcpedit/plugins/dlt_linuxsll/linuxsll.h b/src/tcpedit/plugins/dlt_linuxsll/linuxsll.h new file mode 100644 index 0000000..aedcf3a --- /dev/null +++ b/src/tcpedit/plugins/dlt_linuxsll/linuxsll.h @@ -0,0 +1,90 @@ +/* $Id: linuxsll.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#include "dlt_plugins-int.h" + +#ifndef _DLT_linuxsll_H_ +#define _DLT_linuxsll_H_ + +int dlt_linuxsll_register(tcpeditdlt_t *ctx); +int dlt_linuxsll_init(tcpeditdlt_t *ctx); +int dlt_linuxsll_cleanup(tcpeditdlt_t *ctx); +int dlt_linuxsll_parse_opts(tcpeditdlt_t *ctx); +int dlt_linuxsll_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); +int dlt_linuxsll_encode(tcpeditdlt_t *ctx, u_char *packet, int pktlen, tcpr_dir_t dir); +int dlt_linuxsll_proto(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); +u_char *dlt_linuxsll_get_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen); +u_char *dlt_linuxsll_merge_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen, u_char *l3data); +tcpeditdlt_l2addr_type_t dlt_linuxsll_l2addr_type(void); +int dlt_linuxsll_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); +u_char *dlt_linuxsll_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen); + +/* + * structure to hold any data parsed from the packet by the decoder. + * Example: Ethernet VLAN tag info + */ +struct linuxsll_extra_s { + int dummy; +}; +typedef struct linuxsll_extra_s linuxsll_extra_t; + + +/* + * FIXME: structure to hold any data in the tcpeditdlt_plugin_t->config + * Things like: + * - Parsed user options + * - State between packets + * - Note, you should only use this for the encoder function, decoder functions should place + * "extra" data parsed from the packet in the tcpeditdlt_t->decoded_extra buffer since that + * is available to any encoder plugin. + */ +struct linuxsll_config_s { + /* dummy entry for SunPro compiler which doesn't like empty structs */ + int dummy; +}; +typedef struct linuxsll_config_s linuxsll_config_t; + +struct linux_sll_header_s { + u_int16_t source; /* values 0-4 determine where the packet came and where it's going */ + u_int16_t type; /* linux ARPHRD_* values for link-layer device type. See: + * http://www.gelato.unsw.edu.au/lxr/source/include/linux/if_arp.h + */ +#define ARPHRD_ETHER 1 /* ethernet */ + u_int16_t length; /* source address length */ + u_char address[8]; /* first 8 bytes of source address (may be truncated) */ + u_int16_t proto; /* Ethernet protocol type */ +}; +typedef struct linux_sll_header_s linux_sll_header_t; + +#endif + diff --git a/src/tcpedit/plugins/dlt_linuxsll/linuxsll_opts.def b/src/tcpedit/plugins/dlt_linuxsll/linuxsll_opts.def new file mode 100644 index 0000000..7e5e32f --- /dev/null +++ b/src/tcpedit/plugins/dlt_linuxsll/linuxsll_opts.def @@ -0,0 +1 @@ +/* no options for DLT_LINUX_SLL */ \ No newline at end of file diff --git a/src/tcpedit/plugins/dlt_loop/Makefile.am b/src/tcpedit/plugins/dlt_loop/Makefile.am new file mode 100644 index 0000000..d13ff50 --- /dev/null +++ b/src/tcpedit/plugins/dlt_loop/Makefile.am @@ -0,0 +1,25 @@ +# $Id: Makefile.am 1830 2007-04-21 07:33:54Z aturner $ +# START OF: dlt_loop +# Note, if you add any files to your plugin, you will need to edit dlt_/Makefile.am +# add your .c files to libtcpedit_a_SOURCES +# add your .h files to noinst_HEADERS +# add any other files (like documentation, notes, etc) to EXTRA_DIST +# add your dependancy information (see comment below) + +libtcpedit_a_SOURCES += $(srcdir)/plugins/dlt_loop/loop.c + +noinst_HEADERS += $(srcdir)/plugins/dlt_loop/loop.h + +EXTRA_DIST += $(srcdir)/plugins/dlt_loop/loop_opts.def + +# dependancies for your plugin source code. Edit as necessary +$(srcdir)/plugins/dlt_loop/loop.c: $(srcdir)/tcpedit_stub.h $(srcdir)/plugins/dlt_utils.h \ + $(srcdir)/plugins/dlt_loop/loop.h $(srcdir)/plugins/dlt_plugins.h $(srcdir)/plugins/dlt_plugins-int.h + +# You probably don't want to touch anything below this line until the end of the plugin + +DLT_STUB_DEPS += $(srcdir)/plugins/dlt_loop/loop_opts.def + +MOSTLYCLEANFILES += $(srcdir)/plugins/dlt_loop/*~ + +# END OF: dlt_loop diff --git a/src/tcpedit/plugins/dlt_loop/Makefile.in b/src/tcpedit/plugins/dlt_loop/Makefile.in new file mode 100644 index 0000000..e69de29 diff --git a/src/tcpedit/plugins/dlt_loop/loop.c b/src/tcpedit/plugins/dlt_loop/loop.c new file mode 100644 index 0000000..7d68d91 --- /dev/null +++ b/src/tcpedit/plugins/dlt_loop/loop.c @@ -0,0 +1,135 @@ +/* $Id: loop.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + +#include "dlt_plugins-int.h" +#include "dlt_utils.h" +#include "loop.h" +#include "../dlt_null/null.h" +#include "tcpedit.h" +#include "common.h" +#include "tcpr.h" + +/* + * Basically, DLT_LOOP and DLT_NULL are the same thing except that the PF_ value + * in the header is always network byte order in DLT_LOOP and host byte order + * in DLT_NULL. So since DLT_NULL has to handle both big & little endian values + * we just send all DLT_LOOP processing over there + */ + +static char dlt_name[] = "loop"; +static char _U_ dlt_prefix[] = "loop"; +static u_int16_t dlt_value = DLT_LOOP; + +/* + * Function to register ourselves. This function is always called, regardless + * of what DLT types are being used, so it shouldn't be allocating extra buffers + * or anything like that (use the dlt_loop_init() function below for that). + * Tasks: + * - Create a new plugin struct + * - Fill out the provides/requires bit masks. Note: Only specify which fields are + * actually in the header. + * - Add the plugin to the context's plugin chain + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_loop_register(tcpeditdlt_t *ctx) +{ + tcpeditdlt_plugin_t *plugin; + assert(ctx); + + /* create a new plugin structure */ + plugin = tcpedit_dlt_newplugin(); + + /* set what we provide & require */ + plugin->provides += PLUGIN_MASK_PROTO; + plugin->requires += 0; + + /* what is our DLT value? */ + plugin->dlt = dlt_value; + + /* set the prefix name of our plugin. This is also used as the prefix for our options */ + plugin->name = safe_strdup(dlt_prefix); + + /* 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_parse_opts = dlt_null_parse_opts; + plugin->plugin_decode = dlt_null_decode; + plugin->plugin_encode = dlt_null_encode; + plugin->plugin_proto = dlt_null_proto; + plugin->plugin_l2addr_type = dlt_null_l2addr_type; + plugin->plugin_l2len = dlt_null_l2len; + plugin->plugin_get_layer3 = dlt_null_get_layer3; + plugin->plugin_merge_layer3 = dlt_null_merge_layer3; + plugin->plugin_get_mac = dlt_null_get_mac; + + /* add it to the available plugin list */ + return tcpedit_dlt_addplugin(ctx, plugin); +} + +/* + * Initializer function. This function is called only once, if and only if + * this plugin will be utilized. Remember, if you need to keep track of any state, + * store it in your plugin->config, not a global! + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_loop_init(tcpeditdlt_t *ctx) +{ + tcpeditdlt_plugin_t *plugin; + null_config_t *config; + assert(ctx); + + if ((plugin = tcpedit_dlt_getplugin(ctx, dlt_value)) == NULL) { + tcpedit_seterr(ctx->tcpedit, "Unable to initalize unregistered plugin %s", dlt_name); + return TCPEDIT_ERROR; + } + + /* allocate memory for our deocde extra data */ + if (sizeof(null_extra_t) > 0) + ctx->decoded_extra = safe_malloc(sizeof(null_extra_t)); + + /* allocate memory for our config data */ + if (sizeof(null_config_t) > 0) + plugin->config = safe_malloc(sizeof(null_config_t)); + + config = (null_config_t *)plugin->config; + + + return TCPEDIT_OK; /* success */ +} + + +/* that's all folks! */ diff --git a/src/tcpedit/plugins/dlt_loop/loop.h b/src/tcpedit/plugins/dlt_loop/loop.h new file mode 100644 index 0000000..64fc467 --- /dev/null +++ b/src/tcpedit/plugins/dlt_loop/loop.h @@ -0,0 +1,45 @@ +/* $Id: loop.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#include "dlt_plugins-int.h" + +#ifndef _DLT_loop_H_ +#define _DLT_loop_H_ + +int dlt_loop_register(tcpeditdlt_t *ctx); +int dlt_loop_init(tcpeditdlt_t *ctx); + +/* empty because we use DLT_NULL */ + +#endif + diff --git a/src/tcpedit/plugins/dlt_loop/loop_opts.def b/src/tcpedit/plugins/dlt_loop/loop_opts.def new file mode 100644 index 0000000..2b79413 --- /dev/null +++ b/src/tcpedit/plugins/dlt_loop/loop_opts.def @@ -0,0 +1 @@ +/* Add the flag definitions for your plugin here */ diff --git a/src/tcpedit/plugins/dlt_null/Makefile.am b/src/tcpedit/plugins/dlt_null/Makefile.am new file mode 100644 index 0000000..b75f287 --- /dev/null +++ b/src/tcpedit/plugins/dlt_null/Makefile.am @@ -0,0 +1,25 @@ +# $Id: Makefile.am 1830 2007-04-21 07:33:54Z aturner $ +# START OF: dlt_null +# Note, if you add any files to your plugin, you will need to edit dlt_/Makefile.am +# add your .c files to libtcpedit_a_SOURCES +# add your .h files to noinst_HEADERS +# add any other files (like documentation, notes, etc) to EXTRA_DIST +# add your dependancy information (see comment below) + +libtcpedit_a_SOURCES += $(srcdir)/plugins/dlt_null/null.c + +noinst_HEADERS += $(srcdir)/plugins/dlt_null/null.h + +EXTRA_DIST += $(srcdir)/plugins/dlt_null/null_opts.def + +# dependancies for your plugin source code. Edit as necessary +$(srcdir)/plugins/dlt_null/null.c: $(srcdir)/tcpedit_stub.h $(srcdir)/plugins/dlt_utils.h \ + $(srcdir)/plugins/dlt_null/null.h $(srcdir)/plugins/dlt_plugins.h $(srcdir)/plugins/dlt_plugins-int.h + +# You probably don't want to touch anything below this line until the end of the plugin + +DLT_STUB_DEPS += $(srcdir)/plugins/dlt_null/null_opts.def + +MOSTLYCLEANFILES += $(srcdir)/plugins/dlt_null/*~ + +# END OF: dlt_null diff --git a/src/tcpedit/plugins/dlt_null/Makefile.in b/src/tcpedit/plugins/dlt_null/Makefile.in new file mode 100644 index 0000000..e69de29 diff --git a/src/tcpedit/plugins/dlt_null/null.c b/src/tcpedit/plugins/dlt_null/null.c new file mode 100644 index 0000000..2f5e7c9 --- /dev/null +++ b/src/tcpedit/plugins/dlt_null/null.c @@ -0,0 +1,331 @@ +/* $Id: null.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + +#include "dlt_plugins-int.h" +#include "dlt_utils.h" +#include "null.h" +#include "tcpedit.h" +#include "common.h" +#include "tcpr.h" + +#include // PF_* values + +static char dlt_name[] = "null"; +static char _U_ dlt_prefix[] = "null"; +static u_int16_t dlt_value = DLT_NULL; + +/* + * From the libpcap man page: + * DLT_NULL aka BSD loopback encapsulation; the link layer header is a 4-byte + * field, in host byte order, containing a PF_ value from + * socket.h for the network-layer protocol of the packet. + * + * Note that ``host byte order'' is the byte order of the + * machine on which the packets are captured, and the PF_ values + * are for the OS of the machine on which the packets are captured; + * if a live capture is being done, ``host byte order'' + * is the byte order of the machine capturing the packets, and + * the PF_ values are those of the OS of the machine capturing + * the packets, but if a ``savefile'' is being read, the byte + * order and PF_ values are not necessarily those of the machine + * reading the capture file. + */ + +/* + * Function to register ourselves. This function is always called, regardless + * of what DLT types are being used, so it shouldn't be allocating extra buffers + * or anything like that (use the dlt_null_init() function below for that). + * Tasks: + * - Create a new plugin struct + * - Fill out the provides/requires bit masks. Note: Only specify which fields are + * actually in the header. + * - Add the plugin to the context's plugin chain + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_null_register(tcpeditdlt_t *ctx) +{ + tcpeditdlt_plugin_t *plugin; + assert(ctx); + + /* create a new plugin structure */ + plugin = tcpedit_dlt_newplugin(); + + /* set what we provide & require */ + plugin->provides += PLUGIN_MASK_PROTO; + plugin->requires += 0; + + /* what is our DLT value? */ + plugin->dlt = dlt_value; + + /* set the prefix name of our plugin. This is also used as the prefix for our options */ + plugin->name = safe_strdup(dlt_prefix); + + /* + * Point to our functions, note, you need a function for EVERY method. + * Even if it is only an empty stub returning success. + */ + plugin->plugin_init = dlt_null_init; + plugin->plugin_cleanup = dlt_null_cleanup; + plugin->plugin_parse_opts = dlt_null_parse_opts; + plugin->plugin_decode = dlt_null_decode; + plugin->plugin_encode = dlt_null_encode; + plugin->plugin_proto = dlt_null_proto; + plugin->plugin_l2addr_type = dlt_null_l2addr_type; + plugin->plugin_l2len = dlt_null_l2len; + plugin->plugin_get_layer3 = dlt_null_get_layer3; + plugin->plugin_merge_layer3 = dlt_null_merge_layer3; + + /* add it to the available plugin list */ + return tcpedit_dlt_addplugin(ctx, plugin); +} + + +/* + * Initializer function. This function is called only once, if and only if + * this plugin will be utilized. Remember, if you need to keep track of any state, + * store it in your plugin->config, not a global! + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_null_init(tcpeditdlt_t *ctx) +{ + tcpeditdlt_plugin_t *plugin; + null_config_t *config; + assert(ctx); + + if ((plugin = tcpedit_dlt_getplugin(ctx, dlt_value)) == NULL) { + tcpedit_seterr(ctx->tcpedit, "Unable to initalize unregistered plugin %s", dlt_name); + return TCPEDIT_ERROR; + } + + /* allocate memory for our deocde extra data */ + if (sizeof(null_extra_t) > 0) + ctx->decoded_extra = safe_malloc(sizeof(null_extra_t)); + + /* allocate memory for our config data */ + if (sizeof(null_config_t) > 0) + plugin->config = safe_malloc(sizeof(null_config_t)); + + config = (null_config_t *)plugin->config; + + + 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_null_init(), this is just an stub. + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_null_cleanup(tcpeditdlt_t *ctx) +{ + tcpeditdlt_plugin_t *plugin; + assert(ctx); + + if ((plugin = tcpedit_dlt_getplugin(ctx, dlt_value)) == NULL) { + tcpedit_seterr(ctx->tcpedit, "Unable to cleanup unregistered plugin %s", dlt_name); + return TCPEDIT_ERROR; + } + + if (ctx->decoded_extra != NULL) { + safe_free(ctx->decoded_extra); + ctx->decoded_extra = NULL; + } + + if (plugin->config != NULL) { + safe_free(plugin->config); + plugin->config = NULL; + } + + return TCPEDIT_OK; /* success */ +} + +/* + * This is where you should define all your AutoGen AutoOpts option parsing. + * Any user specified option should have it's bit turned on in the 'provides' + * bit mask. + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_null_parse_opts(tcpeditdlt_t *ctx) +{ + assert(ctx); + + /* nothing to parse here, move along */ + return TCPEDIT_OK; /* success */ +} + +/* + * Function to decode the layer 2 header in the packet. + * You need to fill out: + * - ctx->l2len + * - ctx->srcaddr + * - ctx->dstaddr + * - ctx->proto + * - ctx->decoded_extra + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_null_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen) +{ + int proto; + assert(ctx); + assert(packet); + assert(pktlen > 0); + + if ((proto = dlt_null_proto(ctx, packet, pktlen)) == TCPEDIT_ERROR) + return TCPEDIT_ERROR; + + ctx->proto = (u_int16_t)proto; + ctx->l2len = 4; + + return TCPEDIT_OK; /* success */ +} + +/* + * Function to encode the layer 2 header back into the packet. + * Returns: total packet len or TCPEDIT_ERROR + */ +int +dlt_null_encode(tcpeditdlt_t *ctx, u_char *packet, int pktlen, _U_ tcpr_dir_t dir) +{ + assert(ctx); + assert(pktlen > 0); + assert(packet); + + tcpedit_seterr(ctx->tcpedit, "%s", "DLT_NULL and DLT_LOOP plugins do not support packet encoding"); + return TCPEDIT_ERROR; +} + +/* + * Function returns the Layer 3 protocol type of the given packet, or TCPEDIT_ERROR on error + */ +int +dlt_null_proto(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen) +{ + assert(ctx); + assert(packet); + assert(pktlen > 0); + u_int32_t *af_type; + int protocol = 0; + + af_type = (u_int32_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) { + protocol = ETHERTYPE_IP6; + } else { + tcpedit_seterr(ctx->tcpedit, "Unsupported DLT_NULL/DLT_LOOP PF_ type: 0x%04x", *af_type); + return TCPEDIT_ERROR; + } + + return htons(protocol); +} + +/* + * Function returns a pointer to the layer 3 protocol header or NULL on error + */ +u_char * +dlt_null_get_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen) +{ + int l2len; + assert(ctx); + assert(packet); + + l2len = dlt_null_l2len(ctx, packet, pktlen); + + assert(pktlen >= l2len); + + return tcpedit_dlt_l3data_copy(ctx, packet, pktlen, l2len); +} + +/* + * function merges the packet (containing L2 and old L3) with the l3data buffer + * containing the new l3 data. Note, if L2 % 4 == 0, then they're pointing to the + * same buffer, otherwise there was a memcpy involved on strictly aligned architectures + * like SPARC + */ +u_char * +dlt_null_merge_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen, u_char *l3data) +{ + int l2len; + assert(ctx); + assert(packet); + assert(l3data); + + l2len = dlt_null_l2len(ctx, packet, pktlen); + + assert(pktlen >= l2len); + + return tcpedit_dlt_l3data_merge(ctx, packet, pktlen, l3data, l2len); +} + +/* + * return the length of the L2 header of the current packet + */ +int +dlt_null_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen) +{ + assert(ctx); + assert(packet); + assert(pktlen); + + /* always is 4 */ + return 4; +} + +/* + * return a static pointer to the source/destination MAC address + * return NULL on error/address doesn't exist + */ +u_char * +dlt_null_get_mac(tcpeditdlt_t *ctx, _U_ tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen) +{ + assert(ctx); + assert(packet); + assert(pktlen); + + return(NULL); + +} + +tcpeditdlt_l2addr_type_t +dlt_null_l2addr_type(void) +{ + return NONE; +} + diff --git a/src/tcpedit/plugins/dlt_null/null.h b/src/tcpedit/plugins/dlt_null/null.h new file mode 100644 index 0000000..72e0e40 --- /dev/null +++ b/src/tcpedit/plugins/dlt_null/null.h @@ -0,0 +1,79 @@ +/* $Id: null.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#include "dlt_plugins-int.h" + +#ifndef _DLT_null_H_ +#define _DLT_null_H_ + +int dlt_null_register(tcpeditdlt_t *ctx); +int dlt_null_init(tcpeditdlt_t *ctx); +int dlt_null_cleanup(tcpeditdlt_t *ctx); +int dlt_null_parse_opts(tcpeditdlt_t *ctx); +int dlt_null_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); +int dlt_null_encode(tcpeditdlt_t *ctx, u_char *packet, int pktlen, tcpr_dir_t dir); +int dlt_null_proto(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); +u_char *dlt_null_get_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen); +u_char *dlt_null_merge_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen, u_char *l3data); +tcpeditdlt_l2addr_type_t dlt_null_l2addr_type(void); +int dlt_null_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); +u_char *dlt_null_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen); + +/* + * structure to hold any data parsed from the packet by the decoder. + * Example: Ethernet VLAN tag info + */ +struct null_extra_s { + /* dummy entry for SunPro compiler which doesn't like empty structs */ + int dummy; +}; +typedef struct null_extra_s null_extra_t; + + +/* + * FIXME: structure to hold any data in the tcpeditdlt_plugin_t->config + * Things like: + * - Parsed user options + * - State between packets + * - Note, you should only use this for the encoder function, decoder functions should place + * "extra" data parsed from the packet in the tcpeditdlt_t->decoded_extra buffer since that + * is available to any encoder plugin. + */ +struct null_config_s { + /* dummy entry for SunPro compiler which doesn't like empty structs */ + int dummy; +}; +typedef struct null_config_s null_config_t; + +#endif + diff --git a/src/tcpedit/plugins/dlt_null/null_opts.def b/src/tcpedit/plugins/dlt_null/null_opts.def new file mode 100644 index 0000000..ff16ad6 --- /dev/null +++ b/src/tcpedit/plugins/dlt_null/null_opts.def @@ -0,0 +1 @@ +/* No options for DLT_NULL as this is a decoder only plugin */ diff --git a/src/tcpedit/plugins/dlt_opts.def b/src/tcpedit/plugins/dlt_opts.def new file mode 100644 index 0000000..74fa757 --- /dev/null +++ b/src/tcpedit/plugins/dlt_opts.def @@ -0,0 +1,42 @@ + +flag = { + name = skipl2broadcast; + descrip = "Skip rewriting broadcast/multicast Layer 2 addresses"; + doc = <<- EOText +By default, editing Layer 2 addresses will rewrite +broadcast and multicast MAC addresses. Setting this flag +will keep broadcast/multicast MAC addresses from being rewritten. +EOText; +}; + +/* + * Allow user to specify output DLT. The values for this should + * match the argument name prefix of your plugin. For example: + * DLT_EN10MB is ethernet, so I called the prefix "enet": + * (--enet-src, --enet-dst, --enet-proto) + * so the string I should look for here is "enet" too. It's important + * that the prefix you use here is also used as the "name" in the + * tcpeditdlt_plugin_t structure. + */ + +flag = { + name = dlt; + descrip = "Override output DLT encapsulation"; + arg-type = string; + max = 1; + doc = <<- EO_DLT_DOC +By default, no DLT (data link type) conversion will be made. +To change the DLT type of the output pcap, select one of the following values: +@table @bullet +@item +@var{enet} +Ethernet aka DLT_EN10MB +@item +@var{hdlc} +Cisco HDLC aka DLT_C_HDLC +@item +@var{user} +User specified Layer 2 header and DLT type +@end table +EO_DLT_DOC; +}; diff --git a/src/tcpedit/plugins/dlt_plugins-int.h b/src/tcpedit/plugins/dlt_plugins-int.h new file mode 100644 index 0000000..73caaea --- /dev/null +++ b/src/tcpedit/plugins/dlt_plugins-int.h @@ -0,0 +1,149 @@ +/* $Id: dlt_plugins-int.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + /* + * Internal data structures and helper functions for DLT plugins + * Should not be available outside of the plugin framework + */ + + +#ifndef _DLT_PLUGINS_INT_H_ +#define _DLT_PLUGINS_INT_H_ + +#include "tcpedit-int.h" +#include "tcpr.h" +#include "dlt_plugins.h" +#include "tcpedit_stub.h" + + +/* + * Plugin Requires/Provides Bit Masks + * If you add any fields to the provides/requires bitmask, + * then you also must add appropriate records for + * tcpeditdlt_bit_map[] and tcpeditdlt_bit_info[] + * in dlt_plugins.c + */ +enum tcpeditdlt_bit_mask_e { + PLUGIN_MASK_PROTO = 0x01, + PLUGIN_MASK_SRCADDR = 0x02, + PLUGIN_MASK_DSTADDR = 0x04 +}; +typedef enum tcpeditdlt_bit_mask_e tcpeditdlt_bit_mask_t; + +/* Union of all possible L2 address types */ +union tcpeditdlt_l2address_u { + u_char ethernet[ETHER_ADDR_LEN]; /* ethernet is 6 bytes long */ + u_int8_t c_hdlc; /* Cisco HDLC is a single byte */ +}; +typedef union tcpeditdlt_l2address_u tcpeditdlt_l2address_t; + +/* What kind of address is the union? */ +enum tcpeditdlt_l2addr_type_e { + NONE, /* DLT has no L2 address */ + ETHERNET, /* support ethernet */ + C_HDLC, /* Cisco HDLC uses a 1 byte addr which has only two values 0x0F & 0xBF */ +}; +typedef enum tcpeditdlt_l2addr_type_e tcpeditdlt_l2addr_type_t; + +/* src or dst mac */ +enum tcpeditdlt_mac_type_e { + SRC_MAC, + DST_MAC +}; +typedef enum tcpeditdlt_mac_type_e tcpeditdlt_mac_type_t; + +/* MAC address buffer length */ +#define MAX_MAC_LEN 10 + +/* + * Each plugin must fill this out so that we know what function + * to call from the external API + */ +struct tcpeditdlt_plugin_s { + u_int16_t dlt; /* dlt to register for */ + char *name; /* plugin prefix name */ + struct tcpeditdlt_plugin_s *next; /* next in linked list */ + int requires; /* bit mask for which fields this plugin encoder requires */ + int provides; /* bit mask for which fields this plugin decoder provides */ + int (*plugin_init)(tcpeditdlt_t *); + int (*plugin_cleanup)(tcpeditdlt_t *); + int (*plugin_parse_opts)(tcpeditdlt_t *); + int (*plugin_decode)(tcpeditdlt_t *, const u_char *, const int); + int (*plugin_encode)(tcpeditdlt_t *, u_char *, int, tcpr_dir_t); + int (*plugin_proto)(tcpeditdlt_t *, const u_char *, const int); + int (*plugin_l2len)(tcpeditdlt_t *, const u_char *, const int); + u_char *(*plugin_get_layer3)(tcpeditdlt_t *, u_char *, const int); + u_char *(*plugin_merge_layer3)(tcpeditdlt_t *, u_char *, const int, u_char *); + tcpeditdlt_l2addr_type_t (*plugin_l2addr_type)(void); + u_char *(*plugin_get_mac)(tcpeditdlt_t *, tcpeditdlt_mac_type_t, const u_char *, const int); + void *config; /* user configuration data for the encoder */ + +}; +typedef struct tcpeditdlt_plugin_s tcpeditdlt_plugin_t; + +#define L2EXTRA_LEN 255 /* size of buffer to hold any extra L2 data parsed from the decoder */ + +/* + * internal DLT plugin context + */ +struct tcpeditdlt_s { + tcpedit_t *tcpedit; /* pointer to our tcpedit context */ +#ifdef FORCE_ALIGN + u_char *l3buff; /* pointer for L3 buffer on strictly aligned systems */ +#endif + tcpeditdlt_plugin_t *plugins; /* registered plugins */ + tcpeditdlt_plugin_t *decoder; /* Encoder plugin */ + tcpeditdlt_plugin_t *encoder; /* Decoder plugin */ + /* decoder validator tells us which kind of address we're processing */ + tcpeditdlt_l2addr_type_t addr_type; + + /* skip rewriting IP/MAC's which are broadcast or multicast? */ + int skip_broadcast; + + /* original DLT */ + u_int16_t dlt; + + /* + * These variables are filled out for each packet by the decoder + */ + + /* The following fields are updated on a per-packet basis by the decoder */ + tcpeditdlt_l2address_t srcaddr; /* filled out source address */ + tcpeditdlt_l2address_t dstaddr; /* filled out dst address */ + int l2len; /* set by decoder and updated by encoder */ + u_int16_t proto; /* layer 3 proto type?? */ + void *decoded_extra; /* any extra L2 data from decoder like VLAN tags */ + u_char srcmac[MAX_MAC_LEN]; /* buffers to store the src & dst MAC */ + u_char dstmac[MAX_MAC_LEN]; +}; + +#endif diff --git a/src/tcpedit/plugins/dlt_plugins.c b/src/tcpedit/plugins/dlt_plugins.c new file mode 100644 index 0000000..7aaad34 --- /dev/null +++ b/src/tcpedit/plugins/dlt_plugins.c @@ -0,0 +1,425 @@ +/* $Id: dlt_plugins.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include + +#include "dlt_plugins-int.h" +#include "dlt_utils.h" +#include "common.h" + +/** + * Include plugin header files here... + */ +#include "dlt_en10mb/en10mb.h" +#include "dlt_user/user.h" +#include "dlt_hdlc/hdlc.h" +#include "dlt_raw/raw.h" +#include "dlt_null/null.h" +#include "dlt_loop/loop.h" +#include "dlt_linuxsll/linuxsll.h" +#include "dlt_ieee80211/ieee80211.h" +#include "dlt_radiotap/radiotap.h" + + +/** + * Everyone writing a DLT plugin, must add their registration function + * here. + */ +int +tcpedit_dlt_register(tcpeditdlt_t *ctx) +{ + int retcode = 0; + assert(ctx); + + retcode += dlt_en10mb_register(ctx); + retcode += dlt_hdlc_register(ctx); + retcode += dlt_user_register(ctx); + retcode += dlt_raw_register(ctx); + retcode += dlt_null_register(ctx); + retcode += dlt_loop_register(ctx); + retcode += dlt_linuxsll_register(ctx); + retcode += dlt_ieee80211_register(ctx); + retcode += dlt_radiotap_register(ctx); + + if (retcode < 0) + return TCPEDIT_ERROR; + + return TCPEDIT_OK; +} + + + +/******************************************************************** + * People writing DLT plugins should stop editing here! + * + * Well actually, that's true most of the time, but feel free to take + * a look! + ********************************************************************/ + +/* + * mapping for bit_mask to bit_info. If you're making changes here + * then you almost certainly need to modify tcpeditdlt_t in dlt_plugins-int.h + */ +const u_int32_t tcpeditdlt_bit_map[] = { + PLUGIN_MASK_PROTO, + PLUGIN_MASK_SRCADDR, + PLUGIN_MASK_DSTADDR +}; + +/* Meanings of the above map */ +const char *tcpeditdlt_bit_info[] = { + "Missing required Layer 3 protocol.", + "Missing required Layer 2 source address.", + "Missing required Layer 2 destination address." +}; + +/********************************************************************* + * Internal functions + ********************************************************************/ + +/********************************************************************* + * Public functions + ********************************************************************/ + +/** + * initialize our plugin library. Pass the DLT of the source pcap handle. + * Actions: + * - Create new tcpeditdlt_t context + * - Link tcpedit to new context + * - Register plugins + * - Select decoder plugin using srcdlt + * - Select encoder plugin using destination name + * - Initialize decoder/encoder plugins + * - Parse options for encoder plugin + * - Validate provides/reqiures + user options + */ +tcpeditdlt_t * +tcpedit_dlt_init(tcpedit_t *tcpedit, const int srcdlt) +{ + tcpeditdlt_t *ctx; + int rcode; + const char *dst_dlt_name = NULL; + + assert(tcpedit); + assert(srcdlt >= 0); + + ctx = (tcpeditdlt_t *)safe_malloc(sizeof(tcpeditdlt_t)); + + /* do we need a side buffer for L3 data? */ +#ifdef FORCE_ALIGN + ctx->l3buff = (u_char *)safe_malloc(MAXPACKET); +#endif + + /* copy our tcpedit context */ + ctx->tcpedit = tcpedit; + + /* register all our plugins */ + if (tcpedit_dlt_register(ctx) != TCPEDIT_OK) { + goto INIT_ERROR; + } + + /* Choose decode plugin */ + if ((ctx->decoder = tcpedit_dlt_getplugin(ctx, srcdlt)) == NULL) { + tcpedit_seterr(tcpedit, "No DLT plugin available for source DLT: 0x%x", srcdlt); + goto INIT_ERROR; + } + + /* set our dlt type */ + ctx->dlt = srcdlt; + + /* set our address type */ + ctx->addr_type = ctx->decoder->plugin_l2addr_type(); + + /* initalize decoder plugin */ + rcode = ctx->decoder->plugin_init(ctx); + if (tcpedit_checkerror(ctx->tcpedit, rcode, NULL) != TCPEDIT_OK) { + goto INIT_ERROR; + } + + /* Select the encoder plugin */ + dst_dlt_name = OPT_ARG(DLT) ? OPT_ARG(DLT) : ctx->decoder->name; + if ((ctx->encoder = tcpedit_dlt_getplugin_byname(ctx, dst_dlt_name)) == NULL) { + tcpedit_seterr(tcpedit, "No output DLT plugin available for: %s", dst_dlt_name); + goto INIT_ERROR; + } + + /* Figure out if we're skipping braodcast & multicast */ + if (HAVE_OPT(SKIPL2BROADCAST)) + ctx->skip_broadcast = 1; + + /* init encoder plugin if it's not the decoder plugin */ + if (ctx->encoder->dlt != ctx->decoder->dlt) { + rcode = ctx->encoder->plugin_init(ctx); + if (tcpedit_checkerror(ctx->tcpedit, rcode, NULL) != TCPEDIT_OK) { + goto INIT_ERROR; + } + } + + /* parse the DLT specific options */ + rcode = tcpedit_dlt_parse_opts(ctx); + if (tcpedit_checkerror(ctx->tcpedit, rcode, "parsing options") != TCPEDIT_OK) { + goto INIT_ERROR; + } + + + /* validate that the SRC/DST DLT + options give us enough info */ + rcode = tcpedit_dlt_validate(ctx); + if (tcpedit_checkerror(ctx->tcpedit, rcode, "validating options") != TCPEDIT_OK) { + goto INIT_ERROR; + } + + /* we're OK */ + return ctx; + +INIT_ERROR: + tcpedit_dlt_cleanup(ctx); + return NULL; +} + + +/** + * This is the recommended method to edit a packet. Returns (new) total packet length + * FIXME: This is *broken*. taking packet as a u_char*, but using it as a u_char **! + */ +int +tcpedit_dlt_process(tcpeditdlt_t *ctx, u_char **packet, int pktlen, tcpr_dir_t direction) +{ + int rcode; + + assert(ctx); + assert(packet); + assert(pktlen); + assert(direction == TCPR_DIR_C2S || direction == TCPR_DIR_S2C || direction == TCPR_DIR_NOSEND); + + /* nothing to do here */ + if (direction == TCPR_DIR_NOSEND) + return pktlen; + + /* decode packet */ + if ((rcode = tcpedit_dlt_decode(ctx, *packet, pktlen)) == TCPEDIT_ERROR) { + return TCPEDIT_ERROR; + } else if (rcode == TCPEDIT_WARN) { + warnx("Warning decoding packet: %s", tcpedit_getwarn(ctx->tcpedit)); + } else if (rcode == TCPEDIT_SOFT_ERROR) { + return rcode; /* can't edit the packet */ + } + + /* encode packet */ + if ((rcode = tcpedit_dlt_encode(ctx, *packet, pktlen, direction)) == TCPEDIT_ERROR) { + return TCPEDIT_ERROR; + } else if (rcode == TCPEDIT_WARN) { + warnx("Warning encoding packet: %s", tcpedit_getwarn(ctx->tcpedit)); + } + + return rcode; +} + + +/** + * What is the output DLT type??? + */ +int +tcpedit_dlt_output_dlt(tcpeditdlt_t *ctx) +{ + u_int16_t dlt; + assert(ctx); + + /* + * usually we just return the DLT value of the decoder, but for DLT_USER0 + * we return a user-specified value via --user-dlt + */ + if (ctx->encoder->dlt == DLT_USER0) { + dlt = dlt_user_get_output_dlt(ctx); + } else { + dlt = ctx->encoder->dlt; + } + return dlt; +} + +/** + * Get the layer 2 length of the packet using the DLT plugin currently in + * place + */ +int +tcpedit_dlt_l2len(tcpeditdlt_t *ctx, int dlt, const u_char *packet, const int pktlen) +{ + tcpeditdlt_plugin_t *plugin; + assert(ctx); + assert(dlt >= 0); + assert(packet); + assert(pktlen); + + if ((plugin = tcpedit_dlt_getplugin(ctx, dlt)) == NULL) { + tcpedit_seterr(ctx->tcpedit, "Unable to find plugin for DLT 0x%04x", dlt); + return -1; + } + return plugin->plugin_l2len(ctx, packet, pktlen); +} + +/** + * Get the L3 type. Returns -1 on error. Get error via tcpedit->geterr() + */ +int +tcpedit_dlt_proto(tcpeditdlt_t *ctx, int dlt, const u_char *packet, const int pktlen) +{ + tcpeditdlt_plugin_t *plugin; + + assert(ctx); + assert(dlt >= 0); + assert(packet); + assert(pktlen); + + if ((plugin = tcpedit_dlt_getplugin(ctx, dlt)) == NULL) { + tcpedit_seterr(ctx->tcpedit, "Unable to find plugin for DLT 0x%04x", dlt); + return -1; + } + + return plugin->plugin_proto(ctx, packet, pktlen); +} + +/** + * Get the L3 data. Returns NULL on error. Get error via tcpedit->geterr() + */ +u_char * +tcpedit_dlt_l3data(tcpeditdlt_t *ctx, int dlt, u_char *packet, const int pktlen) +{ + tcpeditdlt_plugin_t *plugin; + + assert(ctx); + assert(dlt >= 0); + assert(packet); + assert(pktlen); + + if ((plugin = tcpedit_dlt_getplugin(ctx, dlt)) == NULL) { + tcpedit_seterr(ctx->tcpedit, "Unable to find plugin for DLT 0x%04x", dlt); + return NULL; + } + + return plugin->plugin_get_layer3(ctx, packet, pktlen); +} + +/** + * \brief Merge the Layer 3 data back onto the mainbuffer so it's immediately + * after the layer 2 header + * + * Since some L2 headers aren't strictly aligned, we need to "merge" the packet w/ L2 data + * and the L3 buffer. This is basically a NO-OP for things like vlan tagged ethernet (16 byte) header + * or Cisco HDLC (4 byte header) but is critical for std ethernet (12 byte header) + */ +u_char * +tcpedit_dlt_merge_l3data(tcpeditdlt_t *ctx, int dlt, u_char *packet, const int pktlen, u_char *l3data) +{ + tcpeditdlt_plugin_t *plugin; + assert(ctx); + assert(dlt >= 0); + assert(pktlen >= 0); + assert(packet); + + if (l3data == NULL) + return packet; + + if ((plugin = tcpedit_dlt_getplugin(ctx, dlt)) == NULL) { + tcpedit_seterr(ctx->tcpedit, "Unable to find plugin for DLT 0x%04x", dlt); + return NULL; + } + + return plugin->plugin_merge_layer3(ctx, packet, pktlen, l3data); +} + + + +/** + * Call the specific plugin decode() method + */ +int +tcpedit_dlt_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen) +{ + return ctx->decoder->plugin_decode(ctx, packet, pktlen); +} + +/** + * Call the specific plugin encode() method + */ +int +tcpedit_dlt_encode(tcpeditdlt_t* ctx, u_char *packet, int pktlen, tcpr_dir_t direction) +{ + return ctx->encoder->plugin_encode(ctx, packet, pktlen, direction); +} + +/** + * what is the source (decoder) DLT type? + */ +int +tcpedit_dlt_src(tcpeditdlt_t *ctx) +{ + assert(ctx); + return ctx->decoder->dlt; +} + +/** + * What is the destination (encoder) DLT type + */ +int +tcpedit_dlt_dst(tcpeditdlt_t *ctx) +{ + assert(ctx); + return ctx->encoder->dlt; +} + + +/** + * cleanup after ourselves: destroys our context and all plugin data + */ +void +tcpedit_dlt_cleanup(tcpeditdlt_t *ctx) +{ + assert(ctx); + + if (ctx->encoder != NULL) + ctx->encoder->plugin_cleanup(ctx); + + if (ctx->decoder != NULL) + ctx->decoder->plugin_cleanup(ctx); + +#ifdef FORCE_ALIGN + safe_free(ctx->l3buff); +#endif + + if (ctx->decoded_extra != NULL) + safe_free(ctx->decoded_extra); + + safe_free(ctx); +} + + diff --git a/src/tcpedit/plugins/dlt_plugins.h b/src/tcpedit/plugins/dlt_plugins.h new file mode 100644 index 0000000..72464f7 --- /dev/null +++ b/src/tcpedit/plugins/dlt_plugins.h @@ -0,0 +1,83 @@ +/* $Id: dlt_plugins.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Main DLT Plugin Header. You should only include this file outside + * of the plugin API. dlt_plugin-int.h is used internal to the plugin ONLY. + */ + +#include "tcpedit.h" + +#ifndef _DLT_PLUGINS_H_ +#define _DLT_PLUGINS_H_ + +/* forward declare our context, so we can use it in the plugin struct */ +typedef struct tcpeditdlt_s tcpeditdlt_t; + +/* + * initialize the DLT plugin backend, and return a new context var. + * call this once per pcap to be processed + */ +tcpeditdlt_t *tcpedit_dlt_init(tcpedit_t *tcpedit, int srcdlt); + +/* cleans up after ourselves. Called for each initalized plugin */ +void tcpedit_dlt_cleanup(tcpeditdlt_t *ctx); + +/* What is the output DLT type? */ +int tcpedit_dlt_output_dlt(tcpeditdlt_t *ctx); +int tcpedit_dlt_l2len(tcpeditdlt_t *ctx, int dlt, const u_char *packet, const int pktlen); + +/* + * process the given packet, by calling decode & encode + */ +int tcpedit_dlt_process(tcpeditdlt_t *ctx, u_char **packet, int pktlen, tcpr_dir_t direction); + +/* + * or you can call them sperately if you want + */ +int tcpedit_dlt_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); +int tcpedit_dlt_encode(tcpeditdlt_t* ctx, u_char *packet, int pktlen, tcpr_dir_t direction); + +/* + * After processing each packet, you can get info about L2/L3 + */ +int tcpedit_dlt_proto(tcpeditdlt_t *ctx, int dlt, const u_char *packet, const int pktlen); +u_char *tcpedit_dlt_l3data(tcpeditdlt_t *ctx, int dlt, u_char *packet, const int pktlen); + +/* merge the L2 & L3 (possibly changed?) after calling tcpedit_dlt_l3data() */ +u_char *tcpedit_dlt_merge_l3data(tcpeditdlt_t *ctx, int dlt, u_char *packet, const int pktlen, u_char *l3data); + + +int tcpedit_dlt_src(tcpeditdlt_t *ctx); +int tcpedit_dlt_dst(tcpeditdlt_t *ctx); + +#endif diff --git a/src/tcpedit/plugins/dlt_radiotap/Makefile.am b/src/tcpedit/plugins/dlt_radiotap/Makefile.am new file mode 100644 index 0000000..91e424a --- /dev/null +++ b/src/tcpedit/plugins/dlt_radiotap/Makefile.am @@ -0,0 +1,25 @@ +# $Id: Makefile.am 1869 2007-05-12 19:53:15Z aturner $ +# START OF: dlt_radiotap +# Note, if you add any files to your plugin, you will need to edit dlt_radiotap/Makefile.am +# add your .c files to libtcpedit_a_SOURCES +# add your .h files to noinst_HEADERS +# add any other files (like documentation, notes, etc) to EXTRA_DIST +# add your dependancy information (see comment below) + +libtcpedit_a_SOURCES += $(srcdir)/plugins/dlt_radiotap/radiotap.c + +noinst_HEADERS += $(srcdir)/plugins/dlt_radiotap/radiotap.h + +EXTRA_DIST += $(srcdir)/plugins/dlt_radiotap/radiotap_opts.def + +# dependancies for your plugin source code. Edit as necessary +$(srcdir)/plugins/dlt_radiotap/radiotap.c: $(srcdir)/tcpedit_stub.h $(srcdir)/plugins/dlt_utils.h \ + $(srcdir)/plugins/dlt_radiotap/radiotap.h $(srcdir)/plugins/dlt_plugins.h $(srcdir)/plugins/dlt_plugins-int.h + +# You probably don't want to touch anything below this line until the end of the plugin + +DLT_STUB_DEPS += $(srcdir)/plugins/dlt_radiotap/radiotap_opts.def + +MOSTLYCLEANFILES += $(srcdir)/plugins/dlt_radiotap/*~ + +# END OF: dlt_radiotap diff --git a/src/tcpedit/plugins/dlt_radiotap/Makefile.in b/src/tcpedit/plugins/dlt_radiotap/Makefile.in new file mode 100644 index 0000000..e69de29 diff --git a/src/tcpedit/plugins/dlt_radiotap/radiotap.c b/src/tcpedit/plugins/dlt_radiotap/radiotap.c new file mode 100644 index 0000000..39134b3 --- /dev/null +++ b/src/tcpedit/plugins/dlt_radiotap/radiotap.c @@ -0,0 +1,363 @@ +/* $Id: radiotap.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + +#include "dlt_plugins-int.h" +#include "dlt_utils.h" +#include "radiotap.h" +#include "../dlt_ieee80211/ieee80211.h" +#include "tcpedit.h" +#include "common.h" +#include "tcpr.h" + +/* edit these variables to taste */ +static char dlt_name[] = "radiotap"; +_U_ static char dlt_prefix[] = "radiotap"; +static u_int16_t dlt_value = DLT_IEEE802_11_RADIO; + +/* + * The Radiotap header plugin utilizes the 802.11 plugin internally to do all the work + * we just eat the radiotap header itself and pass the resulting buffer to the ieee80211 + * plugin. + */ + +static u_char *dlt_radiotap_get_80211(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen, const int radiolen); + +/* + * Function to register ourselves. This function is always called, regardless + * of what DLT types are being used, so it shouldn't be allocating extra buffers + * or anything like that (use the dlt_radiotap_init() function below for that). + * Tasks: + * - Create a new plugin struct + * - Fill out the provides/requires bit masks. Note: Only specify which fields are + * actually in the header. + * - Add the plugin to the context's plugin chain + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_radiotap_register(tcpeditdlt_t *ctx) +{ + tcpeditdlt_plugin_t *plugin; + assert(ctx); + + /* create a new plugin structure */ + plugin = tcpedit_dlt_newplugin(); + + /* we're a decoder only plugin, copy from ieee802.11 */ + plugin->provides += PLUGIN_MASK_PROTO + PLUGIN_MASK_SRCADDR + PLUGIN_MASK_DSTADDR; + plugin->requires += 0; + + /* what is our DLT value? */ + plugin->dlt = dlt_value; + + /* set the prefix name of our plugin. This is also used as the prefix for our options */ + plugin->name = safe_strdup(dlt_name); + + /* + * Point to our functions, note, you need a function for EVERY method. + * Even if it is only an empty stub returning success. + */ + plugin->plugin_init = dlt_radiotap_init; + plugin->plugin_cleanup = dlt_radiotap_cleanup; + plugin->plugin_parse_opts = dlt_radiotap_parse_opts; + plugin->plugin_decode = dlt_radiotap_decode; + plugin->plugin_encode = dlt_radiotap_encode; + plugin->plugin_proto = dlt_radiotap_proto; + plugin->plugin_l2addr_type = dlt_radiotap_l2addr_type; + plugin->plugin_l2len = dlt_radiotap_80211_l2len; + plugin->plugin_get_layer3 = dlt_radiotap_get_layer3; + plugin->plugin_merge_layer3 = dlt_radiotap_merge_layer3; + plugin->plugin_get_mac = dlt_radiotap_get_mac; + + /* add it to the available plugin list */ + return tcpedit_dlt_addplugin(ctx, plugin); +} + +/* + * Initializer function. This function is called only once, if and only iif + * this plugin will be utilized. Remember, if you need to keep track of any state, + * store it in your plugin->config, not a global! + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_radiotap_init(tcpeditdlt_t *ctx) +{ + tcpeditdlt_plugin_t *plugin; + radiotap_config_t *config; + assert(ctx); + + if ((plugin = tcpedit_dlt_getplugin(ctx, dlt_value)) == NULL) { + tcpedit_seterr(ctx->tcpedit, "Unable to initalize unregistered plugin %s", dlt_name); + return TCPEDIT_ERROR; + } + + /* allocate memory for our deocde extra data */ + if (sizeof(radiotap_extra_t) > 0) + ctx->decoded_extra = safe_malloc(sizeof(radiotap_extra_t)); + + /* allocate memory for our config data */ + if (sizeof(radiotap_config_t) > 0) + plugin->config = safe_malloc(sizeof(radiotap_config_t)); + + config = (radiotap_config_t *)plugin->config; + + + 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_radiotap_init(), this is just an stub. + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_radiotap_cleanup(tcpeditdlt_t *ctx) +{ + tcpeditdlt_plugin_t *plugin; + assert(ctx); + + if ((plugin = tcpedit_dlt_getplugin(ctx, dlt_value)) == NULL) { + tcpedit_seterr(ctx->tcpedit, "Unable to cleanup unregistered plugin %s", dlt_name); + return TCPEDIT_ERROR; + } + + if (ctx->decoded_extra != NULL) { + safe_free(ctx->decoded_extra); + ctx->decoded_extra = NULL; + } + + if (plugin->config != NULL) { + safe_free(plugin->config); + plugin->config = NULL; + } + + return TCPEDIT_OK; /* success */ +} + +/* + * This is where you should define all your AutoGen AutoOpts option parsing. + * Any user specified option should have it's bit turned on in the 'provides' + * bit mask. + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_radiotap_parse_opts(tcpeditdlt_t *ctx) +{ + assert(ctx); + + /* we have none */ + + return TCPEDIT_OK; /* success */ +} + +/* + * Function to decode the layer 2 header in the packet. + * You need to fill out: + * - ctx->l2len + * - ctx->srcaddr + * - ctx->dstaddr + * - ctx->proto + * - ctx->decoded_extra + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_radiotap_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen) +{ + int radiolen, rcode; + u_char *data; + assert(ctx); + assert(packet); + assert(pktlen >= (int)sizeof(radiotap_hdr_t)); + + radiolen = dlt_radiotap_l2len(ctx, packet, pktlen); + data = dlt_radiotap_get_80211(ctx, packet, pktlen, radiolen); + + /* ieee80211 decoder fills out everything */ + rcode = dlt_ieee80211_decode(ctx, data, pktlen - radiolen); + + /* need to override the ieee802.11 l2 length result */ + ctx->l2len = dlt_radiotap_80211_l2len(ctx, packet, pktlen); + return rcode; +} + +/* + * Function to encode the layer 2 header back into the packet. + * Returns: total packet len or TCPEDIT_ERROR + */ +int +dlt_radiotap_encode(tcpeditdlt_t *ctx, u_char *packet, int pktlen, _U_ tcpr_dir_t dir) +{ + assert(ctx); + assert(pktlen > 0); + assert(packet); + + tcpedit_seterr(ctx->tcpedit, "%s", "DLT_IEEE802_11_RADIO plugin does not support packet encoding"); + return TCPEDIT_ERROR; +} + +/* + * Function returns the Layer 3 protocol type of the given packet, or TCPEDIT_ERROR on error + * Make sure you return this in host byte order since all the comparisions will be + * against the ETHERTYPE_* values which are oddly in host byte order. + */ +int +dlt_radiotap_proto(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen) +{ + int radiolen; + u_char *data; + assert(ctx); + assert(packet); + assert(pktlen > (int)sizeof(radiotap_hdr_t)); + + radiolen = dlt_radiotap_l2len(ctx, packet, pktlen); + data = dlt_radiotap_get_80211(ctx, packet, pktlen, radiolen); + return dlt_ieee80211_proto(ctx, data, pktlen - radiolen); +} + +/* + * Function returns a pointer to the layer 3 protocol header or NULL on error + */ +u_char * +dlt_radiotap_get_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen) +{ + int radiolen, l2len; + u_char *data; + + assert(ctx); + assert(packet); + + radiolen = dlt_radiotap_l2len(ctx, packet, pktlen); + data = dlt_radiotap_get_80211(ctx, packet, pktlen, radiolen); + l2len = dlt_ieee80211_l2len(ctx, data, pktlen - radiolen); + return tcpedit_dlt_l3data_copy(ctx, data, pktlen - radiolen, l2len); +} + +/* + * function merges the packet (containing L2 and old L3) with the l3data buffer + * containing the new l3 data. Note, if L2 % 4 == 0, then they're pointing to the + * same buffer, otherwise there was a memcpy involved on strictly aligned architectures + * like SPARC + */ +u_char * +dlt_radiotap_merge_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen, u_char *l3data) +{ + int radiolen, l2len; + u_char *data; + + assert(ctx); + assert(packet); + assert(l3data); + + radiolen = dlt_radiotap_l2len(ctx, packet, pktlen); + data = dlt_radiotap_get_80211(ctx, packet, pktlen, radiolen); + l2len = dlt_ieee80211_l2len(ctx, data, pktlen); + return tcpedit_dlt_l3data_merge(ctx, data, pktlen - radiolen, l3data, l2len); +} + +/* + * return a static pointer to the source/destination MAC address + * return NULL on error/address doesn't exist + */ +u_char * +dlt_radiotap_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen) +{ + int radiolen; + u_char *data; + + assert(ctx); + assert(packet); + assert(pktlen); + + radiolen = dlt_radiotap_l2len(ctx, packet, pktlen); + data = dlt_radiotap_get_80211(ctx, packet, pktlen, radiolen); + return dlt_ieee80211_get_mac(ctx, mac, data, pktlen - radiolen); +} + + + +/* + * return the length of the L2 header of the current packet + */ +int +dlt_radiotap_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen) +{ + u_int16_t radiolen; + assert(ctx); + assert(packet); + assert(pktlen); + + memcpy(&radiolen, &packet[2], 2); + return (int)radiolen; +} + +/* + * return the length of the L2 header w/ 802.11 header of the current packet + */ +int +dlt_radiotap_80211_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen) +{ + int radiolen; + u_char *data; + + radiolen = dlt_radiotap_l2len(ctx, packet, pktlen); + data = dlt_radiotap_get_80211(ctx, packet, pktlen, radiolen); + radiolen += dlt_ieee80211_l2len(ctx, data, pktlen - radiolen); + return radiolen; +} + +tcpeditdlt_l2addr_type_t +dlt_radiotap_l2addr_type(void) +{ + /* FIXME: return the tcpeditdlt_l2addr_type_t value that this DLT uses */ + return ETHERNET; +} + +/* + * returns a buffer to the 802.11 header in the packet. + * This does an optimization of only doing a memcpy() once per packet + * since we track which was the last packet # we copied. + */ +static u_char * +dlt_radiotap_get_80211(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen, const int radiolen) +{ + radiotap_extra_t *extra; + static COUNTER lastpacket = 0; + + extra = (radiotap_extra_t *)(ctx->decoded_extra); + if (lastpacket != ctx->tcpedit->runtime.packetnum) { + memcpy(extra->packet, &packet[radiolen], pktlen - radiolen); + lastpacket = ctx->tcpedit->runtime.packetnum; + } + return extra->packet; +} diff --git a/src/tcpedit/plugins/dlt_radiotap/radiotap.h b/src/tcpedit/plugins/dlt_radiotap/radiotap.h new file mode 100644 index 0000000..91ccce6 --- /dev/null +++ b/src/tcpedit/plugins/dlt_radiotap/radiotap.h @@ -0,0 +1,86 @@ +/* $Id: radiotap.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#include "dlt_plugins-int.h" + +#ifndef _DLT_radiotap_H_ +#define _DLT_radiotap_H_ + +int dlt_radiotap_register(tcpeditdlt_t *ctx); +int dlt_radiotap_init(tcpeditdlt_t *ctx); +int dlt_radiotap_cleanup(tcpeditdlt_t *ctx); +int dlt_radiotap_parse_opts(tcpeditdlt_t *ctx); +int dlt_radiotap_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); +int dlt_radiotap_encode(tcpeditdlt_t *ctx, u_char *packet, int pktlen, tcpr_dir_t dir); +int dlt_radiotap_proto(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); +u_char *dlt_radiotap_get_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen); +u_char *dlt_radiotap_merge_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen, u_char *l3data); +tcpeditdlt_l2addr_type_t dlt_radiotap_l2addr_type(void); +int dlt_radiotap_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); +int dlt_radiotap_80211_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); +u_char *dlt_radiotap_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen); + +/* + * FIXME: structure to hold any data parsed from the packet by the decoder. + * Example: Ethernet VLAN tag info + */ +struct radiotap_extra_s { + u_char packet[MAXPACKET]; +}; +typedef struct radiotap_extra_s radiotap_extra_t; + + +/* + * FIXME: structure to hold any data in the tcpeditdlt_plugin_t->config + * Things like: + * - Parsed user options + * - State between packets + * - Note, you should only use this for the encoder function, decoder functions should place + * "extra" data parsed from the packet in the tcpeditdlt_t->decoded_extra buffer since that + * is available to any encoder plugin. + */ +struct radiotap_config_s { + /* dummy entry for SunPro compiler which doesn't like empty structs */ + int dummy; +}; +typedef struct radiotap_config_s radiotap_config_t; + +/* note, all radiotap_hdr fields are in LITTLE endian! WTF??? */ +struct radiotap_hdr_s { + u_int8_t version; + u_int8_t pad; + u_int16_t length; /* total header length */ + u_int32_t present; /* flags of present headers */ +}; +typedef struct radiotap_hdr_s radiotap_hdr_t; +#endif diff --git a/src/tcpedit/plugins/dlt_radiotap/radiotap_opts.def b/src/tcpedit/plugins/dlt_radiotap/radiotap_opts.def new file mode 100644 index 0000000..2b79413 --- /dev/null +++ b/src/tcpedit/plugins/dlt_radiotap/radiotap_opts.def @@ -0,0 +1 @@ +/* Add the flag definitions for your plugin here */ diff --git a/src/tcpedit/plugins/dlt_raw/Makefile.am b/src/tcpedit/plugins/dlt_raw/Makefile.am new file mode 100644 index 0000000..8f55ee5 --- /dev/null +++ b/src/tcpedit/plugins/dlt_raw/Makefile.am @@ -0,0 +1,25 @@ +# $Id: Makefile.am 1830 2007-04-21 07:33:54Z aturner $ +# START OF: dlt_raw +# Note, if you add any files to your plugin, you will need to edit dlt_/Makefile.am +# add your .c files to libtcpedit_a_SOURCES +# add your .h files to noinst_HEADERS +# add any other files (like documentation, notes, etc) to EXTRA_DIST +# add your dependancy information (see comment below) + +libtcpedit_a_SOURCES += $(srcdir)/plugins/dlt_raw/raw.c + +noinst_HEADERS += $(srcdir)/plugins/dlt_raw/raw.h + +EXTRA_DIST += $(srcdir)/plugins/dlt_raw/raw_opts.def + +# dependancies for your plugin source code. Edit as necessary +$(srcdir)/plugins/dlt_raw/raw.c: $(srcdir)/tcpedit_stub.h $(srcdir)/plugins/dlt_utils.h \ + $(srcdir)/plugins/dlt_raw/raw.h $(srcdir)/plugins/dlt_plugins.h $(srcdir)/plugins/dlt_plugins-int.h + +# You probably don't want to touch anything below this line until the end of the plugin + +DLT_STUB_DEPS += $(srcdir)/plugins/dlt_raw/raw_opts.def + +MOSTLYCLEANFILES += $(srcdir)/plugins/dlt_raw/*~ + +# END OF: dlt_raw diff --git a/src/tcpedit/plugins/dlt_raw/Makefile.in b/src/tcpedit/plugins/dlt_raw/Makefile.in new file mode 100644 index 0000000..e69de29 diff --git a/src/tcpedit/plugins/dlt_raw/raw.c b/src/tcpedit/plugins/dlt_raw/raw.c new file mode 100644 index 0000000..e35301a --- /dev/null +++ b/src/tcpedit/plugins/dlt_raw/raw.c @@ -0,0 +1,311 @@ +/* $Id: raw.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + +#include "dlt_plugins-int.h" +#include "dlt_utils.h" +#include "raw.h" +#include "tcpedit.h" +#include "common.h" +#include "tcpr.h" + +/* FIXME: edit these variables to taste */ +static char dlt_name[] = "raw"; +static char _U_ dlt_prefix[] = "raw"; +static u_int16_t dlt_value = DLT_RAW; + +/* + * DLT_RAW is basically a zero length L2 header for IPv4 & IPv6 packets + */ + +/* + * Function to register ourselves. This function is always called, regardless + * of what DLT types are being used, so it shouldn't be allocating extra buffers + * or anything like that (use the dlt_raw_init() function below for that). + * Tasks: + * - Create a new plugin struct + * - Fill out the provides/requires bit masks. Note: Only specify which fields are + * actually in the header. + * - Add the plugin to the context's plugin chain + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_raw_register(tcpeditdlt_t *ctx) +{ + tcpeditdlt_plugin_t *plugin; + assert(ctx); + + /* create a new plugin structure */ + plugin = tcpedit_dlt_newplugin(); + + /* set what we provide & require */ + plugin->provides += PLUGIN_MASK_PROTO; + + /* what is our DLT value? */ + plugin->dlt = dlt_value; + + /* set the prefix name of our plugin. This is also used as the prefix for our options */ + plugin->name = safe_strdup(dlt_prefix); + + /* + * Point to our functions, note, you need a function for EVERY method. + * Even if it is only an empty stub returning success. + */ + plugin->plugin_init = dlt_raw_init; + plugin->plugin_cleanup = dlt_raw_cleanup; + plugin->plugin_parse_opts = dlt_raw_parse_opts; + plugin->plugin_decode = dlt_raw_decode; + plugin->plugin_encode = dlt_raw_encode; + plugin->plugin_proto = dlt_raw_proto; + plugin->plugin_l2addr_type = dlt_raw_l2addr_type; + plugin->plugin_l2len = dlt_raw_l2len; + plugin->plugin_get_layer3 = dlt_raw_get_layer3; + plugin->plugin_merge_layer3 = dlt_raw_merge_layer3; + plugin->plugin_get_mac = dlt_raw_get_mac; + + /* add it to the available plugin list */ + return tcpedit_dlt_addplugin(ctx, plugin); +} + + +/* + * Initializer function. This function is called only once, if and only iif + * this plugin will be utilized. Remember, if you need to keep track of any state, + * store it in your plugin->config, not a global! + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_raw_init(tcpeditdlt_t *ctx) +{ + tcpeditdlt_plugin_t *plugin; + raw_config_t *config; + assert(ctx); + + if ((plugin = tcpedit_dlt_getplugin(ctx, dlt_value)) == NULL) { + tcpedit_seterr(ctx->tcpedit, "Unable to initalize unregistered plugin %s", dlt_name); + return TCPEDIT_ERROR; + } + + /* allocate memory for our deocde extra data */ + if (sizeof(raw_extra_t) > 0) + ctx->decoded_extra = safe_malloc(sizeof(raw_extra_t)); + + /* allocate memory for our config data */ + if (sizeof(raw_config_t) > 0) + plugin->config = safe_malloc(sizeof(raw_config_t)); + + config = (raw_config_t *)plugin->config; + + 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_raw_init(), this is just an stub. + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_raw_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; + } + + /* FIXME: make this function do something if necessary */ + if (ctx->decoded_extra != NULL) { + safe_free(ctx->decoded_extra); + ctx->decoded_extra = NULL; + } + + if (plugin->config != NULL) { + safe_free(plugin->config); + plugin->config = NULL; + } + + return TCPEDIT_OK; /* success */ +} + +/* + * This is where you should define all your AutoGen AutoOpts option parsing. + * Any user specified option should have it's bit turned on in the 'provides' + * bit mask. + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_raw_parse_opts(tcpeditdlt_t *ctx) +{ + assert(ctx); + + /* no op */ + return TCPEDIT_OK; /* success */ +} + +/* + * Function to decode the layer 2 header in the packet. + * You need to fill out: + * - ctx->l2len + * - ctx->srcaddr + * - ctx->dstaddr + * - ctx->proto + * - ctx->decoded_extra + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_raw_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen) +{ + int proto; + assert(ctx); + assert(packet); + assert(pktlen > 0); + + if ((proto = dlt_raw_proto(ctx, packet, pktlen)) == TCPEDIT_ERROR) + return TCPEDIT_ERROR; + + ctx->proto = (u_int16_t)proto; + ctx->l2len = 0; + + return TCPEDIT_OK; /* success */ +} + +/* + * Function to encode the layer 2 header back into the packet. + * Returns: total packet len or TCPEDIT_ERROR + */ +int +dlt_raw_encode(tcpeditdlt_t *ctx, u_char *packet, int pktlen, _U_ tcpr_dir_t dir) +{ + assert(ctx); + assert(pktlen > 0); + assert(packet); + + tcpedit_seterr(ctx->tcpedit, "%s", "DLT_RAW plugin does not support packet encoding"); + return TCPEDIT_ERROR; +} + +/* + * Function returns the Layer 3 protocol type of the given packet, or TCPEDIT_ERROR on error + */ +int +dlt_raw_proto(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen) +{ + struct tcpr_ipv4_hdr *iphdr; + assert(ctx); + assert(packet); + assert(pktlen > 0); + int protocol = 0; + + iphdr = (struct tcpr_ipv4_hdr *)packet; + if (iphdr->ip_v == 0x04) { + protocol = ETHERTYPE_IP; + } else if (iphdr->ip_v == 0x06) { + protocol = ETHERTYPE_IP6; + } else { + tcpedit_seterr(ctx->tcpedit, "%s", "Unsupported DLT_RAW packet: doesn't look like IPv4 or IPv6"); + return TCPEDIT_ERROR; + } + + return htons(protocol); +} + +/* + * Function returns a pointer to the layer 3 protocol header or NULL on error + */ +u_char * +dlt_raw_get_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen) +{ + assert(ctx); + assert(packet); + assert(pktlen); + + /* raw has a zero byte header, so this is basically a non-op */ + + return packet; +} + +/* + * function merges the packet (containing L2 and old L3) with the l3data buffer + * containing the new l3 data. Note, if L2 % 4 == 0, then they're pointing to the + * same buffer, otherwise there was a memcpy involved on strictly aligned architectures + * like SPARC + */ +u_char * +dlt_raw_merge_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen, u_char *l3data) +{ + assert(ctx); + assert(packet); + assert(l3data); + assert(pktlen); + + /* raw has a zero byte header, so this is basically a non-op */ + + return packet; +} + +/* + * return the length of the L2 header of the current packet + */ +int +dlt_raw_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen) +{ + assert(ctx); + assert(packet); + assert(pktlen); + + return 0; +} + +/* + * return a static pointer to the source/destination MAC address + * return NULL on error/address doesn't exist + */ +u_char * +dlt_raw_get_mac(tcpeditdlt_t *ctx, _U_ tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen) +{ + assert(ctx); + assert(packet); + assert(pktlen); + + return(NULL); +} + +tcpeditdlt_l2addr_type_t +dlt_raw_l2addr_type(void) +{ + return NONE; +} + diff --git a/src/tcpedit/plugins/dlt_raw/raw.h b/src/tcpedit/plugins/dlt_raw/raw.h new file mode 100644 index 0000000..7d4558f --- /dev/null +++ b/src/tcpedit/plugins/dlt_raw/raw.h @@ -0,0 +1,79 @@ +/* $Id: raw.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#include "dlt_plugins-int.h" + +#ifndef _DLT_raw_H_ +#define _DLT_raw_H_ + +int dlt_raw_register(tcpeditdlt_t *ctx); +int dlt_raw_init(tcpeditdlt_t *ctx); +int dlt_raw_cleanup(tcpeditdlt_t *ctx); +int dlt_raw_parse_opts(tcpeditdlt_t *ctx); +int dlt_raw_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); +int dlt_raw_encode(tcpeditdlt_t *ctx, u_char *packet, int pktlen, tcpr_dir_t dir); +int dlt_raw_proto(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); +u_char *dlt_raw_get_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen); +u_char *dlt_raw_merge_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen, u_char *l3data); +tcpeditdlt_l2addr_type_t dlt_raw_l2addr_type(void); +int dlt_raw_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); +u_char *dlt_raw_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen); + +/* + * structure to hold any data parsed from the packet by the decoder. + * Example: Ethernet VLAN tag info + */ +struct raw_extra_s { + /* dummy entry for SunPro compiler which doesn't like empty structs */ + int dummy; +}; +typedef struct raw_extra_s raw_extra_t; + + +/* + * FIXME: structure to hold any data in the tcpeditdlt_plugin_t->config + * Things like: + * - Parsed user options + * - State between packets + * - Note, you should only use this for the encoder function, decoder functions should place + * "extra" data parsed from the packet in the tcpeditdlt_t->decoded_extra buffer since that + * is available to any encoder plugin. + */ +struct raw_config_s { + /* dummy entry for SunPro compiler which doesn't like empty structs */ + int dummy; +}; +typedef struct raw_config_s raw_config_t; + +#endif + diff --git a/src/tcpedit/plugins/dlt_raw/raw_opts.def b/src/tcpedit/plugins/dlt_raw/raw_opts.def new file mode 100644 index 0000000..987f459 --- /dev/null +++ b/src/tcpedit/plugins/dlt_raw/raw_opts.def @@ -0,0 +1 @@ +/* No options for DLT_RAW as it's an decoder only plugin */ diff --git a/src/tcpedit/plugins/dlt_stub.def b/src/tcpedit/plugins/dlt_stub.def new file mode 100644 index 0000000..cb36369 --- /dev/null +++ b/src/tcpedit/plugins/dlt_stub.def @@ -0,0 +1,12 @@ +#include dlt_opts.def + +/* Add your plugin option definitions here. */ +#include dlt_en10mb/en10mb_opts.def +#include dlt_hdlc/hdlc_opts.def +#include dlt_user/user_opts.def +#include dlt_raw/raw_opts.def +#include dlt_null/null_opts.def +#include dlt_loop/loop_opts.def +#include dlt_linuxsll/linuxsll_opts.def +#include dlt_ieee80211/ieee80211_opts.def +#include dlt_radiotap/radiotap_opts.def diff --git a/src/tcpedit/plugins/dlt_user/Makefile.am b/src/tcpedit/plugins/dlt_user/Makefile.am new file mode 100644 index 0000000..361efb6 --- /dev/null +++ b/src/tcpedit/plugins/dlt_user/Makefile.am @@ -0,0 +1,25 @@ +# $Id: Makefile.am 1830 2007-04-21 07:33:54Z aturner $ +# START OF: dlt_user +# Note, if you add any files to your plugin, you will need to edit dlt_/Makefile.am +# add your .c files to libtcpedit_a_SOURCES +# add your .h files to noinst_HEADERS +# add any other files (like documentation, notes, etc) to EXTRA_DIST +# add your dependancy information (see comment below) + +libtcpedit_a_SOURCES += $(srcdir)/plugins/dlt_user/user.c + +noinst_HEADERS += $(srcdir)/plugins/dlt_user/user.h + +EXTRA_DIST += $(srcdir)/plugins/dlt_user/user_opts.def + +# dependancies for your plugin source code. Edit as necessary +$(srcdir)/plugins/dlt_user/user.c: $(srcdir)/tcpedit_stub.h $(srcdir)/plugins/dlt_utils.h \ + $(srcdir)/plugins/dlt_user/user.h $(srcdir)/plugins/dlt_plugins.h $(srcdir)/plugins/dlt_plugins-int.h + +# You probably don't want to touch anything below this line until the end of the plugin + +DLT_STUB_DEPS += $(srcdir)/plugins/dlt_user/user_opts.def + +MOSTLYCLEANFILES += $(srcdir)/plugins/dlt_user/*~ + +# END OF: dlt_user diff --git a/src/tcpedit/plugins/dlt_user/Makefile.in b/src/tcpedit/plugins/dlt_user/Makefile.in new file mode 100644 index 0000000..e69de29 diff --git a/src/tcpedit/plugins/dlt_user/user.c b/src/tcpedit/plugins/dlt_user/user.c new file mode 100644 index 0000000..66ddd8d --- /dev/null +++ b/src/tcpedit/plugins/dlt_user/user.c @@ -0,0 +1,375 @@ +/* $Id: user.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + +#include "dlt_plugins-int.h" +#include "dlt_utils.h" +#include "user.h" +#include "tcpedit.h" +#include "common.h" +#include "tcpr.h" + +static char dlt_name[] = "user"; +static char _U_ dlt_prefix[] = "user"; +static u_int16_t dlt_value = DLT_USER0; + +/* + * Function to register ourselves. This function is always called, regardless + * of what DLT types are being used, so it shouldn't be allocating extra buffers + * or anything like that (use the dlt_user_init() function below for that). + * Tasks: + * - Create a new plugin struct + * - Fill out the provides/requires bit masks. Note: Only specify which fields are + * actually in the header. + * - Add the plugin to the context's plugin chain + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_user_register(tcpeditdlt_t *ctx) +{ + tcpeditdlt_plugin_t *plugin; + assert(ctx); + + /* create a new plugin structure */ + plugin = tcpedit_dlt_newplugin(); + + /* FIXME: set what we provide & require */ + plugin->provides += PLUGIN_MASK_PROTO + PLUGIN_MASK_SRCADDR + PLUGIN_MASK_DSTADDR; + plugin->requires += 0; // PLUGIN_MASK_PROTO + PLUGIN_MASK_SRCADDR + PLUGIN_MASK_DSTADDR; + + /* what is our DLT value? */ + plugin->dlt = dlt_value; + + /* set the prefix name of our plugin. This is also used as the prefix for our options */ + plugin->name = safe_strdup(dlt_prefix); + + /* + * Point to our functions, note, you need a function for EVERY method. + * Even if it is only an empty stub returning success. + */ + plugin->plugin_init = dlt_user_init; + plugin->plugin_cleanup = dlt_user_cleanup; + plugin->plugin_parse_opts = dlt_user_parse_opts; + plugin->plugin_decode = dlt_user_decode; + plugin->plugin_encode = dlt_user_encode; + plugin->plugin_proto = dlt_user_proto; + plugin->plugin_l2addr_type = dlt_user_l2addr_type; + plugin->plugin_l2len = dlt_user_l2len; + plugin->plugin_get_layer3 = dlt_user_get_layer3; + plugin->plugin_merge_layer3 = dlt_user_merge_layer3; + plugin->plugin_get_mac = dlt_user_get_mac; + + /* add it to the available plugin list */ + return tcpedit_dlt_addplugin(ctx, plugin); +} + + +/* + * Initializer function. This function is called only once, if and only iif + * this plugin will be utilized. Remember, if you need to keep track of any state, + * store it in your plugin->config, not a global! + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_user_init(tcpeditdlt_t *ctx) +{ + tcpeditdlt_plugin_t *plugin; + user_config_t *config; + assert(ctx); + + if ((plugin = tcpedit_dlt_getplugin(ctx, dlt_value)) == NULL) { + tcpedit_seterr(ctx->tcpedit, "Unable to initalize unregistered plugin %s", dlt_name); + return TCPEDIT_ERROR; + } + + /* allocate memory for our deocde extra data */ + if (sizeof(user_extra_t) > 0) + ctx->decoded_extra = safe_malloc(sizeof(user_extra_t)); + + /* allocate memory for our config data */ + if (sizeof(user_config_t) > 0) + plugin->config = safe_malloc(sizeof(user_config_t)); + + config = (user_config_t *)plugin->config; + /* do nothing */ + 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_user_init(), this is just an stub. + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_user_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; + } + + /* FIXME: make this function do something if necessary */ + if (ctx->decoded_extra != NULL) { + safe_free(ctx->decoded_extra); + ctx->decoded_extra = NULL; + } + + if (plugin->config != NULL) { + safe_free(plugin->config); + plugin->config = NULL; + } + + return TCPEDIT_OK; /* success */ +} + +/* + * This is where you should define all your AutoGen AutoOpts option parsing. + * Any user specified option should have it's bit turned on in the 'provides' + * bit mask. + * Returns: TCPEDIT_ERROR | TCPEDIT_OK | TCPEDIT_WARN + */ +int +dlt_user_parse_opts(tcpeditdlt_t *ctx) +{ + tcpeditdlt_plugin_t *plugin; + user_config_t *config; + assert(ctx); + + plugin = tcpedit_dlt_getplugin(ctx, dlt_value); + config = plugin->config; + + /* + * --user-dlt will override the output DLT type, otherwise we'll use + * the DLT of the decoder + */ + if (HAVE_OPT(USER_DLT)) { + config->dlt = OPT_VALUE_USER_DLT; + } else { + config->dlt = ctx->decoder->dlt; + } + + /* --user-dlink */ + if (HAVE_OPT(USER_DLINK)) { + int ct = STACKCT_OPT(USER_DLINK); + char **list = STACKLST_OPT(USER_DLINK); + int first = 1; + + do { + char *p = *list++; + if (first) { + config->length = read_hexstring(p, config->l2server, USER_L2MAXLEN); + memcpy(config->l2client, config->l2server, config->length); + } else { + if (config->length != read_hexstring(p, config->l2client, USER_L2MAXLEN)) { + tcpedit_seterr(ctx->tcpedit, "%s", + "both --dlink's must contain the same number of bytes"); + return TCPEDIT_ERROR; + } + } + + first = 0; + } while (--ct > 0); + } + + return TCPEDIT_OK; /* success */ +} + +/* you should never decode packets with this plugin! */ +int +dlt_user_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen) +{ + assert(ctx); + assert(packet); + assert(pktlen); + + tcpedit_seterr(ctx->tcpedit, "%s", "DLT_USER0 plugin does not support packet decoding"); + return TCPEDIT_ERROR; +} + +/* + * Function to encode the layer 2 header back into the packet. + * Returns: total packet len or TCPEDIT_ERROR + */ +int +dlt_user_encode(tcpeditdlt_t *ctx, u_char *packet, int pktlen, tcpr_dir_t dir) +{ + user_config_t *config; + tcpeditdlt_plugin_t *plugin; + u_char tmpbuff[MAXPACKET]; + + assert(ctx); + assert(pktlen > 0); + assert(packet); + + plugin = tcpedit_dlt_getplugin(ctx, dlt_value); + config = plugin->config; + + /* Make room for our new l2 header if l2len != config->length */ + if (ctx->l2len > config->length) { + memmove(packet + config->length, packet + ctx->l2len, pktlen - ctx->l2len); + } else if (ctx->l2len < config->length) { + memcpy(tmpbuff, packet, pktlen); + memcpy(packet + config->length, (tmpbuff + ctx->l2len), pktlen - ctx->l2len); + } + + /* update the total packet length */ + pktlen += config->length - ctx->l2len; + + if (dir == TCPR_DIR_C2S) { + memcpy(packet, config->l2client, config->length); + } else if (dir == TCPR_DIR_S2C) { + memcpy(packet, config->l2server, config->length); + } else { + tcpedit_seterr(ctx->tcpedit, "%s", "Encoders only support C2S or C2S!"); + return TCPEDIT_ERROR; + } + + + return pktlen; /* success */ +} + +/* + * Function returns the Layer 3 protocol type of the given packet, or TCPEDIT_ERROR on error + */ +int +dlt_user_proto(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen) +{ + assert(ctx); + assert(packet); + assert(pktlen); + + /* calling this for DLT_USER0 is broken */ + tcpedit_seterr(ctx->tcpedit, "%s", "Nonsensical calling of dlt_user_proto()"); + return TCPEDIT_ERROR; +} + +/* + * Function returns a pointer to the layer 3 protocol header or NULL on error + */ +u_char * +dlt_user_get_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen) +{ + int l2len; + assert(ctx); + assert(packet); + + /* FIXME: Is there anything else we need to do?? */ + l2len = dlt_user_l2len(ctx, packet, pktlen); + + assert(pktlen >= l2len); + + return tcpedit_dlt_l3data_copy(ctx, packet, pktlen, l2len); +} + +/* + * function merges the packet (containing L2 and old L3) with the l3data buffer + * containing the new l3 data. Note, if L2 % 4 == 0, then they're pointing to the + * same buffer, otherwise there was a memcpy involved on strictly aligned architectures + * like SPARC + */ +u_char * +dlt_user_merge_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen, u_char *l3data) +{ + int l2len; + assert(ctx); + assert(packet); + assert(l3data); + + /* FIXME: Is there anything else we need to do?? */ + l2len = dlt_user_l2len(ctx, packet, pktlen); + + assert(pktlen >= l2len); + + return tcpedit_dlt_l3data_merge(ctx, packet, pktlen, l3data, l2len); +} + +/* + * return the length of the L2 header of the current packet + */ +int +dlt_user_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen) +{ + tcpeditdlt_plugin_t *plugin; + user_config_t *config; + assert(ctx); + assert(packet); + assert(pktlen); + + plugin = tcpedit_dlt_getplugin(ctx, dlt_value); + config = plugin->config; + + return config->length; +} + +/* + * return a static pointer to the source/destination MAC address + * return NULL on error/address doesn't exist + */ +u_char * +dlt_user_get_mac(tcpeditdlt_t *ctx, _U_ tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen) +{ + assert(ctx); + assert(packet); + assert(pktlen); + + /* we don't know the format of USER DLT, hence always return NULL */ + return(NULL); +} + +tcpeditdlt_l2addr_type_t +dlt_user_l2addr_type(void) +{ + return NONE; +} + +/* + * Need this special function for dlt_plugins.c:tcpedit_dlt_output_dlt() + */ + +u_int16_t +dlt_user_get_output_dlt(tcpeditdlt_t *ctx) +{ + tcpeditdlt_plugin_t *plugin; + user_config_t *config; + assert(ctx); + + plugin = tcpedit_dlt_getplugin(ctx, dlt_value); + config = plugin->config; + return config->dlt; +} + + diff --git a/src/tcpedit/plugins/dlt_user/user.h b/src/tcpedit/plugins/dlt_user/user.h new file mode 100644 index 0000000..6705251 --- /dev/null +++ b/src/tcpedit/plugins/dlt_user/user.h @@ -0,0 +1,86 @@ +/* $Id: user.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#include "dlt_plugins-int.h" + +#ifndef _DLT_user_H_ +#define _DLT_user_H_ + +int dlt_user_register(tcpeditdlt_t *ctx); +int dlt_user_init(tcpeditdlt_t *ctx); +int dlt_user_cleanup(tcpeditdlt_t *ctx); +int dlt_user_parse_opts(tcpeditdlt_t *ctx); +int dlt_user_decode(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); +int dlt_user_encode(tcpeditdlt_t *ctx, u_char *packet, int pktlen, tcpr_dir_t dir); +int dlt_user_proto(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); +u_char *dlt_user_get_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen); +u_char *dlt_user_merge_layer3(tcpeditdlt_t *ctx, u_char *packet, const int pktlen, u_char *l3data); +tcpeditdlt_l2addr_type_t dlt_user_l2addr_type(void); +int dlt_user_l2len(tcpeditdlt_t *ctx, const u_char *packet, const int pktlen); +u_char *dlt_user_get_mac(tcpeditdlt_t *ctx, tcpeditdlt_mac_type_t mac, const u_char *packet, const int pktlen); + +/* extra function called directly by tcpedit_dlt_output_dlt() */ +u_int16_t dlt_user_get_output_dlt(tcpeditdlt_t *ctx); + + +/* + * FIXME: structure to hold any data parsed from the packet by the decoder. + * Example: Ethernet VLAN tag info + */ +struct user_extra_s { + /* dummy entry for SunPro compiler which doesn't like empty structs */ + int dummy; +}; +typedef struct user_extra_s user_extra_t; + +#define USER_L2MAXLEN 255 + +/* + * FIXME: structure to hold any data in the tcpeditdlt_plugin_t->config + * Things like: + * - Parsed user options + * - State between packets + * - Note, you should only use this for the encoder function, decoder functions should place + * "extra" data parsed from the packet in the tcpeditdlt_t->decoded_extra buffer since that + * is available to any encoder plugin. + */ +struct user_config_s { + u_int16_t dlt; + int length; + u_char l2client[USER_L2MAXLEN]; + u_char l2server[USER_L2MAXLEN]; +}; +typedef struct user_config_s user_config_t; + +#endif + diff --git a/src/tcpedit/plugins/dlt_user/user_opts.def b/src/tcpedit/plugins/dlt_user/user_opts.def new file mode 100644 index 0000000..f3208fe --- /dev/null +++ b/src/tcpedit/plugins/dlt_user/user_opts.def @@ -0,0 +1,32 @@ +/* Add the flag definitions for your plugin here */ + +flag = { + name = user-dlt; + arg-type = "number"; + max = 1; + descrip = "Set output file DLT type"; + range = "0->65535"; + doc = <<- EOText +Set the DLT value of the output pcap file. +EOText; +}; + +flag = { + name = user-dlink; + arg-type = string; + max = 2; + stack-arg; + descrip = "Rewrite Data-Link layer with user specified data"; + doc = <<- EOText +Provide a series of comma deliminated hex values which will be +used to rewrite or create the Layer 2 header of the packets. +The first instance of this argument will rewrite both server +and client traffic, but if this argument is specified a second +time, it will be used for the client traffic. + +Example: +@example +--user-dlink=01,02,03,04,05,06,00,1A,2B,3C,4D,5E,6F,08,00 +@end example +EOText; +}; \ No newline at end of file diff --git a/src/tcpedit/plugins/dlt_utils.c b/src/tcpedit/plugins/dlt_utils.c new file mode 100644 index 0000000..2877318 --- /dev/null +++ b/src/tcpedit/plugins/dlt_utils.c @@ -0,0 +1,264 @@ +/* $Id: dlt_utils.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +#include "dlt_plugins-int.h" +#include "dlt_utils.h" +#include "common.h" + +/* from dlt_plugins.c */ +extern const u_int32_t tcpeditdlt_bit_map[]; +extern const char *tcpeditdlt_bit_info[]; + +/* + * Call parse args on src & dst plugins + */ +int +tcpedit_dlt_parse_opts(tcpeditdlt_t *ctx) +{ + assert(ctx); + + if (ctx->decoder->plugin_parse_opts(ctx) != TCPEDIT_OK) + return TCPEDIT_ERROR; + + if (ctx->decoder->dlt != ctx->encoder->dlt) { + if (ctx->encoder->plugin_parse_opts(ctx) != TCPEDIT_OK) + return TCPEDIT_ERROR; + } + + return TCPEDIT_OK; +} + +/* + * find a given plugin struct in the context for a given DLT. Returns NULL on failure + */ +tcpeditdlt_plugin_t * +tcpedit_dlt_getplugin(tcpeditdlt_t *ctx, int dlt) +{ + tcpeditdlt_plugin_t *ptr; + + assert(ctx); + + ptr = ctx->plugins; + if (ptr == NULL) + return NULL; + + while (ptr->dlt != dlt && ptr->next != NULL) { + ptr = ptr->next; + } + + if (ptr->dlt == dlt) + return ptr; + + return NULL; +} + +/* + * find a given plugin struct in the context for a given DLT. Returns NULL on failure + */ +tcpeditdlt_plugin_t * +tcpedit_dlt_getplugin_byname(tcpeditdlt_t *ctx, const char *name) +{ + tcpeditdlt_plugin_t *ptr; + + assert(ctx); + assert(name); + + ptr = ctx->plugins; + if (ptr == NULL) + return NULL; + + while ((strcmp(ptr->name, name) != 0) && ptr->next != NULL) { + ptr = ptr->next; + } + + if (strcmp(ptr->name, name) == 0) + return ptr; + + return NULL; +} + +/* + * Create a new plugin struct. WILL NOT RETURN ON FAILURE! (out of memory is not recoverable) + */ +tcpeditdlt_plugin_t * +tcpedit_dlt_newplugin(void) +{ + tcpeditdlt_plugin_t *plugin; + + plugin = (tcpeditdlt_plugin_t *)safe_malloc(sizeof(tcpeditdlt_plugin_t)); + plugin->dlt = 0xffff; /* zero is a valid plugin, so use 0xffff */ + return plugin; +} + +/* + * Add a plugin to the plugin chain for the given context. Return 0 on success, + * -1 on failure + */ +int +tcpedit_dlt_addplugin(tcpeditdlt_t *ctx, tcpeditdlt_plugin_t *new) +{ + tcpeditdlt_plugin_t *ptr; + assert(ctx); + assert(new); + + /* look for a dupe by DLT */ + if ((ptr = tcpedit_dlt_getplugin(ctx, new->dlt)) != NULL) { + tcpedit_seterr(ctx->tcpedit, "Can only have one DLT plugin registered per-DLT: 0x%x", new->dlt); + return TCPEDIT_ERROR; + } + + /* dupe by name? */ + if ((ptr = tcpedit_dlt_getplugin_byname(ctx, new->name)) != NULL) { + tcpedit_seterr(ctx->tcpedit, "Can only have one DLT plugin registered per-name: %s", new->name); + return TCPEDIT_ERROR; + } + + /* + * check that the plugin is properly constructed, note that the encoder + * and decoder are optional! + */ + assert(new->dlt < 0xffff); + assert(new->plugin_init); + assert(new->plugin_cleanup); + assert(new->plugin_parse_opts); + assert(new->plugin_proto); + assert(new->plugin_l2addr_type); + assert(new->plugin_l2len); + assert(new->plugin_get_layer3); + assert(new->plugin_merge_layer3); + + + /* add it to the end of the chain */ + if (ctx->plugins == NULL) { + ctx->plugins = new; + } else { + ptr = ctx->plugins; + while (ptr->next != NULL) + ptr = ptr->next; + + ptr->next = new; + } + + /* we're done */ + return 0; +} + + +/* + * validates that the decoder plugin provides all the fields that are required + * by then encoding plugin. Returns TCPEDIT_OK | TCPEDIT_ERROR + */ +int +tcpedit_dlt_validate(tcpeditdlt_t *ctx) +{ + u_int32_t bit; + + /* loops from 1 -> UINT32_MAX by powers of 2 */ + for (bit = 1; bit != 0; bit = bit << 2) { + if (ctx->encoder->requires & bit && ! ctx->decoder->provides & bit) { + tcpedit_seterr(ctx->tcpedit, "%s", tcpeditdlt_bit_info[tcpeditdlt_bit_map[bit]]); + return TCPEDIT_ERROR; + } + } + + dbgx(1, "Input linktype is %s", + pcap_datalink_val_to_description(ctx->decoder->dlt)); + dbgx(1, "Output linktype is %s", + pcap_datalink_val_to_description(ctx->encoder->dlt)); + + return TCPEDIT_OK; +} + + +/* + * Utility function to extract the Layer 3 header and beyond in a single buffer + * Since some CPU's like UltraSPARC are strictly aligned, they really don't like + * it when you jump to an offset which isn't on a word boundry (like ethernet) + */ +u_char * +tcpedit_dlt_l3data_copy(tcpeditdlt_t *ctx, u_char *packet, int pktlen, int l2len) +{ + u_char *ptr; + assert(ctx); + assert(packet); + assert(pktlen); + + if (pktlen <= l2len) + return NULL; + +#ifdef FORCE_ALIGN + /* + * copy layer 3 and up to our temp packet buffer + * for now on, we have to edit the packetbuff because + * just before we send the packet, we copy the packetbuff + * back onto the pkt.data + l2len buffer + * we do all this work to prevent byte alignment issues + */ + if (l2len % 4 == 0) { + ptr = (&(packet)[l2len]); + } else { + ptr = ctx->l3buff; + memcpy(ptr, (&(packet)[l2len]), pktlen - l2len); + } +#else + /* + * on non-strict byte align systems, don't need to memcpy(), + * just point to 14 bytes into the existing buffer + */ + ptr = (&(packet)[l2len]); +#endif + return ptr; +} + +/* + * reverse of tcpedit_dlt_l3data_copy + */ +u_char * +tcpedit_dlt_l3data_merge(tcpeditdlt_t *ctx, u_char *packet, int pktlen, const u_char *l3data, const int l2len) +{ + assert(ctx); + assert(packet); + assert(pktlen >= 0); + assert(l3data); + assert(l2len >= 0); +#ifdef FORCE_ALIGN + /* + * put back the layer 3 and above back in the pkt.data buffer + * we can't edit the packet at layer 3 or above beyond this point + */ + if (l2len % 4 != 0) + memcpy((&(packet)[l2len]), l3data, pktlen - l2len); +#endif + return packet; +} diff --git a/src/tcpedit/plugins/dlt_utils.h b/src/tcpedit/plugins/dlt_utils.h new file mode 100644 index 0000000..70f8b66 --- /dev/null +++ b/src/tcpedit/plugins/dlt_utils.h @@ -0,0 +1,50 @@ +/* $Id: dlt_utils.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#ifndef _DLT_UTILS_H_ +#define _DLT_UTILS_H_ + +u_char *tcpedit_dlt_l3data_copy(tcpeditdlt_t *ctx, u_char *packet, int ptklen, int l2len); +u_char *tcpedit_dlt_l3data_merge(tcpeditdlt_t *ctx, u_char *packet, int pktlen, const u_char *l3data, const int l2len); + +int tcpedit_dlt_parse_opts(tcpeditdlt_t *ctx); +int tcpedit_dlt_validate(tcpeditdlt_t *ctx); + +tcpeditdlt_plugin_t *tcpedit_dlt_newplugin(void); +tcpeditdlt_plugin_t *tcpedit_dlt_getplugin(tcpeditdlt_t *ctx, int dlt); +tcpeditdlt_plugin_t *tcpedit_dlt_getplugin_byname(tcpeditdlt_t *ctx, const char *name); + +int tcpedit_dlt_addplugin(tcpeditdlt_t *ctx, tcpeditdlt_plugin_t *new); + + +#endif diff --git a/src/tcpedit/plugins/ethernet.c b/src/tcpedit/plugins/ethernet.c new file mode 100644 index 0000000..bc95e63 --- /dev/null +++ b/src/tcpedit/plugins/ethernet.c @@ -0,0 +1,61 @@ +/* $Id: ethernet.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#include "tcpedit.h" +#include "dlt_plugins-int.h" +#include +#include + +/* + * takes a ptr to an ethernet address and returns + * 1 if it is unicast or 0 if it is multicast or + * broadcast. + */ +int +is_unicast_ethernet(tcpeditdlt_t *ctx, const u_char *ether) +{ + + assert(ctx); + assert(ether); + + /* is broadcast? */ + if (memcmp(ether, BROADCAST_MAC, ETHER_ADDR_LEN) == 0) + return 0; + + /* Multicast addresses' leading octet are odd */ + if ((ether[0] & 0x01) == 0x01) + return 0; + + /* everything else is unicast */ + return 1; +} diff --git a/src/tcpedit/plugins/ethernet.h b/src/tcpedit/plugins/ethernet.h new file mode 100644 index 0000000..c156a6b --- /dev/null +++ b/src/tcpedit/plugins/ethernet.h @@ -0,0 +1,47 @@ +/* $Id: ethernet.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + + +/* + * Generic functions for ethernet addresses + */ + +#include "dlt_plugins.h" + +#ifndef _ETHERNET_H_ +#define _ETHERNET_H_ + +int is_unicast_ethernet(tcpeditdlt_t *, const u_char *); + + +#endif diff --git a/src/tcpedit/portmap.c b/src/tcpedit/portmap.c new file mode 100644 index 0000000..64cee14 --- /dev/null +++ b/src/tcpedit/portmap.c @@ -0,0 +1,377 @@ +/* $Id: portmap.c 2430 2010-03-27 21:05:46Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This file contains routines to manipulate port maps, in which + * one port number is mapped to another. + */ +#include "config.h" +#include "defines.h" +#include "common.h" + +#include +#include +#include + +#include "tcpreplay.h" +#include "tcpedit-int.h" +#include "portmap.h" + +/** + * mallocs a new tcpedit_portmap_t structure + */ +tcpedit_portmap_t * +new_portmap() +{ + tcpedit_portmap_t *newportmap; + + newportmap = (tcpedit_portmap_t *)safe_malloc(sizeof(tcpedit_portmap_t)); + return (newportmap); +} + +/** + * \brief parses a string : and returns a new tcpedit_portmap_t struct + * + * We support the following formats: + * : - map a single port to a new port + * -: - map a range of ports to a new port + * ++...: - map a list of ports to a single ports + * + * In the case of port ranges or port lists, we actually return a + * chain of tcpedit_portmap_t's + */ +static tcpedit_portmap_t * +ports2PORT(char *ports) +{ + tcpedit_portmap_t *portmap = NULL, *portmap_head = NULL, *portmap_last = NULL; + char *from_s, *to_s, *from_begin, *from_end, *badchar; + long from_l, to_l, from_b, from_e, i; + char *token = NULL, *token2 = NULL; + + assert(ports); + + from_begin = NULL; + from_end = NULL; + + /* first split the port numbers */ + from_s = strtok_r(ports, ":", &token); + to_s = strtok_r(NULL, ":", &token); + + /* if there's anything left, it's a syntax error */ + if (strtok_r(NULL, ":", &token) != NULL) + return NULL; + + /* if either of the parsed strings is NULL, we have a problem */ + if (from_s == NULL || to_s == NULL) + return NULL; + + /* source map can have - (range) or , (and), but not both */ + if (strchr(from_s, '-') && strchr(from_s, '+')) + return NULL; + + /* process to the to port */ + to_l = strtol(to_s, &badchar, 10); + if (strlen(badchar) != 0) + return NULL; + + if (to_l > 65535 || to_l < 0) + return NULL; + + /* + * put the new portmap info into the new node + * while we convert to network-byte order, b/c its better + * to do it once now, rather then each time we have to do a lookup + */ + portmap_head = new_portmap(); + portmap = portmap_head; + + /* process a range, setting from_begin & from_end */ + if (strchr(from_s, '-')) { + from_begin = strtok_r(from_s, "-", &token2); + from_end = strtok_r(NULL, "-", &token2); + from_b = strtol(from_begin, &badchar, 10); + if (strlen(badchar) != 0) + return NULL; + from_e = strtol(from_end, &badchar, 10); + if (strlen(badchar) != 0) + return NULL; + + if (from_b > 65535 || from_b < 0 || from_e > 65535 || from_e < 0) + return NULL; + + for (i = from_b; i <= from_e; i++) { + portmap->from = htons(i); + portmap->to = htons(to_l); + portmap->next = new_portmap(); + portmap_last = portmap; + portmap = portmap->next; + } + portmap_last = NULL; + free(portmap); + } + /* process a list via +, filling in list[] */ + else if (strchr(from_s, '+')) { + from_begin = strtok_r(from_s, "+", &token2); + from_l = strtol(from_begin, &badchar, 10); + if (strlen(badchar) != 0) + return NULL; + portmap->to = htons(to_l); + portmap->from = htons(from_l); + + while ((from_begin = strtok_r(NULL, "+", &token2)) != NULL) { + from_l = strtol(from_begin, &badchar, 10); + if (strlen(badchar) != 0) + return NULL; + if (from_l > 65535 || from_l < 0) + return NULL; + portmap->next = new_portmap(); + portmap = portmap->next; + portmap->to = htons(to_l); + portmap->from = htons(from_l); + } + } + /* this is just the old port:port format */ + else { + /* + * convert the strings to longs: if badchar points to anything + * after, then it was a bad string + */ + from_l = strtol(from_s, &badchar, 10); + if (strlen(badchar) != 0) + return NULL; + if (from_l > 65535 || from_l < 0) + return NULL; + portmap->to = htons(to_l); + portmap->from = htons(from_l); + } + + /* return 1 for success */ + return portmap_head; +} + +/** + * Processes a string (ourstr) containing the portmap ("2000:4000" for + * example) and places the data in **portmapdata and finally returns 1 for + * success, 0 for fail. + */ +int +parse_portmap(tcpedit_portmap_t ** portmap, const char *ourstr) +{ + tcpedit_portmap_t *portmap_ptr; + char *substr = NULL, *ourstrcpy = NULL, *token = NULL; + + assert(ourstr); + ourstrcpy = safe_strdup(ourstr); + + /* first iteration of input */ + substr = strtok_r(ourstrcpy, ",", &token); + + if ((*portmap = ports2PORT(substr)) == NULL) + return 0; + + portmap_ptr = *portmap; + + /* ports2PORT may return a chain, so find the end of it */ + while (portmap_ptr->next != NULL) + portmap_ptr = portmap_ptr->next; + + while (1) { + substr = strtok_r(NULL, ",", &token); + /* if that was the last one, kick out */ + if (substr == NULL) + break; + + /* process next record */ + portmap_ptr->next = ports2PORT(substr); + + /* ports2PORT may return a chain, so find the end of it */ + while (portmap_ptr->next != NULL) + portmap_ptr = portmap_ptr->next; + } + + return 1; +} + + +/** + * Free's all the memory associated with the given portmap chain + */ +void +free_portmap(tcpedit_portmap_t * portmap) +{ + + assert(portmap); + + /* recursively go down the portmaps */ + if (portmap->next != NULL) + free_portmap(portmap->next); + + safe_free(portmap); +} + + +/** + * This function takes a pointer to a portmap list and prints each node + */ +void +print_portmap(tcpedit_portmap_t *portmap_data) +{ + tcpedit_portmap_t *portmap_ptr; + + assert(portmap_data); + portmap_ptr = portmap_data; + while (portmap_ptr != NULL) { + printf("from: %ld to: %ld\n", portmap_ptr->from, portmap_ptr->to); + portmap_ptr = portmap_ptr->next; + } + + printf("\n"); +} + + +/** + * This function takes a portmap and a port, and returns the mapped port, + * or the original port if it isn't mapped to anything. + */ +long +map_port(tcpedit_portmap_t *portmap_data, long port) +{ + tcpedit_portmap_t *portmap_ptr; + long newport; + + assert(portmap_data); + + portmap_ptr = portmap_data; + newport = port; + + /* step through the nodes, resetting newport if a match is found */ + while (portmap_ptr != NULL) { + if (portmap_ptr->from == port) + newport = portmap_ptr->to; + + portmap_ptr = portmap_ptr->next; + } + + return(newport); +} + +/** + * rewrites the TCP or UDP ports based on a portmap + * returns 1 for changes made or 0 for none + */ + +static int +rewrite_ports(tcpedit_t *tcpedit, u_char protocol, u_char *layer4) +{ + tcp_hdr_t *tcp_hdr = NULL; + udp_hdr_t *udp_hdr = NULL; + int changes = 0; + u_int16_t newport; + tcpedit_portmap_t *portmap; + + assert(tcpedit); + assert(tcpedit->portmap); + portmap = tcpedit->portmap; + + if (protocol == IPPROTO_TCP) { + tcp_hdr = (tcp_hdr_t *)layer4; + + /* check if we need to remap the destination port */ + newport = map_port(portmap, tcp_hdr->th_dport); + if (newport != tcp_hdr->th_dport) { + tcp_hdr->th_dport = newport; + changes ++; + } + + /* check if we need to remap the source port */ + newport = map_port(portmap, tcp_hdr->th_sport); + if (newport != tcp_hdr->th_sport) { + tcp_hdr->th_sport = newport; + changes ++; + } + + } else if (protocol == IPPROTO_UDP) { + udp_hdr = (udp_hdr_t *)layer4; + + /* check if we need to remap the destination port */ + newport = map_port(portmap, udp_hdr->uh_dport); + if (newport != udp_hdr->uh_dport) { + udp_hdr->uh_dport = newport; + changes ++; + } + + /* check if we need to remap the source port */ + newport = map_port(portmap, udp_hdr->uh_sport); + if (newport != udp_hdr->uh_sport) { + udp_hdr->uh_sport = newport; + changes ++; + } + + } + return changes; +} + +int +rewrite_ipv4_ports(tcpedit_t *tcpedit, ipv4_hdr_t **ip_hdr) +{ + assert(tcpedit); + + if (*ip_hdr == NULL) { + return 0; + } else if ((*ip_hdr)->ip_p == IPPROTO_TCP || (*ip_hdr)->ip_p == IPPROTO_UDP) { + return rewrite_ports(tcpedit, (*ip_hdr)->ip_p, get_layer4_v4(*ip_hdr)); + } + + return 0; +} + +int +rewrite_ipv6_ports(tcpedit_t *tcpedit, ipv6_hdr_t **ip6_hdr) +{ + assert(tcpedit); + + if (*ip6_hdr == NULL) { + return 0; + } else if ((*ip6_hdr)->ip_nh == IPPROTO_TCP || (*ip6_hdr)->ip_nh == IPPROTO_UDP) { + return rewrite_ports(tcpedit, (*ip6_hdr)->ip_nh, ((u_char*)*ip6_hdr) + TCPR_IPV6_H); + } + return 0; +} + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + diff --git a/src/tcpedit/portmap.h b/src/tcpedit/portmap.h new file mode 100644 index 0000000..cb2b528 --- /dev/null +++ b/src/tcpedit/portmap.h @@ -0,0 +1,54 @@ +/* $Id: portmap.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#ifndef __PORTMAP_H__ +#define __PORTMAP_H__ + +tcpedit_portmap_t *new_portmap(); +int parse_portmap(tcpedit_portmap_t **portmapdata, const char *ourstr); +void free_portmap(tcpedit_portmap_t *portmap); +void print_portmap(tcpedit_portmap_t *portmap); +long map_port(tcpedit_portmap_t *portmap , long port); +int rewrite_ipv4_ports(tcpedit_t *tcpedit, ipv4_hdr_t **ip_hdr); +int rewrite_ipv6_ports(tcpedit_t *tcpedit, ipv6_hdr_t **ip_hdr); + +#endif + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + diff --git a/src/tcpedit/tcpedit-int.h b/src/tcpedit/tcpedit-int.h new file mode 100644 index 0000000..ccc21d2 --- /dev/null +++ b/src/tcpedit/tcpedit-int.h @@ -0,0 +1,147 @@ +/* $Id: tcpedit-int.h 2429 2010-03-27 00:24:25Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "defines.h" +#include "common.h" +#include "tcpedit.h" +#include "plugins/dlt_plugins-int.h" + +#ifndef _TCPEDIT_INT_H_ +#define _TCPEDIT_INT_H_ + +#define TCPEDIT_ERRSTR_LEN 1024 +struct tcpedit_runtime_s { + COUNTER packetnum; + COUNTER total_bytes; + COUNTER pkts_edited; + int dlt1; + int dlt2; + char errstr[TCPEDIT_ERRSTR_LEN]; + char warnstr[TCPEDIT_ERRSTR_LEN]; +#ifdef FORCE_ALIGN + u_char *l3buff; +#endif +}; + +typedef struct tcpedit_runtime_s tcpedit_runtime_t; + +/* + * portmap data struct + */ +struct tcpedit_portmap_s { + long from; + long to; + struct tcpedit_portmap_s *next; +}; +typedef struct tcpedit_portmap_s tcpedit_portmap_t; + + +/* + * all the arguments that the packet editing library supports + */ +struct tcpedit_s { + int validated; /* have we run tcpedit_validate()? */ + struct tcpeditdlt_s *dlt_ctx; + + /* runtime variables, don't mess with these */ + tcpedit_runtime_t runtime; + + /* skip rewriting IP/MAC's which are broadcast or multicast? */ + int skip_broadcast; + + /* rewrite traffic bi-directionally */ + int bidir; +#define TCPEDIT_BIDIR_OFF 0x0 +#define TCPEDIT_BIDIR_ON 0x1 + + /* pad or truncate packets */ + int fixlen; +#define TCPEDIT_FIXLEN_OFF 0x0 +#define TCPEDIT_FIXLEN_PAD 0x1 +#define TCPEDIT_FIXLEN_TRUNC 0x2 +#define TCPEDIT_FIXLEN_DEL 0x3 + + /* rewrite ip? */ + int rewrite_ip; +#define TCPEDIT_REWRITE_IP_OFF 0x0 +#define TCPEDIT_REWRITE_IP_ON 0x1 + + /* fix IP/TCP/UDP checksums */ + u_int8_t fixcsum; +#define TCPEDIT_FIXCSUM_OFF 0x0 +#define TCPEDIT_FIXCSUM_ON 0x1 + + /* remove ethernet FCS */ + u_int8_t efcs; +#define TCPEDIT_EFCS_OFF 0x0 +#define TCPEDIT_EFCS_ON 0x1 + + u_int8_t ttl_mode; +#define TCPEDIT_TTL_OFF 0x0 +#define TCPEDIT_TTL_SET 0x1 +#define TCPEDIT_TTL_ADD 0x2 +#define TCPEDIT_TTL_SUB 0x3 + u_int8_t ttl_value; + + /* TOS/DiffServ/ECN, -1 is disabled, else copy value */ + int tos; + + /* IPv6 FlowLabel, -1 is disabled, else copy value */ + int flowlabel; + + /* IPv6 TClass, -1 is disabled, else copy value */ + int tclass; + + /* rewrite end-point IP addresses between cidrmap1 & cidrmap2 */ + tcpr_cidrmap_t *cidrmap1; /* tcpprep cache data */ + tcpr_cidrmap_t *cidrmap2; + + /* src & dst IP mapping */ + tcpr_cidrmap_t *srcipmap; + tcpr_cidrmap_t *dstipmap; + + /* pseudo-randomize IP addresses using a seed */ + int seed; + + /* rewrite tcp/udp ports */ + tcpedit_portmap_t *portmap; + + int mtu; /* Deal with different MTU's */ + int mtu_truncate; /* Should frames > MTU be truncated? */ +}; + +#define tcpedit_seterr(x, y, ...) __tcpedit_seterr(x, __FUNCTION__, __LINE__, __FILE__, y, __VA_ARGS__) + +void __tcpedit_seterr(tcpedit_t *tcpedit, const char *func, const int line, const char *file, const char *fmt, ...); +void tcpedit_setwarn(tcpedit_t *tcpedit, const char *fmt, ...); + +#endif diff --git a/src/tcpedit/tcpedit.c b/src/tcpedit/tcpedit.c new file mode 100644 index 0000000..d7612c5 --- /dev/null +++ b/src/tcpedit/tcpedit.c @@ -0,0 +1,556 @@ +/* $Id: tcpedit.c 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "defines.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "tcpedit-int.h" +#include "tcpedit_stub.h" +#include "portmap.h" +#include "common.h" +#include "edit_packet.h" +#include "parse_args.h" +#include "plugins/dlt_plugins.h" + + +#include "lib/sll.h" +#include "dlt.h" + +tOptDesc *const tcpedit_tcpedit_optDesc_p; + +/** + * \brief Edit the given packet + * + * Processs a given packet and edit the pkthdr/pktdata structures + * according to the rules in tcpedit + * Returns: TCPEDIT_ERROR on error + * TCPEDIT_SOFT_ERROR on remove packet + * 0 on no change + * 1 on change + */ +int +tcpedit_packet(tcpedit_t *tcpedit, struct pcap_pkthdr **pkthdr, + u_char **pktdata, tcpr_dir_t direction) +{ + ipv4_hdr_t *ip_hdr = NULL; + ipv6_hdr_t *ip6_hdr = NULL; + arp_hdr_t *arp_hdr = NULL; + int l2len = 0, l2proto, retval = 0, dst_dlt, src_dlt, pktlen, lendiff; + int ipflags = 0, tclass = 0; + int needtorecalc = 0; /* did the packet change? if so, checksum */ + u_char *packet = *pktdata; + assert(tcpedit); + assert(pkthdr); + assert(*pkthdr); + assert(pktdata); + assert(packet); + assert(tcpedit->validated); + + + tcpedit->runtime.packetnum++; + dbgx(3, "packet " COUNTER_SPEC " caplen %d", + tcpedit->runtime.packetnum, (*pkthdr)->caplen); + + /* + * remove the Ethernet FCS (checksum)? + * note that this feature requires the end user to be smart and + * only set this flag IFF the pcap has the FCS. If not, then they + * just removed 2 bytes of ACTUAL PACKET DATA. Sucks to be them. + */ + if (tcpedit->efcs > 0) { + (*pkthdr)->caplen -= 4; + (*pkthdr)->len -= 4; + } + + src_dlt = tcpedit_dlt_src(tcpedit->dlt_ctx); + + /* not everything has a L3 header, so check for errors. returns proto in network byte order */ + if ((l2proto = tcpedit_dlt_proto(tcpedit->dlt_ctx, src_dlt, packet, (*pkthdr)->caplen)) < 0) { + dbg(2, "Packet has no L3+ header"); + } else { + dbgx(2, "Layer 3 protocol type is: 0x%04x", ntohs(l2proto)); + } + + /* rewrite Layer 2 */ + if ((pktlen = tcpedit_dlt_process(tcpedit->dlt_ctx, pktdata, (*pkthdr)->caplen, direction)) == TCPEDIT_ERROR) + errx(-1, "%s", tcpedit_geterr(tcpedit)); + + /* unable to edit packet, most likely 802.11 management or data QoS frame */ + if (pktlen == TCPEDIT_SOFT_ERROR) { + dbgx(3, "%s", tcpedit_geterr(tcpedit)); + return TCPEDIT_SOFT_ERROR; + } + + /* update our packet lengths (real/captured) based on L2 length changes */ + lendiff = pktlen - (*pkthdr)->caplen; + (*pkthdr)->caplen += lendiff; + (*pkthdr)->len += lendiff; + + dst_dlt = tcpedit_dlt_dst(tcpedit->dlt_ctx); + l2len = tcpedit_dlt_l2len(tcpedit->dlt_ctx, dst_dlt, packet, (*pkthdr)->caplen); + + dbgx(2, "dst_dlt = %04x\tsrc_dlt = %04x\tproto = %04x\tl2len = %d", dst_dlt, src_dlt, ntohs(l2proto), l2len); + + /* does packet have an IP header? if so set our pointer to it */ + if (l2proto == htons(ETHERTYPE_IP)) { + ip_hdr = (ipv4_hdr_t *)tcpedit_dlt_l3data(tcpedit->dlt_ctx, src_dlt, packet, (*pkthdr)->caplen); + if (ip_hdr == NULL) { + return TCPEDIT_ERROR; + } + dbgx(3, "Packet has an IPv4 header: %p...", ip_hdr); + } else if (l2proto == htons(ETHERTYPE_IP6)) { + ip6_hdr = (ipv6_hdr_t *)tcpedit_dlt_l3data(tcpedit->dlt_ctx, src_dlt, packet, (*pkthdr)->caplen); + if (ip6_hdr == NULL) { + return TCPEDIT_ERROR; + } + dbgx(3, "Packet has an IPv6 header: %p...", ip6_hdr); + } else { + dbgx(3, "Packet isn't IPv4 or IPv6: 0x%04x", l2proto); + /* non-IP packets have a NULL ip_hdr struct */ + ip_hdr = NULL; + } + + /* The following edits only apply for IPv4 */ + if (ip_hdr != NULL) { + + /* set TOS ? */ + if (tcpedit->tos > -1) + ip_hdr->ip_tos = tcpedit->tos; + + /* rewrite the TTL */ + needtorecalc += rewrite_ipv4_ttl(tcpedit, ip_hdr); + + /* rewrite TCP/UDP ports */ + if (tcpedit->portmap != NULL) { + if ((retval = rewrite_ipv4_ports(tcpedit, &ip_hdr)) < 0) + return TCPEDIT_ERROR; + needtorecalc += retval; + } + } + /* IPv6 edits */ + else if (ip6_hdr != NULL) { + /* rewrite the hop limit */ + needtorecalc += rewrite_ipv6_hlim(tcpedit, ip6_hdr); + + /* set traffic class? */ + if (tcpedit->tclass > -1) { + /* calculate the bits */ + tclass = tcpedit->tclass << 20; + + /* convert our 4 bytes to an int */ + memcpy(&ipflags, &ip6_hdr->ip_flags, 4); + + /* strip out the old tclass bits */ + ipflags = ntohl(ipflags) & 0xf00fffff; + + /* add the tclass bits back */ + ipflags += tclass; + ipflags = htonl(ipflags); + memcpy(&ip6_hdr->ip_flags, &ipflags, 4); + } + + /* set the flow label? */ + if (tcpedit->flowlabel > -1) { + memcpy(&ipflags, &ip6_hdr->ip_flags, 4); + ipflags = ntohl(ipflags) & 0xfff00000; + ipflags += tcpedit->flowlabel; + ipflags = htonl(ipflags); + memcpy(&ip6_hdr->ip_flags, &ipflags, 4); + } + + /* rewrite TCP/UDP ports */ + if (tcpedit->portmap != NULL) { + if ((retval = rewrite_ipv6_ports(tcpedit, &ip6_hdr)) < 0) + return TCPEDIT_ERROR; + needtorecalc += retval; + } + } + + /* (Un)truncate or MTU truncate packet? */ + if (tcpedit->fixlen || tcpedit->mtu_truncate) { + if ((retval = untrunc_packet(tcpedit, *pkthdr, packet, ip_hdr, ip6_hdr)) < 0) + return TCPEDIT_ERROR; + needtorecalc += retval; + } + + /* rewrite IP addresses in IPv4/IPv6 or ARP */ + if (tcpedit->rewrite_ip) { + /* IP packets */ + if (ip_hdr != NULL) { + if ((retval = rewrite_ipv4l3(tcpedit, ip_hdr, direction)) < 0) + return TCPEDIT_ERROR; + needtorecalc += retval; + } else if (ip6_hdr != NULL) { + if ((retval = rewrite_ipv6l3(tcpedit, ip6_hdr, direction)) < 0) + return TCPEDIT_ERROR; + needtorecalc += retval; + } + + /* ARP packets */ + else if (l2proto == htons(ETHERTYPE_ARP)) { + arp_hdr = (arp_hdr_t *)&(packet[l2len]); + /* unlike, rewrite_ipl3, we don't care if the packet changed + * because we never need to recalc the checksums for an ARP + * packet. So ignore the return value + */ + if (rewrite_iparp(tcpedit, arp_hdr, direction) < 0) + return TCPEDIT_ERROR; + } + } + + + /* do we need to spoof the src/dst IP address in IPv4 or ARP? */ + if (tcpedit->seed) { + /* IPv4 Packets */ + if (ip_hdr != NULL) { + if ((retval = randomize_ipv4(tcpedit, *pkthdr, packet, + ip_hdr)) < 0) + return TCPEDIT_ERROR; + needtorecalc += retval; + + } else if (ip6_hdr != NULL) { + if ((retval = randomize_ipv6(tcpedit, *pkthdr, packet, + ip6_hdr)) < 0) + return TCPEDIT_ERROR; + needtorecalc += retval; + + /* ARP packets */ + } else if (l2proto == htons(ETHERTYPE_ARP)) { + if (direction == TCPR_DIR_C2S) { + if (randomize_iparp(tcpedit, *pkthdr, packet, + tcpedit->runtime.dlt1) < 0) + return TCPEDIT_ERROR; + } else { + if (randomize_iparp(tcpedit, *pkthdr, packet, + tcpedit->runtime.dlt2) < 0) + return TCPEDIT_ERROR; + } + } + } + + /* do we need to fix checksums? -- must always do this last! */ + if ((tcpedit->fixcsum || needtorecalc)) { + if (ip_hdr != NULL) { + retval = fix_ipv4_checksums(tcpedit, *pkthdr, ip_hdr); + } else if (ip6_hdr != NULL) { + retval = fix_ipv6_checksums(tcpedit, *pkthdr, ip6_hdr); + } else { + retval = TCPEDIT_OK; + } + if (retval < 0) { + return TCPEDIT_ERROR; + } else if (retval == TCPEDIT_WARN) { + warnx("%s", tcpedit_getwarn(tcpedit)); + } + } + + tcpedit_dlt_merge_l3data(tcpedit->dlt_ctx, dst_dlt, packet, (*pkthdr)->caplen, (u_char *)ip_hdr); + + tcpedit->runtime.total_bytes += (*pkthdr)->caplen; + tcpedit->runtime.pkts_edited ++; + return retval; +} + +/** + * initializes the tcpedit library. returns 0 on success, -1 on error. + */ +int +tcpedit_init(tcpedit_t **tcpedit_ex, int dlt) +{ + tcpedit_t *tcpedit; + + *tcpedit_ex = safe_malloc(sizeof(tcpedit_t)); + tcpedit = *tcpedit_ex; + + if ((tcpedit->dlt_ctx = tcpedit_dlt_init(tcpedit, dlt)) == NULL) + return TCPEDIT_ERROR; + + tcpedit->mtu = DEFAULT_MTU; /* assume 802.3 Ethernet */ + + /* disabled by default */ + tcpedit->tos = -1; + tcpedit->tclass = -1; + tcpedit->flowlabel = -1; + + memset(&(tcpedit->runtime), 0, sizeof(tcpedit_runtime_t)); + tcpedit->runtime.dlt1 = dlt; + tcpedit->runtime.dlt2 = dlt; + + dbgx(1, "Input file (1) datalink type is %s\n", + pcap_datalink_val_to_name(dlt)); + +#ifdef FORCE_ALIGN + tcpedit->runtime.l3buff = (u_char *)safe_malloc(MAXPACKET); +#endif + + return TCPEDIT_OK; +} + +/** + * return the output DLT type + */ +int +tcpedit_get_output_dlt(tcpedit_t *tcpedit) +{ + assert(tcpedit); + return tcpedit_dlt_output_dlt(tcpedit->dlt_ctx); +} + +/** + * \brief tcpedit option validator. Call after tcpedit_init() + * + * Validates that given the current state of tcpedit that the given + * pcap source and destination (based on DLT) can be properly rewritten + * return 0 on sucess + * return -1 on error + * DO NOT USE! + */ +int +tcpedit_validate(tcpedit_t *tcpedit) +{ + assert(tcpedit); + tcpedit->validated = 1; + + /* we used to do a bunch of things here, but not anymore... + * maybe I should find something to do or just get ride of it + */ + return 0; +} + +/** + * return the error string when a tcpedit() function returns + * TCPEDIT_ERROR + */ +char * +tcpedit_geterr(tcpedit_t *tcpedit) +{ + + assert(tcpedit); + return tcpedit->runtime.errstr; + +} + +/** + * \brief Internal function to set the tcpedit error string + * + * Used to set the error string when there is an error, result is retrieved + * using tcpedit_geterr(). You shouldn't ever actually call this, but use + * tcpedit_seterr() which is a macro wrapping this instead. + */ +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]; + + assert(tcpedit); + + va_start(ap, fmt); + if (fmt != NULL) { + (void)vsnprintf(errormsg, + (TCPEDIT_ERRSTR_LEN - 1), fmt, ap); + } + + va_end(ap); + + snprintf(tcpedit->runtime.errstr, (TCPEDIT_ERRSTR_LEN -1), "From %s:%s() line %d:\n%s", + file, func, line, errormsg); +} + +/** + * return the warning string when a tcpedit() function returns + * TCPEDIT_WARN + */ +char * +tcpedit_getwarn(tcpedit_t *tcpedit) +{ + assert(tcpedit); + + return tcpedit->runtime.warnstr; +} + +/** + * used to set the warning string when there is an warning + */ +void +tcpedit_setwarn(tcpedit_t *tcpedit, const char *fmt, ...) +{ + va_list ap; + assert(tcpedit); + + va_start(ap, fmt); + if (fmt != NULL) + (void)vsnprintf(tcpedit->runtime.warnstr, (TCPEDIT_ERRSTR_LEN - 1), fmt, ap); + + va_end(ap); + +} + +/** + * \brief Checks the given error code and does the right thing + * + * Generic function which checks the TCPEDIT_* error code + * and always returns OK or ERROR. For warnings, prints the + * warning message and returns OK. For any other value, fails with + * an assert. + * + * prefix is a string prepended to the error/warning + */ +int +tcpedit_checkerror(tcpedit_t *tcpedit, const int rcode, const char *prefix) { + assert(tcpedit); + + switch (rcode) { + case TCPEDIT_OK: + case TCPEDIT_ERROR: + return rcode; + break; + + case TCPEDIT_SOFT_ERROR: + if (prefix != NULL) { + fprintf(stderr, "Error %s: %s\n", prefix, tcpedit_geterr(tcpedit)); + } else { + fprintf(stderr, "Error: %s\n", tcpedit_geterr(tcpedit)); + } + break; + case TCPEDIT_WARN: + if (prefix != NULL) { + fprintf(stderr, "Warning %s: %s\n", prefix, tcpedit_getwarn(tcpedit)); + } else { + fprintf(stderr, "Warning: %s\n", tcpedit_getwarn(tcpedit)); + } + return TCPEDIT_OK; + break; + + default: + assert(0 == 1); /* this should never happen! */ + break; + } + return TCPEDIT_ERROR; +} + +/** + * \brief Cleans up after ourselves. Return 0 on success. + * + * Clean up after ourselves, but does not actually free the ptr. + */ +int +tcpedit_close(tcpedit_t *tcpedit) +{ + + assert(tcpedit); + dbgx(1, "tcpedit processed " COUNTER_SPEC " bytes in " COUNTER_SPEC + " packets.\n", tcpedit->runtime.total_bytes, + tcpedit->runtime.pkts_edited); + + /* free buffer if required */ +#ifdef FORCE_ALIGN + safe_free(tcpedit->runtime.l3buff); +#endif + + return 0; +} + +/** + * Return a ptr to the Layer 3 data. Returns TCPEDIT_ERROR on error + */ +const u_char * +tcpedit_l3data(tcpedit_t *tcpedit, tcpedit_coder_t code, u_char *packet, const int pktlen) +{ + u_char *result = NULL; + if (code == BEFORE_PROCESS) { + result = tcpedit_dlt_l3data(tcpedit->dlt_ctx, tcpedit->dlt_ctx->decoder->dlt, packet, pktlen); + } else { + result = tcpedit_dlt_l3data(tcpedit->dlt_ctx, tcpedit->dlt_ctx->encoder->dlt, packet, pktlen); + } + return result; +} + +/** + * return the length of the layer 2 header. Returns TCPEDIT_ERROR on error + */ +int +tcpedit_l2len(tcpedit_t *tcpedit, tcpedit_coder_t code, u_char *packet, const int pktlen) +{ + int result = 0; + if (code == BEFORE_PROCESS) { + result = tcpedit_dlt_l2len(tcpedit->dlt_ctx, tcpedit->dlt_ctx->decoder->dlt, packet, pktlen); + } else { + result = tcpedit_dlt_l2len(tcpedit->dlt_ctx, tcpedit->dlt_ctx->encoder->dlt, packet, pktlen); + } + return result; +} + +/** + * Returns the layer 3 type, often encoded as the layer2.proto field + */ +int +tcpedit_l3proto(tcpedit_t *tcpedit, tcpedit_coder_t code, const u_char *packet, const int pktlen) +{ + int result = 0; + if (code == BEFORE_PROCESS) { + result = tcpedit_dlt_proto(tcpedit->dlt_ctx, tcpedit->dlt_ctx->decoder->dlt, packet, pktlen); + } else { + result = tcpedit_dlt_proto(tcpedit->dlt_ctx, tcpedit->dlt_ctx->encoder->dlt, packet, pktlen); + } + return ntohs(result); +} + +/* +u_char * +tcpedit_srcmac(tcpedit_t *tcpedit, tcpedit_coder_t code, u_char *packet, const int pktlen) +{ + +} + +u_char * +tcpedit_dstmac(tcpedit_t *tcpedit, tcpedit_coder_t code, u_char *packet, const int pktlen) +{ + +} + +int +tcpedit_maclen(tcpedit_t *tcpedit, tcpedit_coder_t code) +{ + +} + +*/ diff --git a/src/tcpedit/tcpedit.h b/src/tcpedit/tcpedit.h new file mode 100644 index 0000000..cada0c0 --- /dev/null +++ b/src/tcpedit/tcpedit.h @@ -0,0 +1,85 @@ +/* $Id: tcpedit.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "defines.h" +#include "common.h" +#include "parse_args.h" + +#ifndef _TCPEDIT_H_ +#define _TCPEDIT_H_ + +#define TCPEDIT_SOFT_ERROR -2 +#define TCPEDIT_ERROR -1 +#define TCPEDIT_OK 0 +#define TCPEDIT_WARN 1 + +typedef struct tcpedit_s tcpedit_t; + +int tcpedit_init(tcpedit_t **tcpedit_ex, int dlt); +char *tcpedit_geterr(tcpedit_t *tcpedit); +char *tcpedit_getwarn(tcpedit_t *tcpedit); + +int tcpedit_checkerror(tcpedit_t *tcpedit, const int rcode, const char *prefix); +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_get_output_dlt(tcpedit_t *tcpedit); + +enum tcpedit_coder_s { + BEFORE_PROCESS, + AFTER_PROCESS +}; +typedef enum tcpedit_coder_s tcpedit_coder_t; + +/* + * semi-direct packet access methods. Use when you're not using tcpedit_packet() + * all these methods either return NULL or a TCPEDIT_(SOFT_)ERROR code on error + */ +int tcpedit_l2len(tcpedit_t *tcpedit, tcpedit_coder_t code, u_char *packet, const int pktlen); + +/* on strictly aligned systems, this may return a pointer to a temporary static buffer */ +const u_char *tcpedit_l3data(tcpedit_t *tcpedit, tcpedit_coder_t code, u_char *packet, const int pktlen); + +int tcpedit_l3proto(tcpedit_t *tcpedit, tcpedit_coder_t code, const u_char *packet, const int pktlen); + +// u_char *tcpedit_srcmac(tcpedit_t *tcpedit, tcpedit_coder_t code, u_char *packet, const int pktlen); +// u_char *tcpedit_dstmac(tcpedit_t *tcpedit, tcpedit_coder_t code, u_char *packet, const int pktlen); +// int tcpedit_maclen(tcpedit_t *tcpedit, tcpedit_coder_t code); + +COUNTER tcpedit_get_total_bytes(tcpedit_t *tcpedit); +COUNTER tcpedit_get_pkts_edited(tcpedit_t *tcpedit); + +#endif + diff --git a/src/tcpedit/tcpedit_opts.def b/src/tcpedit/tcpedit_opts.def new file mode 100644 index 0000000..9d82d54 --- /dev/null +++ b/src/tcpedit/tcpedit_opts.def @@ -0,0 +1,255 @@ +flag = { + name = tcpedit; + documentation; + lib-name = tcpedit; +}; + +flag = { + name = portmap; + value = r; + arg-type = string; + max = -1; + stack-arg; + descrip = "Rewrite TCP/UDP ports"; + doc = <<- EOText +Specify a list of comma delimited port mappingings consisting of +colon delimited port number pairs. Each colon delimited port pair +consists of the port to match followed by the port number to rewrite. + +Examples: +@example +--portmap=80:8000 --portmap=8080:80 # 80->8000 and 8080->80 +--portmap=8000,8080,88888:80 # 3 different ports become 80 +--portmap=8000-8999:80 # ports 8000 to 8999 become 80 +@end example +EOText; +}; + +flag = { + name = seed; + value = s; + arg-type = number; + descrip = "Randomize src/dst IPv4/v6 addresses w/ given seed"; + max = 1; + doc = <<- EOText +Causes the source and destination IPv4/v6 addresses to be pseudo +randomized but still maintain client/server relationships. +Since the randomization is deterministic based on the seed, +you can reuse the same seed value to recreate the traffic. +EOText; +}; + +flag = { + name = pnat; + value = N; + arg-type = string; + max = 2; + stack-arg; + flags-cant = srcipmap; + flass-cant = dstipmap; + descrip = "Rewrite IPv4/v6 addresses using pseudo-NAT"; + doc = <<- EOText +Takes a comma delimited series of colon delimited CIDR +netblock pairs. Each netblock pair is evaluated in order against +the IP addresses. If the IP address in the packet matches the +first netblock, it is rewriten using the second netblock as a +mask against the high order bits. + +IPv4 Example: +@example +--pnat=192.168.0.0/16:10.77.0.0/16,172.16.0.0/12:10.1.0.0/24 +@end example +IPv6 Example: +@example +--pnat=[2001:db8::/32]:[dead::/16],[2001:db8::/32]:[::ffff:0:0/96] +@end example +EOText; +}; + +flag = { + name = srcipmap; + value = S; + arg-type = string; + max = 1; + flags-cant = pnat; + descrip = "Rewrite source IPv4/v6 addresses using pseudo-NAT"; + doc = <<- EOText +Works just like the --pnat option, but only affects the source IP +addresses in the IPv4/v6 header. +EOText; +}; + +flag = { + name = dstipmap; + value = D; + arg-type = string; + max = 1; + flags-cant = pnat; + descrip = "Rewrite destination IPv4/v6 addresses using pseudo-NAT"; + doc = <<- EOText +Works just like the --pnat option, but only affects the destination IP +addresses in the IPv4/v6 header. +EOText; +}; + + +flag = { + ifdef = HAVE_CACHEFILE_SUPPORT; + name = endpoints; + value = e; + arg-type = string; + max = 1; + flags-must = cachefile; + descrip = "Rewrite IP addresses to be between two endpoints"; + doc = <<- EOText +Takes a pair of colon delimited IPv4/v6 addresses which will be used to rewrite +all traffic to appear to be between the two IP's. + +IPv4 Example: +@example +--endpoints=172.16.0.1:172.16.0.2 +@end example +IPv6 Example: +@example +--endpoints=[2001:db8::dead:beef]:[::ffff:0:0:ac:f:0:2] +@end example + +EOText; +}; + +flag = { + name = skipbroadcast; + value = b; + descrip = "Skip rewriting broadcast/multicast IPv4/v6 addresses"; + doc = <<- EOText +By default --seed, --pnat and --endpoints will rewrite +broadcast and multicast IPv4/v6 and MAC addresses. Setting this flag +will keep broadcast/multicast IPv4/v6 and MAC addresses from being rewritten. +EOText; +}; + +flag = { + name = fixcsum; + value = C; + descrip = "Force recalculation of IPv4/TCP/UDP header checksums"; + doc = <<- EOText +Causes each IPv4/v6 packet to have it's checksums recalcualted and +fixed. Automatically enabled for packets modified with @samp{--seed}, +@samp{--pnat}, @samp{--endpoints} or @samp{--fixlen}. +EOText; +}; + +flag = { + name = mtu; + value = m; + arg-type = number; + max = 1; + arg-range = "1->MAXPACKET"; + default = DEFAULT_MTU; + descrip = "Override default MTU length (1500 bytes)"; + doc = <<- EOText +Override the default 1500 byte MTU size for determining the maximum padding length +(--fixlen=pad) or when truncating (--mtu-trunc). +EOText; +}; + +flag = { + name = mtu-trunc; + max = 1; + descrip = "Truncate packets larger then specified MTU"; + doc = <<- EOText +Similar to --fixlen, this option will truncate data in packets from Layer 3 and above to be +no larger then the MTU. +EOText; +}; + +flag = { + name = efcs; + value = E; + descrip = "Remove Ethernet checksums (FCS) from end of frames"; + doc = <<- EOText +Note, this option is pretty dangerous! We don't actually check to see if a FCS +actually exists in the frame, we just blindly delete the last two bytes. Hence, +you should only use this if you know know that your OS provides the FCS when +reading raw packets. +EOText; +}; + +flag = { + name = ttl; + descrip = "Modify the IPv4/v6 TTL/Hop Limit"; + arg-type = string; + doc = <<- EOText +Allows you to modify the TTL/Hop Limit of all the IPv4/v6 packets. Specify a number to hard-code +the value or +/-value to increase or decrease by the value provided (limited to 1-255). + +Examples: +@example +--ttl=10 +--ttl=+7 +--ttl=-64 +@end example +EOText; +}; + +flag = { + name = tos; + descrip = "Set the IPv4 TOS/DiffServ/ECN byte"; + arg-type = number; + arg-range = "0->255"; + max = 1; + doc = <<- EOText +Allows you to override the TOS (also known as DiffServ/ECN) value in IPv4. +EOText; +}; + +flag = { + name = tclass; + descrip = "Set the IPv6 Traffic Class byte"; + arg-type = number; + arg-range = "0->255"; + max = 1; + doc = <<- EOText +Allows you to override the IPv6 Traffic Class field. +EOText; +}; + +flag = { + name = flowlabel; + descrip = "Set the IPv6 Flow Label"; + arg-type = number; + arg-range = "0->1048575"; + max = 1; + doc = <<- EOText +Allows you to override the 20bit IPv6 Flow Label field. Has no effect on IPv4 +packets. +EOText; +}; + +flag = { + name = fixlen; + value = F; + arg-type = string; + descrip = "Pad or truncate packet data to match header length"; + max = 1; + doc = <<- EOText +Packets may be truncated during capture if the snaplen is smaller then the +packet. This option allows you to modify the packet to pad the packet back +out to the size stored in the IPv4/v6 header or rewrite the IP header total length +to reflect the stored packet length. +@table @bullet +@item +@var{pad} +Truncated packets will be padded out so that the packet length matches the +IPv4 total length +@item +@var{trunc} +Truncated packets will have their IPv4 total length field rewritten to match +the actual packet length +@item +@var{del} +Delete the packet +EOText; +}; + +#include plugins/dlt_stub.def diff --git a/src/tcpedit/tcpedit_stub.def b/src/tcpedit/tcpedit_stub.def new file mode 100644 index 0000000..7a29f49 --- /dev/null +++ b/src/tcpedit/tcpedit_stub.def @@ -0,0 +1,6 @@ +AutoGen definitions options; +prog-name = tcpedit_stub; // but is always required +prog-title = 'libtcpedit autoopts stub'; // also required +long-opts; +#include tcpedit_opts.def +library; diff --git a/src/tcpedit/tcpedit_stub.h b/src/tcpedit/tcpedit_stub.h new file mode 100644 index 0000000..a732a0c --- /dev/null +++ b/src/tcpedit/tcpedit_stub.h @@ -0,0 +1,140 @@ +/* -*- buffer-read-only: t -*- vi: set ro: + * + * DO NOT EDIT THIS FILE (tcpedit_stub.h) + * + * It has been AutoGen-ed April 4, 2010 at 05:59:20 PM by AutoGen 5.9.9 + * From the definitions tcpedit_stub.def + * and the template file options + * + * Generated from AutoOpts 32:2:7 templates. + */ + +/* + * This file was produced by an AutoOpts template. AutoOpts is a + * copyrighted work. This header file is not encumbered by AutoOpts + * licensing, but is provided under the licensing terms chosen by the + * tcpedit_stub author or copyright holder. AutoOpts is licensed under + * the terms of the LGPL. The redistributable library (``libopts'') is + * licensed under the terms of either the LGPL or, at the users discretion, + * the BSD license. See the AutoOpts and/or libopts sources for details. + */ +/* + * This file contains the programmatic interface to the Automated + * Options generated for the tcpedit_stub program. + * These macros are documented in the AutoGen info file in the + * "AutoOpts" chapter. Please refer to that doc for usage help. + */ +#ifndef AUTOOPTS_TCPEDIT_STUB_H_GUARD +#define AUTOOPTS_TCPEDIT_STUB_H_GUARD 1 +#include + +/* + * Enumeration of each option: + */ +typedef enum { + INDEX_OPT_PORTMAP = 1, + INDEX_OPT_SEED = 2, + INDEX_OPT_PNAT = 3, + INDEX_OPT_SRCIPMAP = 4, + INDEX_OPT_DSTIPMAP = 5, + INDEX_OPT_ENDPOINTS = 6, + INDEX_OPT_SKIPBROADCAST = 7, + INDEX_OPT_FIXCSUM = 8, + INDEX_OPT_MTU = 9, + INDEX_OPT_MTU_TRUNC = 10, + INDEX_OPT_EFCS = 11, + INDEX_OPT_TTL = 12, + INDEX_OPT_TOS = 13, + INDEX_OPT_TCLASS = 14, + INDEX_OPT_FLOWLABEL = 15, + INDEX_OPT_FIXLEN = 16, + INDEX_OPT_SKIPL2BROADCAST = 17, + INDEX_OPT_DLT = 18, + INDEX_OPT_ENET_DMAC = 19, + INDEX_OPT_ENET_SMAC = 20, + INDEX_OPT_ENET_VLAN = 21, + INDEX_OPT_ENET_VLAN_TAG = 22, + INDEX_OPT_ENET_VLAN_CFI = 23, + INDEX_OPT_ENET_VLAN_PRI = 24, + INDEX_OPT_HDLC_CONTROL = 25, + INDEX_OPT_HDLC_ADDRESS = 26, + INDEX_OPT_USER_DLT = 27, + INDEX_OPT_USER_DLINK = 28, + LIBRARY_OPTION_COUNT +} teOptIndex; + +#define OPTION_CT 29 + +/* + * Interface defines for all options. Replace "n" with the UPPER_CASED + * option name (as in the teOptIndex enumeration above). + * e.g. HAVE_OPT( TCPEDIT ) + */ +extern tOptDesc * const tcpedit_tcpedit_optDesc_p; +#define DESC(n) (tcpedit_tcpedit_optDesc_p[INDEX_OPT_## n]) +#define HAVE_OPT(n) (! UNUSED_OPT(& DESC(n))) +#define OPT_ARG(n) (DESC(n).optArg.argString) +#define STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK) +#define COUNT_OPT(n) (DESC(n).optOccCt) +#define ISSEL_OPT(n) (SELECTED_OPT(&DESC(n))) +#define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n))) +#define ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n))) +#define STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt) +#define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs) +#define CLEAR_OPT(n) STMTS( \ + DESC(n).fOptState &= OPTST_PERSISTENT_MASK; \ + if ( (DESC(n).fOptState & OPTST_INITENABLED) == 0) \ + DESC(n).fOptState |= OPTST_DISABLED; \ + DESC(n).optCookie = NULL ) + +/* * * * * * + * + * Interface defines for specific options. + */ +#define VALUE_OPT_PORTMAP 'r' +#define VALUE_OPT_SEED 's' +#define OPT_VALUE_SEED (DESC(SEED).optArg.argInt) +#define VALUE_OPT_PNAT 'N' +#define VALUE_OPT_SRCIPMAP 'S' +#define VALUE_OPT_DSTIPMAP 'D' +#ifdef HAVE_CACHEFILE_SUPPORT +#define VALUE_OPT_ENDPOINTS 'e' +#endif /* HAVE_CACHEFILE_SUPPORT */ +#define VALUE_OPT_SKIPBROADCAST 'b' +#define VALUE_OPT_FIXCSUM 'C' +#define VALUE_OPT_MTU 'm' +#define OPT_VALUE_MTU (DESC(MTU).optArg.argInt) +#define VALUE_OPT_MTU_TRUNC 10 +#define VALUE_OPT_EFCS 'E' +#define VALUE_OPT_TTL 12 +#define VALUE_OPT_TOS 13 +#define OPT_VALUE_TOS (DESC(TOS).optArg.argInt) +#define VALUE_OPT_TCLASS 14 +#define OPT_VALUE_TCLASS (DESC(TCLASS).optArg.argInt) +#define VALUE_OPT_FLOWLABEL 15 +#define OPT_VALUE_FLOWLABEL (DESC(FLOWLABEL).optArg.argInt) +#define VALUE_OPT_FIXLEN 'F' +#define VALUE_OPT_SKIPL2BROADCAST 17 +#define VALUE_OPT_DLT 18 +#define VALUE_OPT_ENET_DMAC 19 +#define VALUE_OPT_ENET_SMAC 20 +#define VALUE_OPT_ENET_VLAN 21 +#define VALUE_OPT_ENET_VLAN_TAG 22 +#define OPT_VALUE_ENET_VLAN_TAG (DESC(ENET_VLAN_TAG).optArg.argInt) +#define VALUE_OPT_ENET_VLAN_CFI 23 +#define OPT_VALUE_ENET_VLAN_CFI (DESC(ENET_VLAN_CFI).optArg.argInt) +#define VALUE_OPT_ENET_VLAN_PRI 24 +#define OPT_VALUE_ENET_VLAN_PRI (DESC(ENET_VLAN_PRI).optArg.argInt) +#define VALUE_OPT_HDLC_CONTROL 25 +#define OPT_VALUE_HDLC_CONTROL (DESC(HDLC_CONTROL).optArg.argInt) +#define VALUE_OPT_HDLC_ADDRESS 26 +#define OPT_VALUE_HDLC_ADDRESS (DESC(HDLC_ADDRESS).optArg.argInt) +#define VALUE_OPT_USER_DLT 27 +#define OPT_VALUE_USER_DLT (DESC(USER_DLT).optArg.argInt) +#define VALUE_OPT_USER_DLINK 28 +#define VALUE_OPT_HELP '?' +#define VALUE_OPT_MORE_HELP '!' +/* extracted from /usr/local/share/autogen/opthead.tpl near line 409 */ + +#endif /* AUTOOPTS_TCPEDIT_STUB_H_GUARD */ +/* tcpedit_stub.h ends here */ diff --git a/src/tcpprep.1 b/src/tcpprep.1 new file mode 100644 index 0000000..c2f4de0 --- /dev/null +++ b/src/tcpprep.1 @@ -0,0 +1,403 @@ +.TH TCPPREP 1 2010-04-04 "(tcpprep )" "Programmer's Manual" +.\" DO NOT EDIT THIS FILE (tcpprep.1) +.\" +.\" It has been AutoGen-ed April 4, 2010 at 05:59:19 PM by AutoGen 5.9.9 +.\" From the definitions tcpprep_opts.def +.\" and the template file agman1.tpl +.\" +.SH NAME +tcpprep \- Create a tcpreplay cache cache file from a pcap file. +.SH SYNOPSIS +.B tcpprep +.\" Mixture of short (flag) options and long options +.RB [ \-\fIflag\fP " [\fIvalue\fP]]... [" \--\fIopt-name\fP " [[=| ]\fIvalue\fP]]..." +.PP +All arguments must be options. +.PP +tcpprep is a \fIpcap(3)\fP file pre-processor which creates a cache +file which provides "rules" for \fItcprewrite(1)\fP and \fItcpreplay(1)\fP +on how to process and send packets. +.SH "DESCRIPTION" +This manual page briefly documents the \fBtcpprep\fP command. +The basic operation of tcpreplay is to resend all packets from the +input file(s) out a single file. Tcpprep processes a pcap file and +applies a set of user-specified rules to create a cache file which +tells tcpreplay wether or not to send each packet and which interface the +packet should be sent out of. + +For more details, please see the Tcpreplay Manual at: +http://tcpreplay.synfin.net/trac/wiki/manual +.SH OPTIONS +.TP +.BR \-d " \fInumber\fP, " \--dbug "=" \fInumber\fP +Enable debugging output. +This option may appear up to 1 times. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 5 +.fi +.in -4 +The default \fInumber\fP for this option is: +.ti +4 + 0 +.sp +If configured with \--enable-debug, then you can specify a verbosity +level for debugging output. Higher numbers increase verbosity. +.TP +.BR \-a " \fIstring\fP, " \--auto "=" \fIstring\fP +Auto-split mode. +This option may appear up to 1 times. +This option must not appear in combination with any of the following options: +cidr, port, regex, mac. +.sp +Tcpprep will try to automatically determine the primary function of hosts +based on the traffic captured and classify each host as client or server. +In order to do so, you must provide a hint to tcpprep as to how to search +for clients and servers. Valid hints are: + +.sp 1 +\fBbridge\fP +Bridge mode processes each packet to try to determine if the sender is a +client or server. Once all the packets are processed, the results are weighed +according to the server/client ratio (\fB--ratio\fP) and systems are assigned an +interface. If tcpprep is unable to determine what role a system plays, tcpprep +will abort. +.sp 1 +\fBrouter\fP +Router mode works just like bridge mode, except that after weighing is done, +systems which are undetermined are considered a server if they fall inside a +network known to contain other servers. Router has a greater chance of +successfully splitting clients and servers but is not 100% foolproof. +.sp 1 +\fBclient\fP +Client mode works just like bridge mode, except that unclassified systems are +treated as clients. Client mode should always complete successfully. +.sp 1 +\fBserver\fP +Server mode works just like bridge mode, except that unclassified systems are +treated as servers. Server mode should always complete successfully. +.sp 1 +\fBfirst\fP +First mode works by looking at the first time each IP is seen in the SRC and DST +fields in the IP header. If the host is first seen in the SRC field, it is a +client and if it's first seen in the DST field, it is marked as a server. This +effectively replicates the processing of the tomahawk test tool. First +mode should always complete successfully. +.br +.TP +.BR \-c " \fIstring\fP, " \--cidr "=" \fIstring\fP +CIDR-split mode. +This option may appear up to 1 times. +This option must not appear in combination with any of the following options: +auto, port, regex, mac. +.sp +Specify a comma delimited list of CIDR netblocks to match against +the source IP of each packet. Packets matching any of the CIDR's +are classified as servers. + +IPv4 Example: +.nf + \--cidr=192.168.0.0/16,172.16.0.0/12,10.0.0.0/8 +.fi +IPv6 Example: +.nf + \--cidr=[::ffff:0:0/96],[fe80::/16] +.fi +.TP +.BR \-r " \fIstring\fP, " \--regex "=" \fIstring\fP +Regex-split mode. +This option may appear up to 1 times. +This option must not appear in combination with any of the following options: +auto, port, cidr, mac. +.sp +Specify a regular expression to match against the source IP of each +packet. Packets matching the regex are classified as servers. +.TP +.BR \-p ", " \--port +Port-split mode. +This option may appear up to 1 times. +This option must not appear in combination with any of the following options: +auto, regex, cidr, mac. +.sp +Specifies that TCP and UDP traffic over IPv4 and IPv6 should be classified +as client or server based upon the destination port of the header. +.TP +.BR \-e " \fIstring\fP, " \--mac "=" \fIstring\fP +Source MAC split mode. +This option may appear up to 1 times. +This option must not appear in combination with any of the following options: +auto, regex, cidr, port. +.sp +Specify a list of MAC addresses to match against the source MAC +of each packet. Packets matching one of the values are classified +as servers. +.TP +.BR \--reverse +Matches to be client instead of server. +This option may appear up to 1 times. +.sp +Normally the \fB--mac\fP, \fB--regex\fP and \fB--cidr\fP flags specify are used to specify +the servers and non-IP packets are classified as clients. By using \fB--reverse\fP, these +features are reversed so that the flags specify clients and non-IP packets are classified as +servers. +.TP +.BR \-C " \fIstring\fP, " \--comment "=" \fIstring\fP +Embeded cache file comment. +This option may appear up to 1 times. +.sp +Specify a comment to be imbedded within the output cache file and later +viewed. +.TP +.BR \--no-arg-comment +Do not embed any cache file comment. +This option may appear up to 1 times. +.sp +By default, tcpprep includes the arguments passed on the command line +in the cache file comment (in addition to any user specified \--comment). +If for some reason you do not wish to include this, specify this option. +.TP +.BR \-x " \fIstring\fP, " \--include "=" \fIstring\fP +Include only packets matching rule. +This option may appear up to 1 times. +This option must not appear in combination with any of the following options: +exclude. +.sp +Override default of processing all packets stored in the capture file and only +send/edit packets which match the provided rule. Rules can be one of: + +.sp +.IR "S:,..." +- Source IP must match specified IPv4/v6 CIDR(s) +.sp +.IR "D:,..." +- Destination IP must match specified IPv4/v6 CIDR(s) +.sp +.IR "B:,..." +- Both source and destination IP must match specified IPv4/v6 CIDR(s) +.sp +.IR "E:,..." +- Either IP must match specified IPv4/v6 CIDR(s) +.sp +.IR "P:" +- Must be one of the listed packets where the list +corresponds to the packet number in the capture file. +.nf + \-x P:1-5,9,15,72- +.fi +would process packets 1 thru 5, the 9th and 15th packet, and packets 72 until the +end of the file +.sp +.IR "F:''" +- BPF filter. See the \fItcpdump(8)\fP man page for syntax. +.br +.TP +.BR \-X " \fIstring\fP, " \--exclude "=" \fIstring\fP +Exclude any packet matching this rule. +This option may appear up to 1 times. +This option must not appear in combination with any of the following options: +include. +.sp +Override default of processing all packets stored in the capture file and only +send/edit packets which do NOT match the provided rule. Rules can be one of: + +.sp +.IR "S:,..." +- Source IP must not match specified IPv4/v6 CIDR(s) +.sp +.IR "D:,..." +- Destination IP must not match specified IPv4/v6 CIDR(s) +.sp +.IR "B:,..." +- Both source and destination IP must not match specified IPv4/v6 CIDR(s) +.sp +.IR "E:,..." +- Either IP must not match specified IPv4/v6 CIDR(s) +.sp +.IR "P:" +- Must not be one of the listed packets where the list +corresponds to the packet number in the capture file. +.nf + \-x P:1-5,9,15,72- +.fi +would skip packets 1 thru 5, the 9th and 15th packet, and packets 72 until the +end of the file +.br +.TP +.BR \-o " \fIstring\fP, " \--cachefile "=" \fIstring\fP +Output cache file. +This option may appear up to 1 times. +.sp + +.TP +.BR \-i " \fIstring\fP, " \--pcap "=" \fIstring\fP +Input pcap file to process. +This option may appear up to 1 times. +.sp + +.TP +.BR \-P " \fIstring\fP, " \--print-comment "=" \fIstring\fP +Print embedded comment in the specified cache file. +This option may appear up to 1 times. +.sp + +.TP +.BR \-I " \fIstring\fP, " \--print-info "=" \fIstring\fP +Print basic info from the specified cache file. +This option may appear up to 1 times. +.sp + +.TP +.BR \-S " \fIstring\fP, " \--print-stats "=" \fIstring\fP +Print statistical information about the specified cache file. +This option may appear up to 1 times. +.sp + +.TP +.BR \-s " \fIstring\fP, " \--services "=" \fIstring\fP +Load services file for server ports. +This option may appear up to 1 times. +This option must appear in combination with the following options: +port. +.sp +Uses a list of ports used by servers in the same format as of /etc/services: + / # comment + +Example: +http 80/tcp +.TP +.BR \-N ", " \--nonip +Send non-IP traffic out server interface. +This option may appear up to 1 times. +.sp +By default, non-IP traffic which can not be classified as client +or server is classified as "client". Specifiying \fB--nonip\fP +will reclassify non-IP traffic as "server". Note that the meaning +of this flag is reversed if \fB--reverse\fP is used. +.TP +.BR \-R " \fIstring\fP, " \--ratio "=" \fIstring\fP +Ratio of client to server packets. +This option may appear up to 1 times. +This option must appear in combination with the following options: +auto. +The default \fIstring\fP for this option is: +.ti +4 + 2.0 +.sp +Since a given host may have both client and server traffic being sent +to/from it, tcpprep uses a ratio to weigh these packets. If you would +like to override the default of 2:1 server to client packets required for +a host to be classified as a server, specify it as a floating point value. +.TP +.BR \-m " \fInumber\fP, " \--minmask "=" \fInumber\fP +Minimum network mask length in auto mode. +This option may appear up to 1 times. +This option must appear in combination with the following options: +auto. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 32 +.fi +.in -4 +The default \fInumber\fP for this option is: +.ti +4 + 30 +.sp +By default, auto modes use a minimum network mask length of 30 bits +to build networks containing clients and servers. This allows you +to override this value. Larger values will increase performance but +may provide inaccurate results. +.TP +.BR \-M " \fInumber\fP, " \--maxmask "=" \fInumber\fP +Maximum network mask length in auto mode. +This option may appear up to 1 times. +This option must appear in combination with the following options: +auto. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 32 +.fi +.in -4 +The default \fInumber\fP for this option is: +.ti +4 + 8 +.sp +By default, auto modes use a maximum network mask length of 8 bits +to build networks containing clients and servers. This allows you +to override this value. Larger values will decrease performance +and accuracy but will provide greater chance of success. +.TP +.BR \-v ", " \--verbose +Print decoded packets via tcpdump to STDOUT. +This option may appear up to 1 times. +.sp + +.TP +.BR \-A " \fIstring\fP, " \--decode "=" \fIstring\fP +Arguments passed to tcpdump decoder. +This option may appear up to 1 times. +This option must appear in combination with the following options: +verbose. +.sp +When enabling verbose mode (\fB-v\fP) you may also specify one or +more additional arguments to pass to \fBtcpdump\fP to modify +the way packets are decoded. By default, \-n and \-l are used. +Be sure to quote the arguments so that they are not interpreted +by tcprewrite. The following arguments are valid: + [ \-aAeNqRStuvxX ] + [ \-E spi@ipaddr algo:secret,... ] + [ \-s snaplen ] +.TP +.BR \-V ", " \--version +Print version information. +.sp + +.TP +.BR \-h ", " \--less-help +Display less usage information and exit. +.sp +This option has not been fully documented. +.TP +.BR \-H , " \--help" +Display usage information and exit. +.TP +.BR \-! , " \--more-help" +Extended usage information passed thru pager. +.TP +.BR \- " [\fIrcfile\fP]," " \--save-opts" "[=\fIrcfile\fP]" +Save the option state to \fIrcfile\fP. The default is the \fIlast\fP +configuration file listed in the \fBOPTION PRESETS\fP section, below. +.TP +.BR \- " \fIrcfile\fP," " \--load-opts" "=\fIrcfile\fP," " \--no-load-opts" +Load options from \fIrcfile\fP. +The \fIno-load-opts\fP form will disable the loading +of earlier RC/INI files. \fI--no-load-opts\fP is handled early, +out of order. +.SH OPTION PRESETS +Any option that is not marked as \fInot presettable\fP may be preset +by loading values from configuration ("RC" or ".INI") file(s). +The \fIhomerc\fP file is "\fI$$/\fP", unless that is a directory. +In that case, the file "\fI.tcppreprc\fP" +is searched for within that directory. +.SH "SEE ALSO" +tcpdump(1), tcprewrite(1), tcpreplay(1) +.SH AUTHOR +Copyright 2000-2010 Aaron Turner + +For support please use the tcpreplay-users@lists.sourceforge.net mailing list. + +The latest version of this software is always available from: +http://tcpreplay.synfin.net/ +.PP +Released under the Free BSD License. +.PP +This manual page was \fIAutoGen\fP-erated from the \fBtcpprep\fP +option definitions. diff --git a/src/tcpprep.c b/src/tcpprep.c new file mode 100644 index 0000000..0834312 --- /dev/null +++ b/src/tcpprep.c @@ -0,0 +1,787 @@ +/* $Id: tcpprep.c 2427 2010-03-25 00:38:13Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Purpose: + * 1) Remove the performance bottleneck in tcpreplay for choosing an NIC + * 2) Seperate code to make it more manageable + * 3) Add addtional features which require multiple passes of a pcap + * + * Support: + * Right now we support matching source IP based upon on of the following: + * - Regular expression + * - IP address is contained in one of a list of CIDR blocks + * - Auto learning of CIDR block for servers (clients all other) + */ + +#include "config.h" +#include "defines.h" +#include "common.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "tcpprep.h" +#include "tcpedit/tcpedit.h" +#include "tcpprep_opts.h" +#include "lib/tree.h" +#include "tree.h" +#include "lib/sll.h" +#include "lib/strlcpy.h" + +/* + * global variables + */ +#ifdef DEBUG +int debug = 0; +#endif + +#ifdef ENABLE_VERBOSE +tcpdump_t tcpdump; +#endif + +tcpprep_opt_t options; +int info = 0; +char *ourregex = NULL; +char *cidr = NULL; +tcpr_data_tree_t treeroot; + +static void init(void); +static void post_args(int, char *[]); +static void print_comment(const char *); +static void print_info(const char *); +static void print_stats(const char *); +static int check_ipv4_regex(const unsigned long ip); +static int check_ipv6_regex(const struct tcpr_in6_addr *addr); +static COUNTER process_raw_packets(pcap_t * pcap); +static int check_dst_port(ipv4_hdr_t *ip_hdr, ipv6_hdr_t *ip6_hdr, int len); + + +/* + * main() + */ +int +main(int argc, char *argv[]) +{ + int out_file; + COUNTER totpackets = 0; + char errbuf[PCAP_ERRBUF_SIZE]; + int optct = 0; + + init(); /* init our globals */ + + optct = optionProcess(&tcpprepOptions, argc, argv); + post_args(argc, argv); + + argc -= optct; + argv += optct; + + /* open the cache file */ + if ((out_file = open(OPT_ARG(CACHEFILE), O_WRONLY | O_CREAT | O_TRUNC, + S_IREAD | S_IWRITE | S_IRGRP | S_IWGRP | S_IROTH)) == -1) + errx(-1, "Unable to open cache file %s for writing: %s", + OPT_ARG(CACHEFILE), strerror(errno)); + + readpcap: + /* open the pcap file */ + if ((options.pcap = pcap_open_offline(OPT_ARG(PCAP), errbuf)) == NULL) + errx(-1, "Error opening file: %s", errbuf); + +#ifdef HAVE_PCAP_SNAPSHOT + if (pcap_snapshot(options.pcap) < 65535) + warnx("%s was captured using a snaplen of %d bytes. This may mean you have truncated packets.", + OPT_ARG(PCAP), pcap_snapshot(options.pcap)); +#endif + + /* make sure we support the DLT type */ + switch(pcap_datalink(options.pcap)) { + case DLT_EN10MB: + case DLT_LINUX_SLL: + case DLT_RAW: + case DLT_C_HDLC: + break; /* do nothing because all is good */ + default: + errx(-1, "Unsupported pcap DLT type: 0x%x", pcap_datalink(options.pcap)); + } + + /* Can only split based on MAC address for ethernet */ + if ((pcap_datalink(options.pcap) != DLT_EN10MB) && + (options.mode == MAC_MODE)) { + err(-1, "MAC mode splitting is only supported by DLT_EN10MB packet captures."); + } + +#ifdef ENABLE_VERBOSE + if (HAVE_OPT(VERBOSE)) { + tcpdump_open(&tcpdump, options.pcap); + } +#endif + + /* do we apply a bpf filter? */ + if (options.bpf.filter != NULL) { + if (pcap_compile(options.pcap, &options.bpf.program, options.bpf.filter, + options.bpf.optimize, 0) != 0) { + errx(-1, "Error compiling BPF filter: %s", pcap_geterr(options.pcap)); + } + pcap_setfilter(options.pcap, &options.bpf.program); + } + + if ((totpackets = process_raw_packets(options.pcap)) == 0) { + pcap_close(options.pcap); + err(-1, "No packets were processed. Filter too limiting?"); + } + pcap_close(options.pcap); + +#ifdef ENABLE_VERBOSE + tcpdump_close(&tcpdump); +#endif + + /* we need to process the pcap file twice in HASH/AUTO mode */ + if (options.mode == AUTO_MODE) { + options.mode = options.automode; + if (options.mode == ROUTER_MODE) { /* do we need to convert TREE->CIDR? */ + if (info) + notice("Building network list from pre-cache...\n"); + if (!process_tree()) { + err(-1, "Error: unable to build a valid list of servers. Aborting."); + } + } + else { + /* + * in bridge mode we need to calculate client/sever + * manually since this is done automatically in + * process_tree() + */ + tree_calculate(&treeroot); + } + + if (info) + notice("Buliding cache file...\n"); + /* + * re-process files, but this time generate + * cache + */ + goto readpcap; + } +#ifdef DEBUG + if (debug && (options.cidrdata != NULL)) + print_cidr(options.cidrdata); +#endif + + /* write cache data */ + totpackets = write_cache(options.cachedata, out_file, totpackets, + options.comment); + if (info) + notice("Done.\nCached " COUNTER_SPEC " packets.\n", totpackets); + + /* close cache file */ + close(out_file); + return 0; + +} + + +/** + * checks the dst port to see if this is destined for a server port. + * returns 1 for true, 0 for false + */ +static int +check_dst_port(ipv4_hdr_t *ip_hdr, ipv6_hdr_t *ip6_hdr, int len) +{ + tcp_hdr_t *tcp_hdr = NULL; + udp_hdr_t *udp_hdr = NULL; + u_char proto; + u_char *l4; + + if (ip_hdr) { + if (len < ((ip_hdr->ip_hl * 4) + 4)) + return 0; /* not enough data in the packet to know */ + + proto = ip_hdr->ip_p; + l4 = get_layer4_v4(ip_hdr); + } else if (ip6_hdr) { + if (len < (TCPR_IPV6_H + 4)) + return 0; /* not enough data in the packet to know */ + + proto = get_ipv6_l4proto(ip6_hdr); + dbgx(3, "Our layer4 proto is 0x%hhu", proto); + l4 = get_layer4_v6(ip6_hdr); + + dbgx(3, "Found proto %u at offset %p. base %p (%ld)", proto, (void *)l4, (void *)ip6_hdr, (l4 - (u_char *)ip6_hdr)); + } else { + assert(0); + } + + dbg(3, "Checking the destination port..."); + + if (proto == IPPROTO_TCP) { + tcp_hdr = (tcp_hdr_t *)l4; + + /* is a service? */ + if (options.services.tcp[ntohs(tcp_hdr->th_dport)]) { + dbgx(1, "TCP packet is destined for a server port: %d", ntohs(tcp_hdr->th_dport)); + return 1; + } + + /* nope */ + dbgx(1, "TCP packet is NOT destined for a server port: %d", ntohs(tcp_hdr->th_dport)); + return 0; + } else if (proto == IPPROTO_UDP) { + udp_hdr = (udp_hdr_t *)l4; + + /* is a service? */ + if (options.services.udp[ntohs(udp_hdr->uh_dport)]) { + dbgx(1, "UDP packet is destined for a server port: %d", ntohs(udp_hdr->uh_dport)); + return 1; + } + + /* nope */ + dbgx(1, "UDP packet is NOT destined for a server port: %d", ntohs(udp_hdr->uh_dport)); + return 0; + } + + + /* not a TCP or UDP packet... return as non_ip */ + dbg(1, "Packet isn't a UDP or TCP packet... no port to process."); + return options.nonip; +} + + +/** + * checks to see if an ip address matches a regex. Returns 1 for true + * 0 for false + */ +static int +check_ipv4_regex(const unsigned long ip) +{ + int eflags = 0; + u_char src_ip[16]; + size_t nmatch = 0; + regmatch_t *pmatch = NULL; + + memset(src_ip, '\0', 16); + strlcpy((char *)src_ip, (char *)get_addr2name4(ip, RESOLVE), + sizeof(src_ip)); + if (regexec(&options.preg, (char *)src_ip, nmatch, pmatch, eflags) == 0) { + return 1; + } else { + return 0; + } + +} + +static int +check_ipv6_regex(const struct tcpr_in6_addr *addr) +{ + int eflags = 0; + u_char src_ip[INET6_ADDRSTRLEN]; + size_t nmatch = 0; + regmatch_t *pmatch = NULL; + + memset(src_ip, '\0', 16); + strlcpy((char *)src_ip, (char *)get_addr2name6(addr, RESOLVE), sizeof(src_ip)); + if (regexec(&options.preg, (char *)src_ip, nmatch, pmatch, eflags) == 0) { + return 1; + } else { + return 0; + } +} + +/** + * uses libpcap library to parse the packets and build + * the cache file. + */ +static COUNTER +process_raw_packets(pcap_t * pcap) +{ + ipv4_hdr_t *ip_hdr = NULL; + ipv6_hdr_t *ip6_hdr = NULL; + eth_hdr_t *eth_hdr = NULL; + struct pcap_pkthdr pkthdr; + const u_char *pktdata = NULL; + COUNTER packetnum = 0; + int l2len, cache_result = 0; + u_char ipbuff[MAXPACKET], *buffptr; + tcpr_dir_t direction; + +#ifdef ENABLE_VERBOSE + struct pollfd poller[1]; + + poller[0].fd = tcpdump.outfd; + poller[0].events = POLLIN; + poller[0].revents = 0; +#endif + + assert(pcap); + + while ((pktdata = pcap_next(pcap, &pkthdr)) != NULL) { + packetnum++; + + dbgx(1, "Packet " COUNTER_SPEC, packetnum); + + /* look for include or exclude LIST match */ + if (options.xX.list != NULL) { + if (options.xX.mode < xXExclude) { + if (!check_list(options.xX.list, packetnum)) { + add_cache(&(options.cachedata), DONT_SEND, 0); + continue; + } + } + else if (check_list(options.xX.list, packetnum)) { + add_cache(&(options.cachedata), DONT_SEND, 0); + continue; + } + } + + /* + * If the packet doesn't include an IPv4 header we should just treat + * it as a non-IP packet, UNLESS we're in MAC mode, in which case + * we should let the MAC matcher below handle it + */ + + eth_hdr = (eth_hdr_t *)pktdata; + + if (options.mode != MAC_MODE) { + dbg(3, "Looking for IPv4/v6 header in non-MAC mode"); + + /* get the IP header (if any) */ + buffptr = ipbuff; + + /* first look for IPv4 */ + if ((ip_hdr = (ipv4_hdr_t *)get_ipv4(pktdata, pkthdr.caplen, + pcap_datalink(pcap), &buffptr))) { + dbg(2, "Packet is IPv4"); + + } + + /* then look for IPv6 */ + else if ((ip6_hdr = (ipv6_hdr_t *)get_ipv6(pktdata, pkthdr.caplen, + pcap_datalink(pcap), &buffptr))) { + dbg(2, "Packet is IPv6"); + } + + /* we're something else... */ + else { + dbg(2, "Packet isn't IPv4/v6"); + + /* we don't want to cache these packets twice */ + if (options.mode != AUTO_MODE) { + dbg(3, "Adding to cache using options for Non-IP packets"); + add_cache(&options.cachedata, SEND, options.nonip); + } + + /* go to next packet */ + continue; + } + + l2len = get_l2len(pktdata, pkthdr.caplen, pcap_datalink(pcap)); + + /* look for include or exclude CIDR match */ + if (options.xX.cidr != NULL) { + if (ip_hdr) { + if (!process_xX_by_cidr_ipv4(options.xX.mode, options.xX.cidr, ip_hdr)) { + add_cache(&options.cachedata, DONT_SEND, 0); + continue; + } + } else if (ip6_hdr) { + if (!process_xX_by_cidr_ipv6(options.xX.mode, options.xX.cidr, ip6_hdr)) { + add_cache(&options.cachedata, DONT_SEND, 0); + continue; + } + } + } + } + + switch (options.mode) { + case REGEX_MODE: + dbg(2, "processing regex mode..."); + if (ip_hdr) { + direction = check_ipv4_regex(ip_hdr->ip_src.s_addr); + } else if (ip6_hdr) { + direction = check_ipv6_regex(&ip6_hdr->ip_src); + } + + /* reverse direction? */ + if (HAVE_OPT(REVERSE) && (direction == TCPR_DIR_C2S || direction == TCPR_DIR_S2C)) + direction = direction == TCPR_DIR_C2S ? TCPR_DIR_S2C : TCPR_DIR_C2S; + + cache_result = add_cache(&options.cachedata, SEND, direction); + break; + + case CIDR_MODE: + dbg(2, "processing cidr mode..."); + if (ip_hdr) { + direction = check_ip_cidr(options.cidrdata, ip_hdr->ip_src.s_addr) ? TCPR_DIR_C2S : TCPR_DIR_S2C; + } else if (ip6_hdr) { + direction = check_ip6_cidr(options.cidrdata, &ip6_hdr->ip_src) ? TCPR_DIR_C2S : TCPR_DIR_S2C; + } + + /* reverse direction? */ + if (HAVE_OPT(REVERSE) && (direction == TCPR_DIR_C2S || direction == TCPR_DIR_S2C)) + direction = direction == TCPR_DIR_C2S ? TCPR_DIR_S2C : TCPR_DIR_C2S; + + cache_result = add_cache(&options.cachedata, SEND, direction); + break; + + case MAC_MODE: + dbg(2, "processing mac mode..."); + direction = macinstring(options.maclist, (u_char *)eth_hdr->ether_shost); + + /* reverse direction? */ + if (HAVE_OPT(REVERSE) && (direction == TCPR_DIR_C2S || direction == TCPR_DIR_S2C)) + direction = direction == TCPR_DIR_C2S ? TCPR_DIR_S2C : TCPR_DIR_C2S; + + cache_result = add_cache(&options.cachedata, SEND, direction); + break; + + case AUTO_MODE: + dbg(2, "processing first pass of auto mode..."); + /* first run through in auto mode: create tree */ + if (options.automode != FIRST_MODE) { + if (ip_hdr) { + add_tree_ipv4(ip_hdr->ip_src.s_addr, pktdata); + } else if (ip6_hdr) { + add_tree_ipv6(&ip6_hdr->ip_src, pktdata); + } + } else { + if (ip_hdr) { + add_tree_first_ipv4(pktdata); + } else if (ip6_hdr) { + add_tree_first_ipv6(pktdata); + } + } + break; + + case ROUTER_MODE: + /* + * second run through in auto mode: create route + * based cache + */ + dbg(2, "processing second pass of auto: router mode..."); + if (ip_hdr) { + cache_result = add_cache(&options.cachedata, SEND, + check_ip_tree(options.nonip, ip_hdr->ip_src.s_addr)); + } else { + cache_result = add_cache(&options.cachedata, SEND, + check_ip6_tree(options.nonip, &ip6_hdr->ip_src)); + } + break; + + case BRIDGE_MODE: + /* + * second run through in auto mode: create bridge + * based cache + */ + dbg(2, "processing second pass of auto: bridge mode..."); + if (ip_hdr) { + cache_result = add_cache(&options.cachedata, SEND, + check_ip_tree(DIR_UNKNOWN, ip_hdr->ip_src.s_addr)); + } else { + cache_result = add_cache(&options.cachedata, SEND, + check_ip6_tree(DIR_UNKNOWN, &ip6_hdr->ip_src)); + } + break; + + case SERVER_MODE: + /* + * second run through in auto mode: create bridge + * where unknowns are servers + */ + dbg(2, "processing second pass of auto: server mode..."); + if (ip_hdr) { + cache_result = add_cache(&options.cachedata, SEND, + check_ip_tree(DIR_SERVER, ip_hdr->ip_src.s_addr)); + } else { + cache_result = add_cache(&options.cachedata, SEND, + check_ip6_tree(DIR_SERVER, &ip6_hdr->ip_src)); + } + break; + + case CLIENT_MODE: + /* + * second run through in auto mode: create bridge + * where unknowns are clients + */ + dbg(2, "processing second pass of auto: client mode..."); + if (ip_hdr) { + cache_result = add_cache(&options.cachedata, SEND, + check_ip_tree(DIR_CLIENT, ip_hdr->ip_src.s_addr)); + } else { + cache_result = add_cache(&options.cachedata, SEND, + check_ip6_tree(DIR_CLIENT, &ip6_hdr->ip_src)); + } + break; + + case PORT_MODE: + /* + * process ports based on their destination port + */ + dbg(2, "processing port mode..."); + cache_result = add_cache(&options.cachedata, SEND, + check_dst_port(ip_hdr, ip6_hdr, (pkthdr.caplen - l2len))); + break; + + case FIRST_MODE: + /* + * First packet mode, looks at each host and picks clients + * by the ones which send the first packet in a session + */ + dbg(2, "processing second pass of auto: first packet mode..."); + if (ip_hdr) { + cache_result = add_cache(&options.cachedata, SEND, + check_ip_tree(DIR_UNKNOWN, ip_hdr->ip_src.s_addr)); + } else { + cache_result = add_cache(&options.cachedata, SEND, + check_ip6_tree(DIR_UNKNOWN, &ip6_hdr->ip_src)); + } + break; + + default: + errx(-1, "Whops! What mode are we in anyways? %d", options.mode); + } +#ifdef ENABLE_VERBOSE + if (options.verbose) + tcpdump_print(&tcpdump, &pkthdr, pktdata); +#endif + } + + return packetnum; +} + +/** + * init our options + */ +void +init(void) +{ + int i; + + memset(&options, '\0', sizeof(options)); + options.bpf.optimize = BPF_OPTIMIZE; + + for (i = DEFAULT_LOW_SERVER_PORT; i <= DEFAULT_HIGH_SERVER_PORT; i++) { + options.services.tcp[i] = 1; + options.services.udp[i] = 1; + } + +} + +/** + * post process args + */ +static void +post_args(int argc, char *argv[]) +{ + char myargs[MYARGS_LEN]; + int i, bufsize; + char *tempstr; + + memset(myargs, 0, MYARGS_LEN); + + /* print_comment and print_info don't return */ + if (HAVE_OPT(PRINT_COMMENT)) + print_comment(OPT_ARG(PRINT_COMMENT)); + + if (HAVE_OPT(PRINT_INFO)) + print_info(OPT_ARG(PRINT_INFO)); + + if (HAVE_OPT(PRINT_STATS)) + print_stats(OPT_ARG(PRINT_STATS)); + + if (! HAVE_OPT(CACHEFILE) && ! HAVE_OPT(PCAP)) + err(-1, "Must specify an output cachefile (-o) and input pcap (-i)"); + + if (! options.mode) + err(-1, "Must specify a processing mode: -a, -c, -r, -p"); + +#ifdef DEBUG + if (HAVE_OPT(DBUG)) + debug = OPT_VALUE_DBUG; +#endif + +#ifdef ENABLE_VERBOSE + if (HAVE_OPT(VERBOSE)) { + options.verbose = 1; + } + + if (HAVE_OPT(DECODE)) + tcpdump.args = safe_strdup(OPT_ARG(DECODE)); + + /* + * put the open after decode options so they are passed to tcpdump + */ +#endif + + + /* + * if we are to include the cli args, then prep it for the + * cache file header + */ + if (! options.nocomment) { + /* copy all of our args to myargs */ + for (i = 1; i < argc; i ++) { + /* skip the -C */ + if (strcmp(argv[i], "-C") == 0) { + i += 2; + continue; + } + + strlcat(myargs, argv[i], MYARGS_LEN); + strlcat(myargs, " ", MYARGS_LEN); + } + + /* remove trailing space */ + myargs[strlen(myargs) - 1] = 0; + + dbgx(1, "Comment args length: %zu", strlen(myargs)); + } + + /* setup or options.comment buffer so that that we get args\ncomment */ + if (options.comment != NULL) { + strlcat(myargs, "\n", MYARGS_LEN); + bufsize = strlen(options.comment) + strlen(myargs) + 1; + options.comment = (char *)safe_realloc(options.comment, + bufsize); + + tempstr = strdup(options.comment); + strlcpy(options.comment, myargs, bufsize); + strlcat(options.comment, tempstr, bufsize); + } else { + bufsize = strlen(myargs) + 1; + options.comment = (char *)safe_malloc(bufsize); + strlcpy(options.comment, myargs, bufsize); + } + + dbgx(1, "Final comment length: %zu", strlen(options.comment)); + + /* copy over our min/max mask */ + options.min_mask = OPT_VALUE_MINMASK; + + options.max_mask = OPT_VALUE_MAXMASK; + + if (! options.min_mask > options.max_mask) + errx(-1, "Min network mask len (%d) must be less then max network mask len (%d)", + options.min_mask, options.max_mask); + + options.ratio = atof(OPT_ARG(RATIO)); + if (options.ratio < 0) + err(-1, "Ratio must be a non-negative number."); +} + +/** + * print the tcpprep cache file comment + */ +static void +print_comment(const char *file) +{ + char *cachedata = NULL; + char *comment = NULL; + COUNTER count = 0; + + count = read_cache(&cachedata, file, &comment); + printf("tcpprep args: %s\n", comment); + printf("Cache contains data for " COUNTER_SPEC " packets\n", count); + + exit(0); +} + +/** + * prints out the cache file details + */ +static void +print_info(const char *file) +{ + char *cachedata = NULL; + char *comment = NULL; + COUNTER count = 0, i; + + count = read_cache(&cachedata, file, &comment); + for (i = 1; i <= count; i ++) { + + switch (check_cache(cachedata, i)) { + case TCPR_DIR_C2S: + printf("Packet " COUNTER_SPEC " -> Primary\n", i); + break; + case TCPR_DIR_S2C: + printf("Packet " COUNTER_SPEC " -> Secondary\n", i); + break; + case TCPR_DIR_NOSEND: + printf("Packet " COUNTER_SPEC " -> Don't Send\n", i); + break; + default: + err(-1, "Invalid cachedata value!"); + break; + } + + } + exit(0); +} + +/** + * Print the per-packet statistics + */ +static void +print_stats(const char *file) +{ + char *cachedata = NULL; + char *comment = NULL; + COUNTER count = 0; + COUNTER pri = 0, sec = 0, nosend = 0; + + count = read_cache(&cachedata, file, &comment); + for (COUNTER i = 1; i <= count; i ++) { + int cacheval = check_cache(cachedata, i); + switch (cacheval) { + case TCPR_DIR_C2S: + pri ++; + break; + case TCPR_DIR_S2C: + sec ++; + break; + case TCPR_DIR_NOSEND: + nosend ++; + break; + default: + errx(-1, "Unknown cache value: %d", cacheval); + } + } + printf("Primary packets:\t" COUNTER_SPEC "\n", pri); + printf("Secondary packets:\t" COUNTER_SPEC "\n", sec); + printf("Skipped packets:\t" COUNTER_SPEC "\n", nosend); + printf("------------------------------\n"); + printf("Total packets:\t\t" COUNTER_SPEC "\n", count); + exit(0); +} diff --git a/src/tcpprep.h b/src/tcpprep.h new file mode 100644 index 0000000..ad4cba3 --- /dev/null +++ b/src/tcpprep.h @@ -0,0 +1,85 @@ +/* $Id: tcpprep.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __TCPPREP_H__ +#define __TCPPREP_H__ + +#include "config.h" +#include "defines.h" +#include "common.h" + +#include + + +#ifdef ENABLE_DMALLOC +#include +#endif + + +/* default ports used for servers */ +#define DEFAULT_LOW_SERVER_PORT 0 +#define DEFAULT_HIGH_SERVER_PORT 1023 +#define MYARGS_LEN 1024 + +struct tcpprep_opt_s { + pcap_t *pcap; + int verbose; + char *tcpdump_args; + + tcpr_cache_t *cachedata; + tcpr_cidr_t *cidrdata; + char *maclist; + tcpr_xX_t xX; + tcpr_bpf_t bpf; + tcpr_services_t services; + char *comment; /* cache file comment */ + int nocomment; /* don't include the cli in the comment */ + int mode; /* our overall mode */ + int automode; /* our auto mode */ + int min_mask; + int max_mask; + double ratio; + regex_t preg; + int nonip; +}; +typedef struct tcpprep_opt_s tcpprep_opt_t; + +#endif + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + diff --git a/src/tcpprep_opts.c b/src/tcpprep_opts.c new file mode 100644 index 0000000..38da372 --- /dev/null +++ b/src/tcpprep_opts.c @@ -0,0 +1,1412 @@ +/* -*- buffer-read-only: t -*- vi: set ro: + * + * DO NOT EDIT THIS FILE (tcpprep_opts.c) + * + * It has been AutoGen-ed April 4, 2010 at 05:59:19 PM by AutoGen 5.9.9 + * From the definitions tcpprep_opts.def + * and the template file options + * + * Generated from AutoOpts 32:2:7 templates. + */ + +/* + * This file was produced by an AutoOpts template. AutoOpts is a + * copyrighted work. This source file is not encumbered by AutoOpts + * licensing, but is provided under the licensing terms chosen by the + * tcpprep author or copyright holder. AutoOpts is licensed under + * the terms of the LGPL. The redistributable library (``libopts'') is + * licensed under the terms of either the LGPL or, at the users discretion, + * the BSD license. See the AutoOpts and/or libopts sources for details. + * + * This source file is copyrighted and licensed under the following terms: + * + * tcpprep copyright (c) 2000-2010 Aaron Turner - all rights reserved + * + * tcpprep is free software copyrighted by Aaron Turner. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name ``Aaron Turner'' nor the name of any other + * contributor may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * tcpprep IS PROVIDED BY Aaron Turner ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL Aaron Turner OR ANY OTHER CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +extern FILE * option_usage_fp; +#define OPTION_CODE_COMPILE 1 +#include "tcpprep_opts.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* TRANSLATORS: choose the translation for option names wisely because you + cannot ever change your mind. */ +tSCC zCopyright[] = + "tcpprep copyright (c) 2000-2010 Aaron Turner, all rights reserved"; +tSCC zCopyrightNotice[1454] = +"tcpprep is free software copyrighted by Aaron Turner.\n\n\ +Redistribution and use in source and binary forms, with or without\n\ +modification, are permitted provided that the following conditions are met: 1.\n\ +Redistributions of source code must retain the above copyright notice, this\n\ +list of conditions and the following disclaimer. 2. Redistributions in binary\n\ +form must reproduce the above copyright notice, this list of conditions and the\n\ +following disclaimer in the documentation and/or other materials provided with\n\ +the distribution. 3. Neither the name ``Aaron Turner'' nor the name of any\n\ +other contributor may be used to endorse or promote products derived from this\n\ +software without specific prior written permission.\n\n\ +tcpprep IS PROVIDED BY Aaron Turner ``AS IS'' AND ANY EXPRESS OR IMPLIED\n\ +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n\ +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO\n\ +EVENT SHALL Aaron Turner OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n\ +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\n\ +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n\ +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n\ +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n\ +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\n\ +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."; + +extern tUsageProc optionUsage; + +/* + * global included definitions + */ +#include "defines.h" +#include "common.h" +#include "config.h" +#include "tcpprep.h" +#include +#include +extern tcpprep_opt_t options; + + +#ifndef NULL +# define NULL 0 +#endif +#ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +#endif +#ifndef EXIT_FAILURE +# define EXIT_FAILURE 1 +#endif +/* + * Dbug option description: + */ +#ifdef DEBUG +tSCC zDbugText[] = + "Enable debugging output"; +tSCC zDbug_NAME[] = "DBUG"; +tSCC zDbug_Name[] = "dbug"; +#define zDbugDefaultArg ((char const*)0) +#define DBUG_FLAGS (OPTST_DISABLED | OPTST_IMM \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +#else /* disable Dbug */ +#define VALUE_OPT_DBUG NO_EQUIVALENT +#define DBUG_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zDbugDefaultArg NULL +#define zDbugText NULL +#define zDbug_NAME NULL +#define zDbug_Name NULL +#endif /* DEBUG */ + +/* + * Auto option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zAutoText[] = + "Auto-split mode"; +tSCC zAuto_NAME[] = "AUTO"; +tSCC zAuto_Name[] = "auto"; +static const int + aAutoCantList[] = { + INDEX_OPT_CIDR, + INDEX_OPT_PORT, + INDEX_OPT_REGEX, + INDEX_OPT_MAC, NO_EQUIVALENT }; +#define AUTO_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Cidr option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zCidrText[] = + "CIDR-split mode"; +tSCC zCidr_NAME[] = "CIDR"; +tSCC zCidr_Name[] = "cidr"; +static const int + aCidrCantList[] = { + INDEX_OPT_AUTO, + INDEX_OPT_PORT, + INDEX_OPT_REGEX, + INDEX_OPT_MAC, NO_EQUIVALENT }; +#define CIDR_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Regex option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zRegexText[] = + "Regex-split mode"; +tSCC zRegex_NAME[] = "REGEX"; +tSCC zRegex_Name[] = "regex"; +static const int + aRegexCantList[] = { + INDEX_OPT_AUTO, + INDEX_OPT_PORT, + INDEX_OPT_CIDR, + INDEX_OPT_MAC, NO_EQUIVALENT }; +#define REGEX_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Port option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zPortText[] = + "Port-split mode"; +tSCC zPort_NAME[] = "PORT"; +tSCC zPort_Name[] = "port"; +static const int + aPortCantList[] = { + INDEX_OPT_AUTO, + INDEX_OPT_REGEX, + INDEX_OPT_CIDR, + INDEX_OPT_MAC, NO_EQUIVALENT }; +#define PORT_FLAGS (OPTST_DISABLED) + +/* + * Mac option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zMacText[] = + "Source MAC split mode"; +tSCC zMac_NAME[] = "MAC"; +tSCC zMac_Name[] = "mac"; +static const int + aMacCantList[] = { + INDEX_OPT_AUTO, + INDEX_OPT_REGEX, + INDEX_OPT_CIDR, + INDEX_OPT_PORT, NO_EQUIVALENT }; +#define MAC_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Reverse option description: + */ +tSCC zReverseText[] = + "Matches to be client instead of server"; +tSCC zReverse_NAME[] = "REVERSE"; +tSCC zReverse_Name[] = "reverse"; +#define REVERSE_FLAGS (OPTST_DISABLED) + +/* + * Comment option description: + */ +tSCC zCommentText[] = + "Embeded cache file comment"; +tSCC zComment_NAME[] = "COMMENT"; +tSCC zComment_Name[] = "comment"; +#define COMMENT_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * No_Arg_Comment option description: + */ +tSCC zNo_Arg_CommentText[] = + "Do not embed any cache file comment"; +tSCC zNo_Arg_Comment_NAME[] = "NO_ARG_COMMENT"; +tSCC zNo_Arg_Comment_Name[] = "no-arg-comment"; +#define NO_ARG_COMMENT_FLAGS (OPTST_DISABLED) + +/* + * Include option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zIncludeText[] = + "Include only packets matching rule"; +tSCC zInclude_NAME[] = "INCLUDE"; +tSCC zInclude_Name[] = "include"; +static const int + aIncludeCantList[] = { + INDEX_OPT_EXCLUDE, NO_EQUIVALENT }; +#define INCLUDE_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Exclude option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zExcludeText[] = + "Exclude any packet matching this rule"; +tSCC zExclude_NAME[] = "EXCLUDE"; +tSCC zExclude_Name[] = "exclude"; +static const int + aExcludeCantList[] = { + INDEX_OPT_INCLUDE, NO_EQUIVALENT }; +#define EXCLUDE_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Cachefile option description: + */ +tSCC zCachefileText[] = + "Output cache file"; +tSCC zCachefile_NAME[] = "CACHEFILE"; +tSCC zCachefile_Name[] = "cachefile"; +#define CACHEFILE_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Pcap option description: + */ +tSCC zPcapText[] = + "Input pcap file to process"; +tSCC zPcap_NAME[] = "PCAP"; +tSCC zPcap_Name[] = "pcap"; +#define PCAP_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Print_Comment option description: + */ +tSCC zPrint_CommentText[] = + "Print embedded comment in the specified cache file"; +tSCC zPrint_Comment_NAME[] = "PRINT_COMMENT"; +tSCC zPrint_Comment_Name[] = "print-comment"; +#define PRINT_COMMENT_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Print_Info option description: + */ +tSCC zPrint_InfoText[] = + "Print basic info from the specified cache file"; +tSCC zPrint_Info_NAME[] = "PRINT_INFO"; +tSCC zPrint_Info_Name[] = "print-info"; +#define PRINT_INFO_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Print_Stats option description: + */ +tSCC zPrint_StatsText[] = + "Print statistical information about the specified cache file"; +tSCC zPrint_Stats_NAME[] = "PRINT_STATS"; +tSCC zPrint_Stats_Name[] = "print-stats"; +#define PRINT_STATS_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Services option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zServicesText[] = + "Load services file for server ports"; +tSCC zServices_NAME[] = "SERVICES"; +tSCC zServices_Name[] = "services"; +static const int + aServicesMustList[] = { + INDEX_OPT_PORT, NO_EQUIVALENT }; +#define SERVICES_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Nonip option description: + */ +tSCC zNonipText[] = + "Send non-IP traffic out server interface"; +tSCC zNonip_NAME[] = "NONIP"; +tSCC zNonip_Name[] = "nonip"; +#define NONIP_FLAGS (OPTST_DISABLED) + +/* + * Ratio option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zRatioText[] = + "Ratio of client to server packets"; +tSCC zRatio_NAME[] = "RATIO"; +tSCC zRatio_Name[] = "ratio"; +tSCC zRatioDefaultArg[] = "2.0"; +static const int + aRatioMustList[] = { + INDEX_OPT_AUTO, NO_EQUIVALENT }; +#define RATIO_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Minmask option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zMinmaskText[] = + "Minimum network mask length in auto mode"; +tSCC zMinmask_NAME[] = "MINMASK"; +tSCC zMinmask_Name[] = "minmask"; +#define zMinmaskDefaultArg ((char const*)30) +static const int + aMinmaskMustList[] = { + INDEX_OPT_AUTO, NO_EQUIVALENT }; +#define MINMASK_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Maxmask option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zMaxmaskText[] = + "Maximum network mask length in auto mode"; +tSCC zMaxmask_NAME[] = "MAXMASK"; +tSCC zMaxmask_Name[] = "maxmask"; +#define zMaxmaskDefaultArg ((char const*)8) +static const int + aMaxmaskMustList[] = { + INDEX_OPT_AUTO, NO_EQUIVALENT }; +#define MAXMASK_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Verbose option description: + */ +#ifdef ENABLE_VERBOSE +tSCC zVerboseText[] = + "Print decoded packets via tcpdump to STDOUT"; +tSCC zVerbose_NAME[] = "VERBOSE"; +tSCC zVerbose_Name[] = "verbose"; +#define VERBOSE_FLAGS (OPTST_DISABLED | OPTST_IMM) + +#else /* disable Verbose */ +#define VALUE_OPT_VERBOSE NO_EQUIVALENT +#define VERBOSE_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zVerboseText NULL +#define zVerbose_NAME NULL +#define zVerbose_Name NULL +#endif /* ENABLE_VERBOSE */ + +/* + * Decode option description with + * "Must also have options" and "Incompatible options": + */ +#ifdef ENABLE_VERBOSE +tSCC zDecodeText[] = + "Arguments passed to tcpdump decoder"; +tSCC zDecode_NAME[] = "DECODE"; +tSCC zDecode_Name[] = "decode"; +static const int + aDecodeMustList[] = { + INDEX_OPT_VERBOSE, NO_EQUIVALENT }; +#define DECODE_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +#else /* disable Decode */ +#define VALUE_OPT_DECODE NO_EQUIVALENT +#define DECODE_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define aDecodeMustList NULL +#define zDecodeText NULL +#define zDecode_NAME NULL +#define zDecode_Name NULL +#endif /* ENABLE_VERBOSE */ + +/* + * Version option description: + */ +tSCC zVersionText[] = + "Print version information"; +tSCC zVersion_NAME[] = "VERSION"; +tSCC zVersion_Name[] = "version"; +#define VERSION_FLAGS (OPTST_DISABLED) + +/* + * Less_Help option description: + */ +tSCC zLess_HelpText[] = + "Display less usage information and exit"; +tSCC zLess_Help_NAME[] = "LESS_HELP"; +tSCC zLess_Help_Name[] = "less-help"; +#define LESS_HELP_FLAGS (OPTST_DISABLED | OPTST_IMM) + +/* + * Help/More_Help option descriptions: + */ +tSCC zHelpText[] = "Display usage information and exit"; +tSCC zHelp_Name[] = "help"; +tSCC zMore_HelpText[] = "Extended usage information passed thru pager"; +tSCC zMore_Help_Name[] = "more-help"; +tSCC zSave_OptsText[] = "Save the option state to a config file"; +tSCC zSave_Opts_Name[] = "save-opts"; +tSCC zLoad_OptsText[] = "Load options from a config file"; +tSCC zLoad_Opts_NAME[] = "LOAD_OPTS"; +tSCC zNotLoad_Opts_Name[] = "no-load-opts"; +tSCC zNotLoad_Opts_Pfx[] = "no"; +#define zLoad_Opts_Name (zNotLoad_Opts_Name + 3) +/* + * Declare option callback procedures + */ +#ifdef DEBUG + static tOptProc doOptDbug; +#else /* not DEBUG */ +# define doOptDbug NULL +#endif /* def/not DEBUG */ +extern tOptProc + optionPagedUsage; +static tOptProc + doOptAuto, doOptCidr, doOptComment, + doOptExclude, doOptInclude, doOptLess_Help, + doOptMac, doOptMaxmask, doOptMinmask, + doOptNo_Arg_Comment, doOptNonip, doOptPort, + doOptRegex, doOptServices, doOptVersion, + doUsageOpt; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Define the Tcpprep Option Descriptions. + */ +static tOptDesc optDesc[ OPTION_CT ] = { + { /* entry idx, value */ 0, VALUE_OPT_DBUG, + /* equiv idx, value */ 0, VALUE_OPT_DBUG, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ DBUG_FLAGS, 0, + /* last opt argumnt */ { zDbugDefaultArg }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptDbug, + /* desc, NAME, name */ zDbugText, zDbug_NAME, zDbug_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 1, VALUE_OPT_AUTO, + /* equiv idx, value */ 1, VALUE_OPT_AUTO, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ AUTO_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aAutoCantList, + /* option proc */ doOptAuto, + /* desc, NAME, name */ zAutoText, zAuto_NAME, zAuto_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 2, VALUE_OPT_CIDR, + /* equiv idx, value */ 2, VALUE_OPT_CIDR, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ CIDR_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aCidrCantList, + /* option proc */ doOptCidr, + /* desc, NAME, name */ zCidrText, zCidr_NAME, zCidr_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 3, VALUE_OPT_REGEX, + /* equiv idx, value */ 3, VALUE_OPT_REGEX, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ REGEX_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aRegexCantList, + /* option proc */ doOptRegex, + /* desc, NAME, name */ zRegexText, zRegex_NAME, zRegex_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 4, VALUE_OPT_PORT, + /* equiv idx, value */ 4, VALUE_OPT_PORT, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ PORT_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aPortCantList, + /* option proc */ doOptPort, + /* desc, NAME, name */ zPortText, zPort_NAME, zPort_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 5, VALUE_OPT_MAC, + /* equiv idx, value */ 5, VALUE_OPT_MAC, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ MAC_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aMacCantList, + /* option proc */ doOptMac, + /* desc, NAME, name */ zMacText, zMac_NAME, zMac_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 6, VALUE_OPT_REVERSE, + /* equiv idx, value */ 6, VALUE_OPT_REVERSE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ REVERSE_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zReverseText, zReverse_NAME, zReverse_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 7, VALUE_OPT_COMMENT, + /* equiv idx, value */ 7, VALUE_OPT_COMMENT, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ COMMENT_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptComment, + /* desc, NAME, name */ zCommentText, zComment_NAME, zComment_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 8, VALUE_OPT_NO_ARG_COMMENT, + /* equiv idx, value */ 8, VALUE_OPT_NO_ARG_COMMENT, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ NO_ARG_COMMENT_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptNo_Arg_Comment, + /* desc, NAME, name */ zNo_Arg_CommentText, zNo_Arg_Comment_NAME, zNo_Arg_Comment_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 9, VALUE_OPT_INCLUDE, + /* equiv idx, value */ 9, VALUE_OPT_INCLUDE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ INCLUDE_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aIncludeCantList, + /* option proc */ doOptInclude, + /* desc, NAME, name */ zIncludeText, zInclude_NAME, zInclude_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 10, VALUE_OPT_EXCLUDE, + /* equiv idx, value */ 10, VALUE_OPT_EXCLUDE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ EXCLUDE_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aExcludeCantList, + /* option proc */ doOptExclude, + /* desc, NAME, name */ zExcludeText, zExclude_NAME, zExclude_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 11, VALUE_OPT_CACHEFILE, + /* equiv idx, value */ 11, VALUE_OPT_CACHEFILE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ CACHEFILE_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zCachefileText, zCachefile_NAME, zCachefile_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 12, VALUE_OPT_PCAP, + /* equiv idx, value */ 12, VALUE_OPT_PCAP, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ PCAP_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zPcapText, zPcap_NAME, zPcap_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 13, VALUE_OPT_PRINT_COMMENT, + /* equiv idx, value */ 13, VALUE_OPT_PRINT_COMMENT, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ PRINT_COMMENT_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zPrint_CommentText, zPrint_Comment_NAME, zPrint_Comment_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 14, VALUE_OPT_PRINT_INFO, + /* equiv idx, value */ 14, VALUE_OPT_PRINT_INFO, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ PRINT_INFO_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zPrint_InfoText, zPrint_Info_NAME, zPrint_Info_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 15, VALUE_OPT_PRINT_STATS, + /* equiv idx, value */ 15, VALUE_OPT_PRINT_STATS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ PRINT_STATS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zPrint_StatsText, zPrint_Stats_NAME, zPrint_Stats_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 16, VALUE_OPT_SERVICES, + /* equiv idx, value */ 16, VALUE_OPT_SERVICES, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ SERVICES_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aServicesMustList, NULL, + /* option proc */ doOptServices, + /* desc, NAME, name */ zServicesText, zServices_NAME, zServices_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 17, VALUE_OPT_NONIP, + /* equiv idx, value */ 17, VALUE_OPT_NONIP, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ NONIP_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptNonip, + /* desc, NAME, name */ zNonipText, zNonip_NAME, zNonip_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 18, VALUE_OPT_RATIO, + /* equiv idx, value */ 18, VALUE_OPT_RATIO, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ RATIO_FLAGS, 0, + /* last opt argumnt */ { zRatioDefaultArg }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aRatioMustList, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zRatioText, zRatio_NAME, zRatio_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 19, VALUE_OPT_MINMASK, + /* equiv idx, value */ 19, VALUE_OPT_MINMASK, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ MINMASK_FLAGS, 0, + /* last opt argumnt */ { zMinmaskDefaultArg }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aMinmaskMustList, NULL, + /* option proc */ doOptMinmask, + /* desc, NAME, name */ zMinmaskText, zMinmask_NAME, zMinmask_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 20, VALUE_OPT_MAXMASK, + /* equiv idx, value */ 20, VALUE_OPT_MAXMASK, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ MAXMASK_FLAGS, 0, + /* last opt argumnt */ { zMaxmaskDefaultArg }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aMaxmaskMustList, NULL, + /* option proc */ doOptMaxmask, + /* desc, NAME, name */ zMaxmaskText, zMaxmask_NAME, zMaxmask_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 21, VALUE_OPT_VERBOSE, + /* equiv idx, value */ 21, VALUE_OPT_VERBOSE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ VERBOSE_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zVerboseText, zVerbose_NAME, zVerbose_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 22, VALUE_OPT_DECODE, + /* equiv idx, value */ 22, VALUE_OPT_DECODE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ DECODE_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aDecodeMustList, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zDecodeText, zDecode_NAME, zDecode_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 23, VALUE_OPT_VERSION, + /* equiv idx, value */ 23, VALUE_OPT_VERSION, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ VERSION_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptVersion, + /* desc, NAME, name */ zVersionText, zVersion_NAME, zVersion_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 24, VALUE_OPT_LESS_HELP, + /* equiv idx, value */ 24, VALUE_OPT_LESS_HELP, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ LESS_HELP_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptLess_Help, + /* desc, NAME, name */ zLess_HelpText, zLess_Help_NAME, zLess_Help_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doUsageOpt, + /* desc, NAME, name */ zHelpText, NULL, zHelp_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionPagedUsage, + /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) + | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, NOLIMIT, 0, + /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) + | OPTST_DISABLE_IMM, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionLoadOpt, + /* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name, + /* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx } +}; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Define the Tcpprep Option Environment + */ +tSCC zPROGNAME[] = "TCPPREP"; +tSCC zUsageTitle[] = +"tcpprep (tcpprep) - Create a tcpreplay cache cache file from a pcap file.\n\ +USAGE: %s [ - [] | --[{=| }] ]...\n"; +tSCC zRcName[] = ".tcppreprc"; +tSCC* apzHomeList[] = { + "$$/", + NULL }; + +#define zBugsAddr NULL +tSCC zExplain[] = "\n\ +tcpprep is a ``pcap(3)'' file pre-processor which creates a cache\n\ +file which provides \"rules\" for ``tcprewrite(1)'' and ``tcpreplay(1)''\n\ +on how to process and send packets.\n"; +tSCC zDetail[] = "\n\ +The basic operation of tcpreplay is to resend all packets from the\n\ +input file(s) out a single file. Tcpprep processes a pcap file and \n\ +applies a set of user-specified rules to create a cache file which \n\ +tells tcpreplay wether or not to send each packet and which interface the\n\ +packet should be sent out of.\n\n\ +For more details, please see the Tcpreplay Manual at:\n\ +http://tcpreplay.synfin.net/trac/wiki/manual\n"; +#define zFullVersion NULL +/* extracted from /usr/local/share/autogen/optcode.tpl near line 501 */ + +#if defined(ENABLE_NLS) +# define OPTPROC_BASE OPTPROC_TRANSLATE + static tOptionXlateProc translate_option_strings; +#else +# define OPTPROC_BASE OPTPROC_NONE +# define translate_option_strings NULL +#endif /* ENABLE_NLS */ + + +#define tcpprep_full_usage NULL +#define tcpprep_short_usage NULL +tOptions tcpprepOptions = { + OPTIONS_STRUCT_VERSION, + 0, NULL, /* original argc + argv */ + ( OPTPROC_BASE + + OPTPROC_ERRSTOP + + OPTPROC_SHORTOPT + + OPTPROC_LONGOPT + + OPTPROC_NO_REQ_OPT + + OPTPROC_NO_ARGS + + OPTPROC_GNUUSAGE ), + 0, NULL, /* current option index, current option */ + NULL, NULL, zPROGNAME, + zRcName, zCopyright, zCopyrightNotice, + zFullVersion, apzHomeList, zUsageTitle, + zExplain, zDetail, optDesc, + zBugsAddr, /* address to send bugs to */ + NULL, NULL, /* extensions/saved state */ + optionUsage, /* usage procedure */ + translate_option_strings, /* translation procedure */ + /* + * Indexes to special options + */ + { INDEX_OPT_MORE_HELP, /* more-help option index */ + INDEX_OPT_SAVE_OPTS, /* save option index */ + NO_EQUIVALENT, /* '-#' option index */ + NO_EQUIVALENT /* index of default opt */ + }, + 29 /* full option count */, 25 /* user option count */, + tcpprep_full_usage, tcpprep_short_usage, + NULL, NULL +}; + +/* + * Create the static procedure(s) declared above. + */ +static void +doUsageOpt( + tOptions* pOptions, + tOptDesc* pOptDesc ) +{ + (void)pOptions; + USAGE( EXIT_SUCCESS ); +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the dbug option, when DEBUG is #define-d. + */ +#ifdef DEBUG +static void +doOptDbug(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 0, 5 } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} +#endif /* defined DEBUG */ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the auto option. + */ +static void +doOptAuto(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcpprep_opts.def, line 89 */ + + options.mode = AUTO_MODE; + if (strcmp(OPT_ARG(AUTO), "bridge") == 0) { + options.automode = BRIDGE_MODE; + } + else if (strcmp(OPT_ARG(AUTO), "router") == 0) { + options.automode = ROUTER_MODE; + } + else if (strcmp(OPT_ARG(AUTO), "client") == 0) { + options.automode = CLIENT_MODE; + } + else if (strcmp(OPT_ARG(AUTO), "server") == 0) { + options.automode = SERVER_MODE; + } + else if (strcmp(OPT_ARG(AUTO), "first") == 0) { + options.automode = FIRST_MODE; + } + else { + errx(-1, "Invalid auto mode type: %s", OPT_ARG(AUTO)); + } +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the cidr option. + */ +static void +doOptCidr(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcpprep_opts.def, line 161 */ + + char *cidr = safe_strdup(OPT_ARG(CIDR)); + options.mode = CIDR_MODE; + if (!parse_cidr(&options.cidrdata, cidr, ",")) + errx(-1, "Unable to parse CIDR map: %s", OPT_ARG(CIDR)); + free(cidr); + +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the regex option. + */ +static void +doOptRegex(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcpprep_opts.def, line 196 */ + + int regex_error; + char ebuf[EBUF_SIZE]; + + options.mode = REGEX_MODE; + if ((regex_error = regcomp(&options.preg, OPT_ARG(REGEX), + REG_EXTENDED|REG_NOSUB))) { + regerror(regex_error, &options.preg, ebuf, EBUF_SIZE); + errx(-1, "Unable to compile regex: %s", ebuf); + } + +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the port option. + */ +static void +doOptPort(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcpprep_opts.def, line 224 */ + + options.mode = PORT_MODE; + +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the mac option. + */ +static void +doOptMac(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcpprep_opts.def, line 245 */ + +options.mode = MAC_MODE; +options.maclist = safe_strdup(OPT_ARG(MAC)); + +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the comment option. + */ +static void +doOptComment(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcpprep_opts.def, line 277 */ + + /* our comment_len is only 16bit - myargs[] */ + if (strlen(OPT_ARG(COMMENT)) > ((1 << 16) - 1 - MYARGS_LEN)) + errx(-1, "Comment length %zu is longer then max allowed (%d)", + strlen(OPT_ARG(COMMENT)), (1 << 16) - 1 - MYARGS_LEN); + + /* save the comment */ + options.comment = (char *)safe_malloc(strlen(OPT_ARG(COMMENT)) + 1); + strcpy(options.comment, OPT_ARG(COMMENT)); + +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the no-arg-comment option. + */ +static void +doOptNo_Arg_Comment(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcpprep_opts.def, line 299 */ + +options.nocomment = 1; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the include option. + */ +static void +doOptInclude(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcpprep_opts.def, line 319 */ + + char *include; + + include = safe_strdup(OPT_ARG(INCLUDE)); + options.xX.mode = xX_MODE_INCLUDE; + + if ((options.xX.mode = parse_xX_str(&options.xX, include, &options.bpf)) == xXError) + errx(-1, "Unable to parse include/exclude rule: %s", OPT_ARG(INCLUDE)); + + free(include); + +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the exclude option. + */ +static void +doOptExclude(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcpprep_opts.def, line 366 */ + + char *exclude; + + exclude = safe_strdup(OPT_ARG(EXCLUDE)); + options.xX.mode = xX_MODE_EXCLUDE; + + if ((options.xX.mode = parse_xX_str(&options.xX, exclude, &options.bpf)) == xXError) + errx(-1, "Unable to parse include/exclude rule: %s", OPT_ARG(EXCLUDE)); + + free(exclude); + +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the services option. + */ +static void +doOptServices(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcpprep_opts.def, line 463 */ + parse_services(OPT_ARG(SERVICES), &options.services); + +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the nonip option. + */ +static void +doOptNonip(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcpprep_opts.def, line 474 */ + + options.nonip = DIR_SERVER; + +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the minmask option. + */ +static void +doOptMinmask(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 0, 32 } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the maxmask option. + */ +static void +doOptMaxmask(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 0, 32 } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the version option. + */ +static void +doOptVersion(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcpprep_opts.def, line 575 */ + + fprintf(stderr, "tcpprep version: %s (build %s)", VERSION, svn_version()); +#ifdef DEBUG + fprintf(stderr, " (debug)"); +#endif + fprintf(stderr, "\n"); + fprintf(stderr, "Copyright 2000-2010 by Aaron Turner \n"); + fprintf(stderr, "Cache file supported: %s\n", CACHEVERSION); +#ifdef HAVE_LIBDNET + fprintf(stderr, "Compiled against libdnet: %s\n", LIBDNET_VERSION); +#else + fprintf(stderr, "Not compiled with libdnet.\n"); +#endif +#ifdef HAVE_WINPCAP + fprintf(stderr, "Compiled against winpcap: %s\n", get_pcap_version()); +#else + fprintf(stderr, "Compiled against libpcap: %s\n", get_pcap_version()); +#endif +#ifdef ENABLE_64BITS + fprintf(stderr, "64 bit packet counters: enabled\n"); +#else + fprintf(stderr, "64 bit packet counters: disabled\n"); +#endif +#ifdef ENABLE_VERBOSE + fprintf(stderr, "Verbose printing via tcpdump: enabled\n"); +#else + fprintf(stderr, "Verbose printing via tcpdump: disabled\n"); +#endif + exit(0); + +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the less-help option. + */ +static void +doOptLess_Help(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcpprep_opts.def, line 615 */ + + USAGE(EXIT_FAILURE); + +} +/* extracted from /usr/local/share/autogen/optcode.tpl near line 633 */ + +#if ENABLE_NLS +#include +#include +#include +#include +#include + +static char* AO_gettext( char const* pz ); +static void coerce_it(void** s); + +static char* +AO_gettext( char const* pz ) +{ + char* pzRes; + if (pz == NULL) + return NULL; + pzRes = _(pz); + if (pzRes == pz) + return pzRes; + pzRes = strdup( pzRes ); + if (pzRes == NULL) { + fputs( _("No memory for duping translated strings\n"), stderr ); + exit( EXIT_FAILURE ); + } + return pzRes; +} + +static void coerce_it(void** s) { *s = AO_gettext(*s); } +#define COERSION(_f) \ + coerce_it((void*)&(tcpprepOptions._f)) + +/* + * This invokes the translation code (e.g. gettext(3)). + */ +static void +translate_option_strings( void ) +{ + /* + * Guard against re-translation. It won't work. The strings will have + * been changed by the first pass through this code. One shot only. + */ + if (option_usage_text.field_ct != 0) { + + /* + * Do the translations. The first pointer follows the field count + * field. The field count field is the size of a pointer. + */ + tOptDesc* pOD = tcpprepOptions.pOptDesc; + char** ppz = (char**)(void*)&(option_usage_text); + int ix = option_usage_text.field_ct; + + do { + ppz++; + *ppz = AO_gettext(*ppz); + } while (--ix > 0); + + COERSION(pzCopyright); + COERSION(pzCopyNotice); + COERSION(pzFullVersion); + COERSION(pzUsageTitle); + COERSION(pzExplain); + COERSION(pzDetail); + option_usage_text.field_ct = 0; + + for (ix = tcpprepOptions.optCt; ix > 0; ix--, pOD++) + coerce_it((void*)&(pOD->pzText)); + } + + if ((tcpprepOptions.fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) { + tOptDesc* pOD = tcpprepOptions.pOptDesc; + int ix; + + for (ix = tcpprepOptions.optCt; ix > 0; ix--, pOD++) { + coerce_it((void*)&(pOD->pz_Name)); + coerce_it((void*)&(pOD->pz_DisableName)); + coerce_it((void*)&(pOD->pz_DisablePfx)); + } + /* prevent re-translation */ + tcpprepOptions.fOptSet |= OPTPROC_NXLAT_OPT_CFG | OPTPROC_NXLAT_OPT; + } +} + +#endif /* ENABLE_NLS */ + +#ifdef __cplusplus +} +#endif +/* tcpprep_opts.c ends here */ diff --git a/src/tcpprep_opts.def b/src/tcpprep_opts.def new file mode 100644 index 0000000..f0332bc --- /dev/null +++ b/src/tcpprep_opts.def @@ -0,0 +1,619 @@ +autogen definitions options; + +copyright = { + date = "2000-2010"; + owner = "Aaron Turner"; + type = "bsd"; + author = <<- EOText +Copyright 2000-2010 Aaron Turner + +For support please use the tcpreplay-users@lists.sourceforge.net mailing list. + +The latest version of this software is always available from: +http://tcpreplay.synfin.net/ +EOText; +}; + +package = "tcpprep"; +prog-name = "tcpprep"; +prog-title = "Create a tcpreplay cache cache file from a pcap file."; +long-opts; +gnu-usage; +help-value = "H"; +save-opts-value = ""; +load-opts-value = ""; + +config-header = "config.h"; +include = "#include \"defines.h\"\n" + "#include \"common.h\"\n" + "#include \"config.h\"\n" + "#include \"tcpprep.h\"\n" + "#include \n" + "#include \n" + "extern tcpprep_opt_t options;\n"; + +homerc = "$$/"; + +explain = <<- EOExplain +tcpprep is a @file{pcap(3)} file pre-processor which creates a cache +file which provides "rules" for @file{tcprewrite(1)} and @file{tcpreplay(1)} +on how to process and send packets. +EOExplain; + +detail = <<- EODetail +The basic operation of tcpreplay is to resend all packets from the +input file(s) out a single file. Tcpprep processes a pcap file and +applies a set of user-specified rules to create a cache file which +tells tcpreplay wether or not to send each packet and which interface the +packet should be sent out of. + +For more details, please see the Tcpreplay Manual at: +http://tcpreplay.synfin.net/trac/wiki/manual +EODetail; + +man-doc = <<- EOMan +.SH "SEE ALSO" +tcpdump(1), tcprewrite(1), tcpreplay(1) +EOMan; + + +flag = { + ifdef = DEBUG; + name = dbug; + value = d; + arg-type = number; + max = 1; + immediate; + arg-range = "0->5"; + arg-default = 0; + descrip = "Enable debugging output"; + doc = <<- EOText +If configured with --enable-debug, then you can specify a verbosity +level for debugging output. Higher numbers increase verbosity. +EOText; +}; + + +/* Modes: -a bridge/router/client/server, -c (cidr) */ +flag = { + name = auto; + value = a; + descrip = "Auto-split mode"; + arg-type = string; + max = 1; + flags-cant = cidr; + flags-cant = port; + flags-cant = regex; + flags-cant = mac; + flag-code = <<- EOAuto + + options.mode = AUTO_MODE; + if (strcmp(OPT_ARG(AUTO), "bridge") == 0) { + options.automode = BRIDGE_MODE; + } + else if (strcmp(OPT_ARG(AUTO), "router") == 0) { + options.automode = ROUTER_MODE; + } + else if (strcmp(OPT_ARG(AUTO), "client") == 0) { + options.automode = CLIENT_MODE; + } + else if (strcmp(OPT_ARG(AUTO), "server") == 0) { + options.automode = SERVER_MODE; + } + else if (strcmp(OPT_ARG(AUTO), "first") == 0) { + options.automode = FIRST_MODE; + } + else { + errx(-1, "Invalid auto mode type: %s", OPT_ARG(AUTO)); + } +EOAuto; + doc = <<- EOText +Tcpprep will try to automatically determine the primary function of hosts +based on the traffic captured and classify each host as client or server. +In order to do so, you must provide a hint to tcpprep as to how to search +for clients and servers. Valid hints are: + +@table @bullet +@item +@var{bridge} +Bridge mode processes each packet to try to determine if the sender is a +client or server. Once all the packets are processed, the results are weighed +according to the server/client ratio (@samp{--ratio}) and systems are assigned an +interface. If tcpprep is unable to determine what role a system plays, tcpprep +will abort. +@item +@var{router} +Router mode works just like bridge mode, except that after weighing is done, +systems which are undetermined are considered a server if they fall inside a +network known to contain other servers. Router has a greater chance of +successfully splitting clients and servers but is not 100% foolproof. +@item +@var{client} +Client mode works just like bridge mode, except that unclassified systems are +treated as clients. Client mode should always complete successfully. +@item +@var{server} +Server mode works just like bridge mode, except that unclassified systems are +treated as servers. Server mode should always complete successfully. +@item +@var{first} +First mode works by looking at the first time each IP is seen in the SRC and DST +fields in the IP header. If the host is first seen in the SRC field, it is a +client and if it's first seen in the DST field, it is marked as a server. This +effectively replicates the processing of the tomahawk test tool. First +mode should always complete successfully. +@end table +EOText; +}; + + +flag = { + name = cidr; + value = c; + descrip = "CIDR-split mode"; + arg-type = string; + max = 1; + flags-cant = auto; + flags-cant = port; + flags-cant = regex; + flags-cant = mac; + flag-code = <<- EOCidr + + char *cidr = safe_strdup(OPT_ARG(CIDR)); + options.mode = CIDR_MODE; + if (!parse_cidr(&options.cidrdata, cidr, ",")) + errx(-1, "Unable to parse CIDR map: %s", OPT_ARG(CIDR)); + free(cidr); + +EOCidr; + doc = <<- EOText +Specify a comma delimited list of CIDR netblocks to match against +the source IP of each packet. Packets matching any of the CIDR's +are classified as servers. + +IPv4 Example: +@example +--cidr=192.168.0.0/16,172.16.0.0/12,10.0.0.0/8 +@end example +IPv6 Example: +@example +--cidr=[::ffff:0:0/96],[fe80::/16] +@end example +EOText; +}; + +flag = { + name = regex; + value = r; + descrip = "Regex-split mode"; + arg-type = string; + max = 1; + flags-cant = auto; + flags-cant = port; + flags-cant = cidr; + flags-cant = mac; + flag-code = <<- EORegex + + int regex_error; + char ebuf[EBUF_SIZE]; + + options.mode = REGEX_MODE; + if ((regex_error = regcomp(&options.preg, OPT_ARG(REGEX), + REG_EXTENDED|REG_NOSUB))) { + regerror(regex_error, &options.preg, ebuf, EBUF_SIZE); + errx(-1, "Unable to compile regex: %s", ebuf); + } + +EORegex; + doc = <<- EOText +Specify a regular expression to match against the source IP of each +packet. Packets matching the regex are classified as servers. +EOText; +}; + +flag = { + name = port; + value = p; + descrip = "Port-split mode"; + max = 1; + flags-cant = auto; + flags-cant = regex; + flags-cant = cidr; + flags-cant = mac; + flag-code = <<- EOPort + + options.mode = PORT_MODE; + +EOPort; + doc = <<- EOText +Specifies that TCP and UDP traffic over IPv4 and IPv6 should be classified +as client or server based upon the destination port of the header. +EOText; +}; + +flag = { + name = mac; + value = e; + arg-type = string; + max = 1; + descrip = "Source MAC split mode"; + flags-cant = auto; + flags-cant = regex; + flags-cant = cidr; + flags-cant = port; + flag-code = <<- EOMac + +options.mode = MAC_MODE; +options.maclist = safe_strdup(OPT_ARG(MAC)); + +EOMac; + doc = <<- EOText +Specify a list of MAC addresses to match against the source MAC +of each packet. Packets matching one of the values are classified +as servers. +EOText; + +}; + +flag = { + name = reverse; + max = 1; + descrip = "Matches to be client instead of server"; + doc = <<- EOText +Normally the @samp{--mac}, @samp{--regex} and @samp{--cidr} flags specify are used to specify +the servers and non-IP packets are classified as clients. By using @samp{--reverse}, these +features are reversed so that the flags specify clients and non-IP packets are classified as +servers. +EOText; +}; + +flag = { + name = comment; + value = C; + arg-type = string; + max = 1; + descrip = "Embeded cache file comment"; + flag-code = <<- EOComment + + /* our comment_len is only 16bit - myargs[] */ + if (strlen(OPT_ARG(COMMENT)) > ((1 << 16) - 1 - MYARGS_LEN)) + errx(-1, "Comment length %zu is longer then max allowed (%d)", + strlen(OPT_ARG(COMMENT)), (1 << 16) - 1 - MYARGS_LEN); + + /* save the comment */ + options.comment = (char *)safe_malloc(strlen(OPT_ARG(COMMENT)) + 1); + strcpy(options.comment, OPT_ARG(COMMENT)); + +EOComment; + doc = <<- EOText +Specify a comment to be imbedded within the output cache file and later +viewed. +EOText; +}; + +flag = { + name = no-arg-comment; + max = 1; + descrip = "Do not embed any cache file comment"; + flag-code = <<- EOCode + +options.nocomment = 1; +EOCode; + doc = <<- EOText +By default, tcpprep includes the arguments passed on the command line +in the cache file comment (in addition to any user specified --comment). +If for some reason you do not wish to include this, specify this option. +EOText; +}; + + +/* Include/Exclude */ +flag = { + name = include; + value = x; + arg-type = string; + max = 1; + descrip = "Include only packets matching rule"; + flags-cant = exclude; + flag-code = <<- EOInclude + + char *include; + + include = safe_strdup(OPT_ARG(INCLUDE)); + options.xX.mode = xX_MODE_INCLUDE; + + if ((options.xX.mode = parse_xX_str(&options.xX, include, &options.bpf)) == xXError) + errx(-1, "Unable to parse include/exclude rule: %s", OPT_ARG(INCLUDE)); + + free(include); + +EOInclude; + doc = <<- EOText +Override default of processing all packets stored in the capture file and only +send/edit packets which match the provided rule. Rules can be one of: + +@table @bullet +@item S:,... +- Source IP must match specified IPv4/v6 CIDR(s) +@item D:,... +- Destination IP must match specified IPv4/v6 CIDR(s) +@item B:,... +- Both source and destination IP must match specified IPv4/v6 CIDR(s) +@item E:,... +- Either IP must match specified IPv4/v6 CIDR(s) +@item P: +- Must be one of the listed packets where the list +corresponds to the packet number in the capture file. +@example +-x P:1-5,9,15,72- +@end example +would process packets 1 thru 5, the 9th and 15th packet, and packets 72 until the +end of the file +@item F:'' +- BPF filter. See the @file{tcpdump(8)} man page for syntax. +@end table +EOText; +}; + +flag = { + name = exclude; + value = X; + arg-type = string; + max = 1; + descrip = "Exclude any packet matching this rule"; + flags-cant = include; + flag-code = <<- EOExclude + + char *exclude; + + exclude = safe_strdup(OPT_ARG(EXCLUDE)); + options.xX.mode = xX_MODE_EXCLUDE; + + if ((options.xX.mode = parse_xX_str(&options.xX, exclude, &options.bpf)) == xXError) + errx(-1, "Unable to parse include/exclude rule: %s", OPT_ARG(EXCLUDE)); + + free(exclude); + +EOExclude; + doc = <<- EOText +Override default of processing all packets stored in the capture file and only +send/edit packets which do NOT match the provided rule. Rules can be one of: + +@table @bullet +@item S:,... +- Source IP must not match specified IPv4/v6 CIDR(s) +@item D:,... +- Destination IP must not match specified IPv4/v6 CIDR(s) +@item B:,... +- Both source and destination IP must not match specified IPv4/v6 CIDR(s) +@item E:,... +- Either IP must not match specified IPv4/v6 CIDR(s) +@item P: +- Must not be one of the listed packets where the list +corresponds to the packet number in the capture file. +@example +-x P:1-5,9,15,72- +@end example +would skip packets 1 thru 5, the 9th and 15th packet, and packets 72 until the +end of the file +@end table +EOText; +}; + +flag = { + name = cachefile; + value = o; + arg-type = string; + max = 1; + descrip = "Output cache file"; + doc = ""; +}; + +flag = { + name = pcap; + value = i; + descrip = "Input pcap file to process"; + arg-type = string; + max = 1; + doc = ""; +}; + +flag = { + name = print-comment; + value = P; + arg-type = string; + descrip = "Print embedded comment in the specified cache file"; + max = 1; + doc = ""; +}; + +flag = { + name = print-info; + value = I; + arg-type = string; + descrip = "Print basic info from the specified cache file"; + max = 1; + doc = ""; +}; + +flag = { + name = print-stats; + value = S; + arg-type = string; + descrip = "Print statistical information about the specified cache file"; + max = 1; + doc = ""; +}; + +flag = { + name = services; + value = s; + descrip = "Load services file for server ports"; + flags-must = port; + max = 1; + arg-type = string; + doc = <<- EOText +Uses a list of ports used by servers in the same format as of /etc/services: + / # comment + +Example: +http 80/tcp +EOText; + flag-code = <<- EOServices + parse_services(OPT_ARG(SERVICES), &options.services); + +EOServices; +}; + +flag = { + name = nonip; + value = N; + descrip = "Send non-IP traffic out server interface"; + max = 1; + flag-code = <<- EONonip + + options.nonip = DIR_SERVER; + +EONonip; + doc = <<- EOText +By default, non-IP traffic which can not be classified as client +or server is classified as "client". Specifiying @samp{--nonip} +will reclassify non-IP traffic as "server". Note that the meaning +of this flag is reversed if @samp{--reverse} is used. +EOText; +}; + + +flag = { + name = ratio; + value = R; + arg-type = string; + max = 1; + flags-must = auto; + arg_default = "2.0"; + descrip = "Ratio of client to server packets"; + doc = <<- EOText +Since a given host may have both client and server traffic being sent +to/from it, tcpprep uses a ratio to weigh these packets. If you would +like to override the default of 2:1 server to client packets required for +a host to be classified as a server, specify it as a floating point value. +EOText; +}; + + +flag = { + name = minmask; + value = m; + descrip = "Minimum network mask length in auto mode"; + flags-must = auto; + max = 1; + arg-type = number; + arg-range = "0->32"; + arg_default = 30; + doc = <<- EOText +By default, auto modes use a minimum network mask length of 30 bits +to build networks containing clients and servers. This allows you +to override this value. Larger values will increase performance but +may provide inaccurate results. +EOText; +}; + +flag = { + name = maxmask; + value = M; + descrip = "Maximum network mask length in auto mode"; + flags-must = auto; + max = 1; + arg-type = number; + arg-range = "0->32"; + arg_default = 8; + doc = <<- EOText +By default, auto modes use a maximum network mask length of 8 bits +to build networks containing clients and servers. This allows you +to override this value. Larger values will decrease performance +and accuracy but will provide greater chance of success. +EOText; +}; + +flag = { + ifdef = ENABLE_VERBOSE; + name = verbose; + value = v; + max = 1; + immediate; + descrip = "Print decoded packets via tcpdump to STDOUT"; + settable; + doc = ""; +}; + +flag = { + ifdef = ENABLE_VERBOSE; + name = decode; + flags-must = verbose; + value = A; + arg-type = string; + max = 1; + descrip = "Arguments passed to tcpdump decoder"; + doc = <<- EOText +When enabling verbose mode (@samp{-v}) you may also specify one or +more additional arguments to pass to @code{tcpdump} to modify +the way packets are decoded. By default, -n and -l are used. +Be sure to quote the arguments so that they are not interpreted +by tcprewrite. The following arguments are valid: + [ -aAeNqRStuvxX ] + [ -E spi@ipaddr algo:secret,... ] + [ -s snaplen ] +EOText; +}; + + +flag = { + name = version; + value = V; + descrip = "Print version information"; + flag-code = <<- EOVersion + + fprintf(stderr, "tcpprep version: %s (build %s)", VERSION, svn_version()); +#ifdef DEBUG + fprintf(stderr, " (debug)"); +#endif + fprintf(stderr, "\n"); + fprintf(stderr, "Copyright 2000-2010 by Aaron Turner \n"); + fprintf(stderr, "Cache file supported: %s\n", CACHEVERSION); +#ifdef HAVE_LIBDNET + fprintf(stderr, "Compiled against libdnet: %s\n", LIBDNET_VERSION); +#else + fprintf(stderr, "Not compiled with libdnet.\n"); +#endif +#ifdef HAVE_WINPCAP + fprintf(stderr, "Compiled against winpcap: %s\n", get_pcap_version()); +#else + fprintf(stderr, "Compiled against libpcap: %s\n", get_pcap_version()); +#endif +#ifdef ENABLE_64BITS + fprintf(stderr, "64 bit packet counters: enabled\n"); +#else + fprintf(stderr, "64 bit packet counters: disabled\n"); +#endif +#ifdef ENABLE_VERBOSE + fprintf(stderr, "Verbose printing via tcpdump: enabled\n"); +#else + fprintf(stderr, "Verbose printing via tcpdump: disabled\n"); +#endif + exit(0); + +EOVersion; + doc = ""; +}; + +flag = { + name = less-help; + value = "h"; + immediate; + descrip = "Display less usage information and exit"; + flag-code = <<- EOHelp + + USAGE(EXIT_FAILURE); + +EOHelp; +}; diff --git a/src/tcpprep_opts.h b/src/tcpprep_opts.h new file mode 100644 index 0000000..bfab63d --- /dev/null +++ b/src/tcpprep_opts.h @@ -0,0 +1,243 @@ +/* -*- buffer-read-only: t -*- vi: set ro: + * + * DO NOT EDIT THIS FILE (tcpprep_opts.h) + * + * It has been AutoGen-ed April 4, 2010 at 05:59:19 PM by AutoGen 5.9.9 + * From the definitions tcpprep_opts.def + * and the template file options + * + * Generated from AutoOpts 32:2:7 templates. + */ + +/* + * This file was produced by an AutoOpts template. AutoOpts is a + * copyrighted work. This header file is not encumbered by AutoOpts + * licensing, but is provided under the licensing terms chosen by the + * tcpprep author or copyright holder. AutoOpts is licensed under + * the terms of the LGPL. The redistributable library (``libopts'') is + * licensed under the terms of either the LGPL or, at the users discretion, + * the BSD license. See the AutoOpts and/or libopts sources for details. + * + * This source file is copyrighted and licensed under the following terms: + * + * tcpprep copyright (c) 2000-2010 Aaron Turner - all rights reserved + * + * tcpprep is free software copyrighted by Aaron Turner. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name ``Aaron Turner'' nor the name of any other + * contributor may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * tcpprep IS PROVIDED BY Aaron Turner ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL Aaron Turner OR ANY OTHER CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/* + * This file contains the programmatic interface to the Automated + * Options generated for the tcpprep program. + * These macros are documented in the AutoGen info file in the + * "AutoOpts" chapter. Please refer to that doc for usage help. + */ +#ifndef AUTOOPTS_TCPPREP_OPTS_H_GUARD +#define AUTOOPTS_TCPPREP_OPTS_H_GUARD 1 +#include "config.h" +#include + +/* + * Ensure that the library used for compiling this generated header is at + * least as new as the version current when the header template was released + * (not counting patch version increments). Also ensure that the oldest + * tolerable version is at least as old as what was current when the header + * template was released. + */ +#define AO_TEMPLATE_VERSION 131074 +#if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \ + || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION) +# error option template version mismatches autoopts/options.h header + Choke Me. +#endif + +/* + * Enumeration of each option: + */ +typedef enum { + INDEX_OPT_DBUG = 0, + INDEX_OPT_AUTO = 1, + INDEX_OPT_CIDR = 2, + INDEX_OPT_REGEX = 3, + INDEX_OPT_PORT = 4, + INDEX_OPT_MAC = 5, + INDEX_OPT_REVERSE = 6, + INDEX_OPT_COMMENT = 7, + INDEX_OPT_NO_ARG_COMMENT = 8, + INDEX_OPT_INCLUDE = 9, + INDEX_OPT_EXCLUDE = 10, + INDEX_OPT_CACHEFILE = 11, + INDEX_OPT_PCAP = 12, + INDEX_OPT_PRINT_COMMENT = 13, + INDEX_OPT_PRINT_INFO = 14, + INDEX_OPT_PRINT_STATS = 15, + INDEX_OPT_SERVICES = 16, + INDEX_OPT_NONIP = 17, + INDEX_OPT_RATIO = 18, + INDEX_OPT_MINMASK = 19, + INDEX_OPT_MAXMASK = 20, + INDEX_OPT_VERBOSE = 21, + INDEX_OPT_DECODE = 22, + INDEX_OPT_VERSION = 23, + INDEX_OPT_LESS_HELP = 24, + INDEX_OPT_HELP = 25, + INDEX_OPT_MORE_HELP = 26, + INDEX_OPT_SAVE_OPTS = 27, + INDEX_OPT_LOAD_OPTS = 28 +} teOptIndex; + +#define OPTION_CT 29 + +/* + * Interface defines for all options. Replace "n" with the UPPER_CASED + * option name (as in the teOptIndex enumeration above). + * e.g. HAVE_OPT( DBUG ) + */ +#define DESC(n) (tcpprepOptions.pOptDesc[INDEX_OPT_## n]) +#define HAVE_OPT(n) (! UNUSED_OPT(& DESC(n))) +#define OPT_ARG(n) (DESC(n).optArg.argString) +#define STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK) +#define COUNT_OPT(n) (DESC(n).optOccCt) +#define ISSEL_OPT(n) (SELECTED_OPT(&DESC(n))) +#define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n))) +#define ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n))) +#define STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt) +#define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs) +#define CLEAR_OPT(n) STMTS( \ + DESC(n).fOptState &= OPTST_PERSISTENT_MASK; \ + if ( (DESC(n).fOptState & OPTST_INITENABLED) == 0) \ + DESC(n).fOptState |= OPTST_DISABLED; \ + DESC(n).optCookie = NULL ) + +/* * * * * * + * + * Interface defines for specific options. + */ +#ifdef DEBUG +#define VALUE_OPT_DBUG 'd' +#define OPT_VALUE_DBUG (DESC(DBUG).optArg.argInt) +#endif /* DEBUG */ +#define VALUE_OPT_AUTO 'a' +#define VALUE_OPT_CIDR 'c' +#define VALUE_OPT_REGEX 'r' +#define VALUE_OPT_PORT 'p' +#define VALUE_OPT_MAC 'e' +#define VALUE_OPT_REVERSE 6 +#define VALUE_OPT_COMMENT 'C' +#define VALUE_OPT_NO_ARG_COMMENT 8 +#define VALUE_OPT_INCLUDE 'x' +#define VALUE_OPT_EXCLUDE 'X' +#define VALUE_OPT_CACHEFILE 'o' +#define VALUE_OPT_PCAP 'i' +#define VALUE_OPT_PRINT_COMMENT 'P' +#define VALUE_OPT_PRINT_INFO 'I' +#define VALUE_OPT_PRINT_STATS 'S' +#define VALUE_OPT_SERVICES 's' +#define VALUE_OPT_NONIP 'N' +#define VALUE_OPT_RATIO 'R' +#define VALUE_OPT_MINMASK 'm' +#define OPT_VALUE_MINMASK (DESC(MINMASK).optArg.argInt) +#define VALUE_OPT_MAXMASK 'M' +#define OPT_VALUE_MAXMASK (DESC(MAXMASK).optArg.argInt) +#ifdef ENABLE_VERBOSE +#define VALUE_OPT_VERBOSE 'v' +#define SET_OPT_VERBOSE STMTS( \ + DESC(VERBOSE).optActualIndex = 21; \ + DESC(VERBOSE).optActualValue = VALUE_OPT_VERBOSE; \ + DESC(VERBOSE).fOptState &= OPTST_PERSISTENT_MASK; \ + DESC(VERBOSE).fOptState |= OPTST_SET ) +#endif /* ENABLE_VERBOSE */ +#ifdef ENABLE_VERBOSE +#define VALUE_OPT_DECODE 'A' +#endif /* ENABLE_VERBOSE */ +#define VALUE_OPT_VERSION 'V' +#define VALUE_OPT_LESS_HELP 'h' +#define VALUE_OPT_HELP 'H' +#define VALUE_OPT_MORE_HELP '!' +#define VALUE_OPT_SAVE_OPTS INDEX_OPT_SAVE_OPTS +#define VALUE_OPT_LOAD_OPTS INDEX_OPT_LOAD_OPTS +#define SET_OPT_SAVE_OPTS(a) STMTS( \ + DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \ + DESC(SAVE_OPTS).fOptState |= OPTST_SET; \ + DESC(SAVE_OPTS).optArg.argString = (char const*)(a) ) +/* + * Interface defines not associated with particular options + */ +#define ERRSKIP_OPTERR STMTS( tcpprepOptions.fOptSet &= ~OPTPROC_ERRSTOP ) +#define ERRSTOP_OPTERR STMTS( tcpprepOptions.fOptSet |= OPTPROC_ERRSTOP ) +#define RESTART_OPT(n) STMTS( \ + tcpprepOptions.curOptIdx = (n); \ + tcpprepOptions.pzCurOpt = NULL ) +#define START_OPT RESTART_OPT(1) +#define USAGE(c) (*tcpprepOptions.pUsageProc)( &tcpprepOptions, c ) +/* extracted from /usr/local/share/autogen/opthead.tpl near line 409 */ + +/* * * * * * + * + * Declare the tcpprep option descriptor. + */ +#ifdef __cplusplus +extern "C" { +#endif + +extern tOptions tcpprepOptions; + +#if defined(ENABLE_NLS) +# ifndef _ +# include + static inline char* aoGetsText( char const* pz ) { + if (pz == NULL) return NULL; + return (char*)gettext( pz ); + } +# define _(s) aoGetsText(s) +# endif /* _() */ + +# define OPT_NO_XLAT_CFG_NAMES STMTS(tcpprepOptions.fOptSet |= \ + OPTPROC_NXLAT_OPT_CFG;) +# define OPT_NO_XLAT_OPT_NAMES STMTS(tcpprepOptions.fOptSet |= \ + OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;) + +# define OPT_XLAT_CFG_NAMES STMTS(tcpprepOptions.fOptSet &= \ + ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);) +# define OPT_XLAT_OPT_NAMES STMTS(tcpprepOptions.fOptSet &= \ + ~OPTPROC_NXLAT_OPT;) + +#else /* ENABLE_NLS */ +# define OPT_NO_XLAT_CFG_NAMES +# define OPT_NO_XLAT_OPT_NAMES + +# define OPT_XLAT_CFG_NAMES +# define OPT_XLAT_OPT_NAMES + +# ifndef _ +# define _(_s) _s +# endif +#endif /* ENABLE_NLS */ + +#ifdef __cplusplus +} +#endif +#endif /* AUTOOPTS_TCPPREP_OPTS_H_GUARD */ +/* tcpprep_opts.h ends here */ diff --git a/src/tcpr.h b/src/tcpr.h new file mode 100644 index 0000000..29de126 --- /dev/null +++ b/src/tcpr.h @@ -0,0 +1,1732 @@ +/* $Id: tcpr.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2006-2010 Aaron Turner. + * Copyright (c) 1998 - 2004 Mike D. Schiffman + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This header is heavily based off of (in other words basically stolen from) + * libnet 1.1.3's libnet-headers.h. Many thanks to Mike for doing all this + * work so I basically just needed to do a search and replace to get things + * to work. +*/ + +#include +#include +#include + +#ifndef _TCPR_H_ +#define _TCPR_H_ + +#define ETHER_ADDR_LEN 0x6 +#define FDDI_ADDR_LEN 0x6 +#define TOKEN_RING_ADDR_LEN 0x6 +#define TCPR_ORG_CODE_SIZE 0x3 + + +/** + * Libnet defines header sizes for every builder function exported. + */ +#define TCPR_802_1Q_H 0x12 /**< 802.1Q header: 18 bytes */ +#define TCPR_802_1X_H 0x04 /**< 802.1X header: 4 bytes */ +#define TCPR_802_2_H 0x03 /**< 802.2 LLC header: 3 bytes */ +#define TCPR_802_2SNAP_H 0x08 /**< 802.2 LLC/SNAP header:8 bytes */ +#define TCPR_802_3_H 0x0e /**< 802.3 header: 14 bytes */ +#define TCPR_ARP_H 0x08 /**< ARP header w/o addrs: 8 bytes */ +#define TCPR_ARP_ETH_IP_H 0x1c /**< ARP w/ ETH and IP: 28 bytes */ +#define TCPR_BGP4_HEADER_H 0x13 /**< BGP header: 19 bytes */ +#define TCPR_BGP4_OPEN_H 0x0a /**< BGP open header: 10 bytes */ +#define TCPR_BGP4_UPDATE_H 0x04 /**< BGP open header: 4 bytes */ +#define TCPR_BGP4_NOTIFICATION_H 0x02 /**< BGP notif. header: 2 bytes */ +#define TCPR_CDP_H 0x08 /**< CDP header base: 8 bytes */ +#define TCPR_DHCPV4_H 0xf0 /**< DHCP v4 header: 240 bytes */ +#define TCPR_UDP_DNSV4_H 0x0c /**< UDP DNS v4 header: 12 bytes */ +#define TCPR_TCP_DNSV4_H 0x0e /**< TCP DNS v4 header: 14 bytes */ +#define TCPR_ETH_H 0x0e /**< Ethernet header: 14 bytes */ +#define TCPR_ETH_MTU 1500 /**< Ethernet MTU size: 1500 bytes */ +#define TCPR_FDDI_H 0x15 /**< FDDI header: 21 bytes */ +#define TCPR_ICMPV4_H 0x04 /**< ICMP header base: 4 bytes */ +#define TCPR_ICMPV4_ECHO_H 0x08 /**< ICMP_ECHO header: 8 bytes */ +#define TCPR_ICMPV4_MASK_H 0x0c /**< ICMP_MASK header: 12 bytes */ +#define TCPR_ICMPV4_UNREACH_H 0x08 /**< ICMP_UNREACH header: 8 bytes */ +#define TCPR_ICMPV4_TIMXCEED_H 0x08 /**< ICMP_TIMXCEED header: 8 bytes */ +#define TCPR_ICMPV4_REDIRECT_H 0x08 /**< ICMP_REDIRECT header: 8 bytes */ +#define TCPR_ICMPV4_TS_H 0x14 /**< ICMP_TIMESTAMP headr:20 bytes */ +#define TCPR_ICMPV6_H 0x08 /**< ICMP6 header base: 8 bytes */ +#define TCPR_IGMP_H 0x08 /**< IGMP header: 8 bytes */ +#define TCPR_IPV4_H 0x14 /**< IPv4 header: 20 bytes */ +#define TCPR_IPV6_H 0x28 /**< IPv6 header: 40 bytes */ +#define TCPR_IPV6_FRAG_H 0x08 /**< IPv6 frag header: 8 bytes */ +#define TCPR_IPV6_ROUTING_H 0x04 /**< IPv6 frag header base:4 bytes */ +#define TCPR_IPV6_DESTOPTS_H 0x02 /**< IPv6 dest opts base: 2 bytes */ +#define TCPR_IPV6_HBHOPTS_H 0x02 /**< IPv6 hop/hop opt base:2 bytes */ +#define TCPR_IPSEC_ESP_HDR_H 0x0c /**< IPSEC ESP header: 12 bytes */ +#define TCPR_IPSEC_ESP_FTR_H 0x02 /**< IPSEC ESP footer: 2 bytes */ +#define TCPR_IPSEC_AH_H 0x10 /**< IPSEC AH header: 16 bytes */ +#define TCPR_ISL_H 0x1a /**< ISL header: 26 bytes */ +#define TCPR_GRE_H 0x04 /**< GRE header: 4 bytes */ +#define TCPR_GRE_SRE_H 0x04 /**< GRE SRE header: 4 bytes */ +#define TCPR_MPLS_H 0x04 /**< MPLS header: 4 bytes */ +#define TCPR_OSPF_H 0x10 /**< OSPF header: 16 bytes */ +#define TCPR_OSPF_HELLO_H 0x18 /**< OSPF hello header: 24 bytes */ +#define TCPR_OSPF_DBD_H 0x08 /**< OSPF DBD header: 8 bytes */ +#define TCPR_OSPF_LSR_H 0x0c /**< OSPF LSR header: 12 bytes */ +#define TCPR_OSPF_LSU_H 0x04 /**< OSPF LSU header: 4 bytes */ +#define TCPR_OSPF_LSA_H 0x14 /**< OSPF LSA header: 20 bytes */ +#define TCPR_OSPF_AUTH_H 0x08 /**< OSPF AUTH header: 8 bytes */ +#define TCPR_OSPF_CKSUM 0x10 /**< OSPF CKSUM header: 16 bytes */ +#define TCPR_OSPF_LS_RTR_H 0x10 /**< OSPF LS RTR header: 16 bytes */ +#define TCPR_OSPF_LS_NET_H 0x08 /**< OSPF LS NET header: 8 bytes */ +#define TCPR_OSPF_LS_SUM_H 0x0c /**< OSPF LS SUM header: 12 bytes */ +#define TCPR_OSPF_LS_AS_EXT_H 0x10 /**< OSPF LS AS header: 16 bytes */ +#define TCPR_NTP_H 0x30 /**< NTP header: 48 bytes */ +#define TCPR_RIP_H 0x18 /**< RIP header base: 24 bytes */ +#define TCPR_RPC_CALL_H 0x28 /**< RPC header: 40 bytes + * (assuming 8 byte auth header) + */ +#define TCPR_RPC_CALL_TCP_H 0x2c /**< RPC header: 44 bytes + * (with record marking) + */ +#define TCPR_SEBEK_H 0x30 /* sebek header: 48 bytes */ +#define TCPR_STP_CONF_H 0x23 /**< STP conf header: 35 bytes */ +#define TCPR_STP_TCN_H 0x04 /**< STP tcn header: 4 bytes */ +#define TCPR_TOKEN_RING_H 0x16 /**< Token Ring header: 22 bytes */ +#define TCPR_TCP_H 0x14 /**< TCP header: 20 bytes */ +#define TCPR_UDP_H 0x08 /**< UDP header: 8 bytes */ +#define TCPR_VRRP_H 0x08 /**< VRRP header: 8 bytes */ +#define TCPR_HSRP_H 0x14 /**< HSRP header: 8 bytes */ + +/** + * IEEE 802.1Q (Virtual Local Area Network) VLAN header, static header + * size: 8 bytes + */ +struct tcpr_802_1q_hdr +{ + u_int8_t vlan_dhost[ETHER_ADDR_LEN]; /**< destination ethernet address */ + u_int8_t vlan_shost[ETHER_ADDR_LEN]; /**< source ethernet address */ + u_int16_t vlan_tpi; /**< tag protocol ID */ + u_int16_t vlan_priority_c_vid; /**< priority | VLAN ID */ +#define TCPR_802_1Q_PRIMASK 0x0007 /**< priority mask */ +#define TCPR_802_1Q_CFIMASK 0x0001 /**< CFI mask */ +#define TCPR_802_1Q_VIDMASK 0x0fff /**< vid mask */ + u_int16_t vlan_len; /**< length or type (802.3 / Eth 2) */ +}; + +/** + * IEEE 802.1X EAP (Extensible Authentication Protocol) header, static header + * size: 4 bytes + */ +struct tcpr_802_1x_hdr +{ + u_int8_t dot1x_version; /**< protocol version */ + u_int8_t dot1x_type; /**< frame type */ +#define TCPR_802_1X_PACKET 0x00 /**< 802.1x packet */ +#define TCPR_802_1X_START 0x01 /**< 802.1x start */ +#define TCPR_802_1X_LOGOFF 0x02 /**< 802.1x logoff */ +#define TCPR_802_1X_KEY 0x03 /**< 802.1x key */ +#define TCPR_802_1X_ENCASFAL 0x04 /**< 802.1x encasfal */ + u_int16_t dot1x_length; /**< total frame length */ +}; + +/* + * IEEE 802.2 LLC header + * Link Layer Control + * static header size: 4 bytes + */ +struct tcpr_802_2_hdr +{ + u_int8_t llc_dsap; /* destination service access point */ + u_int8_t llc_ssap; /* source service access point */ +#define TCPR_SAP_STP 0x42 +#define TCPR_SAP_SNAP 0xaa + u_int16_t llc_control; /* control field */ +}; + + +/* + * IEEE 802.2 LLC/SNAP header + * SubNetwork Attachment Point + * static header size: 8 bytes + */ +struct tcpr_802_2snap_hdr +{ + u_int8_t snap_dsap; /* destination service access point */ + u_int8_t snap_ssap; /* destination service access point */ + u_int8_t snap_control; /* control field */ + u_int8_t snap_oui[3]; /* OUI */ + u_int16_t snap_type; /* type */ +}; + + +/* + * 802.3 header + * IEEE Ethernet + * Static header size: 14 bytes + */ +struct tcpr_802_3_hdr +{ + u_int8_t _802_3_dhost[ETHER_ADDR_LEN];/* destination ethernet address */ + u_int8_t _802_3_shost[ETHER_ADDR_LEN];/* source ethernet address */ + u_int16_t _802_3_len; /* packet type ID */ +}; + + +/* + * ARP header + * Address Resolution Protocol + * Base header size: 8 bytes + */ +struct tcpr_arp_hdr +{ + u_int16_t ar_hrd; /* format of hardware address */ +#define ARPHRD_NETROM 0 /* from KA9Q: NET/ROM pseudo */ +#define ARPHRD_ETHER 1 /* Ethernet 10Mbps */ +#define ARPHRD_EETHER 2 /* Experimental Ethernet */ +#define ARPHRD_AX25 3 /* AX.25 Level 2 */ +#define ARPHRD_PRONET 4 /* PROnet token ring */ +#define ARPHRD_CHAOS 5 /* Chaosnet */ +#define ARPHRD_IEEE802 6 /* IEEE 802.2 Ethernet/TR/TB */ +#define ARPHRD_ARCNET 7 /* ARCnet */ +#define ARPHRD_APPLETLK 8 /* APPLEtalk */ +#define ARPHRD_LANSTAR 9 /* Lanstar */ +#define ARPHRD_DLCI 15 /* Frame Relay DLCI */ +#define ARPHRD_ATM 19 /* ATM */ +#define ARPHRD_METRICOM 23 /* Metricom STRIP (new IANA id) */ +#define ARPHRD_IPSEC 31 /* IPsec tunnel */ + u_int16_t ar_pro; /* format of protocol address */ + u_int8_t ar_hln; /* length of hardware address */ + u_int8_t ar_pln; /* length of protocol addres */ + u_int16_t ar_op; /* operation type */ +#define ARPOP_REQUEST 1 /* req to resolve address */ +#define ARPOP_REPLY 2 /* resp to previous request */ +#define ARPOP_REVREQUEST 3 /* req protocol address given hardware */ +#define ARPOP_REVREPLY 4 /* resp giving protocol address */ +#define ARPOP_INVREQUEST 8 /* req to identify peer */ +#define ARPOP_INVREPLY 9 /* resp identifying peer */ + /* address information allocated dynamically */ +}; + +/* + * BGP4 header + * Border Gateway Protocol 4 + * Base header size : 19 bytes + */ +struct tcpr_bgp4_header_hdr +{ +#define TCPR_BGP4_MARKER_SIZE 16 + u_int8_t marker[TCPR_BGP4_MARKER_SIZE]; + u_int16_t len; + u_int8_t type; +#define TCPR_BGP4_OPEN 1 +#define TCPR_BGP4_UPDATE 2 +#define TCPR_BGP4_NOTIFICATION 3 +#define TCPR_BGP4_KEEPALIVE 4 +}; + +/* + * BGP4 open header + * Border Gateway Protocol 4 + * Base header size : 10 bytes + */ +struct tcpr_bgp4_open_hdr +{ + u_int8_t version; + u_int16_t src_as; + u_int16_t hold_time; + u_int32_t bgp_id; + u_int8_t opt_len; +}; + +/* + * BGP4 notification message + * + * Border Gateway Protocol 4 + * Base header size : 2 bytes + * + * Use payload if you need data + */ +struct tcpr_bgp4_notification_hdr +{ +#define TCPR_BGP4_MESSAGE_HEADER_ERROR 1 +#define TCPR_BGP4_OPEN_MESSAGE_ERROR 2 +#define TCPR_BGP4_UPDATE_MESSAGE_ERROR 3 +#define TCPR_BGP4_HOLD_TIMER_EXPIRED 4 +#define TCPR_BGP4_FINITE_STATE__ERROR 5 +#define TCPR_BGP4_CEASE 6 + u_int8_t err_code; + +/* Message Header Error subcodes */ +#define TCPR_BGP4_CONNECTION_NOT_SYNCHRONIZED 1 +#define TCPR_BGP4_BAD_MESSAGE_LENGTH 2 +#define TCPR_BGP4_BAD_MESSAGE_TYPE 3 +/* OPEN Message Error subcodes */ +#define TCPR_BGP4_UNSUPPORTED_VERSION_NUMBER 1 +#define TCPR_BGP4_BAD_PEER_AS 2 +#define TCPR_BGP4_BAD_BGP_IDENTIFIER 3 +#define TCPR_BGP4_UNSUPPORTED_OPTIONAL_PARAMETER 4 +#define TCPR_BGP4_AUTHENTICATION_FAILURE 5 +#define TCPR_BGP4_UNACCEPTABLE_HOLD_TIME 6 +/* UPDATE Message Error subcodes */ +#define TCPR_BGP4_MALFORMED_ATTRIBUTE_LIST +#define TCPR_BGP4_UNRECOGNIZED_WELL_KNOWN_ATTRIBUTE +#define TCPR_BGP4_MISSING_WELL_KNOWN_ATTRIBUTE +#define TCPR_BGP4_ATTRIBUTE_FLAGS_ERROR +#define TCPR_BGP4_ATTRIBUTE_LENGTH_ERROR +#define TCPR_BGP4_INVALID_ORIGIN_ATTRIBUTE +#define TCPR_BGP4_AS_ROUTING_LOOP +#define TCPR_BGP4_INVALID_NEXT_HOP_ATTRIBUTE +#define TCPR_BGP4_OPTIONAL_ATTRIBUTE_ERROR +#define TCPR_BGP4_INVALID_NETWORK_FIELD +#define TCPR_BGP4_MALFORMED_AS_PATH + u_int8_t err_subcode; +}; + + + +/* + * CDP header + * Cisco Discovery Protocol + * Base header size: 8 bytes + */ + +/* + * For checksum stuff -- IANA says 135-254 is "unassigned" as of 12.2001. + * Let's hope this one stays that way for a while! + */ +#define TCPR_PROTO_CDP 200 +struct tcpr_cdp_hdr +{ + u_int8_t cdp_version; /* version (should always be 0x01) */ + u_int8_t cdp_ttl; /* time reciever should hold info in this packet */ + u_int16_t cdp_sum; /* checksum */ + u_int16_t cdp_type; /* type */ +#define TCPR_CDP_DEVID 0x1 /* device id */ +#define TCPR_CDP_ADDRESS 0x2 /* address */ +#define TCPR_CDP_PORTID 0x3 /* port id */ +#define TCPR_CDP_CAPABIL 0x4 /* capabilities */ +#define TCPR_CDP_VERSION 0x5 /* version */ +#define TCPR_CDP_PLATFORM 0x6 /* platform */ +#define TCPR_CDP_IPPREFIX 0x7 /* ip prefix */ + u_int16_t cdp_len; /* type + length + value */ + /* value information done dynamically */ + +/* CDP capabilities */ +#define TCPR_CDP_CAP_L3R 0x01/* performs level 3 routing */ +#define TCPR_CDP_CAP_L2B 0x02/* performs level 2 transparent bridging */ +#define TCPR_CDP_CAP_L2SRB 0x04/* performs level 2 sourceroute bridging */ +#define TCPR_CDP_CAP_L2S 0x08/* performs level 2 switching */ +#define TCPR_CDP_CAP_SR 0x10/* sends and recieves packets on a network */ +#define TCPR_CDP_CAP_NOI 0x20/* does not forward IGMP on non-router ports */ +#define TCPR_CDP_CAP_L1F 0x40/* provides level 1 functionality */ +}; + + +/* + * Used as an overlay for type/len/values + */ +struct tcpr_cdp_value_hdr +{ + u_int16_t cdp_type; + u_int16_t cdp_len; +}; + + +/* + * DHCP header + * Dynamic Host Configuration Protocol + * Static header size: f0 bytes + */ +struct tcpr_dhcpv4_hdr +{ + u_int8_t dhcp_opcode; /* opcode */ +#define TCPR_DHCP_REQUEST 0x1 +#define TCPR_DHCP_REPLY 0x2 + u_int8_t dhcp_htype; /* hardware address type */ + u_int8_t dhcp_hlen; /* hardware address length */ + u_int8_t dhcp_hopcount; /* used by proxy servers */ + u_int32_t dhcp_xid; /* transaction ID */ + u_int16_t dhcp_secs; /* number of seconds since trying to bootstrap */ + u_int16_t dhcp_flags; /* flags for DHCP, unused for BOOTP */ + u_int32_t dhcp_cip; /* client's IP */ + u_int32_t dhcp_yip; /* your IP */ + u_int32_t dhcp_sip; /* server's IP */ + u_int32_t dhcp_gip; /* gateway IP */ + u_int8_t dhcp_chaddr[16]; /* client hardware address */ + u_int8_t dhcp_sname[64]; /* server host name */ + u_int8_t dhcp_file[128]; /* boot file name */ + u_int32_t dhcp_magic; /* BOOTP magic header */ +#define DHCP_MAGIC 0x63825363 +#define TCPR_BOOTP_MIN_LEN 0x12c +#define TCPR_DHCP_PAD 0x00 +#define TCPR_DHCP_SUBNETMASK 0x01 +#define TCPR_DHCP_TIMEOFFSET 0x02 +#define TCPR_DHCP_ROUTER 0x03 +#define TCPR_DHCP_TIMESERVER 0x04 +#define TCPR_DHCP_NAMESERVER 0x05 +#define TCPR_DHCP_DNS 0x06 +#define TCPR_DHCP_LOGSERV 0x07 +#define TCPR_DHCP_COOKIESERV 0x08 +#define TCPR_DHCP_LPRSERV 0x09 +#define TCPR_DHCP_IMPSERV 0x0a +#define TCPR_DHCP_RESSERV 0x0b +#define TCPR_DHCP_HOSTNAME 0x0c +#define TCPR_DHCP_BOOTFILESIZE 0x0d +#define TCPR_DHCP_DUMPFILE 0x0e +#define TCPR_DHCP_DOMAINNAME 0x0f +#define TCPR_DHCP_SWAPSERV 0x10 +#define TCPR_DHCP_ROOTPATH 0x11 +#define TCPR_DHCP_EXTENPATH 0x12 +#define TCPR_DHCP_IPFORWARD 0x13 +#define TCPR_DHCP_SRCROUTE 0x14 +#define TCPR_DHCP_POLICYFILTER 0x15 +#define TCPR_DHCP_MAXASMSIZE 0x16 +#define TCPR_DHCP_IPTTL 0x17 +#define TCPR_DHCP_MTUTIMEOUT 0x18 +#define TCPR_DHCP_MTUTABLE 0x19 +#define TCPR_DHCP_MTUSIZE 0x1a +#define TCPR_DHCP_LOCALSUBNETS 0x1b +#define TCPR_DHCP_BROADCASTADDR 0x1c +#define TCPR_DHCP_DOMASKDISCOV 0x1d +#define TCPR_DHCP_MASKSUPPLY 0x1e +#define TCPR_DHCP_DOROUTEDISC 0x1f +#define TCPR_DHCP_ROUTERSOLICIT 0x20 +#define TCPR_DHCP_STATICROUTE 0x21 +#define TCPR_DHCP_TRAILERENCAP 0x22 +#define TCPR_DHCP_ARPTIMEOUT 0x23 +#define TCPR_DHCP_ETHERENCAP 0x24 +#define TCPR_DHCP_TCPTTL 0x25 +#define TCPR_DHCP_TCPKEEPALIVE 0x26 +#define TCPR_DHCP_TCPALIVEGARBAGE 0x27 +#define TCPR_DHCP_NISDOMAIN 0x28 +#define TCPR_DHCP_NISSERVERS 0x29 +#define TCPR_DHCP_NISTIMESERV 0x2a +#define TCPR_DHCP_VENDSPECIFIC 0x2b +#define TCPR_DHCP_NBNS 0x2c +#define TCPR_DHCP_NBDD 0x2d +#define TCPR_DHCP_NBTCPIP 0x2e +#define TCPR_DHCP_NBTCPSCOPE 0x2f +#define TCPR_DHCP_XFONT 0x30 +#define TCPR_DHCP_XDISPLAYMGR 0x31 +#define TCPR_DHCP_DISCOVERADDR 0x32 +#define TCPR_DHCP_LEASETIME 0x33 +#define TCPR_DHCP_OPTIONOVERLOAD 0x34 +#define TCPR_DHCP_MESSAGETYPE 0x35 +#define TCPR_DHCP_SERVIDENT 0x36 +#define TCPR_DHCP_PARAMREQUEST 0x37 +#define TCPR_DHCP_MESSAGE 0x38 +#define TCPR_DHCP_MAXMSGSIZE 0x39 +#define TCPR_DHCP_RENEWTIME 0x3a +#define TCPR_DHCP_REBINDTIME 0x3b +#define TCPR_DHCP_CLASSSID 0x3c +#define TCPR_DHCP_CLIENTID 0x3d +#define TCPR_DHCP_NISPLUSDOMAIN 0x40 +#define TCPR_DHCP_NISPLUSSERVERS 0x41 +#define TCPR_DHCP_MOBILEIPAGENT 0x44 +#define TCPR_DHCP_SMTPSERVER 0x45 +#define TCPR_DHCP_POP3SERVER 0x46 +#define TCPR_DHCP_NNTPSERVER 0x47 +#define TCPR_DHCP_WWWSERVER 0x48 +#define TCPR_DHCP_FINGERSERVER 0x49 +#define TCPR_DHCP_IRCSERVER 0x4a +#define TCPR_DHCP_STSERVER 0x4b +#define TCPR_DHCP_STDASERVER 0x4c +#define TCPR_DHCP_END 0xff + +#define TCPR_DHCP_MSGDISCOVER 0x01 +#define TCPR_DHCP_MSGOFFER 0x02 +#define TCPR_DHCP_MSGREQUEST 0x03 +#define TCPR_DHCP_MSGDECLINE 0x04 +#define TCPR_DHCP_MSGACK 0x05 +#define TCPR_DHCP_MSGNACK 0x06 +#define TCPR_DHCP_MSGRELEASE 0x07 +#define TCPR_DHCP_MSGINFORM 0x08 +}; + + +/* + * Base DNSv4 header + * Domain Name System + * Base header size: 12/14 bytes + */ +struct tcpr_dnsv4_hdr +{ + u_int16_t h_len; /* length of the packet - only used with TCP */ + u_int16_t id; /* DNS packet ID */ + u_int16_t flags; /* DNS flags */ + u_int16_t num_q; /* Number of questions */ + u_int16_t num_answ_rr; /* Number of answer resource records */ + u_int16_t num_auth_rr; /* Number of authority resource records */ + u_int16_t num_addi_rr; /* Number of additional resource records */ +}; + +#define TCPR_DNS_H TCPR_UDP_DNSV4_H +struct tcpr_dnsv4udp_hdr +{ + u_int16_t id; /* DNS packet ID */ + u_int16_t flags; /* DNS flags */ + u_int16_t num_q; /* Number of questions */ + u_int16_t num_answ_rr; /* Number of answer resource records */ + u_int16_t num_auth_rr; /* Number of authority resource records */ + u_int16_t num_addi_rr; /* Number of additional resource records */ +}; + +/* + * Ethernet II header + * Static header size: 14 bytes + */ +struct tcpr_ethernet_hdr +{ + u_int8_t ether_dhost[ETHER_ADDR_LEN];/* destination ethernet address */ + u_int8_t ether_shost[ETHER_ADDR_LEN];/* source ethernet address */ + u_int16_t ether_type; /* protocol */ +}; + +#ifndef ETHERTYPE_PUP +#define ETHERTYPE_PUP 0x0200 /* PUP protocol */ +#endif +#ifndef ETHERTYPE_IP +#define ETHERTYPE_IP 0x0800 /* IP protocol */ +#endif +#ifndef ETHERTYPE_ARP +#define ETHERTYPE_ARP 0x0806 /* addr. resolution protocol */ +#endif +#ifndef ETHERTYPE_REVARP +#define ETHERTYPE_REVARP 0x8035 /* reverse addr. resolution protocol */ +#endif +#ifndef ETHERTYPE_VLAN +#define ETHERTYPE_VLAN 0x8100 /* IEEE 802.1Q VLAN tagging */ +#endif +#ifndef ETHERTYPE_EAP +#define ETHERTYPE_EAP 0x888e /* IEEE 802.1X EAP authentication */ +#endif +#ifndef ETHERTYPE_MPLS +#define ETHERTYPE_MPLS 0x8847 /* MPLS */ +#endif +#ifndef ETHERTYPE_LOOPBACK +#define ETHERTYPE_LOOPBACK 0x9000 /* used to test interfaces */ +#endif +#ifndef ETHERTYPE_IP6 +#define ETHERTYPE_IP6 0x86DD /* IPv6 */ +#endif + +struct tcpr_ether_addr +{ + u_int8_t ether_addr_octet[6]; /* Ethernet address */ +}; + +/* + * Fiber Distributed Data Interface header + * + * Static header size: 21 bytes (LLC and 48-bit address addr only) + * + * Note: Organization field is 3 bytes which throws off the + * alignment of type. Therefore fddi_type (19 bytes in) + * is specified as two u_int8_ts. + */ +struct tcpr_fddi_hdr +{ + u_int8_t fddi_frame_control; /* Class/Format/Priority */ +#define TCPR_FDDI_LLC_FRAME 0x10 +#define TCPR_FDDI_48BIT_ADDR 0x40 +#define TCPR_FDDI_FC_REQD TCPR_FDDI_LLC_FRAME | TCPR_FDDI_48BIT_ADDR + u_int8_t fddi_dhost[FDDI_ADDR_LEN]; /* destination fddi address */ + u_int8_t fddi_shost[FDDI_ADDR_LEN]; /* source fddi address */ + u_int8_t fddi_llc_dsap; /* DSAP */ + u_int8_t fddi_llc_ssap; /* SSAP */ + u_int8_t fddi_llc_control_field; /* Class/Format/Priority */ + u_int8_t fddi_llc_org_code[TCPR_ORG_CODE_SIZE]; /* Organization Code 3-bytes */ + u_int8_t fddi_type; /* Protocol Type */ + u_int8_t fddi_type1; /* see note above. */ +#define FDDI_TYPE_IP 0x0800 /* IP protocol */ +#define FDDI_TYPE_ARP 0x0806 /* addr. resolution protocol */ +#define FDDI_TYPE_REVARP 0x8035 /* reverse addr. resolution protocol */ +}; + + +struct tcpr_fddi_addr +{ + u_int8_t fddi_addr_octet[6]; /* FDDI address */ +}; + + +/* + * GRE header - RFC 1701 & 2637 + * Generic Routing Encapsulation (GRE) + * Base header size: 4 bytes + */ +struct tcpr_gre_hdr +{ + u_int16_t flags_ver; +#define GRE_CSUM 0x8000 +#define GRE_ROUTING 0x4000 +#define GRE_KEY 0x2000 +#define GRE_SEQ 0x1000 +#define GRE_STRICT 0x0800 +#define GRE_REC 0x0700 +#define GRE_ACK 0x0080 + +#define GRE_FLAGS_MASK 0x00F8 +#define GRE_VERSION_MASK 0x0007 + +#define GRE_VERSION_0 0x0000 +#define GRE_VERSION_1 0x0001 + + u_int16_t type; +#define GRE_SNA 0x0004 +#define GRE_OSI_NETWORK_LAYER 0x00FE +#define GRE_PUP 0x0200 +#define GRE_XNS 0x0600 +#define GRE_IP 0x0800 +#define GRE_CHAOS 0x0804 +#define GRE_RFC_826_ARP 0x0806 +#define GRE_FRAME_RELAY_ARP 0x0808 +#define GRE_VINES 0x0BAD +#define GRE_VINES_ECHO 0x0BAE +#define GRE_VINES_LOOPBACK 0x0BAF +#define GRE_DECNET 0x6003 +#define GRE_TRANSPARENT_ETHERNET_BRIDGING 0x6558 +#define GRE_RAW_FRAME_RELAY 0x6559 +#define GRE_APOLLO_DOMAIN 0x8019 +#define GRE_ETHERTALK 0x809B +#define GRE_NOVELL_IPX 0x8137 +#define GRE_RFC_1144_TCP_IP_COMPRESSION 0x876B +#define GRE_IP_AUTONOMOUS_SYSTEMS 0x876C +#define GRE_SECURE_DATA 0x876D +#define GRE_PPP 0x880b /* taken from RFC 2637 */ + + union { + struct { + u_int16_t sum; /* optional */ + u_int16_t offset; /* optional */ + u_int32_t key; /* optional */ + u_int32_t seq; /* optional */ + } _gre; + + struct { + u_int16_t payload_s; /* optional */ + u_int16_t callID; /* optional */ + u_int32_t seq; /* optional */ + u_int32_t ack; /* optional */ + } _egre; + }_data; + +#define gre_sum _data._gre.sum +#define gre_offset _data._gre.offset +#define gre_key _data._gre.key +#define gre_seq _data._gre.seq + +#define egre_payload_s _data._egre.payload_s +#define egre_callID _data._egre.callID +#define egre_seq _data._egre.seq +#define egre_ack _data._egre.ack +}; + + +#ifndef IPPROTO_GRE +#define IPPROTO_GRE 47 +#endif + +/* + * Source Route Entries (SRE) + * This is used for GRE as the Routing field is a list of SREs - RFC 1701 + * Base header size: 4 bytes + */ +struct tcpr_gre_sre_hdr +{ + u_int16_t af; /* address familly */ + u_int8_t sre_offset; + u_int8_t sre_length; + u_int8_t *routing; +}; + + +/* + * IPv4 header + * Internet Protocol, version 4 + * Static header size: 20 bytes + */ +struct tcpr_ipv4_hdr +{ +#ifdef WORDS_BIGENDIAN + u_int8_t ip_v:4, /* version */ + ip_hl:4; /* header length */ +#else + u_int8_t ip_hl:4, /* header length */ + ip_v:4; /* version */ +#endif + u_int8_t ip_tos; /* type of service */ +#ifndef IPTOS_LOWDELAY +#define IPTOS_LOWDELAY 0x10 +#endif +#ifndef IPTOS_THROUGHPUT +#define IPTOS_THROUGHPUT 0x08 +#endif +#ifndef IPTOS_RELIABILITY +#define IPTOS_RELIABILITY 0x04 +#endif +#ifndef IPTOS_LOWCOST +#define IPTOS_LOWCOST 0x02 +#endif + u_int16_t ip_len; /* total length */ + u_int16_t ip_id; /* identification */ + u_int16_t ip_off; +#ifndef IP_RF +#define IP_RF 0x8000 /* reserved fragment flag */ +#endif +#ifndef IP_DF +#define IP_DF 0x4000 /* dont fragment flag */ +#endif +#ifndef IP_MF +#define IP_MF 0x2000 /* more fragments flag */ +#endif +#ifndef IP_OFFMASK +#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ +#endif + u_int8_t ip_ttl; /* time to live */ + u_int8_t ip_p; /* protocol */ + u_int16_t ip_sum; /* checksum */ + struct in_addr ip_src, ip_dst; /* source and dest address */ +}; + +/* + * IP options + */ +#ifndef IPOPT_EOL +#define IPOPT_EOL 0 /* end of option list */ +#endif +#ifndef IPOPT_NOP +#define IPOPT_NOP 1 /* no operation */ +#endif +#ifndef IPOPT_RR +#define IPOPT_RR 7 /* record packet route */ +#endif +#ifndef IPOPT_TS +#define IPOPT_TS 68 /* timestamp */ +#endif +#ifndef IPOPT_SECURITY +#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */ +#endif +#ifndef IPOPT_LSRR +#define IPOPT_LSRR 131 /* loose source route */ +#endif +#ifndef IPOPT_SATID +#define IPOPT_SATID 136 /* satnet id */ +#endif +#ifndef IPOPT_SSRR +#define IPOPT_SSRR 137 /* strict source route */ +#endif + +struct tcpr_in6_addr +{ + union + { + u_int8_t __u6_addr8[16]; + u_int16_t __u6_addr16[8]; + u_int32_t __u6_addr32[4]; + } __u6_addr; /* 128-bit IP6 address */ +}; +#define tcpr_s6_addr __u6_addr.__u6_addr8 +#define tcpr_s6_addr8 __u6_addr.__u6_addr8 +#define tcpr_s6_addr16 __u6_addr.__u6_addr16 +#define tcpr_s6_addr32 __u6_addr.__u6_addr32 + +/* + * IPv6 header + * Internet Protocol, version 6 + * Static header size: 40 bytes + */ +struct tcpr_ipv6_hdr +{ + u_int8_t ip_flags[4]; /* version, traffic class, flow label */ + u_int16_t ip_len; /* total length */ + u_int8_t ip_nh; /* next header */ + u_int8_t ip_hl; /* hop limit */ + struct tcpr_in6_addr ip_src, ip_dst; /* source and dest address */ +}; + +struct tcpr_ipv6_ext_hdr_base +{ + u_int8_t ip_nh; /* next header */ + u_int8_t ip_len; /* length of header in 8 octet units (sans 1st) */ + /* some more bytes are always here, but we don't know what kind */ +}; + +#define TCPR_IPV6_NH_NO_NEXT 59 +#define TCPR_IPV6_NH_IPV6 41 +#define TCPR_IPV6_NH_ESP 50 +#define TCPR_IPV6_NH_AH 51 + +/* + * IPv6 frag header + * Internet Protocol, version 6 + * Static header size: 8 bytes + */ +#define TCPR_IPV6_NH_FRAGMENT 44 +struct tcpr_ipv6_frag_hdr +{ + u_int8_t ip_nh; /* next header */ + u_int8_t ip_reserved; /* reserved */ + u_int16_t ip_frag; /* fragmentation stuff */ + u_int32_t ip_id; /* id */ +}; + +/* + * IPv6 routing header + * Internet Protocol, version 6 + * Base header size: 4 bytes + */ +#define TCPR_IPV6_NH_ROUTING 43 +struct tcpr_ipv6_routing_hdr +{ + u_int8_t ip_nh; /* next header */ + u_int8_t ip_len; /* length of header in 8 octet units (sans 1st) */ + u_int8_t ip_rtype; /* routing type */ + u_int8_t ip_segments; /* segments left */ + /* routing information allocated dynamically */ +}; + +/* + * IPv6 destination options header + * Internet Protocol, version 6 + * Base header size: 2 bytes + */ +#define TCPR_IPV6_NH_DESTOPTS 60 +struct tcpr_ipv6_destopts_hdr +{ + u_int8_t ip_nh; /* next header */ + u_int8_t ip_len; /* length of header in 8 octet units (sans 1st) */ + /* destination options information allocated dynamically */ +}; + +/* + * IPv6 hop by hop options header + * Internet Protocol, version 6 + * Base header size: 2 bytes + */ +#define TCPR_IPV6_NH_HBH 0 +struct tcpr_ipv6_hbhopts_hdr +{ + u_int8_t ip_nh; /* next header */ + u_int8_t ip_len; /* length of header in 8 octet units (sans 1st) */ + /* destination options information allocated dynamically */ +}; + +/* + * ICMP6 header + * Internet Control Message Protocol v6 + * Base header size: 8 bytes + */ +#ifndef IPPROTO_ICMP6 +#define IPPROTO_ICMP6 0x3a +#endif +struct tcpr_icmpv6_hdr +{ + u_int8_t icmp_type; /* ICMP type */ +#ifndef ICMP6_ECHO +#define ICMP6_ECHO 128 +#endif +#ifndef ICMP6_ECHOREPLY +#define ICMP6_ECHOREPLY 129 +#endif +#ifndef ICMP6_UNREACH +#define ICMP6_UNREACH 1 +#endif +#ifndef ICMP6_PKTTOOBIG +#define ICMP6_PKTTOOBIG 2 +#endif +#ifndef ICMP6_TIMXCEED +#define ICMP6_TIMXCEED 3 +#endif +#ifndef ICMP6_PARAMPROB +#define ICMP6_PARAMPROB 4 +#endif + u_int8_t icmp_code; /* ICMP code */ + u_int16_t icmp_sum; /* ICMP Checksum */ + u_int16_t id; /* ICMP id */ + u_int16_t seq; /* ICMP sequence number */ +}; + + + +/* + * ICMP header + * Internet Control Message Protocol + * Base header size: 4 bytes + */ +struct tcpr_icmpv4_hdr +{ + u_int8_t icmp_type; /* ICMP type */ +#ifndef ICMP_ECHOREPLY +#define ICMP_ECHOREPLY 0 +#endif +#ifndef ICMP_UNREACH +#define ICMP_UNREACH 3 +#endif +#ifndef ICMP_SOURCEQUENCH +#define ICMP_SOURCEQUENCH 4 +#endif +#ifndef ICMP_REDIRECT +#define ICMP_REDIRECT 5 +#endif +#ifndef ICMP_ECHO +#define ICMP_ECHO 8 +#endif +#ifndef ICMP_ROUTERADVERT +#define ICMP_ROUTERADVERT 9 +#endif +#ifndef ICMP_ROUTERSOLICIT +#define ICMP_ROUTERSOLICIT 10 +#endif +#ifndef ICMP_TIMXCEED +#define ICMP_TIMXCEED 11 +#endif +#ifndef ICMP_PARAMPROB +#define ICMP_PARAMPROB 12 +#endif +#ifndef ICMP_TSTAMP +#define ICMP_TSTAMP 13 +#endif +#ifndef ICMP_TSTAMPREPLY +#define ICMP_TSTAMPREPLY 14 +#endif +#ifndef ICMP_IREQ +#define ICMP_IREQ 15 +#endif +#ifndef ICMP_IREQREPLY +#define ICMP_IREQREPLY 16 +#endif +#ifndef ICMP_MASKREQ +#define ICMP_MASKREQ 17 +#endif +#ifndef ICMP_MASKREPLY +#define ICMP_MASKREPLY 18 +#endif + u_int8_t icmp_code; /* ICMP code */ +#ifndef ICMP_UNREACH_NET +#define ICMP_UNREACH_NET 0 +#endif +#ifndef ICMP_UNREACH_HOST +#define ICMP_UNREACH_HOST 1 +#endif +#ifndef ICMP_UNREACH_PROTOCOL +#define ICMP_UNREACH_PROTOCOL 2 +#endif +#ifndef ICMP_UNREACH_PORT +#define ICMP_UNREACH_PORT 3 +#endif +#ifndef ICMP_UNREACH_NEEDFRAG +#define ICMP_UNREACH_NEEDFRAG 4 +#endif +#ifndef ICMP_UNREACH_SRCFAIL +#define ICMP_UNREACH_SRCFAIL 5 +#endif +#ifndef ICMP_UNREACH_NET_UNKNOWN +#define ICMP_UNREACH_NET_UNKNOWN 6 +#endif +#ifndef ICMP_UNREACH_HOST_UNKNOWN +#define ICMP_UNREACH_HOST_UNKNOWN 7 +#endif +#ifndef ICMP_UNREACH_ISOLATED +#define ICMP_UNREACH_ISOLATED 8 +#endif +#ifndef ICMP_UNREACH_NET_PROHIB +#define ICMP_UNREACH_NET_PROHIB 9 +#endif +#ifndef ICMP_UNREACH_HOST_PROHIB +#define ICMP_UNREACH_HOST_PROHIB 10 +#endif +#ifndef ICMP_UNREACH_TOSNET +#define ICMP_UNREACH_TOSNET 11 +#endif +#ifndef ICMP_UNREACH_TOSHOST +#define ICMP_UNREACH_TOSHOST 12 +#endif +#ifndef ICMP_UNREACH_FILTER_PROHIB +#define ICMP_UNREACH_FILTER_PROHIB 13 +#endif +#ifndef ICMP_UNREACH_HOST_PRECEDENCE +#define ICMP_UNREACH_HOST_PRECEDENCE 14 +#endif +#ifndef ICMP_UNREACH_PRECEDENCE_CUTOFF +#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 +#endif +#ifndef ICMP_REDIRECT_NET +#define ICMP_REDIRECT_NET 0 +#endif +#ifndef ICMP_REDIRECT_HOST +#define ICMP_REDIRECT_HOST 1 +#endif +#ifndef ICMP_REDIRECT_TOSNET +#define ICMP_REDIRECT_TOSNET 2 +#endif +#ifndef ICMP_REDIRECT_TOSHOST +#define ICMP_REDIRECT_TOSHOST 3 +#endif +#ifndef ICMP_TIMXCEED_INTRANS +#define ICMP_TIMXCEED_INTRANS 0 +#endif +#ifndef ICMP_TIMXCEED_REASS +#define ICMP_TIMXCEED_REASS 1 +#endif +#ifndef ICMP_PARAMPROB_OPTABSENT +#define ICMP_PARAMPROB_OPTABSENT 1 +#endif + + u_int16_t icmp_sum; /* ICMP Checksum */ + + union + { + struct + { + u_int16_t id; /* ICMP id */ + u_int16_t seq;/* ICMP sequence number */ + } echo; + +#undef icmp_id +#undef icmp_seq +#define icmp_id hun.echo.id +#define icmp_seq hun.echo.seq + + u_int32_t gateway; /* gateway host */ + struct + { + u_int16_t pad;/* padding */ + u_int16_t mtu;/* MTU size */ + } frag; + } hun; + union + { + struct + { + n_time its_otime; + n_time its_rtime; + n_time its_ttime; + } ts; + struct + { + struct tcpr_ipv4_hdr idi_ip; + /* options and then 64 bits of data */ + } ip; + u_int32_t mask; + int8_t data[1]; + +#undef icmp_mask +#define icmp_mask dun.mask +#undef icmp_data +#define icmp_data dun.data + +#undef icmp_otime +#define icmp_otime dun.ts.its_otime +#undef icmp_rtime +#define icmp_rtime dun.ts.its_rtime +#undef icmp_ttime +#define icmp_ttime dun.ts.its_ttime + }dun; +}; + + +/* + * IGMP header + * Internet Group Message Protocol + * Static header size: 8 bytes + */ +struct tcpr_igmp_hdr +{ + u_int8_t igmp_type; /* IGMP type */ +#ifndef IGMP_MEMBERSHIP_QUERY +#define IGMP_MEMBERSHIP_QUERY 0x11 /* membership query */ +#endif +#ifndef IGMP_V1_MEMBERSHIP_REPORT +#define IGMP_V1_MEMBERSHIP_REPORT 0x12 /* Ver. 1 membership report */ +#endif +#ifndef IGMP_V2_MEMBERSHIP_REPORT +#define IGMP_V2_MEMBERSHIP_REPORT 0x16 /* Ver. 2 membership report */ +#endif +#ifndef IGMP_LEAVE_GROUP +#define IGMP_LEAVE_GROUP 0x17 /* Leave-group message */ +#endif + u_int8_t igmp_code; /* IGMP code */ + u_int16_t igmp_sum; /* IGMP checksum */ + struct in_addr igmp_group;/* IGMP host IP */ +}; + + +/* + * IPSEC header + * Internet Protocol Security Protocol + * Encapsulating Security Payload Header Static header size: 12 bytes + * Encapsulating Security Payload Footer Base header size: 2 bytes + * Authentication Header Static Size: 16 bytes + */ +#ifndef IPPROTO_ESP +#define IPPROTO_ESP 50 /* not everyone's got this */ +#endif +struct tcpr_esp_hdr +{ + u_int32_t esp_spi; /* security parameter index */ + u_int32_t esp_seq; /* ESP sequence number */ + u_int32_t esp_iv; /* initialization vector */ +}; + +struct tcpr_esp_ftr +{ + u_int8_t esp_pad_len; /* padding length */ + u_int8_t esp_nh; /* next header pointer */ + int8_t *esp_auth; /* authentication data */ +}; + +#ifndef IPPROTO_AH +#define IPPROTO_AH 51 /* not everyone's got this */ +#endif +struct tcpr_ah_hdr +{ + u_int8_t ah_nh; /* next header */ + u_int8_t ah_len; /* payload length */ + u_int16_t ah_res; /* reserved */ + u_int32_t ah_spi; /* security parameter index */ + u_int32_t ah_seq; /* AH sequence number */ + u_int32_t ah_auth; /* authentication data */ +}; + + +/* + * ISL header + * Cisco Inter-Switch Link + * Static header size: 26 bytes + */ +/* + * For checksum stuff -- IANA says 135-254 is "unassigned" as of 12.2001. + * Let's hope this one stays that way for a while! + */ +#define TCPR_PROTO_ISL 201 +struct tcpr_isl_hdr +{ + u_int8_t isl_dhost[5]; /* destination address "01:00:0c:00:00" */ +#ifdef WORDS_BIGENDIAN + u_int8_t isl_user:4, /* user defined bits */ + isl_type:4; /* type of frame */ +#else + u_int8_t isl_type:4, /* type of frame */ + isl_user:4; /* user defined bits */ +#endif + u_int8_t isl_shost[6]; /* source address */ + u_int16_t isl_len; /* total length of packet - 18 bytes */ + u_int8_t isl_snap[6]; /* 0xaaaa03 + vendor code */ + u_int16_t isl_vid; /* 15 bit VLAN ID, 1 bit BPDU / CDP indicator */ + u_int16_t isl_index; /* port index */ + u_int16_t isl_reserved; /* used for FDDI and token ring */ + /* ethernet frame and 4 byte isl crc */ +}; + +#ifndef IPPROTO_OSPF +#define IPPROTO_OSPF 89 /* not everyone's got this */ +#endif +#define IPPROTO_OSPF_LSA 890 /* made this up. Hope it's unused */ +#define TCPR_MODX 4102 /* used in LSA checksum */ + +/* + * Options used in multiple OSPF packets + * More info can be found in section A.2 of RFC 2328. + */ +#define TCPR_OPT_EBIT 0x02 /* describes the way AS-external-LSAs are flooded */ +#define TCPR_OPT_MCBIT 0x04 /* whether or not IP multicast dgrams are fwdd */ +#define TCPR_OPT_NPBIT 0x08 /* describes handling of type-7 LSAs */ +#define TCPR_OPT_EABIT 0x10 /* rtr's willingness to send/recv EA-LSAs */ +#define TCPR_OPT_DCBIT 0x20 /* describes handling of demand circuits */ + + +/* + * MPLS header + * Multi-Protocol Label Switching + * Static header size: 4 bytes + */ +struct tcpr_mpls_hdr +{ + u_int32_t mpls_les; /* 20 bits label, 3 bits exp, 1 bit bos, ttl */ +#define TCPR_MPLS_BOS_ON 1 +#define TCPR_MPLS_BOS_OFF 0 +}; + +/* + * NTP header + * Network Time Protocol + * Static header size: 48 bytes + */ +struct tcpr_ntp_hdr_l_fp /* int32_t floating point (64-bit) */ +{ + u_int32_t integer; /* integer */ + u_int32_t fraction; /* fraction */ +}; + +struct tcpr_ntp_hdr_s_fp /* int16_t floating point (32-bit) */ +{ + u_int16_t integer; /* integer */ + u_int16_t fraction; /* fraction */ +}; + + +struct tcpr_ntp_hdr +{ + u_int8_t ntp_li_vn_mode; /* leap indicator, version, mode */ +#define TCPR_NTP_LI_NW 0x0 /* no warning */ +#define TCPR_NTP_LI_AS 0x1 /* last minute has 61 seconds */ +#define TCPR_NTP_LI_DS 0x2 /* last minute has 59 seconds */ +#define TCPR_NTP_LI_AC 0x3 /* alarm condition */ + +#define TCPR_NTP_VN_2 0x2 /* version 2 */ +#define TCPR_NTP_VN_3 0x3 /* version 3 */ +#define TCPR_NTP_VN_4 0x4 /* version 4 */ + +#define TCPR_NTP_MODE_R 0x0 /* reserved */ +#define TCPR_NTP_MODE_A 0x1 /* symmetric active */ +#define TCPR_NTP_MODE_P 0x2 /* symmetric passive */ +#define TCPR_NTP_MODE_C 0x3 /* client */ +#define TCPR_NTP_MODE_S 0x4 /* server */ +#define TCPR_NTP_MODE_B 0x5 /* broadcast */ +#define TCPR_NTP_MODE_RC 0x6 /* reserved for NTP control message */ +#define TCPR_NTP_MODE_RP 0x7 /* reserved for private use */ + u_int8_t ntp_stratum; /* stratum */ +#define TCPR_NTP_STRATUM_UNAVAIL 0x0 /* unspecified or unavailable */ +#define TCPR_NTP_STRATUM_PRIMARY 0x1 /* primary reference (radio clock) */ + /* 2 - 15 is secondary */ + /* 16 - 255 is reserved */ + u_int8_t ntp_poll; /* poll interval (should be 4 - 12) */ + u_int8_t ntp_precision; /* local clock precision */ + struct tcpr_ntp_hdr_s_fp ntp_delay; /* roundtrip delay */ + struct tcpr_ntp_hdr_s_fp ntp_dispersion; /* nominal error */ + u_int32_t ntp_reference_id; /* reference source id */ +#define TCPR_NTP_REF_LOCAL 0x4c4f434c /* uncalibrated local clock */ +#define TCPR_NTP_REF_PPS 0x50505300 /* atomic / pulse-per-second clock */ +#define TCPR_NTP_REF_ACTS 0x41435453 /* NIST dialup modem */ +#define TCPR_NTP_REF_USNO 0x55534e4f /* USNO modem service */ +#define TCPR_NTP_REF_PTB 0x50544200 /* PTB (German) modem service */ +#define TCPR_NTP_REF_TDF 0x54444600 /* Allouis (French) radio */ +#define TCPR_NTP_REF_DCF 0x44434600 /* Mainflingen (German) radio */ +#define TCPR_NTP_REF_MSF 0x4d534600 /* Rugby (UK) radio */ +#define TCPR_NTP_REF_WWV 0x57575600 /* Ft Collins (US) radio */ +#define TCPR_NTP_REF_WWVB 0x57575642 /* Boulder (US) radio */ +#define TCPR_NTP_REF_WWVH 0x57575648 /* Kaui Hawaii (US) radio */ +#define TCPR_NTP_REF_CHU 0x43485500 /* Ottaha (Canada) radio */ +#define TCPR_NTP_REF_LORC 0x4c4f5243 /* LORAN-C radionavigation */ +#define TCPR_NTP_REF_OMEG 0x4f4d4547 /* OMEGA radionavigation */ +#define TCPR_NTP_REF_GPS 0x47505300 /* global positioning system */ +#define TCPR_NTP_REF_GOES 0x474f4553 /* geostationary orbit env satellite */ + struct tcpr_ntp_hdr_l_fp ntp_ref_ts; /* reference timestamp */ + struct tcpr_ntp_hdr_l_fp ntp_orig_ts; /* originate timestamp */ + struct tcpr_ntp_hdr_l_fp ntp_rec_ts; /* receive timestamp */ + struct tcpr_ntp_hdr_l_fp ntp_xmt_ts; /* transmit timestamp */ +}; + + +/* + * OSPFv2 header + * Open Shortest Path First + * Static header size: 16 bytes + */ +struct tcpr_ospf_hdr +{ + u_int8_t ospf_v; /* version */ +#define OSPFVERSION 2 + u_int8_t ospf_type; /* type */ +#define TCPR_OSPF_UMD 0 /* UMd monitoring packet */ +#define TCPR_OSPF_HELLO 1 /* HELLO packet */ +#define TCPR_OSPF_DBD 2 /* dataBase description packet */ +#define TCPR_OSPF_LSR 3 /* link state request packet */ +#define TCPR_OSPF_LSU 4 /* link state Update Packet */ +#define TCPR_OSPF_LSA 5 /* link state acknowledgement packet */ + u_int16_t ospf_len; /* length */ + struct in_addr ospf_rtr_id; /* source router ID */ + struct in_addr ospf_area_id;/* roam ID */ + u_int16_t ospf_sum; /* checksum */ + u_int16_t ospf_auth_type; /* authentication type */ +#define TCPR_OSPF_AUTH_NULL 0 /* null password */ +#define TCPR_OSPF_AUTH_SIMPLE 1 /* simple, plaintext, 8 int8_t password */ +#define TCPR_OSPF_AUTH_MD5 2 /* MD5 */ +}; + + +/* + * OSPF authentication header + * Open Shortest Path First + * Static header size: 8 bytes + */ +struct tcpr_auth_hdr +{ + u_int16_t ospf_auth_null; /* NULL */ + u_int8_t ospf_auth_keyid; /* authentication key ID */ + u_int8_t ospf_auth_len; /* auth data length */ + u_int ospf_auth_seq; /* cryptographic sequence number */ +}; + + +/* + * OSPF hello header + * Open Shortest Path First + * Static header size: 28 bytes + */ +struct tcpr_ospf_hello_hdr +{ + struct in_addr hello_nmask; /* netmask associated with the interface */ + u_int16_t hello_intrvl; /* num of seconds between routers last packet */ + u_int8_t hello_opts; /* Options for HELLO packets (look above) */ + u_int8_t hello_rtr_pri; /* router's priority (if 0, can't be backup) */ + u_int hello_dead_intvl; /* # of secs a router is silent till deemed down */ + struct in_addr hello_des_rtr; /* Designated router on the network */ + struct in_addr hello_bkup_rtr; /* Backup router */ + struct in_addr hello_nbr; /* neighbor router, memcpy more as needed */ +}; + + +/* + * Database Description header. + */ +struct tcpr_dbd_hdr +{ + u_int16_t dbd_mtu_len; /* max length of IP dgram that this 'if' can use */ + u_int8_t dbd_opts; /* DBD packet options (from above) */ + u_int8_t dbd_type; /* type of exchange occurring */ +#define TCPR_DBD_IBI 0x01 /* init */ +#define TCPR_DBD_MBIT 0x02 /* more DBD packets are to come */ +#define TCPR_DBD_MSBIT 0x04 /* If 1, sender is the master in the exchange */ + u_int dbd_seq; /* DBD sequence number */ +}; + + +/* + * used for the LS type field in all LS* headers + */ +#define TCPR_LS_TYPE_RTR 1 /* router-LSA */ +#define TCPR_LS_TYPE_NET 2 /* network-LSA */ +#define TCPR_LS_TYPE_IP 3 /* summary-LSA (IP Network) */ +#define TCPR_LS_TYPE_ASBR 4 /* summary-LSA (ASBR) */ +#define TCPR_LS_TYPE_ASEXT 5 /* AS-external-LSA */ + + +/* + * Link State Request header + */ +struct tcpr_lsr_hdr +{ + u_int lsr_type; /* type of LS being requested */ + u_int lsr_lsid; /* link state ID */ + struct in_addr lsr_adrtr; /* advertising router (memcpy more as needed) */ +}; + + +/* + * Link State Update header + */ +struct tcpr_lsu_hdr +{ + u_int lsu_num; /* number of LSAs that will be broadcasted */ +}; + + +/* + * Link State Acknowledgement header. + */ +struct tcpr_lsa_hdr +{ + u_int16_t lsa_age; /* time in seconds since the LSA was originated */ + u_int8_t lsa_opts; /* look above for OPTS_* */ + u_int8_t lsa_type; /* look below for LS_TYPE_* */ + u_int lsa_id; /* link State ID */ + struct in_addr lsa_adv; /* router ID of Advertising router */ + u_int lsa_seq; /* LSA sequence number to detect old/bad ones */ + u_int16_t lsa_sum; /* "Fletcher Checksum" of all fields minus age */ + u_int16_t lsa_len; /* length in bytes including the 20 byte header */ +}; + + +/* + * Router LSA data format + * + * Other stuff for TOS can be added for backward compatability, for this + * version, only OSPFv2 is being FULLY supported. + */ +struct tcpr_rtr_lsa_hdr +{ + u_int16_t rtr_flags; /* set to help describe packet */ +#define TCPR_RTR_FLAGS_W 0x0100 /* W bit */ +#define TCPR_RTR_FLAGS_E 0x0200 /* E bit */ +#define TCPR_RTR_FLAGS_B 0x0400 /* B bit */ + u_int16_t rtr_num; /* number of links within that packet */ + u_int rtr_link_id; /* describes link_data (look below) */ +#define TCPR_LINK_ID_NBR_ID 1 /* Neighbors router ID, also can be 4 */ +#define TCPR_LINK_ID_IP_DES 2 /* IP address of designated router */ +#define TCPR_LINK_ID_SUB 3 /* IP subnet number */ + u_int rtr_link_data; /* Depending on link_id, info is here */ + u_int8_t rtr_type; /* Description of router link */ +#define TCPR_RTR_TYPE_PTP 1 /* Point-To-Point */ +#define TCPR_RTR_TYPE_TRANS 2 /* Connection to a "transit network" */ +#define TCPR_RTR_TYPE_STUB 3 /* Connectin to a "stub network" */ +#define RTR_TYPE_VRTL 4 /* connects to a "virtual link" */ + u_int8_t rtr_tos_num; /* number of different TOS metrics for this link */ + u_int16_t rtr_metric; /* the "cost" of using this link */ +}; + + +/* + * Network LSA data format. + */ +struct tcpr_net_lsa_hdr +{ + struct in_addr net_nmask; /* Netmask for that network */ + u_int net_rtr_id; /* ID of router attached to that network */ +}; + + +/* + * Summary LSA data format. + */ +struct tcpr_sum_lsa_hdr +{ + struct in_addr sum_nmask; /* Netmask of destination IP address */ + u_int sum_metric; /* Same as in rtr_lsa (&0xfff to use last 24bit */ + u_int sum_tos_metric; /* first 8bits are TOS, 24bits are TOS Metric */ +}; + + +/* + * AS External LSA data format. + * & 0xfff logic operator for as_metric to get last 24bits. + */ +struct tcpr_as_lsa_hdr +{ + struct in_addr as_nmask; /* Netmask for advertised destination */ + u_int as_metric; /* May have to set E bit in first 8bits */ +#define TCPR_AS_E_BIT_ON 0x80000000 /* as_metric */ + struct in_addr as_fwd_addr; /* Forwarding address */ + u_int as_rte_tag; /* External route tag */ +}; + + +/* + * Base RIP header + * Routing Information Protocol + * Base header size: 24 bytes + */ +struct tcpr_rip_hdr +{ + u_int8_t rip_cmd; /* RIP command */ +#define RIPCMD_REQUEST 1 /* want info */ +#define RIPCMD_RESPONSE 2 /* responding to request */ +#define RIPCMD_TRACEON 3 /* turn tracing on */ +#define RIPCMD_TRACEOFF 4 /* turn it off */ +#define RIPCMD_POLL 5 /* like request, but anyone answers */ +#define RIPCMD_POLLENTRY 6 /* like poll, but for entire entry */ +#define RIPCMD_MAX 7 /* ? command */ + u_int8_t rip_ver; /* RIP version */ +#define RIPVER_0 0 +#define RIPVER_1 1 +#define RIPVER_2 2 + u_int16_t rip_rd; /* Zero (v1) or Routing Domain (v2) */ + u_int16_t rip_af; /* Address family */ + u_int16_t rip_rt; /* Zero (v1) or Route Tag (v2) */ + u_int32_t rip_addr; /* IP address */ + u_int32_t rip_mask; /* Zero (v1) or Subnet Mask (v2) */ + u_int32_t rip_next_hop; /* Zero (v1) or Next hop IP address (v2) */ + u_int32_t rip_metric; /* Metric */ +}; + +/* + * RPC headers + * Remote Procedure Call + */ +#define TCPR_RPC_CALL 0 +#define TCPR_RPC_REPLY 1 +#define TCPR_RPC_VERS 2 +#define TCPR_RPC_LAST_FRAG 0x80000000 + +/* + * Portmap defines + */ +#define TCPR_PMAP_PROGRAM 100000 +#define TCPR_PMAP_PROC_NULL 0 +#define TCPR_PMAP_PROC_SET 1 +#define TCPR_PMAP_PROC_UNSET 2 +#define TCPR_PMAP_PROC_GETADDR 3 +#define TCPR_PMAP_PROC_DUMP 4 +#define TCPR_PMAP_PROC_CALLIT 5 +#define TCPR_PMAP_PROC_BCAST 5 /* Not a typo */ +#define TCPR_PMAP_PROC_GETTIME 6 +#define TCPR_PMAP_PROC_UADDR2TADDR 7 +#define TCPR_PMAP_PROC_TADDR2UADDR 8 +#define TCPR_PMAP_PROC_GETVERSADDR 9 +#define TCPR_PMAP_PROC_INDIRECT 10 +#define TCPR_PMAP_PROC_GETADDRLIST 11 +#define TCPR_PMAP_PROC_GETSTAT 12 + +/* There will be more to add... */ + +struct tcpr_rpc_opaque_auth +{ + u_int32_t rpc_auth_flavor; + u_int32_t rpc_auth_length; +#if 0 + u_int8_t *rpc_auth_data; +#endif +}; + +struct tcpr_rpc_call +{ + u_int32_t rpc_rpcvers; /* RPC version - must be 2 */ + u_int32_t rpc_prognum; /* Program Number */ + u_int32_t rpc_vers; /* Program Version */ + u_int32_t rpc_procedure; /* RPC procedure */ + struct tcpr_rpc_opaque_auth rpc_credentials; + struct tcpr_rpc_opaque_auth rpc_verifier; +}; + +struct tcpr_rpc_call_hdr +{ + u_int32_t rpc_xid; /* xid (transaction identifier) */ + u_int32_t rpc_type; + struct tcpr_rpc_call rpc_call; +}; + +struct tcpr_rpc_call_tcp_hdr +{ + u_int32_t rpc_record_marking; /* used with byte stream protocols */ + struct tcpr_rpc_call_hdr rpc_common; +}; + +/* + * STP configuration header + * Spanning Tree Protocol + * Static header size: 35 bytes + */ +struct tcpr_stp_conf_hdr +{ + u_int16_t stp_id; /* protocol id */ + u_int8_t stp_version; /* protocol version */ + u_int8_t stp_bpdu_type; /* bridge protocol data unit type */ + u_int8_t stp_flags; /* control flags */ + u_int8_t stp_rootid[8]; /* root id */ + u_int32_t stp_rootpc; /* root path cost */ + u_int8_t stp_bridgeid[8]; /* bridge id */ + u_int16_t stp_portid; /* port id */ + u_int16_t stp_mage; /* message age */ + u_int16_t stp_maxage; /* max age */ + u_int16_t stp_hellot; /* hello time */ + u_int16_t stp_fdelay; /* forward delay */ +}; + + +/* + * STP topology change notification header + * Spanning Tree Protocol + * Static header size: 4 bytes + */ +struct tcpr_stp_tcn_hdr +{ + u_int16_t stp_id; /* protocol id */ + u_int8_t stp_version; /* protocol version */ + u_int8_t stp_bpdu_type; /* bridge protocol data unit type */ +}; + + +/* + * TCP header + * Transmission Control Protocol + * Static header size: 20 bytes + */ +struct tcpr_tcp_hdr +{ + u_int16_t th_sport; /* source port */ + u_int16_t th_dport; /* destination port */ + u_int32_t th_seq; /* sequence number */ + u_int32_t th_ack; /* acknowledgement number */ +#ifdef WORDS_BIGENDIAN + u_int8_t th_off:4, /* data offset */ + th_x2:4; /* (unused) */ +#else + u_int8_t th_x2:4, /* (unused) */ + th_off:4; /* data offset */ +#endif + + u_int8_t th_flags; /* control flags */ +#ifndef TH_FIN +#define TH_FIN 0x01 /* finished send data */ +#endif +#ifndef TH_SYN +#define TH_SYN 0x02 /* synchronize sequence numbers */ +#endif +#ifndef TH_RST +#define TH_RST 0x04 /* reset the connection */ +#endif +#ifndef TH_PUSH +#define TH_PUSH 0x08 /* push data to the app layer */ +#endif +#ifndef TH_ACK +#define TH_ACK 0x10 /* acknowledge */ +#endif +#ifndef TH_URG +#define TH_URG 0x20 /* urgent! */ +#endif +#ifndef TH_ECE +#define TH_ECE 0x40 +#endif +#ifndef TH_CWR +#define TH_CWR 0x80 +#endif + u_int16_t th_win; /* window */ + u_int16_t th_sum; /* checksum */ + u_int16_t th_urp; /* urgent pointer */ +}; + + +/* + * Token Ring Header + */ +struct tcpr_token_ring_hdr +{ + u_int8_t token_ring_access_control; +#define TCPR_TOKEN_RING_FRAME 0x10 + u_int8_t token_ring_frame_control; +#define TCPR_TOKEN_RING_LLC_FRAME 0x40 + u_int8_t token_ring_dhost[TOKEN_RING_ADDR_LEN]; + u_int8_t token_ring_shost[TOKEN_RING_ADDR_LEN]; + u_int8_t token_ring_llc_dsap; + u_int8_t token_ring_llc_ssap; + u_int8_t token_ring_llc_control_field; + u_int8_t token_ring_llc_org_code[TCPR_ORG_CODE_SIZE]; + u_int16_t token_ring_type; +#define TOKEN_RING_TYPE_IP 0x0800 /* IP protocol */ +#define TOKEN_RING_TYPE_ARP 0x0806 /* addr. resolution protocol */ +#define TOKEN_RING_TYPE_REVARP 0x8035 /* reverse addr. resolution protocol */ +}; + +struct tcpr_token_ring_addr +{ + u_int8_t token_ring_addr_octet[6]; /* Token Ring address */ +}; + +/* + * UDP header + * User Data Protocol + * Static header size: 8 bytes + */ +struct tcpr_udp_hdr +{ + u_int16_t uh_sport; /* soure port */ + u_int16_t uh_dport; /* destination port */ + u_int16_t uh_ulen; /* length */ + u_int16_t uh_sum; /* checksum */ +}; + +/* + * Sebek header + * Static header size: 48 bytes + */ +struct tcpr_sebek_hdr +{ + u_int32_t magic; /* identify packets that should be hidden */ + u_int16_t version; /* protocol version, currently 1 */ +#define SEBEK_PROTO_VERSION 1 + u_int16_t type; /* type of record (read data is type 0, write data is type 1) */ +#define SEBEK_TYPE_READ 0 /* Currently, only read is supported */ +#define SEBEK_TYPE_WRITE 1 + u_int32_t counter; /* PDU counter used to identify when packet are lost */ + u_int32_t time_sec; /* seconds since EPOCH according to the honeypot */ + u_int32_t time_usec; /* residual microseconds */ + u_int32_t pid; /* PID */ + u_int32_t uid; /* UID */ + u_int32_t fd; /* FD */ +#define SEBEK_CMD_LENGTH 12 + u_int8_t cmd[SEBEK_CMD_LENGTH]; /* 12 first characters of the command */ + u_int32_t length; /* length in bytes of the PDU's body */ +}; + + +/* + * VRRP header + * Virtual Router Redundancy Protocol + * Static header size: 8 bytes + */ +#ifndef IPPROTO_VRRP +#define IPPROTO_VRRP 112 /* not everyone's got this */ +#endif +struct tcpr_vrrp_hdr +{ +#ifdef WORDS_BIGENDIAN + u_int8_t vrrp_t:4, /* packet type */ + vrrp_v:4; /* protocol version */ +#else + u_int8_t vrrp_v:4, /* protocol version */ + vrrp_t:4; /* packet type */ +#endif +#define TCPR_VRRP_VERSION_01 0x1 +#define TCPR_VRRP_VERSION_02 0x2 +#define TCPR_VRRP_TYPE_ADVERT 0x1 + u_int8_t vrrp_vrouter_id; /* virtual router id */ + u_int8_t vrrp_priority; /* priority */ + u_int8_t vrrp_ip_count; /* number of IP addresses */ + u_int8_t vrrp_auth_type; /* authorization type */ +#define TCPR_VRRP_AUTH_NONE 0x1 +#define TCPR_VRRP_AUTH_PASSWD 0x2 +#define TCPR_VRRP_AUTH_IPAH 0x3 + u_int8_t vrrp_advert_int; /* advertisement interval */ + u_int16_t vrrp_sum; /* checksum */ + /* additional addresses */ + /* authentication info */ +}; + + +/* + * HSRP header + * Static header size: 20 bytes + */ +struct tcpr_hsrp_hdr +{ +#define TCPR_HSRP_VERSION 0x0 + u_int8_t version; /* Version of the HSRP messages */ +#define TCPR_HSRP_TYPE_HELLO 0x0 +#define TCPR_HSRP_TYPE_COUP 0x1 +#define TCPR_HSRP_TYPE_RESIGN 0x2 + u_int8_t opcode; /* Type of message */ +#define TCPR_HSRP_STATE_INITIAL 0x0 +#define TCPR_HSRP_STATE_LEARN 0x1 +#define TCPR_HSRP_STATE_LISTEN 0x2 +#define TCPR_HSRP_STATE_SPEAK 0x4 +#define TCPR_HSRP_STATE_STANDBY 0x8 +#define TCPR_HSRP_STATE_ACTIVE 0x10 + u_int8_t state; /* Current state of the router */ + u_int8_t hello_time; /* Period in seconds between hello messages */ + u_int8_t hold_time; /* Seconds that the current hello message is valid */ + u_int8_t priority; /* Priority for the election proccess */ + u_int8_t group; /* Standby group */ + u_int8_t reserved; /* Reserved field */ +#define HSRP_AUTHDATA_LENGTH 8 + u_int8_t authdata[HSRP_AUTHDATA_LENGTH]; /* Password */ + u_int32_t virtual_ip; /* Virtual IP address */ +}; + +#endif diff --git a/src/tcpreplay-edit.1 b/src/tcpreplay-edit.1 new file mode 100644 index 0000000..3a55ab3 --- /dev/null +++ b/src/tcpreplay-edit.1 @@ -0,0 +1,735 @@ +.TH TCPREPLAY 1 2010-04-04 "(tcpreplay )" "Programmer's Manual" +.\" DO NOT EDIT THIS FILE (tcpreplay-edit.1) +.\" +.\" It has been AutoGen-ed April 4, 2010 at 05:59:20 PM by AutoGen 5.9.9 +.\" From the definitions tcpreplay_opts.def +.\" and the template file agman1.tpl +.\" +.SH NAME +tcpreplay \- Replay network traffic stored in pcap files +.SH SYNOPSIS +.B tcpreplay +.\" Mixture of short (flag) options and long options +.RB [ \-\fIflag\fP " [\fIvalue\fP]]... [" \--\fIopt-name\fP " [[=| ]\fIvalue\fP]]..." +.br +.in +8 + +.PP +tcpreplay is a tool for replaying network traffic from files saved with +tcpdump or other tools which write pcap(3) files. +.SH "DESCRIPTION" +This manual page briefly documents the \fBtcpreplay\fP command. +The basic operation of tcpreplay is to resend all packets from the +input file(s) at the speed at which they were recorded, or a specified +data rate, up to as fast as the hardware is capable. + +Optionally, the traffic can be split between two interfaces, written to +files, filtered and edited in various ways, providing the means to test +firewalls, NIDS and other network devices. + +For more details, please see the Tcpreplay Manual at: +http://tcpreplay.synfin.net/trac/wiki/manual +.SH OPTIONS +.SS "" +.TP +.BR \-r " \fIstring\fP, " \--portmap "=" \fIstring\fP +Rewrite TCP/UDP ports. +This option may appear up to \-1 times. +.sp +Specify a list of comma delimited port mappingings consisting of +colon delimited port number pairs. Each colon delimited port pair +consists of the port to match followed by the port number to rewrite. + +Examples: +.nf + \--portmap=80:8000 \--portmap=8080:80 # 80->8000 and 8080->80 + \--portmap=8000,8080,88888:80 # 3 different ports become 80 + \--portmap=8000-8999:80 # ports 8000 to 8999 become 80 +.fi +.TP +.BR \-s " \fInumber\fP, " \--seed "=" \fInumber\fP +Randomize src/dst IPv4/v6 addresses w/ given seed. +This option may appear up to 1 times. +This option takes an integer number as its argument. +.sp +Causes the source and destination IPv4/v6 addresses to be pseudo +randomized but still maintain client/server relationships. +Since the randomization is deterministic based on the seed, +you can reuse the same seed value to recreate the traffic. +.TP +.BR \-N " \fIstring\fP, " \--pnat "=" \fIstring\fP +Rewrite IPv4/v6 addresses using pseudo-NAT. +This option may appear up to 2 times. +This option must not appear in combination with any of the following options: +srcipmap. +.sp +Takes a comma delimited series of colon delimited CIDR +netblock pairs. Each netblock pair is evaluated in order against +the IP addresses. If the IP address in the packet matches the +first netblock, it is rewriten using the second netblock as a +mask against the high order bits. + +IPv4 Example: +.nf + \--pnat=192.168.0.0/16:10.77.0.0/16,172.16.0.0/12:10.1.0.0/24 +.fi +IPv6 Example: +.nf + \--pnat=[2001:db8::/32]:[dead::/16],[2001:db8::/32]:[::ffff:0:0/96] +.fi +.TP +.BR \-S " \fIstring\fP, " \--srcipmap "=" \fIstring\fP +Rewrite source IPv4/v6 addresses using pseudo-NAT. +This option may appear up to 1 times. +This option must not appear in combination with any of the following options: +pnat. +.sp +Works just like the \--pnat option, but only affects the source IP +addresses in the IPv4/v6 header. +.TP +.BR \-D " \fIstring\fP, " \--dstipmap "=" \fIstring\fP +Rewrite destination IPv4/v6 addresses using pseudo-NAT. +This option may appear up to 1 times. +This option must not appear in combination with any of the following options: +pnat. +.sp +Works just like the \--pnat option, but only affects the destination IP +addresses in the IPv4/v6 header. +.TP +.BR \-e " \fIstring\fP, " \--endpoints "=" \fIstring\fP +Rewrite IP addresses to be between two endpoints. +This option may appear up to 1 times. +This option must appear in combination with the following options: +cachefile. +.sp +Takes a pair of colon delimited IPv4/v6 addresses which will be used to rewrite +all traffic to appear to be between the two IP's. + +IPv4 Example: +.nf + \--endpoints=172.16.0.1:172.16.0.2 +.fi +IPv6 Example: +.nf + \--endpoints=[2001:db8::dead:beef]:[::ffff:0:0:ac:f:0:2] +.fi + +.TP +.BR \-b ", " \--skipbroadcast +Skip rewriting broadcast/multicast IPv4/v6 addresses. +.sp +By default \--seed, \--pnat and \--endpoints will rewrite +broadcast and multicast IPv4/v6 and MAC addresses. Setting this flag +will keep broadcast/multicast IPv4/v6 and MAC addresses from being rewritten. +.TP +.BR \-C ", " \--fixcsum +Force recalculation of IPv4/TCP/UDP header checksums. +.sp +Causes each IPv4/v6 packet to have it's checksums recalcualted and +fixed. Automatically enabled for packets modified with \fB--seed\fP, +\fB--pnat\fP, \fB--endpoints\fP or \fB--fixlen\fP. +.TP +.BR \-m " \fInumber\fP, " \--mtu "=" \fInumber\fP +Override default MTU length (1500 bytes). +This option may appear up to 1 times. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 1 through MAXPACKET +.fi +.in -4 +.sp +Override the default 1500 byte MTU size for determining the maximum padding length +(--fixlen=pad) or when truncating (--mtu-trunc). +.TP +.BR \--mtu-trunc +Truncate packets larger then specified MTU. +This option may appear up to 1 times. +.sp +Similar to \--fixlen, this option will truncate data in packets from Layer 3 and above to be +no larger then the MTU. +.TP +.BR \-E ", " \--efcs +Remove Ethernet checksums (FCS) from end of frames. +.sp +Note, this option is pretty dangerous! We don't actually check to see if a FCS +actually exists in the frame, we just blindly delete the last two bytes. Hence, +you should only use this if you know know that your OS provides the FCS when +reading raw packets. +.TP +.BR \--ttl "=\fIstring\fP" +Modify the IPv4/v6 TTL/Hop Limit. +.sp +Allows you to modify the TTL/Hop Limit of all the IPv4/v6 packets. Specify a number to hard-code +the value or +/-value to increase or decrease by the value provided (limited to 1-255). + +Examples: +.nf + \--ttl=10 + \--ttl=+7 + \--ttl=-64 +.fi +.TP +.BR \--tos "=\fInumber\fP" +Set the IPv4 TOS/DiffServ/ECN byte. +This option may appear up to 1 times. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 255 +.fi +.in -4 +.sp +Allows you to override the TOS (also known as DiffServ/ECN) value in IPv4. +.TP +.BR \--tclass "=\fInumber\fP" +Set the IPv6 Traffic Class byte. +This option may appear up to 1 times. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 255 +.fi +.in -4 +.sp +Allows you to override the IPv6 Traffic Class field. +.TP +.BR \--flowlabel "=\fInumber\fP" +Set the IPv6 Flow Label. +This option may appear up to 1 times. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 1048575 +.fi +.in -4 +.sp +Allows you to override the 20bit IPv6 Flow Label field. Has no effect on IPv4 +packets. +.TP +.BR \-F " \fIstring\fP, " \--fixlen "=" \fIstring\fP +Pad or truncate packet data to match header length. +This option may appear up to 1 times. +.sp +Packets may be truncated during capture if the snaplen is smaller then the +packet. This option allows you to modify the packet to pad the packet back +out to the size stored in the IPv4/v6 header or rewrite the IP header total length +to reflect the stored packet length. +.sp 1 +\fBpad\fP +Truncated packets will be padded out so that the packet length matches the +IPv4 total length +.sp 1 +\fBtrunc\fP +Truncated packets will have their IPv4 total length field rewritten to match +the actual packet length +.sp 1 +\fBdel\fP +Delete the packet +.TP +.BR \--skipl2broadcast +Skip rewriting broadcast/multicast Layer 2 addresses. +.sp +By default, editing Layer 2 addresses will rewrite +broadcast and multicast MAC addresses. Setting this flag +will keep broadcast/multicast MAC addresses from being rewritten. +.TP +.BR \--dlt "=\fIstring\fP" +Override output DLT encapsulation. +This option may appear up to 1 times. +.sp +By default, no DLT (data link type) conversion will be made. +To change the DLT type of the output pcap, select one of the following values: +.sp 1 +\fBenet\fP +Ethernet aka DLT_EN10MB +.sp 1 +\fBhdlc\fP +Cisco HDLC aka DLT_C_HDLC +.sp 1 +\fBuser\fP +User specified Layer 2 header and DLT type +.br +.TP +.BR \--enet-dmac "=\fIstring\fP" +Override destination ethernet MAC addresses. +This option may appear up to 1 times. +.sp +Takes a pair of comma deliminated ethernet MAC addresses which +will replace the destination MAC address of outbound packets. +The first MAC address will be used for the server to client traffic +and the optional second MAC address will be used for the client +to server traffic. + +Example: +.nf + \--enet-dmac=00:12:13:14:15:16,00:22:33:44:55:66 +.fi +.TP +.BR \--enet-smac "=\fIstring\fP" +Override source ethernet MAC addresses. +This option may appear up to 1 times. +.sp +Takes a pair of comma deliminated ethernet MAC addresses which +will replace the source MAC address of outbound packets. +The first MAC address will be used for the server to client traffic +and the optional second MAC address will be used for the client +to server traffic. + +Example: +.nf + \--enet-smac=00:12:13:14:15:16,00:22:33:44:55:66 +.fi +.TP +.BR \--enet-vlan "=\fIstring\fP" +Specify ethernet 802.1q VLAN tag mode. +This option may appear up to 1 times. +.sp +Allows you to rewrite ethernet frames to add a 802.1q header to standard 802.3 +ethernet headers or remove the 802.1q VLAN tag information. +.sp 1 +\fBadd\fP +Rewrites the existing 802.3 ethernet header as an 802.1q VLAN header +.sp 1 +\fBdel\fP +Rewrites the existing 802.1q VLAN header as an 802.3 ethernet header +.TP +.BR \--enet-vlan-tag "=\fInumber\fP" +Specify the new ethernet 802.1q VLAN tag value. +This option may appear up to 1 times. +This option must appear in combination with the following options: +enet-vlan. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 4095 +.fi +.in -4 +.sp + +.TP +.BR \--enet-vlan-cfi "=\fInumber\fP" +Specify the ethernet 802.1q VLAN CFI value. +This option may appear up to 1 times. +This option must appear in combination with the following options: +enet-vlan. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 1 +.fi +.in -4 +.sp + +.TP +.BR \--enet-vlan-pri "=\fInumber\fP" +Specify the ethernet 802.1q VLAN priority. +This option may appear up to 1 times. +This option must appear in combination with the following options: +enet-vlan. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 7 +.fi +.in -4 +.sp + +.TP +.BR \--hdlc-control "=\fInumber\fP" +Specify HDLC control value. +This option may appear up to 1 times. +This option takes an integer number as its argument. +.sp +The Cisco HDLC header has a 1 byte "control" field. Apparently this should +always be 0, but if you can use any 1 byte value. +.TP +.BR \--hdlc-address "=\fInumber\fP" +Specify HDLC address. +This option may appear up to 1 times. +This option takes an integer number as its argument. +.sp +The Cisco HDLC header has a 1 byte "address" field which has two valid +values: +.sp 1 +\fB0x0F\fP +Unicast +.sp 1 +\fB0xBF\fP +Broadcast +.br +You can however specify any single byte value. +.TP +.BR \--user-dlt "=\fInumber\fP" +Set output file DLT type. +This option may appear up to 1 times. +This option takes an integer number as its argument. +.sp +Set the DLT value of the output pcap file. +.TP +.BR \--user-dlink "=\fIstring\fP" +Rewrite Data-Link layer with user specified data. +This option may appear up to 2 times. +.sp +Provide a series of comma deliminated hex values which will be +used to rewrite or create the Layer 2 header of the packets. +The first instance of this argument will rewrite both server +and client traffic, but if this argument is specified a second +time, it will be used for the client traffic. + +Example: +.nf + \--user-dlink=01,02,03,04,05,06,00,1A,2B,3C,4D,5E,6F,08,00 +.fi +.TP +.BR \-d " \fInumber\fP, " \--dbug "=" \fInumber\fP +Enable debugging output. +This option may appear up to 1 times. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 5 +.fi +.in -4 +The default \fInumber\fP for this option is: +.ti +4 + 0 +.sp +If configured with \--enable-debug, then you can specify a verbosity +level for debugging output. Higher numbers increase verbosity. +.TP +.BR \-q ", " \--quiet +Quiet mode. +.sp +Print nothing except the statistics at the end of the run +.TP +.BR \-T " \fIstring\fP, " \--timer "=" \fIstring\fP +Select packet timing mode: select, ioport, rdtsc, gtod, nano, abstime. +This option may appear up to 1 times. +The default \fIstring\fP for this option is: +.ti +4 + gtod +.sp +Allows you to select the packet timing method to use: +.sp +.IR "nano" +- Use nanosleep() API +.sp +.IR "select" +- Use select() API +.sp +.IR "ioport" +- Write to the i386 IO Port 0x80 +.sp +.IR "rdtsc" +- Use the x86/x86_64/PPC RDTSC +.sp +.IR "gtod [default]" +- Use a gettimeofday() loop +.sp +.IR "abstime" +- Use OS X's AbsoluteTime API +.br + +.TP +.BR \--sleep-accel "=\fInumber\fP" +Reduce the amount of time to sleep by specified usec. +This option takes an integer number as its argument. +The default \fInumber\fP for this option is: +.ti +4 + 0 +.sp +Reduce the amount of time we would normally sleep between two packets by the +specified number of usec. This provides a "fuzz factor" to compensate for +running on a non-RTOS and other processes using CPU time. Default is disabled. +.TP +.BR \--rdtsc-clicks "=\fInumber\fP" +Specify the RDTSC clicks/usec. +This option may appear up to 1 times. +This option takes an integer number as its argument. +The default \fInumber\fP for this option is: +.ti +4 + 0 +.sp +Override the calculated number of RDTSC clicks/usec which is often the speed of the +CPU in Mhz. Only useful if you specified \fB--timer=rdtsc\fP +.TP +.BR \-v ", " \--verbose +Print decoded packets via tcpdump to STDOUT. +This option may appear up to 1 times. +.sp + +.TP +.BR \-A " \fIstring\fP, " \--decode "=" \fIstring\fP +Arguments passed to tcpdump decoder. +This option may appear up to 1 times. +This option must appear in combination with the following options: +verbose. +.sp +When enabling verbose mode (\fB-v\fP) you may also specify one or more +additional arguments to pass to \fBtcpdump\fP to modify the way packets +are decoded. By default, \-n and \-l are used. Be sure to +quote the arguments like: \-A "-axxx" so that they are not interpreted +by tcpreplay. Please see the tcpdump(1) man page for a complete list of +options. +.TP +.BR \-K ", " \--enable-file-cache +Enable caching of packets to internal memory. +This option must appear in combination with the following options: +loop. +.sp +Cache pcap file(s) the first time they are cached in RAM so that subsequent +loops don't incurr any disk I/O latency in order to increase performance. Make +sure you have enough free RAM to store the entire pcap file(s) in memory or the +system will swap and performance will suffer. +.TP +.BR \--preload-pcap +Preloads packets into RAM before sending. +.sp +This option loads the specified pcap(s) into RAM before starting to send in order +to improve replay performance while introducing a startup performance hit. +Preloading can be used with or without \fB--loop\fP and implies +\fB--enable-file-cache\fP. +.TP +.BR \-c " \fIstring\fP, " \--cachefile "=" \fIstring\fP +Split traffic via a tcpprep cache file. +This option may appear up to 1 times. +.sp + +.TP +.BR \-i " \fIstring\fP, " \--intf1 "=" \fIstring\fP +Server/primary traffic output interface. +This option may appear up to 1 times. +.sp + +.TP +.BR \-I " \fIstring\fP, " \--intf2 "=" \fIstring\fP +Client/secondary traffic output interface. +This option may appear up to 1 times. +This option must appear in combination with the following options: +cachefile. +.sp + +.TP +.BR \--listnics +List available network interfaces and exit. +.sp + +.TP +.BR \-l " \fInumber\fP, " \--loop "=" \fInumber\fP +Loop through the capture file X times. +This option may appear up to 1 times. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +greater than or equal to 0 +.fi +.in -4 +The default \fInumber\fP for this option is: +.ti +4 + 1 +.sp + +.TP +.BR \--pktlen +Override the snaplen and use the actual packet len. +This option may appear up to 1 times. +.sp +By default, tcpreplay will send packets based on the size of the "snaplen" +stored in the pcap file which is usually the correct thing to do. However, +occasionally, tools will store more bytes then told to. By specifying this +option, tcpreplay will ignore the snaplen field and instead try to send +packets based on the original packet length. Bad things may happen if +you specify this option. +.TP +.BR \-L " \fInumber\fP, " \--limit "=" \fInumber\fP +Limit the number of packets to send. +This option may appear up to 1 times. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +greater than or equal to 1 +.fi +.in -4 +The default \fInumber\fP for this option is: +.ti +4 + \-1 +.sp +By default, tcpreplay will send all the packets. Alternatively, you can +specify a maximum number of packets to send. +.TP +.BR \-x " \fIstring\fP, " \--multiplier "=" \fIstring\fP +Modify replay speed to a given multiple. +This option may appear up to 1 times. +This option must not appear in combination with any of the following options: +pps, mbps, oneatatime, topspeed. +.sp +Specify a floating point value to modify the packet replay speed. +Examples: +.nf + 2.0 will replay traffic at twice the speed captured + 0.7 will replay traffic at 70% the speed captured +.fi +.TP +.BR \-p " \fInumber\fP, " \--pps "=" \fInumber\fP +Replay packets at a given packets/sec. +This option may appear up to 1 times. +This option must not appear in combination with any of the following options: +multiplier, mbps, oneatatime, topspeed. +This option takes an integer number as its argument. +.sp + +.TP +.BR \-M " \fIstring\fP, " \--mbps "=" \fIstring\fP +Replay packets at a given Mbps. +This option may appear up to 1 times. +This option must not appear in combination with any of the following options: +multiplier, pps, oneatatime, topspeed. +.sp +Specify a floating point value for the Mbps rate that tcpreplay +should send packets at. +.TP +.BR \-t ", " \--topspeed +Replay packets as fast as possible. +This option must not appear in combination with any of the following options: +mbps, multiplier, pps, oneatatime. +.sp + +.TP +.BR \-o ", " \--oneatatime +Replay one packet at a time for each user input. +This option must not appear in combination with any of the following options: +mbps, pps, multiplier, topspeed. +.sp +Allows you to step through one or more packets at a time. +.TP +.BR \--pps-multi "=\fInumber\fP" +Number of packets to send for each time interval. +This option must appear in combination with the following options: +pps. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +greater than or equal to 1 +.fi +.in -4 +The default \fInumber\fP for this option is: +.ti +4 + 1 +.sp +When trying to send packets at very high rates, the time between each packet +can be so short that it is impossible to accurately sleep for the required +period of time. This option allows you to send multiple packets at a time, +thus allowing for longer sleep times which can be more accurately implemented. +.TP +.BR \-P ", " \--pid +Print the PID of tcpreplay at startup. +.sp + +.TP +.BR \--stats "=\fInumber\fP" +Print statistics every X seconds. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +greater than or equal to 1 +.fi +.in -4 +.sp +Note that this is very much a "best effort" and long delays between +sending packets may cause equally long delays between printing statistics. +.TP +.BR \-V ", " \--version +Print version information. +.sp + +.TP +.BR \-h ", " \--less-help +Display less usage information and exit. +.sp + +.TP +.BR \-H , " \--help" +Display usage information and exit. +.TP +.BR \-! , " \--more-help" +Extended usage information passed thru pager. +.TP +.BR \- " [\fIrcfile\fP]," " \--save-opts" "[=\fIrcfile\fP]" +Save the option state to \fIrcfile\fP. The default is the \fIlast\fP +configuration file listed in the \fBOPTION PRESETS\fP section, below. +.TP +.BR \- " \fIrcfile\fP," " \--load-opts" "=\fIrcfile\fP," " \--no-load-opts" +Load options from \fIrcfile\fP. +The \fIno-load-opts\fP form will disable the loading +of earlier RC/INI files. \fI--no-load-opts\fP is handled early, +out of order. +.SH OPTION PRESETS +Any option that is not marked as \fInot presettable\fP may be preset +by loading values from configuration ("RC" or ".INI") file(s). +The \fIhomerc\fP file is "\fI$$/\fP", unless that is a directory. +In that case, the file "\fI.tcpreplayrc\fP" +is searched for within that directory. +.SH "SIGNALS" +tcpreplay understands the following signals: +.sp +.IR "\fBSIGUSR1\fP" +Suspend tcpreplay +.sp +.IR "\fBSIGCONT\fP" +Restart tcpreplay +.br + +.SH "SEE ALSO" +tcpreplay-edit(1), tcpdump(1), tcpprep(1), tcprewrite(1), libnet(3) + +.SH "BUGS" +tcpreplay can only send packets as fast as your computer's interface, +processor, disk and system bus will allow. + +Packet timing at high speeds is a black art and very OS/CPU dependent. + +Replaying captured traffic may simulate odd or broken conditions on your +network and cause all sorts of problems. + +In most cases, you can not replay traffic back to/at a server. + +Some operating systems by default do not allow for forging source MAC +addresses. Please consult your operating system's documentation and the +tcpreplay FAQ if you experience this issue. +.SH AUTHOR +Copyright 2000-2010 Aaron Turner + +For support please use the tcpreplay-users@lists.sourceforge.net mailing list. + +The latest version of this software is always available from: +http://tcpreplay.synfin.net/ +.PP +Released under the Free BSD License. +.PP +This manual page was \fIAutoGen\fP-erated from the \fBtcpreplay\fP +option definitions. diff --git a/src/tcpreplay.1 b/src/tcpreplay.1 new file mode 100644 index 0000000..4c01ca1 --- /dev/null +++ b/src/tcpreplay.1 @@ -0,0 +1,370 @@ +.TH TCPREPLAY 1 2010-04-04 "(tcpreplay )" "Programmer's Manual" +.\" DO NOT EDIT THIS FILE (tcpreplay.1) +.\" +.\" It has been AutoGen-ed April 4, 2010 at 05:59:19 PM by AutoGen 5.9.9 +.\" From the definitions tcpreplay_opts.def +.\" and the template file agman1.tpl +.\" +.SH NAME +tcpreplay \- Replay network traffic stored in pcap files +.SH SYNOPSIS +.B tcpreplay +.\" Mixture of short (flag) options and long options +.RB [ \-\fIflag\fP " [\fIvalue\fP]]... [" \--\fIopt-name\fP " [[=| ]\fIvalue\fP]]..." +.br +.in +8 + +.PP +tcpreplay is a tool for replaying network traffic from files saved with +tcpdump or other tools which write pcap(3) files. +.SH "DESCRIPTION" +This manual page briefly documents the \fBtcpreplay\fP command. +The basic operation of tcpreplay is to resend all packets from the +input file(s) at the speed at which they were recorded, or a specified +data rate, up to as fast as the hardware is capable. + +Optionally, the traffic can be split between two interfaces, written to +files, filtered and edited in various ways, providing the means to test +firewalls, NIDS and other network devices. + +For more details, please see the Tcpreplay Manual at: +http://tcpreplay.synfin.net/trac/wiki/manual +.SH OPTIONS +.TP +.BR \-d " \fInumber\fP, " \--dbug "=" \fInumber\fP +Enable debugging output. +This option may appear up to 1 times. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 5 +.fi +.in -4 +The default \fInumber\fP for this option is: +.ti +4 + 0 +.sp +If configured with \--enable-debug, then you can specify a verbosity +level for debugging output. Higher numbers increase verbosity. +.TP +.BR \-q ", " \--quiet +Quiet mode. +.sp +Print nothing except the statistics at the end of the run +.TP +.BR \-T " \fIstring\fP, " \--timer "=" \fIstring\fP +Select packet timing mode: select, ioport, rdtsc, gtod, nano, abstime. +This option may appear up to 1 times. +The default \fIstring\fP for this option is: +.ti +4 + gtod +.sp +Allows you to select the packet timing method to use: +.sp +.IR "nano" +- Use nanosleep() API +.sp +.IR "select" +- Use select() API +.sp +.IR "ioport" +- Write to the i386 IO Port 0x80 +.sp +.IR "rdtsc" +- Use the x86/x86_64/PPC RDTSC +.sp +.IR "gtod [default]" +- Use a gettimeofday() loop +.sp +.IR "abstime" +- Use OS X's AbsoluteTime API +.br + +.TP +.BR \--sleep-accel "=\fInumber\fP" +Reduce the amount of time to sleep by specified usec. +This option takes an integer number as its argument. +The default \fInumber\fP for this option is: +.ti +4 + 0 +.sp +Reduce the amount of time we would normally sleep between two packets by the +specified number of usec. This provides a "fuzz factor" to compensate for +running on a non-RTOS and other processes using CPU time. Default is disabled. +.TP +.BR \--rdtsc-clicks "=\fInumber\fP" +Specify the RDTSC clicks/usec. +This option may appear up to 1 times. +This option takes an integer number as its argument. +The default \fInumber\fP for this option is: +.ti +4 + 0 +.sp +Override the calculated number of RDTSC clicks/usec which is often the speed of the +CPU in Mhz. Only useful if you specified \fB--timer=rdtsc\fP +.TP +.BR \-v ", " \--verbose +Print decoded packets via tcpdump to STDOUT. +This option may appear up to 1 times. +.sp + +.TP +.BR \-A " \fIstring\fP, " \--decode "=" \fIstring\fP +Arguments passed to tcpdump decoder. +This option may appear up to 1 times. +This option must appear in combination with the following options: +verbose. +.sp +When enabling verbose mode (\fB-v\fP) you may also specify one or more +additional arguments to pass to \fBtcpdump\fP to modify the way packets +are decoded. By default, \-n and \-l are used. Be sure to +quote the arguments like: \-A "-axxx" so that they are not interpreted +by tcpreplay. Please see the tcpdump(1) man page for a complete list of +options. +.TP +.BR \-K ", " \--enable-file-cache +Enable caching of packets to internal memory. +This option must appear in combination with the following options: +loop. +.sp +Cache pcap file(s) the first time they are cached in RAM so that subsequent +loops don't incurr any disk I/O latency in order to increase performance. Make +sure you have enough free RAM to store the entire pcap file(s) in memory or the +system will swap and performance will suffer. +.TP +.BR \--preload-pcap +Preloads packets into RAM before sending. +.sp +This option loads the specified pcap(s) into RAM before starting to send in order +to improve replay performance while introducing a startup performance hit. +Preloading can be used with or without \fB--loop\fP and implies +\fB--enable-file-cache\fP. +.TP +.BR \-c " \fIstring\fP, " \--cachefile "=" \fIstring\fP +Split traffic via a tcpprep cache file. +This option may appear up to 1 times. +.sp + +.TP +.BR \-i " \fIstring\fP, " \--intf1 "=" \fIstring\fP +Server/primary traffic output interface. +This option may appear up to 1 times. +.sp + +.TP +.BR \-I " \fIstring\fP, " \--intf2 "=" \fIstring\fP +Client/secondary traffic output interface. +This option may appear up to 1 times. +This option must appear in combination with the following options: +cachefile. +.sp + +.TP +.BR \--listnics +List available network interfaces and exit. +.sp + +.TP +.BR \-l " \fInumber\fP, " \--loop "=" \fInumber\fP +Loop through the capture file X times. +This option may appear up to 1 times. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +greater than or equal to 0 +.fi +.in -4 +The default \fInumber\fP for this option is: +.ti +4 + 1 +.sp + +.TP +.BR \--pktlen +Override the snaplen and use the actual packet len. +This option may appear up to 1 times. +.sp +By default, tcpreplay will send packets based on the size of the "snaplen" +stored in the pcap file which is usually the correct thing to do. However, +occasionally, tools will store more bytes then told to. By specifying this +option, tcpreplay will ignore the snaplen field and instead try to send +packets based on the original packet length. Bad things may happen if +you specify this option. +.TP +.BR \-L " \fInumber\fP, " \--limit "=" \fInumber\fP +Limit the number of packets to send. +This option may appear up to 1 times. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +greater than or equal to 1 +.fi +.in -4 +The default \fInumber\fP for this option is: +.ti +4 + \-1 +.sp +By default, tcpreplay will send all the packets. Alternatively, you can +specify a maximum number of packets to send. +.TP +.BR \-x " \fIstring\fP, " \--multiplier "=" \fIstring\fP +Modify replay speed to a given multiple. +This option may appear up to 1 times. +This option must not appear in combination with any of the following options: +pps, mbps, oneatatime, topspeed. +.sp +Specify a floating point value to modify the packet replay speed. +Examples: +.nf + 2.0 will replay traffic at twice the speed captured + 0.7 will replay traffic at 70% the speed captured +.fi +.TP +.BR \-p " \fInumber\fP, " \--pps "=" \fInumber\fP +Replay packets at a given packets/sec. +This option may appear up to 1 times. +This option must not appear in combination with any of the following options: +multiplier, mbps, oneatatime, topspeed. +This option takes an integer number as its argument. +.sp + +.TP +.BR \-M " \fIstring\fP, " \--mbps "=" \fIstring\fP +Replay packets at a given Mbps. +This option may appear up to 1 times. +This option must not appear in combination with any of the following options: +multiplier, pps, oneatatime, topspeed. +.sp +Specify a floating point value for the Mbps rate that tcpreplay +should send packets at. +.TP +.BR \-t ", " \--topspeed +Replay packets as fast as possible. +This option must not appear in combination with any of the following options: +mbps, multiplier, pps, oneatatime. +.sp + +.TP +.BR \-o ", " \--oneatatime +Replay one packet at a time for each user input. +This option must not appear in combination with any of the following options: +mbps, pps, multiplier, topspeed. +.sp +Allows you to step through one or more packets at a time. +.TP +.BR \--pps-multi "=\fInumber\fP" +Number of packets to send for each time interval. +This option must appear in combination with the following options: +pps. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +greater than or equal to 1 +.fi +.in -4 +The default \fInumber\fP for this option is: +.ti +4 + 1 +.sp +When trying to send packets at very high rates, the time between each packet +can be so short that it is impossible to accurately sleep for the required +period of time. This option allows you to send multiple packets at a time, +thus allowing for longer sleep times which can be more accurately implemented. +.TP +.BR \-P ", " \--pid +Print the PID of tcpreplay at startup. +.sp + +.TP +.BR \--stats "=\fInumber\fP" +Print statistics every X seconds. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +greater than or equal to 1 +.fi +.in -4 +.sp +Note that this is very much a "best effort" and long delays between +sending packets may cause equally long delays between printing statistics. +.TP +.BR \-V ", " \--version +Print version information. +.sp + +.TP +.BR \-h ", " \--less-help +Display less usage information and exit. +.sp + +.TP +.BR \-H , " \--help" +Display usage information and exit. +.TP +.BR \-! , " \--more-help" +Extended usage information passed thru pager. +.TP +.BR \- " [\fIrcfile\fP]," " \--save-opts" "[=\fIrcfile\fP]" +Save the option state to \fIrcfile\fP. The default is the \fIlast\fP +configuration file listed in the \fBOPTION PRESETS\fP section, below. +.TP +.BR \- " \fIrcfile\fP," " \--load-opts" "=\fIrcfile\fP," " \--no-load-opts" +Load options from \fIrcfile\fP. +The \fIno-load-opts\fP form will disable the loading +of earlier RC/INI files. \fI--no-load-opts\fP is handled early, +out of order. +.SH OPTION PRESETS +Any option that is not marked as \fInot presettable\fP may be preset +by loading values from configuration ("RC" or ".INI") file(s). +The \fIhomerc\fP file is "\fI$$/\fP", unless that is a directory. +In that case, the file "\fI.tcpreplayrc\fP" +is searched for within that directory. +.SH "SIGNALS" +tcpreplay understands the following signals: +.sp +.IR "\fBSIGUSR1\fP" +Suspend tcpreplay +.sp +.IR "\fBSIGCONT\fP" +Restart tcpreplay +.br + +.SH "SEE ALSO" +tcpreplay-edit(1), tcpdump(1), tcpprep(1), tcprewrite(1), libnet(3) + +.SH "BUGS" +tcpreplay can only send packets as fast as your computer's interface, +processor, disk and system bus will allow. + +Packet timing at high speeds is a black art and very OS/CPU dependent. + +Replaying captured traffic may simulate odd or broken conditions on your +network and cause all sorts of problems. + +In most cases, you can not replay traffic back to/at a server. + +Some operating systems by default do not allow for forging source MAC +addresses. Please consult your operating system's documentation and the +tcpreplay FAQ if you experience this issue. +.SH AUTHOR +Copyright 2000-2010 Aaron Turner + +For support please use the tcpreplay-users@lists.sourceforge.net mailing list. + +The latest version of this software is always available from: +http://tcpreplay.synfin.net/ +.PP +Released under the Free BSD License. +.PP +This manual page was \fIAutoGen\fP-erated from the \fBtcpreplay\fP +option definitions. diff --git a/src/tcpreplay.c b/src/tcpreplay.c new file mode 100644 index 0000000..de57242 --- /dev/null +++ b/src/tcpreplay.c @@ -0,0 +1,2076 @@ +/* $Id: tcpreplay.c 2433 2010-03-28 20:57:36Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * 2013-06-06, LiJia modify for replay packet multiply. + * add two new arguments: + * -m, Replay streams at a given multiple; + * -d, The distance between raw packet and fake replay packet. + * -D, assign tcpreplay send packet driver, support pcap or marsio. + * -s, marsio CPU bind mask. + */ + +#include "config.h" +#include "defines.h" +#include "common.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifndef __USE_BSD +#define __USE_BSD 1 +#endif +#include +#ifndef __FAVOR_BSD +#define __FAVOR_BSD 1 +#endif +#include +#include + +#include "tcpreplay.h" + +#ifdef TCPREPLAY_EDIT +#include "tcpreplay_edit_opts.h" +#include "tcpedit/tcpedit.h" +tcpedit_t *tcpedit; +#else +#include "tcpreplay_opts.h" +#endif + +#include "send_packets.h" +#include "signal_handler.h" + + +tcpreplay_opt_t options; +struct timeval begin, end; +COUNTER bytes_sent, failed, pkts_sent; +int cache_bit, cache_byte; +volatile int didsig; + +#ifdef DEBUG +int debug = 0; +#endif + +#ifdef HAVE_ABSOLUTE_TIME +#include +#endif + +void preload_pcap_file(int file_idx); +void replay_file(int file_idx); +void usage(void); +void init(void); +void post_args(void); + +extern int send_pkt_driver_mode; /* 1:pcap; 12:marsio4; */ + +#ifdef TCPBURST + +int tcpburst_version_VERSION_20180611; + +#define PROCESS_BAR_SW (1) /* ʵʱ */ +#define TCP_BURST_MTU (1514) + +#include +#include +#include +#include "MESA_list.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +#if PROCESS_BAR_SW /* 2013-12-04 LiJia add, for ʵʱʾ */ +static char *dumpfile_name; +static int dumpfile_last_file_index = -1; +static unsigned long dumpfile_total_size; +static unsigned long dumpfile_read_size = 0; +static int dump_times = 0; +static char process_bar[100][101]; + +static unsigned long __get_file_length(const char *file_name) +{ + struct stat file_stat; + + if(stat(file_name, &file_stat) == 0) + { + return file_stat.st_size; + } + return 0; +} + +void process_bar_print(int len, const char *filename) +{ + double percent; + int index; + + if(dumpfile_total_size < 512 * 10000){ + return; + } + + dump_times++; + dumpfile_read_size += len + sizeof(struct pcap_pkthdr); + + if((dump_times % 10240) == 0){ + if(dumpfile_read_size < dumpfile_total_size){ + percent = ((double)dumpfile_read_size/(double)dumpfile_total_size) * 100; + }else{ + percent = 100.00; + } + index = (int )percent; + if(index >= 99){ + index = 99; + } + printf("\033[HReply dumpfile '%s':\n", filename); + printf("%s \033[41m%0.2f%% \033[0m\n", process_bar[index], percent); + } +} + +void process_bar_prt_all(void) +{ + int i; + for(i = 0; i < 100; i++){ + printf("%s\n", process_bar[i]); + } +} + +int process_bar_prt_init(void) +{ + int i, j; + + for(i = 0; i < 100; i++){ + for(j = 0; j < 100; j++){ + if(j <= i){ + process_bar[i][j] = '>'; + }else{ + process_bar[i][j] = '.'; + } + } + process_bar[i][100] = '\0'; + } + + printf("\033[2J"); +} +#else +void process_bar_print(int len, const char *filename) +{ +} +#endif + + +typedef struct{ + char *encap_cfg_file; + unsigned char outer_vxlan_smac[6]; + unsigned short outer_vxlan_sport_net; + unsigned char outer_vxlan_dmac[6]; + unsigned short outer_vxlan_dport_net; + unsigned int outer_vxlan_sip_net; + unsigned int outer_vxlan_dip_net; + +}encap_args_t; + +static encap_args_t g_vxlan_encap_args; + + +/* asciiַת16 */ +static char MESA_ascii_to_hex(char ascii) +{ + char c = 0; + + switch(ascii) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + c = ascii - 0x30; + break; + + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + c = 10 + ascii - 0x61; + break; + + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + c = 10 + ascii - 0x41; + break; + } + + return c; +} + + /* 2012-04-11 LiJia add,MACַʽתΪ16MACַ. +: + str: MACַַ + delim: ַָΪ':', '-',: xx:xx:xx:xx:xx:xx + ַ޷ָdelimΪ-1. + mac: 洢MACַ(ָ),Ϊ, + MACַΪ11:22:33:44:55:66,mac[0]Ϊ0x11,mac[5]Ϊ0x66. +ֵ: + 0: + -1: +*/ +static int MESA_mac_pton(const char *str, int delim, char *mac) +{ +#define MAC_STR_LEN_DELIM (17) /* length of "11:22:33:44:55:66" */ +#define MAC_STR_LEN_NODELIM (12) /* length of "112233445566" */ + const char *s = str; + int i; + + /* Ϸ */ + if(delim != -1) + { + if(strlen(str) != MAC_STR_LEN_DELIM) + { + printf("MAC string length error!\n"); + return -1; + } + } + else + { + if(strlen(str) != MAC_STR_LEN_NODELIM) + { + printf("MAC string length error!\n"); + return -1; + } + } + + /* Ϸԣͬʱת16ֵ */ + for(i = 0; i < 6; i++) + { + mac[i] = 0; /* 㣬ֵ䶼ǻ */ + if(isxdigit(*s)==0) + { + printf("MAC string type error!\n"); + return -1; + } + mac[i] |= MESA_ascii_to_hex(*s) << 4; + s++; + + if(isxdigit(*s)==0) + { + printf("MAC string type error!\n"); + return -1; + } + mac[i] |= MESA_ascii_to_hex(*s); + s++; + + if((delim != -1) && i<5 && (*s++ != (char)delim)) + { + printf("MAC string type error!\n"); + return -1; + } + } + + return 0; +} + +/* +[main] +vxlan_smac=74:86:7a:d0:12:fc +vxlan_dmac=00-01-6C-53-A9-94 +vxlan_sip=10.0.6.201 +vxlan_dip=10.0.6.59 +vxlan_sport=12345 +vxlan_dport=4789 +*/ +static int parse_encap_cfg_file(const char *filename) +{ + printf("parse encapsulation cfg file:%s\n", filename); + int ret; + unsigned char vxlan_smac[20], vxlan_dmac[20]; + unsigned char sip_str[16], dip_str[16]; + unsigned short tport; + + MESA_load_profile_string_def(options.encap_cfg_file, "main", "vxlan_smac", vxlan_smac, 20, "#"); + MESA_load_profile_string_def(options.encap_cfg_file, "main", "vxlan_dmac", vxlan_dmac, 20, "#"); + + MESA_load_profile_string_def(options.encap_cfg_file, "main", "vxlan_sip", sip_str, 16, "#"); + MESA_load_profile_string_def(options.encap_cfg_file, "main", "vxlan_dip", dip_str, 16, "#"); + + MESA_load_profile_short_def(options.encap_cfg_file, "main", "vxlan_sport", &tport, 0); + g_vxlan_encap_args.outer_vxlan_sport_net = htons(tport); + + MESA_load_profile_short_def(options.encap_cfg_file, "main", "vxlan_dport", &tport, 0); + g_vxlan_encap_args.outer_vxlan_dport_net = htons(tport); + + ret = MESA_mac_pton((char *)vxlan_smac, ':', g_vxlan_encap_args.outer_vxlan_smac); + if(ret < 0){ + ret = MESA_mac_pton((char *)vxlan_smac, '-', g_vxlan_encap_args.outer_vxlan_smac); + if(ret < 0){ + printf("config: %s->vxlan_smac invalid!\n", options.encap_cfg_file); + return -1; + } + } + + ret = MESA_mac_pton((char *)vxlan_dmac, ':', g_vxlan_encap_args.outer_vxlan_dmac); + if(ret < 0){ + ret = MESA_mac_pton((char *)vxlan_dmac, '-', g_vxlan_encap_args.outer_vxlan_dmac); + if(ret < 0){ + printf("config: %s->vxlan_dmac invalid!\n", options.encap_cfg_file); + return -1; + } + } + + ret = inet_pton(AF_INET, sip_str, &g_vxlan_encap_args.outer_vxlan_sip_net); + if(ret <= 0){ + printf("config: %s->vxlan_sip invalid!\n", options.encap_cfg_file); + return -1; + } + + ret = inet_pton(AF_INET, dip_str, &g_vxlan_encap_args.outer_vxlan_dip_net); + if(ret <= 0){ + printf("config: %s->vxlan_dip invalid!\n", options.encap_cfg_file); + return -1; + } + + return 0; +} + +/*************************** ڲʵֽӿ ********************************/ + +/* + * Simple doubly linked list implementation. + * + * Some of the internal functions ("__xxx") are useful when + * manipulating whole lists rather than single entries, as + * sometimes we already know the next/prev entries and we can + * generate better code by using them directly rather than + * using the generic single-entry routines. + */ + +static void INIT_LIST_HEAD(struct list_index *head) +{ + head->nextele = head; + head->preele = head; +} + + +/* + * Insert a new entry between two known consecutive entries. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ +static inline void __list_add(struct list_index *new_list, + struct list_index *prev, + struct list_index *next) +{ + next->preele = new_list; + new_list->nextele = next; + new_list->preele = prev; + prev->nextele = new_list; +} + +/** + * list_add - add a new entry + * @new: new entry to be added + * @head: list head to add it after + * + * Insert a new entry after the specified head. + * This is good for implementing stacks. + * lijia comment: list_add()½ڵheadhead->next֮. + */ +void list_add(struct list_index *new_list, struct list_index *head) +{ + __list_add(new_list, head, head->nextele); +} + + +/** + * list_add_tail - add a new entry + * @new: new entry to be added + * @head: list head to add it before + * + * Insert a new entry before the specified head. + * This is useful for implementing queues. + * lijia comment: list_add_tail()½ڵheadhead->prev֮. + */ +void list_add_tail(struct list_index *new_list, struct list_index *head) +{ + __list_add(new_list, head->preele, head); +} + +/* + * Delete a list entry by making the prev/next entries + * point to each other. + * + * This is only for internal list manipulation where we know + * the prev/next entries already! + */ +static inline void __list_del(struct list_index * prev, struct list_index * next) +{ + next->preele = prev; + prev->nextele = next; +} + +static inline void __list_del_entry(struct list_index *entry) +{ + __list_del(entry->preele, entry->nextele); + entry->nextele = NULL; + entry->preele = NULL; +} + +/** + * list_del - deletes entry from list. + * @entry: the element to delete from the list. + * Note: list_empty() on entry does not return true after this, the entry is + * in an undefined state. + */ + +static void list_del(struct list_index *entry) +{ + __list_del(entry->preele, entry->nextele); + entry->nextele = NULL; + entry->preele = NULL; +} + + +/** + * list_move - delete from one list and add as another's head + * @list: the entry to move + * @head: the head that will precede our entry + */ +static void list_move(struct list_index *list, struct list_index *head) +{ + __list_del_entry(list); + list_add(list, head); +} + +/** + * list_move_tail - delete from one list and add as another's tail + * @list: the entry to move + * @head: the head that will follow our entry + */ +static void list_move_tail(struct list_index *list, struct list_index *head) +{ + __list_del_entry(list); + list_add_tail(list, head); +} + +#if 0 +/** + * list_empty - tests whether a list is empty + * @head: the list to test. + */ +static int list_empty(const struct list_index *head) +{ + return head->nextele == head; +} +#endif + +/** + * list_empty_careful - tests whether a list is empty and not being modified + * @head: the list to test + * + * Description: + * tests whether a list is empty _and_ checks that no other CPU might be + * in the process of modifying either member (next or prev) + * + * NOTE: using list_empty_careful() without synchronization + * can only be safe if the only activity that can happen + * to the list entry is list_del_init(). Eg. it cannot be used + * if another CPU could re-list_add() it. + */ +static int list_empty_careful(const struct list_index *head) +{ + MESA_queue_head_t *next = head->nextele; + return (next == head) && (next == head->preele); +} + +static inline void list_count_init(void **list_count) +{ + long *p_c = (long *)list_count; + *p_c = 0; +} + +static inline void list_count_inc(void **list_count) +{ + long *p_c = (long *)list_count; + long c = *p_c; + *p_c = c + 1; +} + +static inline void list_count_dec(void **list_count) +{ + long *p_c = (long *)list_count; + long c = *p_c; + *p_c = c - 1; +} + +#if MESA_LIST_CHECK != 0 +/*Function:Check the intergrity of the list,to dectect memory mess. +*Input: Queue Head,data check call back function +*Output: return a number below zero,if the queue got a problem,else return 0; +*Author:zhengchao@iie.ac.cn at 20100913 +*/ +#if 0 +static int MESA_q_list_check(const MESA_queue_head_t *qhead_obj,int(*quiddity_check)(const void *)) +{ + MESA_list_index_t *p=NULL, *head=NULL; +// int linked_ele_number=0; + int ret=0; +// return 0; + if(qhead_obj->listcount==0) + { + if(qhead_obj->head!=NULL||qhead_obj->head!=NULL) + { + ret=-1; + } + goto exit; + } + + if(qhead_obj->head==NULL||qhead_obj->tail==NULL) + { + ret=-2; + goto exit; + } + if(qhead_obj->listcount>1){ + if(qhead_obj->head->preele!=NULL||qhead_obj->head->nextele==NULL) + { + ret=-3; + goto exit; + } + if(qhead_obj->tail->preele==NULL||qhead_obj->tail->nextele!=NULL) + { + ret=-4; + goto exit; + } + + head = p = qhead_obj->head; + p = p->nextele; + while(p != head) + { + if(p == NULL) break; + if(p == head){ + ret = -5; /* has a cycle */ + goto exit; + } + p = p->nextele; + } + } + /* + pre=qhead_obj->head; + p=pre->nextele; + while(p!=NULL){ + linked_ele_number++; + + //Is the declared size equal to element linked number; + if(linked_ele_number > qhead_obj->listcount) + { + ret=-5; + goto exit; + } + + //Is element's preele pointer equal to its preele + if(pre!=p->preele) + { + ret=-6; + goto exit; + } + if(quiddity_check!=NULL){ + if(0>quiddity_check(p->quiddity)) + { + ret =-7; + goto exit; + } + } + pre=p; + p=p->nextele; + } + //Is the last element equal to tail + if(pre!=qhead_obj->tail) + { + ret=-8; + goto exit; + } + if(linked_ele_number !=qhead_obj->listcount-1) + { + ret=-9; + goto exit; + } + */ +exit: + if(ret<0) + { + return ret; + } + else + { + return 1; + } + +} +#endif + +#if 2==MESA_LIST_CHECK +/*Simple check,not raversal*/ +static int MESA_q_is_item_in_list(MESA_queue_head_t *qhead_obj, MESA_list_index_t *lindex_obj){ +// MESA_list_index_t* pre=lindex_obj->preele; +// MESA_list_index_t*next=lindex_obj->nextele; + MESA_list_index_t*p=NULL; + int i, num; + + if(list_empty_careful(qhead_obj)){ + return 0; + } + + p = qhead_obj->nextele; + num = MESA_get_list_count(qhead_obj); + i = 0; + while((p != qhead_obj) && (i <= num)) + { + if(p == lindex_obj) + { + return 1; + } + p=p->nextele; + i++; + } + + return 0; + +} +#endif + +/*every MESA_list_index_t leaves list,its pre and next will be set NULL + * In Configuration Transmiiter project, not null element will consider in list, + * pre and next is NULL only if there's one element in list only*/ +static int MESA_q_is_item_in_list_quick(MESA_queue_head_t *qhead_obj, MESA_list_index_t *lindex_obj) +{ + //empty list + if(list_empty_careful(qhead_obj)){ + return 0; + } + + //have more element + if(lindex_obj->nextele==NULL || lindex_obj->preele==NULL){ + return 0; + } + if(lindex_obj->nextele->preele != lindex_obj){ + return 0; + } + if(lindex_obj->preele->nextele != lindex_obj){ + return 0; + } + + return 1; + +} +#endif + +/*************************** ⲿýӿ ********************************/ + + +/* + һʹMESA_listģʱô˳ʼģ. +*/ +int MESA_list_init(MESA_queue_head_t *head) +{ + INIT_LIST_HEAD(head); + list_count_init((void **)&head->quiddity); + return 0; +} + +/* Ϊheadʹʱ, "quiddity"Ϊһlongͱ,ڴ洢Ԫ */ +long MESA_get_list_count(const MESA_queue_head_t *head) +{ + return (long)head->quiddity; +} + +MESA_list_index_t *MESA_q_read_head(const MESA_queue_head_t *qhead_obj) +{ + if(list_empty_careful(qhead_obj)){ + return NULL; + } + return qhead_obj->nextele; +} + + +MESA_list_index_t *MESA_q_get_head(MESA_queue_head_t *qhead_obj) +{ + MESA_list_index_t *out; + if(list_empty_careful(qhead_obj)){ + return NULL; + } + out = qhead_obj->nextele; + list_del(out); + list_count_dec((void **)&qhead_obj->quiddity); + + return out; +} + +MESA_list_index_t *MESA_q_get_tail(MESA_queue_head_t *qhead_obj) +{ + MESA_list_index_t *out; + if(list_empty_careful(qhead_obj)){ + return NULL; + } + out = qhead_obj->preele; + list_del(out); + list_count_dec((void **)&qhead_obj->quiddity); + + return out; +} + +MESA_list_index_t *MESA_q_join_tail(MESA_queue_head_t *qhead_obj, MESA_list_index_t *lindex_obj) +{ + list_add_tail(lindex_obj, qhead_obj); + list_count_inc((void **)&qhead_obj->quiddity); + + return lindex_obj; +} + +MESA_list_index_t *MESA_q_join_head(MESA_queue_head_t *qhead_obj, MESA_list_index_t *lindex_obj) +{ + list_add(lindex_obj, qhead_obj); + list_count_inc((void **)&qhead_obj->quiddity); + + return lindex_obj; +} + +MESA_list_index_t *MESA_q_leave_list(MESA_queue_head_t *qhead_obj, MESA_list_index_t *lindex_obj) +{ +#if 1==MESA_LIST_CHECK + if(0 == MESA_q_is_item_in_list_quick(qhead_obj, lindex_obj)){ + //return NULL; + assert(0); //critical + } +#elif 2==MESA_LIST_CHECK + if(0 == MESA_q_is_item_in_list(qhead_obj, lindex_obj)){ + //return NULL; + assert(0); //critical + } +#endif + list_del(lindex_obj); + list_count_dec((void **)&qhead_obj->quiddity); + + return lindex_obj; +} + +MESA_list_index_t *MESA_q_move_head(MESA_queue_head_t *qhead_obj, MESA_list_index_t *lindex_obj) +{ +#if 1==MESA_LIST_CHECK + if(0 == MESA_q_is_item_in_list_quick(qhead_obj, lindex_obj)){ + //return NULL; + assert(0); //critical + } +#elif 2==MESA_LIST_CHECK + if(0 == MESA_q_is_item_in_list(qhead_obj, lindex_obj)){ + //return NULL; + assert(0); //critical + } +#endif + list_move(lindex_obj, qhead_obj); + + return lindex_obj; +} + +MESA_list_index_t *MESA_q_move_tail(MESA_queue_head_t *qhead_obj, MESA_list_index_t *lindex_obj) +{ +#if 1==MESA_LIST_CHECK + if(0 == MESA_q_is_item_in_list_quick(qhead_obj,lindex_obj)){ + //return NULL; + assert(0); //critical + } +#elif 2==MESA_LIST_CHECK + if(0 == MESA_q_is_item_in_list(qhead_obj, lindex_obj)){ + //return NULL; + assert(0); //critical + } +#endif + list_move_tail(lindex_obj, qhead_obj); + + return lindex_obj; +} + +/************************ MESA_fixed_q implement *************************/ +/************************ MESA_fixed_q ڲʵֽӿ***********************/ +MESA_fixed_q_t *__create_fixed_q_elem(long max_elem_len) +{ + MESA_fixed_q_t *tq; + MESA_fixed_qelem_t *tqelem; + void *tdata; + + tq = (MESA_fixed_q_t *)malloc(sizeof(MESA_fixed_q_t)); + memset(tq, 0, sizeof(MESA_fixed_q_t)); + + tdata = malloc(max_elem_len); + + tqelem = (MESA_fixed_qelem_t *)malloc(sizeof(MESA_fixed_qelem_t)); + tqelem->data = tdata; + tqelem->datalen = 0; + + tq->quiddity = (void *)tqelem; + + return tq; +} + + +/************************ MESA_fixed_q ⲿӿ **************************/ +/* + һʹMESA_fixedģʱô˳ʼģ. + total_elem_num: total queue element number; + max_elem_len : max length of a queue element. +*/ +int MESA_fixed_q_init(MESA_fixed_q_t *__head, long total_elem_num, long max_elem_len) +{ + long i; + MESA_fixed_q_t *real_head, *real_tail; + MESA_fixed_qelem_t *tqelem; + + if(!__head || (0 >= total_elem_num) || (0 >= max_elem_len)){ + return -1; + } + + __head->quiddity = malloc(sizeof(MESA_fixed_qelem_t)); + + /* һڵγԻ˫ */ + real_head = __create_fixed_q_elem(max_elem_len); + INIT_LIST_HEAD(real_head); + + /* Ľڵ */ + for(i = 0; i < total_elem_num; i++){ + real_tail = __create_fixed_q_elem(max_elem_len); + list_add_tail(real_tail, real_head); + } + + __head->nextele = (struct list_index *)real_head; /* ͷڵ.nexteleڴ洢ǰеʵʶͷڵָ */ + __head->preele = (struct list_index *)real_head; /* ͷڵ.preeleڴ洢ǰеʵʶβڵָ */ + tqelem = (MESA_fixed_qelem_t *)__head->quiddity; + list_count_init(&tqelem->data); /* ͷڵ.dataڴ洢ǰеʵԪ */ + tqelem->datalen = max_elem_len; /* ͷڵ.datalenڴ洢ǰеԪ󳤶 */ + + return 0; +} + +long MESA_fixed_q_count(const MESA_fixed_q_t *__head) +{ + const MESA_fixed_qelem_t *tqelem = (MESA_fixed_qelem_t *)__head->quiddity; + return (long)tqelem->data; +} + +MESA_fixed_qelem_t *MESA_fixed_q_read_head(MESA_fixed_q_t *__head) +{ + MESA_fixed_q_t *real_head = (MESA_fixed_q_t *)__head->nextele; + MESA_fixed_q_t *real_tail = (MESA_fixed_q_t *)__head->preele; + + if(list_empty_careful(real_head)){ + return NULL; + } + + if(MESA_fixed_q_count(__head) == 0){ /* queue is empty */ + return NULL; + } + + return (MESA_fixed_qelem_t *)(real_head->quiddity); +} + +MESA_fixed_qelem_t *MESA_fixed_q_get_head(MESA_fixed_q_t *__head) +{ + MESA_fixed_q_t *real_head = (MESA_fixed_q_t *)__head->nextele; + MESA_fixed_q_t *real_tail = (MESA_fixed_q_t *)__head->preele; + MESA_fixed_qelem_t *tq, *ret; + + if(list_empty_careful(real_head)){ + return NULL; + } + + if(MESA_fixed_q_count(__head) == 0){ /* queue is empty */ + return NULL; + } + + tq = (MESA_fixed_qelem_t *)__head->quiddity; + list_count_dec(&tq->data); + + ret = (MESA_fixed_qelem_t *)real_head->quiddity; + __head->nextele = real_head->nextele; + + return ret; +} + +#if 0 +const MESA_fixed_qelem_t *MESA_fixed_q_get_tail(MESA_fixed_q_t *__head) +{ + MESA_fixed_q_t *real_head = (MESA_fixed_q_t *)__head->nextele; + MESA_fixed_q_t *real_tail = (MESA_fixed_q_t *)__head->preele; + MESA_fixed_qelem_t *tq, *ret; + + if(list_empty_careful(real_head)){ + return NULL; + } + + if(real_head == real_tail){ /* queue is empty */ + return NULL; + } + + tq = (MESA_fixed_qelem_t *)__head->quiddity; + list_count_dec(&tq->data); + + ret = (MESA_fixed_qelem_t *)real_tail->quiddity; + __head->preele = real_tail->preele; + + return ret; +} + + +const MESA_fixed_qelem_t *MESA_fixed_q_join_head(MESA_fixed_q_t *__head, void *data, long datalen) +{ + MESA_fixed_q_t *real_head = (MESA_fixed_q_t *)__head->nextele; + MESA_fixed_q_t *real_tail = (MESA_fixed_q_t *)__head->preele; + MESA_fixed_qelem_t *tq, *ret; + MESA_fixed_q_t *join_place; + + if((real_head->preele == real_tail) + ||(real_tail->nextele == real_head)){ /* queue is full */ + return NULL; + } + + tq = (MESA_fixed_qelem_t *)__head->quiddity; + if(tq->datalen < datalen){ + return NULL; + } + list_count_inc(&tq->data); + + join_place = real_head->preele; + ret = (MESA_fixed_qelem_t *)join_place->quiddity; + memcpy(ret->data, data, datalen); + ret->datalen = datalen; + + __head->nextele = join_place; /* update head pointer */ + + return ret; +} +#endif + +MESA_fixed_qelem_t *MESA_fixed_q_join_tail(MESA_fixed_q_t *__head, void *data, long datalen) +{ + MESA_fixed_q_t *real_head = (MESA_fixed_q_t *)__head->nextele; + MESA_fixed_q_t *real_tail = (MESA_fixed_q_t *)__head->preele; + MESA_fixed_qelem_t *tq, *ret; + MESA_fixed_q_t *join_place; + + tq = (MESA_fixed_qelem_t *)__head->quiddity; + + if((real_head->preele == real_tail) + ||(real_tail->nextele == real_head)){ /* queue is full */ + return NULL; + } + + if(tq->datalen < datalen){ + return NULL; + } + list_count_inc(&tq->data); + + join_place = real_tail->nextele; + ret = (MESA_fixed_qelem_t *)join_place->quiddity; + memcpy(ret->data, data, datalen); + ret->datalen = datalen; + + __head->preele = join_place; /* update tail pointer */ + + return ret; +} + +void MESA_fixed_q_destroy(MESA_fixed_q_t *__head) +{ + MESA_fixed_q_t *real_head = (MESA_fixed_q_t *)__head->nextele; + MESA_fixed_q_t *del; + MESA_fixed_qelem_t *tq; + + while(!list_empty_careful(real_head)){ + del = real_head->nextele; + list_del(del); + tq = (MESA_fixed_qelem_t *)del->quiddity; + free(tq->data); + free(tq); + free(del); + } + tq = (MESA_fixed_qelem_t *)real_head->quiddity; + free(tq->data); + free(tq); + free(real_head); + + free(__head->quiddity); + + return; +} + +#ifdef __cplusplus +} +#endif + + +MESA_fixed_q_t *pkt_queue; + + +#ifdef MARSIO +#include "marsio.h" +static struct mr_instance * tcpburst_marsio4_instance; +static struct mr_vdev *tcpburst_marsio4_vdev; +static struct mr_sendpath *tcpburst_marsio4_sendpath; +static char *marsio_send_device; +long marsio_cpu_mask = 0x02; + +int stream_burst_marsio_init(void) +{ + char app_name[64]; + char *cpu_msk_str; + +#ifndef TCPREPLAY_EDIT + cpu_msk_str = OPT_VALUE_CPU_MASK; + if(strncasecmp("0x", cpu_msk_str, 2) != 0){ + fprintf(stderr,"%s\n","cpu-mask arg invalid, for example: 0xF0!\n"); + exit(1); + } + marsio_cpu_mask = strtoul(cpu_msk_str, NULL, 16); +#endif + + tcpburst_marsio4_instance = marsio_create(); + if(NULL == tcpburst_marsio4_instance) { + fprintf(stderr,"%s\n","marsio_create() error!\n"); + exit(1); + } + + int marsio_opt = 1; + marsio_option_set(tcpburst_marsio4_instance, MARSIO_OPT_THREAD_NUM, &marsio_opt, sizeof(int)); + + marsio_option_set(tcpburst_marsio4_instance, MARSIO_OPT_THREAD_MASK, &marsio_cpu_mask, sizeof(long)); + + srand(time(NULL)); + snprintf(app_name, 64, "%s_%c%c%c", "tcpburst", 'a'+random()%26, 'a'+random()%26,'a'+random()%26); + + if(marsio_init(tcpburst_marsio4_instance, app_name) < 0){ + fprintf(stderr,"%s\n","marsio_init() error!\n"); + exit(1); + } + + tcpburst_marsio4_vdev = marsio_open_device(tcpburst_marsio4_instance, marsio_send_device, 0/* rx_stream */, 1 /* tx_stream */); + if(NULL == tcpburst_marsio4_vdev) { + fprintf(stderr,"%s\n","marsio_open_device() error!\n"); + exit(1); + } + + tcpburst_marsio4_sendpath = marsio_sendpath_create_by_vdev(tcpburst_marsio4_vdev); + if(NULL == tcpburst_marsio4_sendpath) { + fprintf(stderr,"%s\n","marsio_sendpath_create_by_vdev() error!\n"); + exit(1); + } + + return 0; +} +#endif + +static int stream_burst_init(void) +{ + int i; + + pkt_queue = (MESA_fixed_q_t *)malloc(options.stream_multiple * sizeof(MESA_fixed_q_t)); + memset(pkt_queue, 0, options.stream_multiple * sizeof(MESA_fixed_q_t)); + + if(options.pkt_distance > 0) + { + for(i = 0; i < options.stream_multiple; i++) + { + MESA_fixed_q_init(&pkt_queue[i], options.pkt_distance*(i+1), TCP_BURST_MTU); + } + } + +#ifdef MARSIO + if(12 == send_pkt_driver_mode){ + stream_burst_marsio_init(); + } +#endif + +#if PROCESS_BAR_SW + process_bar_prt_init(); +#endif + return 0; +} + + +/* + return value: + 1: src addr(ip or port) bigger than dst addr; + -1: src addr(ip or port) smaller than dst addr; +*/ +static inline int stream_addr_cmp_tcp(struct ip *iphdr, struct tcphdr *tcphdr) +{ + int ret; + + if(iphdr->ip_src.s_addr > iphdr->ip_dst.s_addr) + { + ret = 1; + } + else if(iphdr->ip_src.s_addr < iphdr->ip_dst.s_addr) + { + ret = -1; + } + else + { + if(tcphdr->th_sport > tcphdr->th_dport) + { + ret = 1; + } + else + { + ret = -1; + } + } + + return ret; +} + +/* + return value: + 1: src addr(ip or port) bigger than dst addr; + -1: src addr(ip or port) smaller than dst addr; +*/ +static inline int stream_addr_cmp_udp(struct ip *iphdr, struct udphdr *udphdr) +{ + int ret; + + if(iphdr->ip_src.s_addr > iphdr->ip_dst.s_addr) + { + ret = 1; + } + else if(iphdr->ip_src.s_addr < iphdr->ip_dst.s_addr) + { + ret = -1; + } + else + { + if(udphdr->uh_sport > udphdr->uh_dport) + { + ret = 1; + } + else + { + ret = -1; + } + } + + return ret; +} + + +/* ޸ԭIPַʹԪԭͬ. + Ϊ˲¼УͣԴﵽϸߵķʣ + ĵַʱIPַ޸ģӺͼٵֵҪ. +*/ +static int stream_edit_addr(u_char *pkt, int differ) +{ + struct ip *iphdr; + struct tcphdr *tcphdr; + struct udphdr *udphdr; + + differ *= 3; + + iphdr = (struct ip *)(pkt + 14); + + if(IPPROTO_TCP == iphdr->ip_p) + { + tcphdr = (struct tcphdr *)(pkt + 14 + iphdr->ip_hl*4); + if(stream_addr_cmp_tcp(iphdr, tcphdr) < 0) + { + iphdr->ip_src.s_addr -= differ; + iphdr->ip_dst.s_addr += differ; + } + else + { + iphdr->ip_src.s_addr += differ; + iphdr->ip_dst.s_addr -= differ; + } + } + else if(IPPROTO_UDP == iphdr->ip_p) + { + udphdr = (struct udphdr *)(pkt + 14 + iphdr->ip_hl*4); + if(stream_addr_cmp_tcp(iphdr, udphdr) < 0) + { + iphdr->ip_src.s_addr -= differ; + iphdr->ip_dst.s_addr += differ; + } + else + { + iphdr->ip_src.s_addr += differ; + iphdr->ip_dst.s_addr -= differ; + } + }else{ /* ӶGRE, IPinIP, 6over4֧ */ + if(iphdr->ip_src.s_addr <= iphdr->ip_dst.s_addr){ + iphdr->ip_src.s_addr += differ; + iphdr->ip_dst.s_addr -= differ; + }else{ + iphdr->ip_src.s_addr -= differ; + iphdr->ip_dst.s_addr += differ; + } + } + + return 0; +} + +#ifdef MARSIO +static int stream_burst_send_pkt_by_marsio(struct mr_sendpath *handle, const u_char *pkt, size_t pktlen) +{ + marsio_buff_t *send_mbuf[1]; + char *real_buf; + int ret; + + if(pktlen > TCP_BURST_MTU){ + return -1; + } + + ret = marsio_buff_malloc_global(tcpburst_marsio4_instance, send_mbuf, 1, MARSIO_SOCKET_ID_ANY, 0); + if(ret < 0){ + return -1; + } + + /* ˴ʹappendmtod, appendڲʵʰset datalenIJ */ + real_buf = marsio_buff_append(send_mbuf[0], pktlen); + + memcpy(real_buf, pkt, pktlen); + + marsio_send_burst(tcpburst_marsio4_sendpath, 0, send_mbuf, 1); + + return pktlen; +} +#endif + +#ifdef MARSIO +static stream_burst_send_pkt_multiple(void *handle, const u_char *pkt, size_t pktlen) +{ + marsio_buff_t *send_mbuf[256]; + char *real_buf; + int i, ret; + + ret = marsio_buff_malloc_global(tcpburst_marsio4_instance, send_mbuf, 1, MARSIO_SOCKET_ID_ANY, 0); + if(ret < 0){ + return -1; + } + real_buf = marsio_buff_append(send_mbuf[0], pktlen); + memcpy(real_buf, pkt, pktlen); /* ֻcopyһ */ + + for(i = 1; i < options.stream_multiple; i++){ + send_mbuf[i] = marsio_buff_clone_deep(tcpburst_marsio4_instance, send_mbuf[0], MARSIO_SOCKET_ID_ANY, 0); + real_buf = marsio_buff_mtod(send_mbuf[i]); + stream_edit_addr(real_buf, i + 1); + } + + marsio_send_burst(tcpburst_marsio4_sendpath, 0, send_mbuf, options.stream_multiple); + +#if 0 + if(options.stream_multiple > 1){ + real_buf = marsio_buff_append(send_mbuf[0], pktlen); + memcpy(real_buf, pkt, pktlen); /* ֻcopyһ */ + stream_edit_addr(real_buf, i + 1); + marsio_send_burst_with_options(tcpburst_marsio4_sendpath, 0, send_mbuf, 1, MARSIO_SEND_OPT_NO_FREE); + marsio_buff_reset(send_mbuf[0]); + + for(i = 1; i < options.stream_multiple; i++){ + /* ˴ʹappendmtod, appendڲʵʰset datalenIJ */ + real_buf = marsio_buff_append(send_mbuf[0], pktlen); + stream_edit_addr(real_buf, i + 1); + marsio_send_burst_with_options(tcpburst_marsio4_sendpath, 0, send_mbuf, 1, MARSIO_SEND_OPT_NO_FREE); + marsio_buff_reset(send_mbuf[0]); + } + marsio_buff_free(tcpburst_marsio4_instance, send_mbuf, 1, MARSIO_SOCKET_ID_ANY, 0); + }else{ + /* ˴ʹappendmtod, appendڲʵʰset datalenIJ */ + real_buf = marsio_buff_append(send_mbuf[0], pktlen); + + memcpy(real_buf, pkt, pktlen); + + marsio_send_burst(tcpburst_marsio4_sendpath, 0, send_mbuf, 1); + } +#endif + + return pktlen; +} +#endif + +typedef struct{ + unsigned char flags; + + /*------------byte delim -------*/ + unsigned char reserved[3]; + + /*--------int delim -------*/ + unsigned char vlan_id_half_high; + unsigned char link_layer_type : 4; /* 㱨ķװʽ */ + unsigned char vlan_id_half_low : 4; + unsigned int online_test : 1; + unsigned int link_id : 6; + unsigned int dir : 1; + + unsigned int r7 : 1; + unsigned int r6 : 1; + unsigned int r5 : 1; + unsigned int r4 : 1; + unsigned int vni_flag : 1; + unsigned int r2 : 1; + unsigned int r1 : 1; + unsigned int r0 : 1; + +}tcpburst_vxlan_hdr_t; + +#include +#include +#include +static int sendpacket_with_encapsulation(sendpacket_t *handle, const u_char *pkt, size_t pktlen) +{ + char encap_pkt_buf[2048]; + int ret; + + struct ethhdr *ehdr = (struct ethhdr *)encap_pkt_buf; + memcpy(ehdr->h_source, g_vxlan_encap_args.outer_vxlan_smac, 6); + memcpy(ehdr->h_dest, g_vxlan_encap_args.outer_vxlan_dmac, 6); + ehdr->h_proto = ntohs(ETH_P_IP); + + struct ip *ihdr = (struct ip *)(encap_pkt_buf + sizeof(struct ethhdr)); + ihdr->ip_v = 4; + ihdr->ip_hl = 5; + ihdr->ip_tos = 0; + ihdr->ip_len = htons(sizeof(struct ip) + sizeof(struct udphdr) + sizeof(tcpburst_vxlan_hdr_t) + pktlen); + ihdr->ip_id = 0x3412; + ihdr->ip_off = 0; + ihdr->ip_ttl = 64; + ihdr->ip_p = 17; + ihdr->ip_sum = 0; + ihdr->ip_src.s_addr = g_vxlan_encap_args.outer_vxlan_sip_net; + ihdr->ip_dst.s_addr = g_vxlan_encap_args.outer_vxlan_dip_net; + + struct udphdr *uhdr = (struct udphdr *)(encap_pkt_buf + sizeof(struct ethhdr) + sizeof(struct ip)); + + uhdr->uh_sport = g_vxlan_encap_args.outer_vxlan_sport_net; + uhdr->uh_dport = g_vxlan_encap_args.outer_vxlan_dport_net; + uhdr->uh_ulen = htons(sizeof(struct udphdr) + sizeof(tcpburst_vxlan_hdr_t) + pktlen); + uhdr->uh_sum = 0; + + tcpburst_vxlan_hdr_t *vxlan_hdr = (tcpburst_vxlan_hdr_t *)((char *)uhdr + sizeof(struct udphdr)); + + vxlan_hdr->flags = 0; + vxlan_hdr->reserved[0] = 0; + vxlan_hdr->reserved[1] = 0; + vxlan_hdr->reserved[2] = 0; + vxlan_hdr->link_id = 101; + + memcpy(encap_pkt_buf + sizeof(struct ethhdr) + sizeof(struct ip) + sizeof(struct udphdr) + sizeof(tcpburst_vxlan_hdr_t), pkt, pktlen); + + return sendpacket(handle, encap_pkt_buf, pktlen + sizeof(struct ethhdr) + sizeof(struct ip) + sizeof(struct udphdr) + sizeof(tcpburst_vxlan_hdr_t)); +} + +int stream_burst_send_pkt(void *handle, const u_char *pkt, size_t pktlen) +{ + if(1 == send_pkt_driver_mode){ + if(options.encap_cfg_file != NULL){ + return sendpacket_with_encapsulation((sendpacket_t *)handle, pkt, pktlen); + } + return sendpacket((sendpacket_t *)handle, pkt, pktlen); + } + +#ifdef MARSIO + return stream_burst_send_pkt_by_marsio((struct mr_sendpath *)handle, pkt, pktlen); +#endif +} + +int stream_burst(sendpacket_t *sp, const u_char *pkt, size_t pktlen, int flush, int cache_file_idx) +{ + u_char *pdata; + MESA_fixed_qelem_t *q_obj; + int i; + unsigned char pbuf[TCP_BURST_MTU]; + + if(cache_file_idx != dumpfile_last_file_index){ + dumpfile_last_file_index = cache_file_idx; + dumpfile_total_size = __get_file_length(options.files[cache_file_idx]); + } + + process_bar_print(pktlen, options.files[cache_file_idx]); + + struct ip *iphdr = (struct ip *)(pkt + 14); + + if(1 == flush) /* ԭʼѶ, ǿˢ¶ʣݰ */ + { + if(options.pkt_distance > 0) + { + /* ȡ֮ǰİ */ + for(i = 0; i < options.stream_multiple; i++) + { + while((q_obj = MESA_fixed_q_get_head(&pkt_queue[i])) != NULL) + { + stream_burst_send_pkt(sp, q_obj->data, q_obj->datalen); + pkts_sent ++; + bytes_sent += pktlen; + } + } + } + return 0; + } + + /* ֧TCPUDP, GRE, IPinIPЭ */ + if((iphdr->ip_p != IPPROTO_TCP) + && (iphdr->ip_p != IPPROTO_UDP) + && (iphdr->ip_p != IPPROTO_GRE) + && (iphdr->ip_p != IPPROTO_IPIP) + && (iphdr->ip_p != IPPROTO_IPV6)) + { + if((options.stream_multiple != 0) && (options.verbose != 0)){ + fprintf(stderr, "Not support amplify protocol:%d\n", iphdr->ip_p); + } + return -1; + } + + if(pktlen > TCP_BURST_MTU){ + //fprintf(stderr, "Tcpburst error! Packet too long:%d, current MTU is:%d\n", pktlen, TCP_BURST_MTU); + return -1; + } + + if(options.pkt_distance > 0) + { + /* ݴ浽 */ + for(i = 0; i < options.stream_multiple; i++) + { + memcpy(pbuf, pkt, pktlen); + stream_edit_addr(pbuf, i+1); + MESA_fixed_q_join_tail(&pkt_queue[i], pbuf, pktlen); + } + + /* ȡ֮ǰİ */ + for(i = 0; i < options.stream_multiple; i++) + { + if(MESA_fixed_q_count(&pkt_queue[i]) >= options.pkt_distance*(i+1)) + { + q_obj = MESA_fixed_q_get_head(&pkt_queue[i]); + stream_burst_send_pkt(sp, q_obj->data, q_obj->datalen); + pkts_sent ++; + bytes_sent += pktlen; + } + } + } + else + { + /* ûа, ֱӷNݰ */ + for(i = 0; i < options.stream_multiple; i++) + { + //memcpy(pbuf, pkt, pktlen); + //stream_edit_addr(pbuf, i+1); /* ںڲ޸İͷIP */ + stream_burst_send_pkt(sp, pkt, pktlen); + pkts_sent ++; + bytes_sent += pktlen; + } + } + + return 0; +} + +void stream_burst_destroy(void) +{ + int i; + + if(0 == options.pkt_distance) + { + return; + } + + for(i = 0; i < options.stream_multiple; i++) + { + MESA_fixed_q_destroy(&pkt_queue[i]); + } + + free(pkt_queue); +} + +#endif + +#ifdef MARSIO +static void *replay_files_thread(void *arg) +{ + int i; + int loop = (int)arg; + + marsio_thread_init(tcpburst_marsio4_instance); + + if(0 == loop){ + loop = 1; /* һ */ + } + for(i = 0; i < loop; i++){ + replay_file(0); + } + + return NULL; +} +#endif + +int +main(int argc, char *argv[]) +{ + int i, optct = 0; +#ifdef TCPREPLAY_EDIT + int rcode; +#endif + + init(); /* init our globals */ + + optct = optionProcess(&tcpreplayOptions, argc, argv); + argc -= optct; + argv += optct; + +#ifdef TCPBURST +#ifndef TCPREPLAY_EDIT + options.driver_mode = OPT_VALUE_DRIVER_MODE; + if(NULL == options.driver_mode){ + options.driver_mode = "pcap"; /* ûָ, default is pcap */ + } +#ifdef MARSIO + if(strncasecmp(options.driver_mode, "marsio", 6) == 0){ + send_pkt_driver_mode = 12; + marsio_send_device = get_interface(NULL, OPT_ARG(INTF1)); /* ȡԭʼ-iĽӿ */ + OPT_ARG(INTF1) = strdup("lo"); /* ʹloӿƭtcpreplaypcapصijʼ */ + } else +#endif + if(strncasecmp(options.driver_mode, "pcap", 6) == 0){ + send_pkt_driver_mode = 1; + }else{ + printf("Invalid driver-mode:%s\n", options.driver_mode); + exit(1); + } +#endif +#endif + + post_args(); + +#ifdef TCPBURST +#ifndef TCPREPLAY_EDIT + stream_burst_init(); +#endif +#endif + +#ifdef TCPREPLAY_EDIT + /* init tcpedit context */ + if (tcpedit_init(&tcpedit, sendpacket_get_dlt(options.intf1)) < 0) { + errx(-1, "Error initializing tcpedit: %s", tcpedit_geterr(tcpedit)); + } + + /* parse the tcpedit args */ + rcode = tcpedit_post_args(&tcpedit); + if (rcode < 0) { + errx(-1, "Unable to parse args: %s", tcpedit_geterr(tcpedit)); + } else if (rcode == 1) { + warnx("%s", tcpedit_geterr(tcpedit)); + } + + if (tcpedit_validate(tcpedit) < 0) { + errx(-1, "Unable to edit packets given options:\n%s", + tcpedit_geterr(tcpedit)); + } +#endif + + if ((options.enable_file_cache || options.preload_pcap) && ! HAVE_OPT(QUIET)) { + notice("File Cache is enabled"); + } + + /* + * Setup up the file cache, if required + */ + if (options.enable_file_cache || options.preload_pcap) { + options.file_cache = safe_malloc(argc * sizeof(file_cache_t)); + + /* + * Initialise each of the file cache structures + */ + for (i = 0; i < argc; i++) { + options.file_cache[i].index = i; + options.file_cache[i].cached = FALSE; + options.file_cache[i].packet_cache = NULL; + } + } + + for (i = 0; i < argc; i++) { + options.files[i] = safe_strdup(argv[i]); + + /* preload our pcap file? */ + if (options.preload_pcap) { + preload_pcap_file(i); + } + } + + /* init the signal handlers */ + init_signal_handlers(); + + if (gettimeofday(&begin, NULL) < 0) + errx(-1, "gettimeofday() failed: %s", strerror(errno)); + + /* main loop for non-bridge mode */ + if (options.loop > 0) { + while (options.loop--) { /* limited loop */ + /* process each pcap file in order */ + for (i = 0; i < argc; i++) { + /* reset cache markers for each iteration */ + cache_byte = 0; + cache_bit = 0; +#ifdef MARSIO + if(12 == send_pkt_driver_mode){ + pthread_t pid; + pthread_create(&pid, NULL, replay_files_thread, (void *)options.loop); + pthread_join(pid, NULL); + }else{ + replay_file(i); + } +#else + replay_file(i); +#endif + } + } + } + else { + /* loop forever */ + while (1) { + for (i = 0; i < argc; i++) { + /* reset cache markers for each iteration */ + cache_byte = 0; + cache_bit = 0; +#ifdef MARSIO + if(12 == send_pkt_driver_mode){ + pthread_t pid; + pthread_create(&pid, NULL, replay_files_thread, (void *)options.loop); + pthread_join(pid, NULL); + }else{ + replay_file(i); + } +#else + replay_file(i); +#endif + } + } + } + + if (bytes_sent > 0) { + if (gettimeofday(&end, NULL) < 0) + errx(-1, "Unable to gettimeofday(): %s", strerror(errno)); + + packet_stats(&begin, &end, bytes_sent, pkts_sent, failed); + + printf("%s", sendpacket_getstat(options.intf1)); + if (options.intf2 != NULL) + printf("%s", sendpacket_getstat(options.intf2)); + } + +#ifdef TCPBURST +#ifndef TCPREPLAY_EDIT + stream_burst_destroy(); +#endif +#endif + + return 0; +} /* main() */ + +/** + * \brief Preloads the memory cache for the given pcap file_idx + * + * Preloading can be used with or without --loop and implies using + * --enable-file-cache + */ +void +preload_pcap_file(int file_idx) +{ + char *path = options.files[file_idx]; + pcap_t *pcap = NULL; + char ebuf[PCAP_ERRBUF_SIZE]; + const u_char *pktdata = NULL; + struct pcap_pkthdr pkthdr; + packet_cache_t *cached_packet = NULL; + packet_cache_t **prev_packet = &cached_packet; + COUNTER packetnum = 0; + + /* close stdin if reading from it (needed for some OS's) */ + if (strncmp(path, "-", 1) == 0) + if (close(1) == -1) + warnx("unable to close stdin: %s", strerror(errno)); + + if ((pcap = pcap_open_offline(path, ebuf)) == NULL) + errx(-1, "Error opening pcap file: %s", ebuf); + +#ifdef HAVE_PCAP_SNAPSHOT + if (pcap_snapshot(pcap) < 65535) + warnx("%s was captured using a snaplen of %d bytes. This may mean you have truncated packets.", + path, pcap_snapshot(pcap)); +#endif + + /* loop through the pcap. get_next_packet() builds the cache for us! */ + while ((pktdata = get_next_packet(pcap, &pkthdr, file_idx, prev_packet)) != NULL) { + packetnum++; + } + + /* mark this file as cached */ + options.file_cache[file_idx].cached = TRUE; + pcap_close(pcap); +} + +/** + * replay a pcap file out an interface + */ +void +replay_file(int file_idx) +{ + char *path = options.files[file_idx]; + pcap_t *pcap = NULL; + char ebuf[PCAP_ERRBUF_SIZE]; + int dlt; + + if (! HAVE_OPT(QUIET)) + notice("processing file: %s", path); + + /* close stdin if reading from it (needed for some OS's) */ + if (strncmp(path, "-", 1) == 0) + if (close(1) == -1) + warnx("unable to close stdin: %s", strerror(errno)); + + /* read from pcap file if we haven't cached things yet */ + if (! (options.enable_file_cache || options.preload_pcap)) { + if ((pcap = pcap_open_offline(path, ebuf)) == NULL) + errx(-1, "Error opening pcap file: %s", ebuf); + } else { + if (!options.file_cache[file_idx].cached) + if ((pcap = pcap_open_offline(path, ebuf)) == NULL) + errx(-1, "Error opening pcap file: %s", ebuf); + + } + +#ifdef ENABLE_VERBOSE + if (options.verbose) { + + /* in cache mode, we may not have opened the file */ + if (pcap == NULL) + if ((pcap = pcap_open_offline(path, ebuf)) == NULL) + errx(-1, "Error opening pcap file: %s", ebuf); + + /* init tcpdump */ + tcpdump_open(options.tcpdump, pcap); + } +#endif + + + if (pcap != NULL) { + dlt = sendpacket_get_dlt(options.intf1); + if ((dlt > 0) && (dlt != pcap_datalink(pcap))) + warnx("%s DLT (%s) does not match that of the outbound interface: %s (%s)", + path, pcap_datalink_val_to_name(pcap_datalink(pcap)), + options.intf1->device, pcap_datalink_val_to_name(dlt)); + } + + send_packets(pcap, file_idx); + if (pcap != NULL) + pcap_close(pcap); + +#ifdef ENABLE_VERBOSE + tcpdump_close(options.tcpdump); +#endif +} + +/** + * Initialize globals + */ +void +init(void) +{ + bytes_sent = failed = pkts_sent = 0; + memset(&options, 0, sizeof(options)); + + /* replay packets only once */ + options.loop = 1; + + /* Default mode is to replay pcap once in real-time */ + options.speed.mode = SPEED_MULTIPLIER; + options.speed.speed = 1.0; + + /* Set the default timing method */ +#ifdef HAVE_ABSOLUTE_TIME + /* This is always the best (if the OS supports it) */ + options.accurate = ACCURATE_ABS_TIME; +#else + /* This is probably the second best solution */ + options.accurate = ACCURATE_GTOD; +#endif + + /* set the default MTU size */ + options.mtu = DEFAULT_MTU; + + /* disable limit send */ + options.limit_send = -1; + +#ifdef ENABLE_VERBOSE + /* clear out tcpdump struct */ + options.tcpdump = (tcpdump_t *)safe_malloc(sizeof(tcpdump_t)); +#endif + + cache_bit = cache_byte = 0; + +#ifdef TCPBURST + options.stream_multiple = 0; + options.pkt_distance = 0; + options.driver_mode = "pcap"; /* default mode is pcap */ + options.encap_cfg_file = NULL; +#endif + + if (fcntl(STDERR_FILENO, F_SETFL, O_NONBLOCK) < 0) + warnx("Unable to set STDERR to non-blocking: %s", strerror(errno)); +} + +/** + * post processes the args and puts them into our options + */ +void +post_args(void) +{ + char *temp, *intname; + char ebuf[SENDPACKET_ERRBUF_SIZE]; + int int1dlt, int2dlt; + +#ifdef ENABLE_PCAP_FINDALLDEVS + interface_list_t *intlist = get_interface_list(); +#else + interface_list_t *intlist = NULL; +#endif + +#ifdef DEBUG + if (HAVE_OPT(DBUG)) + debug = OPT_VALUE_DBUG; +#else + if (HAVE_OPT(DBUG)) + warn("not configured with --enable-debug. Debugging disabled."); +#endif + + options.loop = OPT_VALUE_LOOP; + options.sleep_accel = OPT_VALUE_SLEEP_ACCEL; + +#ifdef TCPBURST +#ifndef TCPREPLAY_EDIT + options.stream_multiple = OPT_VALUE_MULTIPLE; + if(options.stream_multiple < 0 || options.stream_multiple > 255) + { + printf("Invalid stream_multiple value:%d, must be[0-255].\n", options.stream_multiple); + exit(1); + } + options.pkt_distance = OPT_VALUE_DISTANCE; + if(options.pkt_distance < 0 || options.pkt_distance > 1024) + { + printf("Invalid pkt_distance value:%d, must be[0-1024].\n", options.pkt_distance); + exit(2); + } + if((options.pkt_distance != 0) && (options.stream_multiple == 0)) + { + printf("Warning, You assign pkt_distance but not stream_multiple, nothing to do!\n"); + sleep(1); + } + + options.driver_mode = OPT_VALUE_DRIVER_MODE; + if(NULL == options.driver_mode){ + options.driver_mode = "pcap"; /* ûָ, default is pcap */ + } + if((strncasecmp(options.driver_mode, "pcap", 4) != 0) + && (strncasecmp(options.driver_mode, "marsio", 6) != 0)){ + printf("Invalid driver_mode value:%s, must be[pcap,marsio].\n", options.driver_mode); + exit(1); + } + + options.encap_cfg_file = OPT_VALUE_ENCAP; + if(options.encap_cfg_file != NULL){ + if(parse_encap_cfg_file(options.encap_cfg_file) < 0){ + printf("\n", options.encap_cfg_file); + exit(1); + } + } +#endif + +#endif + + if (HAVE_OPT(LIMIT)) + options.limit_send = OPT_VALUE_LIMIT; + + if (HAVE_OPT(TOPSPEED)) { + options.speed.mode = SPEED_TOPSPEED; + options.speed.speed = 0.0; + } else if (HAVE_OPT(PPS)) { + options.speed.mode = SPEED_PACKETRATE; + options.speed.speed = (float)OPT_VALUE_PPS; + options.speed.pps_multi = OPT_VALUE_PPS_MULTI; + } else if (HAVE_OPT(ONEATATIME)) { + options.speed.mode = SPEED_ONEATATIME; + options.speed.speed = 0.0; + } else if (HAVE_OPT(MBPS)) { + options.speed.mode = SPEED_MBPSRATE; + options.speed.speed = atof(OPT_ARG(MBPS)); + } else if (HAVE_OPT(MULTIPLIER)) { + options.speed.mode = SPEED_MULTIPLIER; + options.speed.speed = atof(OPT_ARG(MULTIPLIER)); + } + + if (HAVE_OPT(STATS)) + options.stats = OPT_ARG(STATS); + +#ifdef ENABLE_VERBOSE + if (HAVE_OPT(VERBOSE)) + options.verbose = 1; + + if (HAVE_OPT(DECODE)) + options.tcpdump->args = safe_strdup(OPT_ARG(DECODE)); + +#endif + + /* + * Check if the file cache should be enabled - if we're looping more than + * once and the command line option has been spec'd + */ + if (HAVE_OPT(ENABLE_FILE_CACHE) && (options.loop != 1)) { + options.enable_file_cache = TRUE; + } + + if (HAVE_OPT(PRELOAD_PCAP)) { + options.preload_pcap = TRUE; + options.enable_file_cache = TRUE; + } + + if (HAVE_OPT(TIMER)) { + if (strcmp(OPT_ARG(TIMER), "select") == 0) { +#ifdef HAVE_SELECT + options.accurate = ACCURATE_SELECT; +#else + err(-1, "tcpreplay not compiled with select support"); +#endif + } else if (strcmp(OPT_ARG(TIMER), "rdtsc") == 0) { +#ifdef HAVE_RDTSC + options.accurate = ACCURATE_RDTSC; +#else + err(-1, "tcpreplay not compiled with rdtsc support"); +#endif + } else if (strcmp(OPT_ARG(TIMER), "ioport") == 0) { +#if defined HAVE_IOPERM && defined(__i386__) + options.accurate = ACCURATE_IOPORT; + ioport_sleep_init(); +#else + err(-1, "tcpreplay not compiled with IO Port 0x80 support"); +#endif + } else if (strcmp(OPT_ARG(TIMER), "gtod") == 0) { + options.accurate = ACCURATE_GTOD; + } else if (strcmp(OPT_ARG(TIMER), "nano") == 0) { + options.accurate = ACCURATE_NANOSLEEP; + } else if (strcmp(OPT_ARG(TIMER), "abstime") == 0) { +#ifdef HAVE_ABSOLUTE_TIME + options.accurate = ACCURATE_ABS_TIME; + if (!MPLibraryIsLoaded()) { + err(-1, "The MP library did not load.\n"); + } +#else + err(-1, "tcpreplay only supports absolute time on Apple OS X"); +#endif + } else { + errx(-1, "Unsupported timer mode: %s", OPT_ARG(TIMER)); + } + } + +#ifdef HAVE_RDTSC + if (HAVE_OPT(RDTSC_CLICKS)) { + rdtsc_calibrate(OPT_VALUE_RDTSC_CLICKS); + } +#endif + + if (HAVE_OPT(PKTLEN)) + warn("--pktlen may cause problems. Use with caution."); + + if ((intname = get_interface(intlist, OPT_ARG(INTF1))) == NULL) + errx(-1, "Invalid interface name/alias: %s", OPT_ARG(INTF1)); + + options.intf1_name = safe_strdup(intname); + + /* open interfaces for writing */ + if ((options.intf1 = sendpacket_open(options.intf1_name, ebuf, TCPR_DIR_C2S)) == NULL) + errx(-1, "Can't open %s: %s", options.intf1_name, ebuf); + + int1dlt = sendpacket_get_dlt(options.intf1); + + if (HAVE_OPT(INTF2)) { + if ((intname = get_interface(intlist, OPT_ARG(INTF2))) == NULL) + errx(-1, "Invalid interface name/alias: %s", OPT_ARG(INTF2)); + + options.intf2_name = safe_strdup(intname); + + /* open interface for writing */ + if ((options.intf2 = sendpacket_open(options.intf2_name, ebuf, TCPR_DIR_S2C)) == NULL) + errx(-1, "Can't open %s: %s", options.intf2_name, ebuf); + + int2dlt = sendpacket_get_dlt(options.intf2); + if (int2dlt != int1dlt) + errx(-1, "DLT type missmatch for %s (%s) and %s (%s)", + options.intf1_name, pcap_datalink_val_to_name(int1dlt), + options.intf2_name, pcap_datalink_val_to_name(int2dlt)); + } + + if (HAVE_OPT(CACHEFILE)) { + temp = safe_strdup(OPT_ARG(CACHEFILE)); + options.cache_packets = read_cache(&options.cachedata, temp, + &options.comment); + safe_free(temp); + } + + if (! HAVE_OPT(QUIET)) + notice("sending out %s %s", options.intf1_name, + options.intf2_name == NULL ? "" : options.intf2_name); +} + +/* + Local Variables: +mode:c +indent-tabs-mode:nil +c-basic-offset:4 +End: +*/ + diff --git a/src/tcpreplay.h b/src/tcpreplay.h new file mode 100644 index 0000000..86a5c53 --- /dev/null +++ b/src/tcpreplay.h @@ -0,0 +1,137 @@ +/* $Id: tcpreplay.h 2433 2010-03-28 20:57:36Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __TCPREPLAY_H__ +#define __TCPREPLAY_H__ + +#include "config.h" +#include "defines.h" +#include "common/sendpacket.h" +#include "common/tcpdump.h" + +#include +#include +#include + +#ifdef ENABLE_DMALLOC +#include +#endif + +//#define STREAM_MULTIPLE (5) /* 2013-06-03 LiJia add, Ŵ */ +//#define RAW_PKT_DISTANCE (10) /* 2013-06-03 LiJia add, ԭʼͷŴİ */ + +struct packet_cache_s { + struct pcap_pkthdr pkthdr; + u_char *pktdata; + + struct packet_cache_s *next; +}; + +typedef struct packet_cache_s packet_cache_t; + +typedef struct { + int index; + int cached; + packet_cache_t *packet_cache; +} file_cache_t; + + +/* run-time options */ +struct tcpreplay_opt_s { + /* input/output */ + char *intf1_name; + char *intf2_name; + sendpacket_t *intf1; + sendpacket_t *intf2; + + tcpr_speed_t speed; + u_int32_t loop; + int sleep_accel; + + int stats; + + /* tcpprep cache data */ + COUNTER cache_packets; + char *cachedata; + char *comment; /* tcpprep comment */ + + /* deal with MTU/packet len issues */ + int mtu; + int truncate; + + /* accurate mode to use */ + int accurate; +#define ACCURATE_NANOSLEEP 0 +#define ACCURATE_SELECT 1 +#define ACCURATE_RDTSC 2 +#define ACCURATE_IOPORT 3 +#define ACCURATE_GTOD 4 +#define ACCURATE_ABS_TIME 5 + + char *files[MAX_FILES]; + COUNTER limit_send; + +#ifdef ENABLE_VERBOSE + /* tcpdump verbose printing */ + int verbose; + char *tcpdump_args; + tcpdump_t *tcpdump; +#endif + + /* pcap file caching */ + int enable_file_cache; + file_cache_t *file_cache; + int preload_pcap; + +#ifdef TCPBURST + int stream_multiple; /* Ŵ */ + int pkt_distance; /* ԭʼ빹ľ */ + + char *driver_mode; /* ײģʽ */ + long cpu_mask; + + char *encap_cfg_file; /* ײװģʽ */ +#endif +}; + +typedef struct tcpreplay_opt_s tcpreplay_opt_t; + +#endif + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + diff --git a/src/tcpreplay_edit_opts.c b/src/tcpreplay_edit_opts.c new file mode 100644 index 0000000..a8997fc --- /dev/null +++ b/src/tcpreplay_edit_opts.c @@ -0,0 +1,2402 @@ +/* -*- buffer-read-only: t -*- vi: set ro: + * + * DO NOT EDIT THIS FILE (tcpreplay_edit_opts.c) + * + * It has been AutoGen-ed April 4, 2010 at 05:59:19 PM by AutoGen 5.9.9 + * From the definitions tcpreplay_opts.def + * and the template file options + * + * Generated from AutoOpts 32:2:7 templates. + */ + +/* + * This file was produced by an AutoOpts template. AutoOpts is a + * copyrighted work. This source file is not encumbered by AutoOpts + * licensing, but is provided under the licensing terms chosen by the + * tcpreplay author or copyright holder. AutoOpts is licensed under + * the terms of the LGPL. The redistributable library (``libopts'') is + * licensed under the terms of either the LGPL or, at the users discretion, + * the BSD license. See the AutoOpts and/or libopts sources for details. + * + * This source file is copyrighted and licensed under the following terms: + * + * tcpreplay copyright (c) 2000-2010 Aaron Turner - all rights reserved + * + * tcpreplay is free software copyrighted by Aaron Turner. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name ``Aaron Turner'' nor the name of any other + * contributor may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * tcpreplay IS PROVIDED BY Aaron Turner ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL Aaron Turner OR ANY OTHER CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +extern FILE * option_usage_fp; +#define OPTION_CODE_COMPILE 1 +#include "tcpreplay_edit_opts.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* TRANSLATORS: choose the translation for option names wisely because you + cannot ever change your mind. */ +tSCC zCopyright[] = + "tcpreplay copyright (c) 2000-2010 Aaron Turner, all rights reserved"; +tSCC zCopyrightNotice[1458] = +"tcpreplay is free software copyrighted by Aaron Turner.\n\n\ +Redistribution and use in source and binary forms, with or without\n\ +modification, are permitted provided that the following conditions are met: 1.\n\ +Redistributions of source code must retain the above copyright notice, this\n\ +list of conditions and the following disclaimer. 2. Redistributions in binary\n\ +form must reproduce the above copyright notice, this list of conditions and the\n\ +following disclaimer in the documentation and/or other materials provided with\n\ +the distribution. 3. Neither the name ``Aaron Turner'' nor the name of any\n\ +other contributor may be used to endorse or promote products derived from this\n\ +software without specific prior written permission.\n\n\ +tcpreplay IS PROVIDED BY Aaron Turner ``AS IS'' AND ANY EXPRESS OR IMPLIED\n\ +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n\ +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO\n\ +EVENT SHALL Aaron Turner OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n\ +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\n\ +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n\ +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n\ +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n\ +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\n\ +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."; + +extern tUsageProc optionUsage; + +/* + * global included definitions + */ +#include "defines.h" +#include "tcpreplay.h" +#include "common.h" +#include "config.h" +#include +#include +#include +extern tcpreplay_opt_t options; + + +#ifndef NULL +# define NULL 0 +#endif +#ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +#endif +#ifndef EXIT_FAILURE +# define EXIT_FAILURE 1 +#endif +/* + * Tcpedit option description: + */ +tSCC zTcpeditText[] = + ""; +#define TCPEDIT_FLAGS (OPTST_DOCUMENT | OPTST_NO_INIT) + +/* + * Portmap option description: + */ +tSCC zPortmapText[] = + "Rewrite TCP/UDP ports"; +tSCC zPortmap_NAME[] = "PORTMAP"; +tSCC zPortmap_Name[] = "portmap"; +#define PORTMAP_FLAGS (OPTST_DISABLED | OPTST_STACKED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Seed option description: + */ +tSCC zSeedText[] = + "Randomize src/dst IPv4/v6 addresses w/ given seed"; +tSCC zSeed_NAME[] = "SEED"; +tSCC zSeed_Name[] = "seed"; +#define SEED_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Pnat option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zPnatText[] = + "Rewrite IPv4/v6 addresses using pseudo-NAT"; +tSCC zPnat_NAME[] = "PNAT"; +tSCC zPnat_Name[] = "pnat"; +static const int + aPnatCantList[] = { + INDEX_OPT_SRCIPMAP, NO_EQUIVALENT }; +#define PNAT_FLAGS (OPTST_DISABLED | OPTST_STACKED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Srcipmap option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zSrcipmapText[] = + "Rewrite source IPv4/v6 addresses using pseudo-NAT"; +tSCC zSrcipmap_NAME[] = "SRCIPMAP"; +tSCC zSrcipmap_Name[] = "srcipmap"; +static const int + aSrcipmapCantList[] = { + INDEX_OPT_PNAT, NO_EQUIVALENT }; +#define SRCIPMAP_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Dstipmap option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zDstipmapText[] = + "Rewrite destination IPv4/v6 addresses using pseudo-NAT"; +tSCC zDstipmap_NAME[] = "DSTIPMAP"; +tSCC zDstipmap_Name[] = "dstipmap"; +static const int + aDstipmapCantList[] = { + INDEX_OPT_PNAT, NO_EQUIVALENT }; +#define DSTIPMAP_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Endpoints option description with + * "Must also have options" and "Incompatible options": + */ +#ifdef HAVE_CACHEFILE_SUPPORT +tSCC zEndpointsText[] = + "Rewrite IP addresses to be between two endpoints"; +tSCC zEndpoints_NAME[] = "ENDPOINTS"; +tSCC zEndpoints_Name[] = "endpoints"; +static const int + aEndpointsMustList[] = { + INDEX_OPT_CACHEFILE, NO_EQUIVALENT }; +#define ENDPOINTS_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +#else /* disable Endpoints */ +#define VALUE_OPT_ENDPOINTS NO_EQUIVALENT +#define ENDPOINTS_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define aEndpointsMustList NULL +#define zEndpointsText NULL +#define zEndpoints_NAME NULL +#define zEndpoints_Name NULL +#endif /* HAVE_CACHEFILE_SUPPORT */ + +/* + * Skipbroadcast option description: + */ +tSCC zSkipbroadcastText[] = + "Skip rewriting broadcast/multicast IPv4/v6 addresses"; +tSCC zSkipbroadcast_NAME[] = "SKIPBROADCAST"; +tSCC zSkipbroadcast_Name[] = "skipbroadcast"; +#define SKIPBROADCAST_FLAGS (OPTST_DISABLED) + +/* + * Fixcsum option description: + */ +tSCC zFixcsumText[] = + "Force recalculation of IPv4/TCP/UDP header checksums"; +tSCC zFixcsum_NAME[] = "FIXCSUM"; +tSCC zFixcsum_Name[] = "fixcsum"; +#define FIXCSUM_FLAGS (OPTST_DISABLED) + +/* + * Mtu option description: + */ +tSCC zMtuText[] = + "Override default MTU length (1500 bytes)"; +tSCC zMtu_NAME[] = "MTU"; +tSCC zMtu_Name[] = "mtu"; +#define MTU_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Mtu_Trunc option description: + */ +tSCC zMtu_TruncText[] = + "Truncate packets larger then specified MTU"; +tSCC zMtu_Trunc_NAME[] = "MTU_TRUNC"; +tSCC zMtu_Trunc_Name[] = "mtu-trunc"; +#define MTU_TRUNC_FLAGS (OPTST_DISABLED) + +/* + * Efcs option description: + */ +tSCC zEfcsText[] = + "Remove Ethernet checksums (FCS) from end of frames"; +tSCC zEfcs_NAME[] = "EFCS"; +tSCC zEfcs_Name[] = "efcs"; +#define EFCS_FLAGS (OPTST_DISABLED) + +/* + * Ttl option description: + */ +tSCC zTtlText[] = + "Modify the IPv4/v6 TTL/Hop Limit"; +tSCC zTtl_NAME[] = "TTL"; +tSCC zTtl_Name[] = "ttl"; +#define TTL_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Tos option description: + */ +tSCC zTosText[] = + "Set the IPv4 TOS/DiffServ/ECN byte"; +tSCC zTos_NAME[] = "TOS"; +tSCC zTos_Name[] = "tos"; +#define TOS_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Tclass option description: + */ +tSCC zTclassText[] = + "Set the IPv6 Traffic Class byte"; +tSCC zTclass_NAME[] = "TCLASS"; +tSCC zTclass_Name[] = "tclass"; +#define TCLASS_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Flowlabel option description: + */ +tSCC zFlowlabelText[] = + "Set the IPv6 Flow Label"; +tSCC zFlowlabel_NAME[] = "FLOWLABEL"; +tSCC zFlowlabel_Name[] = "flowlabel"; +#define FLOWLABEL_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Fixlen option description: + */ +tSCC zFixlenText[] = + "Pad or truncate packet data to match header length"; +tSCC zFixlen_NAME[] = "FIXLEN"; +tSCC zFixlen_Name[] = "fixlen"; +#define FIXLEN_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Skipl2broadcast option description: + */ +tSCC zSkipl2broadcastText[] = + "Skip rewriting broadcast/multicast Layer 2 addresses"; +tSCC zSkipl2broadcast_NAME[] = "SKIPL2BROADCAST"; +tSCC zSkipl2broadcast_Name[] = "skipl2broadcast"; +#define SKIPL2BROADCAST_FLAGS (OPTST_DISABLED) + +/* + * Dlt option description: + */ +tSCC zDltText[] = + "Override output DLT encapsulation"; +tSCC zDlt_NAME[] = "DLT"; +tSCC zDlt_Name[] = "dlt"; +#define DLT_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Enet_Dmac option description: + */ +tSCC zEnet_DmacText[] = + "Override destination ethernet MAC addresses"; +tSCC zEnet_Dmac_NAME[] = "ENET_DMAC"; +tSCC zEnet_Dmac_Name[] = "enet-dmac"; +#define ENET_DMAC_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Enet_Smac option description: + */ +tSCC zEnet_SmacText[] = + "Override source ethernet MAC addresses"; +tSCC zEnet_Smac_NAME[] = "ENET_SMAC"; +tSCC zEnet_Smac_Name[] = "enet-smac"; +#define ENET_SMAC_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Enet_Vlan option description: + */ +tSCC zEnet_VlanText[] = + "Specify ethernet 802.1q VLAN tag mode"; +tSCC zEnet_Vlan_NAME[] = "ENET_VLAN"; +tSCC zEnet_Vlan_Name[] = "enet-vlan"; +#define ENET_VLAN_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Enet_Vlan_Tag option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zEnet_Vlan_TagText[] = + "Specify the new ethernet 802.1q VLAN tag value"; +tSCC zEnet_Vlan_Tag_NAME[] = "ENET_VLAN_TAG"; +tSCC zEnet_Vlan_Tag_Name[] = "enet-vlan-tag"; +static const int + aEnet_Vlan_TagMustList[] = { + INDEX_OPT_ENET_VLAN, NO_EQUIVALENT }; +#define ENET_VLAN_TAG_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Enet_Vlan_Cfi option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zEnet_Vlan_CfiText[] = + "Specify the ethernet 802.1q VLAN CFI value"; +tSCC zEnet_Vlan_Cfi_NAME[] = "ENET_VLAN_CFI"; +tSCC zEnet_Vlan_Cfi_Name[] = "enet-vlan-cfi"; +static const int + aEnet_Vlan_CfiMustList[] = { + INDEX_OPT_ENET_VLAN, NO_EQUIVALENT }; +#define ENET_VLAN_CFI_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Enet_Vlan_Pri option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zEnet_Vlan_PriText[] = + "Specify the ethernet 802.1q VLAN priority"; +tSCC zEnet_Vlan_Pri_NAME[] = "ENET_VLAN_PRI"; +tSCC zEnet_Vlan_Pri_Name[] = "enet-vlan-pri"; +static const int + aEnet_Vlan_PriMustList[] = { + INDEX_OPT_ENET_VLAN, NO_EQUIVALENT }; +#define ENET_VLAN_PRI_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Hdlc_Control option description: + */ +tSCC zHdlc_ControlText[] = + "Specify HDLC control value"; +tSCC zHdlc_Control_NAME[] = "HDLC_CONTROL"; +tSCC zHdlc_Control_Name[] = "hdlc-control"; +#define HDLC_CONTROL_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Hdlc_Address option description: + */ +tSCC zHdlc_AddressText[] = + "Specify HDLC address"; +tSCC zHdlc_Address_NAME[] = "HDLC_ADDRESS"; +tSCC zHdlc_Address_Name[] = "hdlc-address"; +#define HDLC_ADDRESS_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * User_Dlt option description: + */ +tSCC zUser_DltText[] = + "Set output file DLT type"; +tSCC zUser_Dlt_NAME[] = "USER_DLT"; +tSCC zUser_Dlt_Name[] = "user-dlt"; +#define USER_DLT_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * User_Dlink option description: + */ +tSCC zUser_DlinkText[] = + "Rewrite Data-Link layer with user specified data"; +tSCC zUser_Dlink_NAME[] = "USER_DLINK"; +tSCC zUser_Dlink_Name[] = "user-dlink"; +#define USER_DLINK_FLAGS (OPTST_DISABLED | OPTST_STACKED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Dbug option description: + */ +#ifdef DEBUG +tSCC zDbugText[] = + "Enable debugging output"; +tSCC zDbug_NAME[] = "DBUG"; +tSCC zDbug_Name[] = "dbug"; +#define zDbugDefaultArg ((char const*)0) +#define DBUG_FLAGS (OPTST_DISABLED | OPTST_IMM \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +#else /* disable Dbug */ +#define VALUE_OPT_DBUG NO_EQUIVALENT +#define DBUG_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zDbugDefaultArg NULL +#define zDbugText NULL +#define zDbug_NAME NULL +#define zDbug_Name NULL +#endif /* DEBUG */ + +/* + * Quiet option description: + */ +tSCC zQuietText[] = + "Quiet mode"; +tSCC zQuiet_NAME[] = "QUIET"; +tSCC zQuiet_Name[] = "quiet"; +#define QUIET_FLAGS (OPTST_DISABLED) + +/* + * Timer option description: + */ +tSCC zTimerText[] = + "Select packet timing mode: select, ioport, rdtsc, gtod, nano, abstime"; +tSCC zTimer_NAME[] = "TIMER"; +tSCC zTimer_Name[] = "timer"; +tSCC zTimerDefaultArg[] = "gtod"; +#define TIMER_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Sleep_Accel option description: + */ +tSCC zSleep_AccelText[] = + "Reduce the amount of time to sleep by specified usec"; +tSCC zSleep_Accel_NAME[] = "SLEEP_ACCEL"; +tSCC zSleep_Accel_Name[] = "sleep-accel"; +#define zSleep_AccelDefaultArg ((char const*)0) +#define SLEEP_ACCEL_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Rdtsc_Clicks option description: + */ +tSCC zRdtsc_ClicksText[] = + "Specify the RDTSC clicks/usec"; +tSCC zRdtsc_Clicks_NAME[] = "RDTSC_CLICKS"; +tSCC zRdtsc_Clicks_Name[] = "rdtsc-clicks"; +#define zRdtsc_ClicksDefaultArg ((char const*)0) +#define RDTSC_CLICKS_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Verbose option description: + */ +#ifdef ENABLE_VERBOSE +tSCC zVerboseText[] = + "Print decoded packets via tcpdump to STDOUT"; +tSCC zVerbose_NAME[] = "VERBOSE"; +tSCC zVerbose_Name[] = "verbose"; +#define VERBOSE_FLAGS (OPTST_DISABLED | OPTST_IMM) + +#else /* disable Verbose */ +#define VALUE_OPT_VERBOSE NO_EQUIVALENT +#define VERBOSE_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zVerboseText NULL +#define zVerbose_NAME NULL +#define zVerbose_Name NULL +#endif /* ENABLE_VERBOSE */ + +/* + * Decode option description with + * "Must also have options" and "Incompatible options": + */ +#ifdef ENABLE_VERBOSE +tSCC zDecodeText[] = + "Arguments passed to tcpdump decoder"; +tSCC zDecode_NAME[] = "DECODE"; +tSCC zDecode_Name[] = "decode"; +static const int + aDecodeMustList[] = { + INDEX_OPT_VERBOSE, NO_EQUIVALENT }; +#define DECODE_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +#else /* disable Decode */ +#define VALUE_OPT_DECODE NO_EQUIVALENT +#define DECODE_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define aDecodeMustList NULL +#define zDecodeText NULL +#define zDecode_NAME NULL +#define zDecode_Name NULL +#endif /* ENABLE_VERBOSE */ + +/* + * Enable_File_Cache option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zEnable_File_CacheText[] = + "Enable caching of packets to internal memory"; +tSCC zEnable_File_Cache_NAME[] = "ENABLE_FILE_CACHE"; +tSCC zEnable_File_Cache_Name[] = "enable-file-cache"; +static const int + aEnable_File_CacheMustList[] = { + INDEX_OPT_LOOP, NO_EQUIVALENT }; +#define ENABLE_FILE_CACHE_FLAGS (OPTST_DISABLED) + +/* + * Preload_Pcap option description: + */ +tSCC zPreload_PcapText[] = + "Preloads packets into RAM before sending"; +tSCC zPreload_Pcap_NAME[] = "PRELOAD_PCAP"; +tSCC zPreload_Pcap_Name[] = "preload-pcap"; +#define PRELOAD_PCAP_FLAGS (OPTST_DISABLED) + +/* + * Cachefile option description: + */ +tSCC zCachefileText[] = + "Split traffic via a tcpprep cache file"; +tSCC zCachefile_NAME[] = "CACHEFILE"; +tSCC zCachefile_Name[] = "cachefile"; +#define CACHEFILE_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Intf1 option description: + */ +tSCC zIntf1Text[] = + "Server/primary traffic output interface"; +tSCC zIntf1_NAME[] = "INTF1"; +tSCC zIntf1_Name[] = "intf1"; +#define INTF1_FLAGS (OPTST_DISABLED | OPTST_MUST_SET \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Intf2 option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zIntf2Text[] = + "Client/secondary traffic output interface"; +tSCC zIntf2_NAME[] = "INTF2"; +tSCC zIntf2_Name[] = "intf2"; +static const int + aIntf2MustList[] = { + INDEX_OPT_CACHEFILE, NO_EQUIVALENT }; +#define INTF2_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Listnics option description: + */ +#ifdef ENABLE_PCAP_FINDALLDEVS +tSCC zListnicsText[] = + "List available network interfaces and exit"; +tSCC zListnics_NAME[] = "LISTNICS"; +tSCC zListnics_Name[] = "listnics"; +#define LISTNICS_FLAGS (OPTST_DISABLED | OPTST_IMM) + +#else /* disable Listnics */ +#define VALUE_OPT_LISTNICS NO_EQUIVALENT +#define LISTNICS_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zListnicsText NULL +#define zListnics_NAME NULL +#define zListnics_Name NULL +#endif /* ENABLE_PCAP_FINDALLDEVS */ + +/* + * Loop option description: + */ +tSCC zLoopText[] = + "Loop through the capture file X times"; +tSCC zLoop_NAME[] = "LOOP"; +tSCC zLoop_Name[] = "loop"; +#define zLoopDefaultArg ((char const*)1) +#define LOOP_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Pktlen option description: + */ +tSCC zPktlenText[] = + "Override the snaplen and use the actual packet len"; +tSCC zPktlen_NAME[] = "PKTLEN"; +tSCC zPktlen_Name[] = "pktlen"; +#define PKTLEN_FLAGS (OPTST_DISABLED) + +/* + * Limit option description: + */ +tSCC zLimitText[] = + "Limit the number of packets to send"; +tSCC zLimit_NAME[] = "LIMIT"; +tSCC zLimit_Name[] = "limit"; +#define zLimitDefaultArg ((char const*)-1) +#define LIMIT_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Multiplier option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zMultiplierText[] = + "Modify replay speed to a given multiple"; +tSCC zMultiplier_NAME[] = "MULTIPLIER"; +tSCC zMultiplier_Name[] = "multiplier"; +static const int + aMultiplierCantList[] = { + INDEX_OPT_PPS, + INDEX_OPT_MBPS, + INDEX_OPT_ONEATATIME, + INDEX_OPT_TOPSPEED, NO_EQUIVALENT }; +#define MULTIPLIER_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Pps option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zPpsText[] = + "Replay packets at a given packets/sec"; +tSCC zPps_NAME[] = "PPS"; +tSCC zPps_Name[] = "pps"; +static const int + aPpsCantList[] = { + INDEX_OPT_MULTIPLIER, + INDEX_OPT_MBPS, + INDEX_OPT_ONEATATIME, + INDEX_OPT_TOPSPEED, NO_EQUIVALENT }; +#define PPS_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Mbps option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zMbpsText[] = + "Replay packets at a given Mbps"; +tSCC zMbps_NAME[] = "MBPS"; +tSCC zMbps_Name[] = "mbps"; +static const int + aMbpsCantList[] = { + INDEX_OPT_MULTIPLIER, + INDEX_OPT_PPS, + INDEX_OPT_ONEATATIME, + INDEX_OPT_TOPSPEED, NO_EQUIVALENT }; +#define MBPS_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Topspeed option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zTopspeedText[] = + "Replay packets as fast as possible"; +tSCC zTopspeed_NAME[] = "TOPSPEED"; +tSCC zTopspeed_Name[] = "topspeed"; +static const int + aTopspeedCantList[] = { + INDEX_OPT_MBPS, + INDEX_OPT_MULTIPLIER, + INDEX_OPT_PPS, + INDEX_OPT_ONEATATIME, NO_EQUIVALENT }; +#define TOPSPEED_FLAGS (OPTST_DISABLED) + +/* + * Oneatatime option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zOneatatimeText[] = + "Replay one packet at a time for each user input"; +tSCC zOneatatime_NAME[] = "ONEATATIME"; +tSCC zOneatatime_Name[] = "oneatatime"; +static const int + aOneatatimeCantList[] = { + INDEX_OPT_MBPS, + INDEX_OPT_PPS, + INDEX_OPT_MULTIPLIER, + INDEX_OPT_TOPSPEED, NO_EQUIVALENT }; +#define ONEATATIME_FLAGS (OPTST_DISABLED) + +/* + * Pps_Multi option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zPps_MultiText[] = + "Number of packets to send for each time interval"; +tSCC zPps_Multi_NAME[] = "PPS_MULTI"; +tSCC zPps_Multi_Name[] = "pps-multi"; +#define zPps_MultiDefaultArg ((char const*)1) +static const int + aPps_MultiMustList[] = { + INDEX_OPT_PPS, NO_EQUIVALENT }; +#define PPS_MULTI_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Pid option description: + */ +tSCC zPidText[] = + "Print the PID of tcpreplay at startup"; +tSCC zPid_NAME[] = "PID"; +tSCC zPid_Name[] = "pid"; +#define PID_FLAGS (OPTST_DISABLED) + +/* + * Stats option description: + */ +tSCC zStatsText[] = + "Print statistics every X seconds"; +tSCC zStats_NAME[] = "STATS"; +tSCC zStats_Name[] = "stats"; +#define STATS_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Version option description: + */ +tSCC zVersionText[] = + "Print version information"; +tSCC zVersion_NAME[] = "VERSION"; +tSCC zVersion_Name[] = "version"; +#define VERSION_FLAGS (OPTST_DISABLED) + +/* + * Less_Help option description: + */ +tSCC zLess_HelpText[] = + "Display less usage information and exit"; +tSCC zLess_Help_NAME[] = "LESS_HELP"; +tSCC zLess_Help_Name[] = "less-help"; +#define LESS_HELP_FLAGS (OPTST_DISABLED | OPTST_IMM) + +/* + * Help/More_Help option descriptions: + */ +tSCC zHelpText[] = "Display usage information and exit"; +tSCC zHelp_Name[] = "help"; +tSCC zMore_HelpText[] = "Extended usage information passed thru pager"; +tSCC zMore_Help_Name[] = "more-help"; +tSCC zSave_OptsText[] = "Save the option state to a config file"; +tSCC zSave_Opts_Name[] = "save-opts"; +tSCC zLoad_OptsText[] = "Load options from a config file"; +tSCC zLoad_Opts_NAME[] = "LOAD_OPTS"; +tSCC zNotLoad_Opts_Name[] = "no-load-opts"; +tSCC zNotLoad_Opts_Pfx[] = "no"; +#define zLoad_Opts_Name (zNotLoad_Opts_Name + 3) +/* + * Declare option callback procedures + */ +#ifdef DEBUG + static tOptProc doOptDbug; +#else /* not DEBUG */ +# define doOptDbug NULL +#endif /* def/not DEBUG */ +#ifdef ENABLE_PCAP_FINDALLDEVS + static tOptProc doOptListnics; +#else /* not ENABLE_PCAP_FINDALLDEVS */ +# define doOptListnics NULL +#endif /* def/not ENABLE_PCAP_FINDALLDEVS */ +extern tOptProc + optionNumericVal, optionPagedUsage, optionStackArg; +static tOptProc + doOptEnet_Vlan_Cfi, doOptEnet_Vlan_Pri, doOptEnet_Vlan_Tag, + doOptFlowlabel, doOptLess_Help, doOptLimit, + doOptLoop, doOptMtu, doOptPid, + doOptPps_Multi, doOptStats, doOptTclass, + doOptTos, doOptVersion, doUsageOpt; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Define the Tcpreplay Option Descriptions. + */ +static tOptDesc optDesc[ OPTION_CT ] = { + { /* entry idx, value */ 0, 0, + /* equiv idx, value */ 0, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 0, 0, + /* opt state flags */ TCPEDIT_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zTcpeditText, NULL, NULL, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 1, VALUE_OPT_PORTMAP, + /* equiv idx, value */ 1, VALUE_OPT_PORTMAP, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, -1, 0, + /* opt state flags */ PORTMAP_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionStackArg, + /* desc, NAME, name */ zPortmapText, zPortmap_NAME, zPortmap_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 2, VALUE_OPT_SEED, + /* equiv idx, value */ 2, VALUE_OPT_SEED, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ SEED_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionNumericVal, + /* desc, NAME, name */ zSeedText, zSeed_NAME, zSeed_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 3, VALUE_OPT_PNAT, + /* equiv idx, value */ 3, VALUE_OPT_PNAT, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 2, 0, + /* opt state flags */ PNAT_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aPnatCantList, + /* option proc */ optionStackArg, + /* desc, NAME, name */ zPnatText, zPnat_NAME, zPnat_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 4, VALUE_OPT_SRCIPMAP, + /* equiv idx, value */ 4, VALUE_OPT_SRCIPMAP, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ SRCIPMAP_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aSrcipmapCantList, + /* option proc */ NULL, + /* desc, NAME, name */ zSrcipmapText, zSrcipmap_NAME, zSrcipmap_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 5, VALUE_OPT_DSTIPMAP, + /* equiv idx, value */ 5, VALUE_OPT_DSTIPMAP, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ DSTIPMAP_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aDstipmapCantList, + /* option proc */ NULL, + /* desc, NAME, name */ zDstipmapText, zDstipmap_NAME, zDstipmap_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 6, VALUE_OPT_ENDPOINTS, + /* equiv idx, value */ 6, VALUE_OPT_ENDPOINTS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ ENDPOINTS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aEndpointsMustList, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zEndpointsText, zEndpoints_NAME, zEndpoints_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 7, VALUE_OPT_SKIPBROADCAST, + /* equiv idx, value */ 7, VALUE_OPT_SKIPBROADCAST, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ SKIPBROADCAST_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zSkipbroadcastText, zSkipbroadcast_NAME, zSkipbroadcast_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 8, VALUE_OPT_FIXCSUM, + /* equiv idx, value */ 8, VALUE_OPT_FIXCSUM, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ FIXCSUM_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zFixcsumText, zFixcsum_NAME, zFixcsum_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 9, VALUE_OPT_MTU, + /* equiv idx, value */ 9, VALUE_OPT_MTU, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ MTU_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptMtu, + /* desc, NAME, name */ zMtuText, zMtu_NAME, zMtu_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 10, VALUE_OPT_MTU_TRUNC, + /* equiv idx, value */ 10, VALUE_OPT_MTU_TRUNC, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ MTU_TRUNC_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zMtu_TruncText, zMtu_Trunc_NAME, zMtu_Trunc_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 11, VALUE_OPT_EFCS, + /* equiv idx, value */ 11, VALUE_OPT_EFCS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ EFCS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zEfcsText, zEfcs_NAME, zEfcs_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 12, VALUE_OPT_TTL, + /* equiv idx, value */ 12, VALUE_OPT_TTL, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ TTL_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zTtlText, zTtl_NAME, zTtl_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 13, VALUE_OPT_TOS, + /* equiv idx, value */ 13, VALUE_OPT_TOS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ TOS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptTos, + /* desc, NAME, name */ zTosText, zTos_NAME, zTos_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 14, VALUE_OPT_TCLASS, + /* equiv idx, value */ 14, VALUE_OPT_TCLASS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ TCLASS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptTclass, + /* desc, NAME, name */ zTclassText, zTclass_NAME, zTclass_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 15, VALUE_OPT_FLOWLABEL, + /* equiv idx, value */ 15, VALUE_OPT_FLOWLABEL, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ FLOWLABEL_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptFlowlabel, + /* desc, NAME, name */ zFlowlabelText, zFlowlabel_NAME, zFlowlabel_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 16, VALUE_OPT_FIXLEN, + /* equiv idx, value */ 16, VALUE_OPT_FIXLEN, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ FIXLEN_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zFixlenText, zFixlen_NAME, zFixlen_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 17, VALUE_OPT_SKIPL2BROADCAST, + /* equiv idx, value */ 17, VALUE_OPT_SKIPL2BROADCAST, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ SKIPL2BROADCAST_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zSkipl2broadcastText, zSkipl2broadcast_NAME, zSkipl2broadcast_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 18, VALUE_OPT_DLT, + /* equiv idx, value */ 18, VALUE_OPT_DLT, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ DLT_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zDltText, zDlt_NAME, zDlt_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 19, VALUE_OPT_ENET_DMAC, + /* equiv idx, value */ 19, VALUE_OPT_ENET_DMAC, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ ENET_DMAC_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zEnet_DmacText, zEnet_Dmac_NAME, zEnet_Dmac_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 20, VALUE_OPT_ENET_SMAC, + /* equiv idx, value */ 20, VALUE_OPT_ENET_SMAC, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ ENET_SMAC_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zEnet_SmacText, zEnet_Smac_NAME, zEnet_Smac_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 21, VALUE_OPT_ENET_VLAN, + /* equiv idx, value */ 21, VALUE_OPT_ENET_VLAN, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ ENET_VLAN_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zEnet_VlanText, zEnet_Vlan_NAME, zEnet_Vlan_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 22, VALUE_OPT_ENET_VLAN_TAG, + /* equiv idx, value */ 22, VALUE_OPT_ENET_VLAN_TAG, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ ENET_VLAN_TAG_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aEnet_Vlan_TagMustList, NULL, + /* option proc */ doOptEnet_Vlan_Tag, + /* desc, NAME, name */ zEnet_Vlan_TagText, zEnet_Vlan_Tag_NAME, zEnet_Vlan_Tag_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 23, VALUE_OPT_ENET_VLAN_CFI, + /* equiv idx, value */ 23, VALUE_OPT_ENET_VLAN_CFI, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ ENET_VLAN_CFI_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aEnet_Vlan_CfiMustList, NULL, + /* option proc */ doOptEnet_Vlan_Cfi, + /* desc, NAME, name */ zEnet_Vlan_CfiText, zEnet_Vlan_Cfi_NAME, zEnet_Vlan_Cfi_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 24, VALUE_OPT_ENET_VLAN_PRI, + /* equiv idx, value */ 24, VALUE_OPT_ENET_VLAN_PRI, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ ENET_VLAN_PRI_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aEnet_Vlan_PriMustList, NULL, + /* option proc */ doOptEnet_Vlan_Pri, + /* desc, NAME, name */ zEnet_Vlan_PriText, zEnet_Vlan_Pri_NAME, zEnet_Vlan_Pri_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 25, VALUE_OPT_HDLC_CONTROL, + /* equiv idx, value */ 25, VALUE_OPT_HDLC_CONTROL, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ HDLC_CONTROL_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionNumericVal, + /* desc, NAME, name */ zHdlc_ControlText, zHdlc_Control_NAME, zHdlc_Control_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 26, VALUE_OPT_HDLC_ADDRESS, + /* equiv idx, value */ 26, VALUE_OPT_HDLC_ADDRESS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ HDLC_ADDRESS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionNumericVal, + /* desc, NAME, name */ zHdlc_AddressText, zHdlc_Address_NAME, zHdlc_Address_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 27, VALUE_OPT_USER_DLT, + /* equiv idx, value */ 27, VALUE_OPT_USER_DLT, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ USER_DLT_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionNumericVal, + /* desc, NAME, name */ zUser_DltText, zUser_Dlt_NAME, zUser_Dlt_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 28, VALUE_OPT_USER_DLINK, + /* equiv idx, value */ 28, VALUE_OPT_USER_DLINK, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 2, 0, + /* opt state flags */ USER_DLINK_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionStackArg, + /* desc, NAME, name */ zUser_DlinkText, zUser_Dlink_NAME, zUser_Dlink_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 29, VALUE_OPT_DBUG, + /* equiv idx, value */ 29, VALUE_OPT_DBUG, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ DBUG_FLAGS, 0, + /* last opt argumnt */ { zDbugDefaultArg }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptDbug, + /* desc, NAME, name */ zDbugText, zDbug_NAME, zDbug_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 30, VALUE_OPT_QUIET, + /* equiv idx, value */ 30, VALUE_OPT_QUIET, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ QUIET_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zQuietText, zQuiet_NAME, zQuiet_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 31, VALUE_OPT_TIMER, + /* equiv idx, value */ 31, VALUE_OPT_TIMER, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ TIMER_FLAGS, 0, + /* last opt argumnt */ { zTimerDefaultArg }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zTimerText, zTimer_NAME, zTimer_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 32, VALUE_OPT_SLEEP_ACCEL, + /* equiv idx, value */ 32, VALUE_OPT_SLEEP_ACCEL, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ SLEEP_ACCEL_FLAGS, 0, + /* last opt argumnt */ { zSleep_AccelDefaultArg }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionNumericVal, + /* desc, NAME, name */ zSleep_AccelText, zSleep_Accel_NAME, zSleep_Accel_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 33, VALUE_OPT_RDTSC_CLICKS, + /* equiv idx, value */ 33, VALUE_OPT_RDTSC_CLICKS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ RDTSC_CLICKS_FLAGS, 0, + /* last opt argumnt */ { zRdtsc_ClicksDefaultArg }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionNumericVal, + /* desc, NAME, name */ zRdtsc_ClicksText, zRdtsc_Clicks_NAME, zRdtsc_Clicks_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 34, VALUE_OPT_VERBOSE, + /* equiv idx, value */ 34, VALUE_OPT_VERBOSE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ VERBOSE_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zVerboseText, zVerbose_NAME, zVerbose_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 35, VALUE_OPT_DECODE, + /* equiv idx, value */ 35, VALUE_OPT_DECODE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ DECODE_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aDecodeMustList, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zDecodeText, zDecode_NAME, zDecode_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 36, VALUE_OPT_ENABLE_FILE_CACHE, + /* equiv idx, value */ 36, VALUE_OPT_ENABLE_FILE_CACHE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ ENABLE_FILE_CACHE_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aEnable_File_CacheMustList, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zEnable_File_CacheText, zEnable_File_Cache_NAME, zEnable_File_Cache_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 37, VALUE_OPT_PRELOAD_PCAP, + /* equiv idx, value */ 37, VALUE_OPT_PRELOAD_PCAP, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ PRELOAD_PCAP_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zPreload_PcapText, zPreload_Pcap_NAME, zPreload_Pcap_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 38, VALUE_OPT_CACHEFILE, + /* equiv idx, value */ 38, VALUE_OPT_CACHEFILE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ CACHEFILE_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zCachefileText, zCachefile_NAME, zCachefile_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 39, VALUE_OPT_INTF1, + /* equiv idx, value */ 39, VALUE_OPT_INTF1, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 1, 1, 0, + /* opt state flags */ INTF1_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zIntf1Text, zIntf1_NAME, zIntf1_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 40, VALUE_OPT_INTF2, + /* equiv idx, value */ 40, VALUE_OPT_INTF2, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ INTF2_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aIntf2MustList, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zIntf2Text, zIntf2_NAME, zIntf2_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 41, VALUE_OPT_LISTNICS, + /* equiv idx, value */ 41, VALUE_OPT_LISTNICS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ LISTNICS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptListnics, + /* desc, NAME, name */ zListnicsText, zListnics_NAME, zListnics_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 42, VALUE_OPT_LOOP, + /* equiv idx, value */ 42, VALUE_OPT_LOOP, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ LOOP_FLAGS, 0, + /* last opt argumnt */ { zLoopDefaultArg }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptLoop, + /* desc, NAME, name */ zLoopText, zLoop_NAME, zLoop_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 43, VALUE_OPT_PKTLEN, + /* equiv idx, value */ 43, VALUE_OPT_PKTLEN, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ PKTLEN_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zPktlenText, zPktlen_NAME, zPktlen_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 44, VALUE_OPT_LIMIT, + /* equiv idx, value */ 44, VALUE_OPT_LIMIT, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ LIMIT_FLAGS, 0, + /* last opt argumnt */ { zLimitDefaultArg }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptLimit, + /* desc, NAME, name */ zLimitText, zLimit_NAME, zLimit_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 45, VALUE_OPT_MULTIPLIER, + /* equiv idx, value */ 45, VALUE_OPT_MULTIPLIER, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ MULTIPLIER_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aMultiplierCantList, + /* option proc */ NULL, + /* desc, NAME, name */ zMultiplierText, zMultiplier_NAME, zMultiplier_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 46, VALUE_OPT_PPS, + /* equiv idx, value */ 46, VALUE_OPT_PPS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ PPS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aPpsCantList, + /* option proc */ optionNumericVal, + /* desc, NAME, name */ zPpsText, zPps_NAME, zPps_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 47, VALUE_OPT_MBPS, + /* equiv idx, value */ 47, VALUE_OPT_MBPS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ MBPS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aMbpsCantList, + /* option proc */ NULL, + /* desc, NAME, name */ zMbpsText, zMbps_NAME, zMbps_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 48, VALUE_OPT_TOPSPEED, + /* equiv idx, value */ 48, VALUE_OPT_TOPSPEED, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ TOPSPEED_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aTopspeedCantList, + /* option proc */ NULL, + /* desc, NAME, name */ zTopspeedText, zTopspeed_NAME, zTopspeed_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 49, VALUE_OPT_ONEATATIME, + /* equiv idx, value */ 49, VALUE_OPT_ONEATATIME, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ ONEATATIME_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aOneatatimeCantList, + /* option proc */ NULL, + /* desc, NAME, name */ zOneatatimeText, zOneatatime_NAME, zOneatatime_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 50, VALUE_OPT_PPS_MULTI, + /* equiv idx, value */ 50, VALUE_OPT_PPS_MULTI, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ PPS_MULTI_FLAGS, 0, + /* last opt argumnt */ { zPps_MultiDefaultArg }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aPps_MultiMustList, NULL, + /* option proc */ doOptPps_Multi, + /* desc, NAME, name */ zPps_MultiText, zPps_Multi_NAME, zPps_Multi_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 51, VALUE_OPT_PID, + /* equiv idx, value */ 51, VALUE_OPT_PID, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ PID_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptPid, + /* desc, NAME, name */ zPidText, zPid_NAME, zPid_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 52, VALUE_OPT_STATS, + /* equiv idx, value */ 52, VALUE_OPT_STATS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ STATS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptStats, + /* desc, NAME, name */ zStatsText, zStats_NAME, zStats_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 53, VALUE_OPT_VERSION, + /* equiv idx, value */ 53, VALUE_OPT_VERSION, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ VERSION_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptVersion, + /* desc, NAME, name */ zVersionText, zVersion_NAME, zVersion_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 54, VALUE_OPT_LESS_HELP, + /* equiv idx, value */ 54, VALUE_OPT_LESS_HELP, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ LESS_HELP_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptLess_Help, + /* desc, NAME, name */ zLess_HelpText, zLess_Help_NAME, zLess_Help_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doUsageOpt, + /* desc, NAME, name */ zHelpText, NULL, zHelp_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionPagedUsage, + /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) + | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, NOLIMIT, 0, + /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) + | OPTST_DISABLE_IMM, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionLoadOpt, + /* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name, + /* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx } +}; +tOptDesc * const tcpedit_tcpedit_optDesc_p = optDesc + 0; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Define the Tcpreplay Option Environment + */ +tSCC zPROGNAME[] = "TCPREPLAY"; +tSCC zUsageTitle[] = +"tcpreplay (tcpreplay) - Replay network traffic stored in pcap files\n\ +USAGE: %s [ - [] | --[{=| }] ]... \n"; +tSCC zRcName[] = ".tcpreplayrc"; +tSCC* apzHomeList[] = { + "$$/", + NULL }; + +#define zBugsAddr NULL +tSCC zExplain[] = "\n\ +tcpreplay is a tool for replaying network traffic from files saved with\n\ +tcpdump or other tools which write pcap(3) files.\n"; +tSCC zDetail[] = "\n\ +The basic operation of tcpreplay is to resend all packets from the\n\ +input file(s) at the speed at which they were recorded, or a specified \n\ +data rate, up to as fast as the hardware is capable.\n\n\ +Optionally, the traffic can be split between two interfaces, written to\n\ +files, filtered and edited in various ways, providing the means to test\n\ +firewalls, NIDS and other network devices.\n\n\ +For more details, please see the Tcpreplay Manual at:\n\ +http://tcpreplay.synfin.net/trac/wiki/manual\n"; +#define zFullVersion NULL +/* extracted from /usr/local/share/autogen/optcode.tpl near line 501 */ + +#if defined(ENABLE_NLS) +# define OPTPROC_BASE OPTPROC_TRANSLATE + static tOptionXlateProc translate_option_strings; +#else +# define OPTPROC_BASE OPTPROC_NONE +# define translate_option_strings NULL +#endif /* ENABLE_NLS */ + + +#define tcpreplay_full_usage NULL +#define tcpreplay_short_usage NULL +tOptions tcpreplayOptions = { + OPTIONS_STRUCT_VERSION, + 0, NULL, /* original argc + argv */ + ( OPTPROC_BASE + + OPTPROC_ERRSTOP + + OPTPROC_SHORTOPT + + OPTPROC_LONGOPT + + OPTPROC_NO_REQ_OPT + + OPTPROC_ARGS_REQ + + OPTPROC_GNUUSAGE ), + 0, NULL, /* current option index, current option */ + NULL, NULL, zPROGNAME, + zRcName, zCopyright, zCopyrightNotice, + zFullVersion, apzHomeList, zUsageTitle, + zExplain, zDetail, optDesc, + zBugsAddr, /* address to send bugs to */ + NULL, NULL, /* extensions/saved state */ + optionUsage, /* usage procedure */ + translate_option_strings, /* translation procedure */ + /* + * Indexes to special options + */ + { INDEX_OPT_MORE_HELP, /* more-help option index */ + INDEX_OPT_SAVE_OPTS, /* save option index */ + NO_EQUIVALENT, /* '-#' option index */ + 9 /* index of default opt */ + }, + 59 /* full option count */, 55 /* user option count */, + tcpreplay_full_usage, tcpreplay_short_usage, + NULL, NULL +}; + +/* + * Create the static procedure(s) declared above. + */ +static void +doUsageOpt( + tOptions* pOptions, + tOptDesc* pOptDesc ) +{ + (void)pOptions; + USAGE( EXIT_SUCCESS ); +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the mtu option. + */ +static void +doOptMtu(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 1, MAXPACKET } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the tos option. + */ +static void +doOptTos(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 0, 255 } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the tclass option. + */ +static void +doOptTclass(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 0, 255 } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the flowlabel option. + */ +static void +doOptFlowlabel(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 0, 1048575 } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the enet-vlan-tag option. + */ +static void +doOptEnet_Vlan_Tag(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 0, 4095 } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the enet-vlan-cfi option. + */ +static void +doOptEnet_Vlan_Cfi(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 0, 1 } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the enet-vlan-pri option. + */ +static void +doOptEnet_Vlan_Pri(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 0, 7 } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the dbug option, when DEBUG is #define-d. + */ +#ifdef DEBUG +static void +doOptDbug(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 0, 5 } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} +#endif /* defined DEBUG */ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the listnics option, when ENABLE_PCAP_FINDALLDEVS is #define-d. + */ +#ifdef ENABLE_PCAP_FINDALLDEVS +static void +doOptListnics(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcpreplay_opts.def, line 267 */ + + interface_list_t *list = get_interface_list(); + list_interfaces(list); + free(list); + exit(0); + +} +#endif /* defined ENABLE_PCAP_FINDALLDEVS */ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the loop option. + */ +static void +doOptLoop(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 0, LONG_MAX } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the limit option. + */ +static void +doOptLimit(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 1, LONG_MAX } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the pps-multi option. + */ +static void +doOptPps_Multi(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 1, LONG_MAX } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the pid option. + */ +static void +doOptPid(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcpreplay_opts.def, line 417 */ + +fprintf(stderr, "PID: %hu\n", getpid()); + +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the stats option. + */ +static void +doOptStats(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 1, LONG_MAX } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the version option. + */ +static void +doOptVersion(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcpreplay_opts.def, line 440 */ + + fprintf(stderr, "tcpreplay version: %s (build %s)", VERSION, svn_version()); +#ifdef DEBUG + fprintf(stderr, " (debug)"); +#endif + fprintf(stderr, "\n"); + fprintf(stderr, "Copyright 2000-2010 by Aaron Turner \n"); + fprintf(stderr, "Cache file supported: %s\n", CACHEVERSION); +#ifdef HAVE_LIBDNET + fprintf(stderr, "Compiled against libdnet: %s\n", LIBDNET_VERSION); +#else + fprintf(stderr, "Not compiled with libdnet.\n"); +#endif +#ifdef HAVE_WINPCAP + fprintf(stderr, "Compiled against winpcap: %s\n", get_pcap_version()); +#else + fprintf(stderr, "Compiled against libpcap: %s\n", get_pcap_version()); +#endif +#ifdef ENABLE_64BITS + fprintf(stderr, "64 bit packet counters: enabled\n"); +#else + fprintf(stderr, "64 bit packet counters: disabled\n"); +#endif +#ifdef ENABLE_VERBOSE + fprintf(stderr, "Verbose printing via tcpdump: enabled\n"); +#else + fprintf(stderr, "Verbose printing via tcpdump: disabled\n"); +#endif +#ifdef TCPREPLAY_EDIT + fprintf(stderr, "Packet editing: enabled\n"); +#else + fprintf(stderr, "Packet editing: disabled\n"); +#endif +#ifdef ENABLE_FRAGROUTE + fprintf(stderr, "Fragroute engine: enabled\n"); +#else + fprintf(stderr, "Fragroute engine: disabled\n"); +#endif + fprintf(stderr, "Injection method: %s\n", sendpacket_get_method()); + exit(0); + +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the less-help option. + */ +static void +doOptLess_Help(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcpreplay_opts.def, line 491 */ + + USAGE(EXIT_FAILURE); + +} +/* extracted from /usr/local/share/autogen/optcode.tpl near line 633 */ + +#if ENABLE_NLS +#include +#include +#include +#include +#include + +static char* AO_gettext( char const* pz ); +static void coerce_it(void** s); + +static char* +AO_gettext( char const* pz ) +{ + char* pzRes; + if (pz == NULL) + return NULL; + pzRes = _(pz); + if (pzRes == pz) + return pzRes; + pzRes = strdup( pzRes ); + if (pzRes == NULL) { + fputs( _("No memory for duping translated strings\n"), stderr ); + exit( EXIT_FAILURE ); + } + return pzRes; +} + +static void coerce_it(void** s) { *s = AO_gettext(*s); } +#define COERSION(_f) \ + coerce_it((void*)&(tcpreplayOptions._f)) + +/* + * This invokes the translation code (e.g. gettext(3)). + */ +static void +translate_option_strings( void ) +{ + /* + * Guard against re-translation. It won't work. The strings will have + * been changed by the first pass through this code. One shot only. + */ + if (option_usage_text.field_ct != 0) { + + /* + * Do the translations. The first pointer follows the field count + * field. The field count field is the size of a pointer. + */ + tOptDesc* pOD = tcpreplayOptions.pOptDesc; + char** ppz = (char**)(void*)&(option_usage_text); + int ix = option_usage_text.field_ct; + + do { + ppz++; + *ppz = AO_gettext(*ppz); + } while (--ix > 0); + + COERSION(pzCopyright); + COERSION(pzCopyNotice); + COERSION(pzFullVersion); + COERSION(pzUsageTitle); + COERSION(pzExplain); + COERSION(pzDetail); + option_usage_text.field_ct = 0; + + for (ix = tcpreplayOptions.optCt; ix > 0; ix--, pOD++) + coerce_it((void*)&(pOD->pzText)); + } + + if ((tcpreplayOptions.fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) { + tOptDesc* pOD = tcpreplayOptions.pOptDesc; + int ix; + + for (ix = tcpreplayOptions.optCt; ix > 0; ix--, pOD++) { + coerce_it((void*)&(pOD->pz_Name)); + coerce_it((void*)&(pOD->pz_DisableName)); + coerce_it((void*)&(pOD->pz_DisablePfx)); + } + /* prevent re-translation */ + tcpreplayOptions.fOptSet |= OPTPROC_NXLAT_OPT_CFG | OPTPROC_NXLAT_OPT; + } +} + +#endif /* ENABLE_NLS */ + +#ifdef __cplusplus +} +#endif +/* tcpreplay_edit_opts.c ends here */ diff --git a/src/tcpreplay_edit_opts.h b/src/tcpreplay_edit_opts.h new file mode 100644 index 0000000..b321ee9 --- /dev/null +++ b/src/tcpreplay_edit_opts.h @@ -0,0 +1,321 @@ +/* -*- buffer-read-only: t -*- vi: set ro: + * + * DO NOT EDIT THIS FILE (tcpreplay_edit_opts.h) + * + * It has been AutoGen-ed April 4, 2010 at 05:59:18 PM by AutoGen 5.9.9 + * From the definitions tcpreplay_opts.def + * and the template file options + * + * Generated from AutoOpts 32:2:7 templates. + */ + +/* + * This file was produced by an AutoOpts template. AutoOpts is a + * copyrighted work. This header file is not encumbered by AutoOpts + * licensing, but is provided under the licensing terms chosen by the + * tcpreplay author or copyright holder. AutoOpts is licensed under + * the terms of the LGPL. The redistributable library (``libopts'') is + * licensed under the terms of either the LGPL or, at the users discretion, + * the BSD license. See the AutoOpts and/or libopts sources for details. + * + * This source file is copyrighted and licensed under the following terms: + * + * tcpreplay copyright (c) 2000-2010 Aaron Turner - all rights reserved + * + * tcpreplay is free software copyrighted by Aaron Turner. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name ``Aaron Turner'' nor the name of any other + * contributor may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * tcpreplay IS PROVIDED BY Aaron Turner ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL Aaron Turner OR ANY OTHER CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/* + * This file contains the programmatic interface to the Automated + * Options generated for the tcpreplay program. + * These macros are documented in the AutoGen info file in the + * "AutoOpts" chapter. Please refer to that doc for usage help. + */ +#ifndef AUTOOPTS_TCPREPLAY_EDIT_OPTS_H_GUARD +#define AUTOOPTS_TCPREPLAY_EDIT_OPTS_H_GUARD 1 +#include "config.h" +#include + +/* + * Ensure that the library used for compiling this generated header is at + * least as new as the version current when the header template was released + * (not counting patch version increments). Also ensure that the oldest + * tolerable version is at least as old as what was current when the header + * template was released. + */ +#define AO_TEMPLATE_VERSION 131074 +#if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \ + || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION) +# error option template version mismatches autoopts/options.h header + Choke Me. +#endif + +/* + * Enumeration of each option: + */ +typedef enum { + INDEX_OPT_PORTMAP = 1, + INDEX_OPT_SEED = 2, + INDEX_OPT_PNAT = 3, + INDEX_OPT_SRCIPMAP = 4, + INDEX_OPT_DSTIPMAP = 5, + INDEX_OPT_ENDPOINTS = 6, + INDEX_OPT_SKIPBROADCAST = 7, + INDEX_OPT_FIXCSUM = 8, + INDEX_OPT_MTU = 9, + INDEX_OPT_MTU_TRUNC = 10, + INDEX_OPT_EFCS = 11, + INDEX_OPT_TTL = 12, + INDEX_OPT_TOS = 13, + INDEX_OPT_TCLASS = 14, + INDEX_OPT_FLOWLABEL = 15, + INDEX_OPT_FIXLEN = 16, + INDEX_OPT_SKIPL2BROADCAST = 17, + INDEX_OPT_DLT = 18, + INDEX_OPT_ENET_DMAC = 19, + INDEX_OPT_ENET_SMAC = 20, + INDEX_OPT_ENET_VLAN = 21, + INDEX_OPT_ENET_VLAN_TAG = 22, + INDEX_OPT_ENET_VLAN_CFI = 23, + INDEX_OPT_ENET_VLAN_PRI = 24, + INDEX_OPT_HDLC_CONTROL = 25, + INDEX_OPT_HDLC_ADDRESS = 26, + INDEX_OPT_USER_DLT = 27, + INDEX_OPT_USER_DLINK = 28, + INDEX_OPT_DBUG = 29, + INDEX_OPT_QUIET = 30, + INDEX_OPT_TIMER = 31, + INDEX_OPT_SLEEP_ACCEL = 32, + INDEX_OPT_RDTSC_CLICKS = 33, + INDEX_OPT_VERBOSE = 34, + INDEX_OPT_DECODE = 35, + INDEX_OPT_ENABLE_FILE_CACHE = 36, + INDEX_OPT_PRELOAD_PCAP = 37, + INDEX_OPT_CACHEFILE = 38, + INDEX_OPT_INTF1 = 39, + INDEX_OPT_INTF2 = 40, + INDEX_OPT_LISTNICS = 41, + INDEX_OPT_LOOP = 42, + INDEX_OPT_PKTLEN = 43, + INDEX_OPT_LIMIT = 44, + INDEX_OPT_MULTIPLIER = 45, + INDEX_OPT_PPS = 46, + INDEX_OPT_MBPS = 47, + INDEX_OPT_TOPSPEED = 48, + INDEX_OPT_ONEATATIME = 49, + INDEX_OPT_PPS_MULTI = 50, + INDEX_OPT_PID = 51, + INDEX_OPT_STATS = 52, + INDEX_OPT_VERSION = 53, + INDEX_OPT_LESS_HELP = 54, + INDEX_OPT_HELP = 55, + INDEX_OPT_MORE_HELP = 56, + INDEX_OPT_SAVE_OPTS = 57, + INDEX_OPT_LOAD_OPTS = 58 +} teOptIndex; + +#define OPTION_CT 59 + +/* + * Interface defines for all options. Replace "n" with the UPPER_CASED + * option name (as in the teOptIndex enumeration above). + * e.g. HAVE_OPT( TCPEDIT ) + */ +#define DESC(n) (tcpreplayOptions.pOptDesc[INDEX_OPT_## n]) +#define HAVE_OPT(n) (! UNUSED_OPT(& DESC(n))) +#define OPT_ARG(n) (DESC(n).optArg.argString) +#define STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK) +#define COUNT_OPT(n) (DESC(n).optOccCt) +#define ISSEL_OPT(n) (SELECTED_OPT(&DESC(n))) +#define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n))) +#define ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n))) +#define STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt) +#define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs) +#define CLEAR_OPT(n) STMTS( \ + DESC(n).fOptState &= OPTST_PERSISTENT_MASK; \ + if ( (DESC(n).fOptState & OPTST_INITENABLED) == 0) \ + DESC(n).fOptState |= OPTST_DISABLED; \ + DESC(n).optCookie = NULL ) + +/* * * * * * + * + * Interface defines for specific options. + */ +#define VALUE_OPT_PORTMAP 'r' +#define VALUE_OPT_SEED 's' +#define OPT_VALUE_SEED (DESC(SEED).optArg.argInt) +#define VALUE_OPT_PNAT 'N' +#define VALUE_OPT_SRCIPMAP 'S' +#define VALUE_OPT_DSTIPMAP 'D' +#ifdef HAVE_CACHEFILE_SUPPORT +#define VALUE_OPT_ENDPOINTS 'e' +#endif /* HAVE_CACHEFILE_SUPPORT */ +#define VALUE_OPT_SKIPBROADCAST 'b' +#define VALUE_OPT_FIXCSUM 'C' +#define VALUE_OPT_MTU 'm' +#define OPT_VALUE_MTU (DESC(MTU).optArg.argInt) +#define VALUE_OPT_MTU_TRUNC 10 +#define VALUE_OPT_EFCS 'E' +#define VALUE_OPT_TTL 12 +#define VALUE_OPT_TOS 13 +#define OPT_VALUE_TOS (DESC(TOS).optArg.argInt) +#define VALUE_OPT_TCLASS 14 +#define OPT_VALUE_TCLASS (DESC(TCLASS).optArg.argInt) +#define VALUE_OPT_FLOWLABEL 15 +#define OPT_VALUE_FLOWLABEL (DESC(FLOWLABEL).optArg.argInt) +#define VALUE_OPT_FIXLEN 'F' +#define VALUE_OPT_SKIPL2BROADCAST 17 +#define VALUE_OPT_DLT 18 +#define VALUE_OPT_ENET_DMAC 19 +#define VALUE_OPT_ENET_SMAC 20 +#define VALUE_OPT_ENET_VLAN 21 +#define VALUE_OPT_ENET_VLAN_TAG 22 +#define OPT_VALUE_ENET_VLAN_TAG (DESC(ENET_VLAN_TAG).optArg.argInt) +#define VALUE_OPT_ENET_VLAN_CFI 23 +#define OPT_VALUE_ENET_VLAN_CFI (DESC(ENET_VLAN_CFI).optArg.argInt) +#define VALUE_OPT_ENET_VLAN_PRI 24 +#define OPT_VALUE_ENET_VLAN_PRI (DESC(ENET_VLAN_PRI).optArg.argInt) +#define VALUE_OPT_HDLC_CONTROL 25 +#define OPT_VALUE_HDLC_CONTROL (DESC(HDLC_CONTROL).optArg.argInt) +#define VALUE_OPT_HDLC_ADDRESS 26 +#define OPT_VALUE_HDLC_ADDRESS (DESC(HDLC_ADDRESS).optArg.argInt) +#define VALUE_OPT_USER_DLT 27 +#define OPT_VALUE_USER_DLT (DESC(USER_DLT).optArg.argInt) +#define VALUE_OPT_USER_DLINK 28 +#ifdef DEBUG +#define VALUE_OPT_DBUG 'd' +#define OPT_VALUE_DBUG (DESC(DBUG).optArg.argInt) +#endif /* DEBUG */ +#define VALUE_OPT_QUIET 'q' +#define VALUE_OPT_TIMER 'T' +#define VALUE_OPT_SLEEP_ACCEL 32 +#define OPT_VALUE_SLEEP_ACCEL (DESC(SLEEP_ACCEL).optArg.argInt) +#define VALUE_OPT_RDTSC_CLICKS 129 +#define OPT_VALUE_RDTSC_CLICKS (DESC(RDTSC_CLICKS).optArg.argInt) +#ifdef ENABLE_VERBOSE +#define VALUE_OPT_VERBOSE 'v' +#define SET_OPT_VERBOSE STMTS( \ + DESC(VERBOSE).optActualIndex = 34; \ + DESC(VERBOSE).optActualValue = VALUE_OPT_VERBOSE; \ + DESC(VERBOSE).fOptState &= OPTST_PERSISTENT_MASK; \ + DESC(VERBOSE).fOptState |= OPTST_SET ) +#endif /* ENABLE_VERBOSE */ +#ifdef ENABLE_VERBOSE +#define VALUE_OPT_DECODE 'A' +#endif /* ENABLE_VERBOSE */ +#define VALUE_OPT_ENABLE_FILE_CACHE 'K' +#define VALUE_OPT_PRELOAD_PCAP 133 +#define VALUE_OPT_CACHEFILE 'c' +#define VALUE_OPT_INTF1 'i' +#define VALUE_OPT_INTF2 'I' +#ifdef ENABLE_PCAP_FINDALLDEVS +#define VALUE_OPT_LISTNICS 137 +#endif /* ENABLE_PCAP_FINDALLDEVS */ +#define VALUE_OPT_LOOP 'l' +#define OPT_VALUE_LOOP (DESC(LOOP).optArg.argInt) +#define VALUE_OPT_PKTLEN 139 +#define VALUE_OPT_LIMIT 'L' +#define OPT_VALUE_LIMIT (DESC(LIMIT).optArg.argInt) +#define VALUE_OPT_MULTIPLIER 'x' +#define VALUE_OPT_PPS 'p' +#define OPT_VALUE_PPS (DESC(PPS).optArg.argInt) +#define VALUE_OPT_MBPS 'M' +#define VALUE_OPT_TOPSPEED 't' +#define VALUE_OPT_ONEATATIME 'o' +#define VALUE_OPT_PPS_MULTI 146 +#define OPT_VALUE_PPS_MULTI (DESC(PPS_MULTI).optArg.argInt) +#define VALUE_OPT_PID 'P' +#define VALUE_OPT_STATS 148 +#define OPT_VALUE_STATS (DESC(STATS).optArg.argInt) +#define VALUE_OPT_VERSION 'V' +#define VALUE_OPT_LESS_HELP 'h' +#define VALUE_OPT_HELP 'H' +#define VALUE_OPT_MORE_HELP '!' +#define VALUE_OPT_SAVE_OPTS INDEX_OPT_SAVE_OPTS +#define VALUE_OPT_LOAD_OPTS INDEX_OPT_LOAD_OPTS +#define SET_OPT_SAVE_OPTS(a) STMTS( \ + DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \ + DESC(SAVE_OPTS).fOptState |= OPTST_SET; \ + DESC(SAVE_OPTS).optArg.argString = (char const*)(a) ) +/* + * Interface defines not associated with particular options + */ +#define ERRSKIP_OPTERR STMTS( tcpreplayOptions.fOptSet &= ~OPTPROC_ERRSTOP ) +#define ERRSTOP_OPTERR STMTS( tcpreplayOptions.fOptSet |= OPTPROC_ERRSTOP ) +#define RESTART_OPT(n) STMTS( \ + tcpreplayOptions.curOptIdx = (n); \ + tcpreplayOptions.pzCurOpt = NULL ) +#define START_OPT RESTART_OPT(1) +#define USAGE(c) (*tcpreplayOptions.pUsageProc)( &tcpreplayOptions, c ) +/* extracted from /usr/local/share/autogen/opthead.tpl near line 409 */ + +/* * * * * * + * + * Declare the tcpreplay option descriptor. + */ +#ifdef __cplusplus +extern "C" { +#endif + +extern tOptions tcpreplayOptions; + +#if defined(ENABLE_NLS) +# ifndef _ +# include + static inline char* aoGetsText( char const* pz ) { + if (pz == NULL) return NULL; + return (char*)gettext( pz ); + } +# define _(s) aoGetsText(s) +# endif /* _() */ + +# define OPT_NO_XLAT_CFG_NAMES STMTS(tcpreplayOptions.fOptSet |= \ + OPTPROC_NXLAT_OPT_CFG;) +# define OPT_NO_XLAT_OPT_NAMES STMTS(tcpreplayOptions.fOptSet |= \ + OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;) + +# define OPT_XLAT_CFG_NAMES STMTS(tcpreplayOptions.fOptSet &= \ + ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);) +# define OPT_XLAT_OPT_NAMES STMTS(tcpreplayOptions.fOptSet &= \ + ~OPTPROC_NXLAT_OPT;) + +#else /* ENABLE_NLS */ +# define OPT_NO_XLAT_CFG_NAMES +# define OPT_NO_XLAT_OPT_NAMES + +# define OPT_XLAT_CFG_NAMES +# define OPT_XLAT_OPT_NAMES + +# ifndef _ +# define _(_s) _s +# endif +#endif /* ENABLE_NLS */ + +#ifdef __cplusplus +} +#endif +#endif /* AUTOOPTS_TCPREPLAY_EDIT_OPTS_H_GUARD */ +/* tcpreplay_edit_opts.h ends here */ diff --git a/src/tcpreplay_opts.c b/src/tcpreplay_opts.c new file mode 100644 index 0000000..0ebb0f6 --- /dev/null +++ b/src/tcpreplay_opts.c @@ -0,0 +1,1532 @@ +/* -*- buffer-read-only: t -*- vi: set ro: + * + * DO NOT EDIT THIS FILE (tcpreplay_opts.c) + * + * It has been AutoGen-ed April 4, 2010 at 05:59:18 PM by AutoGen 5.9.9 + * From the definitions tcpreplay_opts.def + * and the template file options + * + * Generated from AutoOpts 32:2:7 templates. + */ + +/* + * This file was produced by an AutoOpts template. AutoOpts is a + * copyrighted work. This source file is not encumbered by AutoOpts + * licensing, but is provided under the licensing terms chosen by the + * tcpreplay author or copyright holder. AutoOpts is licensed under + * the terms of the LGPL. The redistributable library (``libopts'') is + * licensed under the terms of either the LGPL or, at the users discretion, + * the BSD license. See the AutoOpts and/or libopts sources for details. + * + * This source file is copyrighted and licensed under the following terms: + * + * tcpreplay copyright (c) 2000-2010 Aaron Turner - all rights reserved + * + * tcpreplay is free software copyrighted by Aaron Turner. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name ``Aaron Turner'' nor the name of any other + * contributor may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * tcpreplay IS PROVIDED BY Aaron Turner ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL Aaron Turner OR ANY OTHER CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +extern FILE * option_usage_fp; +#define OPTION_CODE_COMPILE 1 +#include "tcpreplay_opts.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* TRANSLATORS: choose the translation for option names wisely because you + cannot ever change your mind. */ +tSCC zCopyright[] = + "tcpreplay copyright (c) 2000-2010 Aaron Turner, all rights reserved"; +tSCC zCopyrightNotice[1458] = +"tcpreplay is free software copyrighted by Aaron Turner.\n\n\ +Redistribution and use in source and binary forms, with or without\n\ +modification, are permitted provided that the following conditions are met: 1.\n\ +Redistributions of source code must retain the above copyright notice, this\n\ +list of conditions and the following disclaimer. 2. Redistributions in binary\n\ +form must reproduce the above copyright notice, this list of conditions and the\n\ +following disclaimer in the documentation and/or other materials provided with\n\ +the distribution. 3. Neither the name ``Aaron Turner'' nor the name of any\n\ +other contributor may be used to endorse or promote products derived from this\n\ +software without specific prior written permission.\n\n\ +tcpreplay IS PROVIDED BY Aaron Turner ``AS IS'' AND ANY EXPRESS OR IMPLIED\n\ +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n\ +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO\n\ +EVENT SHALL Aaron Turner OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n\ +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\n\ +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n\ +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n\ +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n\ +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\n\ +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."; + +extern tUsageProc optionUsage; + +/* + * global included definitions + */ +#include "defines.h" +#include "tcpreplay.h" +#include "common.h" +#include "config.h" +#include +#include +#include +extern tcpreplay_opt_t options; + + +#ifndef NULL +# define NULL 0 +#endif +#ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +#endif +#ifndef EXIT_FAILURE +# define EXIT_FAILURE 1 +#endif +/* + * Dbug option description: + */ +#ifdef DEBUG +tSCC zDbugText[] = + "Enable debugging output"; +tSCC zDbug_NAME[] = "DBUG"; +tSCC zDbug_Name[] = "dbug"; +#define zDbugDefaultArg ((char const*)0) +#define DBUG_FLAGS (OPTST_DISABLED | OPTST_IMM \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +#else /* disable Dbug */ +#define VALUE_OPT_DBUG NO_EQUIVALENT +#define DBUG_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zDbugDefaultArg NULL +#define zDbugText NULL +#define zDbug_NAME NULL +#define zDbug_Name NULL +#endif /* DEBUG */ + +/* + * Quiet option description: + */ +tSCC zQuietText[] = + "Quiet mode"; +tSCC zQuiet_NAME[] = "QUIET"; +tSCC zQuiet_Name[] = "quiet"; +#define QUIET_FLAGS (OPTST_DISABLED) + +/* + * Timer option description: + */ +tSCC zTimerText[] = + "Select packet timing mode: select, ioport, rdtsc, gtod, nano, abstime"; +tSCC zTimer_NAME[] = "TIMER"; +tSCC zTimer_Name[] = "timer"; +tSCC zTimerDefaultArg[] = "gtod"; +#define TIMER_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Sleep_Accel option description: + */ +tSCC zSleep_AccelText[] = + "Reduce the amount of time to sleep by specified usec"; +tSCC zSleep_Accel_NAME[] = "SLEEP_ACCEL"; +tSCC zSleep_Accel_Name[] = "sleep-accel"; +#define zSleep_AccelDefaultArg ((char const*)0) +#define SLEEP_ACCEL_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Rdtsc_Clicks option description: + */ +tSCC zRdtsc_ClicksText[] = + "Specify the RDTSC clicks/usec"; +tSCC zRdtsc_Clicks_NAME[] = "RDTSC_CLICKS"; +tSCC zRdtsc_Clicks_Name[] = "rdtsc-clicks"; +#define zRdtsc_ClicksDefaultArg ((char const*)0) +#define RDTSC_CLICKS_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Verbose option description: + */ +#ifdef ENABLE_VERBOSE +tSCC zVerboseText[] = + "Print decoded packets via tcpdump to STDOUT"; +tSCC zVerbose_NAME[] = "VERBOSE"; +tSCC zVerbose_Name[] = "verbose"; +#define VERBOSE_FLAGS (OPTST_DISABLED | OPTST_IMM) + +#else /* disable Verbose */ +#define VALUE_OPT_VERBOSE NO_EQUIVALENT +#define VERBOSE_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zVerboseText NULL +#define zVerbose_NAME NULL +#define zVerbose_Name NULL +#endif /* ENABLE_VERBOSE */ + +/* + * Decode option description with + * "Must also have options" and "Incompatible options": + */ +#ifdef ENABLE_VERBOSE +tSCC zDecodeText[] = + "Arguments passed to tcpdump decoder"; +tSCC zDecode_NAME[] = "DECODE"; +tSCC zDecode_Name[] = "decode"; +static const int + aDecodeMustList[] = { + INDEX_OPT_VERBOSE, NO_EQUIVALENT }; +#define DECODE_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +#else /* disable Decode */ +#define VALUE_OPT_DECODE NO_EQUIVALENT +#define DECODE_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define aDecodeMustList NULL +#define zDecodeText NULL +#define zDecode_NAME NULL +#define zDecode_Name NULL +#endif /* ENABLE_VERBOSE */ + +/* + * Enable_File_Cache option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zEnable_File_CacheText[] = + "Enable caching of packets to internal memory"; +tSCC zEnable_File_Cache_NAME[] = "ENABLE_FILE_CACHE"; +tSCC zEnable_File_Cache_Name[] = "enable-file-cache"; +static const int + aEnable_File_CacheMustList[] = { + INDEX_OPT_LOOP, NO_EQUIVALENT }; +#define ENABLE_FILE_CACHE_FLAGS (OPTST_DISABLED) + +/* + * Preload_Pcap option description: + */ +tSCC zPreload_PcapText[] = + "Preloads packets into RAM before sending"; +tSCC zPreload_Pcap_NAME[] = "PRELOAD_PCAP"; +tSCC zPreload_Pcap_Name[] = "preload-pcap"; +#define PRELOAD_PCAP_FLAGS (OPTST_DISABLED) + +/* + * Cachefile option description: + */ +tSCC zCachefileText[] = + "Split traffic via a tcpprep cache file"; +tSCC zCachefile_NAME[] = "CACHEFILE"; +tSCC zCachefile_Name[] = "cachefile"; +#define CACHEFILE_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Intf1 option description: + */ +tSCC zIntf1Text[] = + "Server/primary traffic output interface"; +tSCC zIntf1_NAME[] = "INTF1"; +tSCC zIntf1_Name[] = "intf1"; +#define INTF1_FLAGS (OPTST_DISABLED | OPTST_MUST_SET \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Intf2 option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zIntf2Text[] = + "Client/secondary traffic output interface"; +tSCC zIntf2_NAME[] = "INTF2"; +tSCC zIntf2_Name[] = "intf2"; +static const int + aIntf2MustList[] = { + INDEX_OPT_CACHEFILE, NO_EQUIVALENT }; +#define INTF2_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Listnics option description: + */ +#ifdef ENABLE_PCAP_FINDALLDEVS +tSCC zListnicsText[] = + "List available network interfaces and exit"; +tSCC zListnics_NAME[] = "LISTNICS"; +tSCC zListnics_Name[] = "listnics"; +#define LISTNICS_FLAGS (OPTST_DISABLED | OPTST_IMM) + +#else /* disable Listnics */ +#define VALUE_OPT_LISTNICS NO_EQUIVALENT +#define LISTNICS_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zListnicsText NULL +#define zListnics_NAME NULL +#define zListnics_Name NULL +#endif /* ENABLE_PCAP_FINDALLDEVS */ + +/* + * Loop option description: + */ +tSCC zLoopText[] = + "Loop through the capture file X times"; +tSCC zLoop_NAME[] = "LOOP"; +tSCC zLoop_Name[] = "loop"; +#define zLoopDefaultArg ((char const*)1) +#define LOOP_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Pktlen option description: + */ +tSCC zPktlenText[] = + "Override the snaplen and use the actual packet len"; +tSCC zPktlen_NAME[] = "PKTLEN"; +tSCC zPktlen_Name[] = "pktlen"; +#define PKTLEN_FLAGS (OPTST_DISABLED) + +/* + * Limit option description: + */ +tSCC zLimitText[] = + "Limit the number of packets to send"; +tSCC zLimit_NAME[] = "LIMIT"; +tSCC zLimit_Name[] = "limit"; +#define zLimitDefaultArg ((char const*)-1) +#define LIMIT_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Multiplier option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zMultiplierText[] = + "Modify replay speed to a given multiple"; +tSCC zMultiplier_NAME[] = "MULTIPLIER"; +tSCC zMultiplier_Name[] = "multiplier"; +static const int + aMultiplierCantList[] = { + INDEX_OPT_PPS, + INDEX_OPT_MBPS, + INDEX_OPT_ONEATATIME, + INDEX_OPT_TOPSPEED, NO_EQUIVALENT }; +#define MULTIPLIER_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Pps option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zPpsText[] = + "Replay packets at a given packets/sec"; +tSCC zPps_NAME[] = "PPS"; +tSCC zPps_Name[] = "pps"; +static const int + aPpsCantList[] = { + INDEX_OPT_MULTIPLIER, + INDEX_OPT_MBPS, + INDEX_OPT_ONEATATIME, + INDEX_OPT_TOPSPEED, NO_EQUIVALENT }; +#define PPS_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Mbps option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zMbpsText[] = + "Replay packets at a given Mbps"; +tSCC zMbps_NAME[] = "MBPS"; +tSCC zMbps_Name[] = "mbps"; +static const int + aMbpsCantList[] = { + INDEX_OPT_MULTIPLIER, + INDEX_OPT_PPS, + INDEX_OPT_ONEATATIME, + INDEX_OPT_TOPSPEED, NO_EQUIVALENT }; +#define MBPS_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Topspeed option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zTopspeedText[] = + "Replay packets as fast as possible"; +tSCC zTopspeed_NAME[] = "TOPSPEED"; +tSCC zTopspeed_Name[] = "topspeed"; +static const int + aTopspeedCantList[] = { + INDEX_OPT_MBPS, + INDEX_OPT_MULTIPLIER, + INDEX_OPT_PPS, + INDEX_OPT_ONEATATIME, NO_EQUIVALENT }; +#define TOPSPEED_FLAGS (OPTST_DISABLED) + +/* + * Oneatatime option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zOneatatimeText[] = + "Replay one packet at a time for each user input"; +tSCC zOneatatime_NAME[] = "ONEATATIME"; +tSCC zOneatatime_Name[] = "oneatatime"; +static const int + aOneatatimeCantList[] = { + INDEX_OPT_MBPS, + INDEX_OPT_PPS, + INDEX_OPT_MULTIPLIER, + INDEX_OPT_TOPSPEED, NO_EQUIVALENT }; +#define ONEATATIME_FLAGS (OPTST_DISABLED) + +/* + * Pps_Multi option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zPps_MultiText[] = + "Number of packets to send for each time interval"; +tSCC zPps_Multi_NAME[] = "PPS_MULTI"; +tSCC zPps_Multi_Name[] = "pps-multi"; +#define zPps_MultiDefaultArg ((char const*)1) +static const int + aPps_MultiMustList[] = { + INDEX_OPT_PPS, NO_EQUIVALENT }; +#define PPS_MULTI_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Pid option description: + */ +tSCC zPidText[] = + "Print the PID of tcpreplay at startup"; +tSCC zPid_NAME[] = "PID"; +tSCC zPid_Name[] = "pid"; +#define PID_FLAGS (OPTST_DISABLED) + +/* + * Stats option description: + */ +tSCC zStatsText[] = + "Print statistics every X seconds"; +tSCC zStats_NAME[] = "STATS"; +tSCC zStats_Name[] = "stats"; +#define STATS_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Version option description: + */ +tSCC zVersionText[] = + "Print version information"; +tSCC zVersion_NAME[] = "VERSION"; +tSCC zVersion_Name[] = "version"; +#define VERSION_FLAGS (OPTST_DISABLED) + +/* + * Less_Help option description: + */ +tSCC zLess_HelpText[] = + "Display less usage information and exit"; +tSCC zLess_Help_NAME[] = "LESS_HELP"; +tSCC zLess_Help_Name[] = "less-help"; +#define LESS_HELP_FLAGS (OPTST_DISABLED | OPTST_IMM) + +/* + * Help/More_Help option descriptions: + */ +tSCC zHelpText[] = "Display usage information and exit"; +tSCC zHelp_Name[] = "help"; +tSCC zMore_HelpText[] = "Extended usage information passed thru pager"; +tSCC zMore_Help_Name[] = "more-help"; +tSCC zSave_OptsText[] = "Save the option state to a config file"; +tSCC zSave_Opts_Name[] = "save-opts"; +tSCC zLoad_OptsText[] = "Load options from a config file"; +tSCC zLoad_Opts_NAME[] = "LOAD_OPTS"; +tSCC zNotLoad_Opts_Name[] = "no-load-opts"; +tSCC zNotLoad_Opts_Pfx[] = "no"; +#define zLoad_Opts_Name (zNotLoad_Opts_Name + 3) + + +#ifdef TCPBURST /* 2013-06-06 LiJia add */ +/* + * -m + * Ŵ. + * STREAM_MULTIPLE option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zMultipleText[] = + "[0-255], Replay streams at a given multiple"; +tSCC zMultiple_NAME[] = "Stream-Multiple"; +tSCC zMultiple_Name[] = "stream-multiple"; +#define zMultipleDefaultArg ((char const*)0) +#define MULTIPLE_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * -d + * طŰԭʼ. + * RAW_PKT_DISTANCE option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zDistanceText[] = + "[0-1024], The distance between raw packet and fake replay packet"; +tSCC zDistance_NAME[] = "Packet-Distance"; +tSCC zDistance_Name[] = "packet-distance"; +#define zDistanceDefaultArg ((char const*)0) +#define DISTANCE_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * -D + * طŰײģʽ + * I/O driver mode. + */ +tSCC zdriver_modeText[] = + "[pcap, marsio], default use pcap mode"; +tSCC zdriver_mode_NAME[] = "Driver-Mode"; +tSCC zdriver_mode_Name[] = "driver-mode"; +#define zdriver_modeDefaultArg ((char const*)"pcap") +#define DRIVER_MODE_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + + +/* + * -s + * marsio CPU bind mask + */ +tSCC zcpu_maskText[] = + "marsio CPU bind mask, must HEX pattenr, for example: 0x1 bind current process on CPU ID 0, 0x8 for CPU ID 3"; +tSCC zcpu_mask_NAME[] = "Cpu-Mask"; +tSCC zcpu_mask_Name[] = "cpu-mask"; +#define zcpu_maskDefaultArg ((char const*)"0x02") +#define DCPU_MASK_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + + + +/* + * -e xxx.cfg + * ײװļ, + * ҪõIJ̫, ʹһָһļ, ļָNϸ, + * vxlanײmacַ, ipַ, vxlanڲֶεȵ. + */ +tSCC zencap_maskText[] = + "raw packet encapsulation config file path"; +tSCC zencap_NAME[] = "ENCAPSULATION"; +tSCC zencap_Name[] = "encapsulation"; +#define zencap_DefaultArg ((char const*)0) +#define DENCAP_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +#endif + + + + + +/* + * Declare option callback procedures + */ +#ifdef DEBUG + static tOptProc doOptDbug; +#else /* not DEBUG */ +# define doOptDbug NULL +#endif /* def/not DEBUG */ +#ifdef ENABLE_PCAP_FINDALLDEVS + static tOptProc doOptListnics; +#else /* not ENABLE_PCAP_FINDALLDEVS */ +# define doOptListnics NULL +#endif /* def/not ENABLE_PCAP_FINDALLDEVS */ +extern tOptProc + optionNumericVal, optionPagedUsage; +static tOptProc + doOptLess_Help, doOptLimit, doOptLoop, doOptPid, + doOptPps_Multi, doOptStats, doOptVersion, doUsageOpt; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Define the Tcpreplay Option Descriptions. + */ +static tOptDesc optDesc[ OPTION_CT ] = { + { /* entry idx, value */ 0, VALUE_OPT_DBUG, + /* equiv idx, value */ 0, VALUE_OPT_DBUG, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ DBUG_FLAGS, 0, + /* last opt argumnt */ { zDbugDefaultArg }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptDbug, + /* desc, NAME, name */ zDbugText, zDbug_NAME, zDbug_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 1, VALUE_OPT_QUIET, + /* equiv idx, value */ 1, VALUE_OPT_QUIET, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ QUIET_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zQuietText, zQuiet_NAME, zQuiet_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 2, VALUE_OPT_TIMER, + /* equiv idx, value */ 2, VALUE_OPT_TIMER, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ TIMER_FLAGS, 0, + /* last opt argumnt */ { zTimerDefaultArg }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zTimerText, zTimer_NAME, zTimer_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 3, VALUE_OPT_SLEEP_ACCEL, + /* equiv idx, value */ 3, VALUE_OPT_SLEEP_ACCEL, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ SLEEP_ACCEL_FLAGS, 0, + /* last opt argumnt */ { zSleep_AccelDefaultArg }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionNumericVal, + /* desc, NAME, name */ zSleep_AccelText, zSleep_Accel_NAME, zSleep_Accel_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 4, VALUE_OPT_RDTSC_CLICKS, + /* equiv idx, value */ 4, VALUE_OPT_RDTSC_CLICKS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ RDTSC_CLICKS_FLAGS, 0, + /* last opt argumnt */ { zRdtsc_ClicksDefaultArg }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionNumericVal, + /* desc, NAME, name */ zRdtsc_ClicksText, zRdtsc_Clicks_NAME, zRdtsc_Clicks_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 5, VALUE_OPT_VERBOSE, + /* equiv idx, value */ 5, VALUE_OPT_VERBOSE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ VERBOSE_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zVerboseText, zVerbose_NAME, zVerbose_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 6, VALUE_OPT_DECODE, + /* equiv idx, value */ 6, VALUE_OPT_DECODE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ DECODE_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aDecodeMustList, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zDecodeText, zDecode_NAME, zDecode_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 7, VALUE_OPT_ENABLE_FILE_CACHE, + /* equiv idx, value */ 7, VALUE_OPT_ENABLE_FILE_CACHE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ ENABLE_FILE_CACHE_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aEnable_File_CacheMustList, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zEnable_File_CacheText, zEnable_File_Cache_NAME, zEnable_File_Cache_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 8, VALUE_OPT_PRELOAD_PCAP, + /* equiv idx, value */ 8, VALUE_OPT_PRELOAD_PCAP, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ PRELOAD_PCAP_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zPreload_PcapText, zPreload_Pcap_NAME, zPreload_Pcap_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 9, VALUE_OPT_CACHEFILE, + /* equiv idx, value */ 9, VALUE_OPT_CACHEFILE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ CACHEFILE_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zCachefileText, zCachefile_NAME, zCachefile_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 10, VALUE_OPT_INTF1, + /* equiv idx, value */ 10, VALUE_OPT_INTF1, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 1, 1, 0, + /* opt state flags */ INTF1_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zIntf1Text, zIntf1_NAME, zIntf1_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 11, VALUE_OPT_INTF2, + /* equiv idx, value */ 11, VALUE_OPT_INTF2, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ INTF2_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aIntf2MustList, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zIntf2Text, zIntf2_NAME, zIntf2_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 12, VALUE_OPT_LISTNICS, + /* equiv idx, value */ 12, VALUE_OPT_LISTNICS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ LISTNICS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptListnics, + /* desc, NAME, name */ zListnicsText, zListnics_NAME, zListnics_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 13, VALUE_OPT_LOOP, + /* equiv idx, value */ 13, VALUE_OPT_LOOP, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ LOOP_FLAGS, 0, + /* last opt argumnt */ { zLoopDefaultArg }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptLoop, + /* desc, NAME, name */ zLoopText, zLoop_NAME, zLoop_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 14, VALUE_OPT_PKTLEN, + /* equiv idx, value */ 14, VALUE_OPT_PKTLEN, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ PKTLEN_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zPktlenText, zPktlen_NAME, zPktlen_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 15, VALUE_OPT_LIMIT, + /* equiv idx, value */ 15, VALUE_OPT_LIMIT, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ LIMIT_FLAGS, 0, + /* last opt argumnt */ { zLimitDefaultArg }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptLimit, + /* desc, NAME, name */ zLimitText, zLimit_NAME, zLimit_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 16, VALUE_OPT_MULTIPLIER, + /* equiv idx, value */ 16, VALUE_OPT_MULTIPLIER, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ MULTIPLIER_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aMultiplierCantList, + /* option proc */ NULL, + /* desc, NAME, name */ zMultiplierText, zMultiplier_NAME, zMultiplier_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 17, VALUE_OPT_PPS, + /* equiv idx, value */ 17, VALUE_OPT_PPS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ PPS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aPpsCantList, + /* option proc */ optionNumericVal, + /* desc, NAME, name */ zPpsText, zPps_NAME, zPps_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 18, VALUE_OPT_MBPS, + /* equiv idx, value */ 18, VALUE_OPT_MBPS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ MBPS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aMbpsCantList, + /* option proc */ NULL, + /* desc, NAME, name */ zMbpsText, zMbps_NAME, zMbps_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 19, VALUE_OPT_TOPSPEED, + /* equiv idx, value */ 19, VALUE_OPT_TOPSPEED, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ TOPSPEED_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aTopspeedCantList, + /* option proc */ NULL, + /* desc, NAME, name */ zTopspeedText, zTopspeed_NAME, zTopspeed_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 20, VALUE_OPT_ONEATATIME, + /* equiv idx, value */ 20, VALUE_OPT_ONEATATIME, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ ONEATATIME_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aOneatatimeCantList, + /* option proc */ NULL, + /* desc, NAME, name */ zOneatatimeText, zOneatatime_NAME, zOneatatime_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 21, VALUE_OPT_PPS_MULTI, + /* equiv idx, value */ 21, VALUE_OPT_PPS_MULTI, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ PPS_MULTI_FLAGS, 0, + /* last opt argumnt */ { zPps_MultiDefaultArg }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aPps_MultiMustList, NULL, + /* option proc */ doOptPps_Multi, + /* desc, NAME, name */ zPps_MultiText, zPps_Multi_NAME, zPps_Multi_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 22, VALUE_OPT_PID, + /* equiv idx, value */ 22, VALUE_OPT_PID, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ PID_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptPid, + /* desc, NAME, name */ zPidText, zPid_NAME, zPid_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 23, VALUE_OPT_STATS, + /* equiv idx, value */ 23, VALUE_OPT_STATS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ STATS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptStats, + /* desc, NAME, name */ zStatsText, zStats_NAME, zStats_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 24, VALUE_OPT_VERSION, + /* equiv idx, value */ 24, VALUE_OPT_VERSION, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ VERSION_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptVersion, + /* desc, NAME, name */ zVersionText, zVersion_NAME, zVersion_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 25, VALUE_OPT_LESS_HELP, + /* equiv idx, value */ 25, VALUE_OPT_LESS_HELP, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ LESS_HELP_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptLess_Help, + /* desc, NAME, name */ zLess_HelpText, zLess_Help_NAME, zLess_Help_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doUsageOpt, + /* desc, NAME, name */ zHelpText, NULL, zHelp_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionPagedUsage, + /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) + | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, NOLIMIT, 0, + /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) + | OPTST_DISABLE_IMM, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionLoadOpt, + /* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name, + /* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx }, + +#ifdef TCPBURST + /* tcpburst */ + { /* entry idx, value */ 30, VALUE_OPT_MULTIPLE, + /* equiv idx, value */ 30, VALUE_OPT_MULTIPLE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ MULTIPLE_FLAGS, 0, + /* last opt argumnt */ { zMultipleDefaultArg }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionNumericVal, + /* desc, NAME, name */ zMultipleText, zMultiple_NAME, zMultiple_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 31, VALUE_OPT_DISTANCE, + /* equiv idx, value */ 31, VALUE_OPT_DISTANCE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ DISTANCE_FLAGS, 0, + /* last opt argumnt */ { zDistanceDefaultArg }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionNumericVal, + /* desc, NAME, name */ zDistanceText, zDistance_NAME, zDistance_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 32, VALUE_OPT_DRIVER_MODE, + /* equiv idx, value */ 32, VALUE_OPT_DRIVER_MODE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ DRIVER_MODE_FLAGS, 0, + /* last opt argumnt */ { zdriver_modeDefaultArg }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zdriver_modeText, zdriver_mode_NAME, zdriver_mode_Name, + /* disablement strs */ NULL, NULL }, + + + { /* entry idx, value */ 33, VALUE_OPT_CPU_MASK, + /* equiv idx, value */ 33, VALUE_OPT_CPU_MASK, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ DCPU_MASK_FLAGS, 0, + /* last opt argumnt */ { zcpu_maskDefaultArg }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zcpu_maskText, zcpu_mask_NAME, zcpu_mask_Name, + /* disablement strs */ NULL, NULL }, + + + { /* entry idx, value */ 34, VALUE_OPT_ENCAP, + /* equiv idx, value */ 34, VALUE_OPT_ENCAP, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ DENCAP_FLAGS, 0, + /* last opt argumnt */ { zencap_DefaultArg }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zencap_maskText, zencap_NAME, zencap_Name, + /* disablement strs */ NULL, NULL }, + + +#endif + +}; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Define the Tcpreplay Option Environment + */ +tSCC zPROGNAME[] = "TCPREPLAY"; +tSCC zUsageTitle[] = +"tcpreplay (tcpreplay) - Replay network traffic stored in pcap files\n\ +USAGE: %s [ - [] | --[{=| }] ]... \n"; +tSCC zRcName[] = ".tcpreplayrc"; +tSCC* apzHomeList[] = { + "$$/", + NULL }; + +#define zBugsAddr NULL +tSCC zExplain[] = "\n\ +tcpreplay is a tool for replaying network traffic from files saved with\n\ +tcpdump or other tools which write pcap(3) files.\n"; +tSCC zDetail[] = "\n\ +The basic operation of tcpreplay is to resend all packets from the\n\ +input file(s) at the speed at which they were recorded, or a specified \n\ +data rate, up to as fast as the hardware is capable.\n\n\ +Optionally, the traffic can be split between two interfaces, written to\n\ +files, filtered and edited in various ways, providing the means to test\n\ +firewalls, NIDS and other network devices.\n\n\ +For more details, please see the Tcpreplay Manual at:\n\ +http://tcpreplay.synfin.net/trac/wiki/manual\n"; +#define zFullVersion NULL +/* extracted from /usr/local/share/autogen/optcode.tpl near line 501 */ + +#if defined(ENABLE_NLS) +# define OPTPROC_BASE OPTPROC_TRANSLATE + static tOptionXlateProc translate_option_strings; +#else +# define OPTPROC_BASE OPTPROC_NONE +# define translate_option_strings NULL +#endif /* ENABLE_NLS */ + + +#define tcpreplay_full_usage NULL +#define tcpreplay_short_usage NULL +tOptions tcpreplayOptions = { + OPTIONS_STRUCT_VERSION, + 0, NULL, /* original argc + argv */ + ( OPTPROC_BASE + + OPTPROC_ERRSTOP + + OPTPROC_SHORTOPT + + OPTPROC_LONGOPT + + OPTPROC_NO_REQ_OPT + + OPTPROC_ARGS_REQ + + OPTPROC_GNUUSAGE ), + 0, NULL, /* current option index, current option */ + NULL, NULL, zPROGNAME, + zRcName, zCopyright, zCopyrightNotice, + zFullVersion, apzHomeList, zUsageTitle, + zExplain, zDetail, optDesc, + zBugsAddr, /* address to send bugs to */ + NULL, NULL, /* extensions/saved state */ + optionUsage, /* usage procedure */ + translate_option_strings, /* translation procedure */ + /* + * Indexes to special options + */ + { INDEX_OPT_MORE_HELP, /* more-help option index */ + INDEX_OPT_SAVE_OPTS, /* save option index */ + NO_EQUIVALENT, /* '-#' option index */ + NO_EQUIVALENT /* index of default opt */ + }, +#ifdef TCPBURST + 35, +#else + 30 /* full option count */, +#endif + 26 /* user option count */, + tcpreplay_full_usage, tcpreplay_short_usage, + NULL, NULL +}; + +/* + * Create the static procedure(s) declared above. + */ +static void +doUsageOpt( + tOptions* pOptions, + tOptDesc* pOptDesc ) +{ + (void)pOptions; + USAGE( EXIT_SUCCESS ); +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the dbug option, when DEBUG is #define-d. + */ +#ifdef DEBUG +static void +doOptDbug(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 0, 5 } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} +#endif /* defined DEBUG */ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the listnics option, when ENABLE_PCAP_FINDALLDEVS is #define-d. + */ +#ifdef ENABLE_PCAP_FINDALLDEVS +static void +doOptListnics(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcpreplay_opts.def, line 267 */ + + interface_list_t *list = get_interface_list(); + list_interfaces(list); + free(list); + exit(0); + +} +#endif /* defined ENABLE_PCAP_FINDALLDEVS */ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the loop option. + */ +static void +doOptLoop(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 0, LONG_MAX } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the limit option. + */ +static void +doOptLimit(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 1, LONG_MAX } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the pps-multi option. + */ +static void +doOptPps_Multi(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 1, LONG_MAX } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the pid option. + */ +static void +doOptPid(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcpreplay_opts.def, line 417 */ + +fprintf(stderr, "PID: %hu\n", getpid()); + +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the stats option. + */ +static void +doOptStats(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 1, LONG_MAX } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the version option. + */ +static void +doOptVersion(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcpreplay_opts.def, line 440 */ + + fprintf(stderr, "tcpreplay version: %s (build %s)", VERSION, svn_version()); +#ifdef DEBUG + fprintf(stderr, " (debug)"); +#endif + fprintf(stderr, "\n"); + fprintf(stderr, "Copyright 2000-2010 by Aaron Turner \n"); + fprintf(stderr, "Cache file supported: %s\n", CACHEVERSION); +#ifdef HAVE_LIBDNET + fprintf(stderr, "Compiled against libdnet: %s\n", LIBDNET_VERSION); +#else + fprintf(stderr, "Not compiled with libdnet.\n"); +#endif +#ifdef HAVE_WINPCAP + fprintf(stderr, "Compiled against winpcap: %s\n", get_pcap_version()); +#else + fprintf(stderr, "Compiled against libpcap: %s\n", get_pcap_version()); +#endif +#ifdef ENABLE_64BITS + fprintf(stderr, "64 bit packet counters: enabled\n"); +#else + fprintf(stderr, "64 bit packet counters: disabled\n"); +#endif +#ifdef ENABLE_VERBOSE + fprintf(stderr, "Verbose printing via tcpdump: enabled\n"); +#else + fprintf(stderr, "Verbose printing via tcpdump: disabled\n"); +#endif +#ifdef TCPREPLAY_EDIT + fprintf(stderr, "Packet editing: enabled\n"); +#else + fprintf(stderr, "Packet editing: disabled\n"); +#endif +#ifdef ENABLE_FRAGROUTE + fprintf(stderr, "Fragroute engine: enabled\n"); +#else + fprintf(stderr, "Fragroute engine: disabled\n"); +#endif + fprintf(stderr, "Injection method: %s\n", sendpacket_get_method()); + exit(0); + +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the less-help option. + */ +static void +doOptLess_Help(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcpreplay_opts.def, line 491 */ + + USAGE(EXIT_FAILURE); + +} +/* extracted from /usr/local/share/autogen/optcode.tpl near line 633 */ + +#if ENABLE_NLS +#include +#include +#include +#include +#include + +static char* AO_gettext( char const* pz ); +static void coerce_it(void** s); + +static char* +AO_gettext( char const* pz ) +{ + char* pzRes; + if (pz == NULL) + return NULL; + pzRes = _(pz); + if (pzRes == pz) + return pzRes; + pzRes = strdup( pzRes ); + if (pzRes == NULL) { + fputs( _("No memory for duping translated strings\n"), stderr ); + exit( EXIT_FAILURE ); + } + return pzRes; +} + +static void coerce_it(void** s) { *s = AO_gettext(*s); } +#define COERSION(_f) \ + coerce_it((void*)&(tcpreplayOptions._f)) + +/* + * This invokes the translation code (e.g. gettext(3)). + */ +static void +translate_option_strings( void ) +{ + /* + * Guard against re-translation. It won't work. The strings will have + * been changed by the first pass through this code. One shot only. + */ + if (option_usage_text.field_ct != 0) { + + /* + * Do the translations. The first pointer follows the field count + * field. The field count field is the size of a pointer. + */ + tOptDesc* pOD = tcpreplayOptions.pOptDesc; + char** ppz = (char**)(void*)&(option_usage_text); + int ix = option_usage_text.field_ct; + + do { + ppz++; + *ppz = AO_gettext(*ppz); + } while (--ix > 0); + + COERSION(pzCopyright); + COERSION(pzCopyNotice); + COERSION(pzFullVersion); + COERSION(pzUsageTitle); + COERSION(pzExplain); + COERSION(pzDetail); + option_usage_text.field_ct = 0; + + for (ix = tcpreplayOptions.optCt; ix > 0; ix--, pOD++) + coerce_it((void*)&(pOD->pzText)); + } + + if ((tcpreplayOptions.fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) { + tOptDesc* pOD = tcpreplayOptions.pOptDesc; + int ix; + + for (ix = tcpreplayOptions.optCt; ix > 0; ix--, pOD++) { + coerce_it((void*)&(pOD->pz_Name)); + coerce_it((void*)&(pOD->pz_DisableName)); + coerce_it((void*)&(pOD->pz_DisablePfx)); + } + /* prevent re-translation */ + tcpreplayOptions.fOptSet |= OPTPROC_NXLAT_OPT_CFG | OPTPROC_NXLAT_OPT; + } +} + +#endif /* ENABLE_NLS */ + +#ifdef __cplusplus +} +#endif +/* tcpreplay_opts.c ends here */ diff --git a/src/tcpreplay_opts.def b/src/tcpreplay_opts.def new file mode 100644 index 0000000..55a1bfd --- /dev/null +++ b/src/tcpreplay_opts.def @@ -0,0 +1,496 @@ +autogen definitions options; + + +copyright = { + date = "2000-2010"; + owner = "Aaron Turner"; + type = "bsd"; + author = <<- EOText +Copyright 2000-2010 Aaron Turner + +For support please use the tcpreplay-users@lists.sourceforge.net mailing list. + +The latest version of this software is always available from: +http://tcpreplay.synfin.net/ +EOText; +}; + +package = "tcpreplay"; +prog-name = "tcpreplay"; +prog-title = "Replay network traffic stored in pcap files"; +long-opts; +gnu-usage; +help-value = "H"; +save-opts-value = ""; +load-opts-value = ""; +argument = ""; + + +config-header = "config.h"; + +include = "#include \"defines.h\"\n" + "#include \"tcpreplay.h\"\n" + "#include \"common.h\"\n" + "#include \"config.h\"\n" + "#include \n" + "#include \n" + "#include \n" + "extern tcpreplay_opt_t options;\n"; + +homerc = "$$/"; + +#ifdef TCPREPLAY_EDIT +#include tcpedit/tcpedit_opts.def +#endif + +explain = <<- EOExplain +tcpreplay is a tool for replaying network traffic from files saved with +tcpdump or other tools which write pcap(3) files. +EOExplain; + +detail = <<- EODetail +The basic operation of tcpreplay is to resend all packets from the +input file(s) at the speed at which they were recorded, or a specified +data rate, up to as fast as the hardware is capable. + +Optionally, the traffic can be split between two interfaces, written to +files, filtered and edited in various ways, providing the means to test +firewalls, NIDS and other network devices. + +For more details, please see the Tcpreplay Manual at: +http://tcpreplay.synfin.net/trac/wiki/manual +EODetail; + +man-doc = <<- EOMan +.SH "SIGNALS" +tcpreplay understands the following signals: +@enumerate +@item @var{SIGUSR1} +Suspend tcpreplay +@item @var{SIGCONT} +Restart tcpreplay +@end enumerate + +.SH "SEE ALSO" +tcpreplay-edit(1), tcpdump(1), tcpprep(1), tcprewrite(1), libnet(3) + +.SH "BUGS" +tcpreplay can only send packets as fast as your computer's interface, +processor, disk and system bus will allow. + +Packet timing at high speeds is a black art and very OS/CPU dependent. + +Replaying captured traffic may simulate odd or broken conditions on your +network and cause all sorts of problems. + +In most cases, you can not replay traffic back to/at a server. + +Some operating systems by default do not allow for forging source MAC +addresses. Please consult your operating system's documentation and the +tcpreplay FAQ if you experience this issue. +EOMan; + + +flag = { + ifdef = DEBUG; + name = dbug; + value = d; + arg-type = number; + max = 1; + immediate; + arg-range = "0->5"; + arg-default = 0; + descrip = "Enable debugging output"; + doc = <<- EOText +If configured with --enable-debug, then you can specify a verbosity +level for debugging output. Higher numbers increase verbosity. +EOText; +}; + +flag = { + name = quiet; + value = q; + descrip = "Quiet mode"; + doc = "Print nothing except the statistics at the end of the run"; +}; + +flag = { + name = timer; + value = T; + arg-default = "gtod"; + max = 1; + arg-type = string; + descrip = "Select packet timing mode: select, ioport, rdtsc, gtod, nano, abstime"; + doc = <<- EOText +Allows you to select the packet timing method to use: +@enumerate +@item nano +- Use nanosleep() API +@item select +- Use select() API +@item ioport +- Write to the i386 IO Port 0x80 +@item rdtsc +- Use the x86/x86_64/PPC RDTSC +@item gtod [default] +- Use a gettimeofday() loop +@item abstime +- Use OS X's AbsoluteTime API +@end enumerate + +EOText; +}; + +flag = { + name = sleep-accel; + arg-type = number; + arg-default = 0; + descrip = "Reduce the amount of time to sleep by specified usec"; + doc = <<- EOText +Reduce the amount of time we would normally sleep between two packets by the +specified number of usec. This provides a "fuzz factor" to compensate for +running on a non-RTOS and other processes using CPU time. Default is disabled. +EOText; +}; + +flag = { + name = rdtsc-clicks; + max = 1; + arg-type = number; + arg-default = 0; + descrip = "Specify the RDTSC clicks/usec"; + doc = <<- EOText +Override the calculated number of RDTSC clicks/usec which is often the speed of the +CPU in Mhz. Only useful if you specified @var{--timer=rdtsc} +EOText; +}; + +/* Verbose decoding via tcpdump */ +flag = { + ifdef = ENABLE_VERBOSE; + name = verbose; + value = v; + max = 1; + immediate; + descrip = "Print decoded packets via tcpdump to STDOUT"; + settable; + doc = ""; +}; + +flag = { + ifdef = ENABLE_VERBOSE; + name = decode; + flags-must = verbose; + value = A; + arg-type = string; + max = 1; + descrip = "Arguments passed to tcpdump decoder"; + doc = <<- EOText +When enabling verbose mode (@var{-v}) you may also specify one or more +additional arguments to pass to @code{tcpdump} to modify the way packets +are decoded. By default, -n and -l are used. Be sure to +quote the arguments like: -A "-axxx" so that they are not interpreted +by tcpreplay. Please see the tcpdump(1) man page for a complete list of +options. +EOText; +}; + +/* Cache files to internal memory */ +flag = { + name = enable_file_cache; + value = K; + flags-must = loop; + descrip = "Enable caching of packets to internal memory"; + doc = <<- EOText +Cache pcap file(s) the first time they are cached in RAM so that subsequent +loops don't incurr any disk I/O latency in order to increase performance. Make +sure you have enough free RAM to store the entire pcap file(s) in memory or the +system will swap and performance will suffer. +EOText; +}; + +flag = { + name = preload_pcap; + descrip = "Preloads packets into RAM before sending"; + doc = <<- EOText +This option loads the specified pcap(s) into RAM before starting to send in order +to improve replay performance while introducing a startup performance hit. +Preloading can be used with or without @var{--loop} and implies +@var{--enable-file-cache}. +EOText; +}; + +/* + * Output modifiers: -c + */ + +flag = { + name = cachefile; + value = c; + arg-type = string; + max = 1; + descrip = "Split traffic via a tcpprep cache file"; + doc = ""; +}; + +/* + * Outputs: -i, -I + */ + +flag = { + name = intf1; + value = i; + arg-type = string; + max = 1; + must-set; + descrip = "Server/primary traffic output interface"; + doc = ""; +}; + +flag = { + name = intf2; + value = I; + arg-type = string; + max = 1; + flags-must = cachefile; + descrip = "Client/secondary traffic output interface"; + doc = ""; +}; + +flag = { + ifdef = ENABLE_PCAP_FINDALLDEVS; + name = listnics; + descrip = "List available network interfaces and exit"; + immediate; + doc = ""; + flag-code = <<- EOFlag + + interface_list_t *list = get_interface_list(); + list_interfaces(list); + free(list); + exit(0); + +EOFlag; +}; + +/* + * Limits and loops: -l + */ + +flag = { + name = loop; + value = l; + arg-type = number; + arg-range = "0->"; + max = 1; + descrip = "Loop through the capture file X times"; + arg-default = 1; + doc = ""; +}; + +flag = { + name = pktlen; + max = 1; + descrip = "Override the snaplen and use the actual packet len"; + doc = <<- EOText +By default, tcpreplay will send packets based on the size of the "snaplen" +stored in the pcap file which is usually the correct thing to do. However, +occasionally, tools will store more bytes then told to. By specifying this +option, tcpreplay will ignore the snaplen field and instead try to send +packets based on the original packet length. Bad things may happen if +you specify this option. +EOText; +}; + +flag = { + name = limit; + value = L; + arg-type = number; + max = 1; + arg-default = -1; + arg-range = "1->"; + descrip = "Limit the number of packets to send"; + doc = <<- EOText +By default, tcpreplay will send all the packets. Alternatively, you can +specify a maximum number of packets to send. +EOText; +}; + +/* + * Replay speed modifiers: -m, -p, -r, -R, -o + */ + +/* note that this is really a float, but autoopts does not support float */ +flag = { + name = multiplier; + flags-cant = pps; + flags-cant = mbps; + flags-cant = oneatatime; + flags-cant = topspeed; + value = x; + arg-type = string; + max = 1; + descrip = "Modify replay speed to a given multiple"; + doc = <<- EOText +Specify a floating point value to modify the packet replay speed. +Examples: +@example + 2.0 will replay traffic at twice the speed captured + 0.7 will replay traffic at 70% the speed captured +@end example +EOText; +}; + +flag = { + name = pps; + flags-cant = multiplier; + flags-cant = mbps; + flags-cant = oneatatime; + flags-cant = topspeed; + value = p; + arg-type = number; + max = 1; + descrip = "Replay packets at a given packets/sec"; + doc = ""; +}; + +flag = { + name = mbps; + flags-cant = multiplier; + flags-cant = pps; + flags-cant = oneatatime; + flags-cant = topspeed; + value = M; + arg-type = string; + max = 1; + descrip = "Replay packets at a given Mbps"; + doc = <<- EOText +Specify a floating point value for the Mbps rate that tcpreplay +should send packets at. +EOText; +}; + +flag = { + name = topspeed; + flags-cant = mbps; + flags-cant = multiplier; + flags-cant = pps; + flags-cant = oneatatime; + value = t; + descrip = "Replay packets as fast as possible"; + doc = ""; +}; + +flag = { + name = oneatatime; + flags-cant = mbps; + flags-cant = pps; + flags-cant = multiplier; + flags-cant = topspeed; + value = o; + descrip = "Replay one packet at a time for each user input"; + doc = <<- EOText +Allows you to step through one or more packets at a time. +EOText; +}; + +flag = { + name = pps-multi; + arg-type = number; + flags-must = pps; + arg-default = 1; + arg-range = "1->"; + descrip = "Number of packets to send for each time interval"; + doc = <<- EOText +When trying to send packets at very high rates, the time between each packet +can be so short that it is impossible to accurately sleep for the required +period of time. This option allows you to send multiple packets at a time, +thus allowing for longer sleep times which can be more accurately implemented. +EOText; +}; + +flag = { + name = pid; + value = P; + descrip = "Print the PID of tcpreplay at startup"; + flag-code = <<- EOPid + +fprintf(stderr, "PID: %hu\n", getpid()); + +EOPid; + doc = ""; +}; + +flag = { + name = stats; + arg-type = number; + arg-range = "1->"; + descrip = "Print statistics every X seconds"; + doc = <<- EOText +Note that this is very much a "best effort" and long delays between +sending packets may cause equally long delays between printing statistics. +EOText; +}; + +flag = { + name = version; + value = V; + descrip = "Print version information"; + flag-code = <<- EOVersion + + fprintf(stderr, "tcpreplay version: %s (build %s)", VERSION, svn_version()); +#ifdef DEBUG + fprintf(stderr, " (debug)"); +#endif + fprintf(stderr, "\n"); + fprintf(stderr, "Copyright 2000-2010 by Aaron Turner \n"); + fprintf(stderr, "Cache file supported: %s\n", CACHEVERSION); +#ifdef HAVE_LIBDNET + fprintf(stderr, "Compiled against libdnet: %s\n", LIBDNET_VERSION); +#else + fprintf(stderr, "Not compiled with libdnet.\n"); +#endif +#ifdef HAVE_WINPCAP + fprintf(stderr, "Compiled against winpcap: %s\n", get_pcap_version()); +#else + fprintf(stderr, "Compiled against libpcap: %s\n", get_pcap_version()); +#endif +#ifdef ENABLE_64BITS + fprintf(stderr, "64 bit packet counters: enabled\n"); +#else + fprintf(stderr, "64 bit packet counters: disabled\n"); +#endif +#ifdef ENABLE_VERBOSE + fprintf(stderr, "Verbose printing via tcpdump: enabled\n"); +#else + fprintf(stderr, "Verbose printing via tcpdump: disabled\n"); +#endif +#ifdef TCPREPLAY_EDIT + fprintf(stderr, "Packet editing: enabled\n"); +#else + fprintf(stderr, "Packet editing: disabled\n"); +#endif +#ifdef ENABLE_FRAGROUTE + fprintf(stderr, "Fragroute engine: enabled\n"); +#else + fprintf(stderr, "Fragroute engine: disabled\n"); +#endif + fprintf(stderr, "Injection method: %s\n", sendpacket_get_method()); + exit(0); + +EOVersion; + doc = ""; +}; + +flag = { + name = less-help; + value = "h"; + immediate; + descrip = "Display less usage information and exit"; + flag-code = <<- EOHelp + + USAGE(EXIT_FAILURE); + +EOHelp; + doc = ""; +}; diff --git a/src/tcpreplay_opts.h b/src/tcpreplay_opts.h new file mode 100644 index 0000000..8607a23 --- /dev/null +++ b/src/tcpreplay_opts.h @@ -0,0 +1,286 @@ +/* -*- buffer-read-only: t -*- vi: set ro: + * + * DO NOT EDIT THIS FILE (tcpreplay_opts.h) + * + * It has been AutoGen-ed April 4, 2010 at 05:59:18 PM by AutoGen 5.9.9 + * From the definitions tcpreplay_opts.def + * and the template file options + * + * Generated from AutoOpts 32:2:7 templates. + */ + +/* + * This file was produced by an AutoOpts template. AutoOpts is a + * copyrighted work. This header file is not encumbered by AutoOpts + * licensing, but is provided under the licensing terms chosen by the + * tcpreplay author or copyright holder. AutoOpts is licensed under + * the terms of the LGPL. The redistributable library (``libopts'') is + * licensed under the terms of either the LGPL or, at the users discretion, + * the BSD license. See the AutoOpts and/or libopts sources for details. + * + * This source file is copyrighted and licensed under the following terms: + * + * tcpreplay copyright (c) 2000-2010 Aaron Turner - all rights reserved + * + * tcpreplay is free software copyrighted by Aaron Turner. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name ``Aaron Turner'' nor the name of any other + * contributor may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * tcpreplay IS PROVIDED BY Aaron Turner ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL Aaron Turner OR ANY OTHER CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/* + * This file contains the programmatic interface to the Automated + * Options generated for the tcpreplay program. + * These macros are documented in the AutoGen info file in the + * "AutoOpts" chapter. Please refer to that doc for usage help. + */ +#ifndef AUTOOPTS_TCPREPLAY_OPTS_H_GUARD +#define AUTOOPTS_TCPREPLAY_OPTS_H_GUARD 1 +#include "config.h" +#include + +/* + * Ensure that the library used for compiling this generated header is at + * least as new as the version current when the header template was released + * (not counting patch version increments). Also ensure that the oldest + * tolerable version is at least as old as what was current when the header + * template was released. + */ +#define AO_TEMPLATE_VERSION 131074 +#if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \ + || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION) +# error option template version mismatches autoopts/options.h header + Choke Me. +#endif + +/* + * Enumeration of each option: + */ +typedef enum { + INDEX_OPT_DBUG = 0, + INDEX_OPT_QUIET = 1, + INDEX_OPT_TIMER = 2, + INDEX_OPT_SLEEP_ACCEL = 3, + INDEX_OPT_RDTSC_CLICKS = 4, + INDEX_OPT_VERBOSE = 5, + INDEX_OPT_DECODE = 6, + INDEX_OPT_ENABLE_FILE_CACHE = 7, + INDEX_OPT_PRELOAD_PCAP = 8, + INDEX_OPT_CACHEFILE = 9, + INDEX_OPT_INTF1 = 10, + INDEX_OPT_INTF2 = 11, + INDEX_OPT_LISTNICS = 12, + INDEX_OPT_LOOP = 13, + INDEX_OPT_PKTLEN = 14, + INDEX_OPT_LIMIT = 15, + INDEX_OPT_MULTIPLIER = 16, + INDEX_OPT_PPS = 17, + INDEX_OPT_MBPS = 18, + INDEX_OPT_TOPSPEED = 19, + INDEX_OPT_ONEATATIME = 20, + INDEX_OPT_PPS_MULTI = 21, + INDEX_OPT_PID = 22, + INDEX_OPT_STATS = 23, + INDEX_OPT_VERSION = 24, + INDEX_OPT_LESS_HELP = 25, + INDEX_OPT_HELP = 26, + INDEX_OPT_MORE_HELP = 27, + INDEX_OPT_SAVE_OPTS = 28, + INDEX_OPT_LOAD_OPTS = 29, +#ifdef TCPBURST + INDEX_OPT_MULTIPLE = 30, + INDEX_OPT_DISTANCE = 31, + INDEX_OPT_DRIVER_MODE = 32, + INDEX_OPT_CPU_MASK = 33, + INDEX_OPT_ENCAP = 34, +#endif +} teOptIndex; + +#ifdef TCPBURST + #define OPTION_CT 35 /* ѡ, -m, -d, -D, -s, -e */ +#else + #define OPTION_CT 30 +#endif + +/* + * Interface defines for all options. Replace "n" with the UPPER_CASED + * option name (as in the teOptIndex enumeration above). + * e.g. HAVE_OPT( DBUG ) + */ +#define DESC(n) (tcpreplayOptions.pOptDesc[INDEX_OPT_## n]) +#define HAVE_OPT(n) (! UNUSED_OPT(& DESC(n))) +#define OPT_ARG(n) (DESC(n).optArg.argString) +#define STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK) +#define COUNT_OPT(n) (DESC(n).optOccCt) +#define ISSEL_OPT(n) (SELECTED_OPT(&DESC(n))) +#define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n))) +#define ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n))) +#define STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt) +#define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs) +#define CLEAR_OPT(n) STMTS( \ + DESC(n).fOptState &= OPTST_PERSISTENT_MASK; \ + if ( (DESC(n).fOptState & OPTST_INITENABLED) == 0) \ + DESC(n).fOptState |= OPTST_DISABLED; \ + DESC(n).optCookie = NULL ) + +/* * * * * * + * + * Interface defines for specific options. + */ +#ifdef DEBUG +#define VALUE_OPT_DBUG 'd' +#define OPT_VALUE_DBUG (DESC(DBUG).optArg.argInt) +#endif /* DEBUG */ +#define VALUE_OPT_QUIET 'q' +#define VALUE_OPT_TIMER 'T' +#define VALUE_OPT_SLEEP_ACCEL 3 +#define OPT_VALUE_SLEEP_ACCEL (DESC(SLEEP_ACCEL).optArg.argInt) +#define VALUE_OPT_RDTSC_CLICKS 4 +#define OPT_VALUE_RDTSC_CLICKS (DESC(RDTSC_CLICKS).optArg.argInt) +#ifdef ENABLE_VERBOSE +#define VALUE_OPT_VERBOSE 'v' +#define SET_OPT_VERBOSE STMTS( \ + DESC(VERBOSE).optActualIndex = 5; \ + DESC(VERBOSE).optActualValue = VALUE_OPT_VERBOSE; \ + DESC(VERBOSE).fOptState &= OPTST_PERSISTENT_MASK; \ + DESC(VERBOSE).fOptState |= OPTST_SET ) +#endif /* ENABLE_VERBOSE */ +#ifdef ENABLE_VERBOSE +#define VALUE_OPT_DECODE 'A' +#endif /* ENABLE_VERBOSE */ +#define VALUE_OPT_ENABLE_FILE_CACHE 'K' +#define VALUE_OPT_PRELOAD_PCAP 8 +#define VALUE_OPT_CACHEFILE 'c' +#define VALUE_OPT_INTF1 'i' +#define VALUE_OPT_INTF2 'I' +#ifdef ENABLE_PCAP_FINDALLDEVS +#define VALUE_OPT_LISTNICS 12 +#endif /* ENABLE_PCAP_FINDALLDEVS */ +#define VALUE_OPT_LOOP 'l' +#define OPT_VALUE_LOOP (DESC(LOOP).optArg.argInt) +#define VALUE_OPT_PKTLEN 14 +#define VALUE_OPT_LIMIT 'L' +#define OPT_VALUE_LIMIT (DESC(LIMIT).optArg.argInt) +#define VALUE_OPT_MULTIPLIER 'x' +#define VALUE_OPT_PPS 'p' +#define OPT_VALUE_PPS (DESC(PPS).optArg.argInt) +#define VALUE_OPT_MBPS 'M' +#define VALUE_OPT_TOPSPEED 't' +#define VALUE_OPT_ONEATATIME 'o' +#define VALUE_OPT_PPS_MULTI 21 +#define OPT_VALUE_PPS_MULTI (DESC(PPS_MULTI).optArg.argInt) +#define VALUE_OPT_PID 'P' +#define VALUE_OPT_STATS 23 +#define OPT_VALUE_STATS (DESC(STATS).optArg.argInt) +#define VALUE_OPT_VERSION 'V' +#define VALUE_OPT_LESS_HELP 'h' +#define VALUE_OPT_HELP 'H' +#define VALUE_OPT_MORE_HELP '!' +#define VALUE_OPT_SAVE_OPTS INDEX_OPT_SAVE_OPTS +#define VALUE_OPT_LOAD_OPTS INDEX_OPT_LOAD_OPTS +#define SET_OPT_SAVE_OPTS(a) STMTS( \ + DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \ + DESC(SAVE_OPTS).fOptState |= OPTST_SET; \ + DESC(SAVE_OPTS).optArg.argString = (char const*)(a) ) + +#ifdef TCPBURST +#define VALUE_OPT_MULTIPLE 'm' +#define OPT_VALUE_MULTIPLE (DESC(MULTIPLE).optArg.argInt) + +#define VALUE_OPT_DISTANCE 'd' +#define OPT_VALUE_DISTANCE (DESC(DISTANCE).optArg.argInt) + + +#define VALUE_OPT_DRIVER_MODE 'D' +#define OPT_VALUE_DRIVER_MODE (DESC(DRIVER_MODE).optArg.argString) + + +#define VALUE_OPT_CPU_MASK 's' +#define OPT_VALUE_CPU_MASK (DESC(CPU_MASK).optArg.argString) + +#define VALUE_OPT_ENCAP 'e' +#define OPT_VALUE_ENCAP (DESC(ENCAP).optArg.argString) + +#endif + + + +/* + * Interface defines not associated with particular options + */ +#define ERRSKIP_OPTERR STMTS( tcpreplayOptions.fOptSet &= ~OPTPROC_ERRSTOP ) +#define ERRSTOP_OPTERR STMTS( tcpreplayOptions.fOptSet |= OPTPROC_ERRSTOP ) +#define RESTART_OPT(n) STMTS( \ + tcpreplayOptions.curOptIdx = (n); \ + tcpreplayOptions.pzCurOpt = NULL ) +#define START_OPT RESTART_OPT(1) +#define USAGE(c) (*tcpreplayOptions.pUsageProc)( &tcpreplayOptions, c ) +/* extracted from /usr/local/share/autogen/opthead.tpl near line 409 */ + +/* * * * * * + * + * Declare the tcpreplay option descriptor. + */ +#ifdef __cplusplus +extern "C" { +#endif + +extern tOptions tcpreplayOptions; + +#if defined(ENABLE_NLS) +# ifndef _ +# include + static inline char* aoGetsText( char const* pz ) { + if (pz == NULL) return NULL; + return (char*)gettext( pz ); + } +# define _(s) aoGetsText(s) +# endif /* _() */ + +# define OPT_NO_XLAT_CFG_NAMES STMTS(tcpreplayOptions.fOptSet |= \ + OPTPROC_NXLAT_OPT_CFG;) +# define OPT_NO_XLAT_OPT_NAMES STMTS(tcpreplayOptions.fOptSet |= \ + OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;) + +# define OPT_XLAT_CFG_NAMES STMTS(tcpreplayOptions.fOptSet &= \ + ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);) +# define OPT_XLAT_OPT_NAMES STMTS(tcpreplayOptions.fOptSet &= \ + ~OPTPROC_NXLAT_OPT;) + +#else /* ENABLE_NLS */ +# define OPT_NO_XLAT_CFG_NAMES +# define OPT_NO_XLAT_OPT_NAMES + +# define OPT_XLAT_CFG_NAMES +# define OPT_XLAT_OPT_NAMES + +# ifndef _ +# define _(_s) _s +# endif +#endif /* ENABLE_NLS */ + +#ifdef __cplusplus +} +#endif +#endif /* AUTOOPTS_TCPREPLAY_OPTS_H_GUARD */ +/* tcpreplay_opts.h ends here */ diff --git a/src/tcprewrite.1 b/src/tcprewrite.1 new file mode 100644 index 0000000..ee28395 --- /dev/null +++ b/src/tcprewrite.1 @@ -0,0 +1,542 @@ +.TH TCPREWRITE 1 2010-04-04 "(tcprewrite )" "Programmer's Manual" +.\" DO NOT EDIT THIS FILE (tcprewrite.1) +.\" +.\" It has been AutoGen-ed April 4, 2010 at 05:59:20 PM by AutoGen 5.9.9 +.\" From the definitions tcprewrite_opts.def +.\" and the template file agman1.tpl +.\" +.SH NAME +tcprewrite \- Rewrite the packets in a pcap file. +.SH SYNOPSIS +.B tcprewrite +.\" Mixture of short (flag) options and long options +.RB [ \-\fIflag\fP " [\fIvalue\fP]]... [" \--\fIopt-name\fP " [[=| ]\fIvalue\fP]]..." +.PP +All arguments must be options. +.SH "DESCRIPTION" +This manual page briefly documents the \fBtcprewrite\fP command. +Tcprewrite is a tool to rewrite packets stored in \fIpcap(3)\fP file format, +such as crated by tools such as \fItcpdump(1)\fP and \fIethereal(1)\fP. +Once a pcap file has had it's packets rewritten, they can be replayed back +out on the network using \fItcpreplay(1)\fP. + +tcprewrite currently supports reading the following DLT types: +.sp 1 +\fBDLT_C_HDLC\fP aka Cisco HDLC +.sp 1 +\fBDLT_EN10MB\fP aka Ethernet +.sp 1 +\fBDLT_LINUX_SLL\fP aka Linux Cooked Socket +.sp 1 +\fBDLT_RAW\fP aka RAW IP +.sp 1 +\fBDLT_NULL\fP aka BSD Loopback +.sp 1 +\fBDLT_LOOP\fP aka OpenBSD Loopback +.sp 1 +\fBDLT_IEEE802_11\fP aka 802.11a/b/g +.sp 1 +\fBDLT_IEEE802_11_RADIO\fP aka 802.11a/b/g with Radiotap headers + +Please see the \--dlt option for supported DLT types for writing. + +The packet editing features of tcprewrite which distinguish between "client" +and "server" traffic requires a tcpprep(1) cache file. + +For more details, please see the Tcpreplay Manual at: +http://tcpreplay.synfin.net/trac/wiki/manual +.SH OPTIONS +.SS "" +.TP +.BR \-r " \fIstring\fP, " \--portmap "=" \fIstring\fP +Rewrite TCP/UDP ports. +This option may appear up to \-1 times. +.sp +Specify a list of comma delimited port mappingings consisting of +colon delimited port number pairs. Each colon delimited port pair +consists of the port to match followed by the port number to rewrite. + +Examples: +.nf + \--portmap=80:8000 \--portmap=8080:80 # 80->8000 and 8080->80 + \--portmap=8000,8080,88888:80 # 3 different ports become 80 + \--portmap=8000-8999:80 # ports 8000 to 8999 become 80 +.fi +.TP +.BR \-s " \fInumber\fP, " \--seed "=" \fInumber\fP +Randomize src/dst IPv4/v6 addresses w/ given seed. +This option may appear up to 1 times. +This option takes an integer number as its argument. +.sp +Causes the source and destination IPv4/v6 addresses to be pseudo +randomized but still maintain client/server relationships. +Since the randomization is deterministic based on the seed, +you can reuse the same seed value to recreate the traffic. +.TP +.BR \-N " \fIstring\fP, " \--pnat "=" \fIstring\fP +Rewrite IPv4/v6 addresses using pseudo-NAT. +This option may appear up to 2 times. +This option must not appear in combination with any of the following options: +srcipmap. +.sp +Takes a comma delimited series of colon delimited CIDR +netblock pairs. Each netblock pair is evaluated in order against +the IP addresses. If the IP address in the packet matches the +first netblock, it is rewriten using the second netblock as a +mask against the high order bits. + +IPv4 Example: +.nf + \--pnat=192.168.0.0/16:10.77.0.0/16,172.16.0.0/12:10.1.0.0/24 +.fi +IPv6 Example: +.nf + \--pnat=[2001:db8::/32]:[dead::/16],[2001:db8::/32]:[::ffff:0:0/96] +.fi +.TP +.BR \-S " \fIstring\fP, " \--srcipmap "=" \fIstring\fP +Rewrite source IPv4/v6 addresses using pseudo-NAT. +This option may appear up to 1 times. +This option must not appear in combination with any of the following options: +pnat. +.sp +Works just like the \--pnat option, but only affects the source IP +addresses in the IPv4/v6 header. +.TP +.BR \-D " \fIstring\fP, " \--dstipmap "=" \fIstring\fP +Rewrite destination IPv4/v6 addresses using pseudo-NAT. +This option may appear up to 1 times. +This option must not appear in combination with any of the following options: +pnat. +.sp +Works just like the \--pnat option, but only affects the destination IP +addresses in the IPv4/v6 header. +.TP +.BR \-e " \fIstring\fP, " \--endpoints "=" \fIstring\fP +Rewrite IP addresses to be between two endpoints. +This option may appear up to 1 times. +This option must appear in combination with the following options: +cachefile. +.sp +Takes a pair of colon delimited IPv4/v6 addresses which will be used to rewrite +all traffic to appear to be between the two IP's. + +IPv4 Example: +.nf + \--endpoints=172.16.0.1:172.16.0.2 +.fi +IPv6 Example: +.nf + \--endpoints=[2001:db8::dead:beef]:[::ffff:0:0:ac:f:0:2] +.fi + +.TP +.BR \-b ", " \--skipbroadcast +Skip rewriting broadcast/multicast IPv4/v6 addresses. +.sp +By default \--seed, \--pnat and \--endpoints will rewrite +broadcast and multicast IPv4/v6 and MAC addresses. Setting this flag +will keep broadcast/multicast IPv4/v6 and MAC addresses from being rewritten. +.TP +.BR \-C ", " \--fixcsum +Force recalculation of IPv4/TCP/UDP header checksums. +.sp +Causes each IPv4/v6 packet to have it's checksums recalcualted and +fixed. Automatically enabled for packets modified with \fB--seed\fP, +\fB--pnat\fP, \fB--endpoints\fP or \fB--fixlen\fP. +.TP +.BR \-m " \fInumber\fP, " \--mtu "=" \fInumber\fP +Override default MTU length (1500 bytes). +This option may appear up to 1 times. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 1 through MAXPACKET +.fi +.in -4 +.sp +Override the default 1500 byte MTU size for determining the maximum padding length +(--fixlen=pad) or when truncating (--mtu-trunc). +.TP +.BR \--mtu-trunc +Truncate packets larger then specified MTU. +This option may appear up to 1 times. +.sp +Similar to \--fixlen, this option will truncate data in packets from Layer 3 and above to be +no larger then the MTU. +.TP +.BR \-E ", " \--efcs +Remove Ethernet checksums (FCS) from end of frames. +.sp +Note, this option is pretty dangerous! We don't actually check to see if a FCS +actually exists in the frame, we just blindly delete the last two bytes. Hence, +you should only use this if you know know that your OS provides the FCS when +reading raw packets. +.TP +.BR \--ttl "=\fIstring\fP" +Modify the IPv4/v6 TTL/Hop Limit. +.sp +Allows you to modify the TTL/Hop Limit of all the IPv4/v6 packets. Specify a number to hard-code +the value or +/-value to increase or decrease by the value provided (limited to 1-255). + +Examples: +.nf + \--ttl=10 + \--ttl=+7 + \--ttl=-64 +.fi +.TP +.BR \--tos "=\fInumber\fP" +Set the IPv4 TOS/DiffServ/ECN byte. +This option may appear up to 1 times. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 255 +.fi +.in -4 +.sp +Allows you to override the TOS (also known as DiffServ/ECN) value in IPv4. +.TP +.BR \--tclass "=\fInumber\fP" +Set the IPv6 Traffic Class byte. +This option may appear up to 1 times. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 255 +.fi +.in -4 +.sp +Allows you to override the IPv6 Traffic Class field. +.TP +.BR \--flowlabel "=\fInumber\fP" +Set the IPv6 Flow Label. +This option may appear up to 1 times. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 1048575 +.fi +.in -4 +.sp +Allows you to override the 20bit IPv6 Flow Label field. Has no effect on IPv4 +packets. +.TP +.BR \-F " \fIstring\fP, " \--fixlen "=" \fIstring\fP +Pad or truncate packet data to match header length. +This option may appear up to 1 times. +.sp +Packets may be truncated during capture if the snaplen is smaller then the +packet. This option allows you to modify the packet to pad the packet back +out to the size stored in the IPv4/v6 header or rewrite the IP header total length +to reflect the stored packet length. +.sp 1 +\fBpad\fP +Truncated packets will be padded out so that the packet length matches the +IPv4 total length +.sp 1 +\fBtrunc\fP +Truncated packets will have their IPv4 total length field rewritten to match +the actual packet length +.sp 1 +\fBdel\fP +Delete the packet +.TP +.BR \--skipl2broadcast +Skip rewriting broadcast/multicast Layer 2 addresses. +.sp +By default, editing Layer 2 addresses will rewrite +broadcast and multicast MAC addresses. Setting this flag +will keep broadcast/multicast MAC addresses from being rewritten. +.TP +.BR \--dlt "=\fIstring\fP" +Override output DLT encapsulation. +This option may appear up to 1 times. +.sp +By default, no DLT (data link type) conversion will be made. +To change the DLT type of the output pcap, select one of the following values: +.sp 1 +\fBenet\fP +Ethernet aka DLT_EN10MB +.sp 1 +\fBhdlc\fP +Cisco HDLC aka DLT_C_HDLC +.sp 1 +\fBuser\fP +User specified Layer 2 header and DLT type +.br +.TP +.BR \--enet-dmac "=\fIstring\fP" +Override destination ethernet MAC addresses. +This option may appear up to 1 times. +.sp +Takes a pair of comma deliminated ethernet MAC addresses which +will replace the destination MAC address of outbound packets. +The first MAC address will be used for the server to client traffic +and the optional second MAC address will be used for the client +to server traffic. + +Example: +.nf + \--enet-dmac=00:12:13:14:15:16,00:22:33:44:55:66 +.fi +.TP +.BR \--enet-smac "=\fIstring\fP" +Override source ethernet MAC addresses. +This option may appear up to 1 times. +.sp +Takes a pair of comma deliminated ethernet MAC addresses which +will replace the source MAC address of outbound packets. +The first MAC address will be used for the server to client traffic +and the optional second MAC address will be used for the client +to server traffic. + +Example: +.nf + \--enet-smac=00:12:13:14:15:16,00:22:33:44:55:66 +.fi +.TP +.BR \--enet-vlan "=\fIstring\fP" +Specify ethernet 802.1q VLAN tag mode. +This option may appear up to 1 times. +.sp +Allows you to rewrite ethernet frames to add a 802.1q header to standard 802.3 +ethernet headers or remove the 802.1q VLAN tag information. +.sp 1 +\fBadd\fP +Rewrites the existing 802.3 ethernet header as an 802.1q VLAN header +.sp 1 +\fBdel\fP +Rewrites the existing 802.1q VLAN header as an 802.3 ethernet header +.TP +.BR \--enet-vlan-tag "=\fInumber\fP" +Specify the new ethernet 802.1q VLAN tag value. +This option may appear up to 1 times. +This option must appear in combination with the following options: +enet-vlan. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 4095 +.fi +.in -4 +.sp + +.TP +.BR \--enet-vlan-cfi "=\fInumber\fP" +Specify the ethernet 802.1q VLAN CFI value. +This option may appear up to 1 times. +This option must appear in combination with the following options: +enet-vlan. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 1 +.fi +.in -4 +.sp + +.TP +.BR \--enet-vlan-pri "=\fInumber\fP" +Specify the ethernet 802.1q VLAN priority. +This option may appear up to 1 times. +This option must appear in combination with the following options: +enet-vlan. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 7 +.fi +.in -4 +.sp + +.TP +.BR \--hdlc-control "=\fInumber\fP" +Specify HDLC control value. +This option may appear up to 1 times. +This option takes an integer number as its argument. +.sp +The Cisco HDLC header has a 1 byte "control" field. Apparently this should +always be 0, but if you can use any 1 byte value. +.TP +.BR \--hdlc-address "=\fInumber\fP" +Specify HDLC address. +This option may appear up to 1 times. +This option takes an integer number as its argument. +.sp +The Cisco HDLC header has a 1 byte "address" field which has two valid +values: +.sp 1 +\fB0x0F\fP +Unicast +.sp 1 +\fB0xBF\fP +Broadcast +.br +You can however specify any single byte value. +.TP +.BR \--user-dlt "=\fInumber\fP" +Set output file DLT type. +This option may appear up to 1 times. +This option takes an integer number as its argument. +.sp +Set the DLT value of the output pcap file. +.TP +.BR \--user-dlink "=\fIstring\fP" +Rewrite Data-Link layer with user specified data. +This option may appear up to 2 times. +.sp +Provide a series of comma deliminated hex values which will be +used to rewrite or create the Layer 2 header of the packets. +The first instance of this argument will rewrite both server +and client traffic, but if this argument is specified a second +time, it will be used for the client traffic. + +Example: +.nf + \--user-dlink=01,02,03,04,05,06,00,1A,2B,3C,4D,5E,6F,08,00 +.fi +.TP +.BR \-d " \fInumber\fP, " \--dbug "=" \fInumber\fP +Enable debugging output. +This option may appear up to 1 times. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 5 +.fi +.in -4 +The default \fInumber\fP for this option is: +.ti +4 + 0 +.sp +If configured with \--enable-debug, then you can specify a verbosity +level for debugging output. Higher numbers increase verbosity. +.TP +.BR \-i " \fIstring\fP, " \--infile "=" \fIstring\fP +Input pcap file to be processed. +This option may appear up to 1 times. +.sp + +.TP +.BR \-o " \fIstring\fP, " \--outfile "=" \fIstring\fP +Output pcap file. +This option may appear up to 1 times. +.sp + +.TP +.BR \-c " \fIstring\fP, " \--cachefile "=" \fIstring\fP +Split traffic via tcpprep cache file. +This option may appear up to 1 times. +.sp +Use tcpprep cache file to split traffic based upon client/server relationships. +.TP +.BR \-v ", " \--verbose +Print decoded packets via tcpdump to STDOUT. +This option may appear up to 1 times. +.sp + +.TP +.BR \-A " \fIstring\fP, " \--decode "=" \fIstring\fP +Arguments passed to tcpdump decoder. +This option may appear up to 1 times. +This option must appear in combination with the following options: +verbose. +.sp +When enabling verbose mode (\fB-v\fP) you may also specify one or +more additional arguments to pass to \fBtcpdump\fP to modify +the way packets are decoded. By default, \-n and \-l are used. +Be sure to quote the arguments so that they are not interpreted +by tcprewrite. Please see the tcpdump(1) man page for a complete list of +options. +.TP +.BR \--fragroute "=\fIstring\fP" +Parse fragroute configuration file. +This option may appear up to 1 times. +.sp +Enable advanced evasion techniques using the built-in fragroute(8) +engine. See the fragroute(8) man page for more details. Important: +tcprewrite does not support the delay, echo or print commands. +.TP +.BR \--fragdir "=\fIstring\fP" +Which flows to apply fragroute to: c2s, s2c, both. +This option may appear up to 1 times. +This option must appear in combination with the following options: +cachefile. +.sp +Apply the fragroute engine to packets going c2s, s2c or both when +using a cache file. +.TP +.BR \--skip-soft-errors +Skip writing packets with soft errors. +This option may appear up to 1 times. +.sp +In some cases, packets can't be decoded or the requested editing +is not possible. Normally these packets are written to the output +file unedited so that tcpprep cache files can still be used, but if +you wish, these packets can be suppressed. + +One example of this is 802.11 management frames which contain no data. +.TP +.BR \-V ", " \--version +Print version information. +.sp + +.TP +.BR \-h ", " \--less-help +Display less usage information and exit. +.sp + +.TP +.BR \-H , " \--help" +Display usage information and exit. +.TP +.BR \-! , " \--more-help" +Extended usage information passed thru pager. +.TP +.BR \- " [\fIrcfile\fP]," " \--save-opts" "[=\fIrcfile\fP]" +Save the option state to \fIrcfile\fP. The default is the \fIlast\fP +configuration file listed in the \fBOPTION PRESETS\fP section, below. +.TP +.BR \- " \fIrcfile\fP," " \--load-opts" "=\fIrcfile\fP," " \--no-load-opts" +Load options from \fIrcfile\fP. +The \fIno-load-opts\fP form will disable the loading +of earlier RC/INI files. \fI--no-load-opts\fP is handled early, +out of order. +.SH OPTION PRESETS +Any option that is not marked as \fInot presettable\fP may be preset +by loading values from configuration ("RC" or ".INI") file(s). +The \fIhomerc\fP file is "\fI$$/\fP", unless that is a directory. +In that case, the file "\fI.tcprewriterc\fP" +is searched for within that directory. +.SH "SEE ALSO" +tcpdump(1), tcpprep(1), tcpreplay(1) +.SH AUTHOR +Copyright 2000-2010 Aaron Turner + +For support please use the tcpreplay-users@lists.sourceforge.net mailing list. + +The latest version of this software is always available from: +http://tcpreplay.synfin.net/ +.PP +Released under the Free BSD License. +.PP +This manual page was \fIAutoGen\fP-erated from the \fBtcprewrite\fP +option definitions. diff --git a/src/tcprewrite.c b/src/tcprewrite.c new file mode 100644 index 0000000..7ebac61 --- /dev/null +++ b/src/tcprewrite.c @@ -0,0 +1,341 @@ +/* $Id: tcprewrite.c 2427 2010-03-25 00:38:13Z aturner $ */ + +/* + * Copyright (c) 2004-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Purpose: Modify packets in a pcap file based on rules provided by the + * user to offload work from tcpreplay and provide a easier means of + * reproducing traffic for testing purposes. + */ + + +#include "config.h" +#include "defines.h" +#include "common.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "tcprewrite.h" +#include "tcprewrite_opts.h" +#include "tcpedit/tcpedit.h" + +#ifdef DEBUG +int debug; +#endif + +#ifdef ENABLE_VERBOSE +/* tcpdump handle */ +tcpdump_t tcpdump; +#endif + +tcprewrite_opt_t options; +tcpedit_t *tcpedit; + +/* local functions */ +void tcprewrite_init(void); +void post_args(int argc, char *argv[]); +void verify_input_pcap(pcap_t *pcap); +int rewrite_packets(tcpedit_t *tcpedit, pcap_t *pin, pcap_dumper_t *pout); + +int +main(int argc, char *argv[]) +{ + int optct, rcode; + pcap_t *dlt_pcap; +#ifdef ENABLE_FRAGROUTE + char ebuf[FRAGROUTE_ERRBUF_LEN]; +#endif + tcprewrite_init(); + + /* call autoopts to process arguments */ + optct = optionProcess(&tcprewriteOptions, argc, argv); + argc -= optct; + argv += optct; + + /* parse the tcprewrite args */ + post_args(argc, argv); + + /* init tcpedit context */ + if (tcpedit_init(&tcpedit, pcap_datalink(options.pin)) < 0) { + errx(-1, "Error initializing tcpedit: %s", tcpedit_geterr(tcpedit)); + } + + /* parse the tcpedit args */ + rcode = tcpedit_post_args(&tcpedit); + if (rcode < 0) { + errx(-1, "Unable to parse args: %s", tcpedit_geterr(tcpedit)); + } else if (rcode == 1) { + warnx("%s", tcpedit_geterr(tcpedit)); + } + + + if (tcpedit_validate(tcpedit) < 0) { + errx(-1, "Unable to edit packets given options:\n%s", + tcpedit_geterr(tcpedit)); + } + + /* open up the output file */ + 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) + 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) + errx(-1, "%s", ebuf); + } +#endif + +#ifdef ENABLE_VERBOSE + if (options.verbose) { + tcpdump_open(&tcpdump, dlt_pcap); + } +#endif + + if ((options.pout = pcap_dump_open(dlt_pcap, options.outfile)) == NULL) + 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) + errx(-1, "Error rewriting packets: %s", tcpedit_geterr(tcpedit)); + + + /* clean up after ourselves */ + pcap_dump_close(options.pout); + pcap_close(options.pin); + +#ifdef ENABLE_VERBOSE + tcpdump_close(&tcpdump); +#endif + +#ifdef ENABLE_DMALLOC + dmalloc_shutdown(); +#endif + return 0; +} + +void +tcprewrite_init(void) +{ + + memset(&options, 0, sizeof(options)); + +#ifdef ENABLE_VERBOSE + /* clear out tcpdump struct */ + memset(&tcpdump, '\0', sizeof(tcpdump_t)); +#endif + + if (fcntl(STDERR_FILENO, F_SETFL, O_NONBLOCK) < 0) + warnx("Unable to set STDERR to non-blocking: %s", strerror(errno)); +} + +/** + * post AutoGen argument processing + */ +void +post_args(_U_ int argc, _U_ char *argv[]) +{ + char ebuf[PCAP_ERRBUF_SIZE]; + +#ifdef DEBUG + if (HAVE_OPT(DBUG)) + debug = OPT_VALUE_DBUG; +#else + if (HAVE_OPT(DBUG)) + warn("not configured with --enable-debug. Debugging disabled."); +#endif + + +#ifdef ENABLE_VERBOSE + if (HAVE_OPT(VERBOSE)) + options.verbose = 1; + + if (HAVE_OPT(DECODE)) + tcpdump.args = safe_strdup(OPT_ARG(DECODE)); +#endif + + +#ifdef ENABLE_FRAGROUTE + if (HAVE_OPT(FRAGROUTE)) + options.fragroute_args = safe_strdup(OPT_ARG(FRAGROUTE)); + + options.fragroute_dir = FRAGROUTE_DIR_BOTH; + if (HAVE_OPT(FRAGDIR)) { + if (strcmp(OPT_ARG(FRAGDIR), "c2s") == 0) { + options.fragroute_dir = FRAGROUTE_DIR_C2S; + } else if (strcmp(OPT_ARG(FRAGDIR), "s2c") == 0) { + options.fragroute_dir = FRAGROUTE_DIR_S2C; + } else if (strcmp(OPT_ARG(FRAGDIR), "both") == 0) { + options.fragroute_dir = FRAGROUTE_DIR_BOTH; + } else { + errx(-1, "Unknown --fragdir value: %s", OPT_ARG(FRAGDIR)); + } + } +#endif + + /* open up the input file */ + options.infile = safe_strdup(OPT_ARG(INFILE)); + if ((options.pin = pcap_open_offline(options.infile, ebuf)) == NULL) + errx(-1, "Unable to open input pcap file: %s", ebuf); + +#ifdef HAVE_PCAP_SNAPSHOT + if (pcap_snapshot(options.pin) < 65535) + warnx("%s was captured using a snaplen of %d bytes. This may mean you have truncated packets.", + options.infile, pcap_snapshot(options.pin)); +#endif + +} + +/** + * Main loop to rewrite packets + */ +int +rewrite_packets(tcpedit_t *tcpedit, pcap_t *pin, pcap_dumper_t *pout) +{ + tcpr_dir_t cache_result = TCPR_DIR_C2S; /* default to primary */ + struct pcap_pkthdr pkthdr, *pkthdr_ptr; /* packet header */ + const u_char *pktconst = NULL; /* packet from libpcap */ + u_char **pktdata = NULL; + static u_char *pktdata_buff; + static char *frag = NULL; + COUNTER packetnum = 0; + int rcode, frag_len, i; + + pkthdr_ptr = &pkthdr; + + if (pktdata_buff == NULL) + pktdata_buff = (u_char *)safe_malloc(MAXPACKET); + + pktdata = &pktdata_buff; + + if (frag == NULL) + frag = (char *)safe_malloc(MAXPACKET); + + /* MAIN LOOP + * Keep sending while we have packets or until + * we've sent enough packets + */ + while ((pktconst = pcap_next(pin, pkthdr_ptr)) != NULL) { + packetnum++; + dbgx(2, "packet " COUNTER_SPEC " caplen %d", packetnum, pkthdr.caplen); + + /* + * copy over the packet so we can pad it out if necessary and + * because pcap_next() returns a const ptr + */ + memcpy(*pktdata, pktconst, pkthdr.caplen); + +#ifdef ENABLE_VERBOSE + if (options.verbose) + tcpdump_print(&tcpdump, pkthdr_ptr, *pktdata); +#endif + + /* Dual nic processing? */ + if (options.cachedata != NULL) { + cache_result = check_cache(options.cachedata, packetnum); + } + + /* sometimes we should not send the packet, in such cases + * no point in editing this packet at all, just write it to the + * output file (note, we can't just remove it, or the tcpprep cache + * file will loose it's indexing + */ + + if (cache_result == TCPR_DIR_NOSEND) + goto WRITE_PACKET; /* still need to write it so cache stays in sync */ + + if ((rcode = tcpedit_packet(tcpedit, &pkthdr_ptr, pktdata, cache_result)) == TCPEDIT_ERROR) { + return -1; + } else if ((rcode == TCPEDIT_SOFT_ERROR) && HAVE_OPT(SKIP_SOFT_ERRORS)) { + /* don't write packet */ + dbgx(1, "Packet " COUNTER_SPEC " is suppressed from being written due to soft errors", packetnum); + continue; + } + + +WRITE_PACKET: +#ifdef ENABLE_FRAGROUTE + if (options.frag_ctx == NULL) { + /* write the packet when there's no fragrouting to be done */ + pcap_dump((u_char *)pout, pkthdr_ptr, *pktdata); + } else { + /* packet needs to be fragmented */ + if ((options.fragroute_dir == FRAGROUTE_DIR_BOTH) || + (cache_result == TCPR_DIR_C2S && options.fragroute_dir == FRAGROUTE_DIR_C2S) || + (cache_result == TCPR_DIR_S2C && options.fragroute_dir == FRAGROUTE_DIR_S2C)) { + + if (fragroute_process(options.frag_ctx, *pktdata, pkthdr_ptr->caplen) < 0) + errx(-1, "Error processing packet via fragroute: %s", options.frag_ctx->errbuf); + + i = 0; + while ((frag_len = fragroute_getfragment(options.frag_ctx, &frag)) > 0) { + /* frags get the same timestamp as the original packet */ + dbgx(1, "processing packet " COUNTER_SPEC " frag: %u (%d)", packetnum, i++, frag_len); + pkthdr_ptr->caplen = frag_len; + pkthdr_ptr->len = frag_len; + pcap_dump((u_char *)pout, pkthdr_ptr, (u_char *)frag); + } + } else { + /* write the packet without fragroute */ + pcap_dump((u_char *)pout, pkthdr_ptr, *pktdata); + } + } +#else + /* write the packet when there's no fragrouting to be done */ + pcap_dump((u_char *)pout, pkthdr_ptr, *pktdata); + +#endif + } /* while() */ + return 0; +} + + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + diff --git a/src/tcprewrite.h b/src/tcprewrite.h new file mode 100644 index 0000000..ec1734f --- /dev/null +++ b/src/tcprewrite.h @@ -0,0 +1,93 @@ +/* $Id: tcprewrite.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2004-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + #ifndef __TCPREWRITE_H__ + #define __TCPREWRITE_H__ + + +#include "config.h" +#include "defines.h" +#include "tcpedit/tcpedit.h" + +#ifdef ENABLE_DMALLOC +#include +#endif + +#ifdef ENABLE_FRAGROUTE +#include "fragroute/fragroute.h" +#endif + +/* runtime options */ +struct tcprewrite_opt_s { + /* input and output pcap filenames & handles */ + char *infile; + char *outfile; + pcap_t *pin; + pcap_dumper_t *pout; + + /* tcpprep cache data */ + COUNTER cache_packets; + char *cachedata; + + /* tcpprep cache file comment */ + char *comment; + +#ifdef ENABLE_VERBOSE + /* tcpdump verbose printing */ + int verbose; + char *tcpdump_args; +#endif + +#ifdef ENABLE_FRAGROUTE + char *fragroute_args; + fragroute_t *frag_ctx; +#define FRAGROUTE_DIR_C2S 1 +#define FRAGROUTE_DIR_S2C 2 +#define FRAGROUTE_DIR_BOTH 4 + int fragroute_dir; +#endif + tcpedit_t *tcpedit; +}; + +typedef struct tcprewrite_opt_s tcprewrite_opt_t; + +#endif /* __TCPREWRITE_H__ */ + + +/* + Local Variables: + mode:c + indent-tabs-mode:nil + c-basic-offset:4 + End: +*/ + diff --git a/src/tcprewrite_opts.c b/src/tcprewrite_opts.c new file mode 100644 index 0000000..7b7e5f6 --- /dev/null +++ b/src/tcprewrite_opts.c @@ -0,0 +1,1818 @@ +/* -*- buffer-read-only: t -*- vi: set ro: + * + * DO NOT EDIT THIS FILE (tcprewrite_opts.c) + * + * It has been AutoGen-ed April 4, 2010 at 05:59:19 PM by AutoGen 5.9.9 + * From the definitions tcprewrite_opts.def + * and the template file options + * + * Generated from AutoOpts 32:2:7 templates. + */ + +/* + * This file was produced by an AutoOpts template. AutoOpts is a + * copyrighted work. This source file is not encumbered by AutoOpts + * licensing, but is provided under the licensing terms chosen by the + * tcprewrite author or copyright holder. AutoOpts is licensed under + * the terms of the LGPL. The redistributable library (``libopts'') is + * licensed under the terms of either the LGPL or, at the users discretion, + * the BSD license. See the AutoOpts and/or libopts sources for details. + * + * This source file is copyrighted and licensed under the following terms: + * + * tcprewrite copyright (c) 2000-2010 Aaron Turner - all rights reserved + * + * tcprewrite is free software copyrighted by Aaron Turner. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name ``Aaron Turner'' nor the name of any other + * contributor may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * tcprewrite IS PROVIDED BY Aaron Turner ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL Aaron Turner OR ANY OTHER CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +extern FILE * option_usage_fp; +#define OPTION_CODE_COMPILE 1 +#include "tcprewrite_opts.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* TRANSLATORS: choose the translation for option names wisely because you + cannot ever change your mind. */ +tSCC zCopyright[] = + "tcprewrite copyright (c) 2000-2010 Aaron Turner, all rights reserved"; +tSCC zCopyrightNotice[1460] = +"tcprewrite is free software copyrighted by Aaron Turner.\n\n\ +Redistribution and use in source and binary forms, with or without\n\ +modification, are permitted provided that the following conditions are met: 1.\n\ +Redistributions of source code must retain the above copyright notice, this\n\ +list of conditions and the following disclaimer. 2. Redistributions in binary\n\ +form must reproduce the above copyright notice, this list of conditions and the\n\ +following disclaimer in the documentation and/or other materials provided with\n\ +the distribution. 3. Neither the name ``Aaron Turner'' nor the name of any\n\ +other contributor may be used to endorse or promote products derived from this\n\ +software without specific prior written permission.\n\n\ +tcprewrite IS PROVIDED BY Aaron Turner ``AS IS'' AND ANY EXPRESS OR IMPLIED\n\ +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n\ +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO\n\ +EVENT SHALL Aaron Turner OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n\ +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\n\ +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n\ +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n\ +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE\n\ +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\n\ +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."; + +extern tUsageProc optionUsage; + +/* + * global included definitions + */ +#include "defines.h" +#include "common.h" +#include "config.h" +#include "tcprewrite.h" +#include +#include +extern tcprewrite_opt_t options; + + +#ifndef NULL +# define NULL 0 +#endif +#ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +#endif +#ifndef EXIT_FAILURE +# define EXIT_FAILURE 1 +#endif +/* + * Tcpedit option description: + */ +tSCC zTcpeditText[] = + ""; +#define TCPEDIT_FLAGS (OPTST_DOCUMENT | OPTST_NO_INIT) + +/* + * Portmap option description: + */ +tSCC zPortmapText[] = + "Rewrite TCP/UDP ports"; +tSCC zPortmap_NAME[] = "PORTMAP"; +tSCC zPortmap_Name[] = "portmap"; +#define PORTMAP_FLAGS (OPTST_DISABLED | OPTST_STACKED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Seed option description: + */ +tSCC zSeedText[] = + "Randomize src/dst IPv4/v6 addresses w/ given seed"; +tSCC zSeed_NAME[] = "SEED"; +tSCC zSeed_Name[] = "seed"; +#define SEED_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Pnat option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zPnatText[] = + "Rewrite IPv4/v6 addresses using pseudo-NAT"; +tSCC zPnat_NAME[] = "PNAT"; +tSCC zPnat_Name[] = "pnat"; +static const int + aPnatCantList[] = { + INDEX_OPT_SRCIPMAP, NO_EQUIVALENT }; +#define PNAT_FLAGS (OPTST_DISABLED | OPTST_STACKED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Srcipmap option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zSrcipmapText[] = + "Rewrite source IPv4/v6 addresses using pseudo-NAT"; +tSCC zSrcipmap_NAME[] = "SRCIPMAP"; +tSCC zSrcipmap_Name[] = "srcipmap"; +static const int + aSrcipmapCantList[] = { + INDEX_OPT_PNAT, NO_EQUIVALENT }; +#define SRCIPMAP_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Dstipmap option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zDstipmapText[] = + "Rewrite destination IPv4/v6 addresses using pseudo-NAT"; +tSCC zDstipmap_NAME[] = "DSTIPMAP"; +tSCC zDstipmap_Name[] = "dstipmap"; +static const int + aDstipmapCantList[] = { + INDEX_OPT_PNAT, NO_EQUIVALENT }; +#define DSTIPMAP_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Endpoints option description with + * "Must also have options" and "Incompatible options": + */ +#ifdef HAVE_CACHEFILE_SUPPORT +tSCC zEndpointsText[] = + "Rewrite IP addresses to be between two endpoints"; +tSCC zEndpoints_NAME[] = "ENDPOINTS"; +tSCC zEndpoints_Name[] = "endpoints"; +static const int + aEndpointsMustList[] = { + INDEX_OPT_CACHEFILE, NO_EQUIVALENT }; +#define ENDPOINTS_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +#else /* disable Endpoints */ +#define VALUE_OPT_ENDPOINTS NO_EQUIVALENT +#define ENDPOINTS_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define aEndpointsMustList NULL +#define zEndpointsText NULL +#define zEndpoints_NAME NULL +#define zEndpoints_Name NULL +#endif /* HAVE_CACHEFILE_SUPPORT */ + +/* + * Skipbroadcast option description: + */ +tSCC zSkipbroadcastText[] = + "Skip rewriting broadcast/multicast IPv4/v6 addresses"; +tSCC zSkipbroadcast_NAME[] = "SKIPBROADCAST"; +tSCC zSkipbroadcast_Name[] = "skipbroadcast"; +#define SKIPBROADCAST_FLAGS (OPTST_DISABLED) + +/* + * Fixcsum option description: + */ +tSCC zFixcsumText[] = + "Force recalculation of IPv4/TCP/UDP header checksums"; +tSCC zFixcsum_NAME[] = "FIXCSUM"; +tSCC zFixcsum_Name[] = "fixcsum"; +#define FIXCSUM_FLAGS (OPTST_DISABLED) + +/* + * Mtu option description: + */ +tSCC zMtuText[] = + "Override default MTU length (1500 bytes)"; +tSCC zMtu_NAME[] = "MTU"; +tSCC zMtu_Name[] = "mtu"; +#define MTU_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Mtu_Trunc option description: + */ +tSCC zMtu_TruncText[] = + "Truncate packets larger then specified MTU"; +tSCC zMtu_Trunc_NAME[] = "MTU_TRUNC"; +tSCC zMtu_Trunc_Name[] = "mtu-trunc"; +#define MTU_TRUNC_FLAGS (OPTST_DISABLED) + +/* + * Efcs option description: + */ +tSCC zEfcsText[] = + "Remove Ethernet checksums (FCS) from end of frames"; +tSCC zEfcs_NAME[] = "EFCS"; +tSCC zEfcs_Name[] = "efcs"; +#define EFCS_FLAGS (OPTST_DISABLED) + +/* + * Ttl option description: + */ +tSCC zTtlText[] = + "Modify the IPv4/v6 TTL/Hop Limit"; +tSCC zTtl_NAME[] = "TTL"; +tSCC zTtl_Name[] = "ttl"; +#define TTL_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Tos option description: + */ +tSCC zTosText[] = + "Set the IPv4 TOS/DiffServ/ECN byte"; +tSCC zTos_NAME[] = "TOS"; +tSCC zTos_Name[] = "tos"; +#define TOS_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Tclass option description: + */ +tSCC zTclassText[] = + "Set the IPv6 Traffic Class byte"; +tSCC zTclass_NAME[] = "TCLASS"; +tSCC zTclass_Name[] = "tclass"; +#define TCLASS_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Flowlabel option description: + */ +tSCC zFlowlabelText[] = + "Set the IPv6 Flow Label"; +tSCC zFlowlabel_NAME[] = "FLOWLABEL"; +tSCC zFlowlabel_Name[] = "flowlabel"; +#define FLOWLABEL_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Fixlen option description: + */ +tSCC zFixlenText[] = + "Pad or truncate packet data to match header length"; +tSCC zFixlen_NAME[] = "FIXLEN"; +tSCC zFixlen_Name[] = "fixlen"; +#define FIXLEN_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Skipl2broadcast option description: + */ +tSCC zSkipl2broadcastText[] = + "Skip rewriting broadcast/multicast Layer 2 addresses"; +tSCC zSkipl2broadcast_NAME[] = "SKIPL2BROADCAST"; +tSCC zSkipl2broadcast_Name[] = "skipl2broadcast"; +#define SKIPL2BROADCAST_FLAGS (OPTST_DISABLED) + +/* + * Dlt option description: + */ +tSCC zDltText[] = + "Override output DLT encapsulation"; +tSCC zDlt_NAME[] = "DLT"; +tSCC zDlt_Name[] = "dlt"; +#define DLT_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Enet_Dmac option description: + */ +tSCC zEnet_DmacText[] = + "Override destination ethernet MAC addresses"; +tSCC zEnet_Dmac_NAME[] = "ENET_DMAC"; +tSCC zEnet_Dmac_Name[] = "enet-dmac"; +#define ENET_DMAC_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Enet_Smac option description: + */ +tSCC zEnet_SmacText[] = + "Override source ethernet MAC addresses"; +tSCC zEnet_Smac_NAME[] = "ENET_SMAC"; +tSCC zEnet_Smac_Name[] = "enet-smac"; +#define ENET_SMAC_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Enet_Vlan option description: + */ +tSCC zEnet_VlanText[] = + "Specify ethernet 802.1q VLAN tag mode"; +tSCC zEnet_Vlan_NAME[] = "ENET_VLAN"; +tSCC zEnet_Vlan_Name[] = "enet-vlan"; +#define ENET_VLAN_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Enet_Vlan_Tag option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zEnet_Vlan_TagText[] = + "Specify the new ethernet 802.1q VLAN tag value"; +tSCC zEnet_Vlan_Tag_NAME[] = "ENET_VLAN_TAG"; +tSCC zEnet_Vlan_Tag_Name[] = "enet-vlan-tag"; +static const int + aEnet_Vlan_TagMustList[] = { + INDEX_OPT_ENET_VLAN, NO_EQUIVALENT }; +#define ENET_VLAN_TAG_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Enet_Vlan_Cfi option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zEnet_Vlan_CfiText[] = + "Specify the ethernet 802.1q VLAN CFI value"; +tSCC zEnet_Vlan_Cfi_NAME[] = "ENET_VLAN_CFI"; +tSCC zEnet_Vlan_Cfi_Name[] = "enet-vlan-cfi"; +static const int + aEnet_Vlan_CfiMustList[] = { + INDEX_OPT_ENET_VLAN, NO_EQUIVALENT }; +#define ENET_VLAN_CFI_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Enet_Vlan_Pri option description with + * "Must also have options" and "Incompatible options": + */ +tSCC zEnet_Vlan_PriText[] = + "Specify the ethernet 802.1q VLAN priority"; +tSCC zEnet_Vlan_Pri_NAME[] = "ENET_VLAN_PRI"; +tSCC zEnet_Vlan_Pri_Name[] = "enet-vlan-pri"; +static const int + aEnet_Vlan_PriMustList[] = { + INDEX_OPT_ENET_VLAN, NO_EQUIVALENT }; +#define ENET_VLAN_PRI_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Hdlc_Control option description: + */ +tSCC zHdlc_ControlText[] = + "Specify HDLC control value"; +tSCC zHdlc_Control_NAME[] = "HDLC_CONTROL"; +tSCC zHdlc_Control_Name[] = "hdlc-control"; +#define HDLC_CONTROL_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * Hdlc_Address option description: + */ +tSCC zHdlc_AddressText[] = + "Specify HDLC address"; +tSCC zHdlc_Address_NAME[] = "HDLC_ADDRESS"; +tSCC zHdlc_Address_Name[] = "hdlc-address"; +#define HDLC_ADDRESS_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * User_Dlt option description: + */ +tSCC zUser_DltText[] = + "Set output file DLT type"; +tSCC zUser_Dlt_NAME[] = "USER_DLT"; +tSCC zUser_Dlt_Name[] = "user-dlt"; +#define USER_DLT_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +/* + * User_Dlink option description: + */ +tSCC zUser_DlinkText[] = + "Rewrite Data-Link layer with user specified data"; +tSCC zUser_Dlink_NAME[] = "USER_DLINK"; +tSCC zUser_Dlink_Name[] = "user-dlink"; +#define USER_DLINK_FLAGS (OPTST_DISABLED | OPTST_STACKED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Dbug option description: + */ +#ifdef DEBUG +tSCC zDbugText[] = + "Enable debugging output"; +tSCC zDbug_NAME[] = "DBUG"; +tSCC zDbug_Name[] = "dbug"; +#define zDbugDefaultArg ((char const*)0) +#define DBUG_FLAGS (OPTST_DISABLED | OPTST_IMM \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC)) + +#else /* disable Dbug */ +#define VALUE_OPT_DBUG NO_EQUIVALENT +#define DBUG_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zDbugDefaultArg NULL +#define zDbugText NULL +#define zDbug_NAME NULL +#define zDbug_Name NULL +#endif /* DEBUG */ + +/* + * Infile option description: + */ +tSCC zInfileText[] = + "Input pcap file to be processed"; +tSCC zInfile_NAME[] = "INFILE"; +tSCC zInfile_Name[] = "infile"; +#define INFILE_FLAGS (OPTST_DISABLED | OPTST_MUST_SET | OPTST_IMM \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Outfile option description: + */ +tSCC zOutfileText[] = + "Output pcap file"; +tSCC zOutfile_NAME[] = "OUTFILE"; +tSCC zOutfile_Name[] = "outfile"; +#define OUTFILE_FLAGS (OPTST_DISABLED | OPTST_MUST_SET \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Cachefile option description: + */ +tSCC zCachefileText[] = + "Split traffic via tcpprep cache file"; +tSCC zCachefile_NAME[] = "CACHEFILE"; +tSCC zCachefile_Name[] = "cachefile"; +#define CACHEFILE_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +/* + * Verbose option description: + */ +#ifdef ENABLE_VERBOSE +tSCC zVerboseText[] = + "Print decoded packets via tcpdump to STDOUT"; +tSCC zVerbose_NAME[] = "VERBOSE"; +tSCC zVerbose_Name[] = "verbose"; +#define VERBOSE_FLAGS (OPTST_DISABLED | OPTST_IMM) + +#else /* disable Verbose */ +#define VALUE_OPT_VERBOSE NO_EQUIVALENT +#define VERBOSE_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zVerboseText NULL +#define zVerbose_NAME NULL +#define zVerbose_Name NULL +#endif /* ENABLE_VERBOSE */ + +/* + * Decode option description with + * "Must also have options" and "Incompatible options": + */ +#ifdef ENABLE_VERBOSE +tSCC zDecodeText[] = + "Arguments passed to tcpdump decoder"; +tSCC zDecode_NAME[] = "DECODE"; +tSCC zDecode_Name[] = "decode"; +static const int + aDecodeMustList[] = { + INDEX_OPT_VERBOSE, NO_EQUIVALENT }; +#define DECODE_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +#else /* disable Decode */ +#define VALUE_OPT_DECODE NO_EQUIVALENT +#define DECODE_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define aDecodeMustList NULL +#define zDecodeText NULL +#define zDecode_NAME NULL +#define zDecode_Name NULL +#endif /* ENABLE_VERBOSE */ + +/* + * Fragroute option description: + */ +#ifdef ENABLE_FRAGROUTE +tSCC zFragrouteText[] = + "Parse fragroute configuration file"; +tSCC zFragroute_NAME[] = "FRAGROUTE"; +tSCC zFragroute_Name[] = "fragroute"; +#define FRAGROUTE_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +#else /* disable Fragroute */ +#define VALUE_OPT_FRAGROUTE NO_EQUIVALENT +#define FRAGROUTE_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define zFragrouteText NULL +#define zFragroute_NAME NULL +#define zFragroute_Name NULL +#endif /* ENABLE_FRAGROUTE */ + +/* + * Fragdir option description with + * "Must also have options" and "Incompatible options": + */ +#ifdef ENABLE_FRAGROUTE +tSCC zFragdirText[] = + "Which flows to apply fragroute to: c2s, s2c, both"; +tSCC zFragdir_NAME[] = "FRAGDIR"; +tSCC zFragdir_Name[] = "fragdir"; +static const int + aFragdirMustList[] = { + INDEX_OPT_CACHEFILE, NO_EQUIVALENT }; +#define FRAGDIR_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + +#else /* disable Fragdir */ +#define VALUE_OPT_FRAGDIR NO_EQUIVALENT +#define FRAGDIR_FLAGS (OPTST_OMITTED | OPTST_NO_INIT) +#define aFragdirMustList NULL +#define zFragdirText NULL +#define zFragdir_NAME NULL +#define zFragdir_Name NULL +#endif /* ENABLE_FRAGROUTE */ + +/* + * Skip_Soft_Errors option description: + */ +tSCC zSkip_Soft_ErrorsText[] = + "Skip writing packets with soft errors"; +tSCC zSkip_Soft_Errors_NAME[] = "SKIP_SOFT_ERRORS"; +tSCC zSkip_Soft_Errors_Name[] = "skip-soft-errors"; +#define SKIP_SOFT_ERRORS_FLAGS (OPTST_DISABLED) + +/* + * Version option description: + */ +tSCC zVersionText[] = + "Print version information"; +tSCC zVersion_NAME[] = "VERSION"; +tSCC zVersion_Name[] = "version"; +#define VERSION_FLAGS (OPTST_DISABLED) + +/* + * Less_Help option description: + */ +tSCC zLess_HelpText[] = + "Display less usage information and exit"; +tSCC zLess_Help_NAME[] = "LESS_HELP"; +tSCC zLess_Help_Name[] = "less-help"; +#define LESS_HELP_FLAGS (OPTST_DISABLED | OPTST_IMM) + +/* + * Help/More_Help option descriptions: + */ +tSCC zHelpText[] = "Display usage information and exit"; +tSCC zHelp_Name[] = "help"; +tSCC zMore_HelpText[] = "Extended usage information passed thru pager"; +tSCC zMore_Help_Name[] = "more-help"; +tSCC zSave_OptsText[] = "Save the option state to a config file"; +tSCC zSave_Opts_Name[] = "save-opts"; +tSCC zLoad_OptsText[] = "Load options from a config file"; +tSCC zLoad_Opts_NAME[] = "LOAD_OPTS"; +tSCC zNotLoad_Opts_Name[] = "no-load-opts"; +tSCC zNotLoad_Opts_Pfx[] = "no"; +#define zLoad_Opts_Name (zNotLoad_Opts_Name + 3) +/* + * Declare option callback procedures + */ +#ifdef DEBUG + static tOptProc doOptDbug; +#else /* not DEBUG */ +# define doOptDbug NULL +#endif /* def/not DEBUG */ +extern tOptProc + optionNumericVal, optionPagedUsage, optionStackArg; +static tOptProc + doOptCachefile, doOptEnet_Vlan_Cfi, doOptEnet_Vlan_Pri, + doOptEnet_Vlan_Tag, doOptFlowlabel, doOptLess_Help, + doOptMtu, doOptTclass, doOptTos, + doOptVersion, doUsageOpt; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Define the Tcprewrite Option Descriptions. + */ +static tOptDesc optDesc[ OPTION_CT ] = { + { /* entry idx, value */ 0, 0, + /* equiv idx, value */ 0, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 0, 0, + /* opt state flags */ TCPEDIT_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zTcpeditText, NULL, NULL, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 1, VALUE_OPT_PORTMAP, + /* equiv idx, value */ 1, VALUE_OPT_PORTMAP, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, -1, 0, + /* opt state flags */ PORTMAP_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionStackArg, + /* desc, NAME, name */ zPortmapText, zPortmap_NAME, zPortmap_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 2, VALUE_OPT_SEED, + /* equiv idx, value */ 2, VALUE_OPT_SEED, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ SEED_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionNumericVal, + /* desc, NAME, name */ zSeedText, zSeed_NAME, zSeed_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 3, VALUE_OPT_PNAT, + /* equiv idx, value */ 3, VALUE_OPT_PNAT, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 2, 0, + /* opt state flags */ PNAT_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aPnatCantList, + /* option proc */ optionStackArg, + /* desc, NAME, name */ zPnatText, zPnat_NAME, zPnat_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 4, VALUE_OPT_SRCIPMAP, + /* equiv idx, value */ 4, VALUE_OPT_SRCIPMAP, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ SRCIPMAP_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aSrcipmapCantList, + /* option proc */ NULL, + /* desc, NAME, name */ zSrcipmapText, zSrcipmap_NAME, zSrcipmap_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 5, VALUE_OPT_DSTIPMAP, + /* equiv idx, value */ 5, VALUE_OPT_DSTIPMAP, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ DSTIPMAP_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, aDstipmapCantList, + /* option proc */ NULL, + /* desc, NAME, name */ zDstipmapText, zDstipmap_NAME, zDstipmap_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 6, VALUE_OPT_ENDPOINTS, + /* equiv idx, value */ 6, VALUE_OPT_ENDPOINTS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ ENDPOINTS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aEndpointsMustList, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zEndpointsText, zEndpoints_NAME, zEndpoints_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 7, VALUE_OPT_SKIPBROADCAST, + /* equiv idx, value */ 7, VALUE_OPT_SKIPBROADCAST, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ SKIPBROADCAST_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zSkipbroadcastText, zSkipbroadcast_NAME, zSkipbroadcast_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 8, VALUE_OPT_FIXCSUM, + /* equiv idx, value */ 8, VALUE_OPT_FIXCSUM, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ FIXCSUM_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zFixcsumText, zFixcsum_NAME, zFixcsum_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 9, VALUE_OPT_MTU, + /* equiv idx, value */ 9, VALUE_OPT_MTU, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ MTU_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptMtu, + /* desc, NAME, name */ zMtuText, zMtu_NAME, zMtu_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 10, VALUE_OPT_MTU_TRUNC, + /* equiv idx, value */ 10, VALUE_OPT_MTU_TRUNC, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ MTU_TRUNC_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zMtu_TruncText, zMtu_Trunc_NAME, zMtu_Trunc_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 11, VALUE_OPT_EFCS, + /* equiv idx, value */ 11, VALUE_OPT_EFCS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ EFCS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zEfcsText, zEfcs_NAME, zEfcs_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 12, VALUE_OPT_TTL, + /* equiv idx, value */ 12, VALUE_OPT_TTL, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ TTL_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zTtlText, zTtl_NAME, zTtl_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 13, VALUE_OPT_TOS, + /* equiv idx, value */ 13, VALUE_OPT_TOS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ TOS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptTos, + /* desc, NAME, name */ zTosText, zTos_NAME, zTos_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 14, VALUE_OPT_TCLASS, + /* equiv idx, value */ 14, VALUE_OPT_TCLASS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ TCLASS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptTclass, + /* desc, NAME, name */ zTclassText, zTclass_NAME, zTclass_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 15, VALUE_OPT_FLOWLABEL, + /* equiv idx, value */ 15, VALUE_OPT_FLOWLABEL, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ FLOWLABEL_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptFlowlabel, + /* desc, NAME, name */ zFlowlabelText, zFlowlabel_NAME, zFlowlabel_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 16, VALUE_OPT_FIXLEN, + /* equiv idx, value */ 16, VALUE_OPT_FIXLEN, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ FIXLEN_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zFixlenText, zFixlen_NAME, zFixlen_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 17, VALUE_OPT_SKIPL2BROADCAST, + /* equiv idx, value */ 17, VALUE_OPT_SKIPL2BROADCAST, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ SKIPL2BROADCAST_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zSkipl2broadcastText, zSkipl2broadcast_NAME, zSkipl2broadcast_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 18, VALUE_OPT_DLT, + /* equiv idx, value */ 18, VALUE_OPT_DLT, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ DLT_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zDltText, zDlt_NAME, zDlt_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 19, VALUE_OPT_ENET_DMAC, + /* equiv idx, value */ 19, VALUE_OPT_ENET_DMAC, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ ENET_DMAC_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zEnet_DmacText, zEnet_Dmac_NAME, zEnet_Dmac_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 20, VALUE_OPT_ENET_SMAC, + /* equiv idx, value */ 20, VALUE_OPT_ENET_SMAC, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ ENET_SMAC_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zEnet_SmacText, zEnet_Smac_NAME, zEnet_Smac_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 21, VALUE_OPT_ENET_VLAN, + /* equiv idx, value */ 21, VALUE_OPT_ENET_VLAN, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ ENET_VLAN_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zEnet_VlanText, zEnet_Vlan_NAME, zEnet_Vlan_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 22, VALUE_OPT_ENET_VLAN_TAG, + /* equiv idx, value */ 22, VALUE_OPT_ENET_VLAN_TAG, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ ENET_VLAN_TAG_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aEnet_Vlan_TagMustList, NULL, + /* option proc */ doOptEnet_Vlan_Tag, + /* desc, NAME, name */ zEnet_Vlan_TagText, zEnet_Vlan_Tag_NAME, zEnet_Vlan_Tag_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 23, VALUE_OPT_ENET_VLAN_CFI, + /* equiv idx, value */ 23, VALUE_OPT_ENET_VLAN_CFI, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ ENET_VLAN_CFI_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aEnet_Vlan_CfiMustList, NULL, + /* option proc */ doOptEnet_Vlan_Cfi, + /* desc, NAME, name */ zEnet_Vlan_CfiText, zEnet_Vlan_Cfi_NAME, zEnet_Vlan_Cfi_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 24, VALUE_OPT_ENET_VLAN_PRI, + /* equiv idx, value */ 24, VALUE_OPT_ENET_VLAN_PRI, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ ENET_VLAN_PRI_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aEnet_Vlan_PriMustList, NULL, + /* option proc */ doOptEnet_Vlan_Pri, + /* desc, NAME, name */ zEnet_Vlan_PriText, zEnet_Vlan_Pri_NAME, zEnet_Vlan_Pri_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 25, VALUE_OPT_HDLC_CONTROL, + /* equiv idx, value */ 25, VALUE_OPT_HDLC_CONTROL, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ HDLC_CONTROL_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionNumericVal, + /* desc, NAME, name */ zHdlc_ControlText, zHdlc_Control_NAME, zHdlc_Control_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 26, VALUE_OPT_HDLC_ADDRESS, + /* equiv idx, value */ 26, VALUE_OPT_HDLC_ADDRESS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ HDLC_ADDRESS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionNumericVal, + /* desc, NAME, name */ zHdlc_AddressText, zHdlc_Address_NAME, zHdlc_Address_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 27, VALUE_OPT_USER_DLT, + /* equiv idx, value */ 27, VALUE_OPT_USER_DLT, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ USER_DLT_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionNumericVal, + /* desc, NAME, name */ zUser_DltText, zUser_Dlt_NAME, zUser_Dlt_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 28, VALUE_OPT_USER_DLINK, + /* equiv idx, value */ 28, VALUE_OPT_USER_DLINK, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 2, 0, + /* opt state flags */ USER_DLINK_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionStackArg, + /* desc, NAME, name */ zUser_DlinkText, zUser_Dlink_NAME, zUser_Dlink_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 29, VALUE_OPT_DBUG, + /* equiv idx, value */ 29, VALUE_OPT_DBUG, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ DBUG_FLAGS, 0, + /* last opt argumnt */ { zDbugDefaultArg }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptDbug, + /* desc, NAME, name */ zDbugText, zDbug_NAME, zDbug_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 30, VALUE_OPT_INFILE, + /* equiv idx, value */ 30, VALUE_OPT_INFILE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 1, 1, 0, + /* opt state flags */ INFILE_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zInfileText, zInfile_NAME, zInfile_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 31, VALUE_OPT_OUTFILE, + /* equiv idx, value */ 31, VALUE_OPT_OUTFILE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 1, 1, 0, + /* opt state flags */ OUTFILE_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zOutfileText, zOutfile_NAME, zOutfile_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 32, VALUE_OPT_CACHEFILE, + /* equiv idx, value */ 32, VALUE_OPT_CACHEFILE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ CACHEFILE_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptCachefile, + /* desc, NAME, name */ zCachefileText, zCachefile_NAME, zCachefile_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 33, VALUE_OPT_VERBOSE, + /* equiv idx, value */ 33, VALUE_OPT_VERBOSE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ VERBOSE_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zVerboseText, zVerbose_NAME, zVerbose_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 34, VALUE_OPT_DECODE, + /* equiv idx, value */ 34, VALUE_OPT_DECODE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ DECODE_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aDecodeMustList, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zDecodeText, zDecode_NAME, zDecode_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 35, VALUE_OPT_FRAGROUTE, + /* equiv idx, value */ 35, VALUE_OPT_FRAGROUTE, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ FRAGROUTE_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zFragrouteText, zFragroute_NAME, zFragroute_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 36, VALUE_OPT_FRAGDIR, + /* equiv idx, value */ 36, VALUE_OPT_FRAGDIR, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ FRAGDIR_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ aFragdirMustList, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zFragdirText, zFragdir_NAME, zFragdir_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 37, VALUE_OPT_SKIP_SOFT_ERRORS, + /* equiv idx, value */ 37, VALUE_OPT_SKIP_SOFT_ERRORS, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ SKIP_SOFT_ERRORS_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zSkip_Soft_ErrorsText, zSkip_Soft_Errors_NAME, zSkip_Soft_Errors_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 38, VALUE_OPT_VERSION, + /* equiv idx, value */ 38, VALUE_OPT_VERSION, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ VERSION_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptVersion, + /* desc, NAME, name */ zVersionText, zVersion_NAME, zVersion_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 39, VALUE_OPT_LESS_HELP, + /* equiv idx, value */ 39, VALUE_OPT_LESS_HELP, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ LESS_HELP_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doOptLess_Help, + /* desc, NAME, name */ zLess_HelpText, zLess_Help_NAME, zLess_Help_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ doUsageOpt, + /* desc, NAME, name */ zHelpText, NULL, zHelp_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ OPTST_IMM | OPTST_NO_INIT, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionPagedUsage, + /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, 1, 0, + /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) + | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ NULL, + /* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS, + /* equiv idx value */ NO_EQUIVALENT, 0, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, NOLIMIT, 0, + /* opt state flags */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) + | OPTST_DISABLE_IMM, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ optionLoadOpt, + /* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name, + /* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx } +}; +tOptDesc * const tcpedit_tcpedit_optDesc_p = optDesc + 0; + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Define the Tcprewrite Option Environment + */ +tSCC zPROGNAME[] = "TCPREWRITE"; +tSCC zUsageTitle[] = +"tcprewrite (tcprewrite) - Rewrite the packets in a pcap file.\n\ +USAGE: %s [ - [] | --[{=| }] ]...\n"; +tSCC zRcName[] = ".tcprewriterc"; +tSCC* apzHomeList[] = { + "$$/", + NULL }; + +#define zBugsAddr NULL +#define zExplain NULL +tSCC zDetail[] = "\n\ +Tcprewrite is a tool to rewrite packets stored in ``pcap(3)'' file format,\n\ +such as crated by tools such as ``tcpdump(1)'' and ``ethereal(1)''.\n\ +Once a pcap file has had it's packets rewritten, they can be replayed back\n\ +out on the network using ``tcpreplay(1)''.\n\n\ +tcprewrite currently supports reading the following DLT types:\n\n\n\ +``DLT_C_HDLC'' aka Cisco HDLC\n\n\n\ +``DLT_EN10MB'' aka Ethernet\n\n\n\ +``DLT_LINUX_SLL'' aka Linux Cooked Socket\n\n\n\ +``DLT_RAW'' aka RAW IP\n\n\n\ +``DLT_NULL'' aka BSD Loopback\n\n\n\ +``DLT_LOOP'' aka OpenBSD Loopback\n\n\n\ +``DLT_IEEE802_11'' aka 802.11a/b/g\n\n\n\ +``DLT_IEEE802_11_RADIO'' aka 802.11a/b/g with Radiotap headers\n\n\ +Please see the --dlt option for supported DLT types for writing.\n\n\ +The packet editing features of tcprewrite which distinguish between \"client\"\n\ +and \"server\" traffic requires a tcpprep(1) cache file.\n\n\ +For more details, please see the Tcpreplay Manual at:\n\ +http://tcpreplay.synfin.net/trac/wiki/manual\n"; +#define zFullVersion NULL +/* extracted from /usr/local/share/autogen/optcode.tpl near line 501 */ + +#if defined(ENABLE_NLS) +# define OPTPROC_BASE OPTPROC_TRANSLATE + static tOptionXlateProc translate_option_strings; +#else +# define OPTPROC_BASE OPTPROC_NONE +# define translate_option_strings NULL +#endif /* ENABLE_NLS */ + + +#define tcprewrite_full_usage NULL +#define tcprewrite_short_usage NULL +tOptions tcprewriteOptions = { + OPTIONS_STRUCT_VERSION, + 0, NULL, /* original argc + argv */ + ( OPTPROC_BASE + + OPTPROC_ERRSTOP + + OPTPROC_SHORTOPT + + OPTPROC_LONGOPT + + OPTPROC_NO_REQ_OPT + + OPTPROC_NO_ARGS + + OPTPROC_GNUUSAGE ), + 0, NULL, /* current option index, current option */ + NULL, NULL, zPROGNAME, + zRcName, zCopyright, zCopyrightNotice, + zFullVersion, apzHomeList, zUsageTitle, + zExplain, zDetail, optDesc, + zBugsAddr, /* address to send bugs to */ + NULL, NULL, /* extensions/saved state */ + optionUsage, /* usage procedure */ + translate_option_strings, /* translation procedure */ + /* + * Indexes to special options + */ + { INDEX_OPT_MORE_HELP, /* more-help option index */ + INDEX_OPT_SAVE_OPTS, /* save option index */ + NO_EQUIVALENT, /* '-#' option index */ + 9 /* index of default opt */ + }, + 44 /* full option count */, 40 /* user option count */, + tcprewrite_full_usage, tcprewrite_short_usage, + NULL, NULL +}; + +/* + * Create the static procedure(s) declared above. + */ +static void +doUsageOpt( + tOptions* pOptions, + tOptDesc* pOptDesc ) +{ + (void)pOptions; + USAGE( EXIT_SUCCESS ); +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the mtu option. + */ +static void +doOptMtu(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 1, MAXPACKET } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the tos option. + */ +static void +doOptTos(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 0, 255 } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the tclass option. + */ +static void +doOptTclass(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 0, 255 } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the flowlabel option. + */ +static void +doOptFlowlabel(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 0, 1048575 } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the enet-vlan-tag option. + */ +static void +doOptEnet_Vlan_Tag(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 0, 4095 } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the enet-vlan-cfi option. + */ +static void +doOptEnet_Vlan_Cfi(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 0, 1 } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the enet-vlan-pri option. + */ +static void +doOptEnet_Vlan_Pri(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 0, 7 } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the dbug option, when DEBUG is #define-d. + */ +#ifdef DEBUG +static void +doOptDbug(tOptions* pOptions, tOptDesc* pOptDesc) +{ + static const struct {long const rmin, rmax;} rng[1] = { + { 0, 5 } }; + long val; + int ix; + char * pzEnd; + + if (pOptions <= OPTPROC_EMIT_LIMIT) + goto emit_ranges; + + errno = 0; + val = strtol(pOptDesc->optArg.argString, &pzEnd, 0); + if ((pOptDesc->optArg.argString == pzEnd) || (errno != 0)) + goto bad_value; + + if (*pzEnd != '\0') + goto bad_value; + for (ix = 0; ix < 1; ix++) { + if (val < rng[ix].rmin) + continue; /* ranges need not be ordered. */ + if (val == rng[ix].rmin) + goto valid_return; + if (rng[ix].rmax == LONG_MIN) + continue; + if (val <= rng[ix].rmax) + goto valid_return; + } + + bad_value: + + option_usage_fp = stderr; + + emit_ranges: + optionShowRange(pOptions, pOptDesc, (void *)rng, 1); + return; + + valid_return: + if ((pOptDesc->fOptState & OPTST_ALLOC_ARG) != 0) { + free((void *)pOptDesc->optArg.argString); + pOptDesc->fOptState &= ~OPTST_ALLOC_ARG; + } + pOptDesc->optArg.argInt = val; +} +#endif /* defined DEBUG */ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the cachefile option. + */ +static void +doOptCachefile(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcprewrite_opts.def, line 128 */ + + options.cache_packets = + read_cache(&options.cachedata, OPT_ARG(CACHEFILE), &options.comment); + +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the version option. + */ +static void +doOptVersion(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcprewrite_opts.def, line 219 */ + + fprintf(stderr, "tcprewrite version: %s (build %s)", VERSION, svn_version()); +#ifdef DEBUG + fprintf(stderr, " (debug)"); +#endif + fprintf(stderr, "\n"); + fprintf(stderr, "Copyright 2000-2010 by Aaron Turner \n"); + fprintf(stderr, "Cache file supported: %s\n", CACHEVERSION); +#ifdef HAVE_LIBDNET + fprintf(stderr, "Compiled against libdnet: %s\n", LIBDNET_VERSION); +#else + fprintf(stderr, "Not compiled with libdnet.\n"); +#endif +#ifdef HAVE_WINPCAP + fprintf(stderr, "Compiled against winpcap: %s\n", get_pcap_version()); +#else + fprintf(stderr, "Compiled against libpcap: %s\n", get_pcap_version()); +#endif +#ifdef ENABLE_64BITS + fprintf(stderr, "64 bit packet counters: enabled\n"); +#else + fprintf(stderr, "64 bit packet counters: disabled\n"); +#endif +#ifdef ENABLE_VERBOSE + fprintf(stderr, "Verbose printing via tcpdump: enabled\n"); +#else + fprintf(stderr, "Verbose printing via tcpdump: disabled\n"); +#endif +#ifdef ENABLE_FRAGROUTE + fprintf(stderr, "Fragroute engine: enabled\n"); +#else + fprintf(stderr, "Fragroute engine: disabled\n"); +#endif + exit(0); + +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the less-help option. + */ +static void +doOptLess_Help(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from tcprewrite_opts.def, line 264 */ + + USAGE(EXIT_FAILURE); + +} +/* extracted from /usr/local/share/autogen/optcode.tpl near line 633 */ + +#if ENABLE_NLS +#include +#include +#include +#include +#include + +static char* AO_gettext( char const* pz ); +static void coerce_it(void** s); + +static char* +AO_gettext( char const* pz ) +{ + char* pzRes; + if (pz == NULL) + return NULL; + pzRes = _(pz); + if (pzRes == pz) + return pzRes; + pzRes = strdup( pzRes ); + if (pzRes == NULL) { + fputs( _("No memory for duping translated strings\n"), stderr ); + exit( EXIT_FAILURE ); + } + return pzRes; +} + +static void coerce_it(void** s) { *s = AO_gettext(*s); } +#define COERSION(_f) \ + coerce_it((void*)&(tcprewriteOptions._f)) + +/* + * This invokes the translation code (e.g. gettext(3)). + */ +static void +translate_option_strings( void ) +{ + /* + * Guard against re-translation. It won't work. The strings will have + * been changed by the first pass through this code. One shot only. + */ + if (option_usage_text.field_ct != 0) { + + /* + * Do the translations. The first pointer follows the field count + * field. The field count field is the size of a pointer. + */ + tOptDesc* pOD = tcprewriteOptions.pOptDesc; + char** ppz = (char**)(void*)&(option_usage_text); + int ix = option_usage_text.field_ct; + + do { + ppz++; + *ppz = AO_gettext(*ppz); + } while (--ix > 0); + + COERSION(pzCopyright); + COERSION(pzCopyNotice); + COERSION(pzFullVersion); + COERSION(pzUsageTitle); + COERSION(pzExplain); + COERSION(pzDetail); + option_usage_text.field_ct = 0; + + for (ix = tcprewriteOptions.optCt; ix > 0; ix--, pOD++) + coerce_it((void*)&(pOD->pzText)); + } + + if ((tcprewriteOptions.fOptSet & OPTPROC_NXLAT_OPT_CFG) == 0) { + tOptDesc* pOD = tcprewriteOptions.pOptDesc; + int ix; + + for (ix = tcprewriteOptions.optCt; ix > 0; ix--, pOD++) { + coerce_it((void*)&(pOD->pz_Name)); + coerce_it((void*)&(pOD->pz_DisableName)); + coerce_it((void*)&(pOD->pz_DisablePfx)); + } + /* prevent re-translation */ + tcprewriteOptions.fOptSet |= OPTPROC_NXLAT_OPT_CFG | OPTPROC_NXLAT_OPT; + } +} + +#endif /* ENABLE_NLS */ + +#ifdef __cplusplus +} +#endif +/* tcprewrite_opts.c ends here */ diff --git a/src/tcprewrite_opts.def b/src/tcprewrite_opts.def new file mode 100644 index 0000000..d822f2a --- /dev/null +++ b/src/tcprewrite_opts.def @@ -0,0 +1,269 @@ +autogen definitions options; + +copyright = { + date = "2000-2010"; + owner = "Aaron Turner"; + type = "bsd"; + author = <<- EOText +Copyright 2000-2010 Aaron Turner + +For support please use the tcpreplay-users@lists.sourceforge.net mailing list. + +The latest version of this software is always available from: +http://tcpreplay.synfin.net/ +EOText; +}; + +package = "tcprewrite"; +prog-name = "tcprewrite"; +prog-title = "Rewrite the packets in a pcap file."; +long-opts; +gnu-usage; +help-value = "H"; +save-opts-value = ""; +load-opts-value = ""; +config-header = "config.h"; + +#include tcpedit/tcpedit_opts.def + +detail = <<- EOText +Tcprewrite is a tool to rewrite packets stored in @file{pcap(3)} file format, +such as crated by tools such as @file{tcpdump(1)} and @file{ethereal(1)}. +Once a pcap file has had it's packets rewritten, they can be replayed back +out on the network using @file{tcpreplay(1)}. + +tcprewrite currently supports reading the following DLT types: +@item +@var{DLT_C_HDLC} aka Cisco HDLC +@item +@var{DLT_EN10MB} aka Ethernet +@item +@var{DLT_LINUX_SLL} aka Linux Cooked Socket +@item +@var{DLT_RAW} aka RAW IP +@item +@var{DLT_NULL} aka BSD Loopback +@item +@var{DLT_LOOP} aka OpenBSD Loopback +@item +@var{DLT_IEEE802_11} aka 802.11a/b/g +@item +@var{DLT_IEEE802_11_RADIO} aka 802.11a/b/g with Radiotap headers + +Please see the --dlt option for supported DLT types for writing. + +The packet editing features of tcprewrite which distinguish between "client" +and "server" traffic requires a tcpprep(1) cache file. + +For more details, please see the Tcpreplay Manual at: +http://tcpreplay.synfin.net/trac/wiki/manual +EOText; + +man-doc = <<- EOMan +.SH "SEE ALSO" +tcpdump(1), tcpprep(1), tcpreplay(1) +EOMan; + + +config-header = "config.h"; +include = "#include \"defines.h\"\n" + "#include \"common.h\"\n" + "#include \"config.h\"\n" + "#include \"tcprewrite.h\"\n" + "#include \n" + "#include \n" + "extern tcprewrite_opt_t options;\n"; + +homerc = "$$/"; + +flag = { + ifdef = DEBUG; + name = dbug; + value = d; + arg-type = number; + descrip = "Enable debugging output"; + arg-range = "0->5"; + arg-default = 0; + max = 1; + immediate; + doc = <<- EOText +If configured with --enable-debug, then you can specify a verbosity +level for debugging output. Higher numbers increase verbosity. +EOText; +}; + + +flag = { + name = infile; + value = i; + arg-type = string; + descrip = "Input pcap file to be processed"; + max = 1; + immediate; + must-set; + doc = ""; +}; + +flag = { + name = outfile; + value = o; + arg-type = string; + descrip = "Output pcap file"; + max = 1; + must-set; + doc = ""; + /* options.outfile is set in post_args, because we need to make + * sure that options.infile is processed first + */ +}; + +flag = { + name = cachefile; + value = c; + arg-type = string; + max = 1; + descrip = "Split traffic via tcpprep cache file"; + settable; + flag-code = <<- EOCachefile + + options.cache_packets = + read_cache(&options.cachedata, OPT_ARG(CACHEFILE), &options.comment); + +EOCachefile; + doc = <<- EOText +Use tcpprep cache file to split traffic based upon client/server relationships. +EOText; +}; + + +/* Verbose decoding via tcpdump */ + +flag = { + ifdef = ENABLE_VERBOSE; + name = verbose; + value = v; + max = 1; + immediate; + descrip = "Print decoded packets via tcpdump to STDOUT"; + settable; + doc = ""; +}; + +flag = { + ifdef = ENABLE_VERBOSE; + name = decode; + flags-must = verbose; + value = A; + arg-type = string; + max = 1; + descrip = "Arguments passed to tcpdump decoder"; + doc = <<- EOText +When enabling verbose mode (@var{-v}) you may also specify one or +more additional arguments to pass to @code{tcpdump} to modify +the way packets are decoded. By default, -n and -l are used. +Be sure to quote the arguments so that they are not interpreted +by tcprewrite. Please see the tcpdump(1) man page for a complete list of +options. +EOText; +}; + + +/* Fragroute */ +flag = { + ifdef = ENABLE_FRAGROUTE; + name = fragroute; + arg-type = string; + max = 1; + descrip = "Parse fragroute configuration file"; + doc = <<- EOText +Enable advanced evasion techniques using the built-in fragroute(8) +engine. See the fragroute(8) man page for more details. Important: +tcprewrite does not support the delay, echo or print commands. +EOText; +}; + + +flag = { + ifdef = ENABLE_FRAGROUTE; + name = fragdir; + flags-must = cachefile; + arg-type = string; + max = 1; + descrip = "Which flows to apply fragroute to: c2s, s2c, both"; + doc = <<- EOText +Apply the fragroute engine to packets going c2s, s2c or both when +using a cache file. +EOText; +}; + +flag = { + name = skip-soft-errors; + max = 1; + descrip = "Skip writing packets with soft errors"; + doc = <<- EOText +In some cases, packets can't be decoded or the requested editing +is not possible. Normally these packets are written to the output +file unedited so that tcpprep cache files can still be used, but if +you wish, these packets can be suppressed. + +One example of this is 802.11 management frames which contain no data. +EOText; +}; + + +flag = { + name = version; + value = V; + descrip = "Print version information"; + flag-code = <<- EOVersion + + fprintf(stderr, "tcprewrite version: %s (build %s)", VERSION, svn_version()); +#ifdef DEBUG + fprintf(stderr, " (debug)"); +#endif + fprintf(stderr, "\n"); + fprintf(stderr, "Copyright 2000-2010 by Aaron Turner \n"); + fprintf(stderr, "Cache file supported: %s\n", CACHEVERSION); +#ifdef HAVE_LIBDNET + fprintf(stderr, "Compiled against libdnet: %s\n", LIBDNET_VERSION); +#else + fprintf(stderr, "Not compiled with libdnet.\n"); +#endif +#ifdef HAVE_WINPCAP + fprintf(stderr, "Compiled against winpcap: %s\n", get_pcap_version()); +#else + fprintf(stderr, "Compiled against libpcap: %s\n", get_pcap_version()); +#endif +#ifdef ENABLE_64BITS + fprintf(stderr, "64 bit packet counters: enabled\n"); +#else + fprintf(stderr, "64 bit packet counters: disabled\n"); +#endif +#ifdef ENABLE_VERBOSE + fprintf(stderr, "Verbose printing via tcpdump: enabled\n"); +#else + fprintf(stderr, "Verbose printing via tcpdump: disabled\n"); +#endif +#ifdef ENABLE_FRAGROUTE + fprintf(stderr, "Fragroute engine: enabled\n"); +#else + fprintf(stderr, "Fragroute engine: disabled\n"); +#endif + exit(0); + +EOVersion; + doc = ""; +}; + +flag = { + name = less-help; + value = h; + immediate; + descrip = "Display less usage information and exit"; + flag-code = <<- EOHelp + + USAGE(EXIT_FAILURE); + +EOHelp; + doc = ""; +}; diff --git a/src/tcprewrite_opts.h b/src/tcprewrite_opts.h new file mode 100644 index 0000000..33f01fa --- /dev/null +++ b/src/tcprewrite_opts.h @@ -0,0 +1,294 @@ +/* -*- buffer-read-only: t -*- vi: set ro: + * + * DO NOT EDIT THIS FILE (tcprewrite_opts.h) + * + * It has been AutoGen-ed April 4, 2010 at 05:59:19 PM by AutoGen 5.9.9 + * From the definitions tcprewrite_opts.def + * and the template file options + * + * Generated from AutoOpts 32:2:7 templates. + */ + +/* + * This file was produced by an AutoOpts template. AutoOpts is a + * copyrighted work. This header file is not encumbered by AutoOpts + * licensing, but is provided under the licensing terms chosen by the + * tcprewrite author or copyright holder. AutoOpts is licensed under + * the terms of the LGPL. The redistributable library (``libopts'') is + * licensed under the terms of either the LGPL or, at the users discretion, + * the BSD license. See the AutoOpts and/or libopts sources for details. + * + * This source file is copyrighted and licensed under the following terms: + * + * tcprewrite copyright (c) 2000-2010 Aaron Turner - all rights reserved + * + * tcprewrite is free software copyrighted by Aaron Turner. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name ``Aaron Turner'' nor the name of any other + * contributor may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * tcprewrite IS PROVIDED BY Aaron Turner ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL Aaron Turner OR ANY OTHER CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +/* + * This file contains the programmatic interface to the Automated + * Options generated for the tcprewrite program. + * These macros are documented in the AutoGen info file in the + * "AutoOpts" chapter. Please refer to that doc for usage help. + */ +#ifndef AUTOOPTS_TCPREWRITE_OPTS_H_GUARD +#define AUTOOPTS_TCPREWRITE_OPTS_H_GUARD 1 +#include "config.h" +#include + +/* + * Ensure that the library used for compiling this generated header is at + * least as new as the version current when the header template was released + * (not counting patch version increments). Also ensure that the oldest + * tolerable version is at least as old as what was current when the header + * template was released. + */ +#define AO_TEMPLATE_VERSION 131074 +#if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \ + || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION) +# error option template version mismatches autoopts/options.h header + Choke Me. +#endif + +/* + * Enumeration of each option: + */ +typedef enum { + INDEX_OPT_PORTMAP = 1, + INDEX_OPT_SEED = 2, + INDEX_OPT_PNAT = 3, + INDEX_OPT_SRCIPMAP = 4, + INDEX_OPT_DSTIPMAP = 5, + INDEX_OPT_ENDPOINTS = 6, + INDEX_OPT_SKIPBROADCAST = 7, + INDEX_OPT_FIXCSUM = 8, + INDEX_OPT_MTU = 9, + INDEX_OPT_MTU_TRUNC = 10, + INDEX_OPT_EFCS = 11, + INDEX_OPT_TTL = 12, + INDEX_OPT_TOS = 13, + INDEX_OPT_TCLASS = 14, + INDEX_OPT_FLOWLABEL = 15, + INDEX_OPT_FIXLEN = 16, + INDEX_OPT_SKIPL2BROADCAST = 17, + INDEX_OPT_DLT = 18, + INDEX_OPT_ENET_DMAC = 19, + INDEX_OPT_ENET_SMAC = 20, + INDEX_OPT_ENET_VLAN = 21, + INDEX_OPT_ENET_VLAN_TAG = 22, + INDEX_OPT_ENET_VLAN_CFI = 23, + INDEX_OPT_ENET_VLAN_PRI = 24, + INDEX_OPT_HDLC_CONTROL = 25, + INDEX_OPT_HDLC_ADDRESS = 26, + INDEX_OPT_USER_DLT = 27, + INDEX_OPT_USER_DLINK = 28, + INDEX_OPT_DBUG = 29, + INDEX_OPT_INFILE = 30, + INDEX_OPT_OUTFILE = 31, + INDEX_OPT_CACHEFILE = 32, + INDEX_OPT_VERBOSE = 33, + INDEX_OPT_DECODE = 34, + INDEX_OPT_FRAGROUTE = 35, + INDEX_OPT_FRAGDIR = 36, + INDEX_OPT_SKIP_SOFT_ERRORS = 37, + INDEX_OPT_VERSION = 38, + INDEX_OPT_LESS_HELP = 39, + INDEX_OPT_HELP = 40, + INDEX_OPT_MORE_HELP = 41, + INDEX_OPT_SAVE_OPTS = 42, + INDEX_OPT_LOAD_OPTS = 43 +} teOptIndex; + +#define OPTION_CT 44 + +/* + * Interface defines for all options. Replace "n" with the UPPER_CASED + * option name (as in the teOptIndex enumeration above). + * e.g. HAVE_OPT( TCPEDIT ) + */ +#define DESC(n) (tcprewriteOptions.pOptDesc[INDEX_OPT_## n]) +#define HAVE_OPT(n) (! UNUSED_OPT(& DESC(n))) +#define OPT_ARG(n) (DESC(n).optArg.argString) +#define STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK) +#define COUNT_OPT(n) (DESC(n).optOccCt) +#define ISSEL_OPT(n) (SELECTED_OPT(&DESC(n))) +#define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n))) +#define ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n))) +#define STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt) +#define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs) +#define CLEAR_OPT(n) STMTS( \ + DESC(n).fOptState &= OPTST_PERSISTENT_MASK; \ + if ( (DESC(n).fOptState & OPTST_INITENABLED) == 0) \ + DESC(n).fOptState |= OPTST_DISABLED; \ + DESC(n).optCookie = NULL ) + +/* * * * * * + * + * Interface defines for specific options. + */ +#define VALUE_OPT_PORTMAP 'r' +#define VALUE_OPT_SEED 's' +#define OPT_VALUE_SEED (DESC(SEED).optArg.argInt) +#define VALUE_OPT_PNAT 'N' +#define VALUE_OPT_SRCIPMAP 'S' +#define VALUE_OPT_DSTIPMAP 'D' +#ifdef HAVE_CACHEFILE_SUPPORT +#define VALUE_OPT_ENDPOINTS 'e' +#endif /* HAVE_CACHEFILE_SUPPORT */ +#define VALUE_OPT_SKIPBROADCAST 'b' +#define VALUE_OPT_FIXCSUM 'C' +#define VALUE_OPT_MTU 'm' +#define OPT_VALUE_MTU (DESC(MTU).optArg.argInt) +#define VALUE_OPT_MTU_TRUNC 10 +#define VALUE_OPT_EFCS 'E' +#define VALUE_OPT_TTL 12 +#define VALUE_OPT_TOS 13 +#define OPT_VALUE_TOS (DESC(TOS).optArg.argInt) +#define VALUE_OPT_TCLASS 14 +#define OPT_VALUE_TCLASS (DESC(TCLASS).optArg.argInt) +#define VALUE_OPT_FLOWLABEL 15 +#define OPT_VALUE_FLOWLABEL (DESC(FLOWLABEL).optArg.argInt) +#define VALUE_OPT_FIXLEN 'F' +#define VALUE_OPT_SKIPL2BROADCAST 17 +#define VALUE_OPT_DLT 18 +#define VALUE_OPT_ENET_DMAC 19 +#define VALUE_OPT_ENET_SMAC 20 +#define VALUE_OPT_ENET_VLAN 21 +#define VALUE_OPT_ENET_VLAN_TAG 22 +#define OPT_VALUE_ENET_VLAN_TAG (DESC(ENET_VLAN_TAG).optArg.argInt) +#define VALUE_OPT_ENET_VLAN_CFI 23 +#define OPT_VALUE_ENET_VLAN_CFI (DESC(ENET_VLAN_CFI).optArg.argInt) +#define VALUE_OPT_ENET_VLAN_PRI 24 +#define OPT_VALUE_ENET_VLAN_PRI (DESC(ENET_VLAN_PRI).optArg.argInt) +#define VALUE_OPT_HDLC_CONTROL 25 +#define OPT_VALUE_HDLC_CONTROL (DESC(HDLC_CONTROL).optArg.argInt) +#define VALUE_OPT_HDLC_ADDRESS 26 +#define OPT_VALUE_HDLC_ADDRESS (DESC(HDLC_ADDRESS).optArg.argInt) +#define VALUE_OPT_USER_DLT 27 +#define OPT_VALUE_USER_DLT (DESC(USER_DLT).optArg.argInt) +#define VALUE_OPT_USER_DLINK 28 +#ifdef DEBUG +#define VALUE_OPT_DBUG 'd' +#define OPT_VALUE_DBUG (DESC(DBUG).optArg.argInt) +#endif /* DEBUG */ +#define VALUE_OPT_INFILE 'i' +#define VALUE_OPT_OUTFILE 'o' +#define VALUE_OPT_CACHEFILE 'c' +#define SET_OPT_CACHEFILE(a) STMTS( \ + DESC(CACHEFILE).optActualIndex = 32; \ + DESC(CACHEFILE).optActualValue = VALUE_OPT_CACHEFILE; \ + DESC(CACHEFILE).fOptState &= OPTST_PERSISTENT_MASK; \ + DESC(CACHEFILE).fOptState |= OPTST_SET; \ + DESC(CACHEFILE).optArg.argString = (a); \ + (*(DESC(CACHEFILE).pOptProc))( &tcprewriteOptions, \ + tcprewriteOptions.pOptDesc + 32 ); ) +#ifdef ENABLE_VERBOSE +#define VALUE_OPT_VERBOSE 'v' +#define SET_OPT_VERBOSE STMTS( \ + DESC(VERBOSE).optActualIndex = 33; \ + DESC(VERBOSE).optActualValue = VALUE_OPT_VERBOSE; \ + DESC(VERBOSE).fOptState &= OPTST_PERSISTENT_MASK; \ + DESC(VERBOSE).fOptState |= OPTST_SET ) +#endif /* ENABLE_VERBOSE */ +#ifdef ENABLE_VERBOSE +#define VALUE_OPT_DECODE 'A' +#endif /* ENABLE_VERBOSE */ +#ifdef ENABLE_FRAGROUTE +#define VALUE_OPT_FRAGROUTE 131 +#endif /* ENABLE_FRAGROUTE */ +#ifdef ENABLE_FRAGROUTE +#define VALUE_OPT_FRAGDIR 132 +#endif /* ENABLE_FRAGROUTE */ +#define VALUE_OPT_SKIP_SOFT_ERRORS 133 +#define VALUE_OPT_VERSION 'V' +#define VALUE_OPT_LESS_HELP 'h' +#define VALUE_OPT_HELP 'H' +#define VALUE_OPT_MORE_HELP '!' +#define VALUE_OPT_SAVE_OPTS INDEX_OPT_SAVE_OPTS +#define VALUE_OPT_LOAD_OPTS INDEX_OPT_LOAD_OPTS +#define SET_OPT_SAVE_OPTS(a) STMTS( \ + DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \ + DESC(SAVE_OPTS).fOptState |= OPTST_SET; \ + DESC(SAVE_OPTS).optArg.argString = (char const*)(a) ) +/* + * Interface defines not associated with particular options + */ +#define ERRSKIP_OPTERR STMTS( tcprewriteOptions.fOptSet &= ~OPTPROC_ERRSTOP ) +#define ERRSTOP_OPTERR STMTS( tcprewriteOptions.fOptSet |= OPTPROC_ERRSTOP ) +#define RESTART_OPT(n) STMTS( \ + tcprewriteOptions.curOptIdx = (n); \ + tcprewriteOptions.pzCurOpt = NULL ) +#define START_OPT RESTART_OPT(1) +#define USAGE(c) (*tcprewriteOptions.pUsageProc)( &tcprewriteOptions, c ) +/* extracted from /usr/local/share/autogen/opthead.tpl near line 409 */ + +/* * * * * * + * + * Declare the tcprewrite option descriptor. + */ +#ifdef __cplusplus +extern "C" { +#endif + +extern tOptions tcprewriteOptions; + +#if defined(ENABLE_NLS) +# ifndef _ +# include + static inline char* aoGetsText( char const* pz ) { + if (pz == NULL) return NULL; + return (char*)gettext( pz ); + } +# define _(s) aoGetsText(s) +# endif /* _() */ + +# define OPT_NO_XLAT_CFG_NAMES STMTS(tcprewriteOptions.fOptSet |= \ + OPTPROC_NXLAT_OPT_CFG;) +# define OPT_NO_XLAT_OPT_NAMES STMTS(tcprewriteOptions.fOptSet |= \ + OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG;) + +# define OPT_XLAT_CFG_NAMES STMTS(tcprewriteOptions.fOptSet &= \ + ~(OPTPROC_NXLAT_OPT|OPTPROC_NXLAT_OPT_CFG);) +# define OPT_XLAT_OPT_NAMES STMTS(tcprewriteOptions.fOptSet &= \ + ~OPTPROC_NXLAT_OPT;) + +#else /* ENABLE_NLS */ +# define OPT_NO_XLAT_CFG_NAMES +# define OPT_NO_XLAT_OPT_NAMES + +# define OPT_XLAT_CFG_NAMES +# define OPT_XLAT_OPT_NAMES + +# ifndef _ +# define _(_s) _s +# endif +#endif /* ENABLE_NLS */ + +#ifdef __cplusplus +} +#endif +#endif /* AUTOOPTS_TCPREWRITE_OPTS_H_GUARD */ +/* tcprewrite_opts.h ends here */ diff --git a/src/tree.c b/src/tree.c new file mode 100644 index 0000000..e3a5b56 --- /dev/null +++ b/src/tree.c @@ -0,0 +1,914 @@ +/* $Id: tree.c 2447 2010-03-30 18:51:12Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "defines.h" +#include "common.h" + +#include +#include +#include + +#include "tree.h" +#include "tcpprep.h" +#include "tcpprep_opts.h" + +extern tcpr_data_tree_t treeroot; +extern tcpprep_opt_t options; +#ifdef DEBUG +extern int debug; +#endif + +/* static buffer used by tree_print*() functions */ +char tree_print_buff[TREEPRINTBUFFLEN]; + +static tcpr_tree_t *new_tree(); +static tcpr_tree_t *packet2tree(const u_char *); +static char *tree_print(tcpr_data_tree_t *); +static char *tree_printnode(const char *, const tcpr_tree_t *); +static void tree_buildcidr(tcpr_data_tree_t *, tcpr_buildcidr_t *); +static int tree_checkincidr(tcpr_data_tree_t *, tcpr_buildcidr_t *); + +static int ipv6_cmp(const struct tcpr_in6_addr *a, const struct tcpr_in6_addr *b); + +RB_PROTOTYPE(tcpr_data_tree_s, tcpr_tree_s, node, tree_comp) +RB_GENERATE(tcpr_data_tree_s, tcpr_tree_s, node, tree_comp) + +/** + * used with rbwalk to walk a tree and generate cidr_t * cidrdata. + * is smart enough to prevent dupes. void * arg is cast to bulidcidr_t + */ +void +tree_buildcidr(tcpr_data_tree_t *treeroot, tcpr_buildcidr_t * bcdata) +{ + tcpr_tree_t *node = NULL; + tcpr_cidr_t *newcidr = NULL; + unsigned long network = 0; + struct tcpr_in6_addr network6; + unsigned long mask = ~0; /* turn on all bits */ + int i, j, k; + + dbg(1, "Running: tree_buildcidr()"); + + RB_FOREACH(node, tcpr_data_tree_s, treeroot) { + + /* we only check types that are vaild */ + if (bcdata->type != DIR_ANY) /* don't check if we're adding ANY */ + if (bcdata->type != node->type) /* no match, exit early */ + return; + /* + * in cases of leaves and last visit add to cidrdata if + * necessary. First check IPv4 + */ + dbgx(4, "Checking if %s exists in cidrdata...", get_addr2name4(node->u.ip, RESOLVE)); + if (node->family == AF_INET) { + if (! check_ip_cidr(options.cidrdata, node->u.ip)) { /* if we exist, abort */ + dbgx(3, "Node %s doesn't exist... creating.", + get_addr2name4(node->u.ip, RESOLVE)); + newcidr = new_cidr(); + newcidr->masklen = bcdata->masklen; + network = node->u.ip & (mask << (32 - bcdata->masklen)); + dbgx(3, "Using network: %s", get_addr2name4(network, RESOLVE)); + newcidr->u.network = network; + add_cidr(&options.cidrdata, &newcidr); + } + } + /* Check IPv6 Address */ + else if (node->family == AF_INET6) { + if (! check_ip6_cidr(options.cidrdata, &node->u.ip6)) { /* if we exist, abort */ + dbgx(3, "Node %s doesn't exist... creating.", + get_addr2name6(&node->u.ip6, RESOLVE)); + + newcidr = new_cidr(); + newcidr->masklen = bcdata->masklen; + + /* init each 4 quads to zero */ + for (i = 0; i < 4; i++) + network6.tcpr_s6_addr32[i] = 0; + + /* Build our mask */ + j = bcdata->masklen / 8; + + for (i = 0; i < j; i++) + network6.tcpr_s6_addr[i] = node->u.ip6.tcpr_s6_addr[i]; + + if ((k = bcdata->masklen % 8) != 0) { + k = ~0 << (8 - k); + network6.tcpr_s6_addr[j] = node->u.ip6.tcpr_s6_addr[i] & k; + } + + dbgx(3, "Using network: %s", get_addr2name6(&network6, RESOLVE)); + newcidr->u.network6 = network6; + add_cidr(&options.cidrdata, &newcidr); + } + } + } +} + + +/** + * uses rbwalk to check to see if a given ip address of a given type in the + * tree is inside any of the cidrdata + */ +static int +tree_checkincidr(tcpr_data_tree_t *treeroot, tcpr_buildcidr_t * bcdata) +{ + tcpr_tree_t *node = NULL; + + + RB_FOREACH(node, tcpr_data_tree_s, treeroot) { + + /* we only check types that are vaild */ + if (bcdata->type != DIR_ANY) /* don't check if we're adding ANY */ + if (bcdata->type != node->type) /* no match, exit early */ + return 0; + + /* + * in cases of leaves and last visit add to cidrdata if + * necessary + */ + if (node->family == AF_INET && check_ip_cidr(options.cidrdata, node->u.ip)) /* if we exist, abort */ + return 1; + if (node->family == AF_INET6 && check_ip6_cidr(options.cidrdata, &node->u.ip6)) + return 1; + + } + return 0; +} + +/** + * processes the tree using rbwalk / tree2cidr to generate a CIDR + * used for 2nd pass, router mode + * + * returns > 0 for success (the mask len), 0 for fail + */ +int +process_tree(void) +{ + int mymask = 0; + tcpr_buildcidr_t *bcdata; + + + dbg(1, "Running: process_tree()"); + + bcdata = (tcpr_buildcidr_t *)safe_malloc(sizeof(tcpr_buildcidr_t)); + + for (mymask = options.max_mask; mymask <= options.min_mask; mymask++) { + dbgx(1, "Current mask: %u", mymask); + + /* set starting vals */ + bcdata->type = DIR_SERVER; + bcdata->masklen = mymask; + + /* build cidrdata with servers */ + tree_buildcidr(&treeroot, bcdata); + + /* calculate types of all IP's */ + tree_calculate(&treeroot); + + /* try to find clients in cidrdata */ + bcdata->type = DIR_CLIENT; + + if (! tree_checkincidr(&treeroot, bcdata)) { /* didn't find any clients in cidrdata */ + safe_free(bcdata); + return (mymask); /* success! */ + } + else { + destroy_cidr(options.cidrdata); /* clean up after our mess */ + options.cidrdata = NULL; + } + } + + safe_free(bcdata); + /* we failed to find a vaild cidr list */ + notice("Unable to determine any IP addresses as a clients."); + notice("Perhaps you should change the --ratio, --minmask/maxmask settings, or try another mode?"); + return (0); +} + +/* + * processes rbdata to bulid cidrdata based upon the + * given type (SERVER, CLIENT, UNKNOWN) using the given masklen + * + * is smart enough to prevent dupes + +void +tcpr_tree_to_cidr(const int masklen, const int type) +{ + +} + */ + +/** + * Checks to see if an IP is client or server by finding it in the tree + * returns TCPR_DIR_C2S or TCPR_DIR_S2C or -1 on error + * if mode = UNKNOWN, then abort on unknowns + * if mode = CLIENT, then unknowns become clients + * if mode = SERVER, then unknowns become servers + */ +tcpr_dir_t +check_ip_tree(const int mode, const unsigned long ip) +{ + tcpr_tree_t *node = NULL, *finder = NULL; + + finder = new_tree(); + finder->family = AF_INET; + finder->u.ip = ip; + + node = RB_FIND(tcpr_data_tree_s, &treeroot, finder); + + if (node == NULL && mode == DIR_UNKNOWN) + errx(-1, "%s (%lu) is an unknown system... aborting.!\n" + "Try a different auto mode (-n router|client|server)", + get_addr2name4(ip, RESOLVE), ip); + +#ifdef DEBUG + switch (node->type) { + case DIR_SERVER: + dbgx(1, "DIR_SERVER: %s", get_addr2name4(ip, RESOLVE)); + break; + case DIR_CLIENT: + dbgx(1, "DIR_CLIENT: %s", get_addr2name4(ip, RESOLVE)); + break; + case DIR_UNKNOWN: + dbgx(1, "DIR_UNKNOWN: %s", get_addr2name4(ip, RESOLVE)); + break; + case DIR_ANY: + dbgx(1, "DIR_ANY: %s", get_addr2name4(ip, RESOLVE)); + break; + } +#endif + + /* + * FIXME: Is this logic correct? I think this might be backwards :( + */ + + /* return node type if we found the node, else return the default (mode) */ + if (node != NULL) { + switch (node->type) { + case DIR_SERVER: + return TCPR_DIR_C2S; + break; + case DIR_CLIENT: + return TCPR_DIR_S2C; + break; + case DIR_UNKNOWN: + case DIR_ANY: + /* use our current mode to determine return code */ + goto return_unknown; + default: + errx(-1, "Node for %s has invalid type: %d", get_addr2name4(ip, RESOLVE), node->type); + } + } + + return_unknown: + switch (mode) { + case DIR_SERVER: + return TCPR_DIR_C2S; + break; + case DIR_CLIENT: + return TCPR_DIR_S2C; + break; + default: + return -1; + } +} + +tcpr_dir_t +check_ip6_tree(const int mode, const struct tcpr_in6_addr *addr) +{ + tcpr_tree_t *node = NULL, *finder = NULL; + + finder = new_tree(); + finder->family = AF_INET6; + finder->u.ip6 = *addr; + + node = RB_FIND(tcpr_data_tree_s, &treeroot, finder); + + if (node == NULL && mode == DIR_UNKNOWN) + errx(-1, "%s is an unknown system... aborting.!\n" + "Try a different auto mode (-n router|client|server)", + get_addr2name6(addr, RESOLVE)); + +#ifdef DEBUG + switch (node->type) { + case DIR_SERVER: + dbgx(1, "DIR_SERVER: %s", get_addr2name6(addr, RESOLVE)); + break; + case DIR_CLIENT: + dbgx(1, "DIR_CLIENT: %s", get_addr2name6(addr, RESOLVE)); + break; + case DIR_UNKNOWN: + dbgx(1, "DIR_UNKNOWN: %s", get_addr2name6(addr, RESOLVE)); + break; + case DIR_ANY: + dbgx(1, "DIR_ANY: %s", get_addr2name6(addr, RESOLVE)); + break; + } +#endif + + /* + * FIXME: Is this logic correct? I think this might be backwards :( + */ + + /* return node type if we found the node, else return the default (mode) */ + if (node != NULL) { + switch (node->type) { + case DIR_SERVER: + return TCPR_DIR_C2S; + break; + case DIR_CLIENT: + return TCPR_DIR_S2C; + break; + case DIR_UNKNOWN: + case DIR_ANY: + /* use our current mode to determine return code */ + goto return_unknown; + default: + errx(-1, "Node for %s has invalid type: %d", get_addr2name6(addr, RESOLVE), node->type); + } + } + + return_unknown: + switch (mode) { + case DIR_SERVER: + return TCPR_DIR_C2S; + break; + case DIR_CLIENT: + return TCPR_DIR_S2C; + break; + default: + return -1; + } +} + +/** + * Parses the IP header of the given packet (data) to get the SRC/DST IP + * addresses. If the SRC IP doesn't exist in the TREE, we add it as a + * client, if the DST IP doesn't exist in the TREE, we add it as a server + */ +void +add_tree_first_ipv4(const u_char *data) +{ + tcpr_tree_t *newnode = NULL, *findnode; + eth_hdr_t *eth_hdr = NULL; + ipv4_hdr_t ip_hdr; + + assert(data); + /* + * first add/find the source IP/client + */ + newnode = new_tree(); + + eth_hdr = (eth_hdr_t *) (data); + /* prevent issues with byte alignment, must memcpy */ + memcpy(&ip_hdr, (data + TCPR_ETH_H), TCPR_IPV4_H); + + /* copy over the source ip, and values to gurantee this a client */ + newnode->family = AF_INET; + newnode->u.ip = ip_hdr.ip_src.s_addr; + newnode->type = DIR_CLIENT; + newnode->client_cnt = 1000; + findnode = RB_FIND(tcpr_data_tree_s, &treeroot, newnode); + + /* if we didn't find it, add it to the tree, else free it */ + if (findnode == NULL) { + RB_INSERT(tcpr_data_tree_s, &treeroot, newnode); + } else { + safe_free(newnode); + } + + /* + * now add/find the destination IP/server + */ + newnode = new_tree(); + eth_hdr = (eth_hdr_t *) (data); + memcpy(&ip_hdr, (data + TCPR_ETH_H), TCPR_IPV4_H); + + newnode->family = AF_INET; + newnode->u.ip = ip_hdr.ip_dst.s_addr; + newnode->type = DIR_SERVER; + newnode->server_cnt = 1000; + findnode = RB_FIND(tcpr_data_tree_s, &treeroot, newnode); + + if (findnode == NULL) { + RB_INSERT(tcpr_data_tree_s, &treeroot, newnode); + } else { + safe_free(newnode); + } +} + +void +add_tree_first_ipv6(const u_char *data) +{ + tcpr_tree_t *newnode = NULL, *findnode; + eth_hdr_t *eth_hdr = NULL; + ipv6_hdr_t ip6_hdr; + + assert(data); + /* + * first add/find the source IP/client + */ + newnode = new_tree(); + + eth_hdr = (eth_hdr_t *) (data); + /* prevent issues with byte alignment, must memcpy */ + memcpy(&ip6_hdr, (data + TCPR_ETH_H), TCPR_IPV6_H); + + /* copy over the source ip, and values to gurantee this a client */ + newnode->family = AF_INET6; + newnode->u.ip6 = ip6_hdr.ip_src; + newnode->type = DIR_CLIENT; + newnode->client_cnt = 1000; + findnode = RB_FIND(tcpr_data_tree_s, &treeroot, newnode); + + /* if we didn't find it, add it to the tree, else free it */ + if (findnode == NULL) { + RB_INSERT(tcpr_data_tree_s, &treeroot, newnode); + } else { + safe_free(newnode); + } + + /* + * now add/find the destination IP/server + */ + newnode = new_tree(); + eth_hdr = (eth_hdr_t *) (data); + memcpy(&ip6_hdr, (data + TCPR_ETH_H), TCPR_IPV6_H); + + newnode->family = AF_INET6; + newnode->u.ip6 = ip6_hdr.ip_dst; + newnode->type = DIR_SERVER; + newnode->server_cnt = 1000; + findnode = RB_FIND(tcpr_data_tree_s, &treeroot, newnode); + + if (findnode == NULL) { + RB_INSERT(tcpr_data_tree_s, &treeroot, newnode); + } else { + safe_free(newnode); + } +} + +static void +add_tree_node(tcpr_tree_t *newnode) +{ + tcpr_tree_t *node; + + /* try to find a simular entry in the tree */ + node = RB_FIND(tcpr_data_tree_s, &treeroot, newnode); + + dbgx(3, "%s", tree_printnode("add_tree", node)); + + /* new entry required */ + if (node == NULL) { + /* increment counters */ + if (newnode->type == DIR_SERVER) { + newnode->server_cnt++; + } + else if (newnode->type == DIR_CLIENT) { + newnode->client_cnt++; + } + /* insert it in */ + RB_INSERT(tcpr_data_tree_s, &treeroot, newnode); + + } + else { + /* we found something, so update it */ + dbgx(2, " node: %p\nnewnode: %p", node, newnode); + dbgx(3, "%s", tree_printnode("update node", node)); + /* increment counter */ + if (newnode->type == DIR_SERVER) { + node->server_cnt++; + } + else if (newnode->type == DIR_CLIENT) { + /* temp debug code */ + node->client_cnt++; + } + + /* didn't insert it, so free it */ + safe_free(newnode); + } + + dbg(2, "------- START NEXT -------"); + dbgx(3, "%s", tree_print(&treeroot)); +} + +/** + * adds an entry to the tree (phase 1 of auto mode). We add each host + * to the tree if it doesn't yet exist. We go through and track: + * - number of times each host acts as a client or server + * - the way the host acted the first time we saw it (client or server) + */ +void +add_tree_ipv4(const unsigned long ip, const u_char * data) +{ + tcpr_tree_t *newnode = NULL; + assert(data); + + newnode = packet2tree(data); + + assert(ip == newnode->u.ip); + + if (newnode->type == DIR_UNKNOWN) { + /* couldn't figure out if packet was client or server */ + + dbgx(2, "%s (%lu) unknown client/server", + get_addr2name4(newnode->u.ip, RESOLVE), newnode->u.ip); + + } + add_tree_node(newnode); +} + +void +add_tree_ipv6(const struct tcpr_in6_addr * addr, const u_char * data) +{ + tcpr_tree_t *newnode = NULL; + assert(data); + + newnode = packet2tree(data); + + assert(ipv6_cmp(addr, &newnode->u.ip6) == 0); + + if (newnode->type == DIR_UNKNOWN) { + /* couldn't figure out if packet was client or server */ + + dbgx(2, "%s unknown client/server", + get_addr2name6(&newnode->u.ip6, RESOLVE)); + } + + add_tree_node(newnode); +} + +/** + * calculates wether each node in the tree is a client, server, or unknown for each node in the tree + */ +void +tree_calculate(tcpr_data_tree_t *treeroot) +{ + tcpr_tree_t *node; + + dbg(1, "Running tree_calculate()"); + + RB_FOREACH(node, tcpr_data_tree_s, treeroot) { + dbgx(4, "Processing %s", get_addr2name4(node->u.ip, RESOLVE)); + if ((node->server_cnt > 0) || (node->client_cnt > 0)) { + /* type based on: server >= (client*ratio) */ + if ((double)node->server_cnt >= (double)node->client_cnt * options.ratio) { + node->type = DIR_SERVER; + dbgx(3, "Setting %s to server", + get_addr2name4(node->u.ip, RESOLVE)); + } + else { + node->type = DIR_CLIENT; + dbgx(3, "Setting %s to client", + get_addr2name4(node->u.ip, RESOLVE)); + } + } + else { /* IP had no client or server connections */ + node->type = DIR_UNKNOWN; + dbgx(3, "Setting %s to unknown", + get_addr2name4(node->u.ip, RESOLVE)); + } + } +} + +static int +ipv6_cmp(const struct tcpr_in6_addr *a, const struct tcpr_in6_addr *b) +{ + int i, k; + + for (i = 0; i < 4; i++) { + if ((k = (a->tcpr_s6_addr32[i] - b->tcpr_s6_addr32[i]))) { + return (k > 0) ? 1 : -1; + } + } + return 0; +} + +/** + * tree_comp(), called by rbsearch compares two treees and returns: + * 1 = first > second + * -1 = first < second + * 0 = first = second + * based upon the ip address stored + * + */ +int +tree_comp(tcpr_tree_t *t1, tcpr_tree_t *t2) +{ + int ret; + if (t1->family > t2->family) { + dbgx(2, "family %d > %d", t1->family, t2->family); + return 1; + } + + if (t1->family < t2->family) { + dbgx(2, "family %d < %d", t1->family, t2->family); + return -1; + } + + if (t1->family == AF_INET) { + if (t1->u.ip > t2->u.ip) { + dbgx(2, "%s > %s", get_addr2name4(t1->u.ip, RESOLVE), + get_addr2name4(t2->u.ip, RESOLVE)); + return 1; + } + + if (t1->u.ip < t2->u.ip) { + dbgx(2, "%s < %s", get_addr2name4(t1->u.ip, RESOLVE), + get_addr2name4(t2->u.ip, RESOLVE)); + return -1; + } + + dbgx(2, "%s = %s", get_addr2name4(t1->u.ip, RESOLVE), + get_addr2name4(t2->u.ip, RESOLVE)); + + return 0; + } + + if (t1->family == AF_INET6) { + ret = ipv6_cmp(&t1->u.ip6, &t1->u.ip6); + dbgx(2, "cmp(%s, %s) = %d", get_addr2name6(&t1->u.ip6, RESOLVE), + get_addr2name6(&t2->u.ip6, RESOLVE), ret); + return ret; + } + + return 0; +} + +/** + * creates a new TREE * with reasonable defaults + */ +static tcpr_tree_t * +new_tree() +{ + tcpr_tree_t *node; + + node = (tcpr_tree_t *)safe_malloc(sizeof(tcpr_tree_t)); + + memset(node, '\0', sizeof(tcpr_tree_t)); + node->server_cnt = 0; + node->client_cnt = 0; + node->type = DIR_UNKNOWN; + node->masklen = -1; + node->u.ip = 0; + return (node); +} + + +/** + * returns a struct of TREE * from a packet header + * and sets the type to be SERVER or CLIENT or UNKNOWN + * if it's an undefined packet, we return -1 for the type + * the u_char * data should be the data that is passed by pcap_dispatch() + */ +tcpr_tree_t * +packet2tree(const u_char * data) +{ + tcpr_tree_t *node = NULL; + eth_hdr_t *eth_hdr = NULL; + ipv4_hdr_t ip_hdr; + ipv6_hdr_t ip6_hdr; + tcp_hdr_t tcp_hdr; + udp_hdr_t udp_hdr; + icmpv4_hdr_t icmp_hdr; + dnsv4_hdr_t dnsv4_hdr; + u_int16_t ether_type; + u_char proto = 0; + int hl = 0; +#ifdef DEBUG + char srcip[INET6_ADDRSTRLEN]; +#endif + + node = new_tree(); + + eth_hdr = (eth_hdr_t *) (data); + + /* prevent issues with byte alignment, must memcpy */ + memcpy(ðer_type, (u_char*)eth_hdr + 12, 2); + + /* drop VLAN info if it exists before the IP info */ + if (ether_type == htons(ETHERTYPE_VLAN)) { + dbg(4,"Processing as VLAN traffic..."); + + /* prevent issues with byte alignment, must memcpy */ + memcpy(ðer_type, (u_char*)eth_hdr + 16, 2); + hl += 4; + } + + if (ether_type == htons(ETHERTYPE_IP)) { + memcpy(&ip_hdr, (data + TCPR_ETH_H + hl), TCPR_IPV4_H); + + node->family = AF_INET; + node->u.ip = ip_hdr.ip_src.s_addr; + proto = ip_hdr.ip_p; + hl += ip_hdr.ip_hl * 4; + +#ifdef DEBUG + strlcpy(srcip, get_addr2name4(ip_hdr.ip_src.s_addr, + RESOLVE), 16); +#endif + } else if (ether_type == htons(ETHERTYPE_IP6)) { + memcpy(&ip6_hdr, (data + TCPR_ETH_H + hl), TCPR_IPV6_H); + + node->family = AF_INET6; + node->u.ip6 = ip6_hdr.ip_src; + proto = ip6_hdr.ip_nh; + hl += TCPR_IPV6_H; + +#ifdef DEBUG + strlcpy(srcip, get_addr2name6(&ip6_hdr.ip_src, RESOLVE), INET6_ADDRSTRLEN); +#endif + } else { + dbgx(2,"Unrecognized ether_type (%x)", ether_type); + } + + + /* copy over the source mac */ + strncpy((char *)node->mac, (char *)eth_hdr->ether_shost, 6); + + /* + * TCP + */ + if (proto == IPPROTO_TCP) { + + dbgx(3, "%s uses TCP... ", srcip); + + /* memcpy it over to prevent alignment issues */ + memcpy(&tcp_hdr, (data + TCPR_ETH_H + hl), TCPR_TCP_H); + + /* ftp-data is going to skew our results so we ignore it */ + if (tcp_hdr.th_sport == 20) + return (node); + + /* set TREE->type based on TCP flags */ + if (tcp_hdr.th_flags == TH_SYN) { + node->type = DIR_CLIENT; + dbg(3, "is a client"); + } + else if (tcp_hdr.th_flags == (TH_SYN | TH_ACK)) { + node->type = DIR_SERVER; + dbg(3, "is a server"); + } + else { + dbg(3, "is an unknown"); + } + + } + /* + * UDP + */ + else if (proto == IPPROTO_UDP) { + /* memcpy over to prevent alignment issues */ + memcpy(&udp_hdr, (data + TCPR_ETH_H + hl), TCPR_UDP_H); + dbgx(3, "%s uses UDP... ", srcip); + + switch (ntohs(udp_hdr.uh_dport)) { + case 0x0035: /* dns */ + /* prevent memory alignment issues */ + memcpy(&dnsv4_hdr, + (data + TCPR_ETH_H + hl + TCPR_UDP_H), TCPR_DNS_H); + + if (dnsv4_hdr.flags & DNS_QUERY_FLAG) { + /* bit set, response */ + node->type = DIR_SERVER; + + dbg(3, "is a dns server"); + + } + else { + /* bit not set, query */ + node->type = DIR_CLIENT; + + dbg(3, "is a dns client"); + } + return (node); + break; + default: + break; + } + + switch (ntohs(udp_hdr.uh_sport)) { + case 0x0035: /* dns */ + /* prevent memory alignment issues */ + memcpy(&dnsv4_hdr, + (data + TCPR_ETH_H + hl + TCPR_UDP_H), + TCPR_DNS_H); + + if ((dnsv4_hdr.flags & 0x7FFFF) ^ DNS_QUERY_FLAG) { + /* bit set, response */ + node->type = DIR_SERVER; + dbg(3, "is a dns server"); + } + else { + /* bit not set, query */ + node->type = DIR_CLIENT; + dbg(3, "is a dns client"); + } + return (node); + break; + default: + + dbgx(3, "unknown UDP protocol: %hu->%hu", udp_hdr.uh_sport, + udp_hdr.uh_dport); + break; + } + } + /* + * ICMP + */ + else if (proto == IPPROTO_ICMP) { + + /* prevent alignment issues */ + memcpy(&icmp_hdr, (data + TCPR_ETH_H + hl), TCPR_ICMPV4_H); + + dbgx(3, "%s uses ICMP... ", srcip); + + /* + * if port unreachable, then source == server, dst == client + */ + if ((icmp_hdr.icmp_type == ICMP_UNREACH) && + (icmp_hdr.icmp_code == ICMP_UNREACH_PORT)) { + node->type = DIR_SERVER; + dbg(3, "is a server with a closed port"); + } + + } + + return (node); +} + + +/** + * prints out a node of the tree to stderr + */ +static char * +tree_printnode(const char *name, const tcpr_tree_t *node) +{ + + memset(&tree_print_buff, '\0', TREEPRINTBUFFLEN); + if (node == NULL) { + snprintf(tree_print_buff, TREEPRINTBUFFLEN, "%s node is null", name); + } + + else { + snprintf(tree_print_buff, TREEPRINTBUFFLEN, + "-- %s: %p\nIP: %s\nMask: %d\nSrvr: %d\nClnt: %d\n", + name, (void *)node, node->family == AF_INET ? + get_addr2name4(node->u.ip, RESOLVE) : + get_addr2name6(&node->u.ip6, RESOLVE), + node->masklen, node->server_cnt, node->client_cnt); + if (node->type == DIR_SERVER) { + strlcat(tree_print_buff, "Type: Server\n--\n", TREEPRINTBUFFLEN); + } + else { + strlcat(tree_print_buff, "Type: Client\n--", TREEPRINTBUFFLEN); + } + + } + return (tree_print_buff); +} + +/** + * prints out the entire tree + */ +static char * +tree_print(tcpr_data_tree_t *treeroot) +{ + tcpr_tree_t *node = NULL; + memset(&tree_print_buff, '\0', TREEPRINTBUFFLEN); + RB_FOREACH(node, tcpr_data_tree_s, treeroot) { + tree_printnode("my node", node); + } + return (tree_print_buff); + +} diff --git a/src/tree.h b/src/tree.h new file mode 100644 index 0000000..85485fd --- /dev/null +++ b/src/tree.h @@ -0,0 +1,78 @@ +/* $Id: tree.h 2423 2010-03-13 07:09:49Z aturner $ */ + +/* + * Copyright (c) 2001-2010 Aaron Turner. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the names of the copyright owners nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef __TREE_H__ +#define __TREE_H__ + +#include "lib/tree.h" + +#define TREEPRINTBUFFLEN 2048 + +typedef struct tcpr_tree_s { + RB_ENTRY(tcpr_tree_s) node; + int family; + union { + unsigned long ip; /* ip/network address in network byte order */ + struct tcpr_in6_addr ip6; + } u; + u_char mac[ETHER_ADDR_LEN]; /* mac address of system */ + int masklen; /* CIDR network mask length */ + int server_cnt; /* count # of times this entry was flagged server */ + int client_cnt; /* flagged client */ + int type; /* 1 = server, 0 = client, -1 = undefined */ +} tcpr_tree_t; + +/* + * replacement for RB_HEAD() which doesn't actually declare the root + */ +typedef struct tcpr_data_tree_s { + tcpr_tree_t *rbh_root; +} tcpr_data_tree_t; + +typedef struct tcpr_buildcidr_s { + int type; /* SERVER|CLIENT|UNKNOWN|ANY */ + int masklen; /* mask size to use to build the CIDR */ +} tcpr_buildcidr_t; + +#define DNS_QUERY_FLAG 0x8000 + +void add_tree_ipv4(const unsigned long, const u_char *); +void add_tree_ipv6(const struct tcpr_in6_addr *, const u_char *); +void add_tree_first_ipv4(const u_char *); +void add_tree_first_ipv6(const u_char *); +tcpr_dir_t check_ip_tree(const int, const unsigned long); +tcpr_dir_t check_ip6_tree(const int, const struct tcpr_in6_addr *); +int process_tree(); +void tree_calculate(tcpr_data_tree_t *); +int tree_comp(tcpr_tree_t *, tcpr_tree_t *); + +#endif diff --git a/test/Makefile.am b/test/Makefile.am new file mode 100644 index 0000000..e3140be --- /dev/null +++ b/test/Makefile.am @@ -0,0 +1,553 @@ +# $Id$ +MAKEFLAGS=-s -k +PRINTF = @PRINTF@ +HOST = @host@ +TARGET = @target@ +BUILD = @build@ +nic1 = @nic1@ +nic2 = @nic2@ +ENABLE_DEBUG = @debug_flag@ +TCPPREP=../src/tcpprep --no-arg-comment +TCPREPLAY=../src/tcpreplay +TCPREWRITE=../src/tcprewrite +TCPBRIDGE=../src/tcpbridge + +EXTRA_DIST = test.pcap test.auto_bridge test.auto_client test.auto_router \ + test.auto_server test.auto_first test.cidr test.comment test.port test.mac \ + test.cidr_reverse test.mac_reverse test.regex_reverse \ + test.prep_config test.primary test.regex test.secondary \ + test.rewrite_seed test.rewrite_portmap test.rewrite_endpoint \ + test.rewrite_pnat test.rewrite_pad test.rewrite_trunc \ + test.rewrite_mac test.rewrite_layer2 test.rewrite_config \ + test.rewrite_skip test.rewrite_dltuser test.rewrite_dlthdlc \ + test.rewrite_vlandel test.rewrite_efcs test.rewrite_1ttl \ + test.rewrite_2ttl test.rewrite_3ttl \ + test2.rewrite_seed test2.rewrite_portmap test2.rewrite_endpoint \ + test2.rewrite_pnat test2.rewrite_pad test2.rewrite_trunc \ + test2.rewrite_mac test2.rewrite_layer2 test2.rewrite_config \ + test2.rewrite_skip test2.rewrite_dltuser test2.rewrite_dlthdlc \ + test2.rewrite_vlandel test2.rewrite_efcs test2.rewrite_1ttl \ + test2.rewrite_mtutrunc \ + test2.rewrite_2ttl test2.rewrite_3ttl test.rewrite_tos test2.rewrite_tos + +test: all +all: clearlog check tcpprep tcpreplay tcprewrite + +clearlog: + -rm test.log + +check: + $(PRINTF) "%s\n" "NOTICE: Tests must be run as root" + $(PRINTF) "%s\n" "Sending traffic on '$(nic1)' and '$(nic2)'" + +if WORDS_BIGENDIAN +STANDARD_REWRITE = standard_bigendian +REWRITE_WARN = "big" +else +STANDARD_REWRITE = standard_littleendian +REWRITE_WARN = "little" +endif + +standard: standard_prep $(STANDARD_REWRITE) + $(PRINTF) "Warning: only creating %s endian standard test files\n" $(REWRITE_WARN) + +standard_prep: + $(TCPPREP) -i test.pcap -o test.auto_router -a router + $(TCPPREP) -i test.pcap -o test.auto_bridge -a bridge + $(TCPPREP) -i test.pcap -o test.auto_client -a client + $(TCPPREP) -i test.pcap -o test.auto_server -a server + $(TCPPREP) -i test.pcap -o test.auto_first -a first + $(TCPPREP) --load-opts config -o test.prep_config + $(TCPPREP) -i test.pcap -o test.port -p + $(TCPPREP) -i test.pcap -o test.mac -e 00:02:3b:00:3d:ce + $(TCPPREP) -i test.pcap -o test.cidr -c '216.27.178.0/24' + $(TCPPREP) -i test.pcap -o test.regex -r '216.27.178.*' + $(TCPPREP) -i test.pcap -o test.comment -C "This is a comment" -p + $(TCPPREP) -i test.pcap -o test.mac_reverse -e 00:02:3b:00:3d:ce --reverse + $(TCPPREP) -i test.pcap -o test.cidr_reverse -c '216.27.178.0/24' --reverse + $(TCPPREP) -i test.pcap -o test.regex_reverse -r '216.27.178.*' --reverse + +standard_bigendian: + $(TCPREWRITE) -i test.pcap -o test.rewrite_seed -s 55 + $(TCPREWRITE) -i test.pcap -o test.rewrite_tos --tos=50 + $(TCPREWRITE) -i test.pcap -o test.rewrite_portmap -r 80:8080 + $(TCPREWRITE) -i test.pcap -o test.rewrite_endpoint \ + -e 10.10.0.1:10.10.0.2 -c test.auto_router + $(TCPREWRITE) -i test.pcap -o test.rewrite_pnat \ + -N 216.27.178.0/24:172.16.0.0/24 + $(TCPREWRITE) -i test.pcap -o test.rewrite_pad -F pad + $(TCPREWRITE) -i test.pcap -o test.rewrite_trunc -F trunc + $(TCPREWRITE) -i test.pcap -o test.rewrite_mac \ + --enet-dmac=00:12:13:14:15:16,00:22:33:44:55:66 \ + --enet-smac=00:22:33:44:55:66,00:12:13:14:15:16 -c test.auto_router + $(TCPREWRITE) -i test.pcap -o test.rewrite_layer2 \ + --dlt=user --user-dlink=00,50,da,5d,46,55,0,7,eb,30,a4,c3,08,0 + $(TCPREWRITE) -i test.pcap -o test.rewrite_config --enet-vlan=add --enet-vlan-tag=45 \ + --enet-vlan-cfi=1 --enet-vlan-pri=5 + $(TCPREWRITE) -i test.pcap -o test.rewrite_skip -b -s 55 \ + --enet-dmac=00:12:13:14:15:16,00:22:33:44:55:66 \ + --enet-smac=00:22:33:44:55:66,00:12:13:14:15:16 -c test.auto_router + $(TCPREWRITE) -i test.pcap -o test.rewrite_dltuser --dlt=user \ + --user-dlink=0x0f,0x00,0x08,0x00 --user-dlt=104 + $(TCPREWRITE) -i test.pcap -o test.rewrite_dlthdlc --dlt=hdlc \ + --hdlc-control=0 --hdlc-address=0x0F + $(TCPREWRITE) -i test.rewrite_config -o test.rewrite_vlandel \ + --enet-vlan=del + $(TCPREWRITE) -i test.pcap -o test.rewrite_efcs --efcs + $(TCPREWRITE) -i test.pcap -o test.rewrite_1ttl --ttl=58 + $(TCPREWRITE) -i test.pcap -o test.rewrite_2ttl --ttl=+58 + $(TCPREWRITE) -i test.pcap -o test.rewrite_3ttl --ttl=-58 + +standard_littleendian: + $(TCPREWRITE) -i test.pcap -o test2.rewrite_seed -s 55 + $(TCPREWRITE) -i test.pcap -o test2.rewrite_tos --tos=50 + $(TCPREWRITE) -i test.pcap -o test2.rewrite_portmap -r 80:8080 + $(TCPREWRITE) -i test.pcap -o test2.rewrite_endpoint \ + -e 10.10.0.1:10.10.0.2 -c test.auto_router + $(TCPREWRITE) -i test.pcap -o test2.rewrite_pnat \ + -N 216.27.178.0/24:172.16.0.0/24 + $(TCPREWRITE) -i test.pcap -o test2.rewrite_pad -F pad + $(TCPREWRITE) -i test.pcap -o test2.rewrite_trunc -F trunc + $(TCPREWRITE) -i test.pcap -o test2.rewrite_mac \ + --enet-dmac=00:12:13:14:15:16,00:22:33:44:55:66 \ + --enet-smac=00:22:33:44:55:66,00:12:13:14:15:16 -c test.auto_router + $(TCPREWRITE) -i test.pcap -o test2.rewrite_layer2 \ + --dlt=user --user-dlink=00,50,da,5d,46,55,0,7,eb,30,a4,c3,08,0 + $(TCPREWRITE) -i test.pcap -o test2.rewrite_config --enet-vlan=add --enet-vlan-tag=45 \ + --enet-vlan-cfi=1 --enet-vlan-pri=5 + $(TCPREWRITE) -i test.pcap -o test2.rewrite_skip -b -s 55 \ + --enet-dmac=00:12:13:14:15:16,00:22:33:44:55:66 \ + --enet-smac=00:22:33:44:55:66,00:12:13:14:15:16 -c test.auto_router + $(TCPREWRITE) -i test.pcap -o test2.rewrite_dltuser --dlt=user \ + --user-dlink=0x0f,0x00,0x08,0x00 --user-dlt=104 + $(TCPREWRITE) -i test.pcap -o test2.rewrite_dlthdlc --dlt=hdlc \ + --hdlc-control=0 --hdlc-address=0x0F + $(TCPREWRITE) -i test.rewrite_config -o test2.rewrite_vlandel \ + --enet-vlan=del + $(TCPREWRITE) -i test.pcap -o test2.rewrite_efcs --efcs + $(TCPREWRITE) -i test.pcap -o test2.rewrite_1ttl --ttl=58 + $(TCPREWRITE) -i test.pcap -o test2.rewrite_2ttl --ttl=+58 + $(TCPREWRITE) -i test.pcap -o test2.rewrite_3ttl --ttl=-58 + $(TCPREWRITE) -i test.pcap -o test2.rewrite_mtutrunc --mtu-trunc --mtu=300 + +tcpprep: auto_router auto_bridge auto_client auto_server auto_first cidr regex \ + port mac comment print_info print_comment prep_config \ + mac_reverse cidr_reverse regex_reverse + +tcprewrite: rewrite_portmap rewrite_endpoint rewrite_pnat rewrite_trunc \ + rewrite_pad rewrite_seed rewrite_mac rewrite_layer2 rewrite_config \ + rewrite_skip rewrite_dltuser rewrite_dlthdlc rewrite_vlandel rewrite_efcs \ + rewrite_1ttl rewrite_2ttl rewrite_3ttl rewrite_tos rewrite_mtutrunc + +tcpreplay: replay_basic replay_cache replay_pps replay_rate replay_top \ + replay_config replay_multi replay_pps_multi replay_precache \ + replay_stats + +prep_config: + $(PRINTF) "%s" "[tcpprep] Config mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] Config mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) --load-opts=config -o test.$@1 >>test.log 2>&1 + diff test.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +auto_router: + $(PRINTF) "%s" "[tcpprep] Auto/Router mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] Auto/Router mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a router >>test.log 2>&1 + diff test.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + +auto_bridge: + $(PRINTF) "%s" "[tcpprep] Auto/Bridge mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] Auto/Bridge mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a bridge >>test.log 2>&1 + diff test.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + +auto_client: + $(PRINTF) "%s" "[tcpprep] Auto/Client mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] Auto/Client mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a client >>test.log 2>&1 + diff test.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + +auto_server: + $(PRINTF) "%s" "[tcpprep] Auto/Server mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] Auto/Server mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a server >>test.log 2>&1 + diff test.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + +auto_first: + $(PRINTF) "%s" "[tcpprep] Auto/First mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] Auto/First mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a first >>test.log 2>&1 + diff test.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + +regex: + $(PRINTF) "%s" "[tcpprep] Regex mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] Regex mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -r '216.27.178.*' >>test.log 2>&1 + diff test.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +cidr: + $(PRINTF) "%s" "[tcpprep] CIDR mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] CIDR mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -c '216.27.178.0/24' >>test.log 2>&1 + diff test.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +port: + $(PRINTF) "%s" "[tcpprep] Port mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] Port mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -p >>test.log 2>&1 + diff test.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +mac: + $(PRINTF) "%s" "[tcpprep] MAC mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] MAC mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -e 00:02:3b:00:3d:ce >>test.log 2>&1 + diff test.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +comment: + $(PRINTF) "%s" "[tcpprep] Comment mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] Comment mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -C "This is a comment" -p >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +print_comment: + $(PRINTF) "%s" "[tcpprep] Print comment mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] Print comment mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -P test.comment >test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + +print_info: + $(PRINTF) "%s" "[tcpprep] Print info mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] Print info mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -I test.comment >test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + + +regex_reverse: + $(PRINTF) "%s" "[tcpprep] Regex reverse mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] Regex reverse mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -r '216.27.178.*' --reverse >>test.log 2>&1 + diff test.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + +cidr_reverse: + $(PRINTF) "%s" "[tcpprep] CIDR reverse mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] CIDR reverse mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -c '216.27.178.0/24' --reverse >>test.log 2>&1 + diff test.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + +mac_reverse: + $(PRINTF) "%s" "[tcpprep] MAC reverse mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] MAC reverse mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -e 00:02:3b:00:3d:ce --reverse >>test.log 2>&1 + diff test.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + +replay_basic: + $(PRINTF) "%s" "[tcpreplay] Basic test: " + $(PRINTF) "%s\n" "*** [tcpreplay] Basic test: " >>test.log + $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -t test.pcap >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +replay_cache: + $(PRINTF) "%s" "[tcpreplay] Cache test: " + $(PRINTF) "%s\n" "*** [tcpreplay] Cache test: " >>test.log + $(TCPREPLAY) $(ENABLE_DEBUG) -c test.cidr -i $(nic1) -I $(nic2) -t test.pcap >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +replay_accurate: + $(PRINTF) "%s" "[tcpreplay] Accurate test: " + $(PRINTF) "%s\n" "*** [tcpreplay] Accurate test: " >>test.log + $(TCPREPLAY) $(ENABLE_DEBUG) -a -i $(nic1) test.pcap >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +replay_stats: + $(PRINTF) "%s" "[tcpreplay] Statistics test: " + $(PRINTF) "%s\n" "*** [tcpreplay] Statistics test: " >>test.log + $(TCPREPLAY) $(ENABLE_DEBUG) --stats=1 -i $(nic1) test.pcap >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_portmap: + $(PRINTF) "%s" "[tcprewrite] Portmap test: " + $(PRINTF) "%s\n" "*** [tcprewrite] Portmap test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_portmap1 -r 80:8080 >>test.log 2>&1 +if WORDS_BIGENDIAN + diff test.$@ test.$@1 >>test.log 2>&1 +else + diff test2.$@ test.$@1 >>test.log 2>&1 +endif + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_endpoint: + $(PRINTF) "%s" "[tcprewrite] Endpoint test: " + $(PRINTF) "%s\n" "*** [tcprewrite] Endpoint test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_endpoint1 -e 10.10.0.1:10.10.0.2 \ + -c test.auto_router >>test.log 2>&1 +if WORDS_BIGENDIAN + diff test.$@ test.$@1 >>test.log 2>&1 +else + diff test2.$@ test.$@1 >>test.log 2>&1 +endif + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_pnat: + $(PRINTF) "%s" "[tcprewrite] Pseudo NAT test: " + $(PRINTF) "%s\n" "*** [tcprewrite] Pseudo NAT test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_pnat1 \ + -N 216.27.178.0/24:172.16.0.0/24 >>test.log 2>&1 +if WORDS_BIGENDIAN + diff test.$@ test.$@1 >>test.log 2>&1 +else + diff test2.$@ test.$@1 >>test.log 2>&1 +endif + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_mac: + $(PRINTF) "%s" "[tcprewrite] Src/Dst MAC test: " + $(PRINTF) "%s\n" "*** [tcprewrite] Src/Dst MAC test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_mac1 \ + --enet-dmac=00:12:13:14:15:16,00:22:33:44:55:66 \ + --enet-smac=00:22:33:44:55:66,00:12:13:14:15:16 -c test.auto_router >>test.log 2>&1 +if WORDS_BIGENDIAN + diff test.$@ test.$@1 >>test.log 2>&1 +else + diff test2.$@ test.$@1 >>test.log 2>&1 +endif + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_trunc: + $(PRINTF) "%s" "[tcprewrite] Truncate test: " + $(PRINTF) "%s\n" "*** [tcprewrite] Truncate test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -F trunc -i test.pcap -o test.rewrite_trunc1 >>test.log 2>&1 +if WORDS_BIGENDIAN + diff test.$@ test.$@1 >>test.log 2>&1 +else + diff test2.$@ test.$@1 >>test.log 2>&1 +endif + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_pad: + $(PRINTF) "%s" "[tcprewrite] Pad test: " + $(PRINTF) "%s\n" "*** [tcprewrite] Pad test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -F pad -i test.pcap -o test.rewrite_pad1 >>test.log 2>&1 +if WORDS_BIGENDIAN + diff test.$@ test.$@1 >>test.log 2>&1 +else + diff test2.$@ test.$@1 >>test.log 2>&1 +endif + if [ $? ] ; then $(PRINTF) "\t\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t\t%s\n" "OK"; fi + +rewrite_seed: + $(PRINTF) "%s" "[tcprewrite] Seed IP test: " + $(PRINTF) "%s\n" "*** [tcprewrite] Seed IP test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_seed1 -s 55 >>test.log 2>&1 +if WORDS_BIGENDIAN + diff test.$@ test.$@1 >>test.log 2>&1 +else + diff test2.$@ test.$@1 >>test.log 2>&1 +endif + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_layer2: + $(PRINTF) "%s" "[tcprewrite] Layer2 test: " + $(PRINTF) "%s\n" "*** [tcprewrite] Layer2 test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) --dlt=user --user-dlink=00,50,da,5d,46,55,0,7,eb,30,a4,c3,08,0 \ + -i test.pcap -o test.rewrite_layer21 >>test.log 2>&1 +if WORDS_BIGENDIAN + diff test.$@ test.$@1 >>test.log 2>&1 +else + diff test2.$@ test.$@1 >>test.log 2>&1 +endif + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_config: + $(PRINTF) "%s" "[tcprewrite] Config/VLAN Add test: " + $(PRINTF) "%s\n" "*** [tcprewrite] Config/VLAN Add test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) --load-opts config >>test.log 2>&1 +if WORDS_BIGENDIAN + diff test.$@ test.$@1 >>test.log 2>&1 +else + diff test2.$@ test.$@1 >>test.log 2>&1 +endif + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + +rewrite_skip: + $(PRINTF) "%s" "[tcprewrite] Skip bcast test: " + $(PRINTF) "%s\n" "*** [tcprewrite] Skip bcast test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_skip1 -b -s 55 \ + --enet-dmac=00:12:13:14:15:16,00:22:33:44:55:66 \ + --enet-smac=00:22:33:44:55:66,00:12:13:14:15:16 -c test.auto_router >>test.log 2>&1 +if WORDS_BIGENDIAN + diff test.$@ test.$@1 >>test.log 2>&1 +else + diff test2.$@ test.$@1 >>test.log 2>&1 +endif + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_dltuser: + $(PRINTF) "%s" "[tcprewrite] DLT User test: " + $(PRINTF) "%s\n" "*** [tcprewrite] DLT User test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_dltuser1 --dlt=user \ + --user-dlink=0x0f,0x00,0x08,0x00 --user-dlt=104 >>test.log 2>&1 +if WORDS_BIGENDIAN + diff test.$@ test.$@1 >>test.log 2>&1 +else + diff test2.$@ test.$@1 >>test.log 2>&1 +endif + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_dlthdlc: + $(PRINTF) "%s" "[tcprewrite] DLT Cisco HDLC test: " + $(PRINTF) "%s\n" "*** [tcprewrite] DLT Cisco HDLC test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_dlthdlc1 --dlt=hdlc \ + --hdlc-control=0 --hdlc-address=0x0F >>test.log 2>&1 +if WORDS_BIGENDIAN + diff test.$@ test.$@1 >>test.log 2>&1 +else + diff test2.$@ test.$@1 >>test.log 2>&1 +endif + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + +rewrite_vlandel: + $(PRINTF) "%s" "[tcprewrite] VLAN Delete test: " + $(PRINTF) "%s\n" "*** [tcprewrite] VLAN Delete test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.rewrite_config -o test.rewrite_vlandel1 \ + --enet-vlan=del >>test.log 2>&1 +if WORDS_BIGENDIAN + diff test.$@ test.$@1 >>test.log 2>&1 +else + diff test2.$@ test.$@1 >>test.log 2>&1 +endif + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_efcs: + $(PRINTF) "%s" "[tcprewrite] Remove EFCS: " + $(PRINTF) "%s\n" "*** [tcprewrite] Remove EFCS: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_efcs1 --efcs >>test.log 2>&1 +if WORDS_BIGENDIAN + diff test.$@ test.$@1 >>test.log 2>&1 +else + diff test2.$@ test.$@1 >>test.log 2>&1 +endif + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_1ttl: + $(PRINTF) "%s" "[tcprewrite] Force TTL: " + $(PRINTF) "%s\n" "*** [tcprewrite] Force TTL: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 --ttl=58 >>test.log 2>&1 +if WORDS_BIGENDIAN + diff test.$@ test.$@1 >>test.log 2>&1 +else + diff test2.$@ test.$@1 >>test.log 2>&1 +endif + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_2ttl: + $(PRINTF) "%s" "[tcprewrite] Increase TTL: " + $(PRINTF) "%s\n" "*** [tcprewrite] Increase TTL: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 --ttl=+58 >>test.log 2>&1 +if WORDS_BIGENDIAN + diff test.$@ test.$@1 >>test.log 2>&1 +else + diff test2.$@ test.$@1 >>test.log 2>&1 +endif + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_3ttl: + $(PRINTF) "%s" "[tcprewrite] Reduce TTL: " + $(PRINTF) "%s\n" "*** [tcprewrite] Reduce TTL: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 --ttl=-58 >>test.log 2>&1 +if WORDS_BIGENDIAN + diff test.$@ test.$@1 >>test.log 2>&1 +else + diff test2.$@ test.$@1 >>test.log 2>&1 +endif + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_tos: + $(PRINTF) "%s" "[tcprewrite] TOS test: " + $(PRINTF) "%s\n" "*** [tcprewrite] TOS test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 --tos=50 >>test.log 2>&1 +if WORDS_BIGENDIAN + diff test.$@ test.$@1 >>test.log 2>&1 +else + diff test2.$@ test.$@1 >>test.log 2>&1 +endif + if [ $? ] ; then $(PRINTF) "\t\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t\t%s\n" "OK"; fi + +rewrite_mtutrunc: + $(PRINTF) "%s" "[tcprewrite] MTU Truncate test: " + $(PRINTF) "%s\n" "*** [tcprewrite] MTU Truncate test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 --mtu-trunc --mtu=300 >>test.log 2>&1 +if WORDS_BIGENDIAN + diff test.$@ test.$@1 >>test.log 2>&1 +else + diff test2.$@ test.$@1 >>test.log 2>&1 +endif + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + +replay_pps: + $(PRINTF) "%s" "[tcpreplay] Packets/sec test: " + $(PRINTF) "%s\n" "*** [tcpreplay] Packets/sec test: " >>test.log + $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -p 25 test.pcap >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +replay_rate: + $(PRINTF) "%s" "[tcpreplay] Mbps test: " + $(PRINTF) "%s\n" "*** [tcpreplay] Mbps test: " >>test.log + $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -M 25.0 test.pcap >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t\t%s\n" "OK"; fi + +replay_multi: + $(PRINTF) "%s" "[tcpreplay] Multiplier test: " + $(PRINTF) "%s\n" "*** [tcpreplay] Multiplier test: " >>test.log + $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -x 25.0 test.pcap >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +replay_pps_multi: + $(PRINTF) "%s" "[tcpreplay] Packets/sec Multiplier test: " + $(PRINTF) "%s\n" "*** [tcpreplay] Packets/sec Multiplier test: " >>test.log + $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -p 100 --pps-multi=5 test.pcap >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t%s\n" "FAILED"; else $(PRINTF) "\t%s\n" "OK"; fi + +replay_top: + $(PRINTF) "%s" "[tcpreplay] Topspeed test: " + $(PRINTF) "%s\n" "*** [tcpreplay] Topspeed test: " >>test.log + $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -t test.pcap >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +replay_precache: + $(PRINTF) "%s" "[tcpreplay] Precache test: " + $(PRINTF) "%s\n" "*** [tcpreplay] Precache test: " >>test.log + $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) --preload-pcap test.pcap >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +datadump_mode: + $(PRINTF) "%s" "[tcpreplay] Data dump test: " + $(PRINTF) "%s\n" "*** [tcpreplay] Data dump mode test: " >>test.log + $(TCPREPLAY) $(ENABLE_DEBUG) -D -i $(nic1) -j $(nic2) -w primary.data -W secondary.data -c test.cidr -R test.pcap >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +replay_config: + $(PRINTF) "%s" "[tcpreplay] Config file/VLAN add test: " + $(PRINTF) "%s\n" "*** [tcpreplay] Config file/VLAN add test: " >>test.log + $(TCPREPLAY) $(ENABLE_DEBUG) --load-opts=config test.pcap >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + +clean: + rm -f *1 test.log core* *~ primary.data secondary.data + +distclean: clean + rm -f Makefile config + +maintainer-clean: distclean diff --git a/test/Makefile.in b/test/Makefile.in new file mode 100644 index 0000000..ea598ee --- /dev/null +++ b/test/Makefile.in @@ -0,0 +1,868 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = test +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(srcdir)/config.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/src/config.h +CONFIG_CLEAN_FILES = config +CONFIG_CLEAN_VPATH_FILES = +SOURCES = +DIST_SOURCES = +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOGEN = @AUTOGEN@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CUT = @CUT@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DMALLOC_LIB = @DMALLOC_LIB@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +GROFF = @GROFF@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LDNETINC = @LDNETINC@ +LDNETLIB = @LDNETLIB@ +LIBOBJS = @LIBOBJS@ +LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@ +LIBOPTS_DIR = @LIBOPTS_DIR@ +LIBOPTS_LDADD = @LIBOPTS_LDADD@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LNAVLIB = @LNAVLIB@ +LNAV_CFLAGS = @LNAV_CFLAGS@ +LN_S = @LN_S@ +LPCAPINC = @LPCAPINC@ +LPCAPLIB = @LPCAPLIB@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PCAP_BPF_H_FILE = @PCAP_BPF_H_FILE@ +PRINTF = @PRINTF@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TCPREPLAY_RELEASE = @TCPREPLAY_RELEASE@ +TCPREPLAY_VERSION = @TCPREPLAY_VERSION@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +debug_flag = @debug_flag@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +nic1 = @nic1@ +nic2 = @nic2@ +oldincludedir = @oldincludedir@ +pcncfg = @pcncfg@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +tcpdump_path = @tcpdump_path@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ + +# $Id$ +MAKEFLAGS = -s -k +HOST = @host@ +TARGET = @target@ +BUILD = @build@ +ENABLE_DEBUG = @debug_flag@ +TCPPREP = ../src/tcpprep --no-arg-comment +TCPREPLAY = ../src/tcpreplay +TCPREWRITE = ../src/tcprewrite +TCPBRIDGE = ../src/tcpbridge +EXTRA_DIST = test.pcap test.auto_bridge test.auto_client test.auto_router \ + test.auto_server test.auto_first test.cidr test.comment test.port test.mac \ + test.cidr_reverse test.mac_reverse test.regex_reverse \ + test.prep_config test.primary test.regex test.secondary \ + test.rewrite_seed test.rewrite_portmap test.rewrite_endpoint \ + test.rewrite_pnat test.rewrite_pad test.rewrite_trunc \ + test.rewrite_mac test.rewrite_layer2 test.rewrite_config \ + test.rewrite_skip test.rewrite_dltuser test.rewrite_dlthdlc \ + test.rewrite_vlandel test.rewrite_efcs test.rewrite_1ttl \ + test.rewrite_2ttl test.rewrite_3ttl \ + test2.rewrite_seed test2.rewrite_portmap test2.rewrite_endpoint \ + test2.rewrite_pnat test2.rewrite_pad test2.rewrite_trunc \ + test2.rewrite_mac test2.rewrite_layer2 test2.rewrite_config \ + test2.rewrite_skip test2.rewrite_dltuser test2.rewrite_dlthdlc \ + test2.rewrite_vlandel test2.rewrite_efcs test2.rewrite_1ttl \ + test2.rewrite_mtutrunc \ + test2.rewrite_2ttl test2.rewrite_3ttl test.rewrite_tos test2.rewrite_tos + +@WORDS_BIGENDIAN_FALSE@STANDARD_REWRITE = standard_littleendian +@WORDS_BIGENDIAN_TRUE@STANDARD_REWRITE = standard_bigendian +@WORDS_BIGENDIAN_FALSE@REWRITE_WARN = "little" +@WORDS_BIGENDIAN_TRUE@REWRITE_WARN = "big" +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu test/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *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);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +config: $(top_builddir)/config.status $(srcdir)/config.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + distclean distclean-generic distclean-libtool 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-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am + + +test: all +all: clearlog check tcpprep tcpreplay tcprewrite + +clearlog: + -rm test.log + +check: + $(PRINTF) "%s\n" "NOTICE: Tests must be run as root" + $(PRINTF) "%s\n" "Sending traffic on '$(nic1)' and '$(nic2)'" + +standard: standard_prep $(STANDARD_REWRITE) + $(PRINTF) "Warning: only creating %s endian standard test files\n" $(REWRITE_WARN) + +standard_prep: + $(TCPPREP) -i test.pcap -o test.auto_router -a router + $(TCPPREP) -i test.pcap -o test.auto_bridge -a bridge + $(TCPPREP) -i test.pcap -o test.auto_client -a client + $(TCPPREP) -i test.pcap -o test.auto_server -a server + $(TCPPREP) -i test.pcap -o test.auto_first -a first + $(TCPPREP) --load-opts config -o test.prep_config + $(TCPPREP) -i test.pcap -o test.port -p + $(TCPPREP) -i test.pcap -o test.mac -e 00:02:3b:00:3d:ce + $(TCPPREP) -i test.pcap -o test.cidr -c '216.27.178.0/24' + $(TCPPREP) -i test.pcap -o test.regex -r '216.27.178.*' + $(TCPPREP) -i test.pcap -o test.comment -C "This is a comment" -p + $(TCPPREP) -i test.pcap -o test.mac_reverse -e 00:02:3b:00:3d:ce --reverse + $(TCPPREP) -i test.pcap -o test.cidr_reverse -c '216.27.178.0/24' --reverse + $(TCPPREP) -i test.pcap -o test.regex_reverse -r '216.27.178.*' --reverse + +standard_bigendian: + $(TCPREWRITE) -i test.pcap -o test.rewrite_seed -s 55 + $(TCPREWRITE) -i test.pcap -o test.rewrite_tos --tos=50 + $(TCPREWRITE) -i test.pcap -o test.rewrite_portmap -r 80:8080 + $(TCPREWRITE) -i test.pcap -o test.rewrite_endpoint \ + -e 10.10.0.1:10.10.0.2 -c test.auto_router + $(TCPREWRITE) -i test.pcap -o test.rewrite_pnat \ + -N 216.27.178.0/24:172.16.0.0/24 + $(TCPREWRITE) -i test.pcap -o test.rewrite_pad -F pad + $(TCPREWRITE) -i test.pcap -o test.rewrite_trunc -F trunc + $(TCPREWRITE) -i test.pcap -o test.rewrite_mac \ + --enet-dmac=00:12:13:14:15:16,00:22:33:44:55:66 \ + --enet-smac=00:22:33:44:55:66,00:12:13:14:15:16 -c test.auto_router + $(TCPREWRITE) -i test.pcap -o test.rewrite_layer2 \ + --dlt=user --user-dlink=00,50,da,5d,46,55,0,7,eb,30,a4,c3,08,0 + $(TCPREWRITE) -i test.pcap -o test.rewrite_config --enet-vlan=add --enet-vlan-tag=45 \ + --enet-vlan-cfi=1 --enet-vlan-pri=5 + $(TCPREWRITE) -i test.pcap -o test.rewrite_skip -b -s 55 \ + --enet-dmac=00:12:13:14:15:16,00:22:33:44:55:66 \ + --enet-smac=00:22:33:44:55:66,00:12:13:14:15:16 -c test.auto_router + $(TCPREWRITE) -i test.pcap -o test.rewrite_dltuser --dlt=user \ + --user-dlink=0x0f,0x00,0x08,0x00 --user-dlt=104 + $(TCPREWRITE) -i test.pcap -o test.rewrite_dlthdlc --dlt=hdlc \ + --hdlc-control=0 --hdlc-address=0x0F + $(TCPREWRITE) -i test.rewrite_config -o test.rewrite_vlandel \ + --enet-vlan=del + $(TCPREWRITE) -i test.pcap -o test.rewrite_efcs --efcs + $(TCPREWRITE) -i test.pcap -o test.rewrite_1ttl --ttl=58 + $(TCPREWRITE) -i test.pcap -o test.rewrite_2ttl --ttl=+58 + $(TCPREWRITE) -i test.pcap -o test.rewrite_3ttl --ttl=-58 + +standard_littleendian: + $(TCPREWRITE) -i test.pcap -o test2.rewrite_seed -s 55 + $(TCPREWRITE) -i test.pcap -o test2.rewrite_tos --tos=50 + $(TCPREWRITE) -i test.pcap -o test2.rewrite_portmap -r 80:8080 + $(TCPREWRITE) -i test.pcap -o test2.rewrite_endpoint \ + -e 10.10.0.1:10.10.0.2 -c test.auto_router + $(TCPREWRITE) -i test.pcap -o test2.rewrite_pnat \ + -N 216.27.178.0/24:172.16.0.0/24 + $(TCPREWRITE) -i test.pcap -o test2.rewrite_pad -F pad + $(TCPREWRITE) -i test.pcap -o test2.rewrite_trunc -F trunc + $(TCPREWRITE) -i test.pcap -o test2.rewrite_mac \ + --enet-dmac=00:12:13:14:15:16,00:22:33:44:55:66 \ + --enet-smac=00:22:33:44:55:66,00:12:13:14:15:16 -c test.auto_router + $(TCPREWRITE) -i test.pcap -o test2.rewrite_layer2 \ + --dlt=user --user-dlink=00,50,da,5d,46,55,0,7,eb,30,a4,c3,08,0 + $(TCPREWRITE) -i test.pcap -o test2.rewrite_config --enet-vlan=add --enet-vlan-tag=45 \ + --enet-vlan-cfi=1 --enet-vlan-pri=5 + $(TCPREWRITE) -i test.pcap -o test2.rewrite_skip -b -s 55 \ + --enet-dmac=00:12:13:14:15:16,00:22:33:44:55:66 \ + --enet-smac=00:22:33:44:55:66,00:12:13:14:15:16 -c test.auto_router + $(TCPREWRITE) -i test.pcap -o test2.rewrite_dltuser --dlt=user \ + --user-dlink=0x0f,0x00,0x08,0x00 --user-dlt=104 + $(TCPREWRITE) -i test.pcap -o test2.rewrite_dlthdlc --dlt=hdlc \ + --hdlc-control=0 --hdlc-address=0x0F + $(TCPREWRITE) -i test.rewrite_config -o test2.rewrite_vlandel \ + --enet-vlan=del + $(TCPREWRITE) -i test.pcap -o test2.rewrite_efcs --efcs + $(TCPREWRITE) -i test.pcap -o test2.rewrite_1ttl --ttl=58 + $(TCPREWRITE) -i test.pcap -o test2.rewrite_2ttl --ttl=+58 + $(TCPREWRITE) -i test.pcap -o test2.rewrite_3ttl --ttl=-58 + $(TCPREWRITE) -i test.pcap -o test2.rewrite_mtutrunc --mtu-trunc --mtu=300 + +tcpprep: auto_router auto_bridge auto_client auto_server auto_first cidr regex \ + port mac comment print_info print_comment prep_config \ + mac_reverse cidr_reverse regex_reverse + +tcprewrite: rewrite_portmap rewrite_endpoint rewrite_pnat rewrite_trunc \ + rewrite_pad rewrite_seed rewrite_mac rewrite_layer2 rewrite_config \ + rewrite_skip rewrite_dltuser rewrite_dlthdlc rewrite_vlandel rewrite_efcs \ + rewrite_1ttl rewrite_2ttl rewrite_3ttl rewrite_tos rewrite_mtutrunc + +tcpreplay: replay_basic replay_cache replay_pps replay_rate replay_top \ + replay_config replay_multi replay_pps_multi replay_precache \ + replay_stats + +prep_config: + $(PRINTF) "%s" "[tcpprep] Config mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] Config mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) --load-opts=config -o test.$@1 >>test.log 2>&1 + diff test.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +auto_router: + $(PRINTF) "%s" "[tcpprep] Auto/Router mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] Auto/Router mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a router >>test.log 2>&1 + diff test.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + +auto_bridge: + $(PRINTF) "%s" "[tcpprep] Auto/Bridge mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] Auto/Bridge mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a bridge >>test.log 2>&1 + diff test.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + +auto_client: + $(PRINTF) "%s" "[tcpprep] Auto/Client mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] Auto/Client mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a client >>test.log 2>&1 + diff test.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + +auto_server: + $(PRINTF) "%s" "[tcpprep] Auto/Server mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] Auto/Server mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a server >>test.log 2>&1 + diff test.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + +auto_first: + $(PRINTF) "%s" "[tcpprep] Auto/First mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] Auto/First mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -a first >>test.log 2>&1 + diff test.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + +regex: + $(PRINTF) "%s" "[tcpprep] Regex mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] Regex mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -r '216.27.178.*' >>test.log 2>&1 + diff test.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +cidr: + $(PRINTF) "%s" "[tcpprep] CIDR mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] CIDR mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -c '216.27.178.0/24' >>test.log 2>&1 + diff test.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +port: + $(PRINTF) "%s" "[tcpprep] Port mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] Port mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -p >>test.log 2>&1 + diff test.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +mac: + $(PRINTF) "%s" "[tcpprep] MAC mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] MAC mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -e 00:02:3b:00:3d:ce >>test.log 2>&1 + diff test.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +comment: + $(PRINTF) "%s" "[tcpprep] Comment mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] Comment mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -C "This is a comment" -p >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +print_comment: + $(PRINTF) "%s" "[tcpprep] Print comment mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] Print comment mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -P test.comment >test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + +print_info: + $(PRINTF) "%s" "[tcpprep] Print info mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] Print info mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -I test.comment >test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + +regex_reverse: + $(PRINTF) "%s" "[tcpprep] Regex reverse mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] Regex reverse mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -r '216.27.178.*' --reverse >>test.log 2>&1 + diff test.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + +cidr_reverse: + $(PRINTF) "%s" "[tcpprep] CIDR reverse mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] CIDR reverse mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -c '216.27.178.0/24' --reverse >>test.log 2>&1 + diff test.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + +mac_reverse: + $(PRINTF) "%s" "[tcpprep] MAC reverse mode test: " + $(PRINTF) "%s\n" "*** [tcpprep] MAC reverse mode test: " >>test.log + $(TCPPREP) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 -e 00:02:3b:00:3d:ce --reverse >>test.log 2>&1 + diff test.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + +replay_basic: + $(PRINTF) "%s" "[tcpreplay] Basic test: " + $(PRINTF) "%s\n" "*** [tcpreplay] Basic test: " >>test.log + $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -t test.pcap >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +replay_cache: + $(PRINTF) "%s" "[tcpreplay] Cache test: " + $(PRINTF) "%s\n" "*** [tcpreplay] Cache test: " >>test.log + $(TCPREPLAY) $(ENABLE_DEBUG) -c test.cidr -i $(nic1) -I $(nic2) -t test.pcap >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +replay_accurate: + $(PRINTF) "%s" "[tcpreplay] Accurate test: " + $(PRINTF) "%s\n" "*** [tcpreplay] Accurate test: " >>test.log + $(TCPREPLAY) $(ENABLE_DEBUG) -a -i $(nic1) test.pcap >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +replay_stats: + $(PRINTF) "%s" "[tcpreplay] Statistics test: " + $(PRINTF) "%s\n" "*** [tcpreplay] Statistics test: " >>test.log + $(TCPREPLAY) $(ENABLE_DEBUG) --stats=1 -i $(nic1) test.pcap >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_portmap: + $(PRINTF) "%s" "[tcprewrite] Portmap test: " + $(PRINTF) "%s\n" "*** [tcprewrite] Portmap test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_portmap1 -r 80:8080 >>test.log 2>&1 +@WORDS_BIGENDIAN_TRUE@ diff test.$@ test.$@1 >>test.log 2>&1 +@WORDS_BIGENDIAN_FALSE@ diff test2.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_endpoint: + $(PRINTF) "%s" "[tcprewrite] Endpoint test: " + $(PRINTF) "%s\n" "*** [tcprewrite] Endpoint test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_endpoint1 -e 10.10.0.1:10.10.0.2 \ + -c test.auto_router >>test.log 2>&1 +@WORDS_BIGENDIAN_TRUE@ diff test.$@ test.$@1 >>test.log 2>&1 +@WORDS_BIGENDIAN_FALSE@ diff test2.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_pnat: + $(PRINTF) "%s" "[tcprewrite] Pseudo NAT test: " + $(PRINTF) "%s\n" "*** [tcprewrite] Pseudo NAT test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_pnat1 \ + -N 216.27.178.0/24:172.16.0.0/24 >>test.log 2>&1 +@WORDS_BIGENDIAN_TRUE@ diff test.$@ test.$@1 >>test.log 2>&1 +@WORDS_BIGENDIAN_FALSE@ diff test2.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_mac: + $(PRINTF) "%s" "[tcprewrite] Src/Dst MAC test: " + $(PRINTF) "%s\n" "*** [tcprewrite] Src/Dst MAC test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_mac1 \ + --enet-dmac=00:12:13:14:15:16,00:22:33:44:55:66 \ + --enet-smac=00:22:33:44:55:66,00:12:13:14:15:16 -c test.auto_router >>test.log 2>&1 +@WORDS_BIGENDIAN_TRUE@ diff test.$@ test.$@1 >>test.log 2>&1 +@WORDS_BIGENDIAN_FALSE@ diff test2.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_trunc: + $(PRINTF) "%s" "[tcprewrite] Truncate test: " + $(PRINTF) "%s\n" "*** [tcprewrite] Truncate test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -F trunc -i test.pcap -o test.rewrite_trunc1 >>test.log 2>&1 +@WORDS_BIGENDIAN_TRUE@ diff test.$@ test.$@1 >>test.log 2>&1 +@WORDS_BIGENDIAN_FALSE@ diff test2.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_pad: + $(PRINTF) "%s" "[tcprewrite] Pad test: " + $(PRINTF) "%s\n" "*** [tcprewrite] Pad test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -F pad -i test.pcap -o test.rewrite_pad1 >>test.log 2>&1 +@WORDS_BIGENDIAN_TRUE@ diff test.$@ test.$@1 >>test.log 2>&1 +@WORDS_BIGENDIAN_FALSE@ diff test2.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t\t%s\n" "OK"; fi + +rewrite_seed: + $(PRINTF) "%s" "[tcprewrite] Seed IP test: " + $(PRINTF) "%s\n" "*** [tcprewrite] Seed IP test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_seed1 -s 55 >>test.log 2>&1 +@WORDS_BIGENDIAN_TRUE@ diff test.$@ test.$@1 >>test.log 2>&1 +@WORDS_BIGENDIAN_FALSE@ diff test2.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_layer2: + $(PRINTF) "%s" "[tcprewrite] Layer2 test: " + $(PRINTF) "%s\n" "*** [tcprewrite] Layer2 test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) --dlt=user --user-dlink=00,50,da,5d,46,55,0,7,eb,30,a4,c3,08,0 \ + -i test.pcap -o test.rewrite_layer21 >>test.log 2>&1 +@WORDS_BIGENDIAN_TRUE@ diff test.$@ test.$@1 >>test.log 2>&1 +@WORDS_BIGENDIAN_FALSE@ diff test2.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_config: + $(PRINTF) "%s" "[tcprewrite] Config/VLAN Add test: " + $(PRINTF) "%s\n" "*** [tcprewrite] Config/VLAN Add test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) --load-opts config >>test.log 2>&1 +@WORDS_BIGENDIAN_TRUE@ diff test.$@ test.$@1 >>test.log 2>&1 +@WORDS_BIGENDIAN_FALSE@ diff test2.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + +rewrite_skip: + $(PRINTF) "%s" "[tcprewrite] Skip bcast test: " + $(PRINTF) "%s\n" "*** [tcprewrite] Skip bcast test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_skip1 -b -s 55 \ + --enet-dmac=00:12:13:14:15:16,00:22:33:44:55:66 \ + --enet-smac=00:22:33:44:55:66,00:12:13:14:15:16 -c test.auto_router >>test.log 2>&1 +@WORDS_BIGENDIAN_TRUE@ diff test.$@ test.$@1 >>test.log 2>&1 +@WORDS_BIGENDIAN_FALSE@ diff test2.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_dltuser: + $(PRINTF) "%s" "[tcprewrite] DLT User test: " + $(PRINTF) "%s\n" "*** [tcprewrite] DLT User test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_dltuser1 --dlt=user \ + --user-dlink=0x0f,0x00,0x08,0x00 --user-dlt=104 >>test.log 2>&1 +@WORDS_BIGENDIAN_TRUE@ diff test.$@ test.$@1 >>test.log 2>&1 +@WORDS_BIGENDIAN_FALSE@ diff test2.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_dlthdlc: + $(PRINTF) "%s" "[tcprewrite] DLT Cisco HDLC test: " + $(PRINTF) "%s\n" "*** [tcprewrite] DLT Cisco HDLC test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_dlthdlc1 --dlt=hdlc \ + --hdlc-control=0 --hdlc-address=0x0F >>test.log 2>&1 +@WORDS_BIGENDIAN_TRUE@ diff test.$@ test.$@1 >>test.log 2>&1 +@WORDS_BIGENDIAN_FALSE@ diff test2.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + +rewrite_vlandel: + $(PRINTF) "%s" "[tcprewrite] VLAN Delete test: " + $(PRINTF) "%s\n" "*** [tcprewrite] VLAN Delete test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.rewrite_config -o test.rewrite_vlandel1 \ + --enet-vlan=del >>test.log 2>&1 +@WORDS_BIGENDIAN_TRUE@ diff test.$@ test.$@1 >>test.log 2>&1 +@WORDS_BIGENDIAN_FALSE@ diff test2.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_efcs: + $(PRINTF) "%s" "[tcprewrite] Remove EFCS: " + $(PRINTF) "%s\n" "*** [tcprewrite] Remove EFCS: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.rewrite_efcs1 --efcs >>test.log 2>&1 +@WORDS_BIGENDIAN_TRUE@ diff test.$@ test.$@1 >>test.log 2>&1 +@WORDS_BIGENDIAN_FALSE@ diff test2.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_1ttl: + $(PRINTF) "%s" "[tcprewrite] Force TTL: " + $(PRINTF) "%s\n" "*** [tcprewrite] Force TTL: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 --ttl=58 >>test.log 2>&1 +@WORDS_BIGENDIAN_TRUE@ diff test.$@ test.$@1 >>test.log 2>&1 +@WORDS_BIGENDIAN_FALSE@ diff test2.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_2ttl: + $(PRINTF) "%s" "[tcprewrite] Increase TTL: " + $(PRINTF) "%s\n" "*** [tcprewrite] Increase TTL: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 --ttl=+58 >>test.log 2>&1 +@WORDS_BIGENDIAN_TRUE@ diff test.$@ test.$@1 >>test.log 2>&1 +@WORDS_BIGENDIAN_FALSE@ diff test2.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_3ttl: + $(PRINTF) "%s" "[tcprewrite] Reduce TTL: " + $(PRINTF) "%s\n" "*** [tcprewrite] Reduce TTL: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 --ttl=-58 >>test.log 2>&1 +@WORDS_BIGENDIAN_TRUE@ diff test.$@ test.$@1 >>test.log 2>&1 +@WORDS_BIGENDIAN_FALSE@ diff test2.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +rewrite_tos: + $(PRINTF) "%s" "[tcprewrite] TOS test: " + $(PRINTF) "%s\n" "*** [tcprewrite] TOS test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 --tos=50 >>test.log 2>&1 +@WORDS_BIGENDIAN_TRUE@ diff test.$@ test.$@1 >>test.log 2>&1 +@WORDS_BIGENDIAN_FALSE@ diff test2.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t\t%s\n" "OK"; fi + +rewrite_mtutrunc: + $(PRINTF) "%s" "[tcprewrite] MTU Truncate test: " + $(PRINTF) "%s\n" "*** [tcprewrite] MTU Truncate test: " >>test.log + $(TCPREWRITE) $(ENABLE_DEBUG) -i test.pcap -o test.$@1 --mtu-trunc --mtu=300 >>test.log 2>&1 +@WORDS_BIGENDIAN_TRUE@ diff test.$@ test.$@1 >>test.log 2>&1 +@WORDS_BIGENDIAN_FALSE@ diff test2.$@ test.$@1 >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + +replay_pps: + $(PRINTF) "%s" "[tcpreplay] Packets/sec test: " + $(PRINTF) "%s\n" "*** [tcpreplay] Packets/sec test: " >>test.log + $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -p 25 test.pcap >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +replay_rate: + $(PRINTF) "%s" "[tcpreplay] Mbps test: " + $(PRINTF) "%s\n" "*** [tcpreplay] Mbps test: " >>test.log + $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -M 25.0 test.pcap >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t\t%s\n" "OK"; fi + +replay_multi: + $(PRINTF) "%s" "[tcpreplay] Multiplier test: " + $(PRINTF) "%s\n" "*** [tcpreplay] Multiplier test: " >>test.log + $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -x 25.0 test.pcap >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +replay_pps_multi: + $(PRINTF) "%s" "[tcpreplay] Packets/sec Multiplier test: " + $(PRINTF) "%s\n" "*** [tcpreplay] Packets/sec Multiplier test: " >>test.log + $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -p 100 --pps-multi=5 test.pcap >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t%s\n" "FAILED"; else $(PRINTF) "\t%s\n" "OK"; fi + +replay_top: + $(PRINTF) "%s" "[tcpreplay] Topspeed test: " + $(PRINTF) "%s\n" "*** [tcpreplay] Topspeed test: " >>test.log + $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) -t test.pcap >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +replay_precache: + $(PRINTF) "%s" "[tcpreplay] Precache test: " + $(PRINTF) "%s\n" "*** [tcpreplay] Precache test: " >>test.log + $(TCPREPLAY) $(ENABLE_DEBUG) -i $(nic1) --preload-pcap test.pcap >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +datadump_mode: + $(PRINTF) "%s" "[tcpreplay] Data dump test: " + $(PRINTF) "%s\n" "*** [tcpreplay] Data dump mode test: " >>test.log + $(TCPREPLAY) $(ENABLE_DEBUG) -D -i $(nic1) -j $(nic2) -w primary.data -W secondary.data -c test.cidr -R test.pcap >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t\t%s\n" "OK"; fi + +replay_config: + $(PRINTF) "%s" "[tcpreplay] Config file/VLAN add test: " + $(PRINTF) "%s\n" "*** [tcpreplay] Config file/VLAN add test: " >>test.log + $(TCPREPLAY) $(ENABLE_DEBUG) --load-opts=config test.pcap >>test.log 2>&1 + if [ $? ] ; then $(PRINTF) "\t\t%s\n" "FAILED"; else $(PRINTF) "\t\t%s\n" "OK"; fi + +clean: + rm -f *1 test.log core* *~ primary.data secondary.data + +distclean: clean + rm -f Makefile config + +maintainer-clean: distclean + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/test/config.in b/test/config.in new file mode 100644 index 0000000..b5ce8a2 --- /dev/null +++ b/test/config.in @@ -0,0 +1,27 @@ +# tcpreplay - Replay network traffic stored in pcap files +# preset/initialization file +# Mon Jan 10 15:19:55 2005 +# +[TCPREPLAY] +cachefile test.auto_bridge +intf1 @nic1@ +intf2 @nic2@ +topspeed + +[TCPREWRITE] +infile test.pcap +outfile test.rewrite_config1 +cachefile test.auto_bridge +enet-vlan add +enet-vlan-tag 45 +enet-vlan-cfi 1 +enet-vlan-pri 5 + +[TCPPREP] +pcap test.pcap +auto bridge +minmask 31 +maxmask 16 +nonip +comment "This file was generated via the config file" + diff --git a/test/test.auto_bridge b/test/test.auto_bridge new file mode 100644 index 0000000..7f7f0a6 Binary files /dev/null and b/test/test.auto_bridge differ diff --git a/test/test.auto_client b/test/test.auto_client new file mode 100644 index 0000000..7f7f0a6 Binary files /dev/null and b/test/test.auto_client differ diff --git a/test/test.auto_first b/test/test.auto_first new file mode 100644 index 0000000..7f7f0a6 Binary files /dev/null and b/test/test.auto_first differ diff --git a/test/test.auto_router b/test/test.auto_router new file mode 100644 index 0000000..7f7f0a6 Binary files /dev/null and b/test/test.auto_router differ diff --git a/test/test.auto_server b/test/test.auto_server new file mode 100644 index 0000000..7f7f0a6 Binary files /dev/null and b/test/test.auto_server differ diff --git a/test/test.cidr b/test/test.cidr new file mode 100644 index 0000000..4f5e08c Binary files /dev/null and b/test/test.cidr differ diff --git a/test/test.cidr_reverse b/test/test.cidr_reverse new file mode 100644 index 0000000..7f7f0a6 Binary files /dev/null and b/test/test.cidr_reverse differ diff --git a/test/test.comment b/test/test.comment new file mode 100644 index 0000000..04d4997 Binary files /dev/null and b/test/test.comment differ diff --git a/test/test.mac b/test/test.mac new file mode 100644 index 0000000..6e5894f Binary files /dev/null and b/test/test.mac differ diff --git a/test/test.mac_reverse b/test/test.mac_reverse new file mode 100644 index 0000000..d0df1af Binary files /dev/null and b/test/test.mac_reverse differ diff --git a/test/test.pcap b/test/test.pcap new file mode 100644 index 0000000..886a2b3 Binary files /dev/null and b/test/test.pcap differ diff --git a/test/test.port b/test/test.port new file mode 100644 index 0000000..4f5e08c Binary files /dev/null and b/test/test.port differ diff --git a/test/test.prep_config b/test/test.prep_config new file mode 100644 index 0000000..d7e0ee6 Binary files /dev/null and b/test/test.prep_config differ diff --git a/test/test.primary b/test/test.primary new file mode 100644 index 0000000..2d1da11 Binary files /dev/null and b/test/test.primary differ diff --git a/test/test.regex b/test/test.regex new file mode 100644 index 0000000..4f5e08c Binary files /dev/null and b/test/test.regex differ diff --git a/test/test.regex_reverse b/test/test.regex_reverse new file mode 100644 index 0000000..2823e97 Binary files /dev/null and b/test/test.regex_reverse differ diff --git a/test/test.rewrite_1ttl b/test/test.rewrite_1ttl new file mode 100644 index 0000000..b389d55 Binary files /dev/null and b/test/test.rewrite_1ttl differ diff --git a/test/test.rewrite_2ttl b/test/test.rewrite_2ttl new file mode 100644 index 0000000..24d59ca Binary files /dev/null and b/test/test.rewrite_2ttl differ diff --git a/test/test.rewrite_3ttl b/test/test.rewrite_3ttl new file mode 100644 index 0000000..904a0cb Binary files /dev/null and b/test/test.rewrite_3ttl differ diff --git a/test/test.rewrite_config b/test/test.rewrite_config new file mode 100644 index 0000000..80b162b Binary files /dev/null and b/test/test.rewrite_config differ diff --git a/test/test.rewrite_dlthdlc b/test/test.rewrite_dlthdlc new file mode 100644 index 0000000..f19d531 Binary files /dev/null and b/test/test.rewrite_dlthdlc differ diff --git a/test/test.rewrite_dltuser b/test/test.rewrite_dltuser new file mode 100644 index 0000000..8db4102 Binary files /dev/null and b/test/test.rewrite_dltuser differ diff --git a/test/test.rewrite_efcs b/test/test.rewrite_efcs new file mode 100644 index 0000000..18acbd1 Binary files /dev/null and b/test/test.rewrite_efcs differ diff --git a/test/test.rewrite_endpoint b/test/test.rewrite_endpoint new file mode 100644 index 0000000..cf08a9f Binary files /dev/null and b/test/test.rewrite_endpoint differ diff --git a/test/test.rewrite_layer2 b/test/test.rewrite_layer2 new file mode 100644 index 0000000..1016a16 Binary files /dev/null and b/test/test.rewrite_layer2 differ diff --git a/test/test.rewrite_mac b/test/test.rewrite_mac new file mode 100644 index 0000000..18ed3b4 Binary files /dev/null and b/test/test.rewrite_mac differ diff --git a/test/test.rewrite_pad b/test/test.rewrite_pad new file mode 100644 index 0000000..01e4831 Binary files /dev/null and b/test/test.rewrite_pad differ diff --git a/test/test.rewrite_pnat b/test/test.rewrite_pnat new file mode 100644 index 0000000..9f6dd86 Binary files /dev/null and b/test/test.rewrite_pnat differ diff --git a/test/test.rewrite_portmap b/test/test.rewrite_portmap new file mode 100644 index 0000000..4562188 Binary files /dev/null and b/test/test.rewrite_portmap differ diff --git a/test/test.rewrite_seed b/test/test.rewrite_seed new file mode 100644 index 0000000..b19582e Binary files /dev/null and b/test/test.rewrite_seed differ diff --git a/test/test.rewrite_skip b/test/test.rewrite_skip new file mode 100644 index 0000000..9de85ec Binary files /dev/null and b/test/test.rewrite_skip differ diff --git a/test/test.rewrite_tos b/test/test.rewrite_tos new file mode 100644 index 0000000..44a39cb Binary files /dev/null and b/test/test.rewrite_tos differ diff --git a/test/test.rewrite_trunc b/test/test.rewrite_trunc new file mode 100644 index 0000000..6d3a7df Binary files /dev/null and b/test/test.rewrite_trunc differ diff --git a/test/test.rewrite_vlandel b/test/test.rewrite_vlandel new file mode 100644 index 0000000..ccdb6b3 Binary files /dev/null and b/test/test.rewrite_vlandel differ diff --git a/test/test.secondary b/test/test.secondary new file mode 100644 index 0000000..d7b4c21 Binary files /dev/null and b/test/test.secondary differ diff --git a/test/test2.rewrite_1ttl b/test/test2.rewrite_1ttl new file mode 100644 index 0000000..1042330 Binary files /dev/null and b/test/test2.rewrite_1ttl differ diff --git a/test/test2.rewrite_2ttl b/test/test2.rewrite_2ttl new file mode 100644 index 0000000..57195f7 Binary files /dev/null and b/test/test2.rewrite_2ttl differ diff --git a/test/test2.rewrite_3ttl b/test/test2.rewrite_3ttl new file mode 100644 index 0000000..eb90da1 Binary files /dev/null and b/test/test2.rewrite_3ttl differ diff --git a/test/test2.rewrite_config b/test/test2.rewrite_config new file mode 100644 index 0000000..a7ad66b Binary files /dev/null and b/test/test2.rewrite_config differ diff --git a/test/test2.rewrite_dlthdlc b/test/test2.rewrite_dlthdlc new file mode 100644 index 0000000..7cf24a0 Binary files /dev/null and b/test/test2.rewrite_dlthdlc differ diff --git a/test/test2.rewrite_dltuser b/test/test2.rewrite_dltuser new file mode 100644 index 0000000..5f44978 Binary files /dev/null and b/test/test2.rewrite_dltuser differ diff --git a/test/test2.rewrite_efcs b/test/test2.rewrite_efcs new file mode 100644 index 0000000..73ebb57 Binary files /dev/null and b/test/test2.rewrite_efcs differ diff --git a/test/test2.rewrite_endpoint b/test/test2.rewrite_endpoint new file mode 100644 index 0000000..7115583 Binary files /dev/null and b/test/test2.rewrite_endpoint differ diff --git a/test/test2.rewrite_layer2 b/test/test2.rewrite_layer2 new file mode 100644 index 0000000..790694c Binary files /dev/null and b/test/test2.rewrite_layer2 differ diff --git a/test/test2.rewrite_mac b/test/test2.rewrite_mac new file mode 100644 index 0000000..8ccf07c Binary files /dev/null and b/test/test2.rewrite_mac differ diff --git a/test/test2.rewrite_mtutrunc b/test/test2.rewrite_mtutrunc new file mode 100644 index 0000000..3d5dfc2 Binary files /dev/null and b/test/test2.rewrite_mtutrunc differ diff --git a/test/test2.rewrite_pad b/test/test2.rewrite_pad new file mode 100644 index 0000000..6417675 Binary files /dev/null and b/test/test2.rewrite_pad differ diff --git a/test/test2.rewrite_pnat b/test/test2.rewrite_pnat new file mode 100644 index 0000000..5d52a00 Binary files /dev/null and b/test/test2.rewrite_pnat differ diff --git a/test/test2.rewrite_portmap b/test/test2.rewrite_portmap new file mode 100644 index 0000000..d7e12df Binary files /dev/null and b/test/test2.rewrite_portmap differ diff --git a/test/test2.rewrite_seed b/test/test2.rewrite_seed new file mode 100644 index 0000000..168f6d0 Binary files /dev/null and b/test/test2.rewrite_seed differ diff --git a/test/test2.rewrite_skip b/test/test2.rewrite_skip new file mode 100644 index 0000000..9d1030b Binary files /dev/null and b/test/test2.rewrite_skip differ diff --git a/test/test2.rewrite_tos b/test/test2.rewrite_tos new file mode 100644 index 0000000..94318ce Binary files /dev/null and b/test/test2.rewrite_tos differ diff --git a/test/test2.rewrite_trunc b/test/test2.rewrite_trunc new file mode 100644 index 0000000..0695e3b Binary files /dev/null and b/test/test2.rewrite_trunc differ diff --git a/test/test2.rewrite_vlandel b/test/test2.rewrite_vlandel new file mode 100644 index 0000000..e547ad3 Binary files /dev/null and b/test/test2.rewrite_vlandel differ